Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0e455aa5 authored by Yiyi Shen's avatar Yiyi Shen
Browse files

[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
parent 759f9ccc
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -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;
    }