Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8cdb6fcd authored by Jessica Hummel's avatar Jessica Hummel
Browse files

Extend DeviceAdminReceiver to receive provisioning complete broadcast.

The managed profile provisioning app completes provisioning (creating the profile, installing the mdm on the secondary user, setting the mdm as the profile owner, removing unneeded apps from secondary user, removing mdm from the primary user). Then it sends a notification that the provisioning has completed across to the new profile. If the mdm, which is now installed on the profile wants to be notified that provisioning has completed it needs to implement this callback method.

Change-Id: I75f2d6d19709fd39aa867f1254e0c37a0c936222
parent 46b8d00b
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -4728,6 +4728,7 @@ package android.app.admin {
    method public void onPasswordExpiring(android.content.Context, android.content.Intent);
    method public void onPasswordFailed(android.content.Context, android.content.Intent);
    method public void onPasswordSucceeded(android.content.Context, android.content.Intent);
    method public void onProfileProvisioningComplete(android.content.Context, android.content.Intent);
    method public void onReceive(android.content.Context, android.content.Intent);
    field public static final java.lang.String ACTION_DEVICE_ADMIN_DISABLED = "android.app.action.DEVICE_ADMIN_DISABLED";
    field public static final java.lang.String ACTION_DEVICE_ADMIN_DISABLE_REQUESTED = "android.app.action.DEVICE_ADMIN_DISABLE_REQUESTED";
@@ -4736,6 +4737,7 @@ package android.app.admin {
    field public static final java.lang.String ACTION_PASSWORD_EXPIRING = "android.app.action.ACTION_PASSWORD_EXPIRING";
    field public static final java.lang.String ACTION_PASSWORD_FAILED = "android.app.action.ACTION_PASSWORD_FAILED";
    field public static final java.lang.String ACTION_PASSWORD_SUCCEEDED = "android.app.action.ACTION_PASSWORD_SUCCEEDED";
    field public static final java.lang.String ACTION_PROVISIONING_COMPLETE = "android.managedprovisioning.ACTION_PROVISIONING_COMPLETE";
    field public static final java.lang.String DEVICE_ADMIN_META_DATA = "android.app.device_admin";
    field public static final java.lang.String EXTRA_DISABLE_WARNING = "android.app.extra.DISABLE_WARNING";
  }
+53 −22
Original line number Diff line number Diff line
@@ -164,6 +164,14 @@ public class DeviceAdminReceiver extends BroadcastReceiver {
    public static final String ACTION_PASSWORD_EXPIRING
            = "android.app.action.ACTION_PASSWORD_EXPIRING";


    /**
     * Action broadcasted when provisioning of a managed profile has completed.
     */
    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
    public static final String ACTION_PROFILE_PROVISIONING_COMPLETE
            = "android.managedprovisioning.ACTION_PROVISIONING_COMPLETE";

    /**
     * Name under which a DevicePolicy component publishes information
     * about itself.  This meta-data must reference an XML resource containing
@@ -291,6 +299,26 @@ public class DeviceAdminReceiver extends BroadcastReceiver {
    public void onPasswordExpiring(Context context, Intent intent) {
    }

    /**
     * Called on the new profile when managed profile provisioning has completed.
     * Managed profile provisioning is the process of setting up the device so that it has a
     * separate profile which is managed by the mobile device management(mdm) application that
     * triggered the provisioning.
     *
     * <p>As part of provisioning a new profile is created, the mdm is moved to the new profile and
     * set as the owner of the profile so that it has full control over it.
     * This intent is only received by the mdm package that is set as profile owner during
     * provisioning.
     *
     * <p>Provisioning can be triggered via an intent with the action
     * android.managedprovisioning.ACTION_PROVISION_MANAGED_PROFILE.
     *
     * @param context The running context as per {@link #onReceive}.
     * @param intent The received intent as per {@link #onReceive}.
     */
    public void onProfileProvisioningComplete(Context context, Intent intent) {
    }

    /**
     * Intercept standard device administrator broadcasts.  Implementations
     * should not override this method; it is better to implement the
@@ -299,6 +327,7 @@ public class DeviceAdminReceiver extends BroadcastReceiver {
    @Override
    public void onReceive(Context context, Intent intent) {
        String action = intent.getAction();

        if (ACTION_PASSWORD_CHANGED.equals(action)) {
            onPasswordChanged(context, intent);
        } else if (ACTION_PASSWORD_FAILED.equals(action)) {
@@ -317,6 +346,8 @@ public class DeviceAdminReceiver extends BroadcastReceiver {
            onDisabled(context, intent);
        } else if (ACTION_PASSWORD_EXPIRING.equals(action)) {
            onPasswordExpiring(context, intent);
        } else if (ACTION_PROFILE_PROVISIONING_COMPLETE.equals(action)) {
            onProfileProvisioningComplete(context, intent);
        }
    }
}