Skip to content

Commit

Permalink
Merge pull request #3458 from richard-dennehy/bluetooth-disconnect-fix
Browse files Browse the repository at this point in the history
fix bluetooth device disconnection not being correctly detected
  • Loading branch information
jamorham authored May 12, 2024
2 parents 6367ca0 + 6b8787c commit e713834
Showing 1 changed file with 2 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,16 @@ public void onReceive(Context context, Intent intent) {
final int state = intent.getIntExtra(BluetoothHeadset.EXTRA_STATE, -1);
final int previousState = intent.getIntExtra(BluetoothHeadset.EXTRA_PREVIOUS_STATE, -1);
final String deviceInfo = device.getName() + "\n" + device.getAddress() + " " + (device.getBluetoothClass() != null ? device.getBluetoothClass() : "<unknown class>");
//UserError.Log.uel(TAG, "Bluetooth audio connection state change: " + state + " was " + previousState + " " + device.getAddress() + " " + device.getName());
// UserError.Log.uel(TAG, "Bluetooth audio connection state change: from " + previousState + " to " + state + " " + device.getAddress() + " " + device.getName());
if (state == BluetoothProfile.STATE_CONNECTED && previousState != BluetoothProfile.STATE_CONNECTED) {
PersistentStore.setString(PREF_LAST_CONNECTED_MAC, device.getAddress());
PersistentStore.setString(PREF_LAST_CONNECTED_NAME, device.getName());
UserError.Log.uel(TAG, "Bluetooth Audio connected: " + deviceInfo);
processDevice(device.getAddress(), true);

} else if (state == BluetoothProfile.STATE_DISCONNECTED && previousState == BluetoothProfile.STATE_CONNECTED) {
} else if (state == BluetoothProfile.STATE_DISCONNECTED && previousState != BluetoothProfile.STATE_DISCONNECTED) {
UserError.Log.uel(TAG, "Bluetooth Audio disconnected: " + deviceInfo);
processDevice(device.getAddress(), false);
}

} else {
UserError.Log.d(TAG, "Device was null in intent!");
}
Expand Down

0 comments on commit e713834

Please sign in to comment.