use of android.telecom.ConnectionRequest in project robolectric by robolectric.
the class ShadowTelecomManager method buildConnectionRequestForIncomingCall.
private static ConnectionRequest buildConnectionRequestForIncomingCall(IncomingCallRecord call) {
PhoneAccountHandle phoneAccount = verifyNotNull(call.phoneAccount);
Bundle extras = verifyNotNull(call.extras);
Uri address = extras.getParcelable(TelecomManager.EXTRA_INCOMING_CALL_ADDRESS);
int videoState = extras.getInt(TelecomManager.EXTRA_START_CALL_WITH_VIDEO_STATE, VideoProfile.STATE_AUDIO_ONLY);
return new ConnectionRequest(phoneAccount, address, new Bundle(extras), videoState);
}
use of android.telecom.ConnectionRequest in project robolectric by robolectric.
the class ShadowTelecomManager method allowOutgoingCall.
/**
* Allows an {@link OutgoingCallRecord} created via {@link TelecomManager#placeCall}.
*
* <p>Specifically, this method sets up the relevant {@link ConnectionService} and returns the
* result of {@link ConnectionService#onCreateOutgoingConnection}.
*/
@TargetApi(M)
@Nullable
public Connection allowOutgoingCall(OutgoingCallRecord call) {
if (call.isHandled) {
throw new IllegalStateException("Call has already been allowed or denied.");
}
call.isHandled = true;
PhoneAccountHandle phoneAccount = verifyNotNull(call.phoneAccount);
ConnectionRequest request = buildConnectionRequestForOutgoingCall(call);
ConnectionService service = setupConnectionService(phoneAccount);
return service.onCreateOutgoingConnection(phoneAccount, request);
}
use of android.telecom.ConnectionRequest in project robolectric by robolectric.
the class ShadowTelecomManager method denyIncomingCall.
/**
* Denies an {@link IncomingCallRecord} created via {@link TelecomManager#addNewIncomingCall}.
*
* <p>Specifically, this method sets up the relevant {@link ConnectionService} and calls {@link
* ConnectionService#onCreateIncomingConnectionFailed}.
*/
@TargetApi(O)
public void denyIncomingCall(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);
service.onCreateIncomingConnectionFailed(phoneAccount, request);
}
use of android.telecom.ConnectionRequest in project robolectric by robolectric.
the class ShadowTelecomManager method denyOutgoingCall.
/**
* Denies an {@link OutgoingCallRecord} created via {@link TelecomManager#placeCall}.
*
* <p>Specifically, this method sets up the relevant {@link ConnectionService} and calls {@link
* ConnectionService#onCreateOutgoingConnectionFailed}.
*/
@TargetApi(O)
public void denyOutgoingCall(OutgoingCallRecord call) {
if (call.isHandled) {
throw new IllegalStateException("Call has already been allowed or denied.");
}
call.isHandled = true;
PhoneAccountHandle phoneAccount = verifyNotNull(call.phoneAccount);
ConnectionRequest request = buildConnectionRequestForOutgoingCall(call);
ConnectionService service = setupConnectionService(phoneAccount);
service.onCreateOutgoingConnectionFailed(phoneAccount, request);
}
use of android.telecom.ConnectionRequest in project robolectric by robolectric.
the class ShadowTelecomManagerTest method testAllowNewIncomingCall.
@Test
public void testAllowNewIncomingCall() {
shadowOf(telecomService).setCallRequestMode(CallRequestMode.ALLOW_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).onCreateIncomingConnection(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);
}
Aggregations