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

Commit 0c9bbf4e authored by Jeff Brown's avatar Jeff Brown Committed by Android (Google) Code Review
Browse files

Merge "Make DreamManagerService more robust." into jb-mr1-dev

parents 5a864aa0 62c82e4d
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -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);
+31 −3
Original line number Diff line number Diff line
@@ -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
@@ -494,6 +494,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>
+8 −2
Original line number Diff line number Diff line
@@ -71,6 +71,12 @@ public class Dream extends Service implements Window.Callback {
    private final static boolean DEBUG = true;
    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.
     *
@@ -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");
            }
+1 −1
Original line number Diff line number Diff line
@@ -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
+2 −1
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import android.app.Activity;
import android.content.Intent;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.service.dreams.Dream;
import android.service.dreams.IDreamManager;
import android.util.Slog;

@@ -45,7 +46,7 @@ public class Somnambulator extends Activity {
            setResult(RESULT_OK, resultIntent);
        } else {
            IDreamManager somnambulist = IDreamManager.Stub.asInterface(
                    ServiceManager.checkService("dreams"));
                    ServiceManager.checkService(Dream.DREAM_SERVICE));
            if (somnambulist != null) {
                try {
                    Slog.v("Somnambulator", "Dreaming by user request.");
Loading