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. 【OpenVINO】基于 OpenVINO C# API 部署 RT-DETR 模型

      RT-DETR是在DETR模型基础上进行改进的,一种基于 DETR 架构的实时端到端检测器,它通过使用一系列新的技术和算法,实现了更高效的训练和推理,在前文我们发表了<基于 OpenVINO ...

  2. [转帖]Oracle中INITRANS和MAXTRANS参数

    每个块都有一个块首部.这个块首部中有一个事务表.事务表中会建立一些条目来描述哪些事务将块上的哪些行/元素锁定.这个事务表的初始大小由对象的INITRANS 设置指定.对于表,这个值默认为2(索引的IN ...

  3. [转帖]FIO 存储性能压测

    一. FIO简介 FIO 是一个多线程IO生成工具,可以生成多种IO模式(随机.顺序.读.写四大类),用来测试磁盘设备的性能.GFIO是FIO的图形监测工具,它提供了图形界面的参数配置,和性能监测图像 ...

  4. [转帖]Linux性能分析:理解系统平均负载

    Linux系统中,平均负载是指单位时间内,处于可运行状态和不可中断状态的进程数.它不仅包括了正在使用CPU的进程,也包括处于不可打断的睡眠状态的进程-它们是在等待其它系统资源如磁盘 I/O 等的进程. ...

  5. [转帖]docker使用buildx构建多平台(x86,arm64)构架镜像

    https://blog.csdn.net/atzqtzq/article/details/128583331 配置文件激活buildx docker目前使用版本为Server Version: 20 ...

  6. [转帖]2.20 Native Operating System Tools

    https://docs.oracle.com/javase/8/docs/technotes/guides/troubleshoot/tooldescr020.html#BABBHHIE 2.20  ...

  7. [转帖] Linux命令拾遗-剖析工具

    https://www.cnblogs.com/codelogs/p/16060472.html 简介# 这是Linux命令拾遗系列的第五篇,本篇主要介绍Linux中常用的线程与内存剖析工具,以及更高 ...

  8. 最佳实践:基于vite3的monorepo前端工程搭建

    一.技术栈选择 1.代码库管理方式-Monorepo: 将多个项目存放在同一个代码库中 选择理由1:多个应用(可以按业务线产品粒度划分)在同一个repo管理,便于统一管理代码规范.共享工作流 选择理由 ...

  9. vue动画 <transition-group> 使用半场动画

    <style> /* 给动画添加一组过度效果 */ .v-enter, .v-leave-to { opacity: 0.8; /* 从右向左进入 */ transform: transl ...

  10. Gin 框架之Cookie与Session

    目录 一.Cookie和Session的由来 二.Cookie简介 1. 什么是Cookie 2. Cookie规范 3. 安全性 4. Cookie 关键配置 三.Session简介 1. 什么是S ...