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

Commit 9d319e4d authored by Jonathan Scott's avatar Jonathan Scott Committed by Android (Google) Code Review
Browse files

Merge changes from topics "bluetoothrestrictions", "headlessfixes2" into udc-dev

* changes:
  Fix global user restriction permission check.
  Make user restriction failures clearer.
parents d9caad58 d7aed4b1
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -2641,6 +2641,7 @@ public class UserManagerService extends IUserManager.Stub {

    private void setUserRestrictionInner(int userId, @NonNull String key, boolean value) {
        if (!UserRestrictionsUtils.isValidRestriction(key)) {
            Slog.e(LOG_TAG, "Setting invalid restriction " + key);
            return;
        }
        synchronized (mRestrictionsLock) {
+41 −41
Original line number Diff line number Diff line
@@ -13287,6 +13287,9 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
                            ? getProfileParentId(caller.getUserId()) : caller.getUserId();
                    setLocalUserRestrictionInternal(admin, key, enabled, affectedUserId);
                }
            } else {
                throw new IllegalStateException("Non-DO/Non-PO cannot set restriction " + key
                        + " while targetSdkVersion is less than UPSIDE_DOWN_CAKE");
            }
        }
    }
@@ -13315,14 +13318,13 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
                /* who= */ null,
                key,
                caller.getPackageName(),
                caller.getUserId()
                UserHandle.USER_ALL
        );
        setGlobalUserRestrictionInternal(admin, key, /* enabled= */ true);
        logUserRestrictionCall(key, /* enabled= */ true, /* parent= */ false, caller);
    }
    private void setLocalUserRestrictionInternal(
            EnforcingAdmin admin, String key, boolean enabled, int userId) {
        PolicyDefinition<Boolean> policyDefinition =
@@ -13340,7 +13342,6 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
                    userId);
        }
    }
    private void setGlobalUserRestrictionInternal(
            EnforcingAdmin admin, String key, boolean enabled) {
        PolicyDefinition<Boolean> policyDefinition =
@@ -22560,7 +22561,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
    );
    /**
     * All the permisisons granted to a profile owner.
     * All the permissions granted to a profile owner.
     */
    private static final List<String> PROFILE_OWNER_PERMISSIONS  =
            List.of(
@@ -22570,6 +22571,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
                    MANAGE_DEVICE_POLICY_APP_RESTRICTIONS,
                    MANAGE_DEVICE_POLICY_AUDIO_OUTPUT,
                    MANAGE_DEVICE_POLICY_AUTOFILL,
                    MANAGE_DEVICE_POLICY_BLUETOOTH,
                    MANAGE_DEVICE_POLICY_CALLS,
                    MANAGE_DEVICE_POLICY_DEBUGGING_FEATURES,
                    MANAGE_DEVICE_POLICY_DISPLAY,
@@ -22606,7 +22608,6 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
                    MANAGE_DEVICE_POLICY_ACROSS_USERS,
                    MANAGE_DEVICE_POLICY_AIRPLANE_MODE,
                    MANAGE_DEVICE_POLICY_APPS_CONTROL,
                    MANAGE_DEVICE_POLICY_BLUETOOTH,
                    MANAGE_DEVICE_POLICY_CAMERA,
                    MANAGE_DEVICE_POLICY_CERTIFICATES,
                    MANAGE_DEVICE_POLICY_COMMON_CRITERIA_MODE,
@@ -22633,7 +22634,6 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
    private static final List<String> ADDITIONAL_PROFILE_OWNER_ON_USER_0_PERMISSIONS =
            List.of(
                    MANAGE_DEVICE_POLICY_AIRPLANE_MODE,
                    MANAGE_DEVICE_POLICY_BLUETOOTH,
                    MANAGE_DEVICE_POLICY_CAMERA,
                    MANAGE_DEVICE_POLICY_DISPLAY,
                    MANAGE_DEVICE_POLICY_FUN,