abstract class DeviceSetupService : Service


This service builds upon the functionality of CredentialProviderService by enabling support for more advanced credential requests, such as device setup.

Note that this service is distinct from CredentialProviderService, which handles basic credential saving and retrieval requests. This service is mainly used to help with user pain point of credentials onboarding during device setup. When the user is setting up a new device, the credential provider can assist with the onboarding by either transferring the credentials to the new device, or receiving the credentials if the current device is the one doing the onboarding.

This service is bound only during the duration of an API call. To receive requests, users must enable the corresponding CredentialProviderService from within the same package, in Android Settings. This service will be invoked as part of Android onboarding and will not contain any UI as part of the process.

Basic Usage

The interaction between Credential Manager and this service typically involves:

  • The Android system forwards the request to enabled credential providers that support the requested feature.

  • Credential providers receive the request, process it, and return an appropriate response.

  • The Android system sends the result back to the client application.

This flow is designed to minimize the service's lifecycle. Calls to the service are stateless. If a service requires maintaining states between calls, it must implement its own state management. Note that the service's process may be terminated by the Android System when unbound, such as during low-memory conditions.

Service Registration

To enable Credential Manager to send requests to a provider service, the provider must:

  • Extend this class and implement the required methods.

  • Declare this service class within Android Manifest with corresponding intent action "androidx.credentials.DEVICE_SETUP_SERVICE_ACTION".

Summary

Public constructors

Public functions

final IBinder?
onBind(intent: Intent?)
abstract Unit

Called when a credential provider should receive credentials for device setup.

abstract Unit

Called when a credential provider should return the state of its credentials to the user.

abstract Unit

Called when a credential provider should return credentials for device setup.

Inherited functions

From android.content.ComponentCallbacks
From android.content.ComponentCallbacks2
open Unit
onTrimMemory(level: Int)
From android.content.Context
open Boolean
bindIsolatedService(
    service: Intent,
    flags: Context.BindServiceFlags,
    instanceName: String,
    executor: Executor,
    conn: ServiceConnection
)
open Boolean
bindIsolatedService(
    service: Intent,
    flags: Int,
    instanceName: String,
    executor: Executor,
    conn: ServiceConnection
)
open Boolean
bindService(
    service: Intent,
    conn: ServiceConnection,
    flags: Context.BindServiceFlags
)
open Boolean
bindService(service: Intent, conn: ServiceConnection, flags: Int)
open Boolean
bindService(
    service: Intent,
    flags: Context.BindServiceFlags,
    executor: Executor,
    conn: ServiceConnection
)
open Boolean
bindService(
    service: Intent,
    flags: Int,
    executor: Executor,
    conn: ServiceConnection
)
open Boolean
bindServiceAsUser(
    service: Intent,
    conn: ServiceConnection,
    flags: Context.BindServiceFlags,
    user: UserHandle
)
open Boolean
bindServiceAsUser(
    service: Intent,
    conn: ServiceConnection,
    flags: Int,
    user: UserHandle
)
open Int
open Int
open IntArray
open Int
open Int
checkCallingUriPermission(uri: Uri, modeFlags: Int)
open IntArray
open Int
checkContentUriPermissionFull(uri: Uri, pid: Int, uid: Int, modeFlags: Int)
open Int
checkPermission(permission: String, pid: Int, uid: Int)
open Int
open Int
checkUriPermission(uri: Uri, pid: Int, uid: Int, modeFlags: Int)
open Int
checkUriPermission(
    uri: Uri?,
    readPermission: String?,
    writePermission: String?,
    pid: Int,
    uid: Int,
    modeFlags: Int
)
open IntArray
checkUriPermissions(
    uris: MutableList<Uri>,
    pid: Int,
    uid: Int,
    modeFlags: Int
)
open Unit

This function is deprecated. Deprecated in Java

