Other answers here may be better than this, but that was my solution to the problem. Be sure to try Emil's answer before using this.
What I have been doing since then was too slow to wait for it to check rssi, as it always changes. If there is a period of time, say, 3 seconds, when the value remains unchanged, it is disconnected from the device. It lasts 15 seconds and adds its own timeout.
This would be necessary to check the signal strength. It was written a couple of years ago, so some things may need to be changed.
private final BluetoothGattCallback mGattCallback = new BluetoothGattCallback() { @Override public void onReadRemoteRssi(BluetoothGatt gatt, int rssi, int status){
Somewhere in a loop, call
mBluetoothGatt.readRemoteRssi()
source share