Merge "Option for going home when going to sleep for devices without physical button." into lmp-mr1-modular-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
86318d768a
@@ -363,6 +363,12 @@ public final class PowerManager {
|
|||||||
*/
|
*/
|
||||||
public static final int GO_TO_SLEEP_REASON_HDMI = 5;
|
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.
|
* Go to sleep flag: Skip dozing state and directly go to full sleep.
|
||||||
* @hide
|
* @hide
|
||||||
|
|||||||
@@ -671,6 +671,12 @@
|
|||||||
-->
|
-->
|
||||||
<integer name="config_triplePressOnPowerBehavior">0</integer>
|
<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] -->
|
<!-- Package name for default keyguard appwidget [DO NOT TRANSLATE] -->
|
||||||
<string name="widget_default_package_name"></string>
|
<string name="widget_default_package_name"></string>
|
||||||
|
|
||||||
|
|||||||
@@ -368,6 +368,7 @@
|
|||||||
<java-symbol type="integer" name="config_shortPressOnPowerBehavior" />
|
<java-symbol type="integer" name="config_shortPressOnPowerBehavior" />
|
||||||
<java-symbol type="integer" name="config_toastDefaultGravity" />
|
<java-symbol type="integer" name="config_toastDefaultGravity" />
|
||||||
<java-symbol type="integer" name="config_triplePressOnPowerBehavior" />
|
<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_framework_scan_interval" />
|
||||||
<java-symbol type="integer" name="config_wifi_supplicant_scan_interval" />
|
<java-symbol type="integer" name="config_wifi_supplicant_scan_interval" />
|
||||||
<java-symbol type="integer" name="config_wifi_scan_interval_p2p_connected" />
|
<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_NOTHING = 0;
|
||||||
static final int DOUBLE_TAP_HOME_RECENT_SYSTEM_UI = 1;
|
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_SUBLAYER = -2;
|
||||||
static final int APPLICATION_MEDIA_OVERLAY_SUBLAYER = -1;
|
static final int APPLICATION_MEDIA_OVERLAY_SUBLAYER = -1;
|
||||||
static final int APPLICATION_PANEL_SUBLAYER = 1;
|
static final int APPLICATION_PANEL_SUBLAYER = 1;
|
||||||
@@ -370,6 +373,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
|||||||
int mLongPressOnPowerBehavior;
|
int mLongPressOnPowerBehavior;
|
||||||
int mDoublePressOnPowerBehavior;
|
int mDoublePressOnPowerBehavior;
|
||||||
int mTriplePressOnPowerBehavior;
|
int mTriplePressOnPowerBehavior;
|
||||||
|
int mShortPressOnSleepBehavior;
|
||||||
boolean mAwake;
|
boolean mAwake;
|
||||||
boolean mScreenOnEarly;
|
boolean mScreenOnEarly;
|
||||||
boolean mScreenOnFully;
|
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() {
|
private int getResolvedLongPressOnPowerBehavior() {
|
||||||
if (FactoryTest.isLongPressOnPowerOffEnabled()) {
|
if (FactoryTest.isLongPressOnPowerOffEnabled()) {
|
||||||
return LONG_PRESS_POWER_SHUT_OFF_NO_CONFIRM;
|
return LONG_PRESS_POWER_SHUT_OFF_NO_CONFIRM;
|
||||||
@@ -1324,6 +1342,8 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
|||||||
com.android.internal.R.integer.config_doublePressOnPowerBehavior);
|
com.android.internal.R.integer.config_doublePressOnPowerBehavior);
|
||||||
mTriplePressOnPowerBehavior = mContext.getResources().getInteger(
|
mTriplePressOnPowerBehavior = mContext.getResources().getInteger(
|
||||||
com.android.internal.R.integer.config_triplePressOnPowerBehavior);
|
com.android.internal.R.integer.config_triplePressOnPowerBehavior);
|
||||||
|
mShortPressOnSleepBehavior = mContext.getResources().getInteger(
|
||||||
|
com.android.internal.R.integer.config_shortPressOnSleepBehavior);
|
||||||
|
|
||||||
readConfigurationDependentBehaviors();
|
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
|
* A home key -> launch home action was detected. Take the appropriate action
|
||||||
* given the situation with the keyguard.
|
* given the situation with the keyguard.
|
||||||
*/
|
*/
|
||||||
void launchHomeFromHotKey() {
|
void launchHomeFromHotKey(final boolean awakenFromDreams) {
|
||||||
if (isKeyguardShowingAndNotOccluded()) {
|
if (isKeyguardShowingAndNotOccluded()) {
|
||||||
// don't launch home if keyguard showing
|
// don't launch home if keyguard showing
|
||||||
} else if (!mHideLockScreen && mKeyguardDelegate.isInputRestricted()) {
|
} else if (!mHideLockScreen && mKeyguardDelegate.isInputRestricted()) {
|
||||||
@@ -3054,7 +3078,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
|||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
}
|
}
|
||||||
sendCloseSystemWindows(SYSTEM_DIALOG_REASON_HOME_KEY);
|
sendCloseSystemWindows(SYSTEM_DIALOG_REASON_HOME_KEY);
|
||||||
startDockOrHome(true /*fromHomeKey*/);
|
startDockOrHome(true /*fromHomeKey*/, awakenFromDreams);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -3066,13 +3090,15 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
|||||||
}
|
}
|
||||||
if (mRecentsVisible) {
|
if (mRecentsVisible) {
|
||||||
// Hide Recents and notify it to launch Home
|
// Hide Recents and notify it to launch Home
|
||||||
awakenDreams();
|
if (awakenFromDreams) {
|
||||||
|
awakenDreams();
|
||||||
|
}
|
||||||
sendCloseSystemWindows(SYSTEM_DIALOG_REASON_HOME_KEY);
|
sendCloseSystemWindows(SYSTEM_DIALOG_REASON_HOME_KEY);
|
||||||
hideRecentApps(false, true);
|
hideRecentApps(false, true);
|
||||||
} else {
|
} else {
|
||||||
// Otherwise, just launch Home
|
// Otherwise, just launch Home
|
||||||
sendCloseSystemWindows(SYSTEM_DIALOG_REASON_HOME_KEY);
|
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: {
|
case KeyEvent.KEYCODE_SLEEP: {
|
||||||
result &= ~ACTION_PASS_TO_USER;
|
result &= ~ACTION_PASS_TO_USER;
|
||||||
|
isWakeKey = false;
|
||||||
if (!mPowerManager.isInteractive()) {
|
if (!mPowerManager.isInteractive()) {
|
||||||
useHapticFeedback = false; // suppress feedback if already non-interactive
|
useHapticFeedback = false; // suppress feedback if already non-interactive
|
||||||
}
|
}
|
||||||
mPowerManager.goToSleep(event.getEventTime(),
|
sleepPress(event);
|
||||||
PowerManager.GO_TO_SLEEP_REASON_POWER_BUTTON, 0);
|
|
||||||
isWakeKey = false;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -5884,8 +5909,10 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
void startDockOrHome(boolean fromHomeKey) {
|
void startDockOrHome(boolean fromHomeKey, boolean awakenFromDreams) {
|
||||||
awakenDreams();
|
if (awakenFromDreams) {
|
||||||
|
awakenDreams();
|
||||||
|
}
|
||||||
|
|
||||||
Intent dock = createHomeDockIntent();
|
Intent dock = createHomeDockIntent();
|
||||||
if (dock != null) {
|
if (dock != null) {
|
||||||
@@ -5923,7 +5950,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
|||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
}
|
}
|
||||||
sendCloseSystemWindows();
|
sendCloseSystemWindows();
|
||||||
startDockOrHome(false /*fromHomeKey*/);
|
startDockOrHome(false /*fromHomeKey*/, true /* awakenFromDreams */);
|
||||||
} else {
|
} else {
|
||||||
// This code brings home to the front or, if it is already
|
// This code brings home to the front or, if it is already
|
||||||
// at the front, puts the device to sleep.
|
// 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:
|
case PowerManager.GO_TO_SLEEP_REASON_POWER_BUTTON:
|
||||||
Slog.i(TAG, "Going to sleep due to power button (uid " + uid +")...");
|
Slog.i(TAG, "Going to sleep due to power button (uid " + uid +")...");
|
||||||
break;
|
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:
|
case PowerManager.GO_TO_SLEEP_REASON_HDMI:
|
||||||
Slog.i(TAG, "Going to sleep due to HDMI standby (uid " + uid +")...");
|
Slog.i(TAG, "Going to sleep due to HDMI standby (uid " + uid +")...");
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user