美文网首页
Android DisplayContent(2) 直接父类Ro

Android DisplayContent(2) 直接父类Ro

作者: 行走中的3卡 | 来源:发表于2023-09-11 13:56 被阅读0次

上一篇介绍了 DisplayContent 的基本概念和类源码 :https://www.jianshu.com/p/8ad3ea741410
这里再仔细看看它所继承的父类和所实现的接口。

class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.DisplayContentInfo {

1. 直接父类 RootDisplayArea

从以下的源码可以看出,其与 IME 容器有较大关联,
例如 将 IME 容器放置在根目录下.
frameworks/base/services/core/java/com/android/server/wm/RootDisplayArea.java

package com.android.server.wm;
/**
 * Root of a {@link DisplayArea} hierarchy. It can be either the {@link DisplayContent} as the root
 * of the whole logical display, or a {@link DisplayAreaGroup} as the root of a partition of the
 * logical display.
 */
class RootDisplayArea extends DisplayArea.Dimmable {
}

即 DisplayArea 层次结构的根.
它可以是 {@link DisplayContent} 作为整个逻辑显示的根,
或 {@link DisplayAreaGroup} 作为逻辑显示分区的根。

关键成员变量:

    /** {@link Feature} that are supported in this {@link DisplayArea} hierarchy. */
    List<DisplayAreaPolicyBuilder.Feature> mFeatures;

    /**
     * Mapping from policy supported {@link Feature} to list of {@link DisplayArea} created to cover
     * all the window types that the {@link Feature} will be applied to.
     */
    Map<Feature, List<DisplayArea<WindowContainer>>> mFeatureToDisplayAreas;

    // 从窗口层 映射 到在该层上保存窗口的 DisplayArea.Tokens 
    /** Mapping from window layer to {@link DisplayArea.Tokens} that holds windows on that layer. */
    private DisplayArea.Tokens[] mAreaForLayer;

    /** Whether the hierarchy has been built. */
    private boolean mHasBuiltHierarchy;

关键方法:

    /**
     * Places the IME container below this root, so that it's bounds and config will be updated to
     * match the root. //将 IME 容器放置在此根目录下,这样它的边界和配置将被更新以匹配根
     */
    void placeImeContainer(DisplayArea.Tokens imeContainer) {}

    /**
     * Finds the {@link DisplayArea.Tokens} in {@code mAreaForLayer} that this type of window
     * should be attached to.
    @Nullable
    DisplayArea.Tokens findAreaForTokenInLayer(WindowToken token) {

    /** Callback after {@link DisplayArea} hierarchy has been built. */
    void onHierarchyBuilt(ArrayList<Feature> features, DisplayArea.Tokens[] areaForLayer,
            Map<Feature, List<DisplayArea<WindowContainer>>> featureToDisplayAreas) {

    private void updateImeContainerForLayers(@Nullable DisplayArea.Tokens imeContainer) {
        final WindowManagerPolicy policy = mWmService.mPolicy;
        mAreaForLayer[policy.getWindowLayerFromTypeLw(TYPE_INPUT_METHOD)] = imeContainer;
        mAreaForLayer[policy.getWindowLayerFromTypeLw(TYPE_INPUT_METHOD_DIALOG)] = imeContainer;
    }           

2. 直接实现的接口 WindowManagerPolicy.DisplayContentInfo

即 获取 显示内容公共信息的接口.
frameworks/base/services/core/java/com/android/server/policy/WindowManagerPolicy.java

package com.android.server.policy;

public interface WindowManagerPolicy extends WindowManagerPolicyConstants {
    /**
     * Interface to get public information of a display content.
     */
    public interface DisplayContentInfo {
        DisplayRotation getDisplayRotation();
        Display getDisplay();
    }

999

基于 Android 14 源码. (20230912 codesearch main 分支)

相关文章

网友评论

      本文标题:Android DisplayContent(2) 直接父类Ro

      本文链接:https://www.haomeiwen.com/subject/ayievdtx.html