主要功能
消息传递
1 | 前置消息生成 |
KeyEvent
1 | Target:to find the focus one self or child. |
ViewGroup:dispatchKeyEvent
1 |
|
View:dispatchKeyEvent
1 | /** |
Activity:dispatchKeyEvent
1 | /** |
TouchEvent
1 | Sequence:dispatchTouchEvent,onInterceptTouchEvent,onTouchEvent ,U型传递 |
U型传递图
总结:
- touch事件先子View后父View,key事件先父View后子View,Activity作为兜底方案
- 不论是touch事件还是key事件都是自顶向下分发的
- …….
与windowsManagerService通信
IWindowSession
1 | new ViewRootImpl -> |
Session
This class represents an active client session. There is generally one Session object per process that is interacting with the window manager.
1 |
|
SurfaceSession
How to Create
1 | ActivityThread(handleResumeActivity) -> |
触发视图的更新
Activity的onCreate
1 | ActivityThread(handleLaunchActivity) -> |
DecorView的建立
via setContentView
1 | Activity (setContentView)-> |
DecorView的添加
via onResume
1 | //## Surface create in ViewRootImpl but is Empty |
AttachToWindow
1 | ActivityThread(handleResumeActivity)-> |
DettachToWindow
1 | ActivityThread(handleDestroyActivity)-> |
其他
数据生命周期
attachInfo
1 | //##ViewRootImpl |
viewParent
1 | //##ViewRootImpl |