Loading src/com/android/server/telecom/CreateConnectionProcessor.java +7 −1 Original line number Diff line number Diff line Loading @@ -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 Loading Loading @@ -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)) { Loading tests/src/com/android/server/telecom/tests/CreateConnectionProcessorTest.java +21 −0 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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 { Loading Loading
src/com/android/server/telecom/CreateConnectionProcessor.java +7 −1 Original line number Diff line number Diff line Loading @@ -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 Loading Loading @@ -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)) { Loading
tests/src/com/android/server/telecom/tests/CreateConnectionProcessorTest.java +21 −0 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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 { Loading