summaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
authorDaniel Sandler <dsandler@android.com>2012-01-30 14:33:52 -0500
committerDaniel Sandler <dsandler@android.com>2012-04-09 15:33:26 -0400
commit7d276c377ce0c56630c06a6da431a6cb9bd76d1e (patch)
treeb5c96c71988ec1a0f3cbd7f64269651e69c8de92 /services
parent63c115c4aa2158ea18338a9fb2c2619755958ddc (diff)
downloadframeworks_base-7d276c377ce0c56630c06a6da431a6cb9bd76d1e.zip
frameworks_base-7d276c377ce0c56630c06a6da431a6cb9bd76d1e.tar.gz
frameworks_base-7d276c377ce0c56630c06a6da431a6cb9bd76d1e.tar.bz2
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
Diffstat (limited to 'services')
-rw-r--r--services/java/com/android/server/PowerManagerService.java15
-rw-r--r--services/java/com/android/server/SystemServer.java20
-rw-r--r--services/java/com/android/server/wm/WindowManagerService.java12
3 files changed, 46 insertions, 1 deletions
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 @@ public class PowerManagerService extends IPowerManager.Stub
+ " noChangeLights=" + noChangeLights
+ " reason=" + reason);
}
-
+
if (noChangeLights) {
newState = (newState & ~LIGHTS_MASK) | (mPowerState & LIGHTS_MASK);
}
@@ -1794,6 +1794,19 @@ public class PowerManagerService extends IPowerManager.Stub
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
diff --git a/services/java/com/android/server/SystemServer.java b/services/java/com/android/server/SystemServer.java
index 7dd736d..68bbb571 100644
--- a/services/java/com/android/server/SystemServer.java
+++ b/services/java/com/android/server/SystemServer.java
@@ -38,6 +38,7 @@ import android.provider.Settings;
import android.server.BluetoothA2dpService;
import android.server.BluetoothService;
import android.server.search.SearchManagerService;
+import android.service.dreams.DreamManagerService;
import android.util.DisplayMetrics;
import android.util.EventLog;
import android.util.Log;
@@ -269,6 +270,7 @@ class ServerThread extends Thread {
CountryDetectorService countryDetector = null;
TextServicesManagerService tsms = null;
LockSettingsService lockSettings = null;
+ DreamManagerService dreamy = null;
// Bring up services needed for UI.
if (factoryTest != SystemServer.FACTORY_TEST_LOW_LEVEL) {
@@ -613,6 +615,18 @@ class ServerThread extends Thread {
} catch (Throwable e) {
reportWtf("starting CommonTimeManagementService service", e);
}
+
+ if (context.getResources().getBoolean(
+ com.android.internal.R.bool.config_enableDreams)) {
+ try {
+ Slog.i(TAG, "Dreams Service");
+ // Dreams (interactive idle-time views, a/k/a screen savers)
+ dreamy = new DreamManagerService(context);
+ ServiceManager.addService("dreams", dreamy);
+ } catch (Throwable e) {
+ reportWtf("starting DreamManagerService", e);
+ }
+ }
}
// Before things start rolling, be sure we have decided whether
@@ -699,6 +713,7 @@ class ServerThread extends Thread {
final CommonTimeManagementService commonTimeMgmtServiceF = commonTimeMgmtService;
final TextServicesManagerService textServiceManagerServiceF = tsms;
final StatusBarManagerService statusBarF = statusBar;
+ final DreamManagerService dreamyF = dreamy;
// We now tell the activity manager it is okay to run third party
// code. It will call back into us once it has gotten to the state
@@ -805,6 +820,11 @@ class ServerThread extends Thread {
} catch (Throwable e) {
reportWtf("making Text Services Manager Service ready", e);
}
+ try {
+ if (dreamyF != null) dreamyF.systemReady();
+ } catch (Throwable e) {
+ reportWtf("making DreamManagerService ready", e);
+ }
}
});
diff --git a/services/java/com/android/server/wm/WindowManagerService.java b/services/java/com/android/server/wm/WindowManagerService.java
index 6f7852d..5fa8111 100644
--- a/services/java/com/android/server/wm/WindowManagerService.java
+++ b/services/java/com/android/server/wm/WindowManagerService.java
@@ -28,6 +28,7 @@ import static android.view.WindowManager.LayoutParams.LAST_APPLICATION_WINDOW;
import static android.view.WindowManager.LayoutParams.LAST_SUB_WINDOW;
import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_STARTING;
import static android.view.WindowManager.LayoutParams.TYPE_BASE_APPLICATION;
+import static android.view.WindowManager.LayoutParams.TYPE_DREAM;
import static android.view.WindowManager.LayoutParams.TYPE_INPUT_METHOD;
import static android.view.WindowManager.LayoutParams.TYPE_INPUT_METHOD_DIALOG;
import static android.view.WindowManager.LayoutParams.TYPE_WALLPAPER;
@@ -2131,6 +2132,11 @@ public class WindowManagerService extends IWindowManager.Stub
+ attrs.token + ". Aborting.");
return WindowManagerImpl.ADD_BAD_APP_TOKEN;
}
+ if (attrs.type == TYPE_DREAM) {
+ Slog.w(TAG, "Attempted to add Dream window with unknown token "
+ + attrs.token + ". Aborting.");
+ return WindowManagerImpl.ADD_BAD_APP_TOKEN;
+ }
token = new WindowToken(this, attrs.token, -1, false);
addToken = true;
} else if (attrs.type >= FIRST_APPLICATION_WINDOW
@@ -2163,6 +2169,12 @@ public class WindowManagerService extends IWindowManager.Stub
+ attrs.token + ". Aborting.");
return WindowManagerImpl.ADD_BAD_APP_TOKEN;
}
+ } else if (attrs.type == TYPE_DREAM) {
+ if (token.windowType != TYPE_DREAM) {
+ Slog.w(TAG, "Attempted to add Dream window with bad token "
+ + attrs.token + ". Aborting.");
+ return WindowManagerImpl.ADD_BAD_APP_TOKEN;
+ }
}
win = new WindowState(this, session, client, token,