diff options
| -rw-r--r-- | packages/SettingsLib/src/com/android/settingslib/bluetooth/LocalBluetoothLeBroadcast.java | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/packages/SettingsLib/src/com/android/settingslib/bluetooth/LocalBluetoothLeBroadcast.java b/packages/SettingsLib/src/com/android/settingslib/bluetooth/LocalBluetoothLeBroadcast.java index 9df23aa2fe29..a6b1dd3ae578 100644 --- a/packages/SettingsLib/src/com/android/settingslib/bluetooth/LocalBluetoothLeBroadcast.java +++ b/packages/SettingsLib/src/com/android/settingslib/bluetooth/LocalBluetoothLeBroadcast.java @@ -292,7 +292,6 @@ public class LocalBluetoothLeBroadcast implements LocalBluetoothProfile { + ", sourceId = " + sourceId); } - updateFallbackActiveDeviceIfNeeded(); } @Override @@ -314,7 +313,18 @@ public class LocalBluetoothLeBroadcast implements LocalBluetoothProfile { public void onSourceAddFailed( @NonNull BluetoothDevice sink, @NonNull BluetoothLeBroadcastMetadata source, - int reason) {} + int reason) { + if (DEBUG) { + Log.d( + TAG, + "onSourceAddFailed(), sink = " + + sink + + ", reason = " + + reason + + ", source = " + + source); + } + } @Override public void onSourceModified( @@ -369,6 +379,9 @@ public class LocalBluetoothLeBroadcast implements LocalBluetoothProfile { + ", state = " + state); } + if (BluetoothUtils.isConnected(state)) { + updateFallbackActiveDeviceIfNeeded(); + } } }; @@ -1056,7 +1069,9 @@ public class LocalBluetoothLeBroadcast implements LocalBluetoothProfile { List<BluetoothLeBroadcastReceiveState> sourceList = mServiceBroadcastAssistant.getAllSources( bluetoothDevice); - return !sourceList.isEmpty(); + return !sourceList.isEmpty() + && sourceList.stream() + .anyMatch(BluetoothUtils::isConnected); }) .collect(Collectors.toList()); if (devicesInSharing.isEmpty()) { @@ -1091,7 +1106,8 @@ public class LocalBluetoothLeBroadcast implements LocalBluetoothProfile { return; } int fallbackActiveGroupId = getFallbackActiveGroupId(); - if (getGroupId(targetCachedDevice) == fallbackActiveGroupId) { + if (fallbackActiveGroupId != BluetoothCsipSetCoordinator.GROUP_ID_INVALID + && getGroupId(targetCachedDevice) == fallbackActiveGroupId) { Log.d( TAG, "Skip updateFallbackActiveDeviceIfNeeded, already is fallback: " @@ -1101,12 +1117,6 @@ public class LocalBluetoothLeBroadcast implements LocalBluetoothProfile { targetCachedDevice.setActive(); } - private boolean isDecryptedSource(BluetoothLeBroadcastReceiveState state) { - return state.getPaSyncState() == BluetoothLeBroadcastReceiveState.PA_SYNC_STATE_SYNCHRONIZED - && state.getBigEncryptionState() - == BluetoothLeBroadcastReceiveState.BIG_ENCRYPTION_STATE_DECRYPTING; - } - private int getFallbackActiveGroupId() { return Settings.Secure.getInt( mContext.getContentResolver(), |