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

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

Fix cross profile available account determination.

When determining which phone accounts can be used for placing an outgoing
call, consider ongoing calls across all profiles.  This corrects an issue
where an active voip call in the work profile prevents the user from
placing a call on the mobile network in their personal profile.

Flag: NONE Bugfix
Test: Manual test across profiles.
Test: Run unit tests and update.
Fixes: 390216890
Change-Id: I5653549a859c3087689fb96664ca34acee18b367
parent f9a03db0
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -3868,7 +3868,7 @@ public class CallsManager extends Call.ListenerBase
        for (PhoneAccountHandle callHandle : activeCallAccounts) {
            allAccounts.removeIf(candidateHandle -> {
                PhoneAccount callAcct = mPhoneAccountRegistrar.getPhoneAccount(callHandle,
                        user);
                        user, true /* acrossProfiles */);
                if (callAcct == null) {
                    Log.w(this, "constructPossiblePhoneAccountsNew: unexpected"
                            + "null PA for PAH, removing : " + candidateHandle);
+19 −3
Original line number Diff line number Diff line
@@ -407,16 +407,28 @@ public class CallsManagerTest extends TelecomTestCase {

        when(mPhoneAccountRegistrar.getPhoneAccount(
                eq(SELF_MANAGED_HANDLE), any())).thenReturn(SELF_MANAGED_ACCOUNT);
        when(mPhoneAccountRegistrar.getPhoneAccount(
                eq(SELF_MANAGED_HANDLE), any(), anyBoolean())).thenReturn(SELF_MANAGED_ACCOUNT);
        when(mPhoneAccountRegistrar.getPhoneAccount(
                eq(SIM_1_HANDLE), any())).thenReturn(SIM_1_ACCOUNT);
        when(mPhoneAccountRegistrar.getPhoneAccount(
                eq(SIM_1_HANDLE), any(), anyBoolean())).thenReturn(SIM_1_ACCOUNT);
        when(mPhoneAccountRegistrar.getPhoneAccount(
                eq(SIM_2_HANDLE), any())).thenReturn(SIM_2_ACCOUNT);
        when(mPhoneAccountRegistrar.getPhoneAccount(
                eq(SIM_2_HANDLE), any(), anyBoolean())).thenReturn(SIM_2_ACCOUNT);
        when(mPhoneAccountRegistrar.getPhoneAccount(
                eq(SIM_3_HANDLE), any())).thenReturn(SIM_3_ACCOUNT);
        when(mPhoneAccountRegistrar.getPhoneAccount(
                eq(SIM_3_HANDLE), any(), anyBoolean())).thenReturn(SIM_3_ACCOUNT);
        when(mPhoneAccountRegistrar.getPhoneAccount(
                eq(CALL_PROVIDER_HANDLE), any())).thenReturn(CALL_PROVIDER_ACCOUNT);
        when(mPhoneAccountRegistrar.getPhoneAccount(
                eq(CALL_PROVIDER_HANDLE), any(), anyBoolean())).thenReturn(CALL_PROVIDER_ACCOUNT);
        when(mPhoneAccountRegistrar.getPhoneAccount(
                eq(WORK_HANDLE), any())).thenReturn(WORK_ACCOUNT);
        when(mPhoneAccountRegistrar.getPhoneAccount(
                eq(WORK_HANDLE), any(), anyBoolean())).thenReturn(WORK_ACCOUNT);
        when(mFeatureFlags.separatelyBindToBtIncallService()).thenReturn(false);
        when(mFeatureFlags.telecomResolveHiddenDependencies()).thenReturn(true);
        when(mContext.createContextAsUser(any(UserHandle.class), eq(0)))
@@ -2297,7 +2309,8 @@ public class CallsManagerTest extends TelecomTestCase {
    public void testSpeakerDisabledWhenNoVideoCapabilities() throws Exception {
        Call outgoingCall = addSpyCall(CallState.NEW);
        when(mPhoneAccountRegistrar.getPhoneAccount(
                any(PhoneAccountHandle.class), any(UserHandle.class))).thenReturn(SIM_1_ACCOUNT);
                any(PhoneAccountHandle.class), any(UserHandle.class), anyBoolean()))
                .thenReturn(SIM_1_ACCOUNT);
        mCallsManager.placeOutgoingCall(outgoingCall, TEST_ADDRESS, null, true,
                VideoProfile.STATE_TX_ENABLED);
        assertFalse(outgoingCall.getStartWithSpeakerphoneOn());
@@ -3691,6 +3704,8 @@ public class CallsManagerTest extends TelecomTestCase {
        assertFalse(mCallsManager.isInSelfManagedCall(TEST_PACKAGE_NAME, TEST_USER_HANDLE));

        // WHEN
        when(mPhoneAccountRegistrar.getPhoneAccount(any(), any(), anyBoolean()))
                .thenReturn(SM_W_DIFFERENT_PACKAGE_AND_USER);
        when(mPhoneAccountRegistrar.getPhoneAccount(any(), any()))
                .thenReturn(SM_W_DIFFERENT_PACKAGE_AND_USER);
        // Ensure contact info lookup succeeds
@@ -3971,7 +3986,8 @@ public class CallsManagerTest extends TelecomTestCase {
        // Remap the PhoneAccounts to inherit the restriction set
        for (PhoneAccountHandle callCapableHandle : callCapableHandles) {
            PhoneAccount pa = mPhoneAccountRegistrar.getPhoneAccount(
                    callCapableHandle, callCapableHandle.getUserHandle());
                    callCapableHandle, callCapableHandle.getUserHandle(),
                    true /* across profiles */);
            assertNotNull("test setup error: could not find PA for PAH:" + callCapableHandle,
                    pa);
            // For simplicity, for testing only apply restrictions to SIM accounts
@@ -3984,7 +4000,7 @@ public class CallsManagerTest extends TelecomTestCase {
                        .setSimultaneousCallingRestriction(Collections.emptySet()).build();
            }
            when(mPhoneAccountRegistrar.getPhoneAccount(eq(callCapableHandle),
                    any())).thenReturn(pa);
                    any(), anyBoolean())).thenReturn(pa);
        }
    }