diff options
author | Jeff Brown <jeffbrown@google.com> | 2014-04-09 00:31:55 -0700 |
---|---|---|
committer | Jeff Brown <jeffbrown@google.com> | 2014-04-10 20:46:14 -0700 |
commit | 037c33eae74bee2774897d969d48947f9abe254f (patch) | |
tree | 9f6a33f07f48b9a08088eb287c1bfdd1fd97bda5 /core/java/android/os/PowerManager.java | |
parent | 7289f3ab8f05db6206d696d75f460fadc05dc731 (diff) | |
download | frameworks_base-037c33eae74bee2774897d969d48947f9abe254f.zip frameworks_base-037c33eae74bee2774897d969d48947f9abe254f.tar.gz frameworks_base-037c33eae74bee2774897d969d48947f9abe254f.tar.bz2 |
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
Diffstat (limited to 'core/java/android/os/PowerManager.java')
-rw-r--r-- | core/java/android/os/PowerManager.java | 59 |
1 files changed, 51 insertions, 8 deletions
diff --git a/core/java/android/os/PowerManager.java b/core/java/android/os/PowerManager.java index 86ef479..646bfef 100644 --- a/core/java/android/os/PowerManager.java +++ b/core/java/android/os/PowerManager.java @@ -582,21 +582,64 @@ public final class PowerManager { } /** - * Returns whether the screen is currently on. + * Returns true if the device is in an interactive state. * <p> - * Only indicates whether the screen is on. The screen could be either bright or dim. + * For historical reasons, the name of this method refers to the power state of + * the screen but it actually describes the overall interactive state of + * the device. This method has been replaced by {@link #isInteractive}. * </p><p> - * {@samplecode - * PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE); - * boolean isScreenOn = pm.isScreenOn(); - * } + * The value returned by this method only indicates whether the device is + * in an interactive state which may have nothing to do with the screen being + * on or off. To determine the actual state of the screen, + * use {@link android.view.Display#getState}. * </p> * - * @return whether the screen is on (bright or dim). + * @return True if the device is in an interactive state. + * + * @deprecated Use {@link #isInteractive} instead. */ + @Deprecated public boolean isScreenOn() { + return isInteractive(); + } + + /** + * Returns true if the device is in an interactive state. + * <p> + * When this method returns true, the device is awake and ready to interact + * with the user (although this is not a guarantee that the user is actively + * interacting with the device just this moment). The main screen is usually + * turned on while in this state. Certain features, such as the proximity + * sensor, may temporarily turn off the screen while still leaving the device in an + * interactive state. Note in particular that the device is still considered + * to be interactive while dreaming (since dreams can be interactive) but not + * when it is dozing or asleep. + * </p><p> + * When this method returns false, the device is dozing or asleep and must + * be awoken before it will become ready to interact with the user again. The + * main screen is usually turned off while in this state. Certain features, + * such as "ambient mode" may cause the main screen to remain on (albeit in a + * low power state) to display system-provided content while the device dozes. + * </p><p> + * The system will send a {@link android.content.Intent#ACTION_SCREEN_ON screen on} + * or {@link android.content.Intent#ACTION_SCREEN_OFF screen off} broadcast + * whenever the interactive state of the device changes. For historical reasons, + * the names of these broadcasts refer to the power state of the screen + * but they are actually sent in response to changes in the overall interactive + * state of the device, as described by this method. + * </p><p> + * Services may use the non-interactive state as a hint to conserve power + * since the user is not present. + * </p> + * + * @return True if the device is in an interactive state. + * + * @see android.content.Intent#ACTION_SCREEN_ON + * @see android.content.Intent#ACTION_SCREEN_OFF + */ + public boolean isInteractive() { try { - return mService.isScreenOn(); + return mService.isInteractive(); } catch (RemoteException e) { return false; } |