1.添加长按菜单按键跳转到“最近应用”,长按Home按键跳转到“Google Search”
修改路径frameworks\base\policy\src\com\android\internal\policy\impl\PhoneWindowManager.java
interceptKeyBeforeDispatching(),这个方法是frameworks中处理按键事件处理的中转站.
找到
if (keyCode == KeyEvent.KEYCODE_HOME) {
if (win != null && win.getAttrs() != null) {
final int flag = win.getAttrs().flags;
//如果在应用程序中有设置窗口的FLAG,屏蔽HOME
if ((flag & WindowManager.LayoutParams.FLAG_HOMEKEY_DISPATCHED) != 0) {// the window wants to handle the home key, so dispatch it to it.
return 0;
}
}
// If we have released the home key, and didn't do anything else
// while it was pressed, then it is time to go home!
if (!down) {
// cancelPreloadRecentApps();
mHomePressed = false;
if (mHomeConsumed) {
mHomeConsumed = false;
return -1;
}
if(mHomeLongPressed){
mHomeLongPressed = false;
return -1;
}
if (canceled) {
Log.i(TAG, "Ignoring HOME; event canceled.");
return -1;
}
// If an incoming call is ringing, HOME is totally disabled.
// (The user is already on the InCallScreen at this point,
// and his ONLY options are to answer or reject the call.)
try {
ITelephony telephonyService = getTelephonyService();
if (telephonyService != null && telephonyService.isRinging()) {
Log.i(TAG, "Ignoring HOME; there's a ringing incoming call.");
return -1;
}
} catch (RemoteException ex) {
Log.w(TAG, "RemoteException from getPhoneInterface()", ex);
}
// Delay handling home if a double-tap is possible.
if (mDoubleTapOnHomeBehavior != DOUBLE_TAP_HOME_NOTHING) {
mHandler.removeCallbacks(mHomeDoubleTapTimeoutRunnable); // just in case
mHomeDoubleTapPending = true;
mHandler.postDelayed(mHomeDoubleTapTimeoutRunnable,
ViewConfiguration.getDoubleTapTimeout());
return -1;
}
// Go home!
launchHomeFromHotKey();
return -1;
}
// If a system window has focus, then it doesn't make sense
// right now to interact with applications.
WindowManager.LayoutParams attrs = win != null ? win.getAttrs() : null;
if (attrs != null) {
final int type = attrs.type;
if (type == WindowManager.LayoutParams.TYPE_KEYGUARD
|| type == WindowManager.LayoutParams.TYPE_KEYGUARD_SCRIM
|| type == WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG) {
// the "app" is keyguard, so give it the key
return 0;
}
final int typeCount = WINDOW_TYPES_WHERE_HOME_DOESNT_WORK.length;
for (int i=0; i<typeCount; i++) {
if (type == WINDOW_TYPES_WHERE_HOME_DOESNT_WORK[i]) {
// don't do anything, but also don't pass it to the app
return -1;
}
}
}
// Remember that home is pressed and handle special actions.
if (repeatCount == 0) {
mHomePressed = true;
if (mHomeDoubleTapPending) {
mHomeDoubleTapPending = false;
//rm by zj
// mHandler.removeCallbacks(mHomeDoubleTapTimeoutRunnable);
// handleDoubleTapOnHome();
} else if (mLongPressOnHomeBehavior == LONG_PRESS_HOME_RECENT_SYSTEM_UI
|| mDoubleTapOnHomeBehavior == DOUBLE_TAP_HOME_RECENT_SYSTEM_UI) {
// preloadRecentApps();
}
} else if ((event.getFlags() & KeyEvent.FLAG_LONG_PRESS) != 0) {
if (!keyguardOn) {
//rm by zj
// handleLongPressOnHome();
/*************add by zj******************/
startGlobalSearch(mContext,null, false, null);
mHomeLongPressed = true;
}
}
return -1;
} else if (keyCode == KeyEvent.KEYCODE_MENU) {
final int chordBug = KeyEvent.META_SHIFT_ON;
//modify by zj20141030
if(!down){
//add by zj
// event = KeyEvent.changeAction(event, KeyEvent.ACTION_DOWN);
// interceptKeyBeforeDispatching(win, event, 100) ;
}else{
if (repeatCount == 0) {
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;
}
}else if ((event.getFlags() & KeyEvent.FLAG_LONG_PRESS) != 0){
if(!keyguardOn){
try {
IStatusBarService statusbar = getStatusBarService();
if (statusbar != null) {
statusbar.toggleRecentApps();
}
} catch (RemoteException e) {
Slog.e(TAG, "RemoteException when showing recent apps", e);
// re-acquire status bar service next time it is needed.
}
}
}
}
2.MTK初次单独编译一些模块的时候,需要先mma,然后才能mm
3.MTK删除一些铃声,frameworks\base\data\sounds这个下有一些脚本,找到铃声的名称,在脚本中注释掉就好了