Loading core/java/android/os/PowerManagerInternal.java +4 −7 Original line number Diff line number Diff line Loading @@ -149,17 +149,14 @@ 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 screenBrightnessFloat The overridden screen brightness between * @param screenBrightness 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). * {@link PowerManager#BRIGHTNESS_INVALID_FLOAT} to disable the override. * @param useNormalBrightnessForDoze Whether use normal brightness while device is dozing. */ public abstract void setDozeOverrideFromDreamManager( int screenState, @Display.StateReason int reason, float screenBrightnessFloat, int screenBrightnessInt, boolean useNormalBrightnessForDoze); int screenState, @Display.StateReason int reason, float screenBrightness, boolean useNormalBrightnessForDoze); /** * Used by sidekick manager to tell the power manager if it shouldn't change the display state Loading core/java/android/service/dreams/DreamService.java +12 −60 Original line number Diff line number Diff line Loading @@ -267,8 +267,7 @@ public class DreamService extends Service implements Window.Callback { private boolean mPreviewMode; private int mDozeScreenState = Display.STATE_UNKNOWN; private @Display.StateReason int mDozeScreenStateReason = Display.STATE_REASON_UNKNOWN; private int mDozeScreenBrightness = PowerManager.BRIGHTNESS_DEFAULT; private float mDozeScreenBrightnessFloat = PowerManager.BRIGHTNESS_INVALID_FLOAT; private float mDozeScreenBrightness = PowerManager.BRIGHTNESS_INVALID_FLOAT; // This variable being true means dozing device expecting normal(non-doze) brightness. private boolean mUseNormalBrightnessForDoze; Loading Loading @@ -930,18 +929,15 @@ public class DreamService extends Service implements Window.Callback { if (mDozing) { try { Slog.v(mTag, "UpdateDoze mDozeScreenState=" + mDozeScreenState + " mDozeScreenBrightness=" + mDozeScreenBrightness + " mDozeScreenBrightnessFloat=" + mDozeScreenBrightnessFloat); + " mDozeScreenBrightness=" + mDozeScreenBrightness); if (startAndStopDozingInBackground()) { mDreamManager.startDozingOneway( dreamToken, mDozeScreenState, mDozeScreenStateReason, mDozeScreenBrightnessFloat, mDozeScreenBrightness, mUseNormalBrightnessForDoze); mDozeScreenBrightness, mUseNormalBrightnessForDoze); } else { mDreamManager.startDozing( dreamToken, mDozeScreenState, mDozeScreenStateReason, mDozeScreenBrightnessFloat, mDozeScreenBrightness, mUseNormalBrightnessForDoze); mDozeScreenBrightness, mUseNormalBrightnessForDoze); } } catch (RemoteException ex) { // system server died Loading Loading @@ -1094,58 +1090,18 @@ 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 + 1} (1) and {@link PowerManager#BRIGHTNESS_ON} (255), * or {@link PowerManager#BRIGHTNESS_DEFAULT} (-1) to ask the system to apply * {@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. * * @see #setDozeScreenBrightness * @hide For use by system UI components only. */ @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) public int getDozeScreenBrightness() { public float getDozeScreenBrightness() { return mDozeScreenBrightness; } /** * 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_DEFAULT} 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 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 * {@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 * 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_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. * * @hide For use by system UI components only. */ @UnsupportedAppUsage public void setDozeScreenBrightness(int brightness) { if (brightness != PowerManager.BRIGHTNESS_DEFAULT) { brightness = clampAbsoluteBrightness(brightness); } synchronized (this) { if (mDozeScreenBrightness != brightness) { mDozeScreenBrightness = brightness; updateDoze(); } } } /** * Sets the screen brightness. * Loading Loading @@ -1195,14 +1151,14 @@ public class DreamService extends Service implements Window.Callback { * @hide For use by system UI components only. */ @UnsupportedAppUsage public void setDozeScreenBrightnessFloat(float brightness) { public void setDozeScreenBrightness(float brightness) { if (!Float.isNaN(brightness)) { brightness = clampAbsoluteBrightnessFloat(brightness); brightness = clampAbsoluteBrightness(brightness); } synchronized (this) { if (!BrightnessSynchronizer.floatEquals(mDozeScreenBrightnessFloat, brightness)) { mDozeScreenBrightnessFloat = brightness; if (!BrightnessSynchronizer.floatEquals(mDozeScreenBrightness, brightness)) { mDozeScreenBrightness = brightness; updateDoze(); } } Loading Loading @@ -1868,11 +1824,7 @@ public class DreamService extends Service implements Window.Callback { } } private static int clampAbsoluteBrightness(int value) { return MathUtils.constrain(value, PowerManager.BRIGHTNESS_OFF, PowerManager.BRIGHTNESS_ON); } private static float clampAbsoluteBrightnessFloat(float value) { private static float clampAbsoluteBrightness(float value) { if (value == PowerManager.BRIGHTNESS_OFF_FLOAT) { return value; } Loading core/java/android/service/dreams/IDreamManager.aidl +3 −4 Original line number Diff line number Diff line Loading @@ -42,8 +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, float screenBrightnessFloat, int screenBrightnessInt, boolean useNormalBrightnessForDoze); void startDozing(in IBinder token, int screenState, int reason, float screenBrightness, boolean useNormalBrightnessForDoze); void stopDozing(in IBinder token); void forceAmbientDisplayEnabled(boolean enabled); ComponentName[] getDreamComponentsForUser(int userId); Loading @@ -56,8 +56,7 @@ interface IDreamManager { @JavaPassthrough(annotation="@android.annotation.RequiresPermission(android.Manifest.permission.WRITE_DREAM_STATE)") oneway void setDevicePostured(in boolean isPostured); oneway void startDozingOneway(in IBinder token, int screenState, int reason, float screenBrightnessFloat, int screenBrightnessInt, boolean useNormalBrightnessForDoze); float screenBrightness, boolean useNormalBrightnessForDoze); oneway void finishSelfOneway(in IBinder token, boolean immediate); @JavaPassthrough(annotation="@android.annotation.RequiresPermission(android.Manifest.permission.WRITE_SECURE_SETTINGS)") void setScreensaverEnabled(boolean enabled); Loading core/java/com/android/internal/display/BrightnessUtils.java +4 −0 Original line number Diff line number Diff line Loading @@ -34,6 +34,10 @@ import android.util.MathUtils; */ public class BrightnessUtils { // Float.NaN (used as invalid for brightness) cannot be stored in config.xml // so -2 is used instead public static final float INVALID_BRIGHTNESS_IN_CONFIG = -2f; // Hybrid Log Gamma constant values private static final float R = 0.5f; private static final float A = 0.17883277f; Loading packages/SystemUI/src/com/android/systemui/doze/AlwaysOnDisplayPolicy.java +12 −23 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ package com.android.systemui.doze; import static com.android.internal.display.BrightnessUtils.INVALID_BRIGHTNESS_IN_CONFIG; import android.content.ContentResolver; import android.content.Context; import android.content.res.Resources; Loading @@ -28,6 +30,7 @@ import android.text.format.DateUtils; import android.util.KeyValueListParser; import android.util.Log; import com.android.internal.display.BrightnessSynchronizer; import com.android.systemui.dagger.SysUISingleton; import com.android.systemui.res.R; Loading Loading @@ -56,27 +59,12 @@ public class AlwaysOnDisplayPolicy { static final String KEY_WALLPAPER_VISIBILITY_MS = "wallpaper_visibility_timeout"; static final String KEY_WALLPAPER_FADE_OUT_MS = "wallpaper_fade_out_duration"; /** * Integer in the scale [1, 255] used to dim the screen while dozing. * * @see R.integer.config_screenBrightnessDoze */ public int defaultDozeBrightness; /** * 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; /** * Float in the scale [0, 1] used to dim the screen just before the screen turns off. * * @see R.integer.config_screenBrightnessDimFloat * Read from {@link R.integer.config_screenBrightnessDimFloat}. If undefined, * {@link R.integer.config_screenBrightnessDim} is used as a fallback. */ public float dimBrightnessFloat; public float dimBrightness; /** * Integer array to map ambient brightness type to real screen brightness in the integer scale Loading Loading @@ -202,12 +190,13 @@ public class AlwaysOnDisplayPolicy { DEFAULT_WALLPAPER_FADE_OUT_MS); wallpaperVisibilityDuration = mParser.getLong(KEY_WALLPAPER_VISIBILITY_MS, DEFAULT_WALLPAPER_VISIBILITY_MS); defaultDozeBrightness = resources.getInteger( com.android.internal.R.integer.config_screenBrightnessDoze); dimBrightness = resources.getInteger( com.android.internal.R.integer.config_screenBrightnessDim); dimBrightnessFloat = resources.getFloat( dimBrightness = resources.getFloat( com.android.internal.R.dimen.config_screenBrightnessDimFloat); if (dimBrightness == INVALID_BRIGHTNESS_IN_CONFIG) { dimBrightness = BrightnessSynchronizer.brightnessIntToFloat( resources.getInteger( com.android.internal.R.integer.config_screenBrightnessDim)); } 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 +4 −7 Original line number Diff line number Diff line Loading @@ -149,17 +149,14 @@ 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 screenBrightnessFloat The overridden screen brightness between * @param screenBrightness 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). * {@link PowerManager#BRIGHTNESS_INVALID_FLOAT} to disable the override. * @param useNormalBrightnessForDoze Whether use normal brightness while device is dozing. */ public abstract void setDozeOverrideFromDreamManager( int screenState, @Display.StateReason int reason, float screenBrightnessFloat, int screenBrightnessInt, boolean useNormalBrightnessForDoze); int screenState, @Display.StateReason int reason, float screenBrightness, boolean useNormalBrightnessForDoze); /** * Used by sidekick manager to tell the power manager if it shouldn't change the display state Loading
core/java/android/service/dreams/DreamService.java +12 −60 Original line number Diff line number Diff line Loading @@ -267,8 +267,7 @@ public class DreamService extends Service implements Window.Callback { private boolean mPreviewMode; private int mDozeScreenState = Display.STATE_UNKNOWN; private @Display.StateReason int mDozeScreenStateReason = Display.STATE_REASON_UNKNOWN; private int mDozeScreenBrightness = PowerManager.BRIGHTNESS_DEFAULT; private float mDozeScreenBrightnessFloat = PowerManager.BRIGHTNESS_INVALID_FLOAT; private float mDozeScreenBrightness = PowerManager.BRIGHTNESS_INVALID_FLOAT; // This variable being true means dozing device expecting normal(non-doze) brightness. private boolean mUseNormalBrightnessForDoze; Loading Loading @@ -930,18 +929,15 @@ public class DreamService extends Service implements Window.Callback { if (mDozing) { try { Slog.v(mTag, "UpdateDoze mDozeScreenState=" + mDozeScreenState + " mDozeScreenBrightness=" + mDozeScreenBrightness + " mDozeScreenBrightnessFloat=" + mDozeScreenBrightnessFloat); + " mDozeScreenBrightness=" + mDozeScreenBrightness); if (startAndStopDozingInBackground()) { mDreamManager.startDozingOneway( dreamToken, mDozeScreenState, mDozeScreenStateReason, mDozeScreenBrightnessFloat, mDozeScreenBrightness, mUseNormalBrightnessForDoze); mDozeScreenBrightness, mUseNormalBrightnessForDoze); } else { mDreamManager.startDozing( dreamToken, mDozeScreenState, mDozeScreenStateReason, mDozeScreenBrightnessFloat, mDozeScreenBrightness, mUseNormalBrightnessForDoze); mDozeScreenBrightness, mUseNormalBrightnessForDoze); } } catch (RemoteException ex) { // system server died Loading Loading @@ -1094,58 +1090,18 @@ 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 + 1} (1) and {@link PowerManager#BRIGHTNESS_ON} (255), * or {@link PowerManager#BRIGHTNESS_DEFAULT} (-1) to ask the system to apply * {@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. * * @see #setDozeScreenBrightness * @hide For use by system UI components only. */ @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) public int getDozeScreenBrightness() { public float getDozeScreenBrightness() { return mDozeScreenBrightness; } /** * 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_DEFAULT} 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 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 * {@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 * 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_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. * * @hide For use by system UI components only. */ @UnsupportedAppUsage public void setDozeScreenBrightness(int brightness) { if (brightness != PowerManager.BRIGHTNESS_DEFAULT) { brightness = clampAbsoluteBrightness(brightness); } synchronized (this) { if (mDozeScreenBrightness != brightness) { mDozeScreenBrightness = brightness; updateDoze(); } } } /** * Sets the screen brightness. * Loading Loading @@ -1195,14 +1151,14 @@ public class DreamService extends Service implements Window.Callback { * @hide For use by system UI components only. */ @UnsupportedAppUsage public void setDozeScreenBrightnessFloat(float brightness) { public void setDozeScreenBrightness(float brightness) { if (!Float.isNaN(brightness)) { brightness = clampAbsoluteBrightnessFloat(brightness); brightness = clampAbsoluteBrightness(brightness); } synchronized (this) { if (!BrightnessSynchronizer.floatEquals(mDozeScreenBrightnessFloat, brightness)) { mDozeScreenBrightnessFloat = brightness; if (!BrightnessSynchronizer.floatEquals(mDozeScreenBrightness, brightness)) { mDozeScreenBrightness = brightness; updateDoze(); } } Loading Loading @@ -1868,11 +1824,7 @@ public class DreamService extends Service implements Window.Callback { } } private static int clampAbsoluteBrightness(int value) { return MathUtils.constrain(value, PowerManager.BRIGHTNESS_OFF, PowerManager.BRIGHTNESS_ON); } private static float clampAbsoluteBrightnessFloat(float value) { private static float clampAbsoluteBrightness(float value) { if (value == PowerManager.BRIGHTNESS_OFF_FLOAT) { return value; } Loading
core/java/android/service/dreams/IDreamManager.aidl +3 −4 Original line number Diff line number Diff line Loading @@ -42,8 +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, float screenBrightnessFloat, int screenBrightnessInt, boolean useNormalBrightnessForDoze); void startDozing(in IBinder token, int screenState, int reason, float screenBrightness, boolean useNormalBrightnessForDoze); void stopDozing(in IBinder token); void forceAmbientDisplayEnabled(boolean enabled); ComponentName[] getDreamComponentsForUser(int userId); Loading @@ -56,8 +56,7 @@ interface IDreamManager { @JavaPassthrough(annotation="@android.annotation.RequiresPermission(android.Manifest.permission.WRITE_DREAM_STATE)") oneway void setDevicePostured(in boolean isPostured); oneway void startDozingOneway(in IBinder token, int screenState, int reason, float screenBrightnessFloat, int screenBrightnessInt, boolean useNormalBrightnessForDoze); float screenBrightness, boolean useNormalBrightnessForDoze); oneway void finishSelfOneway(in IBinder token, boolean immediate); @JavaPassthrough(annotation="@android.annotation.RequiresPermission(android.Manifest.permission.WRITE_SECURE_SETTINGS)") void setScreensaverEnabled(boolean enabled); Loading
core/java/com/android/internal/display/BrightnessUtils.java +4 −0 Original line number Diff line number Diff line Loading @@ -34,6 +34,10 @@ import android.util.MathUtils; */ public class BrightnessUtils { // Float.NaN (used as invalid for brightness) cannot be stored in config.xml // so -2 is used instead public static final float INVALID_BRIGHTNESS_IN_CONFIG = -2f; // Hybrid Log Gamma constant values private static final float R = 0.5f; private static final float A = 0.17883277f; Loading
packages/SystemUI/src/com/android/systemui/doze/AlwaysOnDisplayPolicy.java +12 −23 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ package com.android.systemui.doze; import static com.android.internal.display.BrightnessUtils.INVALID_BRIGHTNESS_IN_CONFIG; import android.content.ContentResolver; import android.content.Context; import android.content.res.Resources; Loading @@ -28,6 +30,7 @@ import android.text.format.DateUtils; import android.util.KeyValueListParser; import android.util.Log; import com.android.internal.display.BrightnessSynchronizer; import com.android.systemui.dagger.SysUISingleton; import com.android.systemui.res.R; Loading Loading @@ -56,27 +59,12 @@ public class AlwaysOnDisplayPolicy { static final String KEY_WALLPAPER_VISIBILITY_MS = "wallpaper_visibility_timeout"; static final String KEY_WALLPAPER_FADE_OUT_MS = "wallpaper_fade_out_duration"; /** * Integer in the scale [1, 255] used to dim the screen while dozing. * * @see R.integer.config_screenBrightnessDoze */ public int defaultDozeBrightness; /** * 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; /** * Float in the scale [0, 1] used to dim the screen just before the screen turns off. * * @see R.integer.config_screenBrightnessDimFloat * Read from {@link R.integer.config_screenBrightnessDimFloat}. If undefined, * {@link R.integer.config_screenBrightnessDim} is used as a fallback. */ public float dimBrightnessFloat; public float dimBrightness; /** * Integer array to map ambient brightness type to real screen brightness in the integer scale Loading Loading @@ -202,12 +190,13 @@ public class AlwaysOnDisplayPolicy { DEFAULT_WALLPAPER_FADE_OUT_MS); wallpaperVisibilityDuration = mParser.getLong(KEY_WALLPAPER_VISIBILITY_MS, DEFAULT_WALLPAPER_VISIBILITY_MS); defaultDozeBrightness = resources.getInteger( com.android.internal.R.integer.config_screenBrightnessDoze); dimBrightness = resources.getInteger( com.android.internal.R.integer.config_screenBrightnessDim); dimBrightnessFloat = resources.getFloat( dimBrightness = resources.getFloat( com.android.internal.R.dimen.config_screenBrightnessDimFloat); if (dimBrightness == INVALID_BRIGHTNESS_IN_CONFIG) { dimBrightness = BrightnessSynchronizer.brightnessIntToFloat( resources.getInteger( com.android.internal.R.integer.config_screenBrightnessDim)); } screenBrightnessArray = mParser.getIntArray(KEY_SCREEN_BRIGHTNESS_ARRAY, resources.getIntArray( R.array.config_doze_brightness_sensor_to_brightness)); Loading