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

Commit 31da75ce 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

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

Change-Id: I3bece6a0af04fce05cf6b920260bedb4709fa507
parents fd300221 45f0feb0
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 {