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

Commit e7ceccfb authored by Grzegorz Kołodziejczyk's avatar Grzegorz Kołodziejczyk
Browse files

bass_client: Use PA_Sync value in update source context

Intention of this change is to unify usage of parameters in modify
source context. To not mix, status with value let's use a most proper
value which is PA_Sync value.

Tag: #bug
Bug: 330690507
Bug: 333050419
Test: atest BassClientServiceTest
Test: atest BassClientStateMachineTest
Change-Id: I2125994b7251b9da2abb5b7298b78ceafe52a7e7
parent 1ac3b366
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -1672,7 +1672,7 @@ public class BassClientService extends ProfileService {
            Message message =
                    stateMachine.obtainMessage(BassClientStateMachine.UPDATE_BCAST_SOURCE);
            message.arg1 = deviceSourceId;
            message.arg2 = BluetoothLeBroadcastReceiveState.PA_SYNC_STATE_INVALID;
            message.arg2 = BassConstants.INVALID_PA_SYNC_VALUE;
            message.obj = updatedMetadata;
            stateMachine.sendMessage(message);
            if (code != null && code.length != 0) {
@@ -1744,7 +1744,7 @@ public class BassClientService extends ProfileService {
                Message message = stateMachine.obtainMessage(
                        BassClientStateMachine.UPDATE_BCAST_SOURCE);
                message.arg1 = sourceId;
                message.arg2 = BluetoothLeBroadcastReceiveState.PA_SYNC_STATE_IDLE;
                message.arg2 = BassConstants.PA_SYNC_DO_NOT_SYNC;
                /* Pending remove set. Remove source once not synchronized to PA */
                message.obj = metaData;
                stateMachine.sendMessage(message);
+18 −7
Original line number Diff line number Diff line
@@ -1545,7 +1545,8 @@ public class BassClientStateMachine extends StateMachine {
            log("no existing SI for update source op");
            return null;
        }
        byte numSubGroups = (byte) metaData.getSubgroups().size();
        List<BluetoothLeBroadcastSubgroup> subGroups = metaData.getSubgroups();
        byte numSubGroups = (byte) subGroups.size();
        byte[] res = new byte[UPDATE_SOURCE_FIXED_LENGTH + numSubGroups * 5];
        int offset = 0;
        // Opcode
@@ -1553,7 +1554,7 @@ public class BassClientStateMachine extends StateMachine {
        // Source_ID
        res[offset++] = (byte) sourceId;
        // PA_Sync
        if (paSync != BluetoothLeBroadcastReceiveState.PA_SYNC_STATE_INVALID) {
        if (paSync != BassConstants.INVALID_PA_SYNC_VALUE) {
            res[offset++] = (byte) paSync;
        } else if (existingState.getPaSyncState()
                == BluetoothLeBroadcastReceiveState.PA_SYNC_STATE_SYNCHRONIZED) {
@@ -1566,12 +1567,22 @@ public class BassClientStateMachine extends StateMachine {
        res[offset++] = (byte) 0xFF;
        // Num_Subgroups
        res[offset++] = numSubGroups;
        for (int i = 0; i < numSubGroups; i++) {

        for (BluetoothLeBroadcastSubgroup subGroup : subGroups) {
            int bisIndexValue;
            if (paSync != BluetoothLeBroadcastReceiveState.PA_SYNC_STATE_INVALID) {
            if (paSync == BassConstants.PA_SYNC_DO_NOT_SYNC) {
                bisIndexValue = 0;
            } else if (paSync == BassConstants.PA_SYNC_PAST_AVAILABLE
                    || paSync == BassConstants.PA_SYNC_PAST_NOT_AVAILABLE) {
                bisIndexValue = getBisSyncFromChannelPreference(subGroup.getChannels());

                // Let sink decide to which BIS sync if there is no channel preference
                if (bisIndexValue == 0) {
                    bisIndexValue = 0xFFFFFFFF;
                }
            } else {
                bisIndexValue = existingState.getBisSyncState().get(i).intValue();
                bisIndexValue =
                        existingState.getBisSyncState().get(subGroups.indexOf(subGroup)).intValue();
            }
            log("UPDATE_BCAST_SOURCE: bisIndexValue : " + bisIndexValue);
            // BIS_Sync
@@ -1780,7 +1791,7 @@ public class BassClientStateMachine extends StateMachine {
                        log("SWITCH_BCAST_SOURCE force source to lost PA sync");
                        Message msg = obtainMessage(UPDATE_BCAST_SOURCE);
                        msg.arg1 = sourceIdToRemove;
                        msg.arg2 = BluetoothLeBroadcastReceiveState.PA_SYNC_STATE_IDLE;
                        msg.arg2 = BassConstants.PA_SYNC_DO_NOT_SYNC;
                        msg.obj = metaDataToUpdate;
                        /* Pending remove set. Remove source once not synchronized to PA */
                        sendMessage(msg);
@@ -1853,7 +1864,7 @@ public class BassClientStateMachine extends StateMachine {
                        writeBassControlPoint(updateSourceInfo);
                        mPendingOperation = message.what;
                        mPendingSourceId = (byte) sourceId;
                        if (paSync == BluetoothLeBroadcastReceiveState.PA_SYNC_STATE_IDLE) {
                        if (paSync == BassConstants.PA_SYNC_DO_NOT_SYNC) {
                            setPendingRemove(sourceId, true);
                        }
                        if (metaData.isEncrypted() && (metaData.getBroadcastCode() != null)) {
+5 −0
Original line number Diff line number Diff line
@@ -46,6 +46,7 @@ public class BassConstants {
    public static final int INVALID_BROADCAST_ID = -1;
    public static final int BROADCAST_ASSIST_ADDRESS_TYPE_PUBLIC = 0;
    public static final int INVALID_SOURCE_ID = -1;
    public static final int INVALID_PA_SYNC_VALUE = -1;
    public static final int ADV_ADDRESS_DONT_MATCHES_EXT_ADV_ADDRESS = 0x00000001;
    public static final int ADV_ADDRESS_DONT_MATCHES_SOURCE_ADV_ADDRESS = 0x00000002;
    // types of command for select and add Broadcast source operations
@@ -76,4 +77,8 @@ public class BassConstants {
    public static final int BCAST_NAME_AD_TYPE = 0x30;
    public static final int BCAST_NAME_LEN_MIN = 4;
    public static final int BCAST_NAME_LEN_MAX = 32;
    // PA_Sync parameter value
    public static final int PA_SYNC_DO_NOT_SYNC = 0x00;
    public static final int PA_SYNC_PAST_AVAILABLE = 0x01;
    public static final int PA_SYNC_PAST_NOT_AVAILABLE = 0x02;
}