summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorJeff Brown <jeffbrown@google.com>2012-07-27 15:51:34 -0700
committerJeff Brown <jeffbrown@google.com>2012-08-15 03:06:24 -0700
commit9630704ed3b265f008a8f64ec60a33cf9dcd3345 (patch)
tree0c905e55ac062b625bf7a9ced250f05213d7873f /tools
parentff7e6ef4f18ff94a9836492ff3ccd1ba7f6804f3 (diff)
downloadframeworks_base-9630704ed3b265f008a8f64ec60a33cf9dcd3345.zip
frameworks_base-9630704ed3b265f008a8f64ec60a33cf9dcd3345.tar.gz
frameworks_base-9630704ed3b265f008a8f64ec60a33cf9dcd3345.tar.bz2
Power manager rewrite.
The major goal of this rewrite is to make it easier to implement power management policies correctly. According, the new implementation primarily uses state-based rather than event-based triggers for applying changes to the current power state. For example, when an application requests that the proximity sensor be used to manage the screen state (by way of a wake lock), the power manager makes note of the fact that the set of wake locks changed. Then it executes a common update function that recalculates the entire state, first looking at wake locks, then considering user activity, and eventually determining whether the screen should be turned on or off. At this point it may make a request to a component called the DisplayPowerController to asynchronously update the display's powe state. Likewise, DisplayPowerController makes note of the updated power request and schedules its own update function to figure out what needs to be changed. The big benefit of this approach is that it's easy to mutate multiple properties of the power state simultaneously then apply their joint effects together all at once. Transitions between states are detected and resolved by the update in a consistent manner. The new power manager service has is implemented as a set of loosely coupled components. For the most part, information only flows one way through these components (by issuing a request to that component) although some components support sending a message back to indicate when the work has been completed. For example, the DisplayPowerController posts a callback runnable asynchronously to tell the PowerManagerService when the display is ready. An important feature of this approach is that each component neatly encapsulates its state and maintains its own invariants. Moreover, we do not need to worry about deadlocks or awkward mutual exclusion semantics because most of the requests are asynchronous. The benefits of this design are especially apparent in the implementation of the screen on / off and brightness control animations which are able to take advantage of framework features like properties, ObjectAnimator and Choreographer. The screen on / off animation is now the responsibility of the power manager (instead of surface flinger). This change makes it much easier to ensure that the animation is properly coordinated with other power state changes and eliminates the cause of race conditions in the older implementation. The because of the userActivity() function has been changed so that it never wakes the device from sleep. This change removes ambiguity around forcing or disabling user activity for various purposes. To wake the device, use wakeUp(). To put it to sleep, use goToSleep(). Simple. The power manager service interface and API has been significantly simplified and consolidated. Also fixed some inconsistencies related to how the minimum and maximum screen brightness setting was presented in brightness control widgets and enforced behind the scenes. At present the following features are implemented: - Wake locks. - User activity. - Wake up / go to sleep. - Power state broadcasts. - Battery stats and event log notifications. - Dreams. - Proximity screen off. - Animated screen on / off transitions. - Auto-dimming. - Auto-brightness control for the screen backlight with different timeouts for ramping up versus ramping down. - Auto-on when plugged or unplugged. - Stay on when plugged. - Device administration maximum user activity timeout. - Application controlled brightness via window manager. The following features are not yet implemented: - Reduced user activity timeout for the key guard. - Reduced user activity timeout for the phone application. - Coordinating screen on barriers with the window manager. - Preventing auto-rotation during power state changes. - Auto-brightness adjustment setting (feature was disabled in previous version of the power manager service pending an improved UI design so leaving it out for now). - Interpolated brightness control (a proposed new scheme for more compactly specifying auto-brightness levels in config.xml). - Button / keyboard backlight control. - Change window manager to associated WorkSource with KEEP_SCREEN_ON_FLAG wake lock instead of talking directly to the battery stats service. - Optionally support animating screen brightness when turning on/off instead of playing electron beam animation (config_animateScreenLights). Change-Id: I1d7a52e98f0449f76d70bf421f6a7f245957d1d7
Diffstat (limited to 'tools')
-rw-r--r--tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeContext.java2
-rw-r--r--tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgePowerManager.java31
2 files changed, 14 insertions, 19 deletions
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeContext.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeContext.java
index 0a1191b..292e4fc 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeContext.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeContext.java
@@ -440,7 +440,7 @@ public final class BridgeContext extends Context {
}
if (POWER_SERVICE.equals(service)) {
- return new PowerManager(new BridgePowerManager(), new Handler());
+ return new PowerManager(this, new BridgePowerManager(), new Handler());
}
throw new UnsupportedOperationException("Unsupported Service: " + service);
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgePowerManager.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgePowerManager.java
index 6071a6b..0c85204 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgePowerManager.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgePowerManager.java
@@ -39,7 +39,7 @@ public class BridgePowerManager implements IPowerManager {
}
@Override
- public void acquireWakeLock(int arg0, IBinder arg1, String arg2, WorkSource arg3)
+ public void acquireWakeLock(IBinder arg0, int arg1, String arg2, WorkSource arg3)
throws RemoteException {
// pass for now.
}
@@ -55,18 +55,7 @@ public class BridgePowerManager implements IPowerManager {
}
@Override
- public int getSupportedWakeLockFlags() throws RemoteException {
- // pass for now.
- return 0;
- }
-
- @Override
- public void goToSleep(long arg0) throws RemoteException {
- // pass for now.
- }
-
- @Override
- public void goToSleepWithReason(long arg0, int arg1) throws RemoteException {
+ public void goToSleep(long arg0, int arg1) throws RemoteException {
// pass for now.
}
@@ -91,17 +80,17 @@ public class BridgePowerManager implements IPowerManager {
}
@Override
- public void setAutoBrightnessAdjustment(float arg0) throws RemoteException {
+ public void setTemporaryScreenAutoBrightnessAdjustmentSettingOverride(float arg0) throws RemoteException {
// pass for now.
}
@Override
- public void setBacklightBrightness(int arg0) throws RemoteException {
+ public void setTemporaryScreenBrightnessSettingOverride(int arg0) throws RemoteException {
// pass for now.
}
@Override
- public void setMaximumScreenOffTimeount(int arg0) throws RemoteException {
+ public void setMaximumScreenOffTimeoutFromDeviceAdmin(int arg0) throws RemoteException {
// pass for now.
}
@@ -121,12 +110,18 @@ public class BridgePowerManager implements IPowerManager {
}
@Override
- public void userActivity(long arg0, boolean arg1) throws RemoteException {
+ public boolean isWakeLockLevelSupported(int level) throws RemoteException {
+ // pass for now.
+ return true;
+ }
+
+ @Override
+ public void userActivity(long time, int event, int flags) throws RemoteException {
// pass for now.
}
@Override
- public void userActivityWithForce(long arg0, boolean arg1, boolean arg2) throws RemoteException {
+ public void wakeUp(long time) throws RemoteException {
// pass for now.
}
}