am 81c47fc2: am 86318d76: Merge "Option for going home when going to sleep for devices without physical button." into lmp-mr1-modular-dev
* commit '81c47fc23a0a15dddf37d96d28305e8b5e5ca2da':
Option for going home when going to sleep for devices without physical button.
diff --git a/services/core/java/com/android/server/policy/PhoneWindowManager.java b/services/core/java/com/android/server/policy/PhoneWindowManager.java
index cdd6c7f..76edee9 100644
--- a/services/core/java/com/android/server/policy/PhoneWindowManager.java
+++ b/services/core/java/com/android/server/policy/PhoneWindowManager.java
@@ -176,6 +176,9 @@
static final int DOUBLE_TAP_HOME_NOTHING = 0;
static final int DOUBLE_TAP_HOME_RECENT_SYSTEM_UI = 1;
+ static final int SHORT_PRESS_SLEEP_GO_TO_SLEEP = 0;
+ static final int SHORT_PRESS_SLEEP_GO_TO_SLEEP_AND_GO_HOME = 1;
+
static final int APPLICATION_MEDIA_SUBLAYER = -2;
static final int APPLICATION_MEDIA_OVERLAY_SUBLAYER = -1;
static final int APPLICATION_PANEL_SUBLAYER = 1;
@@ -371,6 +374,7 @@
int mLongPressOnPowerBehavior;
int mDoublePressOnPowerBehavior;
int mTriplePressOnPowerBehavior;
+ int mShortPressOnSleepBehavior;
boolean mAwake;
boolean mScreenOnEarly;
boolean mScreenOnFully;
@@ -1057,6 +1061,20 @@
}
}
+ private void sleepPress(KeyEvent event) {
+ switch (mShortPressOnSleepBehavior) {
+ case SHORT_PRESS_SLEEP_GO_TO_SLEEP:
+ mPowerManager.goToSleep(event.getEventTime(),
+ PowerManager.GO_TO_SLEEP_REASON_SLEEP_BUTTON, 0);
+ break;
+ case SHORT_PRESS_SLEEP_GO_TO_SLEEP_AND_GO_HOME:
+ launchHomeFromHotKey(false /* awakenDreams */);
+ mPowerManager.goToSleep(event.getEventTime(),
+ PowerManager.GO_TO_SLEEP_REASON_SLEEP_BUTTON, 0);
+ break;
+ }
+ }
+
private int getResolvedLongPressOnPowerBehavior() {
if (FactoryTest.isLongPressOnPowerOffEnabled()) {
return LONG_PRESS_POWER_SHUT_OFF_NO_CONFIRM;
@@ -1321,6 +1339,8 @@
com.android.internal.R.integer.config_doublePressOnPowerBehavior);
mTriplePressOnPowerBehavior = mContext.getResources().getInteger(
com.android.internal.R.integer.config_triplePressOnPowerBehavior);
+ mShortPressOnSleepBehavior = mContext.getResources().getInteger(
+ com.android.internal.R.integer.config_shortPressOnSleepBehavior);
mUseTvRouting = AudioSystem.getPlatformType(mContext) == AudioSystem.PLATFORM_TELEVISION;
@@ -3028,11 +3048,15 @@
}
}
+ void launchHomeFromHotKey() {
+ launchHomeFromHotKey(true /* awakenFromDreams */);
+ }
+
/**
* A home key -> launch home action was detected. Take the appropriate action
* given the situation with the keyguard.
*/
- void launchHomeFromHotKey() {
+ void launchHomeFromHotKey(final boolean awakenFromDreams) {
if (isKeyguardShowingAndNotOccluded()) {
// don't launch home if keyguard showing
} else if (!mHideLockScreen && mKeyguardDelegate.isInputRestricted()) {
@@ -3047,7 +3071,7 @@
} catch (RemoteException e) {
}
sendCloseSystemWindows(SYSTEM_DIALOG_REASON_HOME_KEY);
- startDockOrHome(true /*fromHomeKey*/);
+ startDockOrHome(true /*fromHomeKey*/, awakenFromDreams);
}
}
});
@@ -3059,13 +3083,15 @@
}
if (mRecentsVisible) {
// Hide Recents and notify it to launch Home
- awakenDreams();
+ if (awakenFromDreams) {
+ awakenDreams();
+ }
sendCloseSystemWindows(SYSTEM_DIALOG_REASON_HOME_KEY);
hideRecentApps(false, true);
} else {
// Otherwise, just launch Home
sendCloseSystemWindows(SYSTEM_DIALOG_REASON_HOME_KEY);
- startDockOrHome(true /*fromHomeKey*/);
+ startDockOrHome(true /*fromHomeKey*/, awakenFromDreams);
}
}
}
@@ -4712,12 +4738,11 @@
case KeyEvent.KEYCODE_SLEEP: {
result &= ~ACTION_PASS_TO_USER;
+ isWakeKey = false;
if (!mPowerManager.isInteractive()) {
useHapticFeedback = false; // suppress feedback if already non-interactive
}
- mPowerManager.goToSleep(event.getEventTime(),
- PowerManager.GO_TO_SLEEP_REASON_POWER_BUTTON, 0);
- isWakeKey = false;
+ sleepPress(event);
break;
}
@@ -5896,8 +5921,10 @@
return null;
}
- void startDockOrHome(boolean fromHomeKey) {
- awakenDreams();
+ void startDockOrHome(boolean fromHomeKey, boolean awakenFromDreams) {
+ if (awakenFromDreams) {
+ awakenDreams();
+ }
Intent dock = createHomeDockIntent();
if (dock != null) {
@@ -5935,7 +5962,7 @@
} catch (RemoteException e) {
}
sendCloseSystemWindows();
- startDockOrHome(false /*fromHomeKey*/);
+ startDockOrHome(false /*fromHomeKey*/, true /* awakenFromDreams */);
} else {
// This code brings home to the front or, if it is already
// at the front, puts the device to sleep.
diff --git a/services/core/java/com/android/server/power/PowerManagerService.java b/services/core/java/com/android/server/power/PowerManagerService.java
index 66c2f5f..9e373b7 100644
--- a/services/core/java/com/android/server/power/PowerManagerService.java
+++ b/services/core/java/com/android/server/power/PowerManagerService.java
@@ -1080,6 +1080,9 @@
case PowerManager.GO_TO_SLEEP_REASON_POWER_BUTTON:
Slog.i(TAG, "Going to sleep due to power button (uid " + uid +")...");
break;
+ case PowerManager.GO_TO_SLEEP_REASON_SLEEP_BUTTON:
+ Slog.i(TAG, "Going to sleep due to sleep button (uid " + uid +")...");
+ break;
case PowerManager.GO_TO_SLEEP_REASON_HDMI:
Slog.i(TAG, "Going to sleep due to HDMI standby (uid " + uid +")...");
break;