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

Commit 037c33ea authored by Jeff Brown's avatar Jeff Brown
Browse files

Plumb display power state through display manager.

Declare a new method, Display.getState() to retrieve the actual
power state of a display.

Improved documentation for Intent.ACTION_SCREEN_ON and
Intent.ACTION_SCREEN_OFF to clarify what they really mean in
terms of the interactive state of the device.

Deprecated PowerManager.isScreenOn() and replaced it with
PowerManager.isInteractive() with a more suggestive name and
better documentation.

Redirect display power state changes to go through the display
manager first and only then head over to the power manager for
legacy compatibility.

Eliminated the bright here and woke here policy flags since they
were unused.  Simplified the input dispatch policy somewhat.

Ensure that screen wake locks are respected up until the point
when dozing really begins.

Fixed a regression in DreamService where onDreamingStarted
might be called before onWindowAttached.

Bug: 13133142
Bug: 13472578
Bug: 13929355
Bug: 13760290
Change-Id: Iabef96921dd554ce3768fb18619cefc3230b5fb0
parent 7289f3ab
Loading
Loading
Loading
Loading
+9 −3
Original line number Diff line number Diff line
@@ -18321,7 +18321,8 @@ package android.os {
  public final class PowerManager {
    method public void goToSleep(long);
    method public boolean isScreenOn();
    method public boolean isInteractive();
    method public deprecated boolean isScreenOn();
    method public android.os.PowerManager.WakeLock newWakeLock(int, java.lang.String);
    method public void reboot(java.lang.String);
    method public void userActivity(long, boolean);
@@ -26541,6 +26542,7 @@ package android.view {
    method public float getRefreshRate();
    method public int getRotation();
    method public void getSize(android.graphics.Point);
    method public int getState();
    method public deprecated int getWidth();
    method public boolean isValid();
    field public static final int DEFAULT_DISPLAY = 0; // 0x0
@@ -26548,6 +26550,10 @@ package android.view {
    field public static final int FLAG_PRIVATE = 4; // 0x4
    field public static final int FLAG_SECURE = 2; // 0x2
    field public static final int FLAG_SUPPORTS_PROTECTED_BUFFERS = 1; // 0x1
    field public static final int STATE_DOZING = 3; // 0x3
    field public static final int STATE_OFF = 1; // 0x1
    field public static final int STATE_ON = 2; // 0x2
    field public static final int STATE_UNKNOWN = 0; // 0x0
  }
  public class DragEvent implements android.os.Parcelable {
@@ -26882,7 +26888,7 @@ package android.view {
    field public static final int FLAG_SOFT_KEYBOARD = 2; // 0x2
    field public static final int FLAG_TRACKING = 512; // 0x200
    field public static final int FLAG_VIRTUAL_HARD_KEY = 64; // 0x40
    field public static final int FLAG_WOKE_HERE = 1; // 0x1
    field public static final deprecated int FLAG_WOKE_HERE = 1; // 0x1
    field public static final int KEYCODE_0 = 7; // 0x7
    field public static final int KEYCODE_1 = 8; // 0x8
    field public static final int KEYCODE_2 = 9; // 0x9
@@ -28946,7 +28952,7 @@ package android.view {
    field public static final int FLAG_SHOW_WALLPAPER = 1048576; // 0x100000
    field public static final int FLAG_SHOW_WHEN_LOCKED = 524288; // 0x80000
    field public static final int FLAG_SPLIT_TOUCH = 8388608; // 0x800000
    field public static final int FLAG_TOUCHABLE_WHEN_WAKING = 64; // 0x40
    field public static final deprecated int FLAG_TOUCHABLE_WHEN_WAKING = 64; // 0x40
    field public static final int FLAG_TRANSLUCENT_NAVIGATION = 134217728; // 0x8000000
    field public static final int FLAG_TRANSLUCENT_STATUS = 67108864; // 0x4000000
    field public static final int FLAG_TURN_SCREEN_ON = 2097152; // 0x200000
+25 −2
Original line number Diff line number Diff line
@@ -1414,15 +1414,38 @@ public class Intent implements Parcelable, Cloneable {
    // Standard intent broadcast actions (see action variable).

    /**
     * Broadcast Action: Sent after the screen turns off.
     * Broadcast Action: Sent when the device goes to sleep and becomes non-interactive.
     * <p>
     * For historical reasons, the name of this broadcast action refers to the power
     * state of the screen but it is actually sent in response to changes in the
     * overall interactive state of the device.
     * </p><p>
     * This broadcast is sent when the device becomes non-interactive which may have
     * nothing to do with the screen turning off.  To determine the
     * actual state of the screen, use {@link android.view.Display#getState}.
     * </p><p>
     * See {@link android.os.PowerManager#isInteractive} for details.
     * </p>
     *
     * <p class="note">This is a protected intent that can only be sent
     * by the system.
     */
    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
    public static final String ACTION_SCREEN_OFF = "android.intent.action.SCREEN_OFF";

    /**
     * Broadcast Action: Sent after the screen turns on.
     * Broadcast Action: Sent when the device wakes up and becomes interactive.
     * <p>
     * For historical reasons, the name of this broadcast action refers to the power
     * state of the screen but it is actually sent in response to changes in the
     * overall interactive state of the device.
     * </p><p>
     * This broadcast is sent when the device becomes interactive which may have
     * nothing to do with the screen turning on.  To determine the
     * actual state of the screen, use {@link android.view.Display#getState}.
     * </p><p>
     * See {@link android.os.PowerManager#isInteractive} for details.
     * </p>
     *
     * <p class="note">This is a protected intent that can only be sent
     * by the system.
+1 −13
Original line number Diff line number Diff line
@@ -57,16 +57,6 @@ public abstract class DisplayManagerInternal {
     */
    public abstract boolean isProximitySensorAvailable();

    /**
     * Called by the power manager to blank all displays.
     */
    public abstract void blankAllDisplaysFromPowerManager();

    /**
     * Called by the power manager to unblank all displays.
     */
    public abstract void unblankAllDisplaysFromPowerManager();

    /**
     * Returns information about the specified logical display.
     *
@@ -254,12 +244,10 @@ public abstract class DisplayManagerInternal {
        void onStateChanged();
        void onProximityPositive();
        void onProximityNegative();
        void onDisplayStateChange(int state); // one of the Display state constants

        void acquireSuspendBlocker();
        void releaseSuspendBlocker();

        void blankAllDisplays();
        void unblankAllDisplays();
    }

    /**
+9 −3
Original line number Diff line number Diff line
@@ -25,12 +25,18 @@ import android.view.InputEvent;
 * @hide Only for use within the system server.
 */
public abstract class InputManagerInternal {
    public abstract boolean injectInputEvent(InputEvent event, int displayId, int mode);

    /**
     * Sets information about the displays as needed by the input system.
     * The input system should copy this information if required.
     * Called by the display manager to set information about the displays as needed
     * by the input system.  The input system must copy this information to retain it.
     */
    public abstract void setDisplayViewports(DisplayViewport defaultViewport,
            DisplayViewport externalTouchViewport);

    public abstract boolean injectInputEvent(InputEvent event, int displayId, int mode);
    /**
     * Called by the power manager to tell the input manager whether it should start
     * watching for wake events.
     */
    public abstract void setInteractive(boolean interactive);
}
+1 −1
Original line number Diff line number Diff line
@@ -37,8 +37,8 @@ interface IPowerManager
    void wakeUp(long time);
    void goToSleep(long time, int reason);
    void nap(long time);
    boolean isInteractive();

    boolean isScreenOn();
    void reboot(boolean confirm, String reason, boolean wait);
    void shutdown(boolean confirm, boolean wait);
    void crash(String message);
Loading