注:文章都是通过阅读各位前辈总结的资料、Android 11 Rockchip平台源码、加上自己的思考分析总结出来的,其中难免有理解不对的地方,欢迎大家批评指正。文章为个人学习、研究、欣赏之用,图文内容整理自互联网,如有侵权,请联系删除(◕‿◕),转载请注明出处(©Rockchip ©Android @Linux 版权所有),谢谢。

(==文章基于 Android 11.0==)

【zhoujinjian.com博客原图链接】

【开发板】

【开发板 源码链接】

正是由于前人的分析和总结,帮助我节约了大量的时间和精力,特别感谢,由于不喜欢图片水印,去除了水印,敬请谅解!!!

zhoujinjian.com


==源码(部分)==:

xxx

==源码(部分)==:


(一)、InputManagerService初始化

image-20221027094950105

image-20221027095512362

image-20221027095548641

image-20221027095626369

image-20221027095652842

(1)、InputDispatcher初始化

image-20221027095740500

(2)、InputReader初始化

image-20221027095844947

(3)、EventHub初始化

image-20221027100319791

(4)、InputManagerService.start()

image-20221027100656839

image-20221027100836913

image-20221027100858489

image-20221027100926276

(5)、InputDispatcher.start()

image-20221027101106916

image-20221027113354714

(6)、InputReader.start()

image-20221027101147654

image-20221027113531171

(7)、EventHub::getEvents()

image-20221027132600483

(二)、InputChannel 服务端(System_Server)register

image-20221026113350606

image-20221026192540644

(1)、WindowState.openInputChannel()

image-20221026192704803

image-20221026192752789

image-20221026192815403

image-20221026192926747

image-20221026193014900

image-20221027092859857

(2)、InputManagerService.registerInputChannel()

image-20221027093126783

image-20221027093224596

image-20221027093252326

image-20221027093449771

image-20221027093715359

image-20221027093813544

(三)、InputChannel 客户端(App-Launcher)register

image-20221027094005740

image-20221027094505483

image-20221027094532853

image-20221027094607077

image-20221027094321718

(四)、Input Motion Event事件 Server分发

image-20221027143408175

image-20221027143519671

(1)、InputReader::processEventsLocked()

image-20221027143653894

image-20221027143935200

(2)、InputDevice::process()

image-20221027144139620

(3)、TouchInputMapper::processRawTouches()

image-20221027144621694

Log:

image-20221027145357518

(4)、TouchInputMapper::processRawTouches()

image-20221027145446258

image-20221027145533749

(5)、TouchInputMapper::dispatchTouches()

image-20221027145639238

image-20221027145709304

(6)、InputDispatcher::notifyMotion()

image-20221027150101292

image-20221027150214826

(7)、InputDispatcher::notifyMotion()

image-20221027150650263

image-20221027150816563

(8)、InputDispatcher::dispatchOnceInnerLocked()

image-20221027152145125

image-20221027152228877

(9)、InputDispatcher::dispatchEventLocked()

image-20221027152405656

image-20221027152544526

image-20221027153049512

image-20221027153202922

(10)、InputDispatcher::startDispatchCycleLocked()

image-20221027153340854

(11)、InputPublisher::publishMotionEvent()

image-20221027153617457

image-20221027153754750

image-20221027153812565

image-20221027162237787

(五)、Input Motion Event事件 Client接收

(1)、NativeInputEventReceiver::handleEvent()

image-20221027162447073

image-20221027162400118

(2)、InputConsumer::consume()

image-20221027162600337

image-20221027162710884

image-20221027162732280

(3)、NativeInputEventReceiver::consumeEvents()

image-20221027162918422

image-20221027162830945

(4)、InputEventReceiver::dispatchInputEvent()

image-20221027163134650

image-20221027163310911

(5)、View.dispatchTouchEvent()

image-20221028134050016

image-20221028134140542

(6)、MotionEvent { action=ACTION_DOWN…}

image-20221028134316074

image-20221028134408948

(7)、MotionEvent { action=ACTION_UP…}

