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

Commit a82ebbcd authored by Jakub Tyszkowski's avatar Jakub Tyszkowski
Browse files

BassClient: Allow only one pending source operation

This is required by the API design so that a single device
could have a single pending source operation that is
about to end with an appropriate callback call.

Bug: 150670922
Tag: #feature
Sponsor: jpawlowski@
Test: atest BluetoothInstrumentationTests
Change-Id: I2f2054c6891e171ae04e677b3fe72181d6fb6242
parent b084d6e1
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -741,6 +741,9 @@ public class BassClientService extends ProfileService {
                    BluetoothStatusCodes.ERROR_REMOTE_LINK_ERROR);
            return;
        }
        if (stateMachine.hasPendingSourceOperation()) {
            throw new IllegalStateException("addSource: source operation already pending");
        }
        if (!hasRoomForBroadcastSourceAddition(sink)) {
            log("addSource: device has no room");
            mCallbacks.notifySourceAddFailed(sink, sourceMetadata,
@@ -784,6 +787,9 @@ public class BassClientService extends ProfileService {
                    BluetoothStatusCodes.ERROR_REMOTE_LINK_ERROR);
            return;
        }
        if (stateMachine.hasPendingSourceOperation()) {
            throw new IllegalStateException("modifySource: source operation already pending");
        }
        Message message = stateMachine.obtainMessage(BassClientStateMachine.UPDATE_BCAST_SOURCE);
        message.arg1 = sourceId;
        message.obj = updatedMetadata;
+4 −0
Original line number Diff line number Diff line
@@ -245,6 +245,10 @@ public class BassClientStateMachine extends StateMachine {
        mCurrentMetadata.clear();
    }

    Boolean hasPendingSourceOperation() {
        return mPendingMetadata != null;
    }

    BluetoothLeBroadcastMetadata getCurrentBroadcastMetadata(Integer sourceId) {
        return mCurrentMetadata.getOrDefault(sourceId, null);
    }