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

Commit 0a332deb authored by Aleks Todorov's avatar Aleks Todorov Committed by kholoud mohamed
Browse files

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
parent 4d001dfc
Loading
Loading
Loading
Loading
+13 −3
Original line number Diff line number Diff line
@@ -5739,13 +5739,23 @@ public class DevicePolicyManager {
            "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
+26 −9
Original line number Diff line number Diff line
@@ -10653,15 +10653,6 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
        }
        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 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
                        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 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
        }
    }
    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 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
                }
            }
            sendProvisioningCompletedBroadcast(
                    userInfo.id,
                    ACTION_PROVISION_MANAGED_PROFILE,
                    provisioningParams.isLeaveAllSystemAppsEnabled());
            return userInfo.getUserHandle();
        } catch (Exception e) {
            DevicePolicyEventLogger
@@ -17557,6 +17570,10 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
            disallowAddUser();
            setAdminCanGrantSensorsPermissionForUserUnchecked(deviceOwnerUserId,
                    provisioningParams.canDeviceOwnerGrantSensorsPermissions());
            sendProvisioningCompletedBroadcast(
                    deviceOwnerUserId,
                    ACTION_PROVISION_MANAGED_DEVICE,
                    provisioningParams.isLeaveAllSystemAppsEnabled());
        } catch (Exception e) {
            DevicePolicyEventLogger
                    .createEvent(DevicePolicyEnums.PLATFORM_PROVISIONING_ERROR)