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简介

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

  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. 百度网盘(百度云)SVIP超级会员共享账号每日更新(2023.11.30)

    一.百度网盘SVIP超级会员共享账号 可能很多人不懂这个共享账号是什么意思,小编在这里给大家做一下解答. 我们多知道百度网盘很大的用处就是类似U盘,不同的人把文件上传到百度网盘,别人可以直接下载,避免 ...

  2. [转帖]火狐URL默认打开为HTTPS,切换成http形式

    火狐在当前及未来版本默认URL采用HTTPS进行链接,但个人习惯,某些网站不是https,改http在响应超时状态也会切成https,将默认为http. edge,chrome 依然还是http为主要 ...

  3. [转帖]TiDB 统计数据库占用大小的N种方法

    TiDB之路2022-03-06 3896 前言 TiDB 如何统计数据库占用空间大小 四种方法 方法一 TiDB 统计数据库占用大小的第一种方法是监控.通过查看 {cluster-name} - O ...

  4. [转帖]kafka漏洞升级记录,基于SASL JAAS 配置和 SASL 协议,涉及版本3.4以下

    攻击者可以使用基于 SASL JAAS 配置和 SASL 协议的任意 Kafka 客户端,在对 Kafka Connect worker 创建或修改连接器时,通过构造特殊的配置,进行 JNDI 注入. ...

  5. 申威下单盘SSD与四块盘RAID5的性能测试结果

    申威下单盘SSD与四块盘RAID5的性能测试结果 背景 背景不在说了 申威服务器.. 结论 天坑 做了raid写入性能下降明显. 充分怀疑驱动不行. 四快盘的raid5 跟单盘的读几乎没区别. 感觉这 ...

  6. [转帖]LVS入门篇(三)之LVS的工作模式和调度算法

    LVS入门篇(三)之LVS的工作模式和调度算法 https://www.cnblogs.com/linuxk/p/9358512.html 1.NAT模型 (1)原理图: ①.客户端(200.10.1 ...

  7. [转帖]【杂学第十二篇】oracledb_exporter监听oracle19c数据库出现libclntsh、ORA-12162、ORA-00942异常解决

    http://www.taodudu.cc/news/show-4845374.html docker run -d --name oracledb_exporter --restart=always ...

  8. es6新增的运算符-链判断运算符的诞生[?.]和null的判断运算符??

    指数运算符 ** console.log(2 ** 2 ) //4 console.log(2 ** 3 ) //8 console.log(2 ** 4) //16 链判断运算符的诞生(?.) 在实 ...

  9. vue组件上绑定原生事件

    将原生事件绑定在组件上 .native 修饰符: 子组件 <template> <div class="demo"> <h2>我是子组件< ...

  10. input框数据回填(回显)

    <el-form :model="TeacherruleForm" label-width="80px"> <el-form-item lab ...