summaryrefslogtreecommitdiff
path: root/services/java/com/android/server/power/PowerManagerService.java
diff options
context:
space:
mode:
authorJeff Brown <jeffbrown@google.com>2012-09-30 18:58:59 -0700
committerJeff Brown <jeffbrown@google.com>2012-10-01 14:27:34 -0700
commit1e3b98d47df596d0c4eadbdf60143709f8465b28 (patch)
treeed63fa39f6d2db3b3a3fd9caf61174129198c6cc /services/java/com/android/server/power/PowerManagerService.java
parent1f7a09b5df9f859781d9cfa0053fad44c72c2168 (diff)
New internal API to eliminate poke locks.
Added a new WindowManager.LayoutParams inputFeatures flag to disable automatic user activity behavior when an input event is sent to a window. Added a new WindowManager.LayoutParams field userActivityTimeout. Bug: 7165399 Change-Id: I204eafa37ef26aacc2c52a1ba1ecce1eebb0e0d9
Diffstat (limited to 'services/java/com/android/server/power/PowerManagerService.java')
-rw-r--r--services/java/com/android/server/power/PowerManagerService.java46
1 files changed, 40 insertions, 6 deletions
diff --git a/services/java/com/android/server/power/PowerManagerService.java b/services/java/com/android/server/power/PowerManagerService.java
index b35fa11508cc..ca86b7f02d72 100644
--- a/services/java/com/android/server/power/PowerManagerService.java
+++ b/services/java/com/android/server/power/PowerManagerService.java
@@ -266,6 +266,11 @@ public final class PowerManagerService extends IPowerManager.Stub
// Use -1 to disable.
private int mScreenBrightnessOverrideFromWindowManager = -1;
+ // The user activity timeout override from the window manager
+ // to allow the current foreground activity to override the user activity timeout.
+ // Use -1 to disable.
+ private long mUserActivityTimeoutOverrideFromWindowManager = -1;
+
// The screen brightness setting override from the settings application
// to temporarily adjust the brightness until next updated,
// Use -1 to disable.
@@ -1156,6 +1161,9 @@ public final class PowerManagerService extends IPowerManager.Stub
if (isMaximumScreenOffTimeoutFromDeviceAdminEnforcedLocked()) {
timeout = Math.min(timeout, mMaximumScreenOffTimeoutFromDeviceAdmin);
}
+ if (mUserActivityTimeoutOverrideFromWindowManager >= 0) {
+ timeout = (int)Math.min(timeout, mUserActivityTimeoutOverrideFromWindowManager);
+ }
return Math.max(timeout, MINIMUM_SCREEN_OFF_TIMEOUT);
}
@@ -1573,12 +1581,6 @@ public final class PowerManagerService extends IPowerManager.Stub
}
}
- @Override // Binder call
- public void setPokeLock(int pokey, IBinder lock, String tag) {
- // TODO Auto-generated method stub
- // Only used by phone app, delete this
- }
-
/**
* Set the setting that determines whether the device stays on when plugged in.
* The argument is a bit string, with each bit specifying a power source that,
@@ -1721,6 +1723,36 @@ public final class PowerManagerService extends IPowerManager.Stub
}
/**
+ * Used by the window manager to override the user activity timeout based on the
+ * current foreground activity. It can only be used to make the timeout shorter
+ * than usual, not longer.
+ *
+ * This method must only be called by the window manager.
+ *
+ * @param timeoutMillis The overridden timeout, or -1 to disable the override.
+ */
+ public void setUserActivityTimeoutOverrideFromWindowManager(long timeoutMillis) {
+ mContext.enforceCallingOrSelfPermission(android.Manifest.permission.DEVICE_POWER, null);
+
+ final long ident = Binder.clearCallingIdentity();
+ try {
+ setUserActivityTimeoutOverrideFromWindowManagerInternal(timeoutMillis);
+ } finally {
+ Binder.restoreCallingIdentity(ident);
+ }
+ }
+
+ private void setUserActivityTimeoutOverrideFromWindowManagerInternal(long timeoutMillis) {
+ synchronized (mLock) {
+ if (mUserActivityTimeoutOverrideFromWindowManager != timeoutMillis) {
+ mUserActivityTimeoutOverrideFromWindowManager = timeoutMillis;
+ mDirty |= DIRTY_SETTINGS;
+ updatePowerStateLocked();
+ }
+ }
+ }
+
+ /**
* Used by the settings application and brightness control widgets to
* temporarily override the current screen brightness setting so that the
* user can observe the effect of an intended settings change without applying
@@ -1869,6 +1901,8 @@ public final class PowerManagerService extends IPowerManager.Stub
pw.println(" mScreenBrightnessModeSetting=" + mScreenBrightnessModeSetting);
pw.println(" mScreenBrightnessOverrideFromWindowManager="
+ mScreenBrightnessOverrideFromWindowManager);
+ pw.println(" mUserActivityTimeoutOverrideFromWindowManager="
+ + mUserActivityTimeoutOverrideFromWindowManager);
pw.println(" mTemporaryScreenBrightnessSettingOverride="
+ mTemporaryScreenBrightnessSettingOverride);
pw.println(" mTemporaryScreenAutoBrightnessAdjustmentSettingOverride="