android 按menu键解锁功能的开关

Posted 夏叶星空

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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键解锁功能的开关的主要内容,如果未能解决你的问题,请参考以下文章

电脑的监控控制锁如何解锁

创维电视屏幕显示键盘已加锁怎么弄?

Android 11.0 修改在锁屏界面,按“△”键不能解锁,只能按空格键解锁

Android 按键 在锁屏界面,按“△”不能解锁,只有空格键可以解锁

记录锁、间隙锁、临键锁

键盘上下左右键失灵的原因?