当前位置:   article > 正文

【framework】TaskStack简介_taskstacklistener

taskstacklistener

1 前言

        TaskStack 用于管理 app,一般一个应用程序对应一个 TaskStack,其父容器为 TaskStackContainers(DisplayContent 的子容器),子容器为 Task。

        关于其父类及祖父类的介绍,见 → WindowContainer简介ConfigurationContainer简介

2 源码

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

        (1)类定义

  1. //Task 为子节点类型
  2. public class TaskStack extends WindowContainer<Task> implements BoundsAnimationTarget, ConfigurationContainerListener

        (2)主要属性

  1. final int mStackId
  2. private final Rect mAdjustedBounds = new Rect()
  3. private final Rect mFullyAdjustedImeBounds = new Rect()
  4. private SurfaceControl mAnimationBackgroundSurface
  5. private WindowStateAnimator mAnimationBackgroundAnimator
  6. final AppTokenList mExitingAppTokens = new AppTokenList()
  7. private WindowState mImeWin
  8. private Rect mBoundsAnimationTarget = new Rect()
  9. private Rect mBoundsAnimationSourceHintBounds = new Rect()
  10. ActivityStack mActivityStack
  11. private final Point mLastSurfaceSize = new Point()

        (3)构造方法

  1. TaskStack(WindowManagerService service, int stackId, ActivityStack activityStack) {
  2. super(service);
  3. mStackId = stackId;
  4. mActivityStack = activityStack;
  5. activityStack.registerConfigurationChangeListener(this);
  6. ...
  7. }

        (4)Task 相关

  1. //mChildren.get(mChildren.size() - 1)
  2. Task findHomeTask()
  3. //addTask(task, position, task.showForAllUsers(), true)
  4. void addTask(Task task, int position)
  5. //positionChildAt(position, task, moveParents, showForAllUsers)
  6. void addTask(Task task, int position, boolean showForAllUsers, boolean moveParents)
  7. //mExitingAppTokens.get(i).getTask() == task ? mExitingAppTokens.remove(i)
  8. void removeChild(Task task)
  9. //removeImmediately()
  10. void removeIfPossible()
  11. //super.removeImmediately()
  12. void removeImmediately()
  13. //child.positionAt(position)
  14. void positionChildAt(Task child, int position)
  15. //positionChildAt(POSITION_TOP, child, includingParents)
  16. void positionChildAtTop(Task child, boolean includingParents)
  17. //positionChildAt(POSITION_BOTTOM, child, includingParents)
  18. void positionChildAtBottom(Task child, boolean includingParents)
  19. //positionChildAt(position, child, includingParents, child.showForAllUsers())
  20. void positionChildAt(int position, Task child, boolean includingParents)
  21. //mChildren.get(i).mUserId == userId ? true : false
  22. boolean hasTaskForUser(int userId)
  23. //mChildren.get(i).prepareFreezingBounds()
  24. void prepareFreezingTaskBounds()

        (5)Stack 相关 

  1. //inPinnedWindowingMode() ? (int)Math.ceil(mWmService.dipToPixel(PINNED_WINDOWING_MODE_ELEVATION_IN_DIP, displayMetrics) * 2) : 0
  2. int getStackOutset()
  3. //return displayContentRect.top + (int)((originalStackBottom - displayContentRect.top) * ADJUSTED_STACK_FRACTION_MIN)
  4. int getMinTopStackBottom(final Rect displayContentRect, int originalStackBottom)

        (6)Bounds 相关

  1. //super.setBounds(bounds)
  2. public int setBounds(Rect bounds)
  3. //out.set(super.getBounds())
  4. void getRawBounds(Rect out)
  5. //super.getBounds()
  6. Rect getRawBounds()
  7. //bounds.set(super.getBounds())
  8. public void getBounds(Rect bounds)
  9. //super.getBounds()
  10. public Rect getBounds()
  11. //outBounds.set(mBoundsAnimationTarget)
  12. void getFinalAnimationBounds(Rect outBounds)
  13. //outBounds.set(mBoundsAnimationSourceHintBounds)
  14. void getFinalAnimationSourceHintBounds(Rect outBounds)
  15. //getBounds(outBounds)
  16. void getAnimationOrCurrentBounds(Rect outBounds)
  17. //matchParentBounds()
  18. boolean fillsParent()
  19. //获取包含指定坐标的 task
  20. void findTaskForResizePoint(int x, int y, int delta, DisplayContent.TaskForResizePointSearchResult results)
  21. //设置不可触摸区域
  22. void setTouchExcludeRegion(Task focusedTask, int delta, Region touchExcludeRegion, Rect contentRect, Rect postExclude)

        (7)Display 相关

  1. //final DisplayContent targetDc = mWmService.mRoot.getDisplayContent(displayId)
  2. //targetDc.moveStackToDisplay(this, onTop)
  3. void reparent(int displayId, Rect outStackBounds, boolean onTop)
  4. //final int outset = getStackOutset();
  5. //outPos.x -= outset; outPos.y -= outset
  6. void getRelativeDisplayedPosition(Point outPos)
  7. //super.onDisplayChanged(dc)
  8. void onDisplayChanged(DisplayContent dc)
  9. //return mDisplayContent.getDisplayInfo()
  10. public DisplayInfo getDisplayInfo()
  11. //return mDisplayContent != null
  12. public boolean isAttached()

        (8)Surface 相关

  1. //mLastSurfaceSize
  2. Point getLastSurfaceSize()
  3. //super.prepareSurfaces()
  4. void prepareSurfaces()

        (9)动画相关

  1. //hideAnimationSurface()
  2. void resetAnimationBackgroundAnimator()
  3. //mAnimationBackgroundAnimator = winAnimator
  4. void setAnimationBackground(WindowStateAnimator winAnimator, int color)
  5. //mChildren.get(i).isTaskAnimating()
  6. boolean isTaskAnimating()
  7. public void onPipAnimationEndResize()
  8. //return mBoundsAnimating
  9. public boolean isForceScaled()
  10. //return mBoundsAnimating
  11. public boolean isAnimatingBounds()
  12. //return mBoundsAnimatingToFullscreen
  13. public boolean lastAnimatingBoundsWasToFullscreen()
  14. //return isAnimatingBounds() && lastAnimatingBoundsWasToFullscreen()
  15. public boolean isAnimatingBoundsToFullscreen()
  16. public boolean onAnimationStart(boolean schedulePipModeChangedCallback, boolean forceUpdate, int animationType)
  17. public void onAnimationEnd(boolean schedulePipModeChangedCallback, Rect finalStackSize, boolean moveToFullscreen)
  18. //return mAnimatingAppWindowTokenRegistry
  19. AnimatingAppWindowTokenRegistry getAnimatingAppWindowTokenRegistry()

        (10)Dock 相关

  1. //DockedDividerUtils.calculateBoundsForPosition(target.position, dockSide, outBounds, displayWidth, displayHeight, dividerSize)
  2. void snapDockedStackAfterRotation(Configuration parentConfig, DisplayCutout displayCutout, Rect outBounds)
  3. //getStackDockedModeBounds(parentConfig, false, outStackBounds, dockedBounds, mDisplayContent.mDividerControllerLocked.getContentWidth(), dockedOnTopOrLeft)
  4. void getStackDockedModeBoundsLocked(Configuration parentConfig, Rect dockedBounds, Rect currentTempTaskBounds, Rect outStackBounds, Rect outTempTaskBounds)
  5. //getStackDockedModeBoundsLocked(mDisplayContent.getConfiguration(), dockedBounds, null, bounds, tempBounds)
  6. void resetDockedStackToMiddle()
  7. //getDockSide(mDisplayContent.getConfiguration(), getRawBounds())
  8. int getDockSide()
  9. //getDockSide(dc, dc.getConfiguration(), getRawBounds())
  10. int getDockSideForDisplay(DisplayContent dc)
  11. //getDockSide(mDisplayContent, parentConfig, bounds)
  12. int getDockSide(Configuration parentConfig, Rect bounds)
  13. //return mMinimizeAmount != 0f
  14. boolean isAdjustedForMinimizedDockedStack()
  15. //mMinimizeAmount = minimizeAmount
  16. //updateAdjustedBounds()
  17. boolean setAdjustedForMinimizedDock(float minimizeAmount)
  18. //repositionSplitScreenStackAfterRotation(parentConfig, primary, inOutBounds)
  19. //snapDockedStackAfterRotation(parentConfig, cutout, inOutBounds)
  20. void calculateDockedBoundsForConfigChange(Configuration parentConfig, Rect inOutBounds)

        (11)输入法相关

  1. //updateAdjustForIme(adjustImeAmount, adjustDividerAmount, true)
  2. void setAdjustedForIme(WindowState imeWin, boolean keepLastAmount)
  3. //mAdjustImeAmount = adjustAmount; mAdjustDividerAmount = adjustDividerAmount;
  4. //updateAdjustedBounds()
  5. boolean updateAdjustForIme(float adjustAmount, float adjustDividerAmount, boolean force)
  6. //mAdjustedForIme
  7. boolean isAdjustedForIme()
  8. //return mImeWin != null && mImeWin.isAnimatingLw()
  9. boolean isAnimatingForIme()
  10. //mImeWin = null; mImeGoingAway = false; mAdjustImeAmount = 0f; mAdjustDividerAmount = 0f
  11. //updateAdjustedBounds()
  12. void resetAdjustedForIme(boolean adjustBoundsNow)
  13. //mChildren.get(i).setDragResizing(true, DRAG_RESIZE_MODE_DOCKED_DIVIDER)
  14. //mChildren.get(i).setWaitingForDrawnIfResizingChanged()
  15. void beginImeAdjustAnimation()
  16. //mChildren.get(j).setDragResizing(false, DRAG_RESIZE_MODE_DOCKED_DIVIDER)
  17. void endImeAdjustAnimation()
  18. //task.alignToAdjustedBounds(mAdjustedBounds, insetBounds, getDockSide() == DOCKED_TOP)
  19. void applyAdjustForImeIfNeeded(Task task)

        (12)画中画(PictureInPicture)

  1. Rect getPictureInPictureBounds(float aspectRatio, Rect stackBounds)
  2. void setPictureInPictureAspectRatio(float aspectRatio)
  3. void setPictureInPictureActions(List<RemoteAction> actions)

        (13)Pinned 相关

  1. //getPendingTransaction().setAlpha(sc, mCancelCurrentBoundsAnimation ? 1 : alpha)
  2. public boolean setPinnedStackAlpha(float alpha)
  3. //mWmService.mActivityTaskManager.resizePinnedStack(stackBounds, tempTaskBounds)
  4. public boolean setPinnedStackSize(Rect stackBounds, Rect tempTaskBounds)
  5. return mBoundsAnimating && mCancelCurrentBoundsAnimation
  6. public boolean pinnedStackResizeDisallowed()
  7. void animateResizePinnedStack(Rect toBounds, Rect sourceHintBounds, int animationDuration, boolean fromFullscreen)
  8. //inOutBounds.set(mTmpRect3)
  9. boolean calculatePinnedBoundsForConfigChange(Rect inOutBounds)

        (14)dim 相关

  1. //getBounds(out)
  2. public void getDimBounds(Rect out)
  3. //mDimmer.dimAbove(getPendingTransaction(), alpha)
  4. void dim(float alpha)
  5. //mDimmer.stopDim(getPendingTransaction())
  6. void stopDimming()

         (15)其他

  1. //return (canSpecifyOrientation()) ? super.getOrientation() : SCREEN_ORIENTATION_UNSET
  2. int getOrientation()
  3. //updateSurfaceSize(getPendingTransaction())
  4. public void onConfigurationChanged(Configuration newParentConfig)
  5. //mWmService.mWindowPlacerLocked.requestTraversal()
  6. void onParentChanged()
  7. //return (mBoundsAnimatingRequested || mBoundsAnimating)
  8. public boolean deferScheduleMultiWindowModeChanged()
  9. boolean shouldIgnoreInput()
  10. public boolean shouldDeferStartOnMoveToFullscreen()
  11. void switchUser()
  12. int getMinimizeDistance()
  13. //getDisplayContent().mBoundsAnimationController.onAllWindowsDrawn()
  14. void onAllWindowsDrawn()
  15. boolean checkCompleteDeferredRemoval()
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/很楠不爱3/article/detail/247590
推荐阅读
相关标签
  

闽ICP备14008679号