public boolean interceptKeyBeforeDispatching(WindowState win, int action, int flags,
int keyCode, int scanCode, int metaState, int repeatCount, int policyFlags) {
可以看到這個 function 根據狀況決定HOME key 要不要處理。同時還處理 SEARCH , MENU。
所有的 keyevent,會先進到這裡,再到其他地方。
經過這個篩選後,key 會到 framwork/base/policy/src/com/android/internal/policy/impl/PhoneWindow.java
- protected boolean onKeyDown(int featureId, int keyCode, KeyEvent event)
- protected boolean onKeyUp(int featureId, int keyCode, KeyEvent event)
像 KEYCODE_CAMERA 就會執行下面的code:
sendCloseSystemWindows();
// Broadcast an intent that the Camera button was longpressed
Intent intent = new Intent(Intent.ACTION_CAMERA_BUTTON, null);
intent.putExtra(Intent.EXTRA_KEY_EVENT, event);
getContext().sendOrderedBroadcast(intent, null);
.. close current window & launch CAMERA app在這裡處理的還有:
- KEYCODE_VOLUME_UP/DOWN
- KEYCODE_MEDIA_PLAY_PAUSE
- KEYCODE_MUTE:KEYCODE_HEADSETHOOK.KEYCODE_MEDIA_STOP:KEYCODE_MEDIA_NEXT:KEYCODE_MEDIA_PREVIOUS:KEYCODE_MEDIA_REWIND:KEYCODE_MEDIA_FAST_FORWARD:
- KEYCODE_MENU
- KEYCODE_BACK
- KEYCODE_CALL
- KEYCODE_SEARCH
沒有留言:
張貼留言