Android Input

InputDispatcher publish InputEvent到InputChannel的客户端,在应用主线程调用WindowInputEventReceiver的回调dispatchInputEvent开始事件分发。第一次会交给输入法ImeInputEventSender处理。 

InputMethodManager$ImeInputEventSender(InputEventSender).sendInputEvent(int, InputEvent) line: 131    
InputMethodManager.sendInputEventOnMainLooperLocked(InputMethodManager$PendingEvent) line: 1658    
InputMethodManager.dispatchInputEvent(InputEvent, Object, InputMethodManager$FinishedInputEventCallback, Handler) line: 1621    
ViewRootImpl$ImeInputStage.onProcess(ViewRootImpl$QueuedInputEvent) line: 3698    
ViewRootImpl$ImeInputStage(ViewRootImpl$InputStage).deliver(ViewRootImpl$QueuedInputEvent) line: 3399    
ViewRootImpl$ViewPreImeInputStage(ViewRootImpl$InputStage).onDeliverToNext(ViewRootImpl$QueuedInputEvent) line: 3449    
ViewRootImpl$ViewPreImeInputStage(ViewRootImpl$InputStage).forward(ViewRootImpl$QueuedInputEvent) line: 3418    
ViewRootImpl$ViewPreImeInputStage(ViewRootImpl$InputStage).apply(ViewRootImpl$QueuedInputEvent, int) line: 3426    
ViewRootImpl$ViewPreImeInputStage(ViewRootImpl$InputStage).deliver(ViewRootImpl$QueuedInputEvent) line: 3399    
ViewRootImpl$NativePreImeInputStage(ViewRootImpl$InputStage).onDeliverToNext(ViewRootImpl$QueuedInputEvent) line: 3449    
ViewRootImpl$NativePreImeInputStage(ViewRootImpl$InputStage).forward(ViewRootImpl$QueuedInputEvent) line: 3418    
ViewRootImpl$NativePreImeInputStage(ViewRootImpl$AsyncInputStage).forward(ViewRootImpl$QueuedInputEvent) line: 3525    
ViewRootImpl$NativePreImeInputStage(ViewRootImpl$InputStage).apply(ViewRootImpl$QueuedInputEvent, int) line: 3426    
ViewRootImpl$NativePreImeInputStage(ViewRootImpl$AsyncInputStage).apply(ViewRootImpl$QueuedInputEvent, int) line: 3582    
ViewRootImpl$NativePreImeInputStage(ViewRootImpl$InputStage).deliver(ViewRootImpl$QueuedInputEvent) line: 3399    
ViewRootImpl.deliverInputEvent(ViewRootImpl$QueuedInputEvent) line: 5602    
ViewRootImpl.doProcessInputEvents() line: 5582    
ViewRootImpl.enqueueInputEvent(InputEvent, InputEventReceiver, int, boolean) line: 5553    
ViewRootImpl$WindowInputEventReceiver.onInputEvent(InputEvent) line: 5682    
ViewRootImpl$WindowInputEventReceiver(InputEventReceiver).dispatchInputEvent(int, InputEvent) line: 185    
MessageQueue.nativePollOnce(int, int) line: not available [native method]    
MessageQueue.next() line: 138    
Looper.loop() line: 123    
ActivityThread.main(String[]) line: 5017    
Method.invokeNative(Object, Object[], Class, Class[], Class, int, boolean) line: not available [native method]    
Method.invoke(Object, Object...) line: 515    
ZygoteInit$MethodAndArgsCaller.run() line: 779    
ZygoteInit.main(String[]) line: 595    
NativeStart.main(String[]) line: not available [native method] 

输入法处理后会继续将事件分发给应用,从InputSender dispatchInputEventFinished开始,到ViewRootImpl各个stage开始真正的分发,在postImeInputStage阶段会将事件交给DecorView处理,decorView会调用设置给PhoneWindow的Callback即Activity的dispatchInputEvent接口处理,然后再从DecorView上层的焦点View开始层层分发,直到最后调用View的performClick结束。

