Rename broadcast ACTION_MANAGED_USER_CREATED to ACTION_PROVISIONING_COMPLETED
Also started using it for DPM#provisionFullyManagedDevice and
DPM#createAndProvisionManagedProfile
Bug: 188410712
Bug: 206083853
Test: atest android.devicepolicy.cts.DevicePolicyManagerTest
Change-Id: Ic5bdb2bec16c83671a7e2cc955522b2d8c82ea70
diff --git a/core/java/android/app/admin/DevicePolicyManager.java b/core/java/android/app/admin/DevicePolicyManager.java
index db492b9..7969cda 100644
--- a/core/java/android/app/admin/DevicePolicyManager.java
+++ b/core/java/android/app/admin/DevicePolicyManager.java
@@ -5739,13 +5739,23 @@
"android.app.action.CHECK_POLICY_COMPLIANCE";
/**
- * Broadcast action: notify managed provisioning that new managed user is created.
+ * Broadcast action: notify managed provisioning that PO/DO provisioning has completed.
*
* @hide
*/
@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
- public static final String ACTION_MANAGED_USER_CREATED =
- "android.app.action.MANAGED_USER_CREATED";
+ public static final String ACTION_PROVISIONING_COMPLETED =
+ "android.app.action.PROVISIONING_COMPLETED";
+
+ /**
+ * Extra for {@link #ACTION_PROVISIONING_COMPLETED} to indicate the provisioning action that has
+ * been completed, this can either be {@link #ACTION_PROVISION_MANAGED_PROFILE},
+ * {@link #ACTION_PROVISION_MANAGED_DEVICE}, or {@link #ACTION_PROVISION_MANAGED_USER}.
+ *
+ * @hide
+ */
+ public static final String EXTRA_PROVISIONING_ACTION =
+ "android.app.extra.PROVISIONING_ACTION";
/**
* Broadcast action: notify system that a new (Android) user was added when the device is
diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
index 0625b9f..23b685f 100644
--- a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
+++ b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
@@ -10653,15 +10653,6 @@
}
final int userHandle = user.getIdentifier();
- final Intent intent = new Intent(DevicePolicyManager.ACTION_MANAGED_USER_CREATED)
- .putExtra(Intent.EXTRA_USER_HANDLE, userHandle)
- .putExtra(
- DevicePolicyManager.EXTRA_PROVISIONING_LEAVE_ALL_SYSTEM_APPS_ENABLED,
- leaveAllSystemAppsEnabled)
- .setPackage(getManagedProvisioningPackage(mContext))
- .addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
- mContext.sendBroadcastAsUser(intent, UserHandle.SYSTEM);
-
final long id = mInjector.binderClearCallingIdentity();
try {
manageUserUnchecked(admin, profileOwner, userHandle, adminExtras,
@@ -10672,6 +10663,9 @@
Settings.Secure.USER_SETUP_COMPLETE, 1, userHandle);
}
+ sendProvisioningCompletedBroadcast(
+ userHandle, ACTION_PROVISION_MANAGED_USER, leaveAllSystemAppsEnabled);
+
return user;
} catch (Throwable re) {
mUserManager.removeUser(userHandle);
@@ -10686,6 +10680,20 @@
}
}
+ private void sendProvisioningCompletedBroadcast(
+ int user, String action, boolean leaveAllSystemAppsEnabled) {
+ final Intent intent = new Intent(DevicePolicyManager.ACTION_PROVISIONING_COMPLETED)
+ .putExtra(Intent.EXTRA_USER_HANDLE, user)
+ .putExtra(
+ DevicePolicyManager.EXTRA_PROVISIONING_LEAVE_ALL_SYSTEM_APPS_ENABLED,
+ leaveAllSystemAppsEnabled)
+ .putExtra(DevicePolicyManager.EXTRA_PROVISIONING_ACTION,
+ action)
+ .setPackage(getManagedProvisioningPackage(mContext))
+ .addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
+ mContext.sendBroadcastAsUser(intent, UserHandle.SYSTEM);
+ }
+
private void manageUserUnchecked(ComponentName admin, ComponentName profileOwner,
@UserIdInt int userId, @Nullable PersistableBundle adminExtras,
boolean showDisclaimer) {
@@ -17277,6 +17285,11 @@
}
}
+ sendProvisioningCompletedBroadcast(
+ userInfo.id,
+ ACTION_PROVISION_MANAGED_PROFILE,
+ provisioningParams.isLeaveAllSystemAppsEnabled());
+
return userInfo.getUserHandle();
} catch (Exception e) {
DevicePolicyEventLogger
@@ -17557,6 +17570,10 @@
disallowAddUser();
setAdminCanGrantSensorsPermissionForUserUnchecked(deviceOwnerUserId,
provisioningParams.canDeviceOwnerGrantSensorsPermissions());
+ sendProvisioningCompletedBroadcast(
+ deviceOwnerUserId,
+ ACTION_PROVISION_MANAGED_DEVICE,
+ provisioningParams.isLeaveAllSystemAppsEnabled());
} catch (Exception e) {
DevicePolicyEventLogger
.createEvent(DevicePolicyEnums.PLATFORM_PROVISIONING_ERROR)