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

Commit 53e4d9d3 authored by Hall Liu's avatar Hall Liu
Browse files

Turn on speaker when transitioning from quiescent

When going from the quiescent speaker state to the active speaker state,
turn the speakerphone on.

Fixes: 176199784
Test: atest CallRouteStateMachineTest
Change-Id: I33149a6a5be6397640cd2989939608ddb96040a9
parent 83ade723
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -1272,6 +1272,7 @@ public class CallAudioRouteStateMachine extends StateMachine {
                    return HANDLED;
                case SWITCH_FOCUS:
                    if (msg.arg1 == ACTIVE_FOCUS || msg.arg1 == RINGING_FOCUS) {
                        setSpeakerphoneOn(true);
                        transitionTo(mActiveSpeakerRoute);
                    }
                    return HANDLED;
+31 −0
Original line number Diff line number Diff line
@@ -453,6 +453,37 @@ public class CallAudioRouteStateMachineTest extends TelecomTestCase {
        verifyNewSystemCallAudioState(initState, expectedEndState);
    }

    @SmallTest
    @Test
    public void testFocusChangeFromQuiescentSpeaker() {
        CallAudioRouteStateMachine stateMachine = new CallAudioRouteStateMachine(
                mContext,
                mockCallsManager,
                mockBluetoothRouteManager,
                mockWiredHeadsetManager,
                mockStatusBarNotifier,
                mAudioServiceFactory,
                CallAudioRouteStateMachine.EARPIECE_FORCE_ENABLED,
                mThreadHandler.getLooper());
        stateMachine.setCallAudioManager(mockCallAudioManager);

        when(mockAudioManager.isSpeakerphoneOn()).thenReturn(false);

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

        // Switch to active, pretending that a call came in.
        stateMachine.sendMessageWithSessionInfo(CallAudioRouteStateMachine.SWITCH_FOCUS,
                CallAudioRouteStateMachine.ACTIVE_FOCUS);
        waitForHandlerAction(stateMachine.getHandler(), TEST_TIMEOUT);

        // Make sure that we've successfully switched to the active speaker route and that we've
        // called setSpeakerOn
        assertTrue(stateMachine.isInActiveState());
        verify(mockAudioManager).setSpeakerphoneOn(true);
    }

    @SmallTest
    @Test
    public void testFocusChangeWithAlreadyActiveBtDevice() {