MTK修改长按Home键的操作

来源:互联网 发布:数据分析最常用的软件 编辑:程序博客网 时间:2024/06/06 21:37

需求:长按Home键启动google搜索界面(菜单键为原Home键操作效果)

frameworks\base\core\res\res\values\config.xml

<!-- Control the behavior when the user long presses the home button.            0 - Nothing            1 - Recent apps view in SystemUI            2 - Launch assist intent         This needs to match the constants in         policy/src/com/android/internal/policy/impl/PhoneWindowManager.java    -->    <!-- M: Change default long press on home behavior to Recent apps view -->    <integer name="config_longPressOnHomeBehavior">2</integer>

由上面xml中代码可以看出不同的数字表示不同的操作,这里我们将其修改为2启动一个intent来执行操作

if (keyCode == KeyEvent.KEYCODE_HOME) {            ...        } else if (keyCode == KeyEvent.KEYCODE_MENU) {//modify by cyl 20160830            final int chordBug = KeyEvent.META_SHIFT_ON;            if (down && repeatCount == 0) {this.toggleRecentApps();return -1;                /*if (mEnableShiftMenuBugReports && (metaState & chordBug) == chordBug) {                    Intent intent = new Intent(Intent.ACTION_BUG_REPORT);                    mContext.sendOrderedBroadcastAsUser(intent, UserHandle.CURRENT,                            null, null, null, 0, null, null);                    return -1;                } else if (SHOW_PROCESSES_ON_ALT_MENU &&                        (metaState & KeyEvent.META_ALT_ON) == KeyEvent.META_ALT_ON) {                    Intent service = new Intent();                    service.setClassName(mContext, "com.android.server.LoadAverageService");                    ContentResolver res = mContext.getContentResolver();                    boolean shown = Settings.Global.getInt(                            res, Settings.Global.SHOW_PROCESSES, 0) != 0;                    if (!shown) {                        mContext.startService(service);                    } else {                        mContext.stopService(service);                    }                    Settings.Global.putInt(                            res, Settings.Global.SHOW_PROCESSES, shown ? 0 : 1);                    return -1;                }*/            }        }



0 0
原创粉丝点击