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

Commit 264c7089 authored by Rongxuan Liu's avatar Rongxuan Liu Committed by Automerger Merge Worker
Browse files

Merge changes I6e2c5e26,Iaa648ee0 into main am: aae5339f am: bb4b9dd6

parents 0ee3529f bb4b9dd6
Loading
Loading
Loading
Loading
+3 −5
Original line number Diff line number Diff line
@@ -1244,10 +1244,6 @@ public class BassClientService extends ProfileService {

        if (sourceMetadata == null) {
            log("addSource: Error bad parameter: sourceMetadata cannot be null");
            for (BluetoothDevice device : devices) {
                mCallbacks.notifySourceAddFailed(device, sourceMetadata,
                        BluetoothStatusCodes.ERROR_BAD_PARAMETERS);
            }
            return;
        }

@@ -1636,9 +1632,11 @@ public class BassClientService extends ProfileService {
            BluetoothDevice sink = mPausedBroadcastSinks.remove();
            BluetoothLeBroadcastMetadata metadata = mBroadcastMetadataMap.get(sink);

            if (metadata != null) {
                addSource(sink, metadata, true);
            }
        }
    }

    /**
     * Callback handler
+10 −6
Original line number Diff line number Diff line
@@ -590,8 +590,10 @@ public class BassClientStateMachine extends StateMachine {
        }
        metaData.setSourceDevice(device, device.getAddressType());
        byte[] arrayPresentationDelay = baseData.getLevelOne().presentationDelay;
        int presentationDelay = (int) ((arrayPresentationDelay[2] & 0xff) << 16
                | (arrayPresentationDelay[1] & 0xff)
        int presentationDelay =
                (int)
                        ((arrayPresentationDelay[2] & 0xff) << 16
                                | (arrayPresentationDelay[1] & 0xff) << 8
                                | (arrayPresentationDelay[0] & 0xff));
        metaData.setPresentationDelayMicros(presentationDelay);
        PeriodicAdvertisementResult result =
@@ -1964,10 +1966,12 @@ public class BassClientStateMachine extends StateMachine {
                    cancelActiveSync(null);
                    Message message = obtainMessage(STOP_SCAN_OFFLOAD);
                    sendMessage(message);
                    mService.getCallbacks().notifySourceAddFailed(mDevice,
                            mPendingMetadata, status);
                    if (mPendingMetadata != null) {
                        mService.getCallbacks()
                                .notifySourceAddFailed(mDevice, mPendingMetadata, status);
                        mPendingMetadata = null;
                    }
                }
                break;
            case UPDATE_BCAST_SOURCE:
                if (!mAutoTriggered) {
+9 −14
Original line number Diff line number Diff line
@@ -21,7 +21,6 @@ import static com.google.common.truth.Truth.assertThat;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.after;
import static org.mockito.Mockito.any;
import static org.mockito.Mockito.anyString;
import static org.mockito.Mockito.atLeast;
import static org.mockito.Mockito.clearInvocations;
import static org.mockito.Mockito.doAnswer;
@@ -1012,6 +1011,15 @@ public class BassClientServiceTest {
    public void testInvalidRequestForGroup() {
        // Prepare the initial state
        prepareConnectedDeviceGroup();

        // Verify errors are reported for the entire group
        mBassClientService.addSource(mCurrentDevice1, null, true);
        assertThat(mStateMachines.size()).isEqualTo(2);
        for (BassClientStateMachine sm : mStateMachines.values()) {
            verify(sm, times(0)).sendMessage(any());
        }

        // Prepare valid source for group
        BluetoothLeBroadcastMetadata meta = createBroadcastMetadata(TEST_BROADCAST_ID);
        verifyAddSourceForGroup(meta);
        for (BassClientStateMachine sm: mStateMachines.values()) {
@@ -1032,19 +1040,6 @@ public class BassClientServiceTest {
            }
        }

        // Verify errors are reported for the entire group
        mBassClientService.addSource(mCurrentDevice1, null, true);
        assertThat(mStateMachines.size()).isEqualTo(2);
        for (BassClientStateMachine sm: mStateMachines.values()) {
            BluetoothDevice dev = sm.getDevice();
            try {
                verify(mCallback, after(TIMEOUT_MS).times(1)).onSourceAddFailed(eq(dev),
                        eq(null), eq(BluetoothStatusCodes.ERROR_BAD_PARAMETERS));
            } catch (RemoteException e) {
                throw e.rethrowFromSystemServer();
            }
        }

        // Verify errors are reported for the entire group
        mBassClientService.modifySource(mCurrentDevice, TEST_SOURCE_ID, null);
        assertThat(mStateMachines.size()).isEqualTo(2);
+1 −0
Original line number Diff line number Diff line
@@ -1524,6 +1524,7 @@ public class BassClientStateMachineTest {

        // Test sendPendingCallbacks(ADD_BCAST_SOURCE, ERROR_UNKNOWN)
        moveConnectedStateToConnectedProcessingState();
        mBassClientStateMachine.mPendingMetadata = createBroadcastMetadata();
        mBassClientStateMachine.mPendingOperation = ADD_BCAST_SOURCE;
        sendMessageAndVerifyTransition(
                mBassClientStateMachine.obtainMessage(GATT_TXN_PROCESSED, GATT_FAILURE),