1 /* 2 * Copyright (C) 2017 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License 15 */ 16 17 package android.telecom.cts; 18 19 import android.net.Uri; 20 import android.os.Bundle; 21 import android.telecom.Call; 22 import android.telecom.CallAudioState; 23 import android.telecom.Connection; 24 import android.telecom.ConnectionService; 25 import android.telecom.PhoneAccount; 26 import android.telecom.PhoneAccountHandle; 27 import android.telecom.TelecomManager; 28 import android.telecom.VideoProfile; 29 30 import java.util.ArrayList; 31 import java.util.List; 32 import java.util.function.Predicate; 33 34 import static android.telecom.cts.TestUtils.WAIT_FOR_STATE_CHANGE_TIMEOUT_MS; 35 import static android.telecom.cts.TestUtils.waitOnAllHandlers; 36 37 /** 38 * CTS tests for the self-managed {@link android.telecom.ConnectionService} APIs. 39 * For more information about these APIs, see {@link android.telecom}, and 40 * {@link android.telecom.PhoneAccount#CAPABILITY_SELF_MANAGED}. 41 */ 42 43 public class SelfManagedConnectionServiceTest extends BaseTelecomTestWithMockServices { 44 private Uri TEST_ADDRESS_1 = Uri.fromParts("sip", "call1 (at) test.com", null); 45 private Uri TEST_ADDRESS_2 = Uri.fromParts("tel", "6505551212", null); 46 private Uri TEST_ADDRESS_3 = Uri.fromParts("tel", "6505551213", null); 47 private Uri TEST_ADDRESS_4 = Uri.fromParts(TestUtils.TEST_URI_SCHEME, "fizzle_schmozle", null); 48 49 @Override 50 protected void setUp() throws Exception { 51 super.setUp(); 52 mContext = getInstrumentation().getContext(); 53 if (mShouldTestTelecom) { 54 // Register and enable the CTS ConnectionService; we want to be able to test a managed 55 // ConnectionService alongside a self-managed ConnectionService. 56 setupConnectionService(null, FLAG_REGISTER | FLAG_ENABLE); 57 58 mTelecomManager.registerPhoneAccount(TestUtils.TEST_SELF_MANAGED_PHONE_ACCOUNT_1); 59 mTelecomManager.registerPhoneAccount(TestUtils.TEST_SELF_MANAGED_PHONE_ACCOUNT_2); 60 mTelecomManager.registerPhoneAccount(TestUtils.TEST_SELF_MANAGED_PHONE_ACCOUNT_3); 61 } 62 } 63 64 @Override 65 protected void tearDown() throws Exception { 66 super.tearDown(); 67 68 CtsSelfManagedConnectionService connectionService = 69 CtsSelfManagedConnectionService.getConnectionService(); 70 if (connectionService != null) { 71 connectionService.tearDown(); 72 mTelecomManager.unregisterPhoneAccount(TestUtils.TEST_SELF_MANAGED_HANDLE_1); 73 mTelecomManager.unregisterPhoneAccount(TestUtils.TEST_SELF_MANAGED_HANDLE_2); 74 mTelecomManager.unregisterPhoneAccount(TestUtils.TEST_SELF_MANAGED_HANDLE_3); 75 } 76 } 77 78 /** 79 * Tests {@link TelecomManager#getSelfManagedPhoneAccounts()} API to ensure it returns a list of 80 * the registered self-managed {@link android.telecom.PhoneAccount}s. 81 */ 82 public void testTelecomManagerGetSelfManagedPhoneAccounts() { 83 if (!mShouldTestTelecom) { 84 return; 85 } 86 87 List<PhoneAccountHandle> phoneAccountHandles = 88 mTelecomManager.getSelfManagedPhoneAccounts(); 89 90 assertTrue(phoneAccountHandles.contains(TestUtils.TEST_SELF_MANAGED_HANDLE_1)); 91 assertTrue(phoneAccountHandles.contains(TestUtils.TEST_SELF_MANAGED_HANDLE_2)); 92 assertTrue(phoneAccountHandles.contains(TestUtils.TEST_SELF_MANAGED_HANDLE_3)); 93 assertFalse(phoneAccountHandles.contains(TestUtils.TEST_PHONE_ACCOUNT_HANDLE)); 94 } 95 96 /** 97 * Tests the ability to successfully register a self-managed 98 * {@link android.telecom.PhoneAccount}. 99 * <p> 100 * It should be possible to register self-managed Connection Services which suppor the TEL, SIP, 101 * or other URI schemes. 102 */ 103 public void testRegisterSelfManagedConnectionService() { 104 if (!mShouldTestTelecom) { 105 return; 106 } 107 verifyAccountRegistration(TestUtils.TEST_SELF_MANAGED_HANDLE_1, 108 TestUtils.TEST_SELF_MANAGED_PHONE_ACCOUNT_1); 109 verifyAccountRegistration(TestUtils.TEST_SELF_MANAGED_HANDLE_2, 110 TestUtils.TEST_SELF_MANAGED_PHONE_ACCOUNT_2); 111 verifyAccountRegistration(TestUtils.TEST_SELF_MANAGED_HANDLE_3, 112 TestUtils.TEST_SELF_MANAGED_PHONE_ACCOUNT_3); 113 } 114 115 private void verifyAccountRegistration(PhoneAccountHandle handle, PhoneAccount phoneAccount) { 116 // The phone account is registered in the setup method. 117 assertPhoneAccountRegistered(handle); 118 assertPhoneAccountEnabled(handle); 119 PhoneAccount registeredAccount = mTelecomManager.getPhoneAccount(handle); 120 121 // It should exist and be the same as the previously registered one. 122 assertNotNull(registeredAccount); 123 124 // We cannot just check for equality of the PhoneAccount since the one we registered is not 125 // enabled, and the one we get back after registration is. 126 assertPhoneAccountEquals(phoneAccount, registeredAccount); 127 128 // An important assumption is that self-managed PhoneAccounts are automatically 129 // enabled by default. 130 assertTrue("Self-managed PhoneAccounts must be enabled by default.", 131 registeredAccount.isEnabled()); 132 } 133 134 /** 135 * This test ensures that a {@link android.telecom.PhoneAccount} declared as self-managed cannot 136 * but is also registered as a call provider is not permitted. 137 * 138 * A self-managed {@link android.telecom.PhoneAccount} cannot also be a call provider. 139 */ 140 public void testRegisterCallCapableSelfManagedConnectionService() { 141 if (!mShouldTestTelecom) { 142 return; 143 } 144 145 // Attempt to register both a call provider and self-managed account. 146 PhoneAccount toRegister = TestUtils.TEST_SELF_MANAGED_PHONE_ACCOUNT_1.toBuilder() 147 .setCapabilities(PhoneAccount.CAPABILITY_SELF_MANAGED | 148 PhoneAccount.CAPABILITY_CALL_PROVIDER) 149 .build(); 150 151 registerAndExpectFailure(toRegister); 152 } 153 154 /** 155 * This test ensures that a {@link android.telecom.PhoneAccount} declared as self-managed cannot 156 * but is also registered as a sim subscription is not permitted. 157 * 158 * A self-managed {@link android.telecom.PhoneAccount} cannot also be a SIM subscription. 159 */ 160 public void testRegisterSimSelfManagedConnectionService() { 161 if (!mShouldTestTelecom) { 162 return; 163 } 164 165 // Attempt to register both a call provider and self-managed account. 166 PhoneAccount toRegister = TestUtils.TEST_SELF_MANAGED_PHONE_ACCOUNT_1.toBuilder() 167 .setCapabilities(PhoneAccount.CAPABILITY_SELF_MANAGED | 168 PhoneAccount.CAPABILITY_SIM_SUBSCRIPTION) 169 .build(); 170 171 registerAndExpectFailure(toRegister); 172 } 173 174 /** 175 * This test ensures that a {@link android.telecom.PhoneAccount} declared as self-managed cannot 176 * but is also registered as a connection manager is not permitted. 177 * 178 * A self-managed {@link android.telecom.PhoneAccount} cannot also be a connection manager. 179 */ 180 public void testRegisterConnectionManagerSelfManagedConnectionService() { 181 if (!mShouldTestTelecom) { 182 return; 183 } 184 185 // Attempt to register both a call provider and self-managed account. 186 PhoneAccount toRegister = TestUtils.TEST_SELF_MANAGED_PHONE_ACCOUNT_1.toBuilder() 187 .setCapabilities(PhoneAccount.CAPABILITY_SELF_MANAGED | 188 PhoneAccount.CAPABILITY_CONNECTION_MANAGER) 189 .build(); 190 191 registerAndExpectFailure(toRegister); 192 } 193 194 /** 195 * Attempts to register a {@link android.telecom.PhoneAccount}, expecting a security exception 196 * which indicates that invalid capabilities were specified. 197 * 198 * @param toRegister The PhoneAccount to register. 199 */ 200 private void registerAndExpectFailure(PhoneAccount toRegister) { 201 try { 202 mTelecomManager.registerPhoneAccount(toRegister); 203 } catch (SecurityException se) { 204 assertEquals("Self-managed ConnectionServices cannot also be call capable, " + 205 "connection managers, or SIM accounts.", se.getMessage()); 206 return; 207 } 208 fail("Expected SecurityException"); 209 } 210 211 /** 212 * Tests ability to add a new self-managed incoming connection. 213 */ 214 public void testAddSelfManagedIncomingConnection() throws Exception { 215 if (!mShouldTestTelecom) { 216 return; 217 } 218 219 addAndVerifyIncomingCall(TestUtils.TEST_SELF_MANAGED_HANDLE_1, TEST_ADDRESS_1); 220 addAndVerifyIncomingCall(TestUtils.TEST_SELF_MANAGED_HANDLE_2, TEST_ADDRESS_3); 221 addAndVerifyIncomingCall(TestUtils.TEST_SELF_MANAGED_HANDLE_3, TEST_ADDRESS_4); 222 } 223 224 private void addAndVerifyIncomingCall(PhoneAccountHandle handle, Uri address) 225 throws Exception { 226 TestUtils.addIncomingCall(getInstrumentation(), mTelecomManager, handle, address); 227 228 // Ensure Telecom bound to the self managed CS 229 if (!CtsSelfManagedConnectionService.waitForBinding()) { 230 fail("Could not bind to Self-Managed ConnectionService"); 231 } 232 233 SelfManagedConnection connection = TestUtils.waitForAndGetConnection(address); 234 235 // Expect callback indicating that UI should be shown. 236 connection.getOnShowIncomingUiInvokeCounter().waitForCount(1); 237 setActiveAndVerify(connection); 238 239 // Expect there to be no managed calls at the moment. 240 assertFalse(mTelecomManager.isInManagedCall()); 241 assertTrue(mTelecomManager.isInCall()); 242 243 setDisconnectedAndVerify(connection); 244 } 245 246 /** 247 * Tests ensures that Telecom disallow to place outgoing self-managed call when the ongoing 248 * managed call can not be held. 249 */ 250 public void testDisallowOutgoingCallWhileOngoingManagedCallCanNotBeHeld() throws Exception { 251 if (!mShouldTestTelecom) { 252 return; 253 } 254 255 // GIVEN an ongoing managed call that can not be held 256 addAndVerifyNewIncomingCall(createTestNumber(), null); 257 Connection connection = verifyConnectionForIncomingCall(); 258 int capabilities = connection.getConnectionCapabilities(); 259 capabilities &= ~Connection.CAPABILITY_HOLD; 260 connection.setConnectionCapabilities(capabilities); 261 262 // answer the incoming call 263 MockInCallService inCallService = mInCallCallbacks.getService(); 264 Call call = inCallService.getLastCall(); 265 call.answer(VideoProfile.STATE_AUDIO_ONLY); 266 assertConnectionState(connection, Connection.STATE_ACTIVE); 267 268 // WHEN place a self-managed outgoing call 269 TestUtils.placeOutgoingCall(getInstrumentation(), mTelecomManager, 270 TestUtils.TEST_SELF_MANAGED_HANDLE_1, TEST_ADDRESS_1); 271 272 // THEN the new outgoing call is failed. 273 CtsSelfManagedConnectionService.waitForBinding(); 274 assertTrue(CtsSelfManagedConnectionService.getConnectionService().waitForUpdate( 275 CtsSelfManagedConnectionService.CREATE_OUTGOING_CONNECTION_FAILED_LOCK)); 276 } 277 278 /** 279 * Tests ability to add a new self-managed outgoing connection. 280 * <p> 281 * A self-managed {@link ConnectionService} shall be able to place an outgoing call to tel or 282 * sip {@link Uri}s without being interrupted by system UX or other Telephony-related logic. 283 */ 284 public void testAddSelfManagedOutgoingConnection() throws Exception { 285 if (!mShouldTestTelecom) { 286 return; 287 } 288 placeAndVerifyOutgoingCall(TestUtils.TEST_SELF_MANAGED_HANDLE_1, TEST_ADDRESS_1); 289 placeAndVerifyOutgoingCall(TestUtils.TEST_SELF_MANAGED_HANDLE_2, TEST_ADDRESS_3); 290 placeAndVerifyOutgoingCall(TestUtils.TEST_SELF_MANAGED_HANDLE_3, TEST_ADDRESS_4); 291 } 292 293 private void placeAndVerifyOutgoingCall(PhoneAccountHandle handle, Uri address) throws Exception { 294 295 TestUtils.placeOutgoingCall(getInstrumentation(), mTelecomManager, handle, address); 296 297 // Ensure Telecom bound to the self managed CS 298 if (!CtsSelfManagedConnectionService.waitForBinding()) { 299 fail("Could not bind to Self-Managed ConnectionService"); 300 } 301 302 SelfManagedConnection connection = TestUtils.waitForAndGetConnection(address); 303 assertNotNull("Self-Managed Connection should NOT be null.", connection); 304 assertTrue("Self-Managed Connection should be outgoing.", !connection.isIncomingCall()); 305 306 // The self-managed ConnectionService must NOT have been prompted to show its incoming call 307 // UI for an outgoing call. 308 assertEquals(connection.getOnShowIncomingUiInvokeCounter().getInvokeCount(), 0); 309 310 setActiveAndVerify(connection); 311 312 // Expect there to be no managed calls at the moment. 313 assertFalse(mTelecomManager.isInManagedCall()); 314 // But there should be a call (including self-managed). 315 assertTrue(mTelecomManager.isInCall()); 316 317 setDisconnectedAndVerify(connection); 318 } 319 320 /** 321 * Tests ability to change the audio route via the 322 * {@link android.telecom.Connection#setAudioRoute(int)} API. 323 */ 324 public void testAudioRoute() throws Exception { 325 if (!mShouldTestTelecom) { 326 return; 327 } 328 TestUtils.placeOutgoingCall(getInstrumentation(), mTelecomManager, 329 TestUtils.TEST_SELF_MANAGED_HANDLE_1, TEST_ADDRESS_1); 330 SelfManagedConnection connection = TestUtils.waitForAndGetConnection(TEST_ADDRESS_1); 331 setActiveAndVerify(connection); 332 333 TestUtils.InvokeCounter counter = connection.getCallAudioStateChangedInvokeCounter(); 334 counter.waitForCount(WAIT_FOR_STATE_CHANGE_TIMEOUT_MS); 335 CallAudioState callAudioState = (CallAudioState) counter.getArgs(0)[0]; 336 int availableRoutes = callAudioState.getSupportedRouteMask(); 337 338 // Both the speaker and either wired or earpiece are required to test changing the audio 339 // route. Skip this test if either of these routes is unavailable. 340 if ((availableRoutes & CallAudioState.ROUTE_SPEAKER) == 0 341 || (availableRoutes & CallAudioState.ROUTE_WIRED_OR_EARPIECE) == 0) { 342 return; 343 } 344 345 // Determine what the second route after SPEAKER should be, depending on what's supported. 346 int secondRoute = (availableRoutes & CallAudioState.ROUTE_EARPIECE) == 0 347 ? CallAudioState.ROUTE_WIRED_HEADSET 348 : CallAudioState.ROUTE_EARPIECE; 349 350 connection.setAudioRoute(CallAudioState.ROUTE_SPEAKER); 351 counter.waitForPredicate(new Predicate<CallAudioState>() { 352 @Override 353 public boolean test(CallAudioState cas) { 354 return cas.getRoute() == CallAudioState.ROUTE_SPEAKER; 355 } 356 }, WAIT_FOR_STATE_CHANGE_TIMEOUT_MS); 357 358 connection.setAudioRoute(secondRoute); 359 counter.waitForPredicate(new Predicate<CallAudioState>() { 360 @Override 361 public boolean test(CallAudioState cas) { 362 return cas.getRoute() == secondRoute; 363 } 364 }, WAIT_FOR_STATE_CHANGE_TIMEOUT_MS); 365 if (TestUtils.HAS_BLUETOOTH) { 366 // Call requestBluetoothAudio on a dummy device. This will be a noop since no devices are 367 // connected. 368 connection.requestBluetoothAudio(TestUtils.BLUETOOTH_DEVICE1); 369 } 370 setDisconnectedAndVerify(connection); 371 } 372 /** 373 * Tests that Telecom will allow the incoming call while the number of self-managed call is not 374 * exceed the limit. 375 * @throws Exception 376 */ 377 public void testIncomingWhileOngoingWithinLimit() throws Exception { 378 if (!mShouldTestTelecom) { 379 return; 380 } 381 382 // Create an ongoing call in the first self-managed PhoneAccount. 383 TestUtils.placeOutgoingCall(getInstrumentation(), mTelecomManager, 384 TestUtils.TEST_SELF_MANAGED_HANDLE_1, TEST_ADDRESS_1); 385 SelfManagedConnection connection = TestUtils.waitForAndGetConnection(TEST_ADDRESS_1); 386 setActiveAndVerify(connection); 387 388 // Attempt to create a new incoming call for the other PhoneAccount; it should succeed. 389 TestUtils.addIncomingCall(getInstrumentation(), mTelecomManager, 390 TestUtils.TEST_SELF_MANAGED_HANDLE_2, TEST_ADDRESS_2); 391 SelfManagedConnection connection2 = TestUtils.waitForAndGetConnection(TEST_ADDRESS_2); 392 393 connection2.disconnectAndDestroy(); 394 setDisconnectedAndVerify(connection); 395 } 396 397 /** 398 * Tests the self-managed ConnectionService has gained the focus when it become active. 399 */ 400 public void testSelfManagedConnectionServiceGainedFocus() throws Exception { 401 if (!mShouldTestTelecom) { 402 return; 403 } 404 405 // Attempt to create a new Incoming self-managed call 406 TestUtils.addIncomingCall(getInstrumentation(), mTelecomManager, 407 TestUtils.TEST_SELF_MANAGED_HANDLE_1, TEST_ADDRESS_1); 408 SelfManagedConnection connection = TestUtils.waitForAndGetConnection(TEST_ADDRESS_1); 409 setActiveAndVerify(connection); 410 411 // The ConnectionService has gained the focus 412 assertTrue(CtsSelfManagedConnectionService.getConnectionService().waitForUpdate( 413 CtsSelfManagedConnectionService.FOCUS_GAINED_LOCK)); 414 415 setDisconnectedAndVerify(connection); 416 } 417 418 public void testSelfManagedConnectionServiceLostFocus() throws Exception { 419 if (!mShouldTestTelecom) { 420 return; 421 } 422 423 // GIVEN an ongoing self-managed call 424 TestUtils.addIncomingCall(getInstrumentation(), mTelecomManager, 425 TestUtils.TEST_SELF_MANAGED_HANDLE_1, TEST_ADDRESS_1); 426 SelfManagedConnection connection = TestUtils.waitForAndGetConnection(TEST_ADDRESS_1); 427 setActiveAndVerify(connection); 428 assertTrue(CtsSelfManagedConnectionService.getConnectionService().waitForUpdate( 429 CtsSelfManagedConnectionService.FOCUS_GAINED_LOCK)); 430 431 // WHEN place a managed call 432 placeAndVerifyCall(); 433 verifyConnectionForOutgoingCall().setActive(); 434 assertTrue(connectionService.waitForEvent( 435 MockConnectionService.EVENT_CONNECTION_SERVICE_FOCUS_GAINED)); 436 437 // THEN the self-managed ConnectionService lost the focus 438 439 connection.disconnectAndDestroy(); 440 assertTrue(CtsSelfManagedConnectionService.getConnectionService().waitForUpdate( 441 CtsSelfManagedConnectionService.FOCUS_LOST_LOCK)); 442 } 443 444 /** 445 * Tests that Telecom will disallow the incoming call while the ringing call is existed. 446 */ 447 public void testRingCallLimitForOnePhoneAccount() { 448 if (!mShouldTestTelecom) { 449 return; 450 } 451 452 // GIVEN a self-managed call which state is ringing 453 TestUtils.addIncomingCall(getInstrumentation(), mTelecomManager, 454 TestUtils.TEST_SELF_MANAGED_HANDLE_1, TEST_ADDRESS_1); 455 SelfManagedConnection connection = TestUtils.waitForAndGetConnection(TEST_ADDRESS_1); 456 connection.setRinging(); 457 458 // WHEN create a new incoming call for the the same PhoneAccount 459 TestUtils.addIncomingCall(getInstrumentation(), mTelecomManager, 460 TestUtils.TEST_SELF_MANAGED_HANDLE_1, TEST_ADDRESS_1); 461 462 // THEN the new incoming call is denied 463 assertTrue(CtsSelfManagedConnectionService.getConnectionService().waitForUpdate( 464 CtsSelfManagedConnectionService.CREATE_INCOMING_CONNECTION_FAILED_LOCK)); 465 } 466 467 /** 468 * Tests that Telecom enforces a maximum number of calls for a self-managed ConnectionService. 469 * 470 * @throws Exception 471 */ 472 public void testCallLimit() throws Exception { 473 if (!mShouldTestTelecom) { 474 return; 475 } 476 477 List<SelfManagedConnection> connections = new ArrayList<>(); 478 // Create 10 calls; they should succeed. 479 for (int ix = 0; ix < 10; ix++) { 480 Uri address = Uri.fromParts("sip", "test" + ix + "@test.com", null); 481 // Create an ongoing call in the first self-managed PhoneAccount. 482 TestUtils.placeOutgoingCall(getInstrumentation(), mTelecomManager, 483 TestUtils.TEST_SELF_MANAGED_HANDLE_1, address); 484 SelfManagedConnection connection = TestUtils.waitForAndGetConnection(address); 485 setActiveAndVerify(connection); 486 connections.add(connection); 487 } 488 489 // Try adding an 11th. It should fail to be created. 490 TestUtils.addIncomingCall(getInstrumentation(), mTelecomManager, 491 TestUtils.TEST_SELF_MANAGED_HANDLE_1, TEST_ADDRESS_2); 492 assertTrue("Expected onCreateIncomingConnectionFailed callback", 493 CtsSelfManagedConnectionService.getConnectionService().waitForUpdate( 494 CtsSelfManagedConnectionService.CREATE_INCOMING_CONNECTION_FAILED_LOCK)); 495 496 connections.forEach((selfManagedConnection) -> 497 selfManagedConnection.disconnectAndDestroy()); 498 499 waitOnAllHandlers(getInstrumentation()); 500 } 501 502 /** 503 * Disabled for now; there is not a reliable means of setting a phone number as a test emergency 504 * number. 505 * @throws Exception 506 */ 507 public void DONOTtestEmergencyCallOngoing() throws Exception { 508 if (!mShouldTestTelecom) { 509 return; 510 } 511 512 // TODO: Need to find a reliable way to set a test emergency number. 513 // Set 555-1212 as a test emergency number. 514 TestUtils.executeShellCommand(getInstrumentation(), "setprop ril.ecclist 5551212"); 515 516 Bundle extras = new Bundle(); 517 extras.putParcelable(TelecomManager.EXTRA_PHONE_ACCOUNT_HANDLE, 518 TestUtils.TEST_PHONE_ACCOUNT_HANDLE); 519 mTelecomManager.placeCall(Uri.fromParts(PhoneAccount.SCHEME_TEL, "5551212", null), extras); 520 assertIsInCall(true); 521 assertIsInManagedCall(true); 522 try { 523 TestUtils.waitOnAllHandlers(getInstrumentation()); 524 } catch (Exception e) { 525 fail("Failed to wait on handlers " + e); 526 } 527 528 // Try adding a self managed call. It should fail to be created. 529 TestUtils.addIncomingCall(getInstrumentation(), mTelecomManager, 530 TestUtils.TEST_SELF_MANAGED_HANDLE_1, TEST_ADDRESS_1); 531 assertTrue("Expected onCreateIncomingConnectionFailed callback", 532 CtsSelfManagedConnectionService.getConnectionService().waitForUpdate( 533 CtsSelfManagedConnectionService.CREATE_INCOMING_CONNECTION_FAILED_LOCK)); 534 } 535 536 /** 537 * Sets a connection active, and verifies TelecomManager thinks we're in call but not in a 538 * managed call. 539 * @param connection The connection. 540 */ 541 private void setActiveAndVerify(SelfManagedConnection connection) throws Exception { 542 // Set the connection active. 543 connection.setActive(); 544 545 // Check with Telecom if we're in a call. 546 assertIsInCall(true); 547 assertIsInManagedCall(false); 548 } 549 550 /** 551 * Sets a connection to be disconnected, and then waits until the TelecomManager reports it is 552 * no longer in a call. 553 * 554 * @param connection The connection to disconnect/destroy. 555 */ 556 private void setDisconnectedAndVerify(SelfManagedConnection connection) { 557 // Now, disconnect call and clean it up. 558 connection.disconnectAndDestroy(); 559 560 assertIsInCall(false); 561 assertIsInManagedCall(false); 562 } 563 } 564