public abstract class ConnectionService extends Service
ConnectionService
needs two additional steps before it will be
integrated into the phone app:
1. Registration in AndroidManifest.xml
<service android:name="com.example.package.MyConnectionService" android:label="@string/some_label_for_my_connection_service" android:permission="android.permission.BIND_TELECOM_CONNECTION_SERVICE"> <intent-filter> <action android:name="android.telecom.ConnectionService" /> </intent-filter> </service>
2. Registration of PhoneAccount
with TelecomManager
.
See PhoneAccount
and TelecomManager.registerPhoneAccount(android.telecom.PhoneAccount)
for more information.
Once registered and enabled by the user in the phone app settings, telecom will bind to a
ConnectionService
implementation when it wants that ConnectionService
to place
a call or the service has indicated that is has an incoming call through
TelecomManager.addNewIncomingCall(android.telecom.PhoneAccountHandle, android.os.Bundle)
. The ConnectionService
can then expect a call
to onCreateIncomingConnection(android.telecom.PhoneAccountHandle, android.telecom.ConnectionRequest)
or onCreateOutgoingConnection(android.telecom.PhoneAccountHandle, android.telecom.ConnectionRequest)
wherein it
should provide a new instance of a Connection
object. It is through this
Connection
object that telecom receives state updates and the ConnectionService
receives call-commands such as answer, reject, hold and disconnect.
When there are no more live calls, telecom will unbind from the ConnectionService
.
Service.StartArgFlags, Service.StartResult, Service.StopForegroundFlags
Context.BindServiceFlags, Context.CreatePackageOptions, Context.ServiceName
Modifier and Type | Field and Description |
---|---|
static String |
SERVICE_INTERFACE
The
Intent that must be declared as handled by the service. |
START_CONTINUATION_MASK, START_FLAG_REDELIVERY, START_FLAG_RETRY, START_NOT_STICKY, START_REDELIVER_INTENT, START_STICKY, START_STICKY_COMPATIBILITY, START_TASK_REMOVED_COMPLETE, STOP_FOREGROUND_DETACH, STOP_FOREGROUND_REMOVE
ACCESSIBILITY_SERVICE, ACCOUNT_SERVICE, ACTIVITY_SERVICE, ALARM_SERVICE, APP_OPS_SERVICE, APPWIDGET_SERVICE, AUDIO_SERVICE, BACKUP_SERVICE, BATTERY_SERVICE, BIND_ABOVE_CLIENT, BIND_ADJUST_WITH_ACTIVITY, BIND_ALLOW_OOM_MANAGEMENT, BIND_ALLOW_WHITELIST_MANAGEMENT, BIND_AUTO_CREATE, BIND_DEBUG_UNBIND, BIND_EXTERNAL_SERVICE, BIND_FOREGROUND_SERVICE, BIND_FOREGROUND_SERVICE_WHILE_AWAKE, BIND_IMPORTANT, BIND_NOT_FOREGROUND, BIND_NOT_VISIBLE, BIND_SHOWING_UI, BIND_TREAT_LIKE_ACTIVITY, BIND_VISIBLE, BIND_WAIVE_PRIORITY, BLUETOOTH_SERVICE, CAMERA_SERVICE, CAPTIONING_SERVICE, CARRIER_CONFIG_SERVICE, CLIPBOARD_SERVICE, CONNECTIVITY_SERVICE, CONSUMER_IR_SERVICE, CONTEXT_CREDENTIAL_PROTECTED_STORAGE, CONTEXT_DEVICE_PROTECTED_STORAGE, CONTEXT_IGNORE_SECURITY, CONTEXT_INCLUDE_CODE, CONTEXT_REGISTER_PACKAGE, CONTEXT_RESTRICTED, CONTEXTHUB_SERVICE, COUNTRY_DETECTOR, DEVICE_IDLE_CONTROLLER, DEVICE_POLICY_SERVICE, DISPLAY_SERVICE, DOWNLOAD_SERVICE, DROPBOX_SERVICE, ETHERNET_SERVICE, FINGERPRINT_SERVICE, GATEKEEPER_SERVICE, HARDWARE_PROPERTIES_SERVICE, HDMI_CONTROL_SERVICE, INPUT_METHOD_SERVICE, INPUT_SERVICE, JOB_SCHEDULER_SERVICE, KEYGUARD_SERVICE, LAUNCHER_APPS_SERVICE, LAYOUT_INFLATER_SERVICE, LOCATION_SERVICE, MEDIA_PROJECTION_SERVICE, MEDIA_ROUTER_SERVICE, MEDIA_SESSION_SERVICE, MIDI_SERVICE, MODE_APPEND, MODE_ENABLE_WRITE_AHEAD_LOGGING, MODE_MULTI_PROCESS, MODE_NO_LOCALIZED_COLLATORS, MODE_PRIVATE, MODE_WORLD_READABLE, MODE_WORLD_WRITEABLE, NETWORK_POLICY_SERVICE, NETWORK_SCORE_SERVICE, NETWORK_STATS_SERVICE, NETWORKMANAGEMENT_SERVICE, NFC_SERVICE, NOTIFICATION_SERVICE, NSD_SERVICE, PERSISTENT_DATA_BLOCK_SERVICE, POWER_SERVICE, PRINT_SERVICE, RADIO_SERVICE, RECOVERY_SERVICE, RESTRICTIONS_SERVICE, SEARCH_SERVICE, SENSOR_SERVICE, SERIAL_SERVICE, SHORTCUT_SERVICE, SIP_SERVICE, SOUND_TRIGGER_SERVICE, STATUS_BAR_SERVICE, STORAGE_SERVICE, SYSTEM_HEALTH_SERVICE, TELECOM_SERVICE, TELEPHONY_SERVICE, TELEPHONY_SUBSCRIPTION_SERVICE, TEXT_SERVICES_MANAGER_SERVICE, TRUST_SERVICE, TV_INPUT_SERVICE, UI_MODE_SERVICE, UPDATE_LOCK_SERVICE, USAGE_STATS_SERVICE, USB_SERVICE, USER_SERVICE, VIBRATOR_SERVICE, VOICE_INTERACTION_MANAGER_SERVICE, WALLPAPER_SERVICE, WIFI_NAN_SERVICE, WIFI_P2P_SERVICE, WIFI_RTT_SERVICE, WIFI_SCANNING_SERVICE, WIFI_SERVICE, WINDOW_SERVICE
TRIM_MEMORY_BACKGROUND, TRIM_MEMORY_COMPLETE, TRIM_MEMORY_MODERATE, TRIM_MEMORY_RUNNING_CRITICAL, TRIM_MEMORY_RUNNING_LOW, TRIM_MEMORY_RUNNING_MODERATE, TRIM_MEMORY_UI_HIDDEN
Constructor and Description |
---|
ConnectionService() |
Modifier and Type | Method and Description |
---|---|
void |
addConference(Conference conference)
Adds a new conference call.
|
void |
addExistingConnection(PhoneAccountHandle phoneAccountHandle,
Connection connection)
Adds a connection created by the
ConnectionService and informs telecom of the new
connection. |
void |
conferenceRemoteConnections(RemoteConnection remoteConnection1,
RemoteConnection remoteConnection2)
Indicates to the relevant
RemoteConnectionService that the specified
RemoteConnection s should be merged into a conference call. |
boolean |
containsConference(Conference conference) |
RemoteConnection |
createRemoteIncomingConnection(PhoneAccountHandle connectionManagerPhoneAccount,
ConnectionRequest request)
Ask some other
ConnectionService to create a RemoteConnection given an
incoming request. |
RemoteConnection |
createRemoteOutgoingConnection(PhoneAccountHandle connectionManagerPhoneAccount,
ConnectionRequest request)
Ask some other
ConnectionService to create a RemoteConnection given an
outgoing request. |
Collection<Conference> |
getAllConferences()
Returns all the active
Conference s for which this ConnectionService
has taken responsibility. |
Collection<Connection> |
getAllConnections()
Returns all the active
Connection s for which this ConnectionService
has taken responsibility. |
IBinder |
onBind(Intent intent)
Return the communication channel to the service.
|
void |
onConference(Connection connection1,
Connection connection2)
Conference two specified connections.
|
Connection |
onCreateIncomingConnection(PhoneAccountHandle connectionManagerPhoneAccount,
ConnectionRequest request)
Create a
Connection given an incoming request. |
Connection |
onCreateOutgoingConnection(PhoneAccountHandle connectionManagerPhoneAccount,
ConnectionRequest request)
Create a
Connection given an outgoing request. |
Connection |
onCreateUnknownConnection(PhoneAccountHandle connectionManagerPhoneAccount,
ConnectionRequest request)
Create a
Connection for a new unknown call. |
void |
onRemoteConferenceAdded(RemoteConference conference)
Indicates that a remote conference has been created for existing
RemoteConnection s. |
void |
onRemoteExistingConnectionAdded(RemoteConnection connection)
Called when an existing connection is added remotely.
|
boolean |
onUnbind(Intent intent)
Called when all clients have disconnected from a particular interface
published by the service.
|
protected void |
removeConnection(Connection connection) |
void |
triggerConferenceRecalculate()
Trigger recalculate functinality for conference calls.
|
attach, dump, getApplication, onConfigurationChanged, onCreate, onDestroy, onLowMemory, onRebind, onStart, onStartCommand, onTaskRemoved, onTrimMemory, setForeground, startForeground, stopForeground, stopForeground, stopSelf, stopSelf, stopSelfResult
attachBaseContext, bindService, bindServiceAsUser, canStartActivityForResult, checkCallingOrSelfPermission, checkCallingOrSelfUriPermission, checkCallingPermission, checkCallingUriPermission, checkPermission, checkPermission, checkSelfPermission, checkUriPermission, checkUriPermission, checkUriPermission, clearWallpaper, createApplicationContext, createConfigurationContext, createCredentialProtectedStorageContext, createDeviceProtectedStorageContext, createDisplayContext, createPackageContext, createPackageContextAsUser, databaseList, deleteDatabase, deleteFile, deleteSharedPreferences, enforceCallingOrSelfPermission, enforceCallingOrSelfUriPermission, enforceCallingPermission, enforceCallingUriPermission, enforcePermission, enforceUriPermission, enforceUriPermission, fileList, getApplicationContext, getApplicationInfo, getAssets, getBaseContext, getBasePackageName, getCacheDir, getClassLoader, getCodeCacheDir, getContentResolver, getDatabasePath, getDataDir, getDir, getDisplay, getDisplayAdjustments, getExternalCacheDir, getExternalCacheDirs, getExternalFilesDir, getExternalFilesDirs, getExternalMediaDirs, getFilesDir, getFileStreamPath, getMainLooper, getNoBackupFilesDir, getObbDir, getObbDirs, getOpPackageName, getPackageCodePath, getPackageManager, getPackageName, getPackageResourcePath, getResources, getSharedPreferences, getSharedPreferences, getSharedPreferencesPath, getSystemService, getSystemServiceName, getTheme, getThemeResId, getUserId, getWallpaper, getWallpaperDesiredMinimumHeight, getWallpaperDesiredMinimumWidth, grantUriPermission, isCredentialProtectedStorage, isDeviceProtectedStorage, isRestricted, moveDatabaseFrom, moveSharedPreferencesFrom, openFileInput, openFileOutput, openOrCreateDatabase, openOrCreateDatabase, peekWallpaper, registerReceiver, registerReceiver, registerReceiverAsUser, removeStickyBroadcast, removeStickyBroadcastAsUser, revokeUriPermission, sendBroadcast, sendBroadcast, sendBroadcast, sendBroadcast, sendBroadcastAsUser, sendBroadcastAsUser, sendBroadcastAsUser, sendBroadcastMultiplePermissions, sendOrderedBroadcast, sendOrderedBroadcast, sendOrderedBroadcast, sendOrderedBroadcast, sendOrderedBroadcastAsUser, sendOrderedBroadcastAsUser, sendOrderedBroadcastAsUser, sendStickyBroadcast, sendStickyBroadcastAsUser, sendStickyBroadcastAsUser, sendStickyOrderedBroadcast, sendStickyOrderedBroadcastAsUser, setTheme, setWallpaper, setWallpaper, startActivities, startActivities, startActivitiesAsUser, startActivity, startActivity, startActivityAsUser, startActivityAsUser, startActivityForResult, startInstrumentation, startIntentSender, startIntentSender, startService, startServiceAsUser, stopService, stopServiceAsUser, unbindService, unregisterReceiver
bindServiceAsUser, createCredentialEncryptedStorageContext, createDeviceEncryptedStorageContext, getColor, getColorStateList, getDrawable, getSharedPrefsFile, getString, getString, getSystemService, getText, isCredentialEncryptedStorage, isDeviceEncryptedStorage, migrateDatabaseFrom, migrateSharedPreferencesFrom, obtainStyledAttributes, obtainStyledAttributes, obtainStyledAttributes, obtainStyledAttributes, registerComponentCallbacks, unregisterComponentCallbacks
public static final String SERVICE_INTERFACE
Intent
that must be declared as handled by the service.public final IBinder onBind(Intent intent)
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.
onBind
in class Service
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.public boolean onUnbind(Intent intent)
onUnbind
in class Service
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.Service.onRebind(android.content.Intent)
method later called when new clients bind to it.public final RemoteConnection createRemoteIncomingConnection(PhoneAccountHandle connectionManagerPhoneAccount, ConnectionRequest request)
ConnectionService
to create a RemoteConnection
given an
incoming request. This is used by ConnectionService
s that are registered with
PhoneAccount.CAPABILITY_CONNECTION_MANAGER
and want to be able to manage
SIM-based incoming calls.connectionManagerPhoneAccount
- See description at
onCreateOutgoingConnection(PhoneAccountHandle, ConnectionRequest)
.request
- Details about the incoming call.Connection
object to satisfy this call, or null
to
not handle the call.public final RemoteConnection createRemoteOutgoingConnection(PhoneAccountHandle connectionManagerPhoneAccount, ConnectionRequest request)
ConnectionService
to create a RemoteConnection
given an
outgoing request. This is used by ConnectionService
s that are registered with
PhoneAccount.CAPABILITY_CONNECTION_MANAGER
and want to be able to use the
SIM-based ConnectionService
to place its outgoing calls.connectionManagerPhoneAccount
- See description at
onCreateOutgoingConnection(PhoneAccountHandle, ConnectionRequest)
.request
- Details about the incoming call.Connection
object to satisfy this call, or null
to
not handle the call.public final void conferenceRemoteConnections(RemoteConnection remoteConnection1, RemoteConnection remoteConnection2)
RemoteConnectionService
that the specified
RemoteConnection
s should be merged into a conference call.
If the conference request is successful, the method onRemoteConferenceAdded(android.telecom.RemoteConference)
will
be invoked.
remoteConnection1
- The first of the remote connections to conference.remoteConnection2
- The second of the remote connections to conference.public final void addConference(Conference conference)
onConference(android.telecom.Connection, android.telecom.Connection)
or otherwise, the connection service should supply
an instance of Conference
by invoking this method. A conference call provided by this
method will persist until Conference.destroy()
is invoked on the conference instance.conference
- The new conference object.public final void addExistingConnection(PhoneAccountHandle phoneAccountHandle, Connection connection)
ConnectionService
and informs telecom of the new
connection.phoneAccountHandle
- The phone account handle for the connection.connection
- The connection to add.public final Collection<Connection> getAllConnections()
Connection
s for which this ConnectionService
has taken responsibility.Connection
s created by this ConnectionService
.public final Collection<Conference> getAllConferences()
Conference
s for which this ConnectionService
has taken responsibility.Conference
s created by this ConnectionService
.public Connection onCreateIncomingConnection(PhoneAccountHandle connectionManagerPhoneAccount, ConnectionRequest request)
Connection
given an incoming request. This is used to attach to existing
incoming calls.connectionManagerPhoneAccount
- See description at
onCreateOutgoingConnection(PhoneAccountHandle, ConnectionRequest)
.request
- Details about the incoming call.Connection
object to satisfy this call, or null
to
not handle the call.public void triggerConferenceRecalculate()
public Connection onCreateOutgoingConnection(PhoneAccountHandle connectionManagerPhoneAccount, ConnectionRequest request)
Connection
given an outgoing request. This is used to initiate new
outgoing calls.connectionManagerPhoneAccount
- The connection manager account to use for managing
this call.
If this parameter is not null
, it means that this ConnectionService
has registered one or more PhoneAccount
s having
PhoneAccount.CAPABILITY_CONNECTION_MANAGER
. This parameter will contain
one of these PhoneAccount
s, while the request
will contain another
(usually but not always distinct) PhoneAccount
to be used for actually
making the connection.
If this parameter is null
, it means that this ConnectionService
is
being asked to make a direct connection. The
ConnectionRequest.getAccountHandle()
of parameter request
will be
a PhoneAccount
registered by this ConnectionService
to use for
making the connection.
request
- Details about the outgoing call.Connection
object to satisfy this call, or the result of an invocation
of Connection.createFailedConnection(DisconnectCause)
to not handle the call.public Connection onCreateUnknownConnection(PhoneAccountHandle connectionManagerPhoneAccount, ConnectionRequest request)
Connection
for a new unknown call. An unknown call is a call originating
from the ConnectionService that was neither a user-initiated outgoing call, nor an incoming
call created using
TelecomManager#addNewIncomingCall(PhoneAccountHandle, android.os.Bundle)
.connectionManagerPhoneAccount
- request
- public void onConference(Connection connection1, Connection connection2)
Conference
and pass it into addConference(android.telecom.Conference)
.connection1
- A connection to merge into a conference call.connection2
- A connection to merge into a conference call.public void onRemoteConferenceAdded(RemoteConference conference)
RemoteConnection
s.
When this method is invoked, this ConnectionService
should create its own
representation of the conference call and send it to telecom using addConference(android.telecom.Conference)
.
This is only relevant to ConnectionService
s which are registered with
PhoneAccount.CAPABILITY_CONNECTION_MANAGER
.
conference
- The remote conference call.public void onRemoteExistingConnectionAdded(RemoteConnection connection)
connection
- The existing connection which was added.public boolean containsConference(Conference conference)
protected void removeConnection(Connection connection)