Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -648,6 +648,11 @@ public void onConnectionStateChange(BluetoothGatt gatt, int status, int newState
Peripheral.this.dispatchToCommandCallback("onConnectionStateChange",
() -> Peripheral.this.commandCallback.onConnectionStateChange(gatt, status, newState));
}
// Close it, or the client stays registered with Android and leaks.
if (newState == BluetoothGatt.STATE_DISCONNECTED && Peripheral.this.gatt == gatt) {
gatt.close();
Peripheral.this.gatt = null;
}
suppressDisconnectNotification = Peripheral.this.suppressDisconnectNotification;
// A failed connect closes the gatt and clears `connected` even if the state was CONNECTED.
nowConnected = Peripheral.this.connected;
Expand Down
Loading