1 前言

​ RootWindowContainer 是窗口容器的根容器,子容器是 DisplayContent。关于其父类及祖父类的介绍,见→WindowContainer简介ConfigurationContainer简介

​ 本文主要介绍 WallpaperController 和 RootWindowContainer。

2 源码

2.1 WallpaperController

​ 源码地址→/frameworks/base/services/core/java/com/android/server/wm/WallpaperController.java

(1)主要属性

private WindowManagerService mService

private final DisplayContent mDisplayContent

private final ArrayList<WallpaperWindowToken> mWallpaperTokens = new ArrayList<>()

private WindowState mWallpaperTarget = null

private WindowState mPrevWallpaperTarget = null

private WindowState mWaitingOnWallpaper

private WindowState mTmpTopWallpaper

WindowState mDeferredHideWallpaper = null

private float mLastWallpaperX = -1

private float mLastWallpaperY = -1

private float mLastWallpaperXStep = -1

private float mLastWallpaperYStep = -1

private int mLastWallpaperDisplayOffsetX = Integer.MIN_VALUE

private int mLastWallpaperDisplayOffsetY = Integer.MIN_VALUE

private long mLastWallpaperTimeoutTime

private final FindWallpaperTargetResult mFindResults = new FindWallpaperTargetResult()

(2)内部类

final private static class FindWallpaperTargetResult {
WindowState topWallpaper = null;
WindowState wallpaperTarget = null;
boolean useTopWallpaperAsTarget = false;
boolean resetTopWallpaper = false //topWallpaper = win
void setTopWallpaper(WindowState win) //wallpaperTarget = win
void setWallpaperTarget(WindowState win) //useTopWallpaperAsTarget = topWallpaperAsTarget
void setUseTopWallpaperAsTarget(boolean topWallpaperAsTarget) void reset()
}

(3)函数

private final ToBooleanFunction<WindowState> mFindWallpaperTargetFunction = w -> {
//mFindResults.setTopWallpaper(w)
//mFindResults.setWallpaperTarget(w)
}

(4)Wallpaper 相关

//return mWallpaperTarget
WindowState getWallpaperTarget() //return win == mWallpaperTarget
boolean isWallpaperTarget(WindowState win) //return mWallpaperTarget != null && mWallpaperTarget.mLayer >= win.mBaseLayer
boolean isBelowWallpaperTarget(WindowState win) //return isWallpaperVisible(mWallpaperTarget)
boolean isWallpaperVisible() //mWallpaperTokens.get(i).updateWallpaperVisibility(isWallpaperVisible(mWallpaperTarget))
void updateWallpaperVisibility() //hideWallpapers(mDeferredHideWallpaper)
void hideDeferredWallpapersIfNeeded() //mDeferredHideWallpaper = winGoingAway
void hideWallpapers(final WindowState winGoingAway) boolean updateWallpaperOffset(WindowState wallpaperWin, int dw, int dh, boolean sync) void setWindowWallpaperPosition(WindowState window, float x, float y, float xStep, float yStep) void setWindowWallpaperDisplayOffset(WindowState window, int x, int y) //mWallpaperTokens.get(i).sendWindowWallpaperCommand(action, x, y, z, extras, sync)
Bundle sendWindowWallpaperCommand(WindowState window, String action, int x, int y, int z, Bundle extras, boolean sync) //mLastWallpaperTimeoutTime = 0
void clearLastWallpaperTimeoutTime() //mWaitingOnWallpaper = null; mService.mGlobalLock.notifyAll()
void wallpaperCommandComplete(IBinder window) //mWaitingOnWallpaper = null; mService.mGlobalLock.notifyAll()
void wallpaperOffsetsComplete(IBinder window) void adjustWallpaperWindows() void adjustWallpaperWindowsForAppTransitionIfNeeded(ArraySet<AppWindowToken> openingApps, ArraySet<AppWindowToken> changingApps) //mWallpaperTokens.add(token)
void addWallpaperToken(WallpaperWindowToken token) //return canScreenshotWallpaper(getTopVisibleWallpaper())
boolean canScreenshotWallpaper() Bitmap screenshotWallpaperLocked()

