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

Commit f41e7c5b authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Mitigate issues with stuck calls blocking new outgoing calls." into sc-dev am: 88b0ac85

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/services/Telecomm/+/14924098

Change-Id: I5db635928945bd1219ee0799189f20a4260cd3bb
parents 4ed16615 88b0ac85
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -4299,7 +4299,8 @@ public class CallsManager extends Call.ListenerBase
        return false;
    }

    private boolean makeRoomForOutgoingCall(Call call) {
    @VisibleForTesting
    public boolean makeRoomForOutgoingCall(Call call) {
        // Already room!
        if (!hasMaximumLiveCalls(call)) return true;

@@ -4316,6 +4317,13 @@ public class CallsManager extends Call.ListenerBase
            return true;
        }

        // If the live call is stuck in a connecting state, then we should disconnect it in favor
        // of the new outgoing call.
        if (liveCall.getState() == CallState.CONNECTING) {
            liveCall.disconnect("Force disconnect CONNECTING call.");
            return true;
        }

        if (hasMaximumOutgoingCalls(call)) {
            Call outgoingCall = getFirstCallWithState(OUTGOING_CALL_STATES);
            if (outgoingCall.getState() == CallState.SELECT_PHONE_ACCOUNT) {
+15 −0
Original line number Diff line number Diff line
@@ -1253,6 +1253,21 @@ public class CallsManagerTest extends TelecomTestCase {
        verify(ringingCall).reject(anyBoolean(), any(), any());
    }

    @SmallTest
    @Test
    public void testMakeRoomForOutgoingCallConnecting() {
        Call ongoingCall = addSpyCall(SIM_2_HANDLE, CallState.CONNECTING);

        Call newCall = createCall(SIM_1_HANDLE, CallState.NEW);
        when(mComponentContextFixture.getTelephonyManager().isEmergencyNumber(any()))
                .thenReturn(false);
        newCall.setHandle(Uri.fromParts("tel", "5551213", null),
                TelecomManager.PRESENTATION_ALLOWED);

        assertTrue(mCallsManager.makeRoomForOutgoingCall(newCall));
        verify(ongoingCall).disconnect(anyLong(), anyString());
    }

    /**
     * Verifies that changes to a {@link PhoneAccount}'s
     * {@link PhoneAccount#CAPABILITY_VIDEO_CALLING} capability will be reflected on a call.