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

Commit cfd7173f authored by Tyler Gunn's avatar Tyler Gunn Committed by Android (Google) Code Review
Browse files

Merge "Fix issue with unmute when BT moves to Quiescent." into main

parents 20015f02 fd93e845
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