diff options
author | Jeff Brown <jeffbrown@google.com> | 2014-05-21 08:40:33 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2014-05-21 08:40:33 +0000 |
commit | fcc4fed3c16a57ef713a96b7298ed43aaeef2df4 (patch) | |
tree | 6c6307b9e734caed7bdeb3c983bba895fc2900f9 /policy | |
parent | 1d265716954122f79d5fdd9d953a98e303d298c9 (diff) | |
parent | 6fb904bfd1f943547d6e5bc6f199ffec2290da01 (diff) | |
download | frameworks_base-fcc4fed3c16a57ef713a96b7298ed43aaeef2df4.zip frameworks_base-fcc4fed3c16a57ef713a96b7298ed43aaeef2df4.tar.gz frameworks_base-fcc4fed3c16a57ef713a96b7298ed43aaeef2df4.tar.bz2 |
am 6fb904bf: Merge "Make power button behavior configurable." into klp-modular-dev
* commit '6fb904bfd1f943547d6e5bc6f199ffec2290da01':
Make power button behavior configurable.
Diffstat (limited to 'policy')
-rw-r--r-- | policy/src/com/android/internal/policy/impl/PhoneWindowManager.java | 46 |
1 files changed, 41 insertions, 5 deletions
diff --git a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java index 72f1e4f..524cf69 100644 --- a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java +++ b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java @@ -134,6 +134,11 @@ public class PhoneWindowManager implements WindowManagerPolicy { static final boolean ENABLE_CAR_DOCK_HOME_CAPTURE = true; static final boolean ENABLE_DESK_DOCK_HOME_CAPTURE = false; + static final int SHORT_PRESS_POWER_NOTHING = 0; + static final int SHORT_PRESS_POWER_GO_TO_SLEEP = 1; + static final int SHORT_PRESS_POWER_REALLY_GO_TO_SLEEP = 2; + static final int SHORT_PRESS_POWER_REALLY_GO_TO_SLEEP_AND_GO_HOME = 3; + static final int LONG_PRESS_POWER_NOTHING = 0; static final int LONG_PRESS_POWER_GLOBAL_ACTIONS = 1; static final int LONG_PRESS_POWER_SHUT_OFF = 2; @@ -291,6 +296,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { int mLidKeyboardAccessibility; int mLidNavigationAccessibility; boolean mLidControlsSleep; + int mShortPressOnPowerBehavior = -1; int mLongPressOnPowerBehavior = -1; boolean mScreenOnEarly = false; boolean mScreenOnFully = false; @@ -717,6 +723,33 @@ public class PhoneWindowManager implements WindowManagerPolicy { mHandler.removeCallbacks(mScreenshotRunnable); } + private void powerShortPress(long eventTime) { + if (mShortPressOnPowerBehavior < 0) { + mShortPressOnPowerBehavior = mContext.getResources().getInteger( + com.android.internal.R.integer.config_shortPressOnPowerBehavior); + } + + switch (mShortPressOnPowerBehavior) { + case SHORT_PRESS_POWER_NOTHING: + break; + case SHORT_PRESS_POWER_GO_TO_SLEEP: + mPowerManager.goToSleep(eventTime, + PowerManager.GO_TO_SLEEP_REASON_USER, 0); + break; + case SHORT_PRESS_POWER_REALLY_GO_TO_SLEEP: + mPowerManager.goToSleep(eventTime, + PowerManager.GO_TO_SLEEP_REASON_USER, + PowerManager.GO_TO_SLEEP_FLAG_NO_DOZE); + break; + case SHORT_PRESS_POWER_REALLY_GO_TO_SLEEP_AND_GO_HOME: + mPowerManager.goToSleep(eventTime, + PowerManager.GO_TO_SLEEP_REASON_USER, + PowerManager.GO_TO_SLEEP_FLAG_NO_DOZE); + launchHomeFromHotKey(); + break; + } + } + private final Runnable mPowerLongPress = new Runnable() { @Override public void run() { @@ -4009,7 +4042,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { mPowerKeyTriggered = false; cancelPendingScreenshotChordAction(); if (interceptPowerKeyUp(canceled || mPendingPowerKeyUpCanceled)) { - mPowerManager.goToSleep(event.getEventTime()); + powerShortPress(event.getEventTime()); isWakeKey = false; } mPendingPowerKeyUpCanceled = false; @@ -4864,7 +4897,9 @@ public class PhoneWindowManager implements WindowManagerPolicy { private void applyLidSwitchState() { if (mLidState == LID_CLOSED && mLidControlsSleep) { - mPowerManager.goToSleep(SystemClock.uptimeMillis()); + mPowerManager.goToSleep(SystemClock.uptimeMillis(), + PowerManager.GO_TO_SLEEP_REASON_USER, + PowerManager.GO_TO_SLEEP_FLAG_NO_DOZE); } } @@ -5337,9 +5372,10 @@ public class PhoneWindowManager implements WindowManagerPolicy { pw.print(mLidKeyboardAccessibility); pw.print(" mLidNavigationAccessibility="); pw.print(mLidNavigationAccessibility); pw.print(" mLidControlsSleep="); pw.println(mLidControlsSleep); - pw.print(prefix); pw.print("mLongPressOnPowerBehavior="); - pw.print(mLongPressOnPowerBehavior); - pw.print(" mHasSoftInput="); pw.println(mHasSoftInput); + pw.print(prefix); + pw.print("mShortPressOnPowerBehavior="); pw.print(mShortPressOnPowerBehavior); + pw.print(" mLongPressOnPowerBehavior="); pw.println(mLongPressOnPowerBehavior); + pw.print(prefix); pw.print("mHasSoftInput="); pw.println(mHasSoftInput); pw.print(prefix); pw.print("mScreenOnEarly="); pw.print(mScreenOnEarly); pw.print(" mScreenOnFully="); pw.print(mScreenOnFully); pw.print(" mOrientationSensorEnabled="); pw.println(mOrientationSensorEnabled); |