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

Commit b8ce2aa6 authored by Tyler Gunn's avatar Tyler Gunn
Browse files

Ensure chosen phone account is used if it is valid.

When placing an outgoing call if a phone account is specified, there was
an issue where a list of all potential phone accounts would be returned
instead of just the one the user chose.  Fixed this.

Test: Added unit test, ran broken CTS test.
Bug: 69338480
Change-Id: I81dd73cb80df463217140d8a8087cf4140084b28
parent 153aafa8
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(