diff options
author | Nick Armstrong-Crews <strongarm@google.com> | 2015-09-04 18:04:12 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2015-09-04 18:04:12 +0000 |
commit | 6f0ba402242cb8fd374f5b188e53669ec0cf34c7 (patch) | |
tree | 235ef38d84b06f708c3e6389dc895947ea906bd7 /services | |
parent | fb611846f6ca62ea248eac0b35a8d6d1fe5f5116 (diff) | |
parent | 677adf1e66ba83b8fb2c849c181303b35bd489bc (diff) | |
download | frameworks_base-6f0ba402242cb8fd374f5b188e53669ec0cf34c7.zip frameworks_base-6f0ba402242cb8fd374f5b188e53669ec0cf34c7.tar.gz frameworks_base-6f0ba402242cb8fd374f5b188e53669ec0cf34c7.tar.bz2 |
Merge "Handle KEYCODE_SOFT_SLEEP from Ungaze." into cw-e-dev
Diffstat (limited to 'services')
-rw-r--r-- | services/core/java/com/android/server/policy/PhoneWindowManager.java | 12 | ||||
-rw-r--r-- | services/core/java/com/android/server/power/PowerManagerService.java | 31 |
2 files changed, 43 insertions, 0 deletions
diff --git a/services/core/java/com/android/server/policy/PhoneWindowManager.java b/services/core/java/com/android/server/policy/PhoneWindowManager.java index 34737c1..c7c5afd 100644 --- a/services/core/java/com/android/server/policy/PhoneWindowManager.java +++ b/services/core/java/com/android/server/policy/PhoneWindowManager.java @@ -65,6 +65,7 @@ import android.os.Looper; import android.os.Message; import android.os.Messenger; import android.os.PowerManager; +import android.os.PowerManagerInternal; import android.os.Process; import android.os.RemoteException; import android.os.ServiceManager; @@ -265,6 +266,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { WindowManagerFuncs mWindowManagerFuncs; WindowManagerInternal mWindowManagerInternal; PowerManager mPowerManager; + PowerManagerInternal mPowerManagerInternal; ActivityManagerInternal mActivityManagerInternal; DreamManagerInternal mDreamManagerInternal; IStatusBarService mStatusBarService; @@ -1324,6 +1326,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { mActivityManagerInternal = LocalServices.getService(ActivityManagerInternal.class); mDreamManagerInternal = LocalServices.getService(DreamManagerInternal.class); mAppOpsManager = (AppOpsManager) mContext.getSystemService(Context.APP_OPS_SERVICE); + mPowerManagerInternal = LocalServices.getService(PowerManagerInternal.class); // Init display burn-in protection boolean burnInProtectionEnabled = context.getResources().getBoolean( @@ -5080,6 +5083,15 @@ public class PhoneWindowManager implements WindowManagerPolicy { break; } + case KeyEvent.KEYCODE_SOFT_SLEEP: { + result &= ~ACTION_PASS_TO_USER; + isWakeKey = false; + if (!down) { + mPowerManagerInternal.setUserInactiveOverrideFromWindowManager(); + } + break; + } + case KeyEvent.KEYCODE_WAKEUP: { result &= ~ACTION_PASS_TO_USER; isWakeKey = true; diff --git a/services/core/java/com/android/server/power/PowerManagerService.java b/services/core/java/com/android/server/power/PowerManagerService.java index b920f97..a06ea1f 100644 --- a/services/core/java/com/android/server/power/PowerManagerService.java +++ b/services/core/java/com/android/server/power/PowerManagerService.java @@ -393,6 +393,10 @@ public final class PowerManagerService extends SystemService // Use -1 to disable. private int mScreenBrightnessOverrideFromWindowManager = -1; + // The window manager has determined the user to be inactive via other means. + // Set this to false to disable. + private boolean mUserInactiveOverrideFromWindowManager; + // 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. @@ -1028,6 +1032,10 @@ public final class PowerManagerService extends SystemService mNotifier.onUserActivity(event, uid); + if (mUserInactiveOverrideFromWindowManager) { + mUserInactiveOverrideFromWindowManager = false; + } + if (mWakefulness == WAKEFULNESS_ASLEEP || mWakefulness == WAKEFULNESS_DOZING || (flags & PowerManager.USER_ACTIVITY_FLAG_INDIRECT) != 0) { @@ -1525,6 +1533,7 @@ public final class PowerManagerService extends SystemService final int sleepTimeout = getSleepTimeoutLocked(); final int screenOffTimeout = getScreenOffTimeoutLocked(sleepTimeout); final int screenDimDuration = getScreenDimDurationLocked(screenOffTimeout); + final boolean userInactiveOverride = mUserInactiveOverrideFromWindowManager; mUserActivitySummary = 0; if (mLastUserActivityTime >= mLastWakeTime) { @@ -1550,6 +1559,7 @@ public final class PowerManagerService extends SystemService } } } + if (mUserActivitySummary == 0) { if (sleepTimeout >= 0) { final long anyUserActivity = Math.max(mLastUserActivityTime, @@ -1565,6 +1575,12 @@ public final class PowerManagerService extends SystemService nextTimeout = -1; } } + + if (mUserActivitySummary != USER_ACTIVITY_SCREEN_DREAM && userInactiveOverride) { + mUserActivitySummary = USER_ACTIVITY_SCREEN_DREAM; + nextTimeout = -1; + } + if (mUserActivitySummary != 0 && nextTimeout >= 0) { Message msg = mHandler.obtainMessage(MSG_USER_ACTIVITY_TIMEOUT); msg.setAsynchronous(true); @@ -2494,6 +2510,14 @@ public final class PowerManagerService extends SystemService } } + private void setUserInactiveOverrideFromWindowManagerInternal() { + synchronized (mLock) { + mUserInactiveOverrideFromWindowManager = true; + mDirty |= DIRTY_USER_ACTIVITY; + updatePowerStateLocked(); + } + } + private void setUserActivityTimeoutOverrideFromWindowManagerInternal(long timeoutMillis) { synchronized (mLock) { if (mUserActivityTimeoutOverrideFromWindowManager != timeoutMillis) { @@ -2683,6 +2707,8 @@ public final class PowerManagerService extends SystemService + mScreenBrightnessOverrideFromWindowManager); pw.println(" mUserActivityTimeoutOverrideFromWindowManager=" + mUserActivityTimeoutOverrideFromWindowManager); + pw.println(" mUserInactiveOverrideFromWindowManager=" + + mUserInactiveOverrideFromWindowManager); pw.println(" mTemporaryScreenBrightnessSettingOverride=" + mTemporaryScreenBrightnessSettingOverride); pw.println(" mTemporaryScreenAutoBrightnessAdjustmentSettingOverride=" @@ -3487,6 +3513,11 @@ public final class PowerManagerService extends SystemService } @Override + public void setUserInactiveOverrideFromWindowManager() { + setUserInactiveOverrideFromWindowManagerInternal(); + } + + @Override public void setUserActivityTimeoutOverrideFromWindowManager(long timeoutMillis) { setUserActivityTimeoutOverrideFromWindowManagerInternal(timeoutMillis); } |