【framework】TaskStack简介
1 前言
TaskStack 用于管理 app,一般一个应用程序对应一个 TaskStack,其父容器为 TaskStackContainers(DisplayContent 的子容器),子容器为 Task。
关于其父类及祖父类的介绍,见 → WindowContainer简介、ConfigurationContainer简介。

2 源码
源码地址→/frameworks/base/services/core/java/com/android/server/wm/TaskStack.java
(1)类定义
//Task 为子节点类型
public class TaskStack extends WindowContainer<Task> implements BoundsAnimationTarget, ConfigurationContainerListener
(2)主要属性
final int mStackId
private final Rect mAdjustedBounds = new Rect()
private final Rect mFullyAdjustedImeBounds = new Rect()
private SurfaceControl mAnimationBackgroundSurface
private WindowStateAnimator mAnimationBackgroundAnimator
final AppTokenList mExitingAppTokens = new AppTokenList()
private WindowState mImeWin
private Rect mBoundsAnimationTarget = new Rect()
private Rect mBoundsAnimationSourceHintBounds = new Rect()
ActivityStack mActivityStack
private final Point mLastSurfaceSize = new Point()
(3)构造方法
TaskStack(WindowManagerService service, int stackId, ActivityStack activityStack) {
super(service);
mStackId = stackId;
mActivityStack = activityStack;
activityStack.registerConfigurationChangeListener(this);
...
}
(4)Task 相关
//mChildren.get(mChildren.size() - 1)
Task findHomeTask()
//addTask(task, position, task.showForAllUsers(), true)
void addTask(Task task, int position)
//positionChildAt(position, task, moveParents, showForAllUsers)
void addTask(Task task, int position, boolean showForAllUsers, boolean moveParents)
//mExitingAppTokens.get(i).getTask() == task ? mExitingAppTokens.remove(i)
void removeChild(Task task)
//removeImmediately()
void removeIfPossible()
//super.removeImmediately()
void removeImmediately()
//child.positionAt(position)
void positionChildAt(Task child, int position)
//positionChildAt(POSITION_TOP, child, includingParents)
void positionChildAtTop(Task child, boolean includingParents)
//positionChildAt(POSITION_BOTTOM, child, includingParents)
void positionChildAtBottom(Task child, boolean includingParents)
//positionChildAt(position, child, includingParents, child.showForAllUsers())
void positionChildAt(int position, Task child, boolean includingParents)
//mChildren.get(i).mUserId == userId ? true : false
boolean hasTaskForUser(int userId)
//mChildren.get(i).prepareFreezingBounds()
void prepareFreezingTaskBounds()
(5)Stack 相关
//inPinnedWindowingMode() ? (int)Math.ceil(mWmService.dipToPixel(PINNED_WINDOWING_MODE_ELEVATION_IN_DIP, displayMetrics) * 2) : 0
int getStackOutset()
//return displayContentRect.top + (int)((originalStackBottom - displayContentRect.top) * ADJUSTED_STACK_FRACTION_MIN)
int getMinTopStackBottom(final Rect displayContentRect, int originalStackBottom)
(6)Bounds 相关
//super.setBounds(bounds)
public int setBounds(Rect bounds)
//out.set(super.getBounds())
void getRawBounds(Rect out)
//super.getBounds()
Rect getRawBounds()
//bounds.set(super.getBounds())
public void getBounds(Rect bounds)
//super.getBounds()
public Rect getBounds()
//outBounds.set(mBoundsAnimationTarget)
void getFinalAnimationBounds(Rect outBounds)
//outBounds.set(mBoundsAnimationSourceHintBounds)
void getFinalAnimationSourceHintBounds(Rect outBounds)
//getBounds(outBounds)
void getAnimationOrCurrentBounds(Rect outBounds)
//matchParentBounds()
boolean fillsParent()
//获取包含指定坐标的 task
void findTaskForResizePoint(int x, int y, int delta, DisplayContent.TaskForResizePointSearchResult results)
//设置不可触摸区域
void setTouchExcludeRegion(Task focusedTask, int delta, Region touchExcludeRegion, Rect contentRect, Rect postExclude)
(7)Display 相关
//final DisplayContent targetDc = mWmService.mRoot.getDisplayContent(displayId)
//targetDc.moveStackToDisplay(this, onTop)
void reparent(int displayId, Rect outStackBounds, boolean onTop)
//final int outset = getStackOutset();
//outPos.x -= outset; outPos.y -= outset
void getRelativeDisplayedPosition(Point outPos)
//super.onDisplayChanged(dc)
void onDisplayChanged(DisplayContent dc)
//return mDisplayContent.getDisplayInfo()
public DisplayInfo getDisplayInfo()
//return mDisplayContent != null
public boolean isAttached()
(8)Surface 相关
//mLastSurfaceSize
Point getLastSurfaceSize()
//super.prepareSurfaces()
void prepareSurfaces()
(9)动画相关
//hideAnimationSurface()
void resetAnimationBackgroundAnimator()
//mAnimationBackgroundAnimator = winAnimator
void setAnimationBackground(WindowStateAnimator winAnimator, int color)
//mChildren.get(i).isTaskAnimating()
boolean isTaskAnimating()
public void onPipAnimationEndResize()
//return mBoundsAnimating
public boolean isForceScaled()
//return mBoundsAnimating
public boolean isAnimatingBounds()
//return mBoundsAnimatingToFullscreen
public boolean lastAnimatingBoundsWasToFullscreen()
//return isAnimatingBounds() && lastAnimatingBoundsWasToFullscreen()
public boolean isAnimatingBoundsToFullscreen()
public boolean onAnimationStart(boolean schedulePipModeChangedCallback, boolean forceUpdate, int animationType)
public void onAnimationEnd(boolean schedulePipModeChangedCallback, Rect finalStackSize, boolean moveToFullscreen)
//return mAnimatingAppWindowTokenRegistry
AnimatingAppWindowTokenRegistry getAnimatingAppWindowTokenRegistry()
(10)Dock 相关
//DockedDividerUtils.calculateBoundsForPosition(target.position, dockSide, outBounds, displayWidth, displayHeight, dividerSize)
void snapDockedStackAfterRotation(Configuration parentConfig, DisplayCutout displayCutout, Rect outBounds)
//getStackDockedModeBounds(parentConfig, false, outStackBounds, dockedBounds, mDisplayContent.mDividerControllerLocked.getContentWidth(), dockedOnTopOrLeft)
void getStackDockedModeBoundsLocked(Configuration parentConfig, Rect dockedBounds, Rect currentTempTaskBounds, Rect outStackBounds, Rect outTempTaskBounds)
//getStackDockedModeBoundsLocked(mDisplayContent.getConfiguration(), dockedBounds, null, bounds, tempBounds)
void resetDockedStackToMiddle()
//getDockSide(mDisplayContent.getConfiguration(), getRawBounds())
int getDockSide()
//getDockSide(dc, dc.getConfiguration(), getRawBounds())
int getDockSideForDisplay(DisplayContent dc)
//getDockSide(mDisplayContent, parentConfig, bounds)
int getDockSide(Configuration parentConfig, Rect bounds)
//return mMinimizeAmount != 0f
boolean isAdjustedForMinimizedDockedStack()
//mMinimizeAmount = minimizeAmount
//updateAdjustedBounds()
boolean setAdjustedForMinimizedDock(float minimizeAmount)
//repositionSplitScreenStackAfterRotation(parentConfig, primary, inOutBounds)
//snapDockedStackAfterRotation(parentConfig, cutout, inOutBounds)
void calculateDockedBoundsForConfigChange(Configuration parentConfig, Rect inOutBounds)
(11)输入法相关
//updateAdjustForIme(adjustImeAmount, adjustDividerAmount, true)
void setAdjustedForIme(WindowState imeWin, boolean keepLastAmount)
//mAdjustImeAmount = adjustAmount; mAdjustDividerAmount = adjustDividerAmount;
//updateAdjustedBounds()
boolean updateAdjustForIme(float adjustAmount, float adjustDividerAmount, boolean force)
//mAdjustedForIme
boolean isAdjustedForIme()
//return mImeWin != null && mImeWin.isAnimatingLw()
boolean isAnimatingForIme()
//mImeWin = null; mImeGoingAway = false; mAdjustImeAmount = 0f; mAdjustDividerAmount = 0f
//updateAdjustedBounds()
void resetAdjustedForIme(boolean adjustBoundsNow)
//mChildren.get(i).setDragResizing(true, DRAG_RESIZE_MODE_DOCKED_DIVIDER)
//mChildren.get(i).setWaitingForDrawnIfResizingChanged()
void beginImeAdjustAnimation()
//mChildren.get(j).setDragResizing(false, DRAG_RESIZE_MODE_DOCKED_DIVIDER)
void endImeAdjustAnimation()
//task.alignToAdjustedBounds(mAdjustedBounds, insetBounds, getDockSide() == DOCKED_TOP)
void applyAdjustForImeIfNeeded(Task task)
(12)画中画(PictureInPicture)
Rect getPictureInPictureBounds(float aspectRatio, Rect stackBounds)
void setPictureInPictureAspectRatio(float aspectRatio)
void setPictureInPictureActions(List<RemoteAction> actions)
(13)Pinned 相关
//getPendingTransaction().setAlpha(sc, mCancelCurrentBoundsAnimation ? 1 : alpha)
public boolean setPinnedStackAlpha(float alpha)
//mWmService.mActivityTaskManager.resizePinnedStack(stackBounds, tempTaskBounds)
public boolean setPinnedStackSize(Rect stackBounds, Rect tempTaskBounds)
return mBoundsAnimating && mCancelCurrentBoundsAnimation
public boolean pinnedStackResizeDisallowed()
void animateResizePinnedStack(Rect toBounds, Rect sourceHintBounds, int animationDuration, boolean fromFullscreen)
//inOutBounds.set(mTmpRect3)
boolean calculatePinnedBoundsForConfigChange(Rect inOutBounds)
(14)dim 相关
//getBounds(out)
public void getDimBounds(Rect out)
//mDimmer.dimAbove(getPendingTransaction(), alpha)
void dim(float alpha)
//mDimmer.stopDim(getPendingTransaction())
void stopDimming()
(15)其他
//return (canSpecifyOrientation()) ? super.getOrientation() : SCREEN_ORIENTATION_UNSET
int getOrientation()
//updateSurfaceSize(getPendingTransaction())
public void onConfigurationChanged(Configuration newParentConfig)
//mWmService.mWindowPlacerLocked.requestTraversal()
void onParentChanged()
//return (mBoundsAnimatingRequested || mBoundsAnimating)
public boolean deferScheduleMultiWindowModeChanged()
boolean shouldIgnoreInput()
public boolean shouldDeferStartOnMoveToFullscreen()
void switchUser()
int getMinimizeDistance()
//getDisplayContent().mBoundsAnimationController.onAllWindowsDrawn()
void onAllWindowsDrawn()
boolean checkCompleteDeferredRemoval()
【framework】TaskStack简介的更多相关文章
- 实体框架(Entity Framework)简介
实体框架(Entity Framework)简介 简称EF,与ADO.NET关系 ADO.NET Entity Framework 是微软以 ADO.NET 为基础所发展出来的对象关系对应 (O/R ...
- iOS - 系统经常使用框架(framework)的简介
系统框架(framework)的简介 ImageIO - 该框架的接口可用于导入或导出图像数据及图像元数据 CoreTelephony - 获取IMSI号,SIM卡背面的号码是SIM卡的电子串号, ...
- .NET Entity Framework入门简介及简单操作
Entity Framework是微软借鉴ORM思想开发自己的一个ORM框架. ORM就是将数据库表与实体对象(相当于三层中的Model类)相互映射的一种思想. 最大的优点就是非常方便的跨数据库平台. ...
- Spring Framework体系结构简介
说明:以下转自Spring官方文档,用的版本为4.3.11版本. 一.引用官方文档 2.2.1核心集装箱 所述核心容器由以下部分组成spring-core, spring-beans,spring-c ...
- 2、ASP.NET MVC入门到精通——Entity Framework入门
实体框架(Entity Framework)简介 简称EF 与ADO.NET关系 ADO.NET Entity Framework 是微软以 ADO.NET 为基础所发展出来的对象关系对应 (O/R ...
- C# 泛型简介
摘要:本文讨论泛型处理的问题空间.它们的实现方式.该编程模型的好处,以及独特的创新(例如,约束.一般方法和委托以及一般继承).此外,本文还讨论 .NET Framework 如何利用泛型. 下载 Ge ...
- Robot Framework测试框架学习笔记
一.Robot Framework框架简介 Robot Framework是一种基于Python的可扩展关键字驱动自动化测试框架,通常用于端到端的可接收测试和可接收测试驱动的开发.可以 ...
- 实体框架(Entity Framework)
实体框架(Entity Framework) 实体框架(Entity Framework)简介 ADO.NET Entity Framework 是微软以 ADO.NET 为基础所发展出来的对象关系对 ...
- 七、Framework类库
1.Framework类库简介 .Net Framework类库包含Framework类库(Framework Class Library,FCL).FCL是一组DLL程序集的统称,其中含有数千个类型 ...
- 小试---EF5.0简介
简介 实体框架Entity Framework 是 ADO.NET 中的一组支持开发面向数据的软件应用程序的技术.是微软的一个ORM框架.简单的说就是把关系型数据库映射成面向对象模型. 一篇更加详细的 ...
随机推荐
- [转帖]Kafka中offsets.retention.minutes和log.retention.minutes之间的区别
https://www.cnblogs.com/lestatzhang/p/10771115.html 前言 在Kafka中,我们可能会发现两个与retention相关的配置: log.retenti ...
- [转帖]1. awk基础,awk介绍,awk基本语法,直接使用action,打印列,初识列和行,\$0、\$NF、NF,基础示例,begin模式,end模式
文章目录 前言 awk介绍 awk基本语法 直接使用action 打印列 初识列和行 \$0.\$NF.NF 基础示例 初识模式(begin end) 总结 友情链接 前言 本小节是awk基础入门课程 ...
- [转帖]12.24.2 DECIMAL Data Type Characteristics
https://dev.mysql.com/doc/refman/8.0/en/fixed-point-types.html This section discusses the characteri ...
- [转帖]Jmeter学习笔记(六)——使用badboy录制脚本
https://www.cnblogs.com/pachongshangdexuebi/p/11506274.html 1.下载安装 可以去badboy官网下载地址:http://www.badboy ...
- [转帖]实战瓶颈定位-我的MySQL为什么压不上去
https://plantegg.github.io/2023/06/20/%E5%AE%9E%E6%88%98%E7%93%B6%E9%A2%88%E5%AE%9A%E4%BD%8D-%E6%88% ...
- [转帖] Linux命令拾遗-入门篇
https://www.cnblogs.com/codelogs/p/16060394.html 原创:打码日记(微信公众号ID:codelogs),欢迎分享,转载请保留出处. 简介# 之前出过很多和 ...
- Promise.all()方方详解
1.Promise.all()方方详解 Promise.all,只有所有的Promise成功,才能够算作成功,只要有一个失败了,就直接失败: 它包含一个参数,这个参数是指包含多个Promise的数组: ...
- vue mixin混入 全局混入 局部混入
<div id="app"> --{{nameName}} </div> // 全局混入 不需要注册 var m1 = Vue.mixin({ data() ...
- 给python脚本传递命令行参数
记录一下给python脚本传参数的几种方式 最简单的方式 在cmd/bat脚本中调用python脚本传递参数 #传递参数 python test.py arg1 arg2 arg3 #在python中 ...
- centos7下安装postgresql-10.3
centos7下安装pgsql10.3 前言 下载pgsql-10.3 安装 解压 安装基本的工具 编译 安装 创建目录 data.log 加入系统环境变量 增加用户 postgres 并赋权 初始化 ...