am 86318d76: Merge "Option for going home when going to sleep for devices without physical button." into lmp-mr1-modular-dev
* commit '86318d768a2c5043e1261e9daacf1497d1e4a732': Option for going home when going to sleep for devices without physical button.
This commit is contained in:
@@ -363,6 +363,12 @@ public final class PowerManager {
|
||||
*/
|
||||
public static final int GO_TO_SLEEP_REASON_HDMI = 5;
|
||||
|
||||
/**
|
||||
* Go to sleep reason code: Going to sleep due to the sleep button being pressed.
|
||||
* @hide
|
||||
*/
|
||||
public static final int GO_TO_SLEEP_REASON_SLEEP_BUTTON = 6;
|
||||
|
||||
/**
|
||||
* Go to sleep flag: Skip dozing state and directly go to full sleep.
|
||||
* @hide
|
||||
|
||||
@@ -671,6 +671,12 @@
|
||||
-->
|
||||
<integer name="config_triplePressOnPowerBehavior">0</integer>
|
||||
|
||||
<!-- Control the behavior when the user presses the sleep button.
|
||||
0 - Go to sleep (doze)
|
||||
1 - Go to sleep (doze) and go home
|
||||
-->
|
||||
<integer name="config_shortPressOnSleepBehavior">0</integer>
|
||||
|
||||
<!-- Package name for default keyguard appwidget [DO NOT TRANSLATE] -->
|
||||
<string name="widget_default_package_name" translatable="false"></string>
|
||||
|
||||
|
||||
@@ -368,6 +368,7 @@
|
||||
<java-symbol type="integer" name="config_shortPressOnPowerBehavior" />
|
||||
<java-symbol type="integer" name="config_toastDefaultGravity" />
|
||||
<java-symbol type="integer" name="config_triplePressOnPowerBehavior" />
|
||||
<java-symbol type="integer" name="config_shortPressOnSleepBehavior" />
|
||||
<java-symbol type="integer" name="config_wifi_framework_scan_interval" />
|
||||
<java-symbol type="integer" name="config_wifi_supplicant_scan_interval" />
|
||||
<java-symbol type="integer" name="config_wifi_scan_interval_p2p_connected" />
|
||||
|
||||
@@ -175,6 +175,9 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
||||
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;
|
||||
@@ -370,6 +373,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
||||
int mLongPressOnPowerBehavior;
|
||||
int mDoublePressOnPowerBehavior;
|
||||
int mTriplePressOnPowerBehavior;
|
||||
int mShortPressOnSleepBehavior;
|
||||
boolean mAwake;
|
||||
boolean mScreenOnEarly;
|
||||
boolean mScreenOnFully;
|
||||
@@ -1059,6 +1063,20 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
@@ -1324,6 +1342,8 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
||||
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);
|
||||
|
||||
readConfigurationDependentBehaviors();
|
||||
|
||||
@@ -3035,11 +3055,15 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
||||
}
|
||||
}
|
||||
|
||||
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()) {
|
||||
@@ -3054,7 +3078,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
||||
} catch (RemoteException e) {
|
||||
}
|
||||
sendCloseSystemWindows(SYSTEM_DIALOG_REASON_HOME_KEY);
|
||||
startDockOrHome(true /*fromHomeKey*/);
|
||||
startDockOrHome(true /*fromHomeKey*/, awakenFromDreams);
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -3066,13 +3090,15 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4729,12 +4755,11 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -5885,8 +5910,10 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
||||
return null;
|
||||
}
|
||||
|
||||
void startDockOrHome(boolean fromHomeKey) {
|
||||
awakenDreams();
|
||||
void startDockOrHome(boolean fromHomeKey, boolean awakenFromDreams) {
|
||||
if (awakenFromDreams) {
|
||||
awakenDreams();
|
||||
}
|
||||
|
||||
Intent dock = createHomeDockIntent();
|
||||
if (dock != null) {
|
||||
@@ -5924,7 +5951,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
||||
} 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.
|
||||
|
||||
@@ -1080,6 +1080,9 @@ public final class PowerManagerService extends SystemService
|
||||
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;
|
||||
|
||||
Reference in New Issue
Block a user