Skip to content
This repository has been archived by the owner on Oct 29, 2024. It is now read-only.

Commit

Permalink
Enforce BaseUserRestriction for DISALLOW_CONFIG_BRIGHTNESS
Browse files Browse the repository at this point in the history
Bug: 329205638
Test: pm set-user-restriction --user 0 no_config_brightness 1
Flag: ACONFIG com.android.systemui.enforce_brightness_base_user_restriction DEVELOPMENT
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:f9f3fdba4b4995b0ca45732b95de64318642e210)
Merged-In: I47b8b72a5a5c4098b46f0b5dbbf0654513b03aee
Change-Id: I47b8b72a5a5c4098b46f0b5dbbf0654513b03aee
  • Loading branch information
wangchaohui authored and muhomorr committed Aug 12, 2024
1 parent 1bf842e commit 62ba028
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
10 changes: 10 additions & 0 deletions packages/SystemUI/aconfig/systemui.aconfig
Original file line number Diff line number Diff line change
Expand Up @@ -611,3 +611,13 @@ flag {
description: "Refactors media code to follow the recommended architecture"
bug: "326408371"
}

flag {
name: "enforce_brightness_base_user_restriction"
namespace: "systemui"
description: "Enforce BaseUserRestriction for DISALLOW_CONFIG_BRIGHTNESS."
bug: "329205638"
metadata {
purpose: PURPOSE_BUGFIX
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@
import com.android.internal.display.BrightnessSynchronizer;
import com.android.internal.logging.MetricsLogger;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.settingslib.RestrictedLockUtils;
import com.android.settingslib.RestrictedLockUtilsInternal;
import com.android.systemui.Flags;
import com.android.systemui.dagger.qualifiers.Background;
import com.android.systemui.dagger.qualifiers.Main;
import com.android.systemui.settings.DisplayTracker;
Expand Down Expand Up @@ -369,10 +371,18 @@ public void checkRestrictionAndSetEnabled() {
mBackgroundHandler.post(new Runnable() {
@Override
public void run() {
mControl.setEnforcedAdmin(
int userId = mUserTracker.getUserId();
RestrictedLockUtils.EnforcedAdmin enforcedAdmin =
RestrictedLockUtilsInternal.checkIfRestrictionEnforced(mContext,
UserManager.DISALLOW_CONFIG_BRIGHTNESS,
mUserTracker.getUserId()));
userId);
if (Flags.enforceBrightnessBaseUserRestriction() && enforcedAdmin == null
&& RestrictedLockUtilsInternal.hasBaseUserRestriction(mContext,
UserManager.DISALLOW_CONFIG_BRIGHTNESS,
userId)) {
enforcedAdmin = new RestrictedLockUtils.EnforcedAdmin();
}
mControl.setEnforcedAdmin(enforcedAdmin);
}
});
}
Expand Down

0 comments on commit 62ba028

Please sign in to comment.