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

Commit cac3ab18 authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Filter self managed phone accounts out when finding emergency accts."...

Merge "Filter self managed phone accounts out when finding emergency accts." am: 0754380b am: 45f0feb0 am: 31da75ce

Original change: https://android-review.googlesource.com/c/platform/packages/services/Telecomm/+/1914828

Change-Id: I4ad3740f70a6fdbed5424156f105472ca198719b
parents 750f3a32 31da75ce
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -39,6 +39,7 @@ import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

/**
 * This class creates connections to place new outgoing calls or to attach to an existing incoming
@@ -386,8 +387,13 @@ public class CreateConnectionProcessor implements CreateConnectionResponse {
            mAttemptRecords.clear();
            // Phone accounts in profile do not handle emergency call, use phone accounts in
            // current user.
            // ONLY include phone accounts which are NOT self-managed; we will never consider a self
            // managed phone account for placing an emergency call.
            List<PhoneAccount> allAccounts = mPhoneAccountRegistrar
                    .getAllPhoneAccountsOfCurrentUser();
                    .getAllPhoneAccountsOfCurrentUser()
                    .stream()
                    .filter(act -> !act.hasCapabilities(PhoneAccount.CAPABILITY_SELF_MANAGED))
                    .collect(Collectors.toList());

            if (allAccounts.isEmpty() && mContext.getPackageManager().hasSystemFeature(
                    PackageManager.FEATURE_TELEPHONY)) {
+21 −0
Original line number Diff line number Diff line
@@ -41,6 +41,7 @@ import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.mockito.invocation.InvocationOnMock;
@@ -546,6 +547,26 @@ public class CreateConnectionProcessorTest extends TelecomTestCase {
        verify(mMockCreateConnectionResponse).handleCreateConnectionSuccess(mockCallIdMapper, null);
    }

    /**
     * Ensures that a self-managed phone account won't be considered when attempting to place an
     * emergency call.
     */
    @SmallTest
    @Test
    public void testDontAttemptSelfManaged() {
        when(mMockCall.isEmergencyCall()).thenReturn(true);
        when(mMockCall.isTestEmergencyCall()).thenReturn(false);
        when(mMockCall.getHandle()).thenReturn(Uri.parse(""));

        PhoneAccount selfManagedAcct = makePhoneAccount("sm-acct",
                PhoneAccount.CAPABILITY_SELF_MANAGED
                        | PhoneAccount.CAPABILITY_PLACE_EMERGENCY_CALLS);
        phoneAccounts.add(selfManagedAcct);

        mTestCreateConnectionProcessor.process();
        verify(mMockCall, never()).setTargetPhoneAccount(any(PhoneAccountHandle.class));
    }

    @SmallTest
    @Test
    public void testEmergencyCallSimFailToConnectionManager() throws Exception {