This document discusses how an input event from user (e.g. user key stroke) is propagated in Android framework, and how it is delivered to the corresponding event handler in the application.
This document is based on the code of Android 4.1.1_r6.1 (Jelly Bean).
For each application, a ViewRootImpl object is created to handle communications with the remote system WindowManagerService object. The communication is through a Linux pipe which is encapsulated in an InputChannel object (mInputChannel field in class ViewRootImpl). The ViewRootImpl object also registers an instance of InputEventReceiver when the first View object is registered with it.
frameworks/base/core/java/android/view/ViewRootImpl.java +482