(5)动画

//mWallpaperTokens.get(i).startAnimation(a)
void startWallpaperAnimation(Animation a) boolean isWallpaperTargetAnimating() //mService.getRecentsAnimationController().startAnimation()
boolean processWallpaperDrawPendingTimeout()

2.2 RootWindowContainer

​ 源码地址→/frameworks/base/services/core/java/com/android/server/wm/RootWindowContainer.java

(1)类定义

//DisplayContent 为子节点
class RootWindowContainer extends WindowContainer<DisplayContent> implements ConfigurationContainerListener

(2)实现接口

public interface ConfigurationContainerListener {
void onRequestedOverrideConfigurationChanged(Configuration overrideConfiguration);
}

(3)主要属性

private RootActivityContainer mRootActivityContainer

private Object mLastWindowFreezeSource = null

private Session mHoldScreen = null

private float mScreenBrightness = -1

private long mUserActivityTimeout = -1

WindowState mHoldScreenWindow = null

WindowState mObscuringWindow = null

final WallpaperController mWallpaperController

//mHandler = new MyHandler(service.mH.getLooper())
private final Handler mHandler private int mTopFocusedDisplayId = INVALID_DISPLAY //key为pid
final HashMap<Integer, AppWindowToken> mTopFocusedAppByProcess = new HashMap<>(); //事务
private final SurfaceControl.Transaction mDisplayTransaction = new SurfaceControl.Transaction()

(4)消费者

//关闭系统对话框,w 为 WindowState 类型
private final Consumer<WindowState> mCloseSystemDialogsConsumer = w -> {
if (w.mHasSurface) {
...
w.mClient.closeSystemDialogs(mCloseSystemDialogsReason);
...
}
}; //移除窗口,w 为 WindowState 类型
private static final Consumer<WindowState> sRemoveReplacedWindowsConsumer = w -> {
final AppWindowToken aToken = w.mAppToken;
if (aToken != null) {
aToken.removeReplacedWindowIfNeeded(w);
}
};

​ Consumer 类如下。

public interface Consumer<T> {
void accept(T t); default Consumer<T> andThen(Consumer<? super T> after) {
Objects.requireNonNull(after);
return (T t) -> { accept(t); after.accept(t); };
}
}

(5)Handler

private final class MyHandler extends Handler {
...
public void handleMessage(Message msg) {
switch (msg.what) {
//设置屏幕亮度
case SET_SCREEN_BRIGHTNESS_OVERRIDE:
mService.mPowerManagerInternal.setScreenBrightnessOverrideFromWindowManager(msg.arg1);
break;
//设置屏幕休眠时间
case SET_USER_ACTIVITY_TIMEOUT:
mService.mPowerManagerInternal.setUserActivityTimeoutOverrideFromWindowManager((Long) msg.obj);
break;
...
}
}
}

(6)Window 相关

//mChildren.get(i).findFocusedWindow()
WindowState computeFocusedWindow() void getWindowsByName(ArrayList<WindowState> output, String name) //mChildren.get(i).getAppWindowToken(binder)
AppWindowToken getAppWindowToken(IBinder binder)

(7)Display 相关

//displaysInFocusOrder.put(i, mChildren.get(i).getDisplayId())
void getDisplaysInFocusOrder(SparseIntArray displaysInFocusOrder) //mChildren.get(i).getDisplayId() == displayId ? mChildren.get(i) : null
DisplayContent getDisplayContent(int displayId) //new DisplayContent(display, mService, mWallpaperController, controller)
DisplayContent createDisplayContent(final Display display, DisplayWindowController controller) //mChildren.get(i).getWindowToken(token.token) == token ? mChildren.get(i) : null
DisplayContent getWindowTokenDisplay(WindowToken token) //getDisplayContent(displayId).onOverrideConfigurationChanged(newConfiguration)
int[] setDisplayOverrideConfigurationIfNeeded(Configuration newConfiguration, int displayId)

(8)Surface 相关

