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

Commit fd93e845 authored by Tyler Gunn's avatar Tyler Gunn
Browse files

Fix issue with unmute when BT moves to Quiescent.

The transitRouteBeforeAudioDisconnectBt flagged path does not use the
reinitialize method and instead moves directly to the quiescent BT route.
It does this because the reinitialize method will always revert back to
earpiece route.  BT is a "sticky" route, so we just move back to quiescent
BT if it is still active.

However, because this flagged path doesn't use reinitialize, we never turn
off mute during the state transition.  The resetMuteWhenEnteringQuiescentBtRoute
flag attempted to fix that but put it in the ENTER for the
QuiescentBluetooth route.  The downside to that is that setMuteOn method
does notthing when the current state is a quiescent state.

So, we'll move that logic before the transition to quiescent.


Bug: 336718198
Test: Manual test.
Test: Expanded testQuiescentBluetoothRouteResetMute to verify mute happens.
Change-Id: If97ecc8e2440836ae971be0a1eedae8230d8df3b
parent 1307e792
Loading
Loading
Loading
Loading
+8 −3
Original line number Diff line number Diff line
@@ -847,6 +847,14 @@ public class CallAudioRouteStateMachine extends StateMachine implements CallAudi
                    if (msg.arg1 == NO_FOCUS) {
                        // Only disconnect audio here instead of routing away from BT entirely.
                        if (mFeatureFlags.transitRouteBeforeAudioDisconnectBt()) {
                            // Note: We have to turn off mute here rather than when entering the
                            // QuiescentBluetooth route because setMuteOn will only work when there the
                            // current state is active.
                            // We don't need to do this in the unflagged path since reinitialize
                            // will turn off mute.
                            if (mFeatureFlags.resetMuteWhenEnteringQuiescentBtRoute()) {
                                setMuteOn(false);
                            }
                            transitionTo(mQuiescentBluetoothRoute);
                            mBluetoothRouteManager.disconnectAudio();
                        } else {
@@ -977,9 +985,6 @@ public class CallAudioRouteStateMachine extends StateMachine implements CallAudi
        public void enter() {
            super.enter();
            mHasUserExplicitlyLeftBluetooth = false;
            if (mFeatureFlags.resetMuteWhenEnteringQuiescentBtRoute()) {
                setMuteOn(false);
            }
            updateInternalCallAudioState();
        }

+6 −4
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.ArgumentMatchers.nullable;
@@ -1230,8 +1231,9 @@ public class CallAudioRouteStateMachineTest extends TelecomTestCase {

    @SmallTest
    @Test
    public void testQuiescentBluetoothRouteResetMute() {
    public void testQuiescentBluetoothRouteResetMute() throws Exception {
        when(mFeatureFlags.resetMuteWhenEnteringQuiescentBtRoute()).thenReturn(true);
        when(mFeatureFlags.transitRouteBeforeAudioDisconnectBt()).thenReturn(true);
        CallAudioRouteStateMachine stateMachine = new CallAudioRouteStateMachine(
                mContext,
                mockCallsManager,
@@ -1264,6 +1266,7 @@ public class CallAudioRouteStateMachineTest extends TelecomTestCase {
                CallAudioState.ROUTE_BLUETOOTH, CallAudioState.ROUTE_SPEAKER
                | CallAudioState.ROUTE_EARPIECE | CallAudioState.ROUTE_BLUETOOTH);
        assertEquals(expectedState, stateMachine.getCurrentCallAudioState());
        when(mockAudioManager.isMicrophoneMute()).thenReturn(true);

        stateMachine.sendMessageWithSessionInfo(CallAudioRouteStateMachine.SWITCH_FOCUS,
                CallAudioRouteStateMachine.NO_FOCUS);
@@ -1272,9 +1275,8 @@ public class CallAudioRouteStateMachineTest extends TelecomTestCase {
        expectedState = new CallAudioState(false,
                CallAudioState.ROUTE_BLUETOOTH, CallAudioState.ROUTE_SPEAKER
                | CallAudioState.ROUTE_EARPIECE | CallAudioState.ROUTE_BLUETOOTH);
        // TODO: Re-enable this part of the test; this is now failing because we have to
        // revert ag/23783145.
        // assertEquals(expectedState, stateMachine.getCurrentCallAudioState());
        assertEquals(expectedState, stateMachine.getCurrentCallAudioState());
        verify(mockAudioService).setMicrophoneMute(eq(false), anyString(), anyInt(), eq(null));
    }

    @SmallTest