Android U WMShell动画调用堆栈

本文主要简单介绍WMShell动画调用堆栈

代码环境:repo init -u https://mirrors.tuna.tsinghua.edu.cn/git/AOSP/platform/manifest -b android-14.0.0_r7

Systemserver侧

TAG: 	at com.android.server.wm.Transition.onTransactionReady(Transition.java:1575)
TAG: 	at com.android.server.wm.BLASTSyncEngine$SyncGroup.finishNow(BLASTSyncEngine.java:263)
TAG: 	at com.android.server.wm.BLASTSyncEngine$SyncGroup.tryFinish(BLASTSyncEngine.java:202)
TAG: 	at com.android.server.wm.BLASTSyncEngine$SyncGroup.-$$Nest$mtryFinish(BLASTSyncEngine.java:0)
TAG: 	at com.android.server.wm.BLASTSyncEngine.onSurfacePlacement(BLASTSyncEngine.java:552)
TAG: 	at com.android.server.wm.RootWindowContainer.performSurfacePlacementNoTrace(RootWindowContainer.java:810)
TAG: 	at com.android.server.wm.RootWindowContainer.performSurfacePlacement(RootWindowContainer.java:756)
TAG: 	at com.android.server.wm.WindowSurfacePlacer.performSurfacePlacementLoop(WindowSurfacePlacer.java:177)
TAG: 	at com.android.server.wm.WindowSurfacePlacer.performSurfacePlacement(WindowSurfacePlacer.java:126)
TAG: 	at com.android.server.wm.WindowManagerService.relayoutWindow(WindowManagerService.java:2410)
TAG: 	at com.android.server.wm.Session.relayout(Session.java:249)
TAG: 	at com.android.server.wm.Session.relayoutAsync(Session.java:263)
TAG: 	at android.view.IWindowSession$Stub.onTransact(IWindowSession.java:731)
TAG: 	at com.android.server.wm.Session.onTransact(Session.java:178)
TAG: 	at android.os.Binder.execTransactInternal(Binder.java:1344)
TAG: 	at android.os.Binder.execTransact(Binder.java:1275)

调用WMShell动画是从relayout流程开始,真正去调用WMShell动画的方法是RootWindowContainer.performSurfacePlacementNoTrace方法中的这句mWmService.mSyncEngine.onSurfacePlacement()

Systemserver侧调用的结束点在Transition.onTransactionReady方法

代码路径frameworks/base/services/core/java/com/android/server/wm/Transition.java

java 复制代码
@Override
public void onTransactionReady(int syncId, SurfaceControl.Transaction transaction) {
	......
	mController.getTransitionPlayer().onTransitionReady(
                        mToken, info, transaction, mFinishTransaction);
 	......
}

这里通过ITransitionPlayer跨进程通信到SystemUI,进入wmshell动画

java 复制代码
private ITransitionPlayer mTransitionPlayer;
@Nullable ITransitionPlayer getTransitionPlayer() {
    return mTransitionPlayer;
}

调用ITransitionPlayer对象的onTransitionReady方法,该方法在Transitions中实现

SystemUI侧

代码路径:frameworks/base/libs/WindowManager/Shell/src/com/android/wm/shell/transition/Transitions.java

java 复制代码
@BinderThread
private class TransitionPlayerImpl extends ITransitionPlayer.Stub {
    @Override
    public void onTransitionReady(IBinder iBinder, TransitionInfo transitionInfo,
            SurfaceControl.Transaction t, SurfaceControl.Transaction finishT)
            throws RemoteException {
        mMainExecutor.execute(() -> Transitions.this.onTransitionReady(
                iBinder, transitionInfo, t, finishT));
    }

