/* ****************************************************************************
* HOW TO DECIDE WHERE YOUR KEY HANDLING GOES.
*
* If your key handling must happen before the app gets a crack at the event,
* it goes in PhoneWindowManager.
*
* If your key handling should happen in all windows, and does not depend on
* the state of the current application, other than that the current
* application can override the behavior by handling the event itself, it
* should go in PhoneFallbackEventHandler.
*
* Only if your handling depends on the window, and the fact that it has
* a DecorView, should it go here.
* ****************************************************************************/
Android KeyEvent의 처리 순서
기본적으로 KeyEvent의 처리는 application 내부에서 재정의한다.
만약 처리하지 않으면 이벤트는 최종적으로 PhoneFallbackEventHandler로 떨어지게 된다.
1, PhoneWindowManager.java -> interceptKeyBeforeDispatching
: 가장 먼저 처리되어야 하는 KeyEvent들의 처리
2, PhoneWindow.java -> onKeyUp and onKeyDown
: KeyEvent의 처리가 window에 종속적인 경우 PhoneWindow에서 처리.
3, PhoneFallbackEventHandler.java -> dispatchKeyEvent
: 모든 KeyEvent의 처리가 Window에 의존하지 않고 처리되어야하는 경우, PhoneFallbackEventHandler에 정의한다.
각 1,2,3의 처리 부분에서 true를 리턴하는 경우 다음 stage의 handler에는 전달되지 않고 consume 된다.
출처 :
AOSP source code
'android' 카테고리의 다른 글
platform key Android studio에서 사용하기 (0) | 2018.12.03 |
---|---|
onNewIntent callback in activity (0) | 2018.09.13 |
android power mode 와 linux power mode 비교 (early suspend) (0) | 2018.08.31 |
property read using reflection java (0) | 2018.08.30 |
ErrorMessage: Sending non-protected broadcast (0) | 2018.08.22 |