//mChildren.get(i).destroyLeakedSurfaces()
//mWmService.mActivityManager.killPids(pids, "Free memory", secure)
//winAnimator.destroySurface()
//winAnimator.mWin.mAppToken.getController().removeStartingWindow()
//winAnimator.mWin.mClient.dispatchGetNewSurface()
boolean reclaimSomeSurfaceMemory(WindowStateAnimator winAnimator, String operation, boolean secure) //performSurfacePlacementNoTrace(recoveringMemory
void performSurfacePlacement(boolean recoveringMemory) //mWmService.updateFocusedWindowLocked(UPDATE_FOCUS_WILL_PLACE_SURFACES, false)
//mChildren.get(i).setExitingTokensHasVisible(false)
//applySurfaceChangesTransaction(recoveringMemory)
//mWmService.enableScreenIfNeededLocked()
//mWmService.scheduleAnimationLocked()
void performSurfacePlacementNoTrace(boolean recoveringMemory)

(9)Layout 相关

//mChildren.get(i).isLayoutNeeded()
boolean isLayoutNeeded() //final int pendingChanges = animator.getPendingLayoutChanges(mChildren.get(i).getDisplayId())
//return pendingChanges != 0
boolean hasPendingLayoutChanges(WindowAnimator animator) boolean copyAnimToLayoutParams()

(10)输入法

//mChildren.get(i).mInputMethodWindow
WindowState getCurrentInputMethodWindow()

(11)forAllWindows

//forAllWindows: w.mWinAnimator.setSecureLocked(disabled)
void setSecureSurfaceState(int userId, boolean disabled) //w.setHiddenWhileSuspended(suspended)
void updateHiddenWhileSuspendedState(final ArraySet<String> packages, final boolean suspended) //forAllWindows: w.updateAppOpsState()
void updateAppOpsState() //forAllWindows(mCloseSystemDialogsConsumer, false)
void closeSystemDialogs(String reason) //forAllWindows(sRemoveReplacedWindowsConsumer, true)
void removeReplacedWindows()

(12)forAllDisplays

void forAllDisplays(Consumer<DisplayContent> callback) {
for (int i = mChildren.size() - 1; i >= 0; --i) {
callback.accept(mChildren.get(i));
}
}

(13)forAllDisplayPolicies

void forAllDisplayPolicies(Consumer<DisplayPolicy> callback) {
for (int i = mChildren.size() - 1; i >= 0; --i) {
callback.accept(mChildren.get(i).getDisplayPolicy());
}
}

(14)其他方法

//mChildren.get(i).getStack(windowingMode, activityType)
TaskStack getStack(int windowingMode, int activityType) //win = getWindow((w) -> w.mSession.mPid == pid && w.isVisibleLw()), return win != null
boolean canShowStrictModeViolation(int pid) boolean handleNotObscuredLocked(WindowState w, boolean obscured, boolean syswin)

​ 声明:本文转自【framework】RootWindowContainer简介

