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

Commit 76119858 authored by Jakub Pawłowski's avatar Jakub Pawłowski Committed by Gerrit Code Review
Browse files

Merge changes I080c7fa0,I006d5762

* changes:
  Tbs: Fix error handling for the join call
  Tbs: Sets an active LE audio device when accepting calls
parents cdd8c145 8044f0b8
Loading
Loading
Loading
Loading
+25 −1
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@ import android.util.Log;
import com.android.bluetooth.btservice.ServiceFactory;
import com.android.bluetooth.le_audio.ContentControlIdKeeper;
import com.android.bluetooth.le_audio.LeAudioService;
import com.android.internal.annotations.VisibleForTesting;

import java.util.ArrayList;
import java.util.Arrays;
@@ -735,7 +736,7 @@ public class TbsGeneric {
            mLastIndexAssigned = requestId;
        }


        setActiveLeDevice(device);
        return TbsGatt.CALL_CONTROL_POINT_RESULT_SUCCESS;
    }

@@ -794,6 +795,7 @@ public class TbsGeneric {
                        Request request = new Request(device, callId, opcode, callIndex);
                        try {
                            if (opcode == TbsGatt.CALL_CONTROL_POINT_OPCODE_ACCEPT) {
                                setActiveLeDevice(device);
                                bearer.callback.onAcceptCall(requestId, new ParcelUuid(callId));
                            } else if (opcode == TbsGatt.CALL_CONTROL_POINT_OPCODE_TERMINATE) {
                                bearer.callback.onTerminateCall(requestId, new ParcelUuid(callId));
@@ -839,6 +841,7 @@ public class TbsGeneric {

                        Map.Entry<UUID, Bearer> firstEntry = null;
                        List<ParcelUuid> parcelUuids = new ArrayList<>();
                        result = TbsGatt.CALL_CONTROL_POINT_RESULT_SUCCESS;
                        for (int callIndex : args) {
                            Map.Entry<UUID, Bearer> entry = getCallIdByIndex(callIndex);
                            if (entry == null) {
@@ -862,6 +865,10 @@ public class TbsGeneric {
                            parcelUuids.add(new ParcelUuid(entry.getKey()));
                        }

                        if (result != TbsGatt.CALL_CONTROL_POINT_RESULT_SUCCESS) {
                            break;
                        }

                        Bearer bearer = firstEntry.getValue();
                        Request request = new Request(device, parcelUuids, opcode, args[0]);
                        int requestId = mLastRequestIdAssigned + 1;
@@ -1023,6 +1030,11 @@ public class TbsGeneric {
        return true;
    }

    @VisibleForTesting
    void setLeAudioServiceForTesting(LeAudioService leAudioService) {
        mLeAudioService = leAudioService;
    }

    private synchronized void notifyCclc() {
        if (DBG) {
            Log.d(TAG, "notifyCclc");
@@ -1056,6 +1068,18 @@ public class TbsGeneric {
        mTbsGatt.setBearerUriSchemesSupportedList(mUriSchemes);
    }

    private void setActiveLeDevice(BluetoothDevice device) {
        if (device == null) {
            Log.w(TAG, "setActiveLeDevice: ignore null device");
            return;
        }
        if (!isLeAudioServiceAvailable()) {
            Log.w(TAG, "mLeAudioService not available");
            return;
        }
        mLeAudioService.setActiveDevice(device);
    }

    private static boolean isCallStateTransitionValid(int callState, int requestedOpcode) {
        switch (requestedOpcode) {
            case TbsGatt.CALL_CONTROL_POINT_OPCODE_ACCEPT:
+12 −0
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@ import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentat

import com.android.bluetooth.TestUtils;
import com.android.bluetooth.btservice.AdapterService;
import com.android.bluetooth.le_audio.LeAudioService;

import org.junit.After;
import org.junit.Before;
@@ -282,6 +283,9 @@ public class TbsGenericTest {
        Integer ccid = prepareTestBearer();
        reset(mTbsGatt);

        LeAudioService leAudioService = mock(LeAudioService.class);
        mTbsGeneric.setLeAudioServiceForTesting(leAudioService);

        // Prepare the incoming call
        UUID callUuid = UUID.randomUUID();
        List<BluetoothLeCall> tbsCalls = new ArrayList<>();
@@ -310,6 +314,8 @@ public class TbsGenericTest {
            throw e.rethrowFromSystemServer();
        }
        assertThat(callUuidCaptor.getValue().getUuid()).isEqualTo(callUuid);
        // Active device should be changed
        verify(leAudioService).setActiveDevice(mCurrentDevice);

        // Respond with requestComplete...
        mTbsGeneric.requestResult(ccid, requestIdCaptor.getValue(), BluetoothLeCallControl.RESULT_SUCCESS);
@@ -462,6 +468,9 @@ public class TbsGenericTest {
        Integer ccid = prepareTestBearer();
        reset(mTbsGatt);

        LeAudioService leAudioService = mock(LeAudioService.class);
        mTbsGeneric.setLeAudioServiceForTesting(leAudioService);

        // Act as if peer originates a call via Gtbs
        String uri = "xmpp:123456789";
        mTbsGattCallback.getValue().onCallControlPointRequest(mCurrentDevice,
@@ -476,6 +485,9 @@ public class TbsGenericTest {
            throw e.rethrowFromSystemServer();
        }

        // Active device should be changed
        verify(leAudioService).setActiveDevice(mCurrentDevice);

        // Respond with requestComplete...
        mTbsGeneric.requestResult(ccid, requestIdCaptor.getValue(), BluetoothLeCallControl.RESULT_SUCCESS);
        mTbsGeneric.callAdded(ccid,