MTK修改长按Home键的操作

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

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


    
    2

由上面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;
                }*/
            }
        }



你可能感兴趣的:(MTK随记)