summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorGrace Jia <xiaotonj@google.com>2021-05-09 17:09:18 -0700
committerGrace Jia <xiaotonj@google.com>2021-05-18 15:08:38 +0000
commit302eff838040bc0fcbaf2d69bdceb9653a13878a (patch)
treec23cffd01ee9a09214d72b9e37590f773472a220 /tests
parentf8f1b2e7fd52da2af88a4001fd400959a85267e8 (diff)
downloadplatform_packages_services_Telecomm-302eff838040bc0fcbaf2d69bdceb9653a13878a.tar.gz
platform_packages_services_Telecomm-302eff838040bc0fcbaf2d69bdceb9653a13878a.tar.bz2
platform_packages_services_Telecomm-302eff838040bc0fcbaf2d69bdceb9653a13878a.zip
Block normal outgoing call when there's an ongoing emergency call.
Block non-emergency call if there's an ongoing emergency call when we try to make room for outgoing calls. This can make sure that all non-emergency call will be blocked even if the NewOutgoingCallIntentBroadcaster wouldn't start the call immediately. Bug: 186868542 Test: TelecomUnitTest Change-Id: I9d21e8f23db6b725e978904919198ff9521dd633
Diffstat (limited to 'tests')
-rw-r--r--tests/src/com/android/server/telecom/tests/CallsManagerTest.java45
1 files changed, 45 insertions, 0 deletions
diff --git a/tests/src/com/android/server/telecom/tests/CallsManagerTest.java b/tests/src/com/android/server/telecom/tests/CallsManagerTest.java
index 71e6b3510..eccbecbd9 100644
--- a/tests/src/com/android/server/telecom/tests/CallsManagerTest.java
+++ b/tests/src/com/android/server/telecom/tests/CallsManagerTest.java
@@ -21,6 +21,7 @@ import static junit.framework.TestCase.fail;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyBoolean;
@@ -36,6 +37,8 @@ import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.reset;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.timeout;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -54,6 +57,7 @@ import android.os.UserHandle;
import android.telecom.CallerInfo;
import android.telecom.Connection;
import android.telecom.DisconnectCause;
+import android.telecom.Log;
import android.telecom.PhoneAccount;
import android.telecom.PhoneAccountHandle;
import android.telecom.TelecomManager;
@@ -77,6 +81,7 @@ import com.android.server.telecom.CallsManagerListenerBase;
import com.android.server.telecom.ClockProxy;
import com.android.server.telecom.ConnectionServiceFocusManager;
import com.android.server.telecom.ConnectionServiceFocusManager.ConnectionServiceFocusManagerFactory;
+import com.android.server.telecom.ConnectionServiceWrapper;
import com.android.server.telecom.DefaultDialerCache;
import com.android.server.telecom.EmergencyCallHelper;
import com.android.server.telecom.HeadsetMediaButton;
@@ -1110,6 +1115,46 @@ public class CallsManagerTest extends TelecomTestCase {
assertFalse(mCallsManager.isInEmergencyCall());
}
+
+ @SmallTest
+ @Test
+ public void testBlockNonEmergencyCallDuringEmergencyCall() throws Exception {
+ // Setup a call which the network identified as an emergency call.
+ Call ongoingCall = addSpyCall();
+ ongoingCall.setConnectionProperties(Connection.PROPERTY_NETWORK_IDENTIFIED_EMERGENCY_CALL);
+ assertTrue(mCallsManager.isInEmergencyCall());
+
+ Call newCall = addSpyCall(CallState.NEW);
+ ConnectionServiceWrapper service = mock(ConnectionServiceWrapper.class);
+ doReturn(SIM_2_HANDLE.getComponentName()).when(service).getComponentName();
+
+ // Ensure contact info lookup succeeds
+ doAnswer(invocation -> {
+ Uri handle = invocation.getArgument(0);
+ CallerInfo info = new CallerInfo();
+ CompletableFuture<Pair<Uri, CallerInfo>> callerInfoFuture = new CompletableFuture<>();
+ callerInfoFuture.complete(new Pair<>(handle, info));
+ return callerInfoFuture;
+ }).when(mCallerInfoLookupHelper).startLookup(any(Uri.class));
+
+ // Ensure we have candidate phone account handle info.
+ when(mPhoneAccountRegistrar.getOutgoingPhoneAccountForScheme(any(), any())).thenReturn(
+ SIM_1_HANDLE);
+ when(mPhoneAccountRegistrar.getCallCapablePhoneAccounts(any(), anyBoolean(),
+ any(), anyInt(), anyInt())).thenReturn(
+ new ArrayList<>(Arrays.asList(SIM_1_HANDLE, SIM_2_HANDLE)));
+ mCallsManager.addConnectionServiceRepositoryCache(SIM_2_HANDLE.getComponentName(),
+ SIM_2_HANDLE.getUserHandle(), service);
+
+ CompletableFuture<Call> callFuture = mCallsManager.startOutgoingCall(
+ newCall.getHandle(), newCall.getTargetPhoneAccount(), new Bundle(),
+ UserHandle.CURRENT, new Intent(), "com.test.stuff");
+
+ verify(service, timeout(TEST_TIMEOUT)).createConnectionFailed(any());
+ Call result = callFuture.get(TEST_TIMEOUT, TimeUnit.MILLISECONDS);
+ assertNull(result);
+ }
+
@SmallTest
@Test
public void testHasEmergencyCallIncomingCallPermitted() {