Android R: 记一次修复AOSP的Desktop(桌面模式)或者External Display(扩展投屏)点击最大化按钮,跳出其他应用App问题
原因分析:
抓取点击设置App的最大化按钮,窗口慢慢放大时的当时的log
log_click_Minimize_when_app_to_zoom_in__dumpsys_SurfaceFlinger.txt
此时发现设置App的层级已经跑到了桌面App和其他App的下面,壁纸的上面,
所以,就导致了该问题。
此时,发现设置App层级有两个:
一个是设置App layer层级,另一个是设置App的snapshot anim层级
"snapshot anim"层级动画是,点击最大化按钮时创建用于app最大化时的动画
然后,在frameworks/base/services/core/java/com/android/server/wm/SurfaceFreezer.java创建的:
最后,反复调试得出如下patch:
在这里插入代码片
void freeze(SurfaceControl.Transaction t, Rect startBounds) {
mFreezeBounds.set(startBounds);
mLeash = SurfaceAnimator.createAnimationLeash(mAnimatable, mAnimatable.getSurfaceControl(),
t, ANIMATION_TYPE_SCREEN_ROTATION, startBounds.width(), startBounds.height(),
startBounds.left, startBounds.top, false /* hidden */,
mWmService.mTransactionFactory);
mAnimatable.onAnimationLeashCreated(t, mLeash);
SurfaceControl freezeTarget = mAnimatable.getFreezeSnapshotTarget();
if (freezeTarget != null) {
GraphicBuffer snapshot = createSnapshotBuffer(freezeTarget, startBounds);
if (snapshot != null) {
mSnapshot = new Snapshot(mWmService.mSurfaceFactory, t, snapshot, mLeash);
}
}
}
->
Snapshot(Supplier<Surface> surfaceFactory, SurfaceControl.Transaction t,
GraphicBuffer thumbnailHeader, SurfaceControl parent) {
mSurfaceControl = mAnimatable.makeAnimationLeash()
.setName("snapshot anim: " + mAnimatable.toString())
.setBufferSize(width, height)
.setFormat(PixelFormat.TRANSLUCENT)
.setParent(parent)
.setCallsite("SurfaceFreezer.Snapshot")
.build();
// Transfer the thumbnail to the surface
drawSurface.copyFrom(mSurfaceControl);
drawSurface.attachAndQueueBuffer(thumbnailHeader);
drawSurface.release();
t.show(mSurfaceControl);
// We parent the thumbnail to the container, and just place it on top of anything else
// in the container.
t.setLayer(mSurfaceControl, Integer.MAX_VALUE);
// parent就是mLeash
// 在参考文档中找到Leash是什么?(SurfaceAnimator中有定义)
// 翻译:这个类可以针对那种存在多个child surface的对象进行动画,
// 在执行动画的过程中会创建一个没有Buffer的Surface—“Leash”,
// 将所有child surface绑定到leash上,leash同时也会绑定到原先这些child surface绑定的位置。
// 然后我们将leash给到AnimationAdapter去执行动画,
// 执行动画结束后会将所有child surface重新绑定到原先的父节点上
+ t.setLayer(parent, Integer.MAX_VALUE);
}
同时,还发现在Desktop同时,有两个app都最大化时,点击另一个app的最小化按钮时,后面的app会有动画切换的闪动问题。修改方法时在AppTransition.java中的loadAnimation(),打印transit的值时8,即TRANSIT_TASK_OPEN,修改TRANSIT_TASK_OPEN动画为没有动画解决该问题。
参考文档:
http://itpcb.com/a/94241
Android P——LockFreeAnimation
调试方法:
在开发者选项中:
把“窗口动画缩放”改成最大10x
把“过渡动画缩放”改成最大10x
把“Animator时长缩放”改成最大10x
dumpsys window w | grep “Window #”
或者
dumpsys window visible | grep “Window #”
或者
am stack list 观察点击最大化按钮,App的层级没有变,在其他app的上面。
但是: dumpsys SurfaceFlinger 观察到的是: 点击最大按键的App的层级却位于其他应用之下。
同时,打开设置App和便签App,让设置App在便签App上面
然后:抓取dumpsys SurfaceFlinger log 观察应用层级:
1,抓取点击设置App的最大化按钮之前的log
log_before_click_Minimize_dumpsys_SurfaceFlinger.txt
Display 19260733058351745 HWC layers:
-----------------------------------------------------------------------------------------------------------------------------------------------
Layer name
Z | Window Type | Layer Class | Comp Type | Transform | Disp Frame (LTRB) | Source Crop (LTRB) | Frame Rate (Explicit) [Focused]
------------------------------------------------------------------------------------------------------------------------

最低0.47元/天 解锁文章

被折叠的 条评论
为什么被折叠?



