am 6fb904bf: Merge "Make power button behavior configurable." into klp-modular-dev
* commit '6fb904bfd1f943547d6e5bc6f199ffec2290da01': Make power button behavior configurable.
This commit is contained in:
@@ -35,7 +35,7 @@ interface IPowerManager
|
|||||||
|
|
||||||
void userActivity(long time, int event, int flags);
|
void userActivity(long time, int event, int flags);
|
||||||
void wakeUp(long time);
|
void wakeUp(long time);
|
||||||
void goToSleep(long time, int reason);
|
void goToSleep(long time, int reason, int flags);
|
||||||
void nap(long time);
|
void nap(long time);
|
||||||
boolean isInteractive();
|
boolean isInteractive();
|
||||||
|
|
||||||
|
|||||||
@@ -302,6 +302,12 @@ public final class PowerManager {
|
|||||||
*/
|
*/
|
||||||
public static final int GO_TO_SLEEP_REASON_TIMEOUT = 2;
|
public static final int GO_TO_SLEEP_REASON_TIMEOUT = 2;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Go to sleep flag: Skip dozing state and directly go to full sleep.
|
||||||
|
* @hide
|
||||||
|
*/
|
||||||
|
public static final int GO_TO_SLEEP_FLAG_NO_DOZE = 1 << 0;
|
||||||
|
|
||||||
final Context mContext;
|
final Context mContext;
|
||||||
final IPowerManager mService;
|
final IPowerManager mService;
|
||||||
final Handler mHandler;
|
final Handler mHandler;
|
||||||
@@ -490,8 +496,15 @@ public final class PowerManager {
|
|||||||
* @see #wakeUp
|
* @see #wakeUp
|
||||||
*/
|
*/
|
||||||
public void goToSleep(long time) {
|
public void goToSleep(long time) {
|
||||||
|
goToSleep(time, GO_TO_SLEEP_REASON_USER, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @hide
|
||||||
|
*/
|
||||||
|
public void goToSleep(long time, int reason, int flags) {
|
||||||
try {
|
try {
|
||||||
mService.goToSleep(time, GO_TO_SLEEP_REASON_USER);
|
mService.goToSleep(time, reason, flags);
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -485,6 +485,14 @@
|
|||||||
-->
|
-->
|
||||||
<integer name="config_longPressOnPowerBehavior">1</integer>
|
<integer name="config_longPressOnPowerBehavior">1</integer>
|
||||||
|
|
||||||
|
<!-- Control the behavior when the user short presses the power button.
|
||||||
|
0 - Nothing
|
||||||
|
1 - Go to sleep (doze)
|
||||||
|
2 - Really go to sleep (don't doze)
|
||||||
|
3 - Really go to sleep and go home (don't doze)
|
||||||
|
-->
|
||||||
|
<integer name="config_shortPressOnPowerBehavior">1</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>
|
||||||
|
|
||||||
|
|||||||
@@ -304,6 +304,7 @@
|
|||||||
<java-symbol type="integer" name="config_ntpRetry" />
|
<java-symbol type="integer" name="config_ntpRetry" />
|
||||||
<java-symbol type="integer" name="config_ntpThreshold" />
|
<java-symbol type="integer" name="config_ntpThreshold" />
|
||||||
<java-symbol type="integer" name="config_ntpTimeout" />
|
<java-symbol type="integer" name="config_ntpTimeout" />
|
||||||
|
<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_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" />
|
||||||
|
|||||||
@@ -134,6 +134,11 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
|||||||
static final boolean ENABLE_CAR_DOCK_HOME_CAPTURE = true;
|
static final boolean ENABLE_CAR_DOCK_HOME_CAPTURE = true;
|
||||||
static final boolean ENABLE_DESK_DOCK_HOME_CAPTURE = false;
|
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_NOTHING = 0;
|
||||||
static final int LONG_PRESS_POWER_GLOBAL_ACTIONS = 1;
|
static final int LONG_PRESS_POWER_GLOBAL_ACTIONS = 1;
|
||||||
static final int LONG_PRESS_POWER_SHUT_OFF = 2;
|
static final int LONG_PRESS_POWER_SHUT_OFF = 2;
|
||||||
@@ -291,6 +296,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
|||||||
int mLidKeyboardAccessibility;
|
int mLidKeyboardAccessibility;
|
||||||
int mLidNavigationAccessibility;
|
int mLidNavigationAccessibility;
|
||||||
boolean mLidControlsSleep;
|
boolean mLidControlsSleep;
|
||||||
|
int mShortPressOnPowerBehavior = -1;
|
||||||
int mLongPressOnPowerBehavior = -1;
|
int mLongPressOnPowerBehavior = -1;
|
||||||
boolean mScreenOnEarly = false;
|
boolean mScreenOnEarly = false;
|
||||||
boolean mScreenOnFully = false;
|
boolean mScreenOnFully = false;
|
||||||
@@ -717,6 +723,33 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
|||||||
mHandler.removeCallbacks(mScreenshotRunnable);
|
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() {
|
private final Runnable mPowerLongPress = new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
@@ -4009,7 +4042,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
|||||||
mPowerKeyTriggered = false;
|
mPowerKeyTriggered = false;
|
||||||
cancelPendingScreenshotChordAction();
|
cancelPendingScreenshotChordAction();
|
||||||
if (interceptPowerKeyUp(canceled || mPendingPowerKeyUpCanceled)) {
|
if (interceptPowerKeyUp(canceled || mPendingPowerKeyUpCanceled)) {
|
||||||
mPowerManager.goToSleep(event.getEventTime());
|
powerShortPress(event.getEventTime());
|
||||||
isWakeKey = false;
|
isWakeKey = false;
|
||||||
}
|
}
|
||||||
mPendingPowerKeyUpCanceled = false;
|
mPendingPowerKeyUpCanceled = false;
|
||||||
@@ -4864,7 +4897,9 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
|||||||
|
|
||||||
private void applyLidSwitchState() {
|
private void applyLidSwitchState() {
|
||||||
if (mLidState == LID_CLOSED && mLidControlsSleep) {
|
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(mLidKeyboardAccessibility);
|
||||||
pw.print(" mLidNavigationAccessibility="); pw.print(mLidNavigationAccessibility);
|
pw.print(" mLidNavigationAccessibility="); pw.print(mLidNavigationAccessibility);
|
||||||
pw.print(" mLidControlsSleep="); pw.println(mLidControlsSleep);
|
pw.print(" mLidControlsSleep="); pw.println(mLidControlsSleep);
|
||||||
pw.print(prefix); pw.print("mLongPressOnPowerBehavior=");
|
pw.print(prefix);
|
||||||
pw.print(mLongPressOnPowerBehavior);
|
pw.print("mShortPressOnPowerBehavior="); pw.print(mShortPressOnPowerBehavior);
|
||||||
pw.print(" mHasSoftInput="); pw.println(mHasSoftInput);
|
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(prefix); pw.print("mScreenOnEarly="); pw.print(mScreenOnEarly);
|
||||||
pw.print(" mScreenOnFully="); pw.print(mScreenOnFully);
|
pw.print(" mScreenOnFully="); pw.print(mScreenOnFully);
|
||||||
pw.print(" mOrientationSensorEnabled="); pw.println(mOrientationSensorEnabled);
|
pw.print(" mOrientationSensorEnabled="); pw.println(mOrientationSensorEnabled);
|
||||||
|
|||||||
@@ -898,9 +898,9 @@ public final class PowerManagerService extends com.android.server.SystemService
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void goToSleepInternal(long eventTime, int reason) {
|
private void goToSleepInternal(long eventTime, int reason, int flags) {
|
||||||
synchronized (mLock) {
|
synchronized (mLock) {
|
||||||
if (goToSleepNoUpdateLocked(eventTime, reason)) {
|
if (goToSleepNoUpdateLocked(eventTime, reason, flags)) {
|
||||||
updatePowerStateLocked();
|
updatePowerStateLocked();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -909,9 +909,10 @@ public final class PowerManagerService extends com.android.server.SystemService
|
|||||||
// This method is called goToSleep for historical reasons but we actually start
|
// This method is called goToSleep for historical reasons but we actually start
|
||||||
// dozing before really going to sleep.
|
// dozing before really going to sleep.
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
private boolean goToSleepNoUpdateLocked(long eventTime, int reason) {
|
private boolean goToSleepNoUpdateLocked(long eventTime, int reason, int flags) {
|
||||||
if (DEBUG_SPEW) {
|
if (DEBUG_SPEW) {
|
||||||
Slog.d(TAG, "goToSleepNoUpdateLocked: eventTime=" + eventTime + ", reason=" + reason);
|
Slog.d(TAG, "goToSleepNoUpdateLocked: eventTime=" + eventTime
|
||||||
|
+ ", reason=" + reason + ", flags=" + flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (eventTime < mLastWakeTime
|
if (eventTime < mLastWakeTime
|
||||||
@@ -954,6 +955,11 @@ public final class PowerManagerService extends com.android.server.SystemService
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
EventLog.writeEvent(EventLogTags.POWER_SLEEP_REQUESTED, numWakeLocksCleared);
|
EventLog.writeEvent(EventLogTags.POWER_SLEEP_REQUESTED, numWakeLocksCleared);
|
||||||
|
|
||||||
|
// Skip dozing if requested.
|
||||||
|
if ((flags & PowerManager.GO_TO_SLEEP_FLAG_NO_DOZE) != 0) {
|
||||||
|
reallyGoToSleepNoUpdateLocked(eventTime);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1357,7 +1363,7 @@ public final class PowerManagerService extends com.android.server.SystemService
|
|||||||
changed = napNoUpdateLocked(time);
|
changed = napNoUpdateLocked(time);
|
||||||
} else {
|
} else {
|
||||||
changed = goToSleepNoUpdateLocked(time,
|
changed = goToSleepNoUpdateLocked(time,
|
||||||
PowerManager.GO_TO_SLEEP_REASON_TIMEOUT);
|
PowerManager.GO_TO_SLEEP_REASON_TIMEOUT, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1504,7 +1510,7 @@ public final class PowerManagerService extends com.android.server.SystemService
|
|||||||
// Dream has ended or will be stopped. Update the power state.
|
// Dream has ended or will be stopped. Update the power state.
|
||||||
if (isItBedTimeYetLocked()) {
|
if (isItBedTimeYetLocked()) {
|
||||||
goToSleepNoUpdateLocked(SystemClock.uptimeMillis(),
|
goToSleepNoUpdateLocked(SystemClock.uptimeMillis(),
|
||||||
PowerManager.GO_TO_SLEEP_REASON_TIMEOUT);
|
PowerManager.GO_TO_SLEEP_REASON_TIMEOUT, 0);
|
||||||
updatePowerStateLocked();
|
updatePowerStateLocked();
|
||||||
} else {
|
} else {
|
||||||
wakeUpNoUpdateLocked(SystemClock.uptimeMillis());
|
wakeUpNoUpdateLocked(SystemClock.uptimeMillis());
|
||||||
@@ -2630,7 +2636,7 @@ public final class PowerManagerService extends com.android.server.SystemService
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override // Binder call
|
@Override // Binder call
|
||||||
public void goToSleep(long eventTime, int reason) {
|
public void goToSleep(long eventTime, int reason, int flags) {
|
||||||
if (eventTime > SystemClock.uptimeMillis()) {
|
if (eventTime > SystemClock.uptimeMillis()) {
|
||||||
throw new IllegalArgumentException("event time must not be in the future");
|
throw new IllegalArgumentException("event time must not be in the future");
|
||||||
}
|
}
|
||||||
@@ -2640,7 +2646,7 @@ public final class PowerManagerService extends com.android.server.SystemService
|
|||||||
|
|
||||||
final long ident = Binder.clearCallingIdentity();
|
final long ident = Binder.clearCallingIdentity();
|
||||||
try {
|
try {
|
||||||
goToSleepInternal(eventTime, reason);
|
goToSleepInternal(eventTime, reason, flags);
|
||||||
} finally {
|
} finally {
|
||||||
Binder.restoreCallingIdentity(ident);
|
Binder.restoreCallingIdentity(ident);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2119,7 +2119,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
|
|||||||
try {
|
try {
|
||||||
// Power off the display
|
// Power off the display
|
||||||
getIPowerManager().goToSleep(SystemClock.uptimeMillis(),
|
getIPowerManager().goToSleep(SystemClock.uptimeMillis(),
|
||||||
PowerManager.GO_TO_SLEEP_REASON_DEVICE_ADMIN);
|
PowerManager.GO_TO_SLEEP_REASON_DEVICE_ADMIN, 0);
|
||||||
// Ensure the device is locked
|
// Ensure the device is locked
|
||||||
getWindowManager().lockNow(null);
|
getWindowManager().lockNow(null);
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
|
|||||||
Reference in New Issue
Block a user