【framework】RootWindowContainer简介的更多相关文章

  1. 实体框架(Entity Framework)简介

    实体框架(Entity Framework)简介 简称EF,与ADO.NET关系 ADO.NET Entity Framework 是微软以 ADO.NET 为基础所发展出来的对象关系对应 (O/R ...

  2. iOS - 系统经常使用框架(framework)的简介

    系统框架(framework)的简介 ImageIO  - 该框架的接口可用于导入或导出图像数据及图像元数据 CoreTelephony  - 获取IMSI号,SIM卡背面的号码是SIM卡的电子串号, ...

  3. .NET Entity Framework入门简介及简单操作

    Entity Framework是微软借鉴ORM思想开发自己的一个ORM框架. ORM就是将数据库表与实体对象(相当于三层中的Model类)相互映射的一种思想. 最大的优点就是非常方便的跨数据库平台. ...

  4. Spring Framework体系结构简介

    说明:以下转自Spring官方文档,用的版本为4.3.11版本. 一.引用官方文档 2.2.1核心集装箱 所述核心容器由以下部分组成spring-core, spring-beans,spring-c ...

  5. 2、ASP.NET MVC入门到精通——Entity Framework入门

    实体框架(Entity Framework)简介 简称EF 与ADO.NET关系 ADO.NET Entity Framework 是微软以 ADO.NET 为基础所发展出来的对象关系对应 (O/R ...

  6. C# 泛型简介

    摘要:本文讨论泛型处理的问题空间.它们的实现方式.该编程模型的好处,以及独特的创新(例如,约束.一般方法和委托以及一般继承).此外,本文还讨论 .NET Framework 如何利用泛型. 下载 Ge ...

  7. Robot Framework测试框架学习笔记

    一.Robot Framework框架简介         Robot Framework是一种基于Python的可扩展关键字驱动自动化测试框架,通常用于端到端的可接收测试和可接收测试驱动的开发.可以 ...

  8. 实体框架(Entity Framework)

    实体框架(Entity Framework) 实体框架(Entity Framework)简介 ADO.NET Entity Framework 是微软以 ADO.NET 为基础所发展出来的对象关系对 ...

  9. 七、Framework类库

    1.Framework类库简介 .Net Framework类库包含Framework类库(Framework Class Library,FCL).FCL是一组DLL程序集的统称,其中含有数千个类型 ...

  10. 小试---EF5.0简介

    简介 实体框架Entity Framework 是 ADO.NET 中的一组支持开发面向数据的软件应用程序的技术.是微软的一个ORM框架.简单的说就是把关系型数据库映射成面向对象模型. 一篇更加详细的 ...

随机推荐

  1. 【Altium Designer】五颜六色标识的PCB布板(增强PCB可视化特性)

    出现上图中五颜六色的网络标识,对比各个网络会更加清晰,实现步骤如下 打开或关闭  View--->Net Color Override Active   快捷键     F5 设置 displa ...

  2. 神经网络优化篇:详解局部最优的问题(The problem of local optima)

    局部最优的问题 在深度学习研究早期,人们总是担心优化算法会困在极差的局部最优,不过随着深度学习理论不断发展,对局部最优的理解也发生了改变.向展示一下现在怎么看待局部最优以及深度学习中的优化问题. 这是 ...

  3. [转帖]TLS/SSL (Schannel SSP) 中的密码套件

    https://learn.microsoft.com/zh-cn/windows/win32/secauthn/cipher-suites-in-schannel 密码套件是一组加密算法. TLS/ ...

  4. [转帖]关于虚拟化中cpu的指令集SSE 4.2的不支持

    背景: 局域网中有两台服务器proxmox进行了虚拟化,跑一些测试应用.今天正好想要安装一下clickhouse跑一下.安装前准备: 测试服务器是否支持sse 4.2指令集-如下 [root@slav ...

  5. [转帖]十大主流Nehalem服务器横评(多图)

    https://server.51cto.com/article/201820.html 作者:佚名2010-05-25 09:52:27 运维服务器运维 除了我们的两台基准服务器之外,本次横向评测活 ...

  6. [转帖]Intel、海光、鲲鹏920、飞腾2500 CPU性能对比

    https://plantegg.github.io/2021/06/18/%E5%87%A0%E6%AC%BECPU%E6%80%A7%E8%83%BD%E5%AF%B9%E6%AF%94/ Int ...

  7. WebAssembly入门笔记[1]:与JavaScript的交互

    前一阵子利用Balazor开发了一个NuGet站点,对WebAssembly进行了初步的了解,觉得挺有意思.在接下来的一系列文章中,我们将通过实例演示的方式介绍WebAssembly的一些基本概念和编 ...

  8. SignalR系列文章02---netCoreMvc创建Demo

    1.  新建.net core MVC项目,并引入nuget包 2.  添加客户端库 3.  修改startUp.cs文件,增加services.AddSignalR();和endpoints.Map ...

  9. YiGo学习(一)YiGo介绍

    YiGo是一种开发语言,是一种面向业务人员进行管理信息系统开发的特定领域语言,属于第五代计算机语言.它可以在图形化界面上进行选择.拖拽等动作进行管理业务建模,通过建立对系统需求的描述模型由计算机自动生 ...

  10. 几种方法验证unity是否为development build

    我在月初接入了uwa的性能测试SDK,需要提交一个development build的游戏安装包给uwa进行真人真机测试,本文说下如何判断安装包是否为development build. 直观上判断 ...