Fix 2129239: Add an override method for enabling the menu key on signed builds.
There are now 3 ways to enable the menu key:
- by config file (config_disableMenuKeyInLockScreen)
- by 'adb shell setprop ro.monkey=1' (for automated testing on userdebug builds)
- by creating file '/data/local/enable_menu_key (for automated testing on signed user builds)
Security: this only affects the insecure lock screen (not lock pattern) which is generally enabled.
diff --git a/phone/com/android/internal/policy/impl/LockScreen.java b/phone/com/android/internal/policy/impl/LockScreen.java
index a9f3546..dda5097 100644
--- a/phone/com/android/internal/policy/impl/LockScreen.java
+++ b/phone/com/android/internal/policy/impl/LockScreen.java
@@ -21,6 +21,7 @@
import com.android.internal.widget.RotarySelector;
import android.content.Context;
+import android.content.res.Resources;
import android.text.format.DateFormat;
import android.view.KeyEvent;
import android.view.LayoutInflater;
@@ -35,6 +36,7 @@
import com.android.internal.telephony.IccCard;
import java.util.Date;
+import java.io.File;
import java.text.SimpleDateFormat;
/**
@@ -46,8 +48,9 @@
KeyguardUpdateMonitor.SimStateCallback, KeyguardUpdateMonitor.ConfigurationChangeCallback,
RotarySelector.OnDialTriggerListener {
- static private final boolean DBG = false;
- static private final String TAG = "LockScreen";
+ private static final boolean DBG = false;
+ private static final String TAG = "LockScreen";
+ private static final String ENABLE_MENU_KEY_FILE = "/data/local/enable_menu_key";
private Status mStatus = Status.Normal;
@@ -83,7 +86,7 @@
private java.text.DateFormat mDateFormat;
private java.text.DateFormat mTimeFormat;
private boolean mCreatedInPortrait;
- private boolean mDisableMenuKeyInLockScreen;
+ private boolean mEnableMenuKeyInLockScreen;
/**
* The status of this lock screen.
@@ -136,6 +139,20 @@
}
}
+ /**
+ * In general, we enable unlocking the insecure key guard with the menu key. However, there are
+ * some cases where we wish to disable it, notably when the menu button placement or technology
+ * is prone to false positives.
+ *
+ * @return true if the menu key should be enabled
+ */
+ private boolean shouldEnableMenuKey() {
+ final Resources res = getResources();
+ final boolean configDisabled = res.getBoolean(R.bool.config_disableMenuKeyInLockScreen);
+ final boolean isMonkey = SystemProperties.getBoolean("ro.monkey", false);
+ final boolean fileOverride = (new File(ENABLE_MENU_KEY_FILE)).exists();
+ return !configDisabled || isMonkey || fileOverride;
+ }
/**
* @param context Used to setup the view.
@@ -152,9 +169,7 @@
mUpdateMonitor = updateMonitor;
mCallback = callback;
- mDisableMenuKeyInLockScreen = getResources()
- .getBoolean(R.bool.config_disableMenuKeyInLockScreen)
- && !SystemProperties.getBoolean("ro.monkey", false);
+ mEnableMenuKeyInLockScreen = shouldEnableMenuKey();
mCreatedInPortrait = updateMonitor.isInPortrait();
@@ -220,7 +235,7 @@
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
- if (keyCode == KeyEvent.KEYCODE_MENU && !mDisableMenuKeyInLockScreen) {
+ if (keyCode == KeyEvent.KEYCODE_MENU && mEnableMenuKeyInLockScreen) {
mCallback.goToUnlockScreen();
}
return false;