open Context
createAttributionContext(attributionTag: String?)
open Context
createConfigurationContext(overrideConfiguration: Configuration)
open Context
createContext(contextParams: ContextParams)
open Context
open Context
open Context
open Context
open Context
createPackageContext(packageName: String, flags: Int)
open Context
createWindowContext(type: Int, options: Bundle?)
open Context
createWindowContext(display: Display, type: Int, options: Bundle?)
open Array<String>
open Boolean
open Boolean
open Boolean
open Unit
enforceCallingOrSelfPermission(permission: String, message: String?)
open Unit
enforceCallingOrSelfUriPermission(
    uri: Uri,
    modeFlags: Int,
    message: String
)
open Unit
enforceCallingPermission(permission: String, message: String?)
open Unit
enforceCallingUriPermission(uri: Uri, modeFlags: Int, message: String)
open Unit
enforcePermission(permission: String, pid: Int, uid: Int, message: String?)
open Unit
enforceUriPermission(
    uri: Uri,
    pid: Int,
    uid: Int,
    modeFlags: Int,
    message: String
)
open Unit
enforceUriPermission(
    uri: Uri?,
    readPermission: String?,
    writePermission: String?,
    pid: Int,
    uid: Int,
    modeFlags: Int,
    message: String?
)
open Array<String>
Int
ColorStateList
open File
open File
getDir(name: String, mode: Int)
Drawable?
open File?
open Array<File>
open File
open SharedPreferences
String
getString(resId: Int)
String
getString(resId: Int, vararg formatArgs: Any)
open Any
T
<T : Any> getSystemService(serviceClass: Class<T>)
open String?
getSystemServiceName(serviceClass: Class<*>)
CharSequence
getText(resId: Int)
open Unit
grantUriPermission(toPackage: String, uri: Uri, modeFlags: Int)
open Boolean
moveDatabaseFrom(sourceContext: Context, name: String)
open Boolean
moveSharedPreferencesFrom(sourceContext: Context, name: String)
TypedArray
TypedArray
TypedArray
TypedArray
obtainStyledAttributes(
    set: AttributeSet?,
    attrs: IntArray,
    defStyleAttr: Int,
    defStyleRes: Int
)
open FileInputStream
open FileOutputStream
openFileOutput(name: String, mode: Int)
open SQLiteDatabase
openOrCreateDatabase(
    name: String,
    mode: Int,
    factory: SQLiteDatabase.CursorFactory
)
open SQLiteDatabase
openOrCreateDatabase(
    name: String,
    mode: Int,
    factory: SQLiteDatabase.CursorFactory,
    errorHandler: DatabaseErrorHandler?
)
open Drawable

This function is deprecated. Deprecated in Java

open Unit
open Unit
open Intent?
open Intent?
registerReceiver(
    receiver: BroadcastReceiver?,
    filter: IntentFilter,
    flags: Int
)
open Intent?
registerReceiver(
    receiver: BroadcastReceiver?,
    filter: IntentFilter,
    broadcastPermission: String?,
    scheduler: Handler?
)
open Intent?
registerReceiver(
    receiver: BroadcastReceiver?,
    filter: IntentFilter,
    broadcastPermission: String?,
    scheduler: Handler?,
    flags: Int
)
open Unit

This function is deprecated. Deprecated in Java

open Unit

This function is deprecated. Deprecated in Java

open Unit
open Unit
open Unit
revokeUriPermission(uri: Uri, modeFlags: Int)
open Unit
revokeUriPermission(targetPackage: String, uri: Uri, modeFlags: Int)
open Unit
open Unit
sendBroadcast(intent: Intent, receiverPermission: String?)
open Unit
sendBroadcast(intent: Intent, receiverPermission: String?, options: Bundle?)
open Unit
open Unit
sendBroadcastAsUser(
    intent: Intent,
    user: UserHandle,
    receiverPermission: String?
)
open Unit
sendBroadcastWithMultiplePermissions(
    intent: Intent,
    receiverPermissions: Array<String>
)
open Unit
sendOrderedBroadcast(intent: Intent, receiverPermission: String?)
open Unit
sendOrderedBroadcast(
    intent: Intent,
    receiverPermission: String?,
    options: Bundle?
)
open Unit
sendOrderedBroadcast(
    intent: Intent,
    receiverPermission: String?,
    resultReceiver: BroadcastReceiver?,
    scheduler: Handler?,
    initialCode: Int,
    initialData: String?,
    initialExtras: Bundle?
)
open Unit
sendOrderedBroadcast(
    intent: Intent,
    receiverPermission: String?,
    options: Bundle?,
    resultReceiver: BroadcastReceiver?,
    scheduler: Handler?,
    initialCode: Int,
    initialData: String?,
    initialExtras: Bundle?
)
open Unit
sendOrderedBroadcast(
    intent: Intent,
    receiverPermission: String?,
    receiverAppOp: String?,
    resultReceiver: BroadcastReceiver?,
    scheduler: Handler?,
    initialCode: Int,
    initialData: String?,
    initialExtras: Bundle?
)
open Unit
sendOrderedBroadcastAsUser(
    intent: Intent,
    user: UserHandle,
    receiverPermission: String?,
    resultReceiver: BroadcastReceiver?,
    scheduler: Handler?,
    initialCode: Int,
    initialData: String?,
    initialExtras: Bundle?
)
open Unit

This function is deprecated. Deprecated in Java

open Unit
sendStickyBroadcast(intent: Intent, options: Bundle?)

This function is deprecated. Deprecated in Java

open Unit

This function is deprecated. Deprecated in Java

open Unit
sendStickyOrderedBroadcast(
    intent: Intent,
    resultReceiver: BroadcastReceiver?,
    scheduler: Handler?,
    initialCode: Int,
    initialData: String?,
    initialExtras: Bundle?
)

This function is deprecated. Deprecated in Java

open Unit
sendStickyOrderedBroadcastAsUser(
    intent: Intent,
    user: UserHandle,
    resultReceiver: BroadcastReceiver?,
    scheduler: Handler?,
    initialCode: Int,
    initialData: String?,
    initialExtras: Bundle?
)

This function is deprecated. Deprecated in Java

open Unit
setTheme(resid: Int)
open Unit

This function is deprecated. Deprecated in Java

open Unit

