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

Commit 1a1160ed authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Handle active device when get the audio policy value from remote" into main

parents 36f11beb 98c73380
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -2389,6 +2389,15 @@ class HeadsetStateMachine extends StateMachine {
                Log.d(TAG, "Processing command: " + atString);
                if (processAndroidAtSinkAudioPolicy(args, device)) {
                    mNativeInterface.atResponseCode(device, HeadsetHalConstants.AT_RESPONSE_OK, 0);
                    if (getHfpCallAudioPolicy().getActiveDevicePolicyAfterConnection()
                                    == BluetoothSinkAudioPolicy.POLICY_NOT_ALLOWED
                            && mDevice.equals(mHeadsetService.getActiveDevice())) {
                        Log.d(
                                TAG,
                                "Remove the active device because the active device policy after"
                                        + " connection is not allowed");
                        mHeadsetService.setActiveDevice(null);
                    }
                } else {
                    Log.w(TAG, "Invalid SinkAudioPolicy parameters!");
                    mNativeInterface.atResponseCode(
+8 −0
Original line number Diff line number Diff line
@@ -1923,6 +1923,14 @@ public class HeadsetStateMachineTest {
                .atResponseCode(mTestDevice, HeadsetHalConstants.AT_RESPONSE_ERROR, 0);
    }

    @Test
    public void testCheckAndProcessAndroidAt_handleConnectingTimePolicyNotAllowed() {
        when(mHeadsetService.getActiveDevice()).thenReturn(mTestDevice);
        mHeadsetStateMachine.checkAndProcessAndroidAt(
                "+ANDROID=SINKAUDIOPOLICY,0,2,2", mTestDevice);
        verify(mHeadsetService).setActiveDevice(null);
    }

    @Test
    public void testCheckAndProcessAndroidAt_replyAndroidAtFeatureRequest() {
        // Commands that will be handled