    ......
}
TAG: java.lang.Exception
TAG: 	at com.android.wm.shell.transition.Transitions.playTransition(go/retraceme 691c0b649c5b78e8be353184a2cf4f8453b1bbeba9558d5f9cdae4325458fb69:885)
TAG: 	at com.android.wm.shell.transition.Transitions.processReadyQueue(go/retraceme 691c0b649c5b78e8be353184a2cf4f8453b1bbeba9558d5f9cdae4325458fb69:819)
TAG: 	at com.android.wm.shell.transition.Transitions.dispatchReady(go/retraceme 691c0b649c5b78e8be353184a2cf4f8453b1bbeba9558d5f9cdae4325458fb69:760)
TAG: 	at com.android.wm.shell.transition.Transitions.onTransitionReady(go/retraceme 691c0b649c5b78e8be353184a2cf4f8453b1bbeba9558d5f9cdae4325458fb69:669)
TAG: 	at com.android.wm.shell.transition.Transitions$TransitionPlayerImpl.lambda$onTransitionReady$0(go/retraceme 691c0b649c5b78e8be353184a2cf4f8453b1bbeba9558d5f9cdae4325458fb69:1353)
TAG: 	at com.android.wm.shell.transition.Transitions$TransitionPlayerImpl.$r8$lambda$qsRfWn1ItrZqnFeABBdxU50jPc4(go/retraceme 691c0b649c5b78e8be353184a2cf4f8453b1bbeba9558d5f9cdae4325458fb69:0)
TAG: 	at com.android.wm.shell.transition.Transitions$TransitionPlayerImpl$$ExternalSyntheticLambda0.run(go/retraceme 691c0b649c5b78e8be353184a2cf4f8453b1bbeba9558d5f9cdae4325458fb69:0)
TAG: 	at android.os.Handler.handleCallback(Handler.java:958)
TAG: 	at android.os.Handler.dispatchMessage(Handler.java:99)
TAG: 	at android.os.Looper.loopOnce(Looper.java:205)
TAG: 	at android.os.Looper.loop(Looper.java:294)
TAG: 	at android.os.HandlerThread.run(HandlerThread.java:67)

代码路径:frameworks/base/libs/WindowManager/Shell/src/com/android/wm/shell/transition/Transitions.java

java 复制代码
    private void playTransition(@NonNull ActiveTransition active) {
        ProtoLog.v(ShellProtoLogGroup.WM_SHELL_TRANSITIONS, "Playing animation for %s", active);
        ......

        // If a handler already chose to run this animation, try delegating to it first.
        if (active.mHandler != null) {
            ProtoLog.v(ShellProtoLogGroup.WM_SHELL_TRANSITIONS, " try firstHandler %s",
                    active.mHandler);
            boolean consumed = active.mHandler.startAnimation(active.mToken, active.mInfo,
                    active.mStartT, active.mFinishT, (wct, cb) -> onFinish(active, wct, cb));
         ......
         }
         ......  
    }

这里主要关注active.mHandler.startAnimation方法,是Transitions中TransitionHandler接口的方法

关键在这个startAnimation的实现,从代码上看在多处均有实现,常见的例如画中画(PipTranstion)、分屏(StageCoordinator)等。

相关推荐
长亭外的少年1 小时前
Kotlin 编译失败问题及解决方案:从守护进程到 Gradle 配置
android·开发语言·kotlin
建群新人小猿4 小时前
会员等级经验问题
android·开发语言·前端·javascript·php
1024小神5 小时前
tauri2.0版本开发苹果ios和安卓android应用,环境搭建和最后编译为apk
android·ios·tauri
兰琛5 小时前
20241121 android中树结构列表(使用recyclerView实现)
android·gitee
Y多了个想法6 小时前
RK3568 android11 适配敦泰触摸屏 FocalTech-ft5526
android·rk3568·触摸屏·tp·敦泰·focaltech·ft5526
NotesChapter7 小时前
Android吸顶效果,并有着ViewPager左右切换
android
_祝你今天愉快8 小时前
分析android :The binary version of its metadata is 1.8.0, expected version is 1.5.
android
暮志未晚Webgl8 小时前
109. UE5 GAS RPG 实现检查点的存档功能
android·java·ue5
麦田里的守望者江9 小时前
KMP 中的 expect 和 actual 声明
android·ios·kotlin
Dnelic-9 小时前
解决 Android 单元测试 No tests found for given includes:
android·junit·单元测试·问题记录·自学笔记