赞
踩
参考:
上面的文档有介绍说“窗口层级分为37层”
,这是怎么来的呢?
这个和类DisplayAreaPolicyBuilder
有关,路径frameworks/base/services/core/java/com/android/server/wm/DisplayAreaPolicyBuilder.java
其中的内部类Feature.Builder
,有个如下的属性:
private final boolean[] mLayers;
其初始化如下:
如下:
mLayers = new boolean[mPolicy.getMaxWindowLayer() + 1];
而getMaxWindowLayer
返回的是36
default int getMaxWindowLayer() {
return 36;
}
所以就是37
层了
DisplayAreaPolicy
类的rootHierarchy
在addFeature
时,调用了很多Feature.Builder
的方法,如:
/**
* Set that the feature applies to all window types.
*/
Builder all() {
Arrays.fill(mLayers, true);
return this;
}
将mLayers
中所以元素设置为true
Builder upTo(int typeInclusive) {
final int max = layerFromType(typeInclusive, false);
for (int i = 0; i < max; i++) {
mLayers[i] = true;
}
set(typeInclusive, true);
return this;
}
layerFromType
方法会获取typeInclusive
对应的layer
层级,然后将0-typeInclusive
都设置为true
如上面的TYPE_ACCESSIBILITY_MAGNIFICATION_OVERLAY
,返回为32
,即表示0-32
都设置为true
/**
* Window type: Window for adding accessibility window magnification above other windows.
* This will place the window in the overlay windows.
* @hide
*/
public static final int TYPE_ACCESSIBILITY_MAGNIFICATION_OVERLAY = FIRST_SYSTEM_WINDOW + 39;
Builder except(int... types) {
for (int i = 0; i < types.length; i++) {
int type = types[i];
set(type, false);
}
return this;
}
表示将对应的layer设置为false
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。