当前位置:首页 > 编程笔记 > 正文
已解决

android display 杂谈(三)WMS

来自网友在路上 165865提问 提问时间:2023-11-04 21:35:01阅读次数: 65

最佳答案 问答题库658位专家为你答疑解惑

用来记录学习wms,后续会一点一点更新。。。。。。
代码:android14

WMS是在SystemServer进程中启动的

在SystemServer中的main方法中,调用run方法。
在这里插入图片描述

private void run() {
// Initialize native services.初始化服务,加载android_servers so库
870              System.loadLibrary("android_servers");
// Create the system service manager.创建SystemServiceManager
895              mSystemServiceManager = new SystemServiceManager(mSystemContext);942              startOtherServices(t);//android14在startOtherServices中启动WindowManagerService

android14中,在startOtherServices中启动WindowManagerService

1606              wm = WindowManagerService.main(context, inputManager, !mFirstBoot,
1607                      new PhoneWindowManager(), mActivityManagerService.mActivityTaskManager);

该代码执行了WMS的main方法,会在内部创建一个WMS。其中有一个参数inputManager也是在startOtherServices中创建的,如下。

1589              t.traceBegin("StartInputManagerService");
1590              inputManager = new InputManagerService(context);

总结,WMS的main方法在startOtherServices中,而startOtherServices在SystemServer的run方法中,运行在system_server线程中。

1608              ServiceManager.addService(Context.WINDOW_SERVICE, wm, /* allowIsolated= */ false,
1609                      DUMP_FLAG_PRIORITY_CRITICAL | DUMP_FLAG_PROTO);
1610              ServiceManager.addService(Context.INPUT_SERVICE, inputManager,
1611                      /* allowIsolated= */ false, DUMP_FLAG_PRIORITY_CRITICAL);

上述代码将WMS和IMS注册到ServerManager中。
回到上述的WindowManagerService main中。
/frameworks/base/services/core/java/com/android/server/wm/WindowManagerService.java

1137      public static WindowManagerService main(final Context context, final InputManagerService im,
1138              final boolean showBootMsgs, WindowManagerPolicy policy, ActivityTaskManagerService atm,
1139              DisplayWindowSettingsProvider displayWindowSettingsProvider,
1140              Supplier<SurfaceControl.Transaction> transactionFactory,
1141              Function<SurfaceSession, SurfaceControl.Builder> surfaceControlFactory) {
1142          final WindowManagerService[] wms = new WindowManagerService[1];
1143          DisplayThread.getHandler().runWithScissors(() ->
1144                  wms[0] = new WindowManagerService(context, im, showBootMsgs, policy, atm,
1145                          displayWindowSettingsProvider, transactionFactory,
1146                          surfaceControlFactory), 0);
1147          return wms[0];
1148      }

DisplayThread.getHandler().runWithScissors调用DisplayThread的getHandler方法,获得DisplayThread的handler实例。
可以用来处理需要低延时显示的相关操作。

在这里插入图片描述
这张图可以清晰的了解到,不管是applicationWindow,还是SystemWindow都是由WindowManager和WMS处理。

查看全文

99%的人还看了

猜你感兴趣

版权申明

本文"android display 杂谈(三)WMS":http://eshow365.cn/6-32148-0.html 内容来自互联网,请自行判断内容的正确性。如有侵权请联系我们,立即删除!