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

Commit c19c6d4b authored by Fiona Campbell's avatar Fiona Campbell Committed by Android (Google) Code Review
Browse files

Merge "Make setBrightnessConfigurationForUser locked" into sc-v2-dev

parents 64c7c715 15358d50
Loading
Loading
Loading
Loading
+24 −7
Original line number Diff line number Diff line
@@ -2862,15 +2862,32 @@ public final class DisplayManagerService extends SystemService {
        @Override // Binder call
        public void setBrightnessConfigurationForUser(
                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 -> {
                        if (logicalDisplay.getDisplayInfoLocked().type != Display.TYPE_INTERNAL) {
                            return;
                        }
                final DisplayDevice displayDevice = logicalDisplay.getPrimaryDisplayDeviceLocked();
                setBrightnessConfigurationForDisplay(c, displayDevice.getUniqueId(), userId,
                        packageName);
                        final DisplayDevice displayDevice =
                                logicalDisplay.getPrimaryDisplayDeviceLocked();
                        setBrightnessConfigurationForDisplayInternal(c, displayDevice.getUniqueId(),
                                userId, packageName);
                    });
                }
            } finally {
                Binder.restoreCallingIdentity(token);
            }
        }

        @Override // Binder call
        public void setBrightnessConfigurationForDisplay(BrightnessConfiguration c,