首页 > 代码库 > android 按menu键解锁功能的开关
android 按menu键解锁功能的开关
android 4.4
android 5.0
android 5.1
修改文件frameworks\base\packages\Keyguard\res\values\config.xml
里的
<!-- Allow the menu hard key to be disabled in LockScreen on some devices [DO NOT TRANSLATE] -->
<bool name="config_disableMenuKeyInLockScreen">false</bool>
改为true 即可禁用该功能。
在5.1中
:~/code/ardroid5.1/frameworks/base/packages/Keyguard$ grep -rin "config_disableMenuKeyInLockScreen" ./
./res/values/config.xml:30: <bool name="config_disableMenuKeyInLockScreen">false</bool>
./src/com/android/keyguard/KeyguardViewBase.java:412: final boolean configDisabled = res.getBoolean(R.bool.config_disableMenuKeyInLockScreen);
:~/code/ardroid5.1/frameworks/base/packages/Keyguard$ grep -rin "configDisabled" ./
./src/com/android/keyguard/KeyguardViewBase.java:412: final boolean configDisabled = res.getBoolean(R.bool.config_disableMenuKeyInLockScreen);
./src/com/android/keyguard/KeyguardViewBase.java:415: return !configDisabled || isTestHarness || fileOverride;
:~/code/ardroid5.1/frameworks/base/packages/Keyguard$ vim ./src/com/android/keyguard/KeyguardViewBase.java +415
private static final String ENABLE_MENU_KEY_FILE = "/data/local/enable_menu_key";
private boolean shouldEnableMenuKey() {
final Resources res = getResources();
final boolean configDisabled = res.getBoolean(R.bool.config_disableMenuKeyInLockScreen);
final boolean isTestHarness = ActivityManager.isRunningInTestHarness();
final boolean fileOverride = (new File(ENABLE_MENU_KEY_FILE)).exists();
return !configDisabled || isTestHarness || fileOverride;
}
:~/code/ardroid5.1/frameworks/base/packages/Keyguard$ grep -rin "shouldEnableMenuKey" ./
./src/com/android/keyguard/KeyguardViewBase.java:410: private boolean shouldEnableMenuKey() {
./src/com/android/keyguard/KeyguardViewBase.java:421: if (shouldEnableMenuKey() && !mLockPatternUtils.isSecure()) {
:~/code/ardroid5.1/frameworks/base/packages/Keyguard$ vim ./src/com/android/keyguard/KeyguardViewBase.java +421
public boolean handleMenuKey() {
// The following enables the MENU key to work for testing automation
if (shouldEnableMenuKey() && !mLockPatternUtils.isSecure()) {
dismiss();
return true;
}
return false;
}
:~/code/ardroid5.1/frameworks/base/packages/SystemUI$ grep -rin "handleMenuKey" ./
./src/com/android/systemui/statusbar/phone/KeyguardBouncer.java:226: if (mKeyguardView.handleMenuKey()) {
public boolean onMenuPressed() {
ensureView();
if (mKeyguardView.handleMenuKey()) {
// We need to show it in case it is secure. If not, it will get dismissed in any case.
mRoot.setVisibility(View.VISIBLE);
mKeyguardView.requestFocus();
mKeyguardView.onResume();
return true;
} else {
return false;
}
}
:~/code/ardroid5.1/frameworks/base/packages/SystemUI$ grep -rin "onMenuPressed" ./
./src/com/android/systemui/statusbar/phone/KeyguardBouncer.java:224: public boolean onMenuPressed() {
./src/com/android/systemui/statusbar/phone/PhoneStatusBar.java:3875: public boolean onMenuPressed() {
./src/com/android/systemui/statusbar/phone/PhoneStatusBar.java:3876: return mState == StatusBarState.KEYGUARD && mStatusBarKeyguardViewManager.onMenuPressed();
./src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java:406: public boolean onMenuPressed() {
./src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java:407: return mBouncer.onMenuPressed();
./src/com/android/systemui/statusbar/phone/StatusBarWindowView.java:132: return mService.onMenuPressed();
./src/com/android/systemui/statusbar/phone/StatusBarWindowView.java:132: return mService.onMenuPressed();
@Override
public boolean dispatchKeyEvent(KeyEvent event) {
boolean down = event.getAction() == KeyEvent.ACTION_DOWN;
switch (event.getKeyCode()) {
case KeyEvent.KEYCODE_BACK:
if (!down) {
mService.onBackPressed();
}
return true;
case KeyEvent.KEYCODE_MENU:
if (!down) {
return mService.onMenuPressed();
}
android 按menu键解锁功能的开关