CallRedirectionService

public abstract class CallRedirectionService
extends Service

java.lang.Object
   ↳ android.content.Context
     ↳ android.content.ContextWrapper
       ↳ android.app.Service
         ↳ android.telecom.CallRedirectionService


This service can be implemented to interact between Telecom and its implementor for making outgoing call with optional redirection/cancellation purposes.

Below is an example manifest registration for a CallRedirectionService. <service android:name="your.package.YourCallRedirectionServiceImplementation" android:permission="android.permission.BIND_CALL_REDIRECTION_SERVICE"> <intent-filter> <action android:name="android.telecom.CallRedirectionService"/> </intent-filter> </service>

Summary

Constants

String SERVICE_INTERFACE

The Intent that must be declared as handled by the service.

Inherited constants

Public constructors

CallRedirectionService()

Public methods

final void cancelCall()

The implemented CallRedirectionService calls this method to response a request received via onPlaceCall(android.net.Uri, android.telecom.PhoneAccountHandle, boolean) to inform Telecom that an outgoing call should be canceled entirely.

final IBinder onBind(Intent intent)

Return the communication channel to the service.

abstract void onPlaceCall(Uri handle, PhoneAccountHandle initialPhoneAccount, boolean allowInteractiveResponse)

Telecom calls this method once upon binding to a CallRedirectionService to inform it of a new outgoing call which is being placed.

void onRedirectionTimeout()

Telecom calls this method when times out waiting for the CallRedirectionService to call placeCallUnmodified(), redirectCall(android.net.Uri, android.telecom.PhoneAccountHandle, boolean), or cancelCall()

final boolean onUnbind(Intent intent)

Called when all clients have disconnected from a particular interface published by the service.

final void placeCallUnmodified()

The implemented CallRedirectionService calls this method to response a request received via onPlaceCall(android.net.Uri, android.telecom.PhoneAccountHandle, boolean) to inform Telecom that no changes are required to the outgoing call, and that the call should be placed as-is.

final void redirectCall(Uri gatewayUri, PhoneAccountHandle targetPhoneAccount, boolean confirmFirst)

The implemented CallRedirectionService calls this method to response a request received via onPlaceCall(android.net.Uri, android.telecom.PhoneAccountHandle, boolean) to inform Telecom that changes are required to the phone number or/and PhoneAccountHandle for the outgoing call.

Inherited methods

Constants

SERVICE_INTERFACE

Added in API level 29
public static final String SERVICE_INTERFACE

The Intent that must be declared as handled by the service.

Constant Value: "android.telecom.CallRedirectionService"

Public constructors

CallRedirectionService

public CallRedirectionService ()

Public methods

cancelCall

Added in API level 29
public final void cancelCall ()

The implemented CallRedirectionService calls this method to response a request received via onPlaceCall(android.net.Uri, android.telecom.PhoneAccountHandle, boolean) to inform Telecom that an outgoing call should be canceled entirely.

This can only be called from implemented onPlaceCall(android.net.Uri, android.telecom.PhoneAccountHandle, boolean). The response corresponds to the latest request via onPlaceCall(android.net.Uri, android.telecom.PhoneAccountHandle, boolean).

onBind

Added in API level 29
public final IBinder onBind (Intent intent)

Return the communication channel to the service. May return null if clients can not bind to the service. The returned IBinder is usually for a complex interface that has been described using aidl.

Note that unlike other application components, calls on to the IBinder interface returned here may not happen on the main thread of the process. More information about the main thread can be found in Processes and Threads.

Parameters
intent Intent: This value cannot be null.

Returns
IBinder This value may be null.

onPlaceCall

Added in API level 29
public abstract void onPlaceCall (Uri handle, 
                PhoneAccountHandle initialPhoneAccount, 
                boolean allowInteractiveResponse)

Telecom calls this method once upon binding to a CallRedirectionService to inform it of a new outgoing call which is being placed. Telecom does not request to redirect emergency calls and does not request to redirect calls with gateway information.

Telecom will cancel the call if Telecom does not receive a response in 5 seconds from the implemented CallRedirectionService set by users.

The implemented CallRedirectionService can call placeCallUnmodified(), redirectCall(android.net.Uri, android.telecom.PhoneAccountHandle, boolean), and cancelCall() only from here. Calls to these methods are assumed by the Telecom framework to be the response for the phone call for which onPlaceCall(android.net.Uri, android.telecom.PhoneAccountHandle, boolean) was invoked by Telecom. The Telecom framework will only invoke onPlaceCall(android.net.Uri, android.telecom.PhoneAccountHandle, boolean) once each time it binds to a CallRedirectionService.

Parameters
handle Uri: the phone number dialed by the user, represented in E.164 format if possible This value cannot be null.

initialPhoneAccount PhoneAccountHandle: the PhoneAccountHandle on which the call will be placed. This value cannot be null.

allowInteractiveResponse boolean: a boolean to tell if the implemented CallRedirectionService should allow interactive responses with users. Will be false if, for example the device is in car mode and the user would not be able to interact with their device.

onRedirectionTimeout

Added in API level 33
public void onRedirectionTimeout ()

Telecom calls this method when times out waiting for the CallRedirectionService to call placeCallUnmodified(), redirectCall(android.net.Uri, android.telecom.PhoneAccountHandle, boolean), or cancelCall()

onUnbind

Added in API level 29
public final boolean onUnbind (Intent intent)

Called when all clients have disconnected from a particular interface published by the service. The default implementation does nothing and returns false.

Parameters
intent Intent: This value cannot be null.

Returns
boolean Return true if you would like to have the service's onRebind(Intent) method later called when new clients bind to it.

placeCallUnmodified

Added in API level 29
public final void placeCallUnmodified ()

The implemented CallRedirectionService calls this method to response a request received via onPlaceCall(android.net.Uri, android.telecom.PhoneAccountHandle, boolean) to inform Telecom that no changes are required to the outgoing call, and that the call should be placed as-is.

This can only be called from implemented onPlaceCall(android.net.Uri, android.telecom.PhoneAccountHandle, boolean). The response corresponds to the latest request via onPlaceCall(android.net.Uri, android.telecom.PhoneAccountHandle, boolean).

redirectCall

Added in API level 29
public final void redirectCall (Uri gatewayUri, 
                PhoneAccountHandle targetPhoneAccount, 
                boolean confirmFirst)

The implemented CallRedirectionService calls this method to response a request received via onPlaceCall(android.net.Uri, android.telecom.PhoneAccountHandle, boolean) to inform Telecom that changes are required to the phone number or/and PhoneAccountHandle for the outgoing call. Telecom will cancel the call if the implemented CallRedirectionService replies Telecom a handle for an emergency number.

This can only be called from implemented onPlaceCall(android.net.Uri, android.telecom.PhoneAccountHandle, boolean). The response corresponds to the latest request via onPlaceCall(android.net.Uri, android.telecom.PhoneAccountHandle, boolean).

Parameters
gatewayUri Uri: the gateway uri for call redirection. This value cannot be null.

targetPhoneAccount PhoneAccountHandle: the PhoneAccountHandle to use when placing the call. This value cannot be null.

confirmFirst boolean: Telecom will ask users to confirm the redirection via a yes/no dialog if the confirmFirst is true, and if the redirection request of this response was sent with a true flag of allowInteractiveResponse via onPlaceCall(android.net.Uri, android.telecom.PhoneAccountHandle, boolean)