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

Commit 0c5bfde6 authored by Pranav Madapurmath's avatar Pranav Madapurmath
Browse files

Enforce max ringing call check for DSDA only

Update the max ringing call check in processIncomingCallIntent to only
enforce it for calls that require sequencing. For calls on the same
phone account, we'll allow Telephony to handle this in CallManager
instead where it used to be handled in the past. This is causing timing
issues for single sim where the second incoming call is being rejected
in a lab test due to placement of the 2nd call.

Bug: 415680299
Flag: EXEMPT test fix
Test: atest CallsManagerTest
Change-Id: I09b3cc8093fdbd3173c1800b2d6427d4b5648689
parent 2d16482b
Loading
Loading
Loading
Loading
+13 −2
Original line number Diff line number Diff line
@@ -1826,8 +1826,14 @@ public class CallsManager extends Call.ListenerBase
                notifyCreateConnectionFailed(phoneAccountHandle, call);
            }
        } else if (mFeatureFlags.enableCallSequencing()
                && ((hasMaximumManagedRingingCalls(call) && !ignoreIncomingCallFailureOnSameNumber)
                || hasMaximumManagedDialingCalls(call))) {
                && ((hasMaximumManagedRingingCalls(call) && !CallSequencingController
                .arePhoneAccountsSame(getRingingOrSimulatedRingingCall(), call)
                && !ignoreIncomingCallFailureOnSameNumber)
                || (hasMaximumManagedDialingCalls(call)
                && !CallSequencingController.arePhoneAccountsSame(getDialingCall(), call)))) {
            // Only perform this when the calls are on different phone accounts. Otherwise, let
            // Telephony handle the rejection logic.

            // Fail incoming call if there's already a ringing or dialing call present.
            boolean maxRinging = hasMaximumManagedRingingCalls(call);
            if (maxRinging) {
@@ -4633,6 +4639,11 @@ public class CallsManager extends Call.ListenerBase
                CallState.ANSWERED, CallState.SIMULATED_RINGING);
    }

    @VisibleForTesting
    public Call getDialingCall() {
        return getFirstCallWithState(CallState.DIALING, CallState.PULLING);
    }

    public Call getActiveCall() {
        return getFirstCallWithState(CallState.ACTIVE);
    }
+15 −5
Original line number Diff line number Diff line
@@ -3858,13 +3858,23 @@ public class CallsManagerTest extends TelecomTestCase {
    @SmallTest
    @Test
    public void testIgnoreMaxRingingCallOnSameNumber() {
        verifyMaxRingingCallNoError(SIM_1_HANDLE, TEST_ADDRESS);
    }

    @SmallTest
    @Test
    public void testIgnoreMaxRingingCallOnSamePhoneAccount() {
        verifyMaxRingingCallNoError(SIM_2_HANDLE, TEST_ADDRESS2);
    }

    private void verifyMaxRingingCallNoError(PhoneAccountHandle handle, Uri address) {
        when(mFeatureFlags.enableCallSequencing()).thenReturn(true);
        when(mFeatureFlags.allowCallOnSameConnectionMgr()).thenReturn(true);
        setupCallerInfoLookupHelper();
        ConnectionServiceWrapper service = mock(ConnectionServiceWrapper.class);
        doReturn(SIM_1_HANDLE.getComponentName()).when(service).getComponentName();
        mCallsManager.addConnectionServiceRepositoryCache(SIM_1_HANDLE.getComponentName(),
                SIM_1_HANDLE.getUserHandle(), service);
        doReturn(handle.getComponentName()).when(service).getComponentName();
        mCallsManager.addConnectionServiceRepositoryCache(handle.getComponentName(),
                handle.getUserHandle(), service);
        when(mPhoneAccountRegistrar.phoneAccountRequiresBindPermission(
                any(PhoneAccountHandle.class))).thenReturn(true);

@@ -3879,8 +3889,8 @@ public class CallsManagerTest extends TelecomTestCase {

        // THEN, add a new incoming call with the same number as the 1st call
        Bundle extras = new Bundle();
        extras.putParcelable(TelecomManager.EXTRA_INCOMING_CALL_ADDRESS, TEST_ADDRESS);
        Call newCall = mCallsManager.processIncomingCallIntent(SIM_2_HANDLE, extras, false);
        extras.putParcelable(TelecomManager.EXTRA_INCOMING_CALL_ADDRESS, address);
        Call newCall = mCallsManager.processIncomingCallIntent(handle, extras, false);
        // Verify we don't mark the call as auto missed and that the connection doesn't fail
        // locally.
        assertEquals(existingIncomingCall, mCallsManager.getRingingOrSimulatedRingingCall());