Loading core/java/android/os/PowerManagerInternal.java +8 −3 Original line number Diff line number Diff line Loading @@ -139,11 +139,16 @@ public abstract class PowerManagerInternal { * @param screenState The overridden screen state, or {@link Display#STATE_UNKNOWN} * to disable the override. * @param reason The reason for overriding the screen state. * @param screenBrightness The overridden screen brightness, or * {@link PowerManager#BRIGHTNESS_DEFAULT} to disable the override. * @param screenBrightnessFloat The overridden screen brightness between * {@link PowerManager#BRIGHTNESS_MIN} and {@link PowerManager#BRIGHTNESS_MAX}, or * {@link PowerManager#BRIGHTNESS_INVALID_FLOAT} if screenBrightnessInt should be used instead. * @param screenBrightnessInt The overridden screen brightness between 1 and 255, or * {@link PowerManager#BRIGHTNESS_DEFAULT} to disable the override. Not used if * screenBrightnessFloat is provided (is not NaN). */ public abstract void setDozeOverrideFromDreamManager( int screenState, @Display.StateReason int reason, int screenBrightness); int screenState, @Display.StateReason int reason, float screenBrightnessFloat, int screenBrightnessInt); /** * Used by sidekick manager to tell the power manager if it shouldn't change the display state Loading core/java/android/provider/Settings.java +1 −1 Original line number Diff line number Diff line Loading @@ -15820,7 +15820,7 @@ public final class Settings { * The following keys are supported: * * <pre> * screen_brightness_array (int[]) * screen_brightness_array (int[], values in range [1, 255]) * dimming_scrim_array (int[]) * prox_screen_off_delay (long) * prox_cooldown_trigger (long) core/java/android/service/dreams/DreamService.java +56 −9 Original line number Diff line number Diff line Loading @@ -74,6 +74,7 @@ import android.view.accessibility.AccessibilityEvent; import com.android.internal.R; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.display.BrightnessSynchronizer; import com.android.internal.util.DumpUtils; import java.io.FileDescriptor; Loading Loading @@ -269,6 +270,7 @@ public class DreamService extends Service implements Window.Callback { private volatile int mDozeScreenState = Display.STATE_UNKNOWN; private volatile @Display.StateReason int mDozeScreenStateReason = Display.STATE_REASON_UNKNOWN; private volatile int mDozeScreenBrightness = PowerManager.BRIGHTNESS_DEFAULT; private volatile float mDozeScreenBrightnessFloat = PowerManager.BRIGHTNESS_INVALID_FLOAT; private boolean mDebug = false; Loading Loading @@ -928,11 +930,11 @@ public class DreamService extends Service implements Window.Callback { if (startAndStopDozingInBackground()) { mDreamManager.startDozingOneway( mDreamToken, mDozeScreenState, mDozeScreenStateReason, mDozeScreenBrightness); mDozeScreenBrightnessFloat, mDozeScreenBrightness); } else { mDreamManager.startDozing( mDreamToken, mDozeScreenState, mDozeScreenStateReason, mDozeScreenBrightness); mDozeScreenBrightnessFloat, mDozeScreenBrightness); } } catch (RemoteException ex) { Loading Loading @@ -1057,7 +1059,7 @@ public class DreamService extends Service implements Window.Callback { * Gets the screen brightness to use while dozing. * * @return The screen brightness while dozing as a value between * {@link PowerManager#BRIGHTNESS_OFF} (0) and {@link PowerManager#BRIGHTNESS_ON} (255), * {@link PowerManager#BRIGHTNESS_OFF + 1} (1) and {@link PowerManager#BRIGHTNESS_ON} (255), * or {@link PowerManager#BRIGHTNESS_DEFAULT} (-1) to ask the system to apply * its default policy based on the screen state. * Loading @@ -1078,11 +1080,11 @@ public class DreamService extends Service implements Window.Callback { * The dream may set a different brightness before starting to doze and may adjust * the brightness while dozing to conserve power and achieve various effects. * </p><p> * Note that dream may specify any brightness in the full 0-255 range, including * Note that dream may specify any brightness in the full 1-255 range, including * values that are less than the minimum value for manual screen brightness * adjustments by the user. In particular, the value may be set to 0 which may * turn off the backlight entirely while still leaving the screen on although * this behavior is device dependent and not guaranteed. * adjustments by the user. In particular, the value may be set to * {@link PowerManager.BRIGHTNESS_OFF} which may turn off the backlight entirely while still * leaving the screen on although this behavior is device dependent and not guaranteed. * </p><p> * The available range of display brightness values and their behavior while dozing is * hardware dependent and may vary across devices. The dream may therefore Loading @@ -1090,7 +1092,7 @@ public class DreamService extends Service implements Window.Callback { * </p> * * @param brightness The screen brightness while dozing as a value between * {@link PowerManager#BRIGHTNESS_OFF} (0) and {@link PowerManager#BRIGHTNESS_ON} (255), * {@link PowerManager#BRIGHTNESS_OFF + 1} (1) and {@link PowerManager#BRIGHTNESS_ON} (255), * or {@link PowerManager#BRIGHTNESS_DEFAULT} (-1) to ask the system to apply * its default policy based on the screen state. * Loading @@ -1107,6 +1109,44 @@ public class DreamService extends Service implements Window.Callback { } } /** * Sets the screen brightness to use while dozing. * <p> * The value of this property determines the power state of the primary display * once {@link #startDozing} has been called. The default value is * {@link PowerManager#BRIGHTNESS_INVALID_FLOAT} which lets the system decide. * The dream may set a different brightness before starting to doze and may adjust * the brightness while dozing to conserve power and achieve various effects. * </p><p> * Note that dream may specify any brightness in the full 0-1 range, including * values that are less than the minimum value for manual screen brightness * adjustments by the user. In particular, the value may be set to * {@link PowerManager#BRIGHTNESS_OFF_FLOAT} which may turn off the backlight entirely while * still leaving the screen on although this behavior is device dependent and not guaranteed. * </p><p> * The available range of display brightness values and their behavior while dozing is * hardware dependent and may vary across devices. The dream may therefore * need to be modified or configured to correctly support the hardware. * </p> * * @param brightness The screen brightness while dozing as a value between * {@link PowerManager#BRIGHTNESS_MIN} (0) and {@link PowerManager#BRIGHTNESS_MAX} (1), * or {@link PowerManager#BRIGHTNESS_INVALID_FLOAT} (Float.NaN) to ask the system to apply * its default policy based on the screen state. * * @hide For use by system UI components only. */ @UnsupportedAppUsage public void setDozeScreenBrightnessFloat(float brightness) { if (!Float.isNaN(brightness)) { brightness = clampAbsoluteBrightnessFloat(brightness); } if (!BrightnessSynchronizer.floatEquals(mDozeScreenBrightnessFloat, brightness)) { mDozeScreenBrightnessFloat = brightness; updateDoze(); } } /** * Called when this Dream is constructed. */ Loading Loading @@ -1751,6 +1791,13 @@ public class DreamService extends Service implements Window.Callback { return MathUtils.constrain(value, PowerManager.BRIGHTNESS_OFF, PowerManager.BRIGHTNESS_ON); } private static float clampAbsoluteBrightnessFloat(float value) { if (value == PowerManager.BRIGHTNESS_OFF_FLOAT) { return value; } return MathUtils.constrain(value, PowerManager.BRIGHTNESS_MIN, PowerManager.BRIGHTNESS_MAX); } /** * The DreamServiceWrapper is used as a gateway to the system_server, where DreamController * uses it to control the DreamService. It is also used to receive callbacks from the Loading core/java/android/service/dreams/IDreamManager.aidl +4 −2 Original line number Diff line number Diff line Loading @@ -42,7 +42,8 @@ interface IDreamManager { /** @deprecated Please use finishSelfOneway instead. */ void finishSelf(in IBinder token, boolean immediate); /** @deprecated Please use startDozingOneway instead. */ void startDozing(in IBinder token, int screenState, int reason, int screenBrightness); void startDozing(in IBinder token, int screenState, int reason, float screenBrightnessFloat, int screenBrightnessInt); void stopDozing(in IBinder token); void forceAmbientDisplayEnabled(boolean enabled); ComponentName[] getDreamComponentsForUser(int userId); Loading @@ -52,6 +53,7 @@ interface IDreamManager { void startDreamActivity(in Intent intent); @JavaPassthrough(annotation="@android.annotation.RequiresPermission(android.Manifest.permission.WRITE_DREAM_STATE)") oneway void setDreamIsObscured(in boolean isObscured); oneway void startDozingOneway(in IBinder token, int screenState, int reason, int screenBrightness); oneway void startDozingOneway(in IBinder token, int screenState, int reason, float screenBrightnessFloat, int screenBrightnessInt); oneway void finishSelfOneway(in IBinder token, boolean immediate); } packages/SystemUI/src/com/android/systemui/doze/AlwaysOnDisplayPolicy.java +13 −3 Original line number Diff line number Diff line Loading @@ -57,21 +57,29 @@ public class AlwaysOnDisplayPolicy { /** * Integer used to dim the screen while dozing. * Integer in the scale [1, 255] used to dim the screen while dozing. * * @see R.integer.config_screenBrightnessDoze */ public int defaultDozeBrightness; /** * Integer used to dim the screen just before the screen turns off. * Integer in the scale [1, 255] used to dim the screen just before the screen turns off. * * @see R.integer.config_screenBrightnessDim */ public int dimBrightness; /** * Integer array to map ambient brightness type to real screen brightness. * Float in the scale [0, 1] used to dim the screen just before the screen turns off. * * @see R.integer.config_screenBrightnessDimFloat */ public float dimBrightnessFloat; /** * Integer array to map ambient brightness type to real screen brightness in the integer scale * [1, 255]. * * @see Settings.Global#ALWAYS_ON_DISPLAY_CONSTANTS * @see #KEY_SCREEN_BRIGHTNESS_ARRAY Loading Loading @@ -189,6 +197,8 @@ public class AlwaysOnDisplayPolicy { com.android.internal.R.integer.config_screenBrightnessDoze); dimBrightness = resources.getInteger( com.android.internal.R.integer.config_screenBrightnessDim); dimBrightnessFloat = resources.getFloat( com.android.internal.R.dimen.config_screenBrightnessDimFloat); screenBrightnessArray = mParser.getIntArray(KEY_SCREEN_BRIGHTNESS_ARRAY, resources.getIntArray( R.array.config_doze_brightness_sensor_to_brightness)); Loading Loading
core/java/android/os/PowerManagerInternal.java +8 −3 Original line number Diff line number Diff line Loading @@ -139,11 +139,16 @@ public abstract class PowerManagerInternal { * @param screenState The overridden screen state, or {@link Display#STATE_UNKNOWN} * to disable the override. * @param reason The reason for overriding the screen state. * @param screenBrightness The overridden screen brightness, or * {@link PowerManager#BRIGHTNESS_DEFAULT} to disable the override. * @param screenBrightnessFloat The overridden screen brightness between * {@link PowerManager#BRIGHTNESS_MIN} and {@link PowerManager#BRIGHTNESS_MAX}, or * {@link PowerManager#BRIGHTNESS_INVALID_FLOAT} if screenBrightnessInt should be used instead. * @param screenBrightnessInt The overridden screen brightness between 1 and 255, or * {@link PowerManager#BRIGHTNESS_DEFAULT} to disable the override. Not used if * screenBrightnessFloat is provided (is not NaN). */ public abstract void setDozeOverrideFromDreamManager( int screenState, @Display.StateReason int reason, int screenBrightness); int screenState, @Display.StateReason int reason, float screenBrightnessFloat, int screenBrightnessInt); /** * Used by sidekick manager to tell the power manager if it shouldn't change the display state Loading
core/java/android/provider/Settings.java +1 −1 Original line number Diff line number Diff line Loading @@ -15820,7 +15820,7 @@ public final class Settings { * The following keys are supported: * * <pre> * screen_brightness_array (int[]) * screen_brightness_array (int[], values in range [1, 255]) * dimming_scrim_array (int[]) * prox_screen_off_delay (long) * prox_cooldown_trigger (long)
core/java/android/service/dreams/DreamService.java +56 −9 Original line number Diff line number Diff line Loading @@ -74,6 +74,7 @@ import android.view.accessibility.AccessibilityEvent; import com.android.internal.R; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.display.BrightnessSynchronizer; import com.android.internal.util.DumpUtils; import java.io.FileDescriptor; Loading Loading @@ -269,6 +270,7 @@ public class DreamService extends Service implements Window.Callback { private volatile int mDozeScreenState = Display.STATE_UNKNOWN; private volatile @Display.StateReason int mDozeScreenStateReason = Display.STATE_REASON_UNKNOWN; private volatile int mDozeScreenBrightness = PowerManager.BRIGHTNESS_DEFAULT; private volatile float mDozeScreenBrightnessFloat = PowerManager.BRIGHTNESS_INVALID_FLOAT; private boolean mDebug = false; Loading Loading @@ -928,11 +930,11 @@ public class DreamService extends Service implements Window.Callback { if (startAndStopDozingInBackground()) { mDreamManager.startDozingOneway( mDreamToken, mDozeScreenState, mDozeScreenStateReason, mDozeScreenBrightness); mDozeScreenBrightnessFloat, mDozeScreenBrightness); } else { mDreamManager.startDozing( mDreamToken, mDozeScreenState, mDozeScreenStateReason, mDozeScreenBrightness); mDozeScreenBrightnessFloat, mDozeScreenBrightness); } } catch (RemoteException ex) { Loading Loading @@ -1057,7 +1059,7 @@ public class DreamService extends Service implements Window.Callback { * Gets the screen brightness to use while dozing. * * @return The screen brightness while dozing as a value between * {@link PowerManager#BRIGHTNESS_OFF} (0) and {@link PowerManager#BRIGHTNESS_ON} (255), * {@link PowerManager#BRIGHTNESS_OFF + 1} (1) and {@link PowerManager#BRIGHTNESS_ON} (255), * or {@link PowerManager#BRIGHTNESS_DEFAULT} (-1) to ask the system to apply * its default policy based on the screen state. * Loading @@ -1078,11 +1080,11 @@ public class DreamService extends Service implements Window.Callback { * The dream may set a different brightness before starting to doze and may adjust * the brightness while dozing to conserve power and achieve various effects. * </p><p> * Note that dream may specify any brightness in the full 0-255 range, including * Note that dream may specify any brightness in the full 1-255 range, including * values that are less than the minimum value for manual screen brightness * adjustments by the user. In particular, the value may be set to 0 which may * turn off the backlight entirely while still leaving the screen on although * this behavior is device dependent and not guaranteed. * adjustments by the user. In particular, the value may be set to * {@link PowerManager.BRIGHTNESS_OFF} which may turn off the backlight entirely while still * leaving the screen on although this behavior is device dependent and not guaranteed. * </p><p> * The available range of display brightness values and their behavior while dozing is * hardware dependent and may vary across devices. The dream may therefore Loading @@ -1090,7 +1092,7 @@ public class DreamService extends Service implements Window.Callback { * </p> * * @param brightness The screen brightness while dozing as a value between * {@link PowerManager#BRIGHTNESS_OFF} (0) and {@link PowerManager#BRIGHTNESS_ON} (255), * {@link PowerManager#BRIGHTNESS_OFF + 1} (1) and {@link PowerManager#BRIGHTNESS_ON} (255), * or {@link PowerManager#BRIGHTNESS_DEFAULT} (-1) to ask the system to apply * its default policy based on the screen state. * Loading @@ -1107,6 +1109,44 @@ public class DreamService extends Service implements Window.Callback { } } /** * Sets the screen brightness to use while dozing. * <p> * The value of this property determines the power state of the primary display * once {@link #startDozing} has been called. The default value is * {@link PowerManager#BRIGHTNESS_INVALID_FLOAT} which lets the system decide. * The dream may set a different brightness before starting to doze and may adjust * the brightness while dozing to conserve power and achieve various effects. * </p><p> * Note that dream may specify any brightness in the full 0-1 range, including * values that are less than the minimum value for manual screen brightness * adjustments by the user. In particular, the value may be set to * {@link PowerManager#BRIGHTNESS_OFF_FLOAT} which may turn off the backlight entirely while * still leaving the screen on although this behavior is device dependent and not guaranteed. * </p><p> * The available range of display brightness values and their behavior while dozing is * hardware dependent and may vary across devices. The dream may therefore * need to be modified or configured to correctly support the hardware. * </p> * * @param brightness The screen brightness while dozing as a value between * {@link PowerManager#BRIGHTNESS_MIN} (0) and {@link PowerManager#BRIGHTNESS_MAX} (1), * or {@link PowerManager#BRIGHTNESS_INVALID_FLOAT} (Float.NaN) to ask the system to apply * its default policy based on the screen state. * * @hide For use by system UI components only. */ @UnsupportedAppUsage public void setDozeScreenBrightnessFloat(float brightness) { if (!Float.isNaN(brightness)) { brightness = clampAbsoluteBrightnessFloat(brightness); } if (!BrightnessSynchronizer.floatEquals(mDozeScreenBrightnessFloat, brightness)) { mDozeScreenBrightnessFloat = brightness; updateDoze(); } } /** * Called when this Dream is constructed. */ Loading Loading @@ -1751,6 +1791,13 @@ public class DreamService extends Service implements Window.Callback { return MathUtils.constrain(value, PowerManager.BRIGHTNESS_OFF, PowerManager.BRIGHTNESS_ON); } private static float clampAbsoluteBrightnessFloat(float value) { if (value == PowerManager.BRIGHTNESS_OFF_FLOAT) { return value; } return MathUtils.constrain(value, PowerManager.BRIGHTNESS_MIN, PowerManager.BRIGHTNESS_MAX); } /** * The DreamServiceWrapper is used as a gateway to the system_server, where DreamController * uses it to control the DreamService. It is also used to receive callbacks from the Loading
core/java/android/service/dreams/IDreamManager.aidl +4 −2 Original line number Diff line number Diff line Loading @@ -42,7 +42,8 @@ interface IDreamManager { /** @deprecated Please use finishSelfOneway instead. */ void finishSelf(in IBinder token, boolean immediate); /** @deprecated Please use startDozingOneway instead. */ void startDozing(in IBinder token, int screenState, int reason, int screenBrightness); void startDozing(in IBinder token, int screenState, int reason, float screenBrightnessFloat, int screenBrightnessInt); void stopDozing(in IBinder token); void forceAmbientDisplayEnabled(boolean enabled); ComponentName[] getDreamComponentsForUser(int userId); Loading @@ -52,6 +53,7 @@ interface IDreamManager { void startDreamActivity(in Intent intent); @JavaPassthrough(annotation="@android.annotation.RequiresPermission(android.Manifest.permission.WRITE_DREAM_STATE)") oneway void setDreamIsObscured(in boolean isObscured); oneway void startDozingOneway(in IBinder token, int screenState, int reason, int screenBrightness); oneway void startDozingOneway(in IBinder token, int screenState, int reason, float screenBrightnessFloat, int screenBrightnessInt); oneway void finishSelfOneway(in IBinder token, boolean immediate); }
packages/SystemUI/src/com/android/systemui/doze/AlwaysOnDisplayPolicy.java +13 −3 Original line number Diff line number Diff line Loading @@ -57,21 +57,29 @@ public class AlwaysOnDisplayPolicy { /** * Integer used to dim the screen while dozing. * Integer in the scale [1, 255] used to dim the screen while dozing. * * @see R.integer.config_screenBrightnessDoze */ public int defaultDozeBrightness; /** * Integer used to dim the screen just before the screen turns off. * Integer in the scale [1, 255] used to dim the screen just before the screen turns off. * * @see R.integer.config_screenBrightnessDim */ public int dimBrightness; /** * Integer array to map ambient brightness type to real screen brightness. * Float in the scale [0, 1] used to dim the screen just before the screen turns off. * * @see R.integer.config_screenBrightnessDimFloat */ public float dimBrightnessFloat; /** * Integer array to map ambient brightness type to real screen brightness in the integer scale * [1, 255]. * * @see Settings.Global#ALWAYS_ON_DISPLAY_CONSTANTS * @see #KEY_SCREEN_BRIGHTNESS_ARRAY Loading Loading @@ -189,6 +197,8 @@ public class AlwaysOnDisplayPolicy { com.android.internal.R.integer.config_screenBrightnessDoze); dimBrightness = resources.getInteger( com.android.internal.R.integer.config_screenBrightnessDim); dimBrightnessFloat = resources.getFloat( com.android.internal.R.dimen.config_screenBrightnessDimFloat); screenBrightnessArray = mParser.getIntArray(KEY_SCREEN_BRIGHTNESS_ARRAY, resources.getIntArray( R.array.config_doze_brightness_sensor_to_brightness)); Loading