先重新看看 DisplayContent 類的定義:
class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.DisplayContentInfo {
直接父類為 RootDisplayArea, 而它的定義:
class RootDisplayArea extends DisplayArea.Dimmable {
因此要再看 DisplayArea.Dimmable
1.DisplayArea.Dimmable
作為 DisplayArea 的內(nèi)部靜態(tài)類, 表示可以置灰逾冬,而它實際上是繼承了 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();
}
}
}
可以看出來祥诽,它的創(chuàng)建實際上依賴父類 DisplayArea 的構(gòu)造函數(shù).
并且類本身的也做為泛型對象..
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雄坪,代表也是一個窗口容器
構(gòu)造方法
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 --