CredentialProviderEventsService


abstract class CredentialProviderEventsService : Service


A base service for credential providers to receive advanced requests from androidx.credentials.CredentialManager.

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

Note that this service is distinct from CredentialProviderService, which handles basic credential saving and retrieval requests.

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.

Basic Usage

The interaction between Credential Manager and this service typically involves:

  • A client application invokes an advanced API in androidx.credentials.CredentialManager, such as a conditional credential creation request using androidx.credentials.CreatePublicKeyCredentialRequest.isConditional.

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

  • Depending on the requested feature, providers may display UI elements such as notifications.

  • 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 state 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:

For example: ``xml <credential-provider xmlns:android="http://schemas.android.com/apk/res/android" android:settingsActivity="xyz"> <capabilities> <capability name="android.credentials.TYPE_PASSWORD_CREDENTIAL" /> <capability name="androidx.credentials.TYPE_PUBLIC_KEY_CREDENTIAL" /> </capabilities> <events-service class-name="MyCredentialProviderEventsService" /> </credential-provider> ``

Summary

Public constructors

Public functions

open IBinder?
onBind(intent: Intent?)
open Unit

Called when a credential provider should create a credential.

open Unit

Called when a credential provider should receive credential state signals from a calling application.

Inherited functions

From android.content.Context
Boolean
bindIsolatedService(
    service: Intent,
    flags: Context.BindServiceFlags,
    instanceName: String,
    executor: Executor,
    conn: ServiceConnection
)
Int
ColorStateList
Drawable?
String
getString(resId: Int)
String
getString(resId: Int, vararg formatArgs: Any)
T
<T : Any> getSystemService(serviceClass: Class<T>)
CharSequence
getText(resId: Int)
TypedArray
TypedArray
TypedArray
TypedArray
obtainStyledAttributes(
    set: AttributeSet?,
    attrs: IntArray,
    defStyleAttr: Int,
    defStyleRes: Int
)
Unit
Unit
sendBroadcastWithMultiplePermissions(
    intent: Intent,
    receiverPermissions: Array<String>
)
From android.content.ContextWrapper
Boolean
bindIsolatedService(
    service: Intent,
    flags: Int,
    instanceName: String,
    executor: Executor,
    conn: ServiceConnection
)
Boolean
bindService(
    service: Intent,
    conn: ServiceConnection,
    flags: Context.BindServiceFlags
)
Boolean
bindService(service: Intent, conn: ServiceConnection, flags: Int)
Boolean
bindService(
    service: Intent,
    flags: Context.BindServiceFlags,
    executor: Executor,
    conn: ServiceConnection
)
Boolean
bindService(
    service: Intent,
    flags: Int,
    executor: Executor,
    conn: ServiceConnection
)
Boolean
bindServiceAsUser(
    service: Intent,
    conn: ServiceConnection,
    flags: Context.BindServiceFlags,
    user: UserHandle
)
Boolean
bindServiceAsUser(
    service: Intent,
    conn: ServiceConnection,
    flags: Int,
    user: UserHandle
)
Int
Int
IntArray
Int
Int
checkCallingUriPermission(uri: Uri, modeFlags: Int)
IntArray
Int
checkContentUriPermissionFull(uri: Uri, pid: Int, uid: Int, modeFlags: Int)
Int
checkPermission(permission: String, pid: Int, uid: Int)
Int
Int
checkUriPermission(uri: Uri, pid: Int, uid: Int, modeFlags: Int)
Int
checkUriPermission(
    uri: Uri?,
    readPermission: String?,
    writePermission: String?,
    pid: Int,
    uid: Int,
    modeFlags: Int
)
IntArray
checkUriPermissions(
    uris: MutableList<Uri>,
    pid: Int,
    uid: Int,
    modeFlags: Int
)
Unit
Context
createAttributionContext(attributionTag: String?)
Context
createConfigurationContext(overrideConfiguration: Configuration)
Context
createContext(contextParams: ContextParams)
Context
Context
Context
Context
Context
createPackageContext(packageName: String, flags: Int)
Context
createWindowContext(type: Int, options: Bundle?)
Context
createWindowContext(display: Display, type: Int, options: Bundle?)
Array<String>
Boolean
Boolean
Boolean
Unit
enforceCallingOrSelfPermission(permission: String, message: String?)
Unit
enforceCallingOrSelfUriPermission(
    uri: Uri,
    modeFlags: Int,
    message: String
)
Unit
enforceCallingPermission(permission: String, message: String?)
Unit
enforceCallingUriPermission(uri: Uri, modeFlags: Int, message: String)
Unit
enforcePermission(permission: String, pid: Int, uid: Int, message: String?)
Unit
enforceUriPermission(
    uri: Uri,
    pid: Int,
    uid: Int,
    modeFlags: Int,
    message: String
)
Unit
enforceUriPermission(
    uri: Uri?,
    readPermission: String?,
    writePermission: String?,
    pid: Int,
    uid: Int,
    modeFlags: Int,
    message: String?
)
Array<String>
File
File
getDir(name: String, mode: Int)
File?
Array<File>
File
SharedPreferences
Any
String?
getSystemServiceName(serviceClass: Class<*>)
Unit
grantUriPermission(toPackage: String, uri: Uri, modeFlags: Int)
Boolean
moveDatabaseFrom(sourceContext: Context, name: String)
Boolean
moveSharedPreferencesFrom(sourceContext: Context, name: String)
FileInputStream
FileOutputStream
openFileOutput(name: String, mode: Int)
SQLiteDatabase
openOrCreateDatabase(
    name: String,
    mode: Int,
    factory: SQLiteDatabase.CursorFactory
)
SQLiteDatabase
openOrCreateDatabase(
    name: String,
    mode: Int,
    factory: SQLiteDatabase.CursorFactory,
    errorHandler: DatabaseErrorHandler?
)
Drawable
Unit
Unit
Unit
Intent?
Intent?
registerReceiver(
    receiver: BroadcastReceiver?,
    filter: IntentFilter,
    flags: Int
)
Intent?
registerReceiver(
    receiver: BroadcastReceiver?,
    filter: IntentFilter,
    broadcastPermission: String?,
    scheduler: Handler?
)
Intent?
registerReceiver(
    receiver: BroadcastReceiver?,
    filter: IntentFilter,
    broadcastPermission: String?,
    scheduler: Handler?,
    flags: Int
)
Unit
Unit
Unit
Unit
revokeUriPermission(uri: Uri, modeFlags: Int)
Unit
revokeUriPermission(targetPackage: String, uri: Uri, modeFlags: Int)
Unit
Unit
sendBroadcast(intent: Intent, receiverPermission: String?)
Unit
sendBroadcast(intent: Intent, receiverPermission: String?, options: Bundle?)
Unit
Unit
sendBroadcastAsUser(
    intent: Intent,
    user: UserHandle,
    receiverPermission: String?
)
Unit
sendOrderedBroadcast(intent: Intent, receiverPermission: String?)
Unit
sendOrderedBroadcast(
    intent: Intent,
    receiverPermission: String?,
    options: Bundle?
)
Unit
sendOrderedBroadcast(
    intent: Intent,
    receiverPermission: String?,
    resultReceiver: BroadcastReceiver?,
    scheduler: Handler?,
    initialCode: Int,
    initialData: String?,
    initialExtras: Bundle?
)
Unit
sendOrderedBroadcast(
    intent: Intent,
    receiverPermission: String?,
    options: Bundle?,
    resultReceiver: BroadcastReceiver?,
    scheduler: Handler?,
    initialCode: Int,
    initialData: String?,
    initialExtras: Bundle?
)
Unit
sendOrderedBroadcast(
    intent: Intent,
    receiverPermission: String?,
    receiverAppOp: String?,
    resultReceiver: BroadcastReceiver?,
    scheduler: Handler?,
    initialCode: Int,
    initialData: String?,
    initialExtras: Bundle?
)
Unit
sendOrderedBroadcast(
    intent: Intent,
    initialCode: Int,
    receiverPermission: String?,
    receiverAppOp: String?,
    resultReceiver: BroadcastReceiver?,
    scheduler: Handler?,
    initialData: String?,
    initialExtras: Bundle?,
    options: Bundle?
)
Unit
sendOrderedBroadcastAsUser(
    intent: Intent,
    user: UserHandle,
    receiverPermission: String?,
    resultReceiver: BroadcastReceiver?,
    scheduler: Handler?,
    initialCode: Int,
    initialData: String?,
    initialExtras: Bundle?
)
Unit
Unit
sendStickyBroadcast(intent: Intent, options: Bundle?)
Unit
Unit
sendStickyOrderedBroadcast(
    intent: Intent,
    resultReceiver: BroadcastReceiver?,
    scheduler: Handler?,
    initialCode: Int,
    initialData: String?,
    initialExtras: Bundle?
)
Unit
sendStickyOrderedBroadcastAsUser(
    intent: Intent,
    user: UserHandle,
    resultReceiver: BroadcastReceiver?,
    scheduler: Handler?,
    initialCode: Int,
    initialData: String?,
    initialExtras: Bundle?
)
Unit
setTheme(resid: Int)
Unit
Unit
Unit
Unit
startActivities(intents: Array<Intent>, options: Bundle?)
Unit
Unit
startActivity(intent: Intent, options: Bundle?)
ComponentName?
Boolean
startInstrumentation(
    className: ComponentName,
    profileFile: String?,
    arguments: Bundle?
)
Unit
startIntentSender(
    intent: IntentSender,
    fillInIntent: Intent?,
    flagsMask: Int,
    flagsValues: Int,
    extraFlags: Int
)
Unit
startIntentSender(
    intent: IntentSender,
    fillInIntent: Intent?,
    flagsMask: Int,
    flagsValues: Int,
    extraFlags: Int,
    options: Bundle?
)
ComponentName?
startService(service: Intent)
Boolean
Unit
Unit
Unit
Unit
Unit
Unit
updateServiceGroup(conn: ServiceConnection, group: Int, importance: Int)
From android.app.Service
Unit
Unit
dump(fd: FileDescriptor, writer: PrintWriter, args: Array<String>)
Unit
Unit
Unit
Unit
Unit
onRebind(intent: Intent)
Unit
onStart(intent: Intent, startId: Int)
Int
onStartCommand(intent: Intent, flags: Int, startId: Int)
Unit
onTaskRemoved(rootIntent: Intent)
Unit
onTimeout(startId: Int)
Unit
onTimeout(startId: Int, fgsType: Int)
Unit
onTrimMemory(level: Int)
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)
Unit
Unit
stopSelf(startId: Int)
Boolean
stopSelfResult(startId: Int)

