Skip to content
Snippets Groups Projects
Commit 96e72b2b authored by Jakub Tyszkowski's avatar Jakub Tyszkowski Committed by Jack He
Browse files

BassClient: Reconnect devices in the background

Bug: 229965085
Bug: 150670922
Tag: #feature
Sponsor: jpawlowski@
Test: atest BluetoothInstrumentationTests
Change-Id: I5fdc54d0700741ef940e4263b2bc7839f7d7d638
(cherry picked from commit b084d6e1)
parent 58ffcb54
No related branches found
No related tags found
No related merge requests found
......@@ -996,6 +996,16 @@ public class BassClientStateMachine extends StateMachine {
} else {
broadcastConnectionState(
mDevice, mLastConnectionState, BluetoothProfile.STATE_DISCONNECTED);
if (mLastConnectionState != BluetoothProfile.STATE_DISCONNECTED) {
// Reconnect in background if not disallowed by the service
if (mService.okToConnect(mDevice)) {
mBluetoothGatt = mDevice.connectGatt(mService, true,
mGattCallback, BluetoothDevice.TRANSPORT_LE,
(BluetoothDevice.PHY_LE_1M_MASK
| BluetoothDevice.PHY_LE_2M_MASK
| BluetoothDevice.PHY_LE_CODED_MASK), null);
}
}
}
}
......@@ -1032,7 +1042,15 @@ public class BassClientStateMachine extends StateMachine {
}
break;
case DISCONNECT:
Log.w(TAG, "Disconnected: DISCONNECT ignored: " + mDevice);
// Disconnect if there's an ongoing background connection
if (mBluetoothGatt != null) {
log("Cancelling the background connection to " + mDevice);
mBluetoothGatt.disconnect();
mBluetoothGatt.close();
mBluetoothGatt = null;
} else {
Log.d(TAG, "Disconnected: DISCONNECT ignored: " + mDevice);
}
break;
case CONNECTION_STATE_CHANGED:
int state = (int) message.obj;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment