use of android.telecom.ConnectionService 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.ConnectionService 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.ConnectionService in project robolectric by robolectric.
the class ShadowTelecomManager method setupConnectionService.
private static ConnectionService setupConnectionService(PhoneAccountHandle phoneAccount) {
ComponentName service = phoneAccount.getComponentName();
Class<? extends ConnectionService> clazz;
try {
clazz = Class.forName(service.getClassName()).asSubclass(ConnectionService.class);
} catch (ClassNotFoundException e) {
throw new IllegalArgumentException(e);
}
return verifyNotNull(ServiceController.of(ReflectionHelpers.callConstructor(clazz), null).create().get());
}
use of android.telecom.ConnectionService 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.ConnectionService 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);
}
Aggregations