This function is deprecated. Deprecated in Java

open Unit
open Unit
startActivities(intents: Array<Intent>, options: Bundle?)
open Unit
open Unit
startActivity(intent: Intent, options: Bundle?)
open ComponentName?
open Boolean
startInstrumentation(
    className: ComponentName,
    profileFile: String?,
    arguments: Bundle?
)
open Unit
startIntentSender(
    intent: IntentSender,
    fillInIntent: Intent?,
    flagsMask: Int,
    flagsValues: Int,
    extraFlags: Int
)
open Unit
startIntentSender(
    intent: IntentSender,
    fillInIntent: Intent?,
    flagsMask: Int,
    flagsValues: Int,
    extraFlags: Int,
    options: Bundle?
)
open ComponentName?
startService(service: Intent)
open Boolean
open Unit
open Unit
open Unit
open Unit
open Unit
updateServiceGroup(conn: ServiceConnection, group: Int, importance: Int)
From android.content.ContextWrapper
open Unit
open Unit
sendOrderedBroadcast(
    intent: Intent,
    initialCode: Int,
    receiverPermission: String?,
    receiverAppOp: String?,
    resultReceiver: BroadcastReceiver?,
    scheduler: Handler?,
    initialData: String?,
    initialExtras: Bundle?,
    options: Bundle?
)
From android.app.Service
open Unit
dump(fd: FileDescriptor, writer: PrintWriter, args: Array<String>)
open Unit
open Unit
open Unit
onRebind(intent: Intent)
open Unit
onStart(intent: Intent, startId: Int)

This function is deprecated. Deprecated in Java

open Int
onStartCommand(intent: Intent, flags: Int, startId: Int)
open Unit
onTaskRemoved(rootIntent: Intent)
open Unit
onTimeout(startId: Int)
open Unit
onTimeout(startId: Int, fgsType: Int)
open Boolean
onUnbind(intent: Intent)
Unit
startForeground(id: Int, notification: Notification)
Unit
startForeground(
    id: Int,
    notification: Notification,
    foregroundServiceType: Int
)
Unit
stopForeground(notificationBehavior: Int)
Unit
stopForeground(removeNotification: Boolean)

This function is deprecated. Deprecated in Java

Unit
Unit
stopSelf(startId: Int)
Boolean
stopSelfResult(startId: Int)

Public constructors

DeviceSetupService

Added in 1.0.0-alpha05
DeviceSetupService()

Public functions

onBind

Added in 1.0.0-alpha05
final fun onBind(intent: Intent?): IBinder?

onExportCredentialsRequest

Added in 1.0.0-alpha05
abstract fun onExportCredentialsRequest(
    request: ExportCredentialsRequest,
    callingAppInfo: CallingAppInfo,
    callback: OutcomeReceiverCompat<ExportCredentialsResponseExportCredentialsException>
): Unit

Called when a credential provider should receive credentials for device setup.

This method should be extended by credential providers to receive credential push requests. When the current device is being setup with a paired device, the credentials from the paired device can be transferred to the current device.

Parameters
request: ExportCredentialsRequest

The request for pushing the credentials to this device.

callingAppInfo: CallingAppInfo

the requesting app info

callback: OutcomeReceiverCompat<ExportCredentialsResponseExportCredentialsException>

The callback to receive the result of the credential push.

onGetCredentialTransferCapabilities

Added in 1.0.0-alpha05
abstract fun onGetCredentialTransferCapabilities(
    request: CredentialTransferCapabilitiesRequest,
    callingAppInfo: CallingAppInfo,
    callback: OutcomeReceiverCompat<CredentialTransferCapabilitiesGetCredentialTransferCapabilitiesException>
): Unit

Called when a credential provider should return the state of its credentials to the user.

This method should be extended by credential providers to facilitate with device setup. When the current device is used to facilitate the device setup of another device, the Android System can request for the number of credentials that can be transferred and their size. These info can be displayed to the user during the setup process.

Parameters
request: CredentialTransferCapabilitiesRequest

The request for the state of the transferable credentials to this device.

callingAppInfo: CallingAppInfo

the requesting app info

callback: OutcomeReceiverCompat<CredentialTransferCapabilitiesGetCredentialTransferCapabilitiesException>

The callback to receive the result of the request.

onImportCredentialsRequest

Added in 1.0.0-alpha05
abstract fun onImportCredentialsRequest(
    request: ImportCredentialsRequest,
    callingAppInfo: CallingAppInfo,
    callback: OutcomeReceiverCompat<ImportCredentialsResponseImportCredentialsException>
): Unit

Called when a credential provider should return credentials for device setup.

This method should be extended by credential providers to receive credential fetch requests. When the current device is used to facilitate the device setup of another device, the Android System can request for the credentials stored on this device to be transferred to the new device.

Parameters
request: ImportCredentialsRequest

The request for pulling the credentials from this device.

callingAppInfo: CallingAppInfo

the requesting app info

callback: OutcomeReceiverCompat<ImportCredentialsResponseImportCredentialsException>

The callback to receive the result of the credential fetching.