WMS学习上

93 阅读2分钟

一、了解WMS

页面流程

Activity-->Window-->DecorView->
                                ViewStub(导航栏等系统控件)
                                ContentParent-ContentView-setContentView(页面布局文件)

image.png

页面绘制逻辑

  • 页面的显示逻辑

image.png

image.png

  • 绘制Canvas的来源
ViewrootImpl:
IWindowSession.relayout->mSurfaceControll->
surface.copyfrom(mSurfaceControl)->mSurface.lockCanvas->
canvace-decorview-view.draw


Session:用AIDL实现的一个Bindler通信代码

二、 Android 中的Window

1、Window、WindowManager、WMS简单介绍

WMS<->WindowManager-Window WindowManager:Window管理类 Window:窗口,Activity、Dialog、Toast、popwindow、输入法、系统弹窗 WMS:真正的窗口管理类大小、层级、添加、删除、启动

2、Window基本概念

窗口的分类: Application Window :应用程序窗口Activity Sub Window :子窗口,不能独立存在,需要附着在其他窗口上才可以 popwindow System Window:输入法、系统音量调、错误窗口等

类型:

Application Window:1~99都是属于应用层的窗口
//这个1用来做App Window下线判断的,应用窗口标志不能比当前更低
public static final int FIRST_APPLICATION_WINDOW = 1;
//
public static final int TYPE_BASE_APPLICATION   = 1;
public static final int TYPE_APPLICATION        = 2;
//App点击图标到展示应用启动页之间的页面(闪屏页)
public static final int TYPE_APPLICATION_STARTING = 3;
public static final int TYPE_DRAWN_APPLICATION = 4;

//app window上线判断,表示1~99之前都是App window
public static final int LAST_APPLICATION_WINDOW = 99;

sub window:1000~1999

/**

  • Start of types of sub-windows. The {@link #token} of these windows
  • must be set to the window they are attached to. These types of
  • windows are kept next to their attached window in Z-order, and their
  • coordinate space is relative to their attached window. */ public static final int FIRST_SUB_WINDOW = 1000;

/**

  • Window type: a panel on top of an application window. These windows
  • appear on top of their attached window. */ public static final int TYPE_APPLICATION_PANEL = FIRST_SUB_WINDOW;

/**

  • Window type: window for showing media (such as video). These windows
  • are displayed behind their attached window. */ public static final int TYPE_APPLICATION_MEDIA = FIRST_SUB_WINDOW + 1;

/**

  • Window type: a sub-panel on top of an application window. These
  • windows are displayed on top their attached window and any
  • {@link #TYPE_APPLICATION_PANEL} panels. */ public static final int TYPE_APPLICATION_SUB_PANEL = FIRST_SUB_WINDOW + 2;

/** Window type: like {@link #TYPE_APPLICATION_PANEL}, but layout

  • of the window happens as that of a top-level window, not
  • as a child of its container. */ public static final int TYPE_APPLICATION_ATTACHED_DIALOG = FIRST_SUB_WINDOW + 3;

/**

  • Window type: window for showing overlays on top of media windows.
  • These windows are displayed between TYPE_APPLICATION_MEDIA and the
  • application window. They should be translucent to be useful. This
  • is a big ugly hack so:
  • @hide */ @UnsupportedAppUsage public static final int TYPE_APPLICATION_MEDIA_OVERLAY = FIRST_SUB_WINDOW + 4;

/**

  • Window type: a above sub-panel on top of an application window and it's
  • sub-panel windows. These windows are displayed on top of their attached window
  • and any {@link #TYPE_APPLICATION_SUB_PANEL} panels.
  • @hide */ public static final int TYPE_APPLICATION_ABOVE_SUB_PANEL = FIRST_SUB_WINDOW + 5;

/**

  • End of types of sub-windows. */ public static final int LAST_SUB_WINDOW = 1999;

    SystemWindow 2000~2999

依次递增,次序,排列显示问题中间不能插入窗口 次序越大离用户越近。越靠前

image.png

窗口标志:跟窗口相应有关;

image.png

image.png

image.png

image.png

3、WindowManager对窗口的添加、更新

image.png

image.png

image.png

更新窗口 image.png

4、UI刷新的流程