diff options
author | 2025-03-11 15:20:00 +0800 | |
---|---|---|
committer | 2025-03-11 16:16:06 +0800 | |
commit | 0e455aa58a6aa010dafd0dc3024223af8857857a (patch) | |
tree | 34462fc18a1ebfb1b889e421b05f37cacc83edf3 | |
parent | 759f9ccce1b30fbe82c7bbc3723b1fc97008a43d (diff) |
[Audiosharing] Check broadcast id before return cached metadata
When caller getLatestBluetoothLeBroadcastMetadata between
onBroadcastStarted and onBroadcastMetadataChanged, they could get a
staled cached metadata. In this case we need call broadcast api to fetch
the latest metadata.
Bug: 400803742
Test: atest
Flag: EXEMPT bug fix
Change-Id: I25bd8f75ce6913c6c6fb3c4620e96e077a9a0953
-rw-r--r-- | packages/SettingsLib/src/com/android/settingslib/bluetooth/LocalBluetoothLeBroadcast.java | 6 |
1 files changed, 5 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 08f7806207db..a861f6fb158c 100644 --- a/packages/SettingsLib/src/com/android/settingslib/bluetooth/LocalBluetoothLeBroadcast.java +++ b/packages/SettingsLib/src/com/android/settingslib/bluetooth/LocalBluetoothLeBroadcast.java @@ -721,7 +721,10 @@ public class LocalBluetoothLeBroadcast implements LocalBluetoothProfile { Log.d(TAG, "The BluetoothLeBroadcast is null"); return null; } - if (mBluetoothLeBroadcastMetadata == null) { + if (mBluetoothLeBroadcastMetadata == null + // mBroadcastId is updated when onBroadcastStarted, which is always before + // onBroadcastMetadataChanged, so mBroadcastId is always the latest broadcast info + || mBluetoothLeBroadcastMetadata.getBroadcastId() != mBroadcastId) { final List<BluetoothLeBroadcastMetadata> metadataList = mServiceBroadcast.getAllBroadcastMetadata(); mBluetoothLeBroadcastMetadata = @@ -729,6 +732,7 @@ public class LocalBluetoothLeBroadcast implements LocalBluetoothProfile { .filter(i -> i.getBroadcastId() == mBroadcastId) .findFirst() .orElse(null); + Log.d(TAG, "getLatestBluetoothLeBroadcastMetadata for broadcast id " + mBroadcastId); } return mBluetoothLeBroadcastMetadata; } |