Skip to content

Commit

Permalink
Revert "Add panic detection to back button"
Browse files Browse the repository at this point in the history
This reverts commit 96e9cc5.

The feature was added for Android Wear, however it never got used.
This change reverts the change that added this feature. CTS test for it
has been removed in ag/3340085.

Bug: 62069912

Change-Id: I4f2aa580ebb5fdff236df76eb89d9cef640c1e32
  • Loading branch information
Erik Wolsheimer authored and liutikas committed Dec 12, 2017
1 parent 0ff7a64 commit bb97879
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 88 deletions.
6 changes: 0 additions & 6 deletions core/res/res/values/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -963,12 +963,6 @@
-->
<integer name="config_longPressOnBackBehavior">0</integer>

<!-- Control the behavior when the user panic presses the back button.
0 - Nothing
1 - Go to home
-->
<integer name="config_backPanicBehavior">0</integer>

<!-- Control the behavior when the user short presses the power button.
0 - Nothing
1 - Go to sleep (doze)
Expand Down
1 change: 0 additions & 1 deletion core/res/res/values/symbols.xml
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,6 @@
<java-symbol type="integer" name="config_veryLongPressOnPowerBehavior" />
<java-symbol type="integer" name="config_veryLongPressTimeout" />
<java-symbol type="integer" name="config_longPressOnBackBehavior" />
<java-symbol type="integer" name="config_backPanicBehavior" />
<java-symbol type="integer" name="config_lowMemoryKillerMinFreeKbytesAdjust" />
<java-symbol type="integer" name="config_lowMemoryKillerMinFreeKbytesAbsolute" />
<java-symbol type="integer" name="config_max_pan_devices" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -321,11 +321,6 @@ public class PhoneWindowManager implements WindowManagerPolicy {
static final int LONG_PRESS_BACK_NOTHING = 0;
static final int LONG_PRESS_BACK_GO_TO_VOICE_ASSIST = 1;

// Number of presses needed before we induce panic press behavior on the back button
static final int PANIC_PRESS_BACK_COUNT = 4;
static final int PANIC_PRESS_BACK_NOTHING = 0;
static final int PANIC_PRESS_BACK_HOME = 1;

// These need to match the documentation/constant in
// core/res/res/values/config.xml
static final int LONG_PRESS_HOME_NOTHING = 0;
Expand Down Expand Up @@ -520,7 +515,6 @@ public void onDrawn() {
volatile boolean mBackKeyHandled;
volatile boolean mBeganFromNonInteractive;
volatile int mPowerKeyPressCounter;
volatile int mBackKeyPressCounter;
volatile boolean mEndCallKeyHandled;
volatile boolean mCameraGestureTriggeredDuringGoingToSleep;
volatile boolean mGoingToSleep;
Expand Down Expand Up @@ -582,7 +576,6 @@ public void onDrawn() {
int mDoublePressOnPowerBehavior;
int mTriplePressOnPowerBehavior;
int mLongPressOnBackBehavior;
int mPanicPressOnBackBehavior;
int mShortPressOnSleepBehavior;
int mShortPressOnWindowBehavior;
volatile boolean mAwake;
Expand Down Expand Up @@ -800,16 +793,15 @@ public void onDrawn() {
private static final int MSG_SHOW_PICTURE_IN_PICTURE_MENU = 17;
private static final int MSG_BACK_LONG_PRESS = 18;
private static final int MSG_DISPOSE_INPUT_CONSUMER = 19;
private static final int MSG_BACK_DELAYED_PRESS = 20;
private static final int MSG_ACCESSIBILITY_SHORTCUT = 21;
private static final int MSG_BUGREPORT_TV = 22;
private static final int MSG_ACCESSIBILITY_TV = 23;
private static final int MSG_DISPATCH_BACK_KEY_TO_AUTOFILL = 24;
private static final int MSG_SYSTEM_KEY_PRESS = 25;
private static final int MSG_HANDLE_ALL_APPS = 26;
private static final int MSG_LAUNCH_ASSIST = 27;
private static final int MSG_LAUNCH_ASSIST_LONG_PRESS = 28;
private static final int MSG_POWER_VERY_LONG_PRESS = 29;
private static final int MSG_ACCESSIBILITY_SHORTCUT = 20;
private static final int MSG_BUGREPORT_TV = 21;
private static final int MSG_ACCESSIBILITY_TV = 22;
private static final int MSG_DISPATCH_BACK_KEY_TO_AUTOFILL = 23;
private static final int MSG_SYSTEM_KEY_PRESS = 24;
private static final int MSG_HANDLE_ALL_APPS = 25;
private static final int MSG_LAUNCH_ASSIST = 26;
private static final int MSG_LAUNCH_ASSIST_LONG_PRESS = 27;
private static final int MSG_POWER_VERY_LONG_PRESS = 28;

private static final int MSG_REQUEST_TRANSIENT_BARS_ARG_STATUS = 0;
private static final int MSG_REQUEST_TRANSIENT_BARS_ARG_NAVIGATION = 1;
Expand Down Expand Up @@ -887,15 +879,10 @@ public void handleMessage(Message msg) {
break;
case MSG_BACK_LONG_PRESS:
backLongPress();
finishBackKeyPress();
break;
case MSG_DISPOSE_INPUT_CONSUMER:
disposeInputConsumer((InputConsumer) msg.obj);
break;
case MSG_BACK_DELAYED_PRESS:
backMultiPressAction(msg.arg1);
finishBackKeyPress();
break;
case MSG_ACCESSIBILITY_SHORTCUT:
accessibilityShortcutActivated();
break;
Expand Down Expand Up @@ -1181,14 +1168,6 @@ private void interceptBackKeyDown() {
// Reset back key state for long press
mBackKeyHandled = false;

// Cancel multi-press detection timeout.
if (hasPanicPressOnBackBehavior()) {
if (mBackKeyPressCounter != 0
&& mBackKeyPressCounter < PANIC_PRESS_BACK_COUNT) {
mHandler.removeMessages(MSG_BACK_DELAYED_PRESS);
}
}

if (hasLongPressOnBackBehavior()) {
Message msg = mHandler.obtainMessage(MSG_BACK_LONG_PRESS);
msg.setAsynchronous(true);
Expand All @@ -1202,21 +1181,6 @@ private boolean interceptBackKeyUp(KeyEvent event) {
// Cache handled state
boolean handled = mBackKeyHandled;

if (hasPanicPressOnBackBehavior()) {
// Check for back key panic press
++mBackKeyPressCounter;

final long eventTime = event.getDownTime();

if (mBackKeyPressCounter <= PANIC_PRESS_BACK_COUNT) {
// This could be a multi-press. Wait a little bit longer to confirm.
Message msg = mHandler.obtainMessage(MSG_BACK_DELAYED_PRESS,
mBackKeyPressCounter, 0, eventTime);
msg.setAsynchronous(true);
mHandler.sendMessageDelayed(msg, ViewConfiguration.getMultiPressTimeout());
}
}

// Reset back long press state
cancelPendingBackKeyAction();

Expand Down Expand Up @@ -1394,10 +1358,6 @@ private void finishPowerKeyPress() {
}
}

private void finishBackKeyPress() {
mBackKeyPressCounter = 0;
}

private void cancelPendingPowerKeyAction() {
if (!mPowerKeyHandled) {
mPowerKeyHandled = true;
Expand All @@ -1415,18 +1375,6 @@ private void cancelPendingBackKeyAction() {
}
}

private void backMultiPressAction(int count) {
if (count >= PANIC_PRESS_BACK_COUNT) {
switch (mPanicPressOnBackBehavior) {
case PANIC_PRESS_BACK_NOTHING:
break;
case PANIC_PRESS_BACK_HOME:
launchHomeFromHotKey();
break;
}
}
}

private void powerPress(long eventTime, boolean interactive, int count) {
if (mScreenOnEarly && !mScreenOnFully) {
Slog.i(TAG, "Suppressed redundant power key press while "
Expand Down Expand Up @@ -1642,10 +1590,6 @@ private boolean hasLongPressOnBackBehavior() {
return mLongPressOnBackBehavior != LONG_PRESS_BACK_NOTHING;
}

private boolean hasPanicPressOnBackBehavior() {
return mPanicPressOnBackBehavior != PANIC_PRESS_BACK_NOTHING;
}

private void interceptScreenshotChord() {
if (mScreenshotChordEnabled
&& mScreenshotChordVolumeDownKeyTriggered && mScreenshotChordPowerKeyTriggered
Expand Down Expand Up @@ -2036,8 +1980,6 @@ public void init(Context context, IWindowManager windowManager,

mLongPressOnBackBehavior = mContext.getResources().getInteger(
com.android.internal.R.integer.config_longPressOnBackBehavior);
mPanicPressOnBackBehavior = mContext.getResources().getInteger(
com.android.internal.R.integer.config_backPanicBehavior);

mShortPressOnPowerBehavior = mContext.getResources().getInteger(
com.android.internal.R.integer.config_shortPressOnPowerBehavior);
Expand Down Expand Up @@ -8295,9 +8237,6 @@ public void dump(String prefix, PrintWriter pw, String[] args) {
pw.print(prefix);
pw.print("mLongPressOnBackBehavior=");
pw.println(longPressOnBackBehaviorToString(mLongPressOnBackBehavior));
pw.print(prefix);
pw.print("mPanicPressOnBackBehavior=");
pw.println(panicPressOnBackBehaviorToString(mPanicPressOnBackBehavior));
pw.print(prefix);
pw.print("mLongPressOnHomeBehavior=");
pw.println(longPressOnHomeBehaviorToString(mLongPressOnHomeBehavior));
Expand Down Expand Up @@ -8498,17 +8437,6 @@ private static String longPressOnBackBehaviorToString(int behavior) {
}
}

private static String panicPressOnBackBehaviorToString(int behavior) {
switch (behavior) {
case PANIC_PRESS_BACK_NOTHING:
return "PANIC_PRESS_BACK_NOTHING";
case PANIC_PRESS_BACK_HOME:
return "PANIC_PRESS_BACK_HOME";
default:
return Integer.toString(behavior);
}
}

private static String longPressOnHomeBehaviorToString(int behavior) {
switch (behavior) {
case LONG_PRESS_HOME_NOTHING:
Expand Down

0 comments on commit bb97879

Please sign in to comment.