diff options
| author | 2024-03-13 05:39:36 +0000 | |
|---|---|---|
| committer | 2024-03-13 05:39:36 +0000 | |
| commit | 385a7945b569d118f4d2a2f45ca6ffbaa7f34d2d (patch) | |
| tree | 92994cb23e5aaf66471e0bb1cddb4b8ac0664ec9 | |
| parent | 7ea8687ebbbe8b028cc123d59601cbe8ef9d00ad (diff) | |
| parent | 1f07e88880ee253818033e0c9da18c47537dc99e (diff) | |
Merge "[Audiosharing] Fix fallback device selection." into main
| -rw-r--r-- | packages/SettingsLib/src/com/android/settingslib/bluetooth/LocalBluetoothLeBroadcast.java | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/packages/SettingsLib/src/com/android/settingslib/bluetooth/LocalBluetoothLeBroadcast.java b/packages/SettingsLib/src/com/android/settingslib/bluetooth/LocalBluetoothLeBroadcast.java index bd27c896a3c4..1118efc3e953 100644 --- a/packages/SettingsLib/src/com/android/settingslib/bluetooth/LocalBluetoothLeBroadcast.java +++ b/packages/SettingsLib/src/com/android/settingslib/bluetooth/LocalBluetoothLeBroadcast.java @@ -81,11 +81,13 @@ public class LocalBluetoothLeBroadcast implements LocalBluetoothProfile { public static final int BROADCAST_STATE_UNKNOWN = 0; public static final int BROADCAST_STATE_ON = 1; public static final int BROADCAST_STATE_OFF = 2; + @Retention(RetentionPolicy.SOURCE) @IntDef( prefix = {"BROADCAST_STATE_"}, value = {BROADCAST_STATE_UNKNOWN, BROADCAST_STATE_ON, BROADCAST_STATE_OFF}) public @interface BroadcastState {} + private static final String SETTINGS_PKG = "com.android.settings"; private static final String TAG = "LocalBluetoothLeBroadcast"; private static final boolean DEBUG = BluetoothUtils.D; @@ -1068,7 +1070,7 @@ public class LocalBluetoothLeBroadcast implements LocalBluetoothProfile { return; } int fallbackActiveGroupId = getFallbackActiveGroupId(); - if (targetCachedDevice.getGroupId() == fallbackActiveGroupId) { + if (getGroupId(targetCachedDevice) == fallbackActiveGroupId) { Log.d( TAG, "Skip updateFallbackActiveDeviceIfNeeded, already is fallback: " @@ -1091,6 +1093,23 @@ public class LocalBluetoothLeBroadcast implements LocalBluetoothProfile { BluetoothCsipSetCoordinator.GROUP_ID_INVALID); } + private int getGroupId(CachedBluetoothDevice cachedDevice) { + int groupId = cachedDevice.getGroupId(); + String anonymizedAddress = cachedDevice.getDevice().getAnonymizedAddress(); + if (groupId != BluetoothCsipSetCoordinator.GROUP_ID_INVALID) { + Log.d(TAG, "getGroupId by CSIP profile for device: " + anonymizedAddress); + return groupId; + } + for (LocalBluetoothProfile profile : cachedDevice.getProfiles()) { + if (profile instanceof LeAudioProfile) { + Log.d(TAG, "getGroupId by LEA profile for device: " + anonymizedAddress); + return ((LeAudioProfile) profile).getGroupId(cachedDevice.getDevice()); + } + } + Log.d(TAG, "getGroupId return invalid id for device: " + anonymizedAddress); + return BluetoothCsipSetCoordinator.GROUP_ID_INVALID; + } + private void notifyBroadcastStateChange(@BroadcastState int state) { if (!mContext.getPackageName().equals(SETTINGS_PKG)) { Log.d(TAG, "Skip notifyBroadcastStateChange, not triggered by Settings."); |