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

Commit 98c73380 authored by Eric Shih's avatar Eric Shih
Browse files

Handle active device when get the audio policy value from remote

Bug: 359743806
Test: atest BluetoothInstrumentationTests:HeadsetStateMachineTest
Flag: Exempt, trivial and obvious fix.
Change-Id: Iaafeed6fad8d6b34e17cc344cab561766fda9ae0
parent c1bc65e3
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