网站规划建设实训,酒店建筑设计网站,长沙建设工程备案合同查询网站,选手机网站窗口在App端是以PhoneWindow的形式存在#xff0c;承载了一个Activity的View层级结构。这里我们探讨一下WMS端窗口的形式。
窗口容器类 —— WindowContainer类
/*** Defines common functionality for classes that can hold windows directly or through their* children …窗口在App端是以PhoneWindow的形式存在承载了一个Activity的View层级结构。这里我们探讨一下WMS端窗口的形式。
窗口容器类 —— WindowContainer类
/*** Defines common functionality for classes that can hold windows directly or through their* children in a hierarchy form.* The test class is {link WindowContainerTests} which must be kept up-to-date and ran anytime* changes are made to this class.*/
class WindowContainerE extends WindowContainer extends ConfigurationContainerEimplements ComparableWindowContainer, Animatable, SurfaceFreezer.Freezable,InsetsControlTarget {....../*** The parent of this window container.* For removing or setting new parent {link #setParent} should be used, because it also* performs configuration updates based on new parents settings.*/private WindowContainerWindowContainer mParent null;......// List of children for this window container. List is in z-order as the children appear on// screen with the top-most window container at the tail of the list.protected final WindowListE mChildren new WindowListE();WindowContainer注释中开头就说明了其作用即给可以直接持有窗口的自己或它的孩子定义了一些公共的方法和属性。 WindowContainer定义了能够直接或者间接以层级结构的形式持有窗口的类的通用功能。 从类的定义和名称可以看到WindowContainer是一个容器类可以容纳WindowContainer及其子类对象。如果另外一个容器类作为WindowState的容器那么这个容器类需要继承WindowContainer或其子类。
其中mParent和mChildren一个代表父节点一个代表子节点而且子节点的list顺序代表就是z轴的层级显示顺序list尾巴在比list的头的z轴层级要高。 1mParent是WindowContainer类型成员变量保存的是当前WindowContainer的父容器的引用。 2mChildren是WindowList类型的成员变量保存的则是当前WindowContainer持有的所有子容器。并且列表的顺序也就是子容器出现在屏幕上的顺序最顶层的子容器位于队尾。
根窗口容器 —— RootWindowContainer
/** Root {link WindowContainer} for the device. */
public class RootWindowContainer extends WindowContainerDisplayContent根窗口容器树的根是它。通过它遍历寻找可以找到窗口树上的窗口。它的孩子是DisplayContent。
屏幕 —— DisplayContent
/*** Utility class for keeping track of the WindowStates and other pertinent contents of a* particular Display.*/
class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.DisplayContentInfo {该类是对应着显示屏幕的Android是支持多屏幕的所以可能存在多个DisplayContent对象。上图只画了一个对象的结构其他对象的结构也是和画的对象的结构是相似的。
窗口 —— WindowState类
/** A window in the window manager. */
class WindowState extends WindowContainerWindowState implements WindowManagerPolicy.WindowState,InsetsControlTarget, InputTarget {在WMS窗口体系中一个WindowState对象就代表了一个窗口其继承WindowContainer这就说明WindowState同样可以作为其他窗口的父容器例如我们常见的PopupWindow
WindowState的容器
可直接持有WindowState的容器即WindowToken和ActivityRecord
WindowToken类
/*** Container of a set of related windows in the window manager. Often this is an AppWindowToken,* which is the handle for an Activity that it uses to display windows. For nested windows, there is* a WindowToken created for the parent window to manage its children.*/
class WindowToken extends WindowContainerWindowState {这个注释的意思大概是说窗口管理器中一组相关窗口的容器。这通常是一个AppWindowToken它是用于显示窗口的“活动”的句柄。对于嵌套窗口会为父窗口创建一个WindowToken来管理其子窗口。 总而言之就是用WindowToken来管理WindowState
ActivityRecord类
/*** An entry in the history task, representing an activity.*/
public final class ActivityRecord extends WindowToken implements WindowManagerService.AppFreezeListener {ActivityRecord是WindowToken的子类在WMS中一个ActivityRecord对象就代表一个Activity对象。
WallpaperWindowToken类
/*** A token that represents a set of wallpaper windows.*/
class WallpaperWindowToken extends WindowToken {WallpaperWindowToken继承WindowToken是用来存放和Wallpaper相关的窗口。 一般来说一个窗口的父容器是WindowToken还是ActivityRecord是否主动使用ViewManager.addView来添加一个窗口 父容器为WindowToken的情况APP含系统应用主动调用添加窗口方法来添加窗口如StatusBar、浮窗等。即非Activity窗口 父容器为ActivityRecord的情况系统侧调用添加窗口方法来添加窗口如在桌面启动一个应用等。即Activity窗口
从层级角度将窗口划分为 App之上的窗口父容器为WindowToken如StatusBar和NavigationBar。 App窗口父容器为ActivityRecord如Launcher。 App之下的窗口父容器为WallpaperWindowToken如ImageWallpaper窗口 WindowToken的容器 —— DisplayArea.Tokens /*** DisplayArea that contains WindowTokens, and orders them according to their type.*/public static class Tokens extends DisplayAreaWindowToken {ActivityRecord的容器 —— Task
/*** {link Task} is a TaskFragment that can contain a group of activities to perform a certain job.* Activities of the same task affinities usually group in the same {link Task}. A {link Task}* can also be an entity that showing in the Recents Screen for a job that user interacted with.* A {link Task} can also contain other {link Task}s.*/
class Task extends TaskFragment {Task继承TaskFragment它的孩子可以是Task也可以是ActivityRecord类型。是一个TaskFragment它可以包含一组执行特定作业的Activity。具有相同任务相似性的Activity通常在同一任务中分组。任务也可以是显示在用户交互的作业的最近屏幕中的实体。任务还可以包含其他任务。
/*** A basic container that can be used to contain activities or other {link TaskFragment}, which* also able to manage the activity lifecycle and updates the visibilities of the activities in it.*/
class TaskFragment extends WindowContainerWindowContainer {一个基本容器可用于包含Activity或其他TaskFragment它还能够管理Activity生命周期并更新其中活动的可见性。
Task的容器 —— TaskDisplayArea
/*** {link DisplayArea} that represents a section of a screen that contains app window containers.** The children can be either {link Task} or {link TaskDisplayArea}.*/
final class TaskDisplayArea extends DisplayAreaWindowContainer {TaskDisplayArea代表了屏幕上一块专门用来存放App窗口的区域。 它的子容器可能是Task或者是TaskDisplayArea。