summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorJeff Brown <jeffbrown@google.com>2012-09-26 17:25:22 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2012-09-26 17:25:23 -0700
commit0c9bbf4e13f2be6a4b930da2379c77e06a68c2cb (patch)
tree128f62103b9db114d27037404d9cef29d44b3d4f /core
parent5a864aa0d8919d38b23c9e7e90455181d3a979e3 (diff)
parent62c82e4d92cc0b856059f905d81885f7808a0e7d (diff)
downloadframeworks_base-0c9bbf4e13f2be6a4b930da2379c77e06a68c2cb.zip
frameworks_base-0c9bbf4e13f2be6a4b930da2379c77e06a68c2cb.tar.gz
frameworks_base-0c9bbf4e13f2be6a4b930da2379c77e06a68c2cb.tar.bz2
Merge "Make DreamManagerService more robust." into jb-mr1-dev
Diffstat (limited to 'core')
-rw-r--r--core/java/android/os/IPowerManager.aidl1
-rw-r--r--core/java/android/os/PowerManager.java34
-rw-r--r--core/java/android/service/dreams/Dream.java10
-rw-r--r--core/java/android/service/dreams/IDreamManager.aidl2
4 files changed, 41 insertions, 6 deletions
diff --git a/core/java/android/os/IPowerManager.aidl b/core/java/android/os/IPowerManager.aidl
index 7aee644..eec19cb 100644
--- a/core/java/android/os/IPowerManager.aidl
+++ b/core/java/android/os/IPowerManager.aidl
@@ -34,6 +34,7 @@ interface IPowerManager
void userActivity(long time, int event, int flags);
void wakeUp(long time);
void goToSleep(long time, int reason);
+ void nap(long time);
boolean isScreenOn();
void reboot(String reason);
diff --git a/core/java/android/os/PowerManager.java b/core/java/android/os/PowerManager.java
index cc2c002..58372f4 100644
--- a/core/java/android/os/PowerManager.java
+++ b/core/java/android/os/PowerManager.java
@@ -426,7 +426,7 @@ public final class PowerManager {
* </p>
*
* @param when The time of the user activity, in the {@link SystemClock#uptimeMillis()}
- * time base. This timestamp is used to correctly order the user activity with
+ * time base. This timestamp is used to correctly order the user activity request with
* other power management functions. It should be set
* to the timestamp of the input event that caused the user activity.
* @param noChangeLights If true, does not cause the keyboard backlight to turn on
@@ -457,7 +457,7 @@ public final class PowerManager {
*
* @param time The time when the request to go to sleep was issued, in the
* {@link SystemClock#uptimeMillis()} time base. This timestamp is used to correctly
- * order the user activity with other power management functions. It should be set
+ * order the go to sleep request with other power management functions. It should be set
* to the timestamp of the input event that caused the request to go to sleep.
*
* @see #userActivity
@@ -481,7 +481,7 @@ public final class PowerManager {
*
* @param time The time when the request to wake up was issued, in the
* {@link SystemClock#uptimeMillis()} time base. This timestamp is used to correctly
- * order the user activity with other power management functions. It should be set
+ * order the wake up request with other power management functions. It should be set
* to the timestamp of the input event that caused the request to wake up.
*
* @see #userActivity
@@ -495,6 +495,34 @@ public final class PowerManager {
}
/**
+ * Forces the device to start napping.
+ * <p>
+ * If the device is currently awake, starts dreaming, otherwise does nothing.
+ * When the dream ends or if the dream cannot be started, the device will
+ * either wake up or go to sleep depending on whether there has been recent
+ * user activity.
+ * </p><p>
+ * Requires the {@link android.Manifest.permission#DEVICE_POWER} permission.
+ * </p>
+ *
+ * @param time The time when the request to nap was issued, in the
+ * {@link SystemClock#uptimeMillis()} time base. This timestamp is used to correctly
+ * order the nap request with other power management functions. It should be set
+ * to the timestamp of the input event that caused the request to nap.
+ *
+ * @see #wakeUp
+ * @see #goToSleep
+ *
+ * @hide
+ */
+ public void nap(long time) {
+ try {
+ mService.nap(time);
+ } catch (RemoteException e) {
+ }
+ }
+
+ /**
* Sets the brightness of the backlights (screen, keyboard, button).
* <p>
* Requires the {@link android.Manifest.permission#DEVICE_POWER} permission.
diff --git a/core/java/android/service/dreams/Dream.java b/core/java/android/service/dreams/Dream.java
index 473414c..590acfa 100644
--- a/core/java/android/service/dreams/Dream.java
+++ b/core/java/android/service/dreams/Dream.java
@@ -72,6 +72,12 @@ public class Dream extends Service implements Window.Callback {
private final String TAG = Dream.class.getSimpleName() + "[" + getClass().getSimpleName() + "]";
/**
+ * The name of the dream manager service.
+ * @hide
+ */
+ public static final String DREAM_SERVICE = "dreams";
+
+ /**
* Used with {@link Intent#ACTION_MAIN} to declare the necessary intent-filter for a dream.
*
* @see Dream
@@ -499,7 +505,7 @@ public class Dream extends Service implements Window.Callback {
// end public api
private void loadSandman() {
- mSandman = IDreamManager.Stub.asInterface(ServiceManager.getService("dreams"));
+ mSandman = IDreamManager.Stub.asInterface(ServiceManager.getService(DREAM_SERVICE));
}
private final void attach(IBinder windowToken) {
@@ -584,7 +590,7 @@ public class Dream extends Service implements Window.Callback {
mFinished = true;
if (mSandman != null) {
- mSandman.awakenSelf(mWindowToken);
+ mSandman.finishSelf(mWindowToken);
} else {
Slog.w(TAG, "No dream manager found");
}
diff --git a/core/java/android/service/dreams/IDreamManager.aidl b/core/java/android/service/dreams/IDreamManager.aidl
index bd1c524..1c1b390 100644
--- a/core/java/android/service/dreams/IDreamManager.aidl
+++ b/core/java/android/service/dreams/IDreamManager.aidl
@@ -30,5 +30,5 @@ interface IDreamManager {
ComponentName getDefaultDreamComponent();
void testDream(in ComponentName componentName);
boolean isDreaming();
- void awakenSelf(in IBinder token);
+ void finishSelf(in IBinder token);
} \ No newline at end of file