summaryrefslogtreecommitdiff
path: root/core/java
diff options
context:
space:
mode:
authorOleg Kibirev <olegk@google.com>2018-11-13 10:43:07 -0800
committerOleg Kibirev <olegk@google.com>2018-11-15 12:54:02 -0800
commit2385b5ef7ec943f40b9f44305569bdbc2d7ef059 (patch)
tree98ae0b548e2c83cc37fe79a5ac5dad218032c2e7 /core/java
parent8b46029dbbc78f3cc91e16513d2b61e24522dec3 (diff)
Add a PowerManager @SystemApi to start a dream
go/startdream This is a simplier alternative to ag/5460565 Bug: 119130690 Test: Use of API from launcherX Change-Id: I9b8e1dc04095045077c37014290120efec9dc331
Diffstat (limited to 'core/java')
-rw-r--r--core/java/android/os/PowerManager.java24
1 files changed, 24 insertions, 0 deletions
diff --git a/core/java/android/os/PowerManager.java b/core/java/android/os/PowerManager.java
index a307cd80e724..1c1db68babc3 100644
--- a/core/java/android/os/PowerManager.java
+++ b/core/java/android/os/PowerManager.java
@@ -24,6 +24,7 @@ import android.annotation.SystemApi;
import android.annotation.SystemService;
import android.annotation.TestApi;
import android.content.Context;
+import android.service.dreams.Sandman;
import android.util.Log;
import android.util.proto.ProtoOutputStream;
@@ -1001,6 +1002,29 @@ public final class PowerManager {
}
/**
+ * Requests the device to start dreaming.
+ * <p>
+ * If dream can not be started, for example if another {@link PowerManager} transition is in
+ * progress, does nothing. Unlike {@link #nap(long)}, this does not put device to sleep when
+ * dream ends.
+ * </p><p>
+ * Requires the {@link android.Manifest.permission#WRITE_DREAM_STATE} permission.
+ * </p>
+ *
+ * @param time The time when the request to nap was issued, in the
+ * {@link SystemClock#uptimeMillis()} time base. This timestamp may be used to correctly
+ * order the dream request with other power management functions. It should be set
+ * to the timestamp of the input event that caused the request to dream.
+ *
+ * @hide
+ */
+ @SystemApi
+ @RequiresPermission(android.Manifest.permission.WRITE_DREAM_STATE)
+ public void dream(long time) {
+ Sandman.startDreamByUserRequest(mContext);
+ }
+
+ /**
* Boosts the brightness of the screen to maximum for a predetermined
* period of time. This is used to make the screen more readable in bright
* daylight for a short duration.