Merge "Make setBrightnessConfigurationForUser locked" into sc-v2-dev am: c19c6d4b3c
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15949362 Change-Id: Id404fc7aa4bcd32fe49363fad074953997fb66a9
This commit is contained in:
@@ -2862,14 +2862,31 @@ public final class DisplayManagerService extends SystemService {
|
||||
@Override // Binder call
|
||||
public void setBrightnessConfigurationForUser(
|
||||
BrightnessConfiguration c, @UserIdInt int userId, String packageName) {
|
||||
mLogicalDisplayMapper.forEachLocked(logicalDisplay -> {
|
||||
if (logicalDisplay.getDisplayInfoLocked().type != Display.TYPE_INTERNAL) {
|
||||
return;
|
||||
mContext.enforceCallingOrSelfPermission(
|
||||
Manifest.permission.CONFIGURE_DISPLAY_BRIGHTNESS,
|
||||
"Permission required to change the display's brightness configuration");
|
||||
if (userId != UserHandle.getCallingUserId()) {
|
||||
mContext.enforceCallingOrSelfPermission(
|
||||
Manifest.permission.INTERACT_ACROSS_USERS,
|
||||
"Permission required to change the display brightness"
|
||||
+ " configuration of another user");
|
||||
}
|
||||
final long token = Binder.clearCallingIdentity();
|
||||
try {
|
||||
synchronized (mSyncRoot) {
|
||||
mLogicalDisplayMapper.forEachLocked(logicalDisplay -> {
|
||||
if (logicalDisplay.getDisplayInfoLocked().type != Display.TYPE_INTERNAL) {
|
||||
return;
|
||||
}
|
||||
final DisplayDevice displayDevice =
|
||||
logicalDisplay.getPrimaryDisplayDeviceLocked();
|
||||
setBrightnessConfigurationForDisplayInternal(c, displayDevice.getUniqueId(),
|
||||
userId, packageName);
|
||||
});
|
||||
}
|
||||
final DisplayDevice displayDevice = logicalDisplay.getPrimaryDisplayDeviceLocked();
|
||||
setBrightnessConfigurationForDisplay(c, displayDevice.getUniqueId(), userId,
|
||||
packageName);
|
||||
});
|
||||
} finally {
|
||||
Binder.restoreCallingIdentity(token);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // Binder call
|
||||
|
||||
Reference in New Issue
Block a user