summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Yiyi Shen <yiyishen@google.com> 2024-04-10 10:53:13 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2024-04-10 10:53:13 +0000
commit895a715e44f54995bf2158e54557e0e0003fc1f6 (patch)
tree8db6f5f0df4a3f8e4d4bea3bfe2f208fd5fcc51c
parent08df28f4cdde7171a20f1ba2a323f828780c311a (diff)
parent940ed9ab3109808ef1b709ac9e0e618f09eb1c0b (diff)
Merge "[Audiosharing] Avoid fallback device update when onSourceRemoved." into main
-rw-r--r--packages/SettingsLib/src/com/android/settingslib/bluetooth/LocalBluetoothLeBroadcast.java20
1 files changed, 19 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 f054b4922f47..9df23aa2fe29 100644
--- a/packages/SettingsLib/src/com/android/settingslib/bluetooth/LocalBluetoothLeBroadcast.java
+++ b/packages/SettingsLib/src/com/android/settingslib/bluetooth/LocalBluetoothLeBroadcast.java
@@ -337,7 +337,6 @@ public class LocalBluetoothLeBroadcast implements LocalBluetoothProfile {
+ ", sourceId = "
+ sourceId);
}
- updateFallbackActiveDeviceIfNeeded();
}
@Override
@@ -469,6 +468,15 @@ public class LocalBluetoothLeBroadcast implements LocalBluetoothProfile {
mServiceBroadcast.startBroadcast(settings);
}
+ /** Checks if the broadcast is playing. */
+ public boolean isPlaying(int broadcastId) {
+ if (mServiceBroadcast == null) {
+ Log.d(TAG, "check isPlaying failed, the BluetoothLeBroadcast is null.");
+ return false;
+ }
+ return mServiceBroadcast.isPlaying(broadcastId);
+ }
+
private BluetoothLeBroadcastSettings buildBroadcastSettings(
boolean isPublic,
@Nullable String broadcastName,
@@ -1026,6 +1034,16 @@ public class LocalBluetoothLeBroadcast implements LocalBluetoothProfile {
/** Update fallback active device if needed. */
public void updateFallbackActiveDeviceIfNeeded() {
+ if (mServiceBroadcast == null) {
+ Log.d(TAG, "Skip updateFallbackActiveDeviceIfNeeded due to broadcast profile is null");
+ return;
+ }
+ List<BluetoothLeBroadcastMetadata> sources = mServiceBroadcast.getAllBroadcastMetadata();
+ if (sources.stream()
+ .noneMatch(source -> mServiceBroadcast.isPlaying(source.getBroadcastId()))) {
+ Log.d(TAG, "Skip updateFallbackActiveDeviceIfNeeded due to no broadcast ongoing");
+ return;
+ }
if (mServiceBroadcastAssistant == null) {
Log.d(TAG, "Skip updateFallbackActiveDeviceIfNeeded due to assistant profile is null");
return;