当前位置:   article > 正文

屏幕的窗口层级_displayareapolicybuilder

displayareapolicybuilder

屏幕的窗口层级

参考:

窗口层级分为37层

上面的文档有介绍说“窗口层级分为37层”,这是怎么来的呢?

这个和类DisplayAreaPolicyBuilder有关,路径frameworks/base/services/core/java/com/android/server/wm/DisplayAreaPolicyBuilder.java

其中的内部类Feature.Builder,有个如下的属性:

private final boolean[] mLayers;
  • 1

其初始化如下:

初始化
如下:

mLayers = new boolean[mPolicy.getMaxWindowLayer() + 1];
  • 1

getMaxWindowLayer返回的是36

    default int getMaxWindowLayer() {
        return 36;
    }
  • 1
  • 2
  • 3

所以就是37层了

DisplayAreaPolicyBuilder.Feature.Builder

DisplayAreaPolicy类的rootHierarchyaddFeature时,调用了很多Feature.Builder的方法,如:

Feature.Builder

all

            /**
             * Set that the feature applies to all window types.
             */
            Builder all() {
                Arrays.fill(mLayers, true);
                return this;
            }
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7

mLayers中所以元素设置为true

upTo

            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;
            }
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8

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;
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

TYPE_ACCESSIBILITY_MAGNIFICATION_OVERLAY

except

            Builder except(int... types) {
                for (int i = 0; i < types.length; i++) {
                    int type = types[i];
                    set(type, false);
                }
                return this;
            }
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7

表示将对应的layer设置为false

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/盐析白兔/article/detail/325896
推荐阅读
相关标签
  

闽ICP备14008679号