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

Commit b4ebf4ea authored by xiaotonj's avatar xiaotonj Committed by Grace Jia
Browse files

Reset mute state when entering QuiescentBluetoothState.

Currently we skipped the mute state reset when entering the
QuiescentBluetoothState. This will cause the call route to BT devices
hold it's mute state even in the following calls.

Bug: b/311313250
Test: atest CallAudioRouteStateMachineTest
Change-Id: I3561cd884706b63266c23af81e8c1e73c1b89bdf
parent 1d71b0a4
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -49,6 +49,13 @@ flag {
  bug: "303001133"
}

flag {
  name: "reset_mute_when_entering_quiescent_bt_route"
  namespace: "telecom"
  description: "Reset mute state when entering quiescent bluetooth route."
  bug: "311313250"
}

flag {
  name: "update_route_mask_when_bt_connected"
  namespace: "telecom"
+3 −1
Original line number Diff line number Diff line
@@ -17,7 +17,6 @@
package com.android.server.telecom;


import android.annotation.FlaggedApi;
import android.app.ActivityManager;
import android.bluetooth.BluetoothDevice;
import android.content.BroadcastReceiver;
@@ -1074,6 +1073,9 @@ public class CallAudioRouteStateMachine extends StateMachine implements CallAudi
        public void enter() {
            super.enter();
            mHasUserExplicitlyLeftBluetooth = false;
            if (mFeatureFlags.resetMuteWhenEnteringQuiescentBtRoute()) {
                setMuteOn(false);
            }
            updateInternalCallAudioState();
        }

+47 −0
Original line number Diff line number Diff line
@@ -1238,6 +1238,53 @@ public class CallAudioRouteStateMachineTest extends TelecomTestCase {
        assertEquals(expectedState, stateMachine.getCurrentCallAudioState());
    }

    @SmallTest
    @Test
    public void testQuiescentBluetoothRouteResetMute() {
        when(mFeatureFlags.resetMuteWhenEnteringQuiescentBtRoute()).thenReturn(true);
        CallAudioRouteStateMachine stateMachine = new CallAudioRouteStateMachine(
                mContext,
                mockCallsManager,
                mockBluetoothRouteManager,
                mockWiredHeadsetManager,
                mockStatusBarNotifier,
                mAudioServiceFactory,
                CallAudioRouteStateMachine.EARPIECE_FORCE_ENABLED,
                mThreadHandler.getLooper(),
                Runnable::run /** do async stuff sync for test purposes */,
                mCommunicationDeviceTracker,
                mFeatureFlags);
        stateMachine.setCallAudioManager(mockCallAudioManager);

        CallAudioState initState = new CallAudioState(false,
                CallAudioState.ROUTE_BLUETOOTH, CallAudioState.ROUTE_SPEAKER
                | CallAudioState.ROUTE_EARPIECE | CallAudioState.ROUTE_BLUETOOTH);
        stateMachine.initialize(initState);

        // Switch to active and mute
        stateMachine.sendMessageWithSessionInfo(CallAudioRouteStateMachine.SWITCH_FOCUS,
                CallAudioRouteStateMachine.ACTIVE_FOCUS);
        stateMachine.sendMessageWithSessionInfo(CallAudioRouteStateMachine.BT_AUDIO_CONNECTED);
        waitForHandlerAction(stateMachine.getAdapterHandler(), TEST_TIMEOUT);
        assertTrue(stateMachine.isInActiveState());

        stateMachine.sendMessageWithSessionInfo(CallAudioRouteStateMachine.MUTE_ON);
        waitForHandlerAction(stateMachine.getAdapterHandler(), TEST_TIMEOUT);
        CallAudioState expectedState = new CallAudioState(true,
                CallAudioState.ROUTE_BLUETOOTH, CallAudioState.ROUTE_SPEAKER
                | CallAudioState.ROUTE_EARPIECE | CallAudioState.ROUTE_BLUETOOTH);
        assertEquals(expectedState, stateMachine.getCurrentCallAudioState());

        stateMachine.sendMessageWithSessionInfo(CallAudioRouteStateMachine.SWITCH_FOCUS,
                CallAudioRouteStateMachine.NO_FOCUS);
        waitForHandlerAction(stateMachine.getAdapterHandler(), TEST_TIMEOUT);

        expectedState = new CallAudioState(false,
                CallAudioState.ROUTE_BLUETOOTH, CallAudioState.ROUTE_SPEAKER
                | CallAudioState.ROUTE_EARPIECE | CallAudioState.ROUTE_BLUETOOTH);
        assertEquals(expectedState, stateMachine.getCurrentCallAudioState());
    }

    @SmallTest
    @Test
    public void testSupportRouteMaskUpdateWhenBtAudioConnected() {