Loading core/java/android/hardware/display/DisplayManagerInternal.java +8 −2 Original line number Diff line number Diff line Loading @@ -498,6 +498,7 @@ public abstract class DisplayManagerInternal { // Overrides the policy for adjusting screen brightness and state while dozing. public int dozeScreenState; public float dozeScreenBrightness; public int dozeScreenStateReason; public DisplayPowerRequest() { policy = POLICY_BRIGHT; Loading @@ -508,6 +509,7 @@ public abstract class DisplayManagerInternal { blockScreenOn = false; dozeScreenBrightness = PowerManager.BRIGHTNESS_INVALID_FLOAT; dozeScreenState = Display.STATE_UNKNOWN; dozeScreenStateReason = Display.STATE_REASON_UNKNOWN; } public DisplayPowerRequest(DisplayPowerRequest other) { Loading @@ -529,6 +531,7 @@ public abstract class DisplayManagerInternal { boostScreenBrightness = other.boostScreenBrightness; dozeScreenBrightness = other.dozeScreenBrightness; dozeScreenState = other.dozeScreenState; dozeScreenStateReason = other.dozeScreenStateReason; } @Override Loading @@ -551,7 +554,8 @@ public abstract class DisplayManagerInternal { && lowPowerMode == other.lowPowerMode && boostScreenBrightness == other.boostScreenBrightness && floatEquals(dozeScreenBrightness, other.dozeScreenBrightness) && dozeScreenState == other.dozeScreenState; && dozeScreenState == other.dozeScreenState && dozeScreenStateReason == other.dozeScreenStateReason; } private boolean floatEquals(float f1, float f2) { Loading @@ -575,7 +579,9 @@ public abstract class DisplayManagerInternal { + ", lowPowerMode=" + lowPowerMode + ", boostScreenBrightness=" + boostScreenBrightness + ", dozeScreenBrightness=" + dozeScreenBrightness + ", dozeScreenState=" + Display.stateToString(dozeScreenState); + ", dozeScreenState=" + Display.stateToString(dozeScreenState) + ", dozeScreenStateReason=" + Display.stateReasonToString(dozeScreenStateReason); } public static String policyToString(int policy) { Loading core/java/android/os/PowerManagerInternal.java +2 −1 Original line number Diff line number Diff line Loading @@ -136,11 +136,12 @@ 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. */ public abstract void setDozeOverrideFromDreamManager( int screenState, int screenBrightness); int screenState, @Display.StateReason int reason, int screenBrightness); /** * 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 +20 −2 Original line number Diff line number Diff line Loading @@ -265,6 +265,7 @@ public class DreamService extends Service implements Window.Callback { private boolean mWindowless; 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 boolean mDebug = false; Loading Loading @@ -750,7 +751,9 @@ public class DreamService extends Service implements Window.Callback { if (mDozing) { try { mDreamManager.startDozing(mDreamToken, mDozeScreenState, mDozeScreenBrightness); mDreamManager.startDozing( mDreamToken, mDozeScreenState, mDozeScreenStateReason, mDozeScreenBrightness); } catch (RemoteException ex) { // system server died } Loading Loading @@ -809,6 +812,19 @@ public class DreamService extends Service implements Window.Callback { return mDozeScreenState; } /** * Same as {@link #setDozeScreenState(int, int)}, but with no screen state reason specified. * * <p>Use {@link #setDozeScreenState(int, int)} whenever possible to allow properly accounting * for the screen state reason. * * @hide */ @UnsupportedAppUsage public void setDozeScreenState(int state) { setDozeScreenState(state, Display.STATE_REASON_UNKNOWN); } /** * Sets the screen state to use while dozing. * <p> Loading Loading @@ -843,13 +859,15 @@ public class DreamService extends Service implements Window.Callback { * {@link Display#STATE_DOZE}, {@link Display#STATE_DOZE_SUSPEND}, * {@link Display#STATE_ON_SUSPEND}, {@link Display#STATE_OFF}, or {@link Display#STATE_UNKNOWN} * for the default behavior. * @param reason the reason for setting the specified screen state. * * @hide For use by system UI components only. */ @UnsupportedAppUsage public void setDozeScreenState(int state) { public void setDozeScreenState(int state, @Display.StateReason int reason) { if (mDozeScreenState != state) { mDozeScreenState = state; mDozeScreenStateReason = reason; updateDoze(); } } Loading core/java/android/service/dreams/IDreamManager.aidl +1 −1 Original line number Diff line number Diff line Loading @@ -40,7 +40,7 @@ interface IDreamManager { boolean isDreamingOrInPreview(); boolean canStartDreaming(boolean isScreenOn); void finishSelf(in IBinder token, boolean immediate); void startDozing(in IBinder token, int screenState, int screenBrightness); void startDozing(in IBinder token, int screenState, int reason, int screenBrightness); void stopDozing(in IBinder token); void forceAmbientDisplayEnabled(boolean enabled); ComponentName[] getDreamComponentsForUser(int userId); Loading core/java/android/view/Display.java +97 −0 Original line number Diff line number Diff line Loading @@ -503,6 +503,79 @@ public final class Display { */ public static final int STATE_ON_SUSPEND = ViewProtoEnums.DISPLAY_STATE_ON_SUSPEND; // 6 /** * The cause of the display state change is unknown. * * @hide */ public static final int STATE_REASON_UNKNOWN = ViewProtoEnums.DISPLAY_STATE_REASON_UNKNOWN; /** * The default power and display policy caused the display state. * * @hide */ public static final int STATE_REASON_DEFAULT_POLICY = ViewProtoEnums.DISPLAY_STATE_REASON_DEFAULT_POLICY; /** * The display state was changed due to acquiring a draw wake lock. * * @hide */ public static final int STATE_REASON_DRAW_WAKE_LOCK = ViewProtoEnums.DISPLAY_STATE_REASON_DRAW_WAKE_LOCK; /** * The display state was changed due to display offloading. * * @hide */ public static final int STATE_REASON_OFFLOAD = ViewProtoEnums.DISPLAY_STATE_REASON_OFFLOAD; /** * The display state was changed due to a tilt event. * * @hide */ public static final int STATE_REASON_TILT = ViewProtoEnums.DISPLAY_STATE_REASON_TILT; /** * The display state was changed due to the dream manager. * * @hide */ public static final int STATE_REASON_DREAM_MANAGER = ViewProtoEnums.DISPLAY_STATE_REASON_DREAM_MANAGER; /** * The display state was changed due to a {@link KeyEvent}. * * @hide */ public static final int STATE_REASON_KEY = ViewProtoEnums.DISPLAY_STATE_REASON_KEY; /** * The display state was changed due to a {@link MotionEvent}. * * @hide */ public static final int STATE_REASON_MOTION = ViewProtoEnums.DISPLAY_STATE_REASON_MOTION; /** @hide */ @IntDef(prefix = {"STATE_REASON_"}, value = { STATE_REASON_UNKNOWN, STATE_REASON_DEFAULT_POLICY, STATE_REASON_DRAW_WAKE_LOCK, STATE_REASON_OFFLOAD, STATE_REASON_TILT, STATE_REASON_DREAM_MANAGER, STATE_REASON_KEY, STATE_REASON_MOTION, }) @Retention(RetentionPolicy.SOURCE) public @interface StateReason {} /* The color mode constants defined below must be kept in sync with the ones in * system/core/include/system/graphics-base.h */ Loading Loading @@ -1996,6 +2069,30 @@ public final class Display { } } /** @hide */ public static String stateReasonToString(@StateReason int reason) { switch (reason) { case STATE_REASON_UNKNOWN: return "UNKNOWN"; case STATE_REASON_DEFAULT_POLICY: return "DEFAULT_POLICY"; case STATE_REASON_DRAW_WAKE_LOCK: return "DRAW_WAKE_LOCK"; case STATE_REASON_OFFLOAD: return "OFFLOAD"; case STATE_REASON_TILT: return "TILT"; case STATE_REASON_DREAM_MANAGER: return "DREAM_MANAGER"; case STATE_REASON_KEY: return "KEY"; case STATE_REASON_MOTION: return "MOTION"; default: return Integer.toString(reason); } } /** * Returns true if display updates may be suspended while in the specified * display power state. In SUSPEND states, updates are absolutely forbidden. Loading Loading
core/java/android/hardware/display/DisplayManagerInternal.java +8 −2 Original line number Diff line number Diff line Loading @@ -498,6 +498,7 @@ public abstract class DisplayManagerInternal { // Overrides the policy for adjusting screen brightness and state while dozing. public int dozeScreenState; public float dozeScreenBrightness; public int dozeScreenStateReason; public DisplayPowerRequest() { policy = POLICY_BRIGHT; Loading @@ -508,6 +509,7 @@ public abstract class DisplayManagerInternal { blockScreenOn = false; dozeScreenBrightness = PowerManager.BRIGHTNESS_INVALID_FLOAT; dozeScreenState = Display.STATE_UNKNOWN; dozeScreenStateReason = Display.STATE_REASON_UNKNOWN; } public DisplayPowerRequest(DisplayPowerRequest other) { Loading @@ -529,6 +531,7 @@ public abstract class DisplayManagerInternal { boostScreenBrightness = other.boostScreenBrightness; dozeScreenBrightness = other.dozeScreenBrightness; dozeScreenState = other.dozeScreenState; dozeScreenStateReason = other.dozeScreenStateReason; } @Override Loading @@ -551,7 +554,8 @@ public abstract class DisplayManagerInternal { && lowPowerMode == other.lowPowerMode && boostScreenBrightness == other.boostScreenBrightness && floatEquals(dozeScreenBrightness, other.dozeScreenBrightness) && dozeScreenState == other.dozeScreenState; && dozeScreenState == other.dozeScreenState && dozeScreenStateReason == other.dozeScreenStateReason; } private boolean floatEquals(float f1, float f2) { Loading @@ -575,7 +579,9 @@ public abstract class DisplayManagerInternal { + ", lowPowerMode=" + lowPowerMode + ", boostScreenBrightness=" + boostScreenBrightness + ", dozeScreenBrightness=" + dozeScreenBrightness + ", dozeScreenState=" + Display.stateToString(dozeScreenState); + ", dozeScreenState=" + Display.stateToString(dozeScreenState) + ", dozeScreenStateReason=" + Display.stateReasonToString(dozeScreenStateReason); } public static String policyToString(int policy) { Loading
core/java/android/os/PowerManagerInternal.java +2 −1 Original line number Diff line number Diff line Loading @@ -136,11 +136,12 @@ 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. */ public abstract void setDozeOverrideFromDreamManager( int screenState, int screenBrightness); int screenState, @Display.StateReason int reason, int screenBrightness); /** * 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 +20 −2 Original line number Diff line number Diff line Loading @@ -265,6 +265,7 @@ public class DreamService extends Service implements Window.Callback { private boolean mWindowless; 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 boolean mDebug = false; Loading Loading @@ -750,7 +751,9 @@ public class DreamService extends Service implements Window.Callback { if (mDozing) { try { mDreamManager.startDozing(mDreamToken, mDozeScreenState, mDozeScreenBrightness); mDreamManager.startDozing( mDreamToken, mDozeScreenState, mDozeScreenStateReason, mDozeScreenBrightness); } catch (RemoteException ex) { // system server died } Loading Loading @@ -809,6 +812,19 @@ public class DreamService extends Service implements Window.Callback { return mDozeScreenState; } /** * Same as {@link #setDozeScreenState(int, int)}, but with no screen state reason specified. * * <p>Use {@link #setDozeScreenState(int, int)} whenever possible to allow properly accounting * for the screen state reason. * * @hide */ @UnsupportedAppUsage public void setDozeScreenState(int state) { setDozeScreenState(state, Display.STATE_REASON_UNKNOWN); } /** * Sets the screen state to use while dozing. * <p> Loading Loading @@ -843,13 +859,15 @@ public class DreamService extends Service implements Window.Callback { * {@link Display#STATE_DOZE}, {@link Display#STATE_DOZE_SUSPEND}, * {@link Display#STATE_ON_SUSPEND}, {@link Display#STATE_OFF}, or {@link Display#STATE_UNKNOWN} * for the default behavior. * @param reason the reason for setting the specified screen state. * * @hide For use by system UI components only. */ @UnsupportedAppUsage public void setDozeScreenState(int state) { public void setDozeScreenState(int state, @Display.StateReason int reason) { if (mDozeScreenState != state) { mDozeScreenState = state; mDozeScreenStateReason = reason; updateDoze(); } } Loading
core/java/android/service/dreams/IDreamManager.aidl +1 −1 Original line number Diff line number Diff line Loading @@ -40,7 +40,7 @@ interface IDreamManager { boolean isDreamingOrInPreview(); boolean canStartDreaming(boolean isScreenOn); void finishSelf(in IBinder token, boolean immediate); void startDozing(in IBinder token, int screenState, int screenBrightness); void startDozing(in IBinder token, int screenState, int reason, int screenBrightness); void stopDozing(in IBinder token); void forceAmbientDisplayEnabled(boolean enabled); ComponentName[] getDreamComponentsForUser(int userId); Loading
core/java/android/view/Display.java +97 −0 Original line number Diff line number Diff line Loading @@ -503,6 +503,79 @@ public final class Display { */ public static final int STATE_ON_SUSPEND = ViewProtoEnums.DISPLAY_STATE_ON_SUSPEND; // 6 /** * The cause of the display state change is unknown. * * @hide */ public static final int STATE_REASON_UNKNOWN = ViewProtoEnums.DISPLAY_STATE_REASON_UNKNOWN; /** * The default power and display policy caused the display state. * * @hide */ public static final int STATE_REASON_DEFAULT_POLICY = ViewProtoEnums.DISPLAY_STATE_REASON_DEFAULT_POLICY; /** * The display state was changed due to acquiring a draw wake lock. * * @hide */ public static final int STATE_REASON_DRAW_WAKE_LOCK = ViewProtoEnums.DISPLAY_STATE_REASON_DRAW_WAKE_LOCK; /** * The display state was changed due to display offloading. * * @hide */ public static final int STATE_REASON_OFFLOAD = ViewProtoEnums.DISPLAY_STATE_REASON_OFFLOAD; /** * The display state was changed due to a tilt event. * * @hide */ public static final int STATE_REASON_TILT = ViewProtoEnums.DISPLAY_STATE_REASON_TILT; /** * The display state was changed due to the dream manager. * * @hide */ public static final int STATE_REASON_DREAM_MANAGER = ViewProtoEnums.DISPLAY_STATE_REASON_DREAM_MANAGER; /** * The display state was changed due to a {@link KeyEvent}. * * @hide */ public static final int STATE_REASON_KEY = ViewProtoEnums.DISPLAY_STATE_REASON_KEY; /** * The display state was changed due to a {@link MotionEvent}. * * @hide */ public static final int STATE_REASON_MOTION = ViewProtoEnums.DISPLAY_STATE_REASON_MOTION; /** @hide */ @IntDef(prefix = {"STATE_REASON_"}, value = { STATE_REASON_UNKNOWN, STATE_REASON_DEFAULT_POLICY, STATE_REASON_DRAW_WAKE_LOCK, STATE_REASON_OFFLOAD, STATE_REASON_TILT, STATE_REASON_DREAM_MANAGER, STATE_REASON_KEY, STATE_REASON_MOTION, }) @Retention(RetentionPolicy.SOURCE) public @interface StateReason {} /* The color mode constants defined below must be kept in sync with the ones in * system/core/include/system/graphics-base.h */ Loading Loading @@ -1996,6 +2069,30 @@ public final class Display { } } /** @hide */ public static String stateReasonToString(@StateReason int reason) { switch (reason) { case STATE_REASON_UNKNOWN: return "UNKNOWN"; case STATE_REASON_DEFAULT_POLICY: return "DEFAULT_POLICY"; case STATE_REASON_DRAW_WAKE_LOCK: return "DRAW_WAKE_LOCK"; case STATE_REASON_OFFLOAD: return "OFFLOAD"; case STATE_REASON_TILT: return "TILT"; case STATE_REASON_DREAM_MANAGER: return "DREAM_MANAGER"; case STATE_REASON_KEY: return "KEY"; case STATE_REASON_MOTION: return "MOTION"; default: return Integer.toString(reason); } } /** * Returns true if display updates may be suspended while in the specified * display power state. In SUSPEND states, updates are absolutely forbidden. Loading