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

Commit 9787ba52 authored by Thomas Stuart's avatar Thomas Stuart Committed by Android (Google) Code Review
Browse files

Merge "fix potential audio flicker w/ CS outgoing calls" into main

parents 1da6c4e6 86d215ea
Loading
Loading
Loading
Loading
+8 −3
Original line number Diff line number Diff line
@@ -753,11 +753,10 @@ public class CallsManager extends Call.ListenerBase
    @Override
    @VisibleForTesting
    public void onSuccessfulOutgoingCall(Call call, int callState) {
        Log.v(this, "onSuccessfulOutgoingCall, %s", call);
        Log.v(this, "onSuccessfulOutgoingCall, call=[%s], state=[%d]", call, callState);
        call.setPostCallPackageName(getRoleManagerAdapter().getDefaultCallScreeningApp(
                call.getAssociatedUser()));

        setCallState(call, callState, "successful outgoing call");
        if (!mCalls.contains(call)) {
            // Call was not added previously in startOutgoingCall due to it being a potential MMI
            // code, so add it now.
@@ -769,8 +768,14 @@ public class CallsManager extends Call.ListenerBase
            listener.onConnectionServiceChanged(call, null, call.getConnectionService());
        }

        // Allow the ConnectionService to start the call in the active state. This case is helpful
        // for conference calls or meetings that can skip the dialing stage.
        if (callState == CallState.ACTIVE) {
            setCallState(call, callState, "skipping the dialing state and setting active");
        } else {
            markCallAsDialing(call);
        }
    }

    @Override
    public void onFailedOutgoingCall(Call call, DisconnectCause disconnectCause) {
+24 −0
Original line number Diff line number Diff line
@@ -2508,6 +2508,30 @@ public class CallsManagerTest extends TelecomTestCase {
        assertEquals(DEFAULT_CALL_SCREENING_APP, outgoingCall.getPostCallPackageName());
    }

    /**
     * Verify the only call state set from calling onSuccessfulOutgoingCall is CallState.DIALING.
     */
    @SmallTest
    @Test
    public void testOutgoingCallStateIsSetToAPreviousStateAndIgnored() {
        Call outgoingCall = addSpyCall(CallState.CONNECTING);
        mCallsManager.onSuccessfulOutgoingCall(outgoingCall, CallState.NEW);
        verify(outgoingCall, never()).setState(eq(CallState.NEW), any());
        verify(outgoingCall, times(1)).setState(eq(CallState.DIALING), any());
    }

    /**
     * Verify a ConnectionService can start the call in the active state and avoid the dialing state
     */
    @SmallTest
    @Test
    public void testOutgoingCallStateCanAvoidDialingAndGoStraightToActive() {
        Call outgoingCall = addSpyCall(CallState.CONNECTING);
        mCallsManager.onSuccessfulOutgoingCall(outgoingCall, CallState.ACTIVE);
        verify(outgoingCall, never()).setState(eq(CallState.DIALING), any());
        verify(outgoingCall, times(1)).setState(eq(CallState.ACTIVE), any());
    }

    @SmallTest
    @Test
    public void testRejectIncomingCallOnPAHInactive_SecondaryUser() throws Exception {