Merge "Make setBrightnessConfigurationForUser locked" into sc-v2-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
c19c6d4b3c
@@ -2862,15 +2862,32 @@ public final class DisplayManagerService extends SystemService {
|
|||||||
@Override // Binder call
|
@Override // Binder call
|
||||||
public void setBrightnessConfigurationForUser(
|
public void setBrightnessConfigurationForUser(
|
||||||
BrightnessConfiguration c, @UserIdInt int userId, String packageName) {
|
BrightnessConfiguration c, @UserIdInt int userId, String packageName) {
|
||||||
|
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 -> {
|
mLogicalDisplayMapper.forEachLocked(logicalDisplay -> {
|
||||||
if (logicalDisplay.getDisplayInfoLocked().type != Display.TYPE_INTERNAL) {
|
if (logicalDisplay.getDisplayInfoLocked().type != Display.TYPE_INTERNAL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final DisplayDevice displayDevice = logicalDisplay.getPrimaryDisplayDeviceLocked();
|
final DisplayDevice displayDevice =
|
||||||
setBrightnessConfigurationForDisplay(c, displayDevice.getUniqueId(), userId,
|
logicalDisplay.getPrimaryDisplayDeviceLocked();
|
||||||
packageName);
|
setBrightnessConfigurationForDisplayInternal(c, displayDevice.getUniqueId(),
|
||||||
|
userId, packageName);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
} finally {
|
||||||
|
Binder.restoreCallingIdentity(token);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override // Binder call
|
@Override // Binder call
|
||||||
public void setBrightnessConfigurationForDisplay(BrightnessConfiguration c,
|
public void setBrightnessConfigurationForDisplay(BrightnessConfiguration c,
|
||||||
|
|||||||
Reference in New Issue
Block a user