Merge "Add system wide long-press back button functionality" into nyc-dev
am: 526cb5a26a
* commit '526cb5a26ab76c7bafe6df32c5c0d93e7518d1c6':
Add system wide long-press back button functionality
This commit is contained in:
@@ -805,6 +805,13 @@
|
|||||||
-->
|
-->
|
||||||
<integer name="config_longPressOnPowerBehavior">1</integer>
|
<integer name="config_longPressOnPowerBehavior">1</integer>
|
||||||
|
|
||||||
|
<!-- Control the behavior when the user long presses the back button. Non-zero values are only
|
||||||
|
valid for watches as part of CDD/CTS.
|
||||||
|
0 - Nothing
|
||||||
|
1 - Go to voice assist
|
||||||
|
-->
|
||||||
|
<integer name="config_longPressOnBackBehavior">0</integer>
|
||||||
|
|
||||||
<!-- Control the behavior when the user short presses the power button.
|
<!-- Control the behavior when the user short presses the power button.
|
||||||
0 - Nothing
|
0 - Nothing
|
||||||
1 - Go to sleep (doze)
|
1 - Go to sleep (doze)
|
||||||
|
|||||||
@@ -382,6 +382,7 @@
|
|||||||
<java-symbol type="integer" name="config_extraFreeKbytesAbsolute" />
|
<java-symbol type="integer" name="config_extraFreeKbytesAbsolute" />
|
||||||
<java-symbol type="integer" name="config_immersive_mode_confirmation_panic" />
|
<java-symbol type="integer" name="config_immersive_mode_confirmation_panic" />
|
||||||
<java-symbol type="integer" name="config_longPressOnPowerBehavior" />
|
<java-symbol type="integer" name="config_longPressOnPowerBehavior" />
|
||||||
|
<java-symbol type="integer" name="config_longPressOnBackBehavior" />
|
||||||
<java-symbol type="integer" name="config_lowMemoryKillerMinFreeKbytesAdjust" />
|
<java-symbol type="integer" name="config_lowMemoryKillerMinFreeKbytesAdjust" />
|
||||||
<java-symbol type="integer" name="config_lowMemoryKillerMinFreeKbytesAbsolute" />
|
<java-symbol type="integer" name="config_lowMemoryKillerMinFreeKbytesAbsolute" />
|
||||||
<java-symbol type="integer" name="config_max_pan_devices" />
|
<java-symbol type="integer" name="config_max_pan_devices" />
|
||||||
|
|||||||
@@ -191,6 +191,9 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
|||||||
static final int LONG_PRESS_POWER_SHUT_OFF = 2;
|
static final int LONG_PRESS_POWER_SHUT_OFF = 2;
|
||||||
static final int LONG_PRESS_POWER_SHUT_OFF_NO_CONFIRM = 3;
|
static final int LONG_PRESS_POWER_SHUT_OFF_NO_CONFIRM = 3;
|
||||||
|
|
||||||
|
static final int LONG_PRESS_BACK_NOTHING = 0;
|
||||||
|
static final int LONG_PRESS_BACK_GO_TO_VOICE_ASSIST = 1;
|
||||||
|
|
||||||
static final int MULTI_PRESS_POWER_NOTHING = 0;
|
static final int MULTI_PRESS_POWER_NOTHING = 0;
|
||||||
static final int MULTI_PRESS_POWER_THEATER_MODE = 1;
|
static final int MULTI_PRESS_POWER_THEATER_MODE = 1;
|
||||||
static final int MULTI_PRESS_POWER_BRIGHTNESS_BOOST = 2;
|
static final int MULTI_PRESS_POWER_BRIGHTNESS_BOOST = 2;
|
||||||
@@ -391,6 +394,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
|||||||
// handler thread. We'll need to resolve this someday by teaching the input dispatcher
|
// handler thread. We'll need to resolve this someday by teaching the input dispatcher
|
||||||
// to hold wakelocks during dispatch and eliminating the critical path.
|
// to hold wakelocks during dispatch and eliminating the critical path.
|
||||||
volatile boolean mPowerKeyHandled;
|
volatile boolean mPowerKeyHandled;
|
||||||
|
volatile boolean mBackKeyHandled;
|
||||||
volatile boolean mBeganFromNonInteractive;
|
volatile boolean mBeganFromNonInteractive;
|
||||||
volatile int mPowerKeyPressCounter;
|
volatile int mPowerKeyPressCounter;
|
||||||
volatile boolean mEndCallKeyHandled;
|
volatile boolean mEndCallKeyHandled;
|
||||||
@@ -443,6 +447,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
|||||||
int mLongPressOnPowerBehavior;
|
int mLongPressOnPowerBehavior;
|
||||||
int mDoublePressOnPowerBehavior;
|
int mDoublePressOnPowerBehavior;
|
||||||
int mTriplePressOnPowerBehavior;
|
int mTriplePressOnPowerBehavior;
|
||||||
|
int mLongPressOnBackBehavior;
|
||||||
int mShortPressOnSleepBehavior;
|
int mShortPressOnSleepBehavior;
|
||||||
int mShortPressWindowBehavior;
|
int mShortPressWindowBehavior;
|
||||||
boolean mAwake;
|
boolean mAwake;
|
||||||
@@ -699,6 +704,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
|||||||
private static final int MSG_UPDATE_DREAMING_SLEEP_TOKEN = 15;
|
private static final int MSG_UPDATE_DREAMING_SLEEP_TOKEN = 15;
|
||||||
private static final int MSG_REQUEST_TRANSIENT_BARS = 16;
|
private static final int MSG_REQUEST_TRANSIENT_BARS = 16;
|
||||||
private static final int MSG_REQUEST_TV_PICTURE_IN_PICTURE = 17;
|
private static final int MSG_REQUEST_TV_PICTURE_IN_PICTURE = 17;
|
||||||
|
private static final int MSG_BACK_LONG_PRESS = 18;
|
||||||
|
|
||||||
private static final int MSG_REQUEST_TRANSIENT_BARS_ARG_STATUS = 0;
|
private static final int MSG_REQUEST_TRANSIENT_BARS_ARG_STATUS = 0;
|
||||||
private static final int MSG_REQUEST_TRANSIENT_BARS_ARG_NAVIGATION = 1;
|
private static final int MSG_REQUEST_TRANSIENT_BARS_ARG_NAVIGATION = 1;
|
||||||
@@ -763,6 +769,9 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
|||||||
case MSG_REQUEST_TV_PICTURE_IN_PICTURE:
|
case MSG_REQUEST_TV_PICTURE_IN_PICTURE:
|
||||||
requestTvPictureInPictureInternal();
|
requestTvPictureInPictureInternal();
|
||||||
break;
|
break;
|
||||||
|
case MSG_BACK_LONG_PRESS:
|
||||||
|
backLongPress();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1109,6 +1118,13 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void cancelPendingBackKeyAction() {
|
||||||
|
if (!mBackKeyHandled) {
|
||||||
|
mBackKeyHandled = true;
|
||||||
|
mHandler.removeMessages(MSG_BACK_LONG_PRESS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void powerPress(long eventTime, boolean interactive, int count) {
|
private void powerPress(long eventTime, boolean interactive, int count) {
|
||||||
if (mScreenOnEarly && !mScreenOnFully) {
|
if (mScreenOnEarly && !mScreenOnFully) {
|
||||||
Slog.i(TAG, "Suppressed redundant power key press while "
|
Slog.i(TAG, "Suppressed redundant power key press while "
|
||||||
@@ -1216,6 +1232,19 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void backLongPress() {
|
||||||
|
mBackKeyHandled = true;
|
||||||
|
|
||||||
|
switch (mLongPressOnBackBehavior) {
|
||||||
|
case LONG_PRESS_BACK_NOTHING:
|
||||||
|
break;
|
||||||
|
case LONG_PRESS_BACK_GO_TO_VOICE_ASSIST:
|
||||||
|
Intent intent = new Intent(Intent.ACTION_VOICE_ASSIST);
|
||||||
|
startActivityAsUser(intent, UserHandle.CURRENT_OR_SELF);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void sleepPress(long eventTime) {
|
private void sleepPress(long eventTime) {
|
||||||
if (mShortPressOnSleepBehavior == SHORT_PRESS_SLEEP_GO_TO_SLEEP_AND_GO_HOME) {
|
if (mShortPressOnSleepBehavior == SHORT_PRESS_SLEEP_GO_TO_SLEEP_AND_GO_HOME) {
|
||||||
launchHomeFromHotKey(false /* awakenDreams */, true /*respectKeyguard*/);
|
launchHomeFromHotKey(false /* awakenDreams */, true /*respectKeyguard*/);
|
||||||
@@ -1244,6 +1273,10 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
|||||||
return getResolvedLongPressOnPowerBehavior() != LONG_PRESS_POWER_NOTHING;
|
return getResolvedLongPressOnPowerBehavior() != LONG_PRESS_POWER_NOTHING;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean hasLongPressOnBackBehavior() {
|
||||||
|
return mLongPressOnBackBehavior != LONG_PRESS_BACK_NOTHING;
|
||||||
|
}
|
||||||
|
|
||||||
private void interceptScreenshotChord() {
|
private void interceptScreenshotChord() {
|
||||||
if (mScreenshotChordEnabled
|
if (mScreenshotChordEnabled
|
||||||
&& mScreenshotChordVolumeDownKeyTriggered && mScreenshotChordPowerKeyTriggered
|
&& mScreenshotChordVolumeDownKeyTriggered && mScreenshotChordPowerKeyTriggered
|
||||||
@@ -1573,6 +1606,9 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
|||||||
mSupportLongPressPowerWhenNonInteractive = mContext.getResources().getBoolean(
|
mSupportLongPressPowerWhenNonInteractive = mContext.getResources().getBoolean(
|
||||||
com.android.internal.R.bool.config_supportLongPressPowerWhenNonInteractive);
|
com.android.internal.R.bool.config_supportLongPressPowerWhenNonInteractive);
|
||||||
|
|
||||||
|
mLongPressOnBackBehavior = mContext.getResources().getInteger(
|
||||||
|
com.android.internal.R.integer.config_longPressOnBackBehavior);
|
||||||
|
|
||||||
mShortPressOnPowerBehavior = mContext.getResources().getInteger(
|
mShortPressOnPowerBehavior = mContext.getResources().getInteger(
|
||||||
com.android.internal.R.integer.config_shortPressOnPowerBehavior);
|
com.android.internal.R.integer.config_shortPressOnPowerBehavior);
|
||||||
mLongPressOnPowerBehavior = mContext.getResources().getInteger(
|
mLongPressOnPowerBehavior = mContext.getResources().getInteger(
|
||||||
@@ -5341,6 +5377,29 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
|||||||
|
|
||||||
// Handle special keys.
|
// Handle special keys.
|
||||||
switch (keyCode) {
|
switch (keyCode) {
|
||||||
|
case KeyEvent.KEYCODE_BACK: {
|
||||||
|
if (down) {
|
||||||
|
mBackKeyHandled = false;
|
||||||
|
if (hasLongPressOnBackBehavior()) {
|
||||||
|
Message msg = mHandler.obtainMessage(MSG_BACK_LONG_PRESS);
|
||||||
|
msg.setAsynchronous(true);
|
||||||
|
mHandler.sendMessageDelayed(msg,
|
||||||
|
ViewConfiguration.get(mContext).getDeviceGlobalActionKeyTimeout());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
boolean handled = mBackKeyHandled;
|
||||||
|
|
||||||
|
// Reset back key state
|
||||||
|
cancelPendingBackKeyAction();
|
||||||
|
|
||||||
|
// Don't pass back press to app if we've already handled it
|
||||||
|
if (handled) {
|
||||||
|
result &= ~ACTION_PASS_TO_USER;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case KeyEvent.KEYCODE_VOLUME_DOWN:
|
case KeyEvent.KEYCODE_VOLUME_DOWN:
|
||||||
case KeyEvent.KEYCODE_VOLUME_UP:
|
case KeyEvent.KEYCODE_VOLUME_UP:
|
||||||
case KeyEvent.KEYCODE_VOLUME_MUTE: {
|
case KeyEvent.KEYCODE_VOLUME_MUTE: {
|
||||||
@@ -7389,6 +7448,8 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
|||||||
pw.print(" mLidNavigationAccessibility="); pw.print(mLidNavigationAccessibility);
|
pw.print(" mLidNavigationAccessibility="); pw.print(mLidNavigationAccessibility);
|
||||||
pw.print(" mLidControlsScreenLock="); pw.println(mLidControlsScreenLock);
|
pw.print(" mLidControlsScreenLock="); pw.println(mLidControlsScreenLock);
|
||||||
pw.print(" mLidControlsSleep="); pw.println(mLidControlsSleep);
|
pw.print(" mLidControlsSleep="); pw.println(mLidControlsSleep);
|
||||||
|
pw.print(prefix);
|
||||||
|
pw.print(" mLongPressOnBackBehavior="); pw.println(mLongPressOnBackBehavior);
|
||||||
pw.print(prefix);
|
pw.print(prefix);
|
||||||
pw.print("mShortPressOnPowerBehavior="); pw.print(mShortPressOnPowerBehavior);
|
pw.print("mShortPressOnPowerBehavior="); pw.print(mShortPressOnPowerBehavior);
|
||||||
pw.print(" mLongPressOnPowerBehavior="); pw.println(mLongPressOnPowerBehavior);
|
pw.print(" mLongPressOnPowerBehavior="); pw.println(mLongPressOnPowerBehavior);
|
||||||
|
|||||||
Reference in New Issue
Block a user