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

Commit b8f65bff authored by Yan Zhu's avatar Yan Zhu Committed by Android (Google) Code Review
Browse files

Merge "New DevicePolicyManager operation: WIPE_DATA, LOGOUT_USER, SET_USER_RESTRICTION"

parents 185e7141 832138f2
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -381,11 +381,14 @@ package android.app.admin {
    field public static final String ACTION_DATA_SHARING_RESTRICTION_APPLIED = "android.app.action.DATA_SHARING_RESTRICTION_APPLIED";
    field public static final int OPERATION_CREATE_AND_MANAGE_USER = 5; // 0x5
    field public static final int OPERATION_LOCK_NOW = 1; // 0x1
    field public static final int OPERATION_LOGOUT_USER = 9; // 0x9
    field public static final int OPERATION_REBOOT = 7; // 0x7
    field public static final int OPERATION_REMOVE_USER = 6; // 0x6
    field public static final int OPERATION_SET_USER_RESTRICTION = 10; // 0xa
    field public static final int OPERATION_START_USER_IN_BACKGROUND = 3; // 0x3
    field public static final int OPERATION_STOP_USER = 4; // 0x4
    field public static final int OPERATION_SWITCH_USER = 2; // 0x2
    field public static final int OPERATION_WIPE_DATA = 8; // 0x8
  }

  public static final class SecurityLog.SecurityEvent implements android.os.Parcelable {
+13 −1
Original line number Diff line number Diff line
@@ -2615,6 +2615,15 @@ public class DevicePolicyManager {
    /** @hide */
    @TestApi
    public static final int OPERATION_REBOOT = 7;
    /** @hide */
    @TestApi
    public static final int OPERATION_WIPE_DATA = 8;
    /** @hide */
    @TestApi
    public static final int OPERATION_LOGOUT_USER = 9;
    /** @hide */
    @TestApi
    public static final int OPERATION_SET_USER_RESTRICTION = 10;
    private static final String PREFIX_OPERATION = "OPERATION_";
@@ -2626,7 +2635,10 @@ public class DevicePolicyManager {
            OPERATION_STOP_USER,
            OPERATION_CREATE_AND_MANAGE_USER,
            OPERATION_REMOVE_USER,
            OPERATION_REBOOT
            OPERATION_REBOOT,
            OPERATION_WIPE_DATA,
            OPERATION_LOGOUT_USER,
            OPERATION_SET_USER_RESTRICTION
    })
    @Retention(RetentionPolicy.SOURCE)
    public static @interface DevicePolicyOperation {
+3 −0
Original line number Diff line number Diff line
@@ -6158,6 +6158,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
                (admin != null) || hasCallingOrSelfPermission(permission.MASTER_CLEAR),
                "No active admin for user %d and caller %d does not hold MASTER_CLEAR permission",
                caller.getUserId(), caller.getUid());
        checkCanExecuteOrThrowUnsafe(DevicePolicyManager.OPERATION_WIPE_DATA);
        if (TextUtils.isEmpty(wipeReasonForUser)) {
            if (calledByProfileOwnerOnOrgOwnedDevice && !calledOnParentInstance) {
@@ -9795,6 +9796,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
        Objects.requireNonNull(who, "ComponentName is null");
        final CallerIdentity caller = getCallerIdentity(who);
        Preconditions.checkCallAuthorization(isProfileOwner(caller) || isDeviceOwner(caller));
        checkCanExecuteOrThrowUnsafe(DevicePolicyManager.OPERATION_LOGOUT_USER);
        final int callingUserId = caller.getUserId();
        synchronized (getLockObject()) {
@@ -9980,6 +9982,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
                    throw new SecurityException("Profile owner cannot set user restriction " + key);
                }
            }
            checkCanExecuteOrThrowUnsafe(DevicePolicyManager.OPERATION_SET_USER_RESTRICTION);
            // Save the restriction to ActiveAdmin.
            final Bundle restrictions = activeAdmin.ensureUserRestrictions();