【framework】TaskStack简介
1.【framework】ConfigurationContainer简介2.【framework】WindowContainer简介3.【framework】RootWindowContainer简介4.【framework】DisplayContent简介
5.【framework】TaskStack简介
6.【framework】Task简介7.【framework】WMS启动流程8.【framework】View添加过程9.【framework】ATMS启动流程10.【framework】AMS启动流程11.【framework】Activity启动流程12.【framework】应用进程启动流程13.【framework】Surface创建流程14.【framework】IMS启动流程15.【framework】InputChannel创建流程16.【framework】surfaceflinger启动流程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()
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· 上周热点回顾(2.24-3.2)