diff options
author | 2025-02-10 01:46:43 -0800 | |
---|---|---|
committer | 2025-02-10 01:46:43 -0800 | |
commit | 28aae60c1521aa4df6853bb8c76dc5c1d5c297bd (patch) | |
tree | 1d5fa3ddfdcf1895ff915b5a510a5e65f5c16ad1 /packages/SettingsLib/src | |
parent | e018f198e06d765259c81791fbdb940c32f91ed9 (diff) | |
parent | b85941deaf2c5984484b20fe4de1d99e2bd9ff19 (diff) |
Merge "[Audiosharing] Sync temp bond state when CSIP grouping" into main
Diffstat (limited to 'packages/SettingsLib/src')
-rw-r--r-- | packages/SettingsLib/src/com/android/settingslib/bluetooth/CsipDeviceManager.java | 34 |
1 files changed, 26 insertions, 8 deletions
diff --git a/packages/SettingsLib/src/com/android/settingslib/bluetooth/CsipDeviceManager.java b/packages/SettingsLib/src/com/android/settingslib/bluetooth/CsipDeviceManager.java index bf86911ee683..572444edea29 100644 --- a/packages/SettingsLib/src/com/android/settingslib/bluetooth/CsipDeviceManager.java +++ b/packages/SettingsLib/src/com/android/settingslib/bluetooth/CsipDeviceManager.java @@ -30,11 +30,13 @@ import android.util.Log; import androidx.annotation.ChecksSdkIntAtLeast; import com.android.internal.annotations.VisibleForTesting; +import com.android.settingslib.flags.Flags; import java.util.ArrayList; import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.Set; import java.util.stream.Collectors; @@ -385,7 +387,7 @@ public class CsipDeviceManager { preferredMainDevice.refresh(); hasChanged = true; } - syncAudioSharingSourceIfNeeded(preferredMainDevice); + syncAudioSharingStatusIfNeeded(preferredMainDevice); } if (hasChanged) { log("addMemberDevicesIntoMainDevice: After changed, CachedBluetoothDevice list: " @@ -399,13 +401,16 @@ public class CsipDeviceManager { return userManager != null && userManager.isManagedProfile(); } - private void syncAudioSharingSourceIfNeeded(CachedBluetoothDevice mainDevice) { + private void syncAudioSharingStatusIfNeeded(CachedBluetoothDevice mainDevice) { boolean isAudioSharingEnabled = BluetoothUtils.isAudioSharingUIAvailable(mContext); - if (isAudioSharingEnabled) { + if (isAudioSharingEnabled && mainDevice != null) { if (isWorkProfile()) { - log("addMemberDevicesIntoMainDevice: skip sync source for work profile"); + log("addMemberDevicesIntoMainDevice: skip sync audio sharing status, work profile"); return; } + Set<CachedBluetoothDevice> deviceSet = new HashSet<>(); + deviceSet.add(mainDevice); + deviceSet.addAll(mainDevice.getMemberDevice()); boolean hasBroadcastSource = BluetoothUtils.isBroadcasting(mBtManager) && BluetoothUtils.hasConnectedBroadcastSource( mainDevice, mBtManager); @@ -419,9 +424,6 @@ public class CsipDeviceManager { if (metadata != null && assistant != null) { log("addMemberDevicesIntoMainDevice: sync audio sharing source after " + "combining the top level devices."); - Set<CachedBluetoothDevice> deviceSet = new HashSet<>(); - deviceSet.add(mainDevice); - deviceSet.addAll(mainDevice.getMemberDevice()); Set<BluetoothDevice> sinksToSync = deviceSet.stream() .map(CachedBluetoothDevice::getDevice) .filter(device -> @@ -435,8 +437,24 @@ public class CsipDeviceManager { } } } + if (Flags.enableTemporaryBondDevicesUi()) { + log("addMemberDevicesIntoMainDevice: sync temp bond metadata for audio sharing " + + "sinks after combining the top level devices."); + Set<BluetoothDevice> sinksToSync = deviceSet.stream() + .map(CachedBluetoothDevice::getDevice).filter(Objects::nonNull).collect( + Collectors.toSet()); + if (sinksToSync.stream().anyMatch(BluetoothUtils::isTemporaryBondDevice)) { + for (BluetoothDevice device : sinksToSync) { + if (!BluetoothUtils.isTemporaryBondDevice(device)) { + log("addMemberDevicesIntoMainDevice: sync temp bond metadata for " + + device.getAnonymizedAddress()); + BluetoothUtils.setTemporaryBondMetadata(device); + } + } + } + } } else { - log("addMemberDevicesIntoMainDevice: skip sync source, flag disabled"); + log("addMemberDevicesIntoMainDevice: skip sync audio sharing status, flag disabled"); } } |