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

Commit f20a256b authored by Grace Jia's avatar Grace Jia
Browse files

Fallback to QuiescentBluetoothRoute when abandon focus from

ActiveBluetoothRoute.

Currently we try to reinitialized the call audio state machine
when we abandon the focus from ActiveBluetoothRoute. Since at that
time the BT audio already became inactive (while keep connected),
we mistakenly entered QuiescentEarpieceRoute which makes the audio
of the next call routed to earpiece route at the beginning. Fix
this by specific switch to QuiescentBluetoothRoute in this case.

Bug: 282069439
Test: atest CallAudioRouteStateMachineTest
Change-Id: I5a610b48fb0ca5f881df0b9319c3056d7dfe379f
parent 0c235541
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -918,7 +918,7 @@ public class CallAudioRouteStateMachine extends StateMachine {
                    if (msg.arg1 == NO_FOCUS) {
                        // Only disconnect audio here instead of routing away from BT entirely.
                        mBluetoothRouteManager.disconnectAudio();
                        reinitialize();
                        transitionTo(mQuiescentBluetoothRoute);
                        mCallAudioManager.notifyAudioOperationsComplete();
                    } else if (msg.arg1 == RINGING_FOCUS
                            && !mBluetoothRouteManager.isInbandRingingEnabled()) {
+11 −0
Original line number Diff line number Diff line
@@ -60,6 +60,7 @@ import java.util.List;
import java.util.Set;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.eq;
@@ -694,6 +695,16 @@ public class CallAudioRouteStateMachineTest extends TelecomTestCase {
        verify(mockBluetoothRouteManager, atLeastOnce())
                .connectBluetoothAudio(eq(bluetoothDevice1.getAddress()));
        assertTrue(stateMachine.isInActiveState());

        // Switch to inactive, pretending that the call disconnected.
        stateMachine.sendMessageWithSessionInfo(CallAudioRouteStateMachine.SWITCH_FOCUS,
                CallAudioRouteStateMachine.NO_FOCUS);
        waitForHandlerAction(stateMachine.getHandler(), TEST_TIMEOUT);

        // Make sure that we've successfully switched to the quiescent BT route
        assertEquals(CallAudioState.ROUTE_BLUETOOTH,
                stateMachine.getCurrentCallAudioState().getRoute());
        assertFalse(stateMachine.isInActiveState());
    }

    @SmallTest