DelegatedAdminReceiver
open class DelegatedAdminReceiver : BroadcastReceiver
kotlin.Any | ||
↳ | android.content.BroadcastReceiver | |
↳ | android.app.admin.DelegatedAdminReceiver |
Base class for delegated apps to handle callbacks related to their delegated capabilities.
Delegated apps are apps that receive additional capabilities from the profile owner or device owner apps. Some of these capabilities involve the framework calling into the apps. To receive these callbacks, delegated apps should subclass this class and override the appropriate methods here. The subclassed receiver needs to be published in the app's manifest, with appropriate intent filters to mark which callbacks the receiver is interested in. An app can have multiple receivers as long as they listen for disjoint set of callbacks. For the manifest definitions, it must be protected by the android.Manifest.permission#BIND_DEVICE_ADMIN
permission to ensure only the system can trigger these callbacks.
The callback methods happen on the main thread of the process. Thus long running operations must be done on another thread. Note that because a receiver is done once returning from its onReceive function, such long-running operations should probably be done in a Service
.
Summary
Public constructors | |
---|---|
Public methods | |
---|---|
open String? |
Allows this receiver to select the alias for a private key and certificate pair for authentication. |
open Unit |
onNetworkLogsAvailable(context: Context, intent: Intent, batchToken: Long, networkLogsCount: Int) Called each time a new batch of network logs can be retrieved. |
Unit |
Intercept delegated device administrator broadcasts. |
open Unit |
onSecurityLogsAvailable(context: Context, intent: Intent) Called each time a new batch of security logs can be retrieved. |
Inherited functions | |
---|---|
Public constructors
DelegatedAdminReceiver
DelegatedAdminReceiver()
Public methods
onChoosePrivateKeyAlias
open fun onChoosePrivateKeyAlias(
context: Context,
intent: Intent,
uid: Int,
uri: Uri?,
alias: String?
): String?
Allows this receiver to select the alias for a private key and certificate pair for authentication. If this method returns null, the default android.app.Activity
will be shown that lets the user pick a private key and certificate pair. If this method returns KeyChain#KEY_ALIAS_SELECTION_DENIED
, the default android.app.Activity
will not be shown and the user will not be allowed to pick anything. And the app, that called android.security.KeyChain#choosePrivateKeyAlias, will receive null
back.
This callback is only applicable if the delegated app has DevicePolicyManager#DELEGATION_CERT_SELECTION
capability. Additionally, it must declare an intent filter for DeviceAdminReceiver#ACTION_CHOOSE_PRIVATE_KEY_ALIAS
in the receiver's manifest in order to receive this callback. The default implementation simply throws UnsupportedOperationException
.
Parameters | |
---|---|
context |
Context: The running context as per onReceive . This value cannot be null . |
intent |
Intent: The received intent as per onReceive . This value cannot be null . |
uid |
Int: The uid of the app asking for the private key and certificate pair. |
uri |
Uri?: The URI to authenticate, may be null. |
alias |
String?: The alias preselected by the client, or null. |
Return | |
---|---|
String? |
The private key alias to return and grant access to. |
See Also
onNetworkLogsAvailable
open fun onNetworkLogsAvailable(
context: Context,
intent: Intent,
batchToken: Long,
networkLogsCount: Int
): Unit
Called each time a new batch of network logs can be retrieved. This callback method will only ever be called when network logging is enabled. The logs can only be retrieved while network logging is enabled.
If a secondary user or profile is created, this callback won't be received until all users become affiliated again (even if network logging is enabled). It will also no longer be possible to retrieve the network logs batch with the most recent batchToken
provided by this callback. See DevicePolicyManager#setAffiliationIds
.
This callback is only applicable if the delegated app has DevicePolicyManager#DELEGATION_NETWORK_LOGGING
capability. Additionally, it must declare an intent filter for DeviceAdminReceiver#ACTION_NETWORK_LOGS_AVAILABLE
in the receiver's manifest in order to receive this callback. The default implementation simply throws UnsupportedOperationException
.
This callback is triggered by a foreground broadcast and the app should ensure that any long-running work is not executed synchronously inside the callback.
Parameters | |
---|---|
context |
Context: The running context as per onReceive . This value cannot be null . |
intent |
Intent: The received intent as per onReceive . This value cannot be null . |
batchToken |
Long: The token representing the current batch of network logs. |
networkLogsCount |
Int: The total count of events in the current batch of network logs. Value is 1 or greater |
onReceive
fun onReceive(
context: Context,
intent: Intent
): Unit
Intercept delegated device administrator broadcasts. Implementations should not override this method; implement the convenience callbacks for each action instead.
Parameters | |
---|---|
context |
Context: This value cannot be null . |
intent |
Intent: This value cannot be null . |
onSecurityLogsAvailable
open fun onSecurityLogsAvailable(
context: Context,
intent: Intent
): Unit
Called each time a new batch of security logs can be retrieved. This callback method will only ever be called when security logging is enabled. The logs can only be retrieved while security logging is enabled.
If a secondary user or profile is created, this callback won't be received until all users become affiliated again (even if security logging is enabled). It will also no longer be possible to retrieve the security logs. See DevicePolicyManager#setAffiliationIds
.
This callback is only applicable if the delegated app has DevicePolicyManager#DELEGATION_SECURITY_LOGGING
capability. Additionally, it must declare an intent filter for DeviceAdminReceiver#ACTION_SECURITY_LOGS_AVAILABLE
in the receiver's manifest in order to receive this callback. The default implementation simply throws UnsupportedOperationException
.
This callback is triggered by a foreground broadcast and the app should ensure that any long-running work is not executed synchronously inside the callback.
Parameters | |
---|---|
context |
Context: The running context as per onReceive . This value cannot be null . |
intent |
Intent: The received intent as per onReceive . This value cannot be null . |