先重新看看 DisplayContent 类的定义:
class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.DisplayContentInfo {
直接父类为 RootDisplayArea, 而它的定义:
class RootDisplayArea extends DisplayArea.Dimmable {
因此要再看 DisplayArea.Dimmable
1.DisplayArea.Dimmable
作为 DisplayArea 的内部静态类, 表示可以置灰,而它实际上是继承了 DisplayArea
/**
* DisplayArea that can be dimmed.
*/
static class Dimmable extends DisplayArea<DisplayArea> {
private final Dimmer mDimmer = new Dimmer(this);
private final Rect mTmpDimBoundsRect = new Rect();
Dimmable(WindowManagerService wms, Type type, String name, int featureId) {
super(wms, type, name, featureId);
}
@Override
Dimmer getDimmer() {
return mDimmer;
}
@Override
void prepareSurfaces() {
mDimmer.resetDimStates();
super.prepareSurfaces();
// Bounds need to be relative, as the dim layer is a child.
getBounds(mTmpDimBoundsRect);
mTmpDimBoundsRect.offsetTo(0 /* newLeft */, 0 /* newTop */);
// If SystemUI is dragging for recents, we want to reset the dim state so any dim layer
// on the display level fades out.
if (forAllTasks(task -> !task.canAffectSystemUiFlags())) {
mDimmer.resetDimStates();
}
if (mDimmer.updateDims(getSyncTransaction(), mTmpDimBoundsRect)) {
scheduleAnimation();
}
}
}
可以看出来,它的创建实际上依赖父类 DisplayArea 的构造函数.
并且类本身的也做为泛型对象..
2. DisplayArea 源码
用于将 WindowContainer 分组到 DisplayContent 下面的容器。
DisplayAreas 由 {@link DisplayAreaPolicy} 管理, 可以重写配置并且可以被束缚。
DisplayAreas 可以包含嵌套的 DisplayAreas.
frameworks/base/services/core/java/com/android/server/wm/DisplayArea.java
类的定义:
/**
* Container for grouping WindowContainer below DisplayContent.
*
* DisplayAreas are managed by a {@link DisplayAreaPolicy}, and can override configurations and
* can be leashed.
*
* DisplayAreas can contain nested DisplayAreas.
*
* DisplayAreas come in three flavors, to ensure that windows have the right Z-Order:
* - BELOW_TASKS: Can only contain BELOW_TASK DisplayAreas and WindowTokens that go below tasks.
* - ABOVE_TASKS: Can only contain ABOVE_TASK DisplayAreas and WindowTokens that go above tasks.
* - ANY: Can contain any kind of DisplayArea, and any kind of WindowToken or the Task container.
*
* @param <T> type of the children of the DisplayArea.
*/
public class DisplayArea<T extends WindowContainer> extends WindowContainer<T> {
可以看到它的 父类其实也是 WindowContainer,代表也是一个窗口容器
构造方法
DisplayArea(WindowManagerService wms, Type type, String name, int featureId) {
super(wms);
// TODO(display-area): move this up to ConfigurationContainer
setOverrideOrientation(SCREEN_ORIENTATION_UNSET);
mType = type;
mName = name;
mFeatureId = featureId;
mRemoteToken = new RemoteToken(this);
mOrganizerController =
wms.mAtmService.mWindowOrganizerController.mDisplayAreaOrganizerController;
}
999
基于 Android 14 源码. (20230913 codesearch main 分支)
-- END --