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)等。

相关推荐
数据猎手小k29 分钟前
AndroidLab:一个系统化的Android代理框架,包含操作环境和可复现的基准测试,支持大型语言模型和多模态模型。
android·人工智能·机器学习·语言模型
你的小101 小时前
JavaWeb项目-----博客系统
android
风和先行2 小时前
adb 命令查看设备存储占用情况
android·adb
AaVictory.2 小时前
Android 开发 Java中 list实现 按照时间格式 yyyy-MM-dd HH:mm 顺序
android·java·list
似霰3 小时前
安卓智能指针sp、wp、RefBase浅析
android·c++·binder
大风起兮云飞扬丶3 小时前
Android——网络请求
android
干一行,爱一行3 小时前
android camera data -> surface 显示
android
断墨先生4 小时前
uniapp—android原生插件开发(3Android真机调试)
android·uni-app
无极程序员5 小时前
PHP常量
android·ide·android studio
萌面小侠Plus6 小时前
Android笔记(三十三):封装设备性能级别判断工具——低端机还是高端机
android·性能优化·kotlin·工具类·低端机