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

Commit bfe04c4b authored by Rongxuan Liu's avatar Rongxuan Liu
Browse files

[le audio] BassClient check and reset mPendingMetadata

mPendingMetadata is used to track the source add/update gatt operations.
It should be reset properly with the gatt response. And after being set to the current metadata, it should also be reset properly. Otherwise, it
might cause the hasPendingSourceOperation return unexpected state.

Bug: 316423019
Bug: 316005152
Test: atest BassClientServiceTest BassClientStateMachineTest
Test: manual test with le audio broadcast QR code path
Change-Id: I139f792c64fd848ade81f1d852c6e9e09da06681
parent c4575757
Loading
Loading
Loading
Loading
+9 −3
Original line number Diff line number Diff line
@@ -669,8 +669,10 @@ public class BassClientStateMachine extends StateMachine {
                            mPeriodicAdvManager, mDevice, serviceData, syncHandle);
                }
            } else {
                if (mService.isLocalBroadcast(mPendingMetadata)) {
                    int advHandle = mPendingMetadata.getSourceAdvertisingSid();
                BluetoothLeBroadcastMetadata currentMetadata =
                    getCurrentBroadcastMetadata(recvState.getSourceId());
                if (mService.isLocalBroadcast(currentMetadata)) {
                    int advHandle = currentMetadata.getSourceAdvertisingSid();
                    serviceData = 0x000000FF & recvState.getSourceId();
                    serviceData = serviceData << 8;
                    // Address we set in the Source Address can differ from the address in the air
@@ -877,6 +879,7 @@ public class BassClientStateMachine extends StateMachine {
                        BluetoothStatusCodes.REASON_LOCAL_APP_REQUEST);
                if (mPendingMetadata != null) {
                    setCurrentBroadcastMetadata(recvState.getSourceId(), mPendingMetadata);
                    mPendingMetadata = null;
                }
                checkAndUpdateBroadcastCode(recvState);
                processPASyncState(recvState);
@@ -893,7 +896,10 @@ public class BassClientStateMachine extends StateMachine {
                            BluetoothStatusCodes.REASON_LOCAL_APP_REQUEST);
                } else {
                    log("update to an existing recvState");
                    if (mPendingMetadata != null) {
                        setCurrentBroadcastMetadata(recvState.getSourceId(), mPendingMetadata);
                        mPendingMetadata = null;
                    }
                    mService.getCallbacks().notifySourceModified(mDevice,
                            recvState.getSourceId(), BluetoothStatusCodes.REASON_LOCAL_APP_REQUEST);
                    checkAndUpdateBroadcastCode(recvState);