use of android.telecom.ConnectionRequest in project robolectric by robolectric.
the class ShadowTelecomManagerTest method testAllowPlaceCall.
@Test
@Config(minSdk = M)
public void testAllowPlaceCall() {
shadowOf(telecomService).setCallRequestMode(CallRequestMode.ALLOW_ALL);
Uri address = Uri.parse("tel:+1-201-555-0123");
PhoneAccountHandle phoneAccount = createHandle("id");
Bundle outgoingCallExtras = new Bundle();
outgoingCallExtras.putString("TEST_EXTRA_KEY", "TEST_EXTRA_VALUE");
Bundle extras = new Bundle();
extras.putParcelable(TelecomManager.EXTRA_PHONE_ACCOUNT_HANDLE, phoneAccount);
extras.putInt(TelecomManager.EXTRA_START_CALL_WITH_VIDEO_STATE, VideoProfile.STATE_BIDIRECTIONAL);
extras.putBundle(TelecomManager.EXTRA_OUTGOING_CALL_EXTRAS, outgoingCallExtras);
telecomService.placeCall(address, extras);
ArgumentCaptor<ConnectionRequest> requestCaptor = ArgumentCaptor.forClass(ConnectionRequest.class);
verify(connectionServiceListener).onCreateOutgoingConnection(eq(phoneAccount), requestCaptor.capture());
verifyNoMoreInteractions(connectionServiceListener);
ConnectionRequest request = requestCaptor.getValue();
assertThat(request.getAccountHandle()).isEqualTo(phoneAccount);
assertThat(request.getExtras().getString("TEST_EXTRA_KEY")).isEqualTo("TEST_EXTRA_VALUE");
assertThat(request.getAddress()).isEqualTo(address);
assertThat(request.getVideoState()).isEqualTo(VideoProfile.STATE_BIDIRECTIONAL);
}
use of android.telecom.ConnectionRequest in project robolectric by robolectric.
the class ShadowTelecomManagerTest method testDenyNewIncomingCall.
@Test
@Config(minSdk = O)
public void testDenyNewIncomingCall() {
shadowOf(telecomService).setCallRequestMode(CallRequestMode.DENY_ALL);
Uri address = Uri.parse("tel:+1-201-555-0123");
PhoneAccountHandle phoneAccount = createHandle("id");
Bundle extras = new Bundle();
extras.putParcelable(TelecomManager.EXTRA_INCOMING_CALL_ADDRESS, address);
extras.putInt(TelecomManager.EXTRA_START_CALL_WITH_VIDEO_STATE, VideoProfile.STATE_BIDIRECTIONAL);
extras.putString("TEST_EXTRA_KEY", "TEST_EXTRA_VALUE");
telecomService.addNewIncomingCall(createHandle("id"), extras);
ArgumentCaptor<ConnectionRequest> requestCaptor = ArgumentCaptor.forClass(ConnectionRequest.class);
verify(connectionServiceListener).onCreateIncomingConnectionFailed(eq(phoneAccount), requestCaptor.capture());
verifyNoMoreInteractions(connectionServiceListener);
ConnectionRequest request = requestCaptor.getValue();
assertThat(request.getAccountHandle()).isEqualTo(phoneAccount);
assertThat(request.getExtras().getString("TEST_EXTRA_KEY")).isEqualTo("TEST_EXTRA_VALUE");
assertThat(request.getAddress()).isEqualTo(address);
assertThat(request.getVideoState()).isEqualTo(VideoProfile.STATE_BIDIRECTIONAL);
}
use of android.telecom.ConnectionRequest in project robolectric by robolectric.
the class ShadowTelecomManagerTest method testDenyPlaceCall.
@Test
@Config(minSdk = O)
public void testDenyPlaceCall() {
shadowOf(telecomService).setCallRequestMode(CallRequestMode.DENY_ALL);
Uri address = Uri.parse("tel:+1-201-555-0123");
PhoneAccountHandle phoneAccount = createHandle("id");
Bundle outgoingCallExtras = new Bundle();
outgoingCallExtras.putString("TEST_EXTRA_KEY", "TEST_EXTRA_VALUE");
Bundle extras = new Bundle();
extras.putParcelable(TelecomManager.EXTRA_PHONE_ACCOUNT_HANDLE, phoneAccount);
extras.putInt(TelecomManager.EXTRA_START_CALL_WITH_VIDEO_STATE, VideoProfile.STATE_BIDIRECTIONAL);
extras.putBundle(TelecomManager.EXTRA_OUTGOING_CALL_EXTRAS, outgoingCallExtras);
telecomService.placeCall(address, extras);
ArgumentCaptor<ConnectionRequest> requestCaptor = ArgumentCaptor.forClass(ConnectionRequest.class);
verify(connectionServiceListener).onCreateOutgoingConnectionFailed(eq(phoneAccount), requestCaptor.capture());
verifyNoMoreInteractions(connectionServiceListener);
ConnectionRequest request = requestCaptor.getValue();
assertThat(request.getAccountHandle()).isEqualTo(phoneAccount);
assertThat(request.getExtras().getString("TEST_EXTRA_KEY")).isEqualTo("TEST_EXTRA_VALUE");
assertThat(request.getAddress()).isEqualTo(address);
assertThat(request.getVideoState()).isEqualTo(VideoProfile.STATE_BIDIRECTIONAL);
}
use of android.telecom.ConnectionRequest in project robolectric by robolectric.
the class ShadowTelecomManager method allowIncomingCall.
/**
* Allows an {@link IncomingCallRecord} created via {@link TelecomManager#addNewIncomingCall}.
*
* <p>Specifically, this method sets up the relevant {@link ConnectionService} and returns the
* result of {@link ConnectionService#onCreateIncomingConnection}.
*/
@TargetApi(M)
@Nullable
public Connection allowIncomingCall(IncomingCallRecord call) {
if (call.isHandled) {
throw new IllegalStateException("Call has already been allowed or denied.");
}
call.isHandled = true;
PhoneAccountHandle phoneAccount = verifyNotNull(call.phoneAccount);
ConnectionRequest request = buildConnectionRequestForIncomingCall(call);
ConnectionService service = setupConnectionService(phoneAccount);
return service.onCreateIncomingConnection(phoneAccount, request);
}
use of android.telecom.ConnectionRequest in project robolectric by robolectric.
the class ShadowTelecomManager method buildConnectionRequestForOutgoingCall.
private static ConnectionRequest buildConnectionRequestForOutgoingCall(OutgoingCallRecord call) {
PhoneAccountHandle phoneAccount = verifyNotNull(call.phoneAccount);
Uri address = verifyNotNull(call.address);
Bundle extras = verifyNotNull(call.extras);
Bundle outgoingCallExtras = extras.getBundle(TelecomManager.EXTRA_OUTGOING_CALL_EXTRAS);
int videoState = extras.getInt(TelecomManager.EXTRA_START_CALL_WITH_VIDEO_STATE, VideoProfile.STATE_AUDIO_ONLY);
return new ConnectionRequest(phoneAccount, address, outgoingCallExtras == null ? null : new Bundle(outgoingCallExtras), videoState);
}
Aggregations