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

Commit e5894622 authored by Tyler Gunn's avatar Tyler Gunn Committed by android-build-merger
Browse files

Ensure chosen phone account is used if it is valid. am: b8ce2aa6

am: 069eba62

Change-Id: I5848301578fff3c05b6d575db7c44ae64cc94cf5
parents eda744d5 069eba62
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -1229,6 +1229,9 @@ public class CallsManager extends Call.ListenerBase
            if (targetPhoneAccountHandle != null) {
                if (!accounts.contains(targetPhoneAccountHandle)) {
                    targetPhoneAccountHandle = null;
                } else {
                    // The target phone account is valid and was found.
                    return Arrays.asList(targetPhoneAccountHandle);
                }
            }

+19 −0
Original line number Diff line number Diff line
@@ -315,6 +315,25 @@ public class CallsManagerTest extends TelecomTestCase {
        assertTrue(accounts.contains(SIM_1_HANDLE));
    }

    /**
     * Tests that we will use the provided target phone account if it exists.
     * @throws Exception
     */
    @MediumTest
    public void testUseSpecifiedAccount() throws Exception {
        when(mPhoneAccountRegistrar.getOutgoingPhoneAccountForScheme(any(), any())).thenReturn(
                null);
        when(mPhoneAccountRegistrar.getCallCapablePhoneAccounts(any(), anyBoolean(),
                any(), anyInt())).thenReturn(
                new ArrayList<>(Arrays.asList(SIM_1_HANDLE, SIM_2_HANDLE)));

        List<PhoneAccountHandle> accounts = mCallsManager.findOutgoingCallPhoneAccount(
                SIM_2_HANDLE, TEST_ADDRESS, false /* isVideo */, null /* userHandle */);

        assertEquals(1, accounts.size());
        assertTrue(accounts.contains(SIM_2_HANDLE));
    }

    private void setupMsimAccounts() {
        TelephonyManager mockTelephonyManager = mComponentContextFixture.getTelephonyManager();
        when(mockTelephonyManager.getMultiSimConfiguration()).thenReturn(