(3) InputListener.cpp
frameworks/base/services/input/InputListener.cpp
(http://androidxref.com/source/history/frameworks/base/services/input/InputListener.cpp)
Introduced the concept of an InputListener to further decouple the InputReader from the InputDispatcher.
The InputListener exposes just the minimum interface that the InputReader needs to communicate with the
outside world. The InputReader passes arguments to the InputListener by reference, which makes it easy to
queue them up.
(4) InputDispatcher.cpp
frameworks/base/services/input/InputDispatcher.cpp
InputListener를 자세히 보진 않았지만 사실은 InputReader에서 InputListener를 거쳐서 InputDispatcher로 들어옴
notifyKey(){
KeyEvent 생성
enqueueInboundEventLocked(KeyEntry)
}
notifyMotion(){
MotionEvent 생성
enqueueInboundEventLocked(MotionEntry)
enqueueInboundEventLocked()함수에서는 KeyEntry/MotionEntry를 queue에 저장하고 Event 내용에 따라 정보를 갱신한다.
여기까지는 InputReader에 의해 호출된 함수가 Queue에 Event 내용을 저장하는 과정이다. (참고: http://marujj.tistory.com/?page=8)
지금부터는 InputDispatcher의 Thread, 실질적인 동작에 대해 분석.
InputDispatcher Class는 기본적으로 아래의 InputDispatcherThread에 의해서 동작한다.
case EventEntry::TYPE_KEY:
--> dispatchKeyLocked
--> dispatchEventToCurrentInputTargetsLocked
case EventEntry::TYPE_MOTION:
--> dispatchMotionLocked
--> dispatchEventToCurrentInputTargetsLocked
dispatchEventToCurrentInputTargetsLocked
--> prepareDispatchCycleLocked
--> enqueueDispatchEntryLocked
...
// Enqueue the dispatch entry./
connection->outboundQueue.enqueueAtTail(dispatchEntry);
여기서 Connection은 이것!
InputDispatcher::Connection::Connection(const sp<InputChannel>& inputChannel,
const sp<InputWindowHandle>& inputWindowHandle, bool monitor) :
status(STATUS_NORMAL), inputChannel(inputChannel), inputWindowHandle(inputWindowHandle),
monitor(monitor), inputPublisher(inputChannel),
lastEventTime(LONG_LONG_MAX), lastDispatchTime(LONG_LONG_MAX) {
}
이 Connection과 위쪽에서 연결되는 부분은 WindowManagerService이다
1) frameworks/base/service/java/com/android/server/wm/WindowManagerService.java
addWindow()에서 mInputManager.registerInputChannel(win.mInputChannel, win.mInputWindowHandle);
2) frameworks/base/core/java/android/view/InputQueue.java
registerInputChannel() --> nativeRegisterInputChannel()
3) frameworks/base/core/jni/android_view_InputQueue.cpp
android_view_InputQueue_nativeRegisterInputChannel()
--> registerInputChannel() // 여기서 Connection 생성
이제 강적 바인더구나.. 바인더 공부를 해야겠다ㅠㅠ
'Android' 카테고리의 다른 글
Android Event Dispatch Process (0) | 2012.06.21 |
---|---|
Android GestureDetector (0) | 2012.06.12 |
Monkey Test 옵션 정리 (0) | 2012.02.20 |
인사이드 안드로이드 Chapter5 (0) | 2012.02.02 |
인사이드 안드로이드 Chapter4 (0) | 2012.02.02 |