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

Commit 5e141f9d authored by Grace Jia's avatar Grace Jia Committed by Android (Google) Code Review
Browse files

Merge "Reset mute state when entering QuiescentBluetoothState." into main

parents 26b9fdc5 b4ebf4ea
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() {