android display 杂谈(三)WMS

编程入门 行业动态 更新时间:2024-10-23 09:38:38

android display <a href=https://www.elefans.com/category/jswz/34/1767767.html style=杂谈(三)WMS"/>

android display 杂谈(三)WMS

用来记录学习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处理。

更多推荐

android display 杂谈(三)WMS

本文发布于:2023-11-17 00:27:18,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1635016.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:杂谈   android   display   WMS

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!