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

Commit a2c59324 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Enforce max ringing call check for DSDA only" into main

parents 10a3f561 0c5bfde6
Loading
Loading
Loading
Loading
+13 −2
Original line number Diff line number Diff line
@@ -1822,8 +1822,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) {
@@ -4642,6 +4648,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
@@ -3879,13 +3879,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);

@@ -3900,8 +3910,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());