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

Commit 82f42a9a authored by Tyler Gunn's avatar Tyler Gunn Committed by android-build-merger
Browse files

Reset audio route when self-managed calls are disconnected. am: 911d4de7 am: 47bc46e9

am: f502000e

Change-Id: Ie115efcc5c0f9a1f25170ae7ef522a2b00d85440
parents debedb6e f502000e
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -418,6 +418,17 @@ public class CallAudioManager extends CallsManagerListenerBase {
        }
    }

    /**
     * Switch call audio routing to the baseline route, including bluetooth headsets if there are
     * any connected.
     */
    void switchBaseline() {
        Log.i(this, "switchBaseline");
        mCallAudioRouteStateMachine.sendMessageWithSessionInfo(
                CallAudioRouteStateMachine.USER_SWITCH_BASELINE_ROUTE,
                CallAudioRouteStateMachine.INCLUDE_BLUETOOTH_IN_BASELINE);
    }

    void silenceRingers() {
        for (Call call : mRingingCalls) {
            call.silence();
+6 −0
Original line number Diff line number Diff line
@@ -3092,6 +3092,12 @@ public class CallsManager extends Call.ListenerBase
        mCalls.stream()
                .filter(c -> c.isSelfManaged())
                .forEach(c -> c.disconnect());

        // When disconnecting all self-managed calls, switch audio routing back to the baseline
        // route.  This ensures if, for example, the self-managed ConnectionService was routed to
        // speakerphone that we'll switch back to earpiece for the managed call which necessitated
        // disconnecting the self-managed calls.
        mCallAudioManager.switchBaseline();
    }

    /**
+26 −0
Original line number Diff line number Diff line
@@ -955,4 +955,30 @@ public class BasicCallTests extends TelecomSystemTest {
        assertFalse(mTelecomSystem.getTelecomServiceImpl().getBinder()
                .isOutgoingCallPermitted(mPhoneAccountSelfManaged.getAccountHandle()));
    }

    /**
     * Basic to verify audio route gets reset to baseline when emergency call placed while a
     * self-managed call is underway.
     * @throws Exception
     */
    @LargeTest
    public void testDisconnectSelfManaged() throws Exception {
        // Add a self-managed call.
        PhoneAccountHandle phoneAccountHandle = mPhoneAccountSelfManaged.getAccountHandle();
        startAndMakeActiveIncomingCall("650-555-1212", phoneAccountHandle,
                mConnectionServiceFixtureA);
        Connection connection = mConnectionServiceFixtureA.mLatestConnection;

        // Route self-managed call to speaker.
        connection.setAudioRoute(CallAudioState.ROUTE_SPEAKER);
        waitForHandlerAction(new Handler(Looper.getMainLooper()), TEST_TIMEOUT);

        // Place an emergency call.
        startAndMakeDialingEmergencyCall("650-555-1212", mPhoneAccountE0.getAccountHandle(),
                mConnectionServiceFixtureA);

        // Should have reverted back to earpiece.
        assertEquals(CallAudioState.ROUTE_EARPIECE,
                mInCallServiceFixtureX.mCallAudioState.getRoute());
    }
}