Loading core/java/android/hardware/display/DisplayManagerInternal.java +27 −2 Original line number Diff line number Diff line Loading @@ -470,6 +470,31 @@ public abstract class DisplayManagerInternal { */ public abstract boolean isDisplayReadyForMirroring(int displayId); /** * Used by the window manager to override the per-display screen brightness based on the * current foreground activity. * * The key of the array is the displayId. If a displayId is missing from the array, this is * equivalent to clearing any existing brightness overrides for that display. * * This method must only be called by the window manager. */ public abstract void setScreenBrightnessOverrideFromWindowManager( SparseArray<DisplayBrightnessOverrideRequest> brightnessOverrides); /** * Describes a request for overriding the brightness of a single display. */ public static class DisplayBrightnessOverrideRequest { // An override of the screen brightness. // Set to PowerManager.BRIGHTNESS_INVALID if there's no override. public float brightness = PowerManager.BRIGHTNESS_INVALID_FLOAT; // Tag used to identify the app window requesting the brightness override. public CharSequence tag; } /** * Describes the requested power state of the display. * Loading Loading @@ -505,11 +530,11 @@ public abstract class DisplayManagerInternal { // nearby, turning it off temporarily until the object is moved away. public boolean useProximitySensor; // An override of the screen brightness. // A global override of the screen brightness, applied to all displays. // Set to PowerManager.BRIGHTNESS_INVALID if there's no override. public float screenBrightnessOverride; // Tag used to identify the app window requesting the brightness override. // Tag used to identify the reason for the global brightness override. public CharSequence screenBrightnessOverrideTag; // An override of the screen auto-brightness adjustment factor in the range -1 (dimmer) to Loading core/java/android/os/PowerManagerInternal.java +0 −12 Original line number Diff line number Diff line Loading @@ -97,18 +97,6 @@ public abstract class PowerManagerInternal { return wakefulness == WAKEFULNESS_AWAKE || wakefulness == WAKEFULNESS_DREAMING; } /** * Used by the window manager to override the screen brightness based on the * current foreground activity. * * This method must only be called by the window manager. * * @param brightness The overridden brightness, or Float.NaN to disable the override. * @param tag Source identifier of the app window that requests the override. */ public abstract void setScreenBrightnessOverrideFromWindowManager( float brightness, CharSequence tag); /** * Used by the window manager to override the user activity timeout based on the * current foreground activity. It can only be used to make the timeout shorter Loading services/core/java/com/android/server/display/DisplayManagerService.java +17 −0 Original line number Diff line number Diff line Loading @@ -5282,6 +5282,23 @@ public final class DisplayManagerService extends SystemService { packageName); } @Override public void setScreenBrightnessOverrideFromWindowManager( SparseArray<DisplayBrightnessOverrideRequest> brightnessOverrides) { SparseArray<DisplayPowerController> dpcs = new SparseArray<>(); synchronized (mSyncRoot) { for (int i = 0; i < mDisplayPowerControllers.size(); i++) { dpcs.put(mDisplayPowerControllers.keyAt(i), mDisplayPowerControllers.valueAt(i)); } } for (int i = 0; i < dpcs.size(); ++i) { final int displayId = dpcs.keyAt(i); final DisplayPowerController dpc = dpcs.valueAt(i); dpc.setBrightnessOverrideRequest(brightnessOverrides.get(displayId)); } } @Override public boolean requestPowerState(int groupId, DisplayPowerRequest request, boolean waitForNegativeProximity) { Loading services/core/java/com/android/server/display/DisplayPowerController.java +15 −0 Original line number Diff line number Diff line Loading @@ -42,6 +42,7 @@ import android.hardware.display.AmbientBrightnessDayStats; import android.hardware.display.BrightnessChangeEvent; import android.hardware.display.BrightnessConfiguration; import android.hardware.display.BrightnessInfo; import android.hardware.display.DisplayManagerInternal; import android.hardware.display.DisplayManagerInternal.DisplayOffloadSession; import android.hardware.display.DisplayManagerInternal.DisplayPowerCallbacks; import android.hardware.display.DisplayManagerInternal.DisplayPowerRequest; Loading Loading @@ -170,6 +171,7 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call private static final int MSG_OFFLOADING_SCREEN_ON_UNBLOCKED = 18; private static final int MSG_SET_STYLUS_BEING_USED = 19; private static final int MSG_SET_STYLUS_USE_ENDED = 20; private static final int MSG_SET_WINDOW_MANAGER_BRIGHTNESS_OVERRIDE = 21; private static final int BRIGHTNESS_CHANGE_STATSD_REPORT_INTERVAL_MS = 500; Loading Loading @@ -850,6 +852,12 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call } } public void setBrightnessOverrideRequest( DisplayManagerInternal.DisplayBrightnessOverrideRequest request) { Message msg = mHandler.obtainMessage(MSG_SET_WINDOW_MANAGER_BRIGHTNESS_OVERRIDE, request); mHandler.sendMessageAtTime(msg, mClock.uptimeMillis()); } public void setDisplayOffloadSession(DisplayOffloadSession session) { if (session == mDisplayOffloadSession) { return; Loading Loading @@ -3100,6 +3108,13 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call updatePowerState(); break; case MSG_SET_WINDOW_MANAGER_BRIGHTNESS_OVERRIDE: if (mDisplayBrightnessController.updateWindowManagerBrightnessOverride( (DisplayManagerInternal.DisplayBrightnessOverrideRequest) msg.obj)) { updatePowerState(); } break; case MSG_STOP: cleanupHandlerThreadAfterStop(); break; Loading services/core/java/com/android/server/display/brightness/DisplayBrightnessController.java +14 −0 Original line number Diff line number Diff line Loading @@ -179,6 +179,20 @@ public final class DisplayBrightnessController { } } /** * Updates the brightness override from WindowManager. * * @param request The request to override the brightness * @return whether this request will result in a change of the brightness */ public boolean updateWindowManagerBrightnessOverride( DisplayManagerInternal.DisplayBrightnessOverrideRequest request) { synchronized (mLock) { return mDisplayBrightnessStrategySelector.getOverrideBrightnessStrategy() .updateWindowManagerBrightnessOverride(request); } } /** * Sets the brightness to follow */ Loading Loading
core/java/android/hardware/display/DisplayManagerInternal.java +27 −2 Original line number Diff line number Diff line Loading @@ -470,6 +470,31 @@ public abstract class DisplayManagerInternal { */ public abstract boolean isDisplayReadyForMirroring(int displayId); /** * Used by the window manager to override the per-display screen brightness based on the * current foreground activity. * * The key of the array is the displayId. If a displayId is missing from the array, this is * equivalent to clearing any existing brightness overrides for that display. * * This method must only be called by the window manager. */ public abstract void setScreenBrightnessOverrideFromWindowManager( SparseArray<DisplayBrightnessOverrideRequest> brightnessOverrides); /** * Describes a request for overriding the brightness of a single display. */ public static class DisplayBrightnessOverrideRequest { // An override of the screen brightness. // Set to PowerManager.BRIGHTNESS_INVALID if there's no override. public float brightness = PowerManager.BRIGHTNESS_INVALID_FLOAT; // Tag used to identify the app window requesting the brightness override. public CharSequence tag; } /** * Describes the requested power state of the display. * Loading Loading @@ -505,11 +530,11 @@ public abstract class DisplayManagerInternal { // nearby, turning it off temporarily until the object is moved away. public boolean useProximitySensor; // An override of the screen brightness. // A global override of the screen brightness, applied to all displays. // Set to PowerManager.BRIGHTNESS_INVALID if there's no override. public float screenBrightnessOverride; // Tag used to identify the app window requesting the brightness override. // Tag used to identify the reason for the global brightness override. public CharSequence screenBrightnessOverrideTag; // An override of the screen auto-brightness adjustment factor in the range -1 (dimmer) to Loading
core/java/android/os/PowerManagerInternal.java +0 −12 Original line number Diff line number Diff line Loading @@ -97,18 +97,6 @@ public abstract class PowerManagerInternal { return wakefulness == WAKEFULNESS_AWAKE || wakefulness == WAKEFULNESS_DREAMING; } /** * Used by the window manager to override the screen brightness based on the * current foreground activity. * * This method must only be called by the window manager. * * @param brightness The overridden brightness, or Float.NaN to disable the override. * @param tag Source identifier of the app window that requests the override. */ public abstract void setScreenBrightnessOverrideFromWindowManager( float brightness, CharSequence tag); /** * Used by the window manager to override the user activity timeout based on the * current foreground activity. It can only be used to make the timeout shorter Loading
services/core/java/com/android/server/display/DisplayManagerService.java +17 −0 Original line number Diff line number Diff line Loading @@ -5282,6 +5282,23 @@ public final class DisplayManagerService extends SystemService { packageName); } @Override public void setScreenBrightnessOverrideFromWindowManager( SparseArray<DisplayBrightnessOverrideRequest> brightnessOverrides) { SparseArray<DisplayPowerController> dpcs = new SparseArray<>(); synchronized (mSyncRoot) { for (int i = 0; i < mDisplayPowerControllers.size(); i++) { dpcs.put(mDisplayPowerControllers.keyAt(i), mDisplayPowerControllers.valueAt(i)); } } for (int i = 0; i < dpcs.size(); ++i) { final int displayId = dpcs.keyAt(i); final DisplayPowerController dpc = dpcs.valueAt(i); dpc.setBrightnessOverrideRequest(brightnessOverrides.get(displayId)); } } @Override public boolean requestPowerState(int groupId, DisplayPowerRequest request, boolean waitForNegativeProximity) { Loading
services/core/java/com/android/server/display/DisplayPowerController.java +15 −0 Original line number Diff line number Diff line Loading @@ -42,6 +42,7 @@ import android.hardware.display.AmbientBrightnessDayStats; import android.hardware.display.BrightnessChangeEvent; import android.hardware.display.BrightnessConfiguration; import android.hardware.display.BrightnessInfo; import android.hardware.display.DisplayManagerInternal; import android.hardware.display.DisplayManagerInternal.DisplayOffloadSession; import android.hardware.display.DisplayManagerInternal.DisplayPowerCallbacks; import android.hardware.display.DisplayManagerInternal.DisplayPowerRequest; Loading Loading @@ -170,6 +171,7 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call private static final int MSG_OFFLOADING_SCREEN_ON_UNBLOCKED = 18; private static final int MSG_SET_STYLUS_BEING_USED = 19; private static final int MSG_SET_STYLUS_USE_ENDED = 20; private static final int MSG_SET_WINDOW_MANAGER_BRIGHTNESS_OVERRIDE = 21; private static final int BRIGHTNESS_CHANGE_STATSD_REPORT_INTERVAL_MS = 500; Loading Loading @@ -850,6 +852,12 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call } } public void setBrightnessOverrideRequest( DisplayManagerInternal.DisplayBrightnessOverrideRequest request) { Message msg = mHandler.obtainMessage(MSG_SET_WINDOW_MANAGER_BRIGHTNESS_OVERRIDE, request); mHandler.sendMessageAtTime(msg, mClock.uptimeMillis()); } public void setDisplayOffloadSession(DisplayOffloadSession session) { if (session == mDisplayOffloadSession) { return; Loading Loading @@ -3100,6 +3108,13 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call updatePowerState(); break; case MSG_SET_WINDOW_MANAGER_BRIGHTNESS_OVERRIDE: if (mDisplayBrightnessController.updateWindowManagerBrightnessOverride( (DisplayManagerInternal.DisplayBrightnessOverrideRequest) msg.obj)) { updatePowerState(); } break; case MSG_STOP: cleanupHandlerThreadAfterStop(); break; Loading
services/core/java/com/android/server/display/brightness/DisplayBrightnessController.java +14 −0 Original line number Diff line number Diff line Loading @@ -179,6 +179,20 @@ public final class DisplayBrightnessController { } } /** * Updates the brightness override from WindowManager. * * @param request The request to override the brightness * @return whether this request will result in a change of the brightness */ public boolean updateWindowManagerBrightnessOverride( DisplayManagerInternal.DisplayBrightnessOverrideRequest request) { synchronized (mLock) { return mDisplayBrightnessStrategySelector.getOverrideBrightnessStrategy() .updateWindowManagerBrightnessOverride(request); } } /** * Sets the brightness to follow */ Loading