Public constructors

CredentialProviderEventsService

Added in 1.0.0-alpha06
CredentialProviderEventsService()

Public functions

onBind

Added in 1.0.0-alpha06
open fun onBind(intent: Intent?): IBinder?

onCreateCredentialRequest

Added in 1.0.0-alpha06
open fun onCreateCredentialRequest(
    request: ProviderCreateCredentialRequest,
    cancellationSignal: CancellationSignal,
    callback: OutcomeReceiverCompat<CreateCredentialResponseCreateCredentialException>
): Unit

Called when a credential provider should create a credential.

This method should be extended by credential providers to receive credential creation requests. Note that for now, a credential provider will only receive conditional passkey creation requests through this endpoint (after certain internal conditions are met), and all other regular credential creation requests will still come through CredentialProviderService.onBeginCreateCredential API.

The difference between CredentialProviderService.onBeginCreateCredential and this API is that in the former, providers return entries that are shown on the UI, whereas in this one, providers simply create the passkey and return the response.

Because there is no UI from the system in the conditional passkey creation flow, it is required that providers fulfill certain conditions before creating the passkey:

  1. Check that the user has a credential stored with the provider already that has been recently used.

  2. Show a notification to notify the user after creating the passkey.

Note that the credential provider must be selected as the preferred service for them to receive the conditional passkey create request. When they do receive the request, they must check if the request is of type androidx.credentials.CreatePublicKeyCredentialRequest and that androidx.credentials.CreatePublicKeyCredentialRequest.isConditional is set to true.

Parameters
request: ProviderCreateCredentialRequest

The request for creating a credential.

cancellationSignal: CancellationSignal

A signal to cancel the operation.

callback: OutcomeReceiverCompat<CreateCredentialResponseCreateCredentialException>

The callback to receive the result of the credential creation.

onSignalCredentialStateRequest

Added in 1.0.0-alpha06
open fun onSignalCredentialStateRequest(
    request: ProviderSignalCredentialStateRequest,
    callback: ProviderSignalCredentialStateCallback
): Unit

Called when a credential provider should receive credential state signals from a calling application.

This method should be extended by credential providers to receive credential state signal requests. Note there is no required action on receipt of this request if it is not applicable, however there are recommended actions. See spec

Parameters
request: ProviderSignalCredentialStateRequest

The request for signalling a user's credential state.

callback: ProviderSignalCredentialStateCallback

The callback to receive the result of the credential state signal.