背景:
近来有学员朋友在做自由窗口升级aosp14时候,虽然马哥已经给大家提供了aosp14的适配patch,但是那个值实现了基本功能,没有和aosp13那么全面,发现自由窗口的顶部操作栏这部分内容和以前aosp13有较大的差异,于是和马哥这边进行了相关的讨论交流,确实发现这块差异比aosp13大了不少,这里进行一下相关记录总结方便后续学员观看。
aosp13和aosp14的CaptionView对比情况
aosp13时候,课程也分析过,在进入自由窗口后主要是变成DecorCaptionView这个layout容器
安卓14版本已经看不到有相关的DecorCaptionView
下面来剖析aosp 14上到底是啥原理。
aosp 14 CaptionWindow图层情况
注意这里的这里的CaptionWindow其实并不可以通过dumpsys window windows这样方式看到它,说明它本身不是一个windowstate,不受窗口层级结构树管理,只能在sf的dump看到,为了更加直观使用winscope来看看
SurfaceFlinger看看图层,明显看到了Caption of Task这个顶部工具图层
但是在window的图层结构没有看到
核心拖动放大逻辑处理
代码位置
frameworks/base/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/FluidResizeTaskPositioner.java
拖拉上面的CaptionWindow部分,让自由窗口移动堆栈情况
onDragPositioningStart:73, FluidResizeTaskPositioner (com.android.wm.shell.windowdecor)
handleMotionEvent:265, CaptionWindowDecorViewModel$CaptionTouchEventListener (com.android.wm.shell.windowdecor)
onMotionEvent:72, DragDetector (com.android.wm.shell.windowdecor)
onTouch:249, CaptionWindowDecorViewModel$CaptionTouchEventListener (com.android.wm.shell.windowdecor)
dispatchTouchEvent:15651, View (android.view)
dispatchTransformedTouchEvent:3114, ViewGroup (android.view)
dispatchTouchEvent:2787, ViewGroup (android.view)
dispatchPointerEvent:15919, View (android.view)
processPointerEvent:7021, ViewRootImpl$ViewPostImeInputStage (android.view)
onProcess:6815, ViewRootImpl$ViewPostImeInputStage (android.view)
deliver:6229, ViewRootImpl$InputStage (android.view)
onDeliverToNext:6286, ViewRootImpl$InputStage (android.view)
forward:6252, ViewRootImpl$InputStage (android.view)
forward:6417, ViewRootImpl$AsyncInputStage (android.view)
apply:6260, ViewRootImpl$InputStage (android.view)
apply:6474, ViewRootImpl$AsyncInputStage (android.view)
deliver:6233, ViewRootImpl$InputStage (android.view)
onDeliverToNext:6286, ViewRootImpl$InputStage (android.view)
forward:6252, ViewRootImpl$InputStage (android.view)
apply:6260, ViewRootImpl$InputStage (android.view)
deliver:6233, ViewRootImpl$InputStage (android.view)
deliverInputEvent:9211, ViewRootImpl (android.view)
doProcessInputEvents:9162, ViewRootImpl (android.view)
enqueueInputEvent:9131, ViewRootImpl (android.view)
onInputEvent:9337, ViewRootImpl$WindowInputEventReceiver (android.view)
dispatchInputEvent:267, InputEventReceiver (android.view)
nativePollOnce:-1, MessageQueue (android.os)
next:335, MessageQueue (android.os)
loopOnce:162, Looper (android.os)
loop:294, Looper (android.os)
run:67, HandlerThread (android.os)
边角触摸点击拖拽放大,让自由窗口放大执行堆栈情况
onDragPositioningStart:73, FluidResizeTaskPositioner (com.android.wm.shell.windowdecor)
handleMotionEvent:325, DragResizeInputListener$TaskResizeInputEventReceiver (com.android.wm.shell.windowdecor)
onMotionEvent:72, DragDetector (com.android.wm.shell.windowdecor)
handleInputEvent:302, DragResizeInputListener$TaskResizeInputEventReceiver (com.android.wm.shell.windowdecor)
onInputEvent:295, DragResizeInputListener$TaskResizeInputEventReceiver (com.android.wm.shell.windowdecor)
dispatchInputEvent:267, InputEventReceiver (android.view)
nativePollOnce:-1, MessageQueue (android.os)
next:335, MessageQueue (android.os)
loopOnce:162, Looper (android.os)
loop:294, Looper (android.os)
run:67, HandlerThread (android.os)
总结差异
总结出来了Caption在aosp13和aosp14的差别
更多framework技术干货,请关注下面“千里马学框架”