image-20221028134532535

image-20221028134556342

(8)、Pointer 0: id=0, toolType=1, x=1294.325806, y=401.628113

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
52806: 10-21 15:00:37.848   950  1094 D InputDispatcher:   Pointer 0: id=0, toolType=1, x=1294.325806, y=401.628113, pressure=1.000000, size=0.000000, touchMajor=0.000000, touchMinor=0.000000, toolMajor=0.000000, toolMinor=0.000000, orientation=0.000000
52823: 10-21 15:00:37.850 950 1093 D InputDispatcher: Pointer 0: id=0, toolType=1, x=1294.325806, y=401.628113, pressure=1.000000, size=0.000000, touchMajor=0.000000, touchMinor=0.000000, toolMajor=0.000000, toolMinor=0.000000, orientation=0.000000
53173: 10-21 15:00:37.880 950 1094 D InputDispatcher: Pointer 0: id=0, toolType=1, x=1294.325806, y=401.628113, pressure=1.000000, size=0.000000, touchMajor=0.000000, touchMinor=0.000000, toolMajor=0.000000, toolMinor=0.000000, orientation=0.000000
53193: 10-21 15:00:37.882 950 1093 D InputDispatcher: Pointer 0: id=0, toolType=1, x=1294.325806, y=401.628113, pressure=1.000000, size=0.000000, touchMajor=0.000000, touchMinor=0.000000, toolMajor=0.000000, toolMinor=0.000000, orientation=0.000000
53532: 10-21 15:00:37.953 4443 4443 V ViewRootImpl[Launcher]: Done with EarlyPostImeInputStage. QueuedInputEvent{flags=0, hasNextQueuedEvent=true, hasInputEventReceiver=true, mEvent=MotionEvent { action=ACTION_DOWN, actionButton=0, id[0]=0, x[0]=1294.3258, y[0]=401.6281, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, classification=NONE, metaState=0, flags=0x2, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=98717, downTime=98717, deviceId=-1, source=0x1002, displayId=0 }}
53533: 10-21 15:00:37.954 4443 4443 V ViewRootImpl[Launcher]: Done with NativePostImeInputStage. QueuedInputEvent{flags=0, hasNextQueuedEvent=true, hasInputEventReceiver=true, mEvent=MotionEvent { action=ACTION_DOWN, actionButton=0, id[0]=0, x[0]=1294.3258, y[0]=401.6281, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, classification=NONE, metaState=0, flags=0x2, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=98717, downTime=98717, deviceId=-1, source=0x1002, displayId=0 }}
53535: 10-21 15:00:37.955 4443 4443 D HMI_Launcher: DragLayer: onInterceptTouchEvent: mDragging=false, ev=MotionEvent { action=ACTION_DOWN, actionButton=0, id[0]=0, x[0]=1294.3258, y[0]=401.6281, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, classification=NONE, metaState=0, flags=0x2, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=98717, downTime=98717, deviceId=-1, source=0x1002, displayId=0 }
53549: 10-21 15:00:37.955 4443 4443 D HMI_Launcher: Workspace: onInterceptTouchEvent: 1294.3258, 401.6281
54150: 10-21 15:00:37.967 4443 4443 D ViewRootImpl: processPointerEvent src=0x1002 eventTimeNano=98717995000 id=0x3e5d3449 MotionEvent:MotionEvent { action=ACTION_DOWN, actionButton=0, id[0]=0, x[0]=1294.3258, y[0]=401.6281, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, classification=NONE, metaState=0, flags=0x2, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=98717, downTime=98717, deviceId=-1, source=0x1002, displayId=0 } handled:true
54178: 10-21 15:00:37.967 4443 4443 V ViewRootImpl[Launcher]: Done with ViewPostImeInputStage. QueuedInputEvent{flags=FINISHED|FINISHED_HANDLED, hasNextQueuedEvent=true, hasInputEventReceiver=true, mEvent=MotionEvent { action=ACTION_DOWN, actionButton=0, id[0]=0, x[0]=1294.3258, y[0]=401.6281, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, classification=NONE, metaState=0, flags=0x2, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=98717, downTime=98717, deviceId=-1, source=0x1002, displayId=0 }}
54179: 10-21 15:00:37.968 4443 4443 V ViewRootImpl[Launcher]: Done with SyntheticInputStage. QueuedInputEvent{flags=FINISHED|FINISHED_HANDLED, hasNextQueuedEvent=true, hasInputEventReceiver=true, mEvent=MotionEvent { action=ACTION_DOWN, actionButton=0, id[0]=0, x[0]=1294.3258, y[0]=401.6281, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, classification=NONE, metaState=0, flags=0x2, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=98717, downTime=98717, deviceId=-1, source=0x1002, displayId=0 }}
54224: 10-21 15:00:37.968 4443 4443 V ViewRootImpl[Launcher]: Done with EarlyPostImeInputStage. QueuedInputEvent{flags=0, hasNextQueuedEvent=true, hasInputEventReceiver=true, mEvent=MotionEvent { action=ACTION_UP, actionButton=0, id[0]=0, x[0]=1294.3258, y[0]=401.6281, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, classification=NONE, metaState=0, flags=0x2, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=98749, downTime=98717, deviceId=-1, source=0x1002, displayId=0 }}
54225: 10-21 15:00:37.969 4443 4443 V ViewRootImpl[Launcher]: Done with NativePostImeInputStage. QueuedInputEvent{flags=0, hasNextQueuedEvent=true, hasInputEventReceiver=true, mEvent=MotionEvent { action=ACTION_UP, actionButton=0, id[0]=0, x[0]=1294.3258, y[0]=401.6281, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, classification=NONE, metaState=0, flags=0x2, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=98749, downTime=98717, deviceId=-1, source=0x1002, displayId=0 }}
54226: 10-21 15:00:37.969 4443 4443 D HMI_Launcher: DragLayer: onInterceptTouchEvent: mDragging=false, ev=MotionEvent { action=ACTION_UP, actionButton=0, id[0]=0, x[0]=1294.3258, y[0]=401.6281, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, classification=NONE, metaState=0, flags=0x2, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=98749, downTime=98717, deviceId=-1, source=0x1002, displayId=0 }
54228: 10-21 15:00:37.969 4443 4443 D HMI_Launcher: Workspace: onInterceptTouchEvent: 1294.3258, 401.6281
54368: 10-21 15:00:37.974 4443 4443 D ViewRootImpl: processPointerEvent src=0x1002 eventTimeNano=98749755000 id=0x1e902588 MotionEvent:MotionEvent { action=ACTION_UP, actionButton=0, id[0]=0, x[0]=1294.3258, y[0]=401.6281, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, classification=NONE, metaState=0, flags=0x2, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=98749, downTime=98717, deviceId=-1, source=0x1002, displayId=0 } handled:true
54396: 10-21 15:00:37.974 4443 4443 V ViewRootImpl[Launcher]: Done with ViewPostImeInputStage. QueuedInputEvent{flags=FINISHED|FINISHED_HANDLED, hasNextQueuedEvent=true, hasInputEventReceiver=true, mEvent=MotionEvent { action=ACTION_UP, actionButton=0, id[0]=0, x[0]=1294.3258, y[0]=401.6281, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, classification=NONE, metaState=0, flags=0x2, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=98749, downTime=98717, deviceId=-1, source=0x1002, displayId=0 }}
54397: 10-21 15:00:37.974 4443 4443 V ViewRootImpl[Launcher]: Done with SyntheticInputStage. QueuedInputEvent{flags=FINISHED|FINISHED_HANDLED, hasNextQueuedEvent=true, hasInputEventReceiver=true, mEvent=MotionEvent { action=ACTION_UP, actionButton=0, id[0]=0, x[0]=1294.3258, y[0]=401.6281, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, classification=NONE, metaState=0, flags=0x2, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=98749, downTime=98717, deviceId=-1, source=0x1002, displayId=0 }}

(六)、参考资料(特别感谢):

(1)xxx