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_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 to inform the implemented CallRedirectionService of a new outgoing call which is being placed.

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 handle, 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

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

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).

onBind

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: The Intent that was used to bind to this service, as given to Context.bindService. Note that any extras that were included with the Intent at that point will not be seen here.

Returns
IBinder Return an IBinder through which clients can call on to the service.

onPlaceCall

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

Telecom calls this method to inform the implemented CallRedirectionService 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.

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

initialPhoneAccount PhoneAccountHandle: the PhoneAccountHandle on which the call will be placed. This value must never 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.

onUnbind

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: The Intent that was used to bind to this service, as given to Context.bindService. Note that any extras that were included with the Intent at that point will not be seen here.

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

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).

redirectCall

public final void redirectCall (Uri handle, 
                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).

Parameters
handle Uri: the new phone number to dial This value must never be null.

targetPhoneAccount PhoneAccountHandle: the PhoneAccountHandle to use when placing the call. If null, no change will be made to the PhoneAccountHandle used to place the call. This value must never 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)