05-12 03:31:53.139  1000 28585 28585 E AndroidRuntime: java.lang.IllegalThreadStateException
05-12 03:31:53.139  1000 28585 28585 E AndroidRuntime: 	at java.lang.Thread.start(Thread.java:724)
05-12 03:31:53.139  1000 28585 28585 E AndroidRuntime: 	at com.xx.xx.activity.MainActivity.onClick(MainActivity.java:236)
05-12 03:31:53.139  1000 28585 28585 E AndroidRuntime: 	at android.view.View.performClick(View.java:6294)
05-12 03:31:53.139  1000 28585 28585 E AndroidRuntime: 	at android.view.View.onKeyUp(View.java:12470)
05-12 03:31:53.139  1000 28585 28585 E AndroidRuntime: 	at android.widget.TextView.onKeyUp(TextView.java:7422)
05-12 03:31:53.139  1000 28585 28585 E AndroidRuntime: 	at android.view.KeyEvent.dispatch(KeyEvent.java:2715)
05-12 03:31:53.139  1000 28585 28585 E AndroidRuntime: 	at android.view.View.dispatchKeyEvent(View.java:11713)
05-12 03:31:53.139  1000 28585 28585 E AndroidRuntime: 	at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1834)
05-12 03:31:53.139  1000 28585 28585 E AndroidRuntime: 	at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1834)
05-12 03:31:53.139  1000 28585 28585 E AndroidRuntime: 	at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1834)
05-12 03:31:53.139  1000 28585 28585 E AndroidRuntime: 	at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1834)
05-12 03:31:53.139  1000 28585 28585 E AndroidRuntime: 	at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1834)
05-12 03:31:53.139  1000 28585 28585 E AndroidRuntime: 	at com.android.internal.policy.DecorView.superDispatchKeyEvent(DecorView.java:440)
05-12 03:31:53.139  1000 28585 28585 E AndroidRuntime: 	at com.android.internal.policy.PhoneWindow.superDispatchKeyEvent(PhoneWindow.java:1819)
05-12 03:31:53.139  1000 28585 28585 E AndroidRuntime: 	at android.app.Activity.dispatchKeyEvent(Activity.java:3267)
05-12 03:31:53.139  1000 28585 28585 E AndroidRuntime: 	at com.android.internal.policy.DecorView.dispatchKeyEvent(DecorView.java:354)
05-12 03:31:53.139  1000 28585 28585 E AndroidRuntime: 	at android.view.ViewRootImpl$ViewPostImeInputStage.processKeyEvent(ViewRootImpl.java:4733)
05-12 03:31:53.139  1000 28585 28585 E AndroidRuntime: 	at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:4605)
05-12 03:31:53.139  1000 28585 28585 E AndroidRuntime: 	at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4147)
05-12 03:31:53.139  1000 28585 28585 E AndroidRuntime: 	at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4200)
05-12 03:31:53.139  1000 28585 28585 E AndroidRuntime: 	at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4166)
05-12 03:31:53.139  1000 28585 28585 E AndroidRuntime: 	at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:4293)
05-12 03:31:53.139  1000 28585 28585 E AndroidRuntime: 	at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4174)
05-12 03:31:53.139  1000 28585 28585 E AndroidRuntime: 	at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:4350)
05-12 03:31:53.139  1000 28585 28585 E AndroidRuntime: 	at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4147)
05-12 03:31:53.139  1000 28585 28585 E AndroidRuntime: 	at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4200)
05-12 03:31:53.139  1000 28585 28585 E AndroidRuntime: 	at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4166)
05-12 03:31:53.139  1000 28585 28585 E AndroidRuntime: 	at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4174)
05-12 03:31:53.139  1000 28585 28585 E AndroidRuntime: 	at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4147)
05-12 03:31:53.139  1000 28585 28585 E AndroidRuntime: 	at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4200)
05-12 03:31:53.139  1000 28585 28585 E AndroidRuntime: 	at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4166)
05-12 03:31:53.139  1000 28585 28585 E AndroidRuntime: 	at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:4326)
05-12 03:31:53.139  1000 28585 28585 E AndroidRuntime: 	at android.view.ViewRootImpl$ImeInputStage.onFinishedInputEvent(ViewRootImpl.java:4487)
05-12 03:31:53.139  1000 28585 28585 E AndroidRuntime: 	at android.view.inputmethod.InputMethodManager$PendingEvent.run(InputMethodManager.java:2435)
05-12 03:31:53.139  1000 28585 28585 E AndroidRuntime: 	at android.view.inputmethod.InputMethodManager.invokeFinishedInputEventCallback(InputMethodManager.java:1998)
05-12 03:31:53.139  1000 28585 28585 E AndroidRuntime: 	at android.view.inputmethod.InputMethodManager.finishedInputEvent(InputMethodManager.java:1989)
05-12 03:31:53.139  1000 28585 28585 E AndroidRuntime: 	at android.view.inputmethod.InputMethodManager$ImeInputEventSender.onInputEventFinished(InputMethodManager.java:2412)
05-12 03:31:53.139  1000 28585 28585 E AndroidRuntime: 	at android.view.InputEventSender.dispatchInputEventFinished(InputEventSender.java:141)
05-12 03:31:53.139  1000 28585 28585 E AndroidRuntime: 	at android.os.MessageQueue.nativePollOnce(Native Method)
05-12 03:31:53.139  1000 28585 28585 E AndroidRuntime: 	at android.os.MessageQueue.next(MessageQueue.java:325)
05-12 03:31:53.139  1000 28585 28585 E AndroidRuntime: 	at android.os.Looper.loop(Looper.java:142)
05-12 03:31:53.139  1000 28585 28585 E AndroidRuntime: 	at android.app.ActivityThread.main(ActivityThread.java:6494)
05-12 03:31:53.139  1000 28585 28585 E AndroidRuntime: 	at java.lang.reflect.Method.invoke(Native Method)
05-12 03:31:53.139  1000 28585 28585 E AndroidRuntime: 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
05-12 03:31:53.139  1000 28585 28585 E AndroidRuntime: 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)

 

你可能感兴趣的:(Android Input)