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

Commit b7291c55 authored by Aswin Sankar's avatar Aswin Sankar Committed by Android (Google) Code Review
Browse files

Merge "e911 call should go on same SIM as ongoing VoLTE call." into udc-dev

parents 68f450de 8df798ff
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -3187,7 +3187,10 @@ public class CallsManager extends Call.ListenerBase
                        isEmergency);
        // Only one SIM PhoneAccount can be active at one time for DSDS. Only that SIM PhoneAccount
        // should be available if a call is already active on the SIM account.
        if (!isDsdaCallingPossible()) {
        // Similarly, the emergency call should be attempted over the same PhoneAccount as the
        // ongoing call. However, if the ongoing call is over cross-SIM registration, then the
        // emergency call will be attempted over a different Phone object at a later stage.
        if (isEmergency || !isDsdaCallingPossible()) {
            List<PhoneAccountHandle> simAccounts =
                    mPhoneAccountRegistrar.getSimPhoneAccountsOfCurrentUser();
            PhoneAccountHandle ongoingCallAccount = null;
+65 −12
Original line number Diff line number Diff line
@@ -70,6 +70,7 @@ import android.telecom.PhoneAccountHandle;
import android.telecom.TelecomManager;
import android.telecom.VideoProfile;
import android.telephony.CarrierConfigManager;
import android.telephony.PhoneCapability;
import android.telephony.TelephonyManager;
import android.test.suitebuilder.annotation.MediumTest;
import android.test.suitebuilder.annotation.SmallTest;
@@ -243,6 +244,7 @@ public class CallsManagerTest extends TelecomTestCase {
    @Mock private AnomalyReporterAdapter mAnomalyReporterAdapter;
    @Mock private Ringer.AccessibilityManagerAdapter mAccessibilityManagerAdapter;
    @Mock private BlockedNumbersAdapter mBlockedNumbersAdapter;
    @Mock private PhoneCapability mPhoneCapability;

    private CallsManager mCallsManager;

@@ -335,18 +337,9 @@ public class CallsManagerTest extends TelecomTestCase {
        assertEquals(0, mCallsManager.constructPossiblePhoneAccounts(null, null, false, false).size());
    }

    /**
     * Verify behavior for multisim devices where we want to ensure that the active sim is used for
     * placing a new call.
     * @throws Exception
     */
    @MediumTest
    @Test
    public void testConstructPossiblePhoneAccountsMultiSimActive() throws Exception {
        setupMsimAccounts();

    private Call constructOngoingCall(String callId, PhoneAccountHandle phoneAccountHandle) {
        Call ongoingCall = new Call(
                "1", /* callId */
                callId,
                mContext,
                mCallsManager,
                mLock,
@@ -355,13 +348,26 @@ public class CallsManagerTest extends TelecomTestCase {
                TEST_ADDRESS,
                null /* GatewayInfo */,
                null /* connectionManagerPhoneAccountHandle */,
                SIM_2_HANDLE,
                phoneAccountHandle,
                Call.CALL_DIRECTION_INCOMING,
                false /* shouldAttachToExistingConnection*/,
                false /* isConference */,
                mClockProxy,
                mToastFactory);
        ongoingCall.setState(CallState.ACTIVE, "just cuz");
        return ongoingCall;
    }
    /**
     * Verify behavior for multisim devices where we want to ensure that the active sim is used for
     * placing a new call.
     * @throws Exception
     */
    @MediumTest
    @Test
    public void testConstructPossiblePhoneAccountsMultiSimActive() throws Exception {
        setupMsimAccounts();

        Call ongoingCall = constructOngoingCall("1", SIM_2_HANDLE);
        mCallsManager.addCall(ongoingCall);

        List<PhoneAccountHandle> phoneAccountHandles = mCallsManager.constructPossiblePhoneAccounts(
@@ -384,6 +390,47 @@ public class CallsManagerTest extends TelecomTestCase {
        assertEquals(2, phoneAccountHandles.size());
    }

    /**
     * For DSDA-enabled multisim devices with an ongoing call, verify that both SIMs'
     * PhoneAccountHandles are constructed while placing a new call.
     * @throws Exception
     */
    @MediumTest
    @Test
    public void testConstructPossiblePhoneAccountsMultiSimActive_dsdaCallingPossible() throws
            Exception {
        setupMsimAccounts();
        setMaxActiveVoiceSubscriptions(2);

        Call ongoingCall = constructOngoingCall("1", SIM_2_HANDLE);
        mCallsManager.addCall(ongoingCall);

        List<PhoneAccountHandle> phoneAccountHandles = mCallsManager.constructPossiblePhoneAccounts(
                TEST_ADDRESS, null, false, false);
        assertEquals(2, phoneAccountHandles.size());
    }

    /**
     * For DSDA-enabled multisim devices with an ongoing call, verify that only the active SIMs'
     * PhoneAccountHandle is constructed while placing an emergency call.
     * @throws Exception
     */
    @MediumTest
    @Test
    public void testConstructPossiblePhoneAccountsMultiSimActive_dsdaCallingPossible_emergencyCall()
            throws Exception {
        setupMsimAccounts();
        setMaxActiveVoiceSubscriptions(2);

        Call ongoingCall = constructOngoingCall("1", SIM_2_HANDLE);
        mCallsManager.addCall(ongoingCall);

        List<PhoneAccountHandle> phoneAccountHandles = mCallsManager.constructPossiblePhoneAccounts(
                TEST_ADDRESS, null, false, true /* isEmergency */);
        assertEquals(1, phoneAccountHandles.size());
        assertEquals(SIM_2_HANDLE, phoneAccountHandles.get(0));
    }

    private void setupCallerInfoLookupHelper() {
        doAnswer(invocation -> {
            Uri handle = invocation.getArgument(0);
@@ -2866,4 +2913,10 @@ public class CallsManagerTest extends TelecomTestCase {
        when(mPhoneAccountRegistrar.getSimPhoneAccountsOfCurrentUser()).thenReturn(
                new ArrayList<>(Arrays.asList(SIM_1_HANDLE, SIM_2_HANDLE)));
    }

    private void setMaxActiveVoiceSubscriptions(int num) {
        TelephonyManager mockTelephonyManager = mComponentContextFixture.getTelephonyManager();
        when(mockTelephonyManager.getPhoneCapability()).thenReturn(mPhoneCapability);
        when(mPhoneCapability.getMaxActiveVoiceSubscriptions()).thenReturn(num);
    }
}