New Android Dreams architecture, disabled for now.

Rather than normal Activities (which have a host of problems
when used for this purpose), screen savers are now a
special kind of Service that can add views to its own
special window (TYPE_DREAM, in the SCREENSAVER layer).

Dreams are now launched by the power manager; whenever it is
about to turn the screen off, it asks the window manager if
it wants to run a screen saver instead. (http://b/5677408)

Also, the new config_enableDreams bool allows the entire
feature to be switched on or off in one place. It is
currently switched off (and the APIs are all @hidden).

Change-Id: Idfe9d430568471d15f4b463cb70586a899a331f7
diff --git a/services/java/com/android/server/PowerManagerService.java b/services/java/com/android/server/PowerManagerService.java
index 52a4110..bebce7e 100644
--- a/services/java/com/android/server/PowerManagerService.java
+++ b/services/java/com/android/server/PowerManagerService.java
@@ -1752,7 +1752,7 @@
                         + " noChangeLights=" + noChangeLights
                         + " reason=" + reason);
             }
-
+            
             if (noChangeLights) {
                 newState = (newState & ~LIGHTS_MASK) | (mPowerState & LIGHTS_MASK);
             }
@@ -1794,6 +1794,19 @@
 
             final boolean stateChanged = mPowerState != newState;
 
+            if (stateChanged && reason == WindowManagerPolicy.OFF_BECAUSE_OF_TIMEOUT) {
+                if (mPolicy.isScreenSaverEnabled()) {
+                    if (mSpew) {
+                        Slog.d(TAG, "setPowerState: running screen saver instead of turning off screen");
+                    }
+                    if (mPolicy.startScreenSaver()) {
+                        // was successful
+                        return;
+                    }
+                }
+            }
+
+
             if (oldScreenOn != newScreenOn) {
                 if (newScreenOn) {
                     // When the user presses the power button, we need to always send out the