From fc48b072e8caa62849ee305f89f38d248d4a1ded Mon Sep 17 00:00:00 2001 From: Winson Date: Thu, 21 Apr 2016 11:20:11 -0700 Subject: [PATCH] Caching the display rect to reduce binder calls. - Only update the display rect and orientation on configuration change. Bug: 28122871 Change-Id: I2e87e7643902d5f45ac4a311109f5e1870f48d3b --- .../android/systemui/recents/RecentsImpl.java | 7 +- .../systemui/recents/model/TaskStack.java | 8 +- .../views/RecentsTransitionHelper.java | 2 +- .../views/TaskStackLayoutAlgorithm.java | 9 +-- .../systemui/recents/views/TaskStackView.java | 74 +++++++++++-------- .../systemui/recents/views/TaskView.java | 45 ++++------- .../recents/views/TaskViewThumbnail.java | 56 ++++++-------- 7 files changed, 94 insertions(+), 107 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/recents/RecentsImpl.java b/packages/SystemUI/src/com/android/systemui/recents/RecentsImpl.java index e62c86e141f62..cf18c41b1cd00 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/RecentsImpl.java +++ b/packages/SystemUI/src/com/android/systemui/recents/RecentsImpl.java @@ -588,6 +588,7 @@ public class RecentsImpl implements ActivityOptions.OnAnimationFinishedListener */ private void updateHeaderBarLayout(TaskStack stack, Rect windowRectOverride) { SystemServicesProxy ssp = Recents.getSystemServices(); + Rect displayRect = ssp.getDisplayRect(); Rect systemInsets = new Rect(); ssp.getStableInsets(systemInsets); Rect windowRect = windowRectOverride != null @@ -608,10 +609,10 @@ public class RecentsImpl implements ActivityOptions.OnAnimationFinishedListener // Rebind the header bar and draw it for the transition stackLayout.setSystemInsets(systemInsets); if (stack != null) { - stackLayout.getTaskStackBounds(windowRect, systemInsets.top, systemInsets.right, - mTaskStackBounds); + stackLayout.getTaskStackBounds(displayRect, windowRect, systemInsets.top, + systemInsets.right, mTaskStackBounds); stackLayout.reset(); - stackLayout.initialize(windowRect, mTaskStackBounds, + stackLayout.initialize(displayRect, windowRect, mTaskStackBounds, TaskStackLayoutAlgorithm.StackState.getStackStateForStack(stack)); mDummyStackView.setTasks(stack, false /* allowNotifyStackChanges */); diff --git a/packages/SystemUI/src/com/android/systemui/recents/model/TaskStack.java b/packages/SystemUI/src/com/android/systemui/recents/model/TaskStack.java index 47995c4b73f3e..32b7a99e3084a 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/model/TaskStack.java +++ b/packages/SystemUI/src/com/android/systemui/recents/model/TaskStack.java @@ -481,8 +481,9 @@ public class TaskStack { * Returns the task stack bounds with the given {@param width} and * {@param height}. */ - public Rect getDockedTaskStackBounds(int width, int height, int dividerSize, Rect insets, - TaskStackLayoutAlgorithm layoutAlgorithm, Resources res, Rect windowRectOut) { + public Rect getDockedTaskStackBounds(Rect displayRect, int width, int height, + int dividerSize, Rect insets, TaskStackLayoutAlgorithm layoutAlgorithm, + Resources res, Rect windowRectOut) { // Calculate the inverse docked task bounds boolean isHorizontalDivision = res.getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT; @@ -499,7 +500,8 @@ public class TaskStack { int top = dockArea.bottom < 1f ? 0 : insets.top; - layoutAlgorithm.getTaskStackBounds(windowRectOut, top, insets.right, taskStackBounds); + layoutAlgorithm.getTaskStackBounds(displayRect, windowRectOut, top, insets.right, + taskStackBounds); return taskStackBounds; } } diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/RecentsTransitionHelper.java b/packages/SystemUI/src/com/android/systemui/recents/views/RecentsTransitionHelper.java index 1238c637e006b..cf35a96b38f77 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/views/RecentsTransitionHelper.java +++ b/packages/SystemUI/src/com/android/systemui/recents/views/RecentsTransitionHelper.java @@ -404,7 +404,7 @@ public class RecentsTransitionHelper { transform.rect.round(taskRect); if (stackView.getStack().getStackFrontMostTask(false /* includeFreeformTasks */) != taskView.getTask()) { - taskRect.bottom = 2 * Recents.getSystemServices().getDisplayRect().height(); + taskRect.bottom = taskRect.top + stackView.getMeasuredHeight(); } return new AppTransitionAnimationSpec(taskView.getTask().key.id, b, taskRect); } diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackLayoutAlgorithm.java b/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackLayoutAlgorithm.java index 0022d66103b10..270d981734fb7 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackLayoutAlgorithm.java +++ b/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackLayoutAlgorithm.java @@ -432,10 +432,9 @@ public class TaskStackLayoutAlgorithm { * Computes the stack and task rects. The given task stack bounds already has the top/right * insets and left/right padding already applied. */ - public void initialize(Rect windowRect, Rect taskStackBounds, StackState state) { - SystemServicesProxy ssp = Recents.getSystemServices(); + public void initialize(Rect displayRect, Rect windowRect, Rect taskStackBounds, + StackState state) { Rect lastStackRect = new Rect(mStackRect); - Rect displayRect = ssp.getDisplayRect(); int topMargin = getScaleForExtent(windowRect, displayRect, mBaseTopMargin, mMinMargin, HEIGHT); int bottomMargin = getScaleForExtent(windowRect, displayRect, mBaseBottomMargin, mMinMargin, @@ -999,14 +998,12 @@ public class TaskStackLayoutAlgorithm { * top and right system insets (but not the bottom inset) and left/right paddings, but _not_ * the top/bottom padding or insets. */ - public void getTaskStackBounds(Rect windowRect, int topInset, int rightInset, + public void getTaskStackBounds(Rect displayRect, Rect windowRect, int topInset, int rightInset, Rect taskStackBounds) { taskStackBounds.set(windowRect.left, windowRect.top + topInset, windowRect.right - rightInset, windowRect.bottom); // Ensure that the new width is at most the smaller display edge size - SystemServicesProxy ssp = Recents.getSystemServices(); - Rect displayRect = ssp.getDisplayRect(); int sideMargin = getScaleForExtent(windowRect, displayRect, mBaseSideMargin, mMinMargin, WIDTH); int targetStackWidth = taskStackBounds.width() - 2 * sideMargin; diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackView.java b/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackView.java index 610b4e104538a..e1e863c20f9c2 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackView.java +++ b/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackView.java @@ -25,6 +25,7 @@ import android.animation.ValueAnimator; import android.annotation.IntDef; import android.content.ComponentName; import android.content.Context; +import android.content.res.Configuration; import android.content.res.Resources; import android.graphics.Canvas; import android.graphics.Rect; @@ -126,48 +127,48 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal /** Update only the layout to the initial state. */ private static final int INITIAL_STATE_UPDATE_LAYOUT_ONLY = 2; - LayoutInflater mInflater; - TaskStack mStack = new TaskStack(); + private LayoutInflater mInflater; + private TaskStack mStack = new TaskStack(); @ViewDebug.ExportedProperty(deepExport=true, prefix="layout_") TaskStackLayoutAlgorithm mLayoutAlgorithm; // The stable layout algorithm is only used to calculate the task rect with the stable bounds - TaskStackLayoutAlgorithm mStableLayoutAlgorithm; + private TaskStackLayoutAlgorithm mStableLayoutAlgorithm; @ViewDebug.ExportedProperty(deepExport=true, prefix="scroller_") - TaskStackViewScroller mStackScroller; + private TaskStackViewScroller mStackScroller; @ViewDebug.ExportedProperty(deepExport=true, prefix="touch_") - TaskStackViewTouchHandler mTouchHandler; - TaskStackAnimationHelper mAnimationHelper; - GradientDrawable mFreeformWorkspaceBackground; - ObjectAnimator mFreeformWorkspaceBackgroundAnimator; - ViewPool mViewPool; + private TaskStackViewTouchHandler mTouchHandler; + private TaskStackAnimationHelper mAnimationHelper; + private GradientDrawable mFreeformWorkspaceBackground; + private ObjectAnimator mFreeformWorkspaceBackgroundAnimator; + private ViewPool mViewPool; - ArrayList mTaskViews = new ArrayList<>(); - ArrayList mCurrentTaskTransforms = new ArrayList<>(); - ArraySet mIgnoreTasks = new ArraySet<>(); - AnimationProps mDeferredTaskViewLayoutAnimation = null; + private ArrayList mTaskViews = new ArrayList<>(); + private ArrayList mCurrentTaskTransforms = new ArrayList<>(); + private ArraySet mIgnoreTasks = new ArraySet<>(); + private AnimationProps mDeferredTaskViewLayoutAnimation = null; @ViewDebug.ExportedProperty(deepExport=true, prefix="doze_") - DozeTrigger mUIDozeTrigger; + private DozeTrigger mUIDozeTrigger; @ViewDebug.ExportedProperty(deepExport=true, prefix="focused_task_") - Task mFocusedTask; + private Task mFocusedTask; - int mTaskCornerRadiusPx; + private int mTaskCornerRadiusPx; private int mDividerSize; private int mStartTimerIndicatorDuration; @ViewDebug.ExportedProperty(category="recents") - boolean mTaskViewsClipDirty = true; + private boolean mTaskViewsClipDirty = true; @ViewDebug.ExportedProperty(category="recents") - boolean mAwaitingFirstLayout = true; + private boolean mAwaitingFirstLayout = true; @ViewDebug.ExportedProperty(category="recents") @InitialStateAction - int mInitialState = INITIAL_STATE_UPDATE_ALL; + private int mInitialState = INITIAL_STATE_UPDATE_ALL; @ViewDebug.ExportedProperty(category="recents") - boolean mInMeasureLayout = false; + private boolean mInMeasureLayout = false; @ViewDebug.ExportedProperty(category="recents") - boolean mEnterAnimationComplete = false; + private boolean mEnterAnimationComplete = false; @ViewDebug.ExportedProperty(category="recents") - boolean mTouchExplorationEnabled; + private boolean mTouchExplorationEnabled; @ViewDebug.ExportedProperty(category="recents") boolean mScreenPinningEnabled; @@ -183,12 +184,17 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal // The current window bounds are dynamic and may change as the user drags and drops @ViewDebug.ExportedProperty(category="recents") private Rect mWindowRect = new Rect(); + // The current display bounds + @ViewDebug.ExportedProperty(category="recents") + private Rect mDisplayRect = new Rect(); + // The current display orientation + @ViewDebug.ExportedProperty(category="recents") + private int mDisplayOrientation = Configuration.ORIENTATION_UNDEFINED; private Rect mTmpRect = new Rect(); private ArrayMap mTmpTaskViewMap = new ArrayMap<>(); private List mTmpTaskViews = new ArrayList<>(); private TaskViewTransform mTmpTransform = new TaskViewTransform(); - private ArrayList mTmpTaskTransforms = new ArrayList<>(); private int[] mTmpIntPair = new int[2]; private boolean mResetToInitialStateWhenResized; private int mLastWidth; @@ -248,6 +254,8 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal mTaskCornerRadiusPx = res.getDimensionPixelSize( R.dimen.recents_task_view_rounded_corners_radius); mDividerSize = ssp.getDockedDividerSize(context); + mDisplayOrientation = Utilities.getAppConfiguration(mContext).orientation; + mDisplayRect = ssp.getDisplayRect(); int taskBarDismissDozeDelaySeconds = getResources().getInteger( R.integer.recents_task_bar_dismiss_delay_seconds); @@ -1150,7 +1158,7 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal // Update the stable stack bounds, but only update the current stack bounds if the stable // bounds have changed. This is because we may get spurious measures while dragging where // our current stack bounds reflect the target drop region. - mLayoutAlgorithm.getTaskStackBounds(new Rect(0, 0, width, height), + mLayoutAlgorithm.getTaskStackBounds(mDisplayRect, new Rect(0, 0, width, height), mLayoutAlgorithm.mSystemInsets.top, mLayoutAlgorithm.mSystemInsets.right, mTmpRect); if (!mTmpRect.equals(mStableStackBounds)) { mStableStackBounds.set(mTmpRect); @@ -1160,9 +1168,9 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal } // Compute the rects in the stack algorithm - mStableLayoutAlgorithm.initialize(mStableWindowRect, mStableStackBounds, + mStableLayoutAlgorithm.initialize(mDisplayRect, mStableWindowRect, mStableStackBounds, TaskStackLayoutAlgorithm.StackState.getStackStateForStack(mStack)); - mLayoutAlgorithm.initialize(mWindowRect, mStackBounds, + mLayoutAlgorithm.initialize(mDisplayRect, mWindowRect, mStackBounds, TaskStackLayoutAlgorithm.StackState.getStackStateForStack(mStack)); updateLayoutAlgorithm(false /* boundScroll */); @@ -1538,7 +1546,7 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal private void bindTaskView(TaskView tv, Task task) { // Rebind the task and request that this task's data be filled into the TaskView - tv.onTaskBound(task); + tv.onTaskBound(task, mTouchExplorationEnabled, mDisplayOrientation, mDisplayRect); // Load the task data Recents.getTaskLoader().loadTaskData(task); @@ -1802,11 +1810,11 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal int height = getMeasuredHeight(); height -= systemInsets.bottom; systemInsets.bottom = 0; - mStackBounds.set(dockState.getDockedTaskStackBounds(getMeasuredWidth(), + mStackBounds.set(dockState.getDockedTaskStackBounds(mDisplayRect, getMeasuredWidth(), height, mDividerSize, systemInsets, mLayoutAlgorithm, getResources(), mWindowRect)); mLayoutAlgorithm.setSystemInsets(systemInsets); - mLayoutAlgorithm.initialize(mWindowRect, mStackBounds, + mLayoutAlgorithm.initialize(mDisplayRect, mWindowRect, mStackBounds, TaskStackLayoutAlgorithm.StackState.getStackStateForStack(mStack)); updateLayoutAlgorithm(true /* boundScroll */); ignoreTaskOverrides = true; @@ -1817,7 +1825,7 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal mStackBounds.set(mStableStackBounds); removeIgnoreTask(event.task); mLayoutAlgorithm.setSystemInsets(mStableLayoutAlgorithm.mSystemInsets); - mLayoutAlgorithm.initialize(mWindowRect, mStackBounds, + mLayoutAlgorithm.initialize(mDisplayRect, mWindowRect, mStackBounds, TaskStackLayoutAlgorithm.StackState.getStackStateForStack(mStack)); updateLayoutAlgorithm(true /* boundScroll */); addIgnoreTask(event.task); @@ -1960,6 +1968,10 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal } public final void onBusEvent(ConfigurationChangedEvent event) { + if (event.fromDeviceOrientationChange) { + mDisplayOrientation = Utilities.getAppConfiguration(mContext).orientation; + mDisplayRect = Recents.getSystemServices().getDisplayRect(); + } reloadOnConfigurationChange(); // Notify the task views of the configuration change so they can reload their resources @@ -2072,6 +2084,8 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal writer.print(" stackBounds="); writer.print(Utilities.dumpRect(mStackBounds)); writer.print(" stableWindow="); writer.print(Utilities.dumpRect(mStableWindowRect)); writer.print(" window="); writer.print(Utilities.dumpRect(mWindowRect)); + writer.print(" display="); writer.print(Utilities.dumpRect(mDisplayRect)); + writer.print(" orientation="); writer.print(mDisplayOrientation); writer.print(" [0x"); writer.print(id); writer.print("]"); writer.println(); diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/TaskView.java b/packages/SystemUI/src/com/android/systemui/recents/views/TaskView.java index 7ea70b587fd70..1d476c60309b8 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/views/TaskView.java +++ b/packages/SystemUI/src/com/android/systemui/recents/views/TaskView.java @@ -126,21 +126,21 @@ public class TaskView extends FixedSizeFrameLayout implements Task.TaskCallbacks }; @ViewDebug.ExportedProperty(category="recents") - float mDimAlpha; - float mActionButtonTranslationZ; + private float mDimAlpha; + private float mActionButtonTranslationZ; @ViewDebug.ExportedProperty(deepExport=true, prefix="task_") - Task mTask; + private Task mTask; @ViewDebug.ExportedProperty(category="recents") - boolean mTaskDataLoaded; + private boolean mTaskDataLoaded; @ViewDebug.ExportedProperty(category="recents") - boolean mClipViewInStack = true; + private boolean mClipViewInStack = true; @ViewDebug.ExportedProperty(category="recents") - boolean mTouchExplorationEnabled; + private boolean mTouchExplorationEnabled; @ViewDebug.ExportedProperty(category="recents") - boolean mIsDisabledInSafeMode; + private boolean mIsDisabledInSafeMode; @ViewDebug.ExportedProperty(deepExport=true, prefix="view_bounds_") - AnimateableViewBounds mViewBounds; + private AnimateableViewBounds mViewBounds; private AnimatorSet mTransformAnimation; private ObjectAnimator mDimAnimator; @@ -152,12 +152,12 @@ public class TaskView extends FixedSizeFrameLayout implements Task.TaskCallbacks TaskViewThumbnail mThumbnailView; @ViewDebug.ExportedProperty(deepExport=true, prefix="header_") TaskViewHeader mHeaderView; - View mActionButtonView; - View mIncompatibleAppToastView; - TaskViewCallbacks mCb; + private View mActionButtonView; + private View mIncompatibleAppToastView; + private TaskViewCallbacks mCb; @ViewDebug.ExportedProperty(category="recents") - Point mDownTouchPos = new Point(); + private Point mDownTouchPos = new Point(); private Toast mDisabledAppToast; @@ -196,7 +196,6 @@ public class TaskView extends FixedSizeFrameLayout implements Task.TaskCallbacks */ void onReload(boolean isResumingFromVisible) { resetNoUserInteractionState(); - readSystemFlags(); if (!isResumingFromVisible) { resetViewProperties(); } @@ -212,12 +211,6 @@ public class TaskView extends FixedSizeFrameLayout implements Task.TaskCallbacks return mViewBounds; } - @Override - protected void onAttachedToWindow() { - super.onAttachedToWindow(); - readSystemFlags(); - } - @Override protected void onFinishInflate() { // Bind the views @@ -598,12 +591,14 @@ public class TaskView extends FixedSizeFrameLayout implements Task.TaskCallbacks /**** TaskCallbacks Implementation ****/ - public void onTaskBound(Task t) { + public void onTaskBound(Task t, boolean touchExplorationEnabled, int displayOrientation, + Rect displayRect) { SystemServicesProxy ssp = Recents.getSystemServices(); + mTouchExplorationEnabled = touchExplorationEnabled; mTask = t; mTask.addCallback(this); mIsDisabledInSafeMode = !mTask.isSystemApp && ssp.isInSafeMode(); - mThumbnailView.bindToTask(mTask, mIsDisabledInSafeMode); + mThumbnailView.bindToTask(mTask, mIsDisabledInSafeMode, displayOrientation, displayRect); mHeaderView.bindToTask(mTask, mTouchExplorationEnabled, mIsDisabledInSafeMode); if (!t.isDockable && ssp.hasDockedTask()) { @@ -709,12 +704,4 @@ public class TaskView extends FixedSizeFrameLayout implements Task.TaskCallbacks } EventBus.getDefault().unregister(this); } - - /** - * Reads current system flags related to accessibility and screen pinning. - */ - private void readSystemFlags() { - SystemServicesProxy ssp = Recents.getSystemServices(); - mTouchExplorationEnabled = ssp.isTouchExplorationEnabled(); - } } diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/TaskViewThumbnail.java b/packages/SystemUI/src/com/android/systemui/recents/views/TaskViewThumbnail.java index 109dc201d5f9d..3193759509168 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/views/TaskViewThumbnail.java +++ b/packages/SystemUI/src/com/android/systemui/recents/views/TaskViewThumbnail.java @@ -29,16 +29,12 @@ import android.graphics.LightingColorFilter; import android.graphics.Matrix; import android.graphics.Paint; import android.graphics.Rect; -import android.graphics.Region; import android.graphics.Shader; import android.util.AttributeSet; import android.view.View; import android.view.ViewDebug; import com.android.systemui.R; -import com.android.systemui.recents.Recents; -import com.android.systemui.recents.misc.SystemServicesProxy; -import com.android.systemui.recents.misc.Utilities; import com.android.systemui.recents.model.Task; @@ -53,41 +49,38 @@ public class TaskViewThumbnail extends View { private Task mTask; + private int mDisplayOrientation = Configuration.ORIENTATION_UNDEFINED; private Rect mDisplayRect = new Rect(); - private int mOrientation = Configuration.ORIENTATION_UNDEFINED; // Drawing @ViewDebug.ExportedProperty(category="recents") - Rect mTaskViewRect = new Rect(); + private Rect mTaskViewRect = new Rect(); @ViewDebug.ExportedProperty(category="recents") - Rect mThumbnailRect = new Rect(); + private Rect mThumbnailRect = new Rect(); @ViewDebug.ExportedProperty(category="recents") - float mThumbnailScale; - float mFullscreenThumbnailScale; - ActivityManager.TaskThumbnailInfo mThumbnailInfo; + private float mThumbnailScale; + private float mFullscreenThumbnailScale; + private ActivityManager.TaskThumbnailInfo mThumbnailInfo; - int mCornerRadius; + private int mCornerRadius; @ViewDebug.ExportedProperty(category="recents") - float mDimAlpha; - Matrix mScaleMatrix = new Matrix(); - Paint mDrawPaint = new Paint(); - Paint mBgFillPaint = new Paint(); - BitmapShader mBitmapShader; - LightingColorFilter mLightingColorFilter = new LightingColorFilter(0xffffffff, 0); + private float mDimAlpha; + private Matrix mScaleMatrix = new Matrix(); + private Paint mDrawPaint = new Paint(); + private Paint mBgFillPaint = new Paint(); + private BitmapShader mBitmapShader; + private LightingColorFilter mLightingColorFilter = new LightingColorFilter(0xffffffff, 0); - // Task bar clipping, the top of this thumbnail can be clipped against the opaque header - // bar that overlaps this thumbnail - View mTaskBar; - @ViewDebug.ExportedProperty(category="recents") - Rect mClipRect = new Rect(); + // Clip the top of the thumbnail against the opaque header bar that overlaps this view + private View mTaskBar; // Visibility optimization, if the thumbnail height is less than the height of the header // bar for the task view, then just mark this thumbnail view as invisible @ViewDebug.ExportedProperty(category="recents") - boolean mInvisible; + private boolean mInvisible; @ViewDebug.ExportedProperty(category="recents") - boolean mDisabledInSafeMode; + private boolean mDisabledInSafeMode; public TaskViewThumbnail(Context context) { this(context, null); @@ -128,15 +121,6 @@ public class TaskViewThumbnail extends View { updateThumbnailScale(); } - @Override - protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { - super.onMeasure(widthMeasureSpec, heightMeasureSpec); - - SystemServicesProxy ssp = Recents.getSystemServices(); - mOrientation = Utilities.getAppConfiguration(mContext).orientation; - mDisplayRect = ssp.getDisplayRect(); - } - @Override protected void onDraw(Canvas canvas) { if (mInvisible) { @@ -247,7 +231,7 @@ public class TaskViewThumbnail extends View { mThumbnailScale = 0f; } else if (isStackTask) { float invThumbnailScale = 1f / mFullscreenThumbnailScale; - if (mOrientation == Configuration.ORIENTATION_PORTRAIT) { + if (mDisplayOrientation == Configuration.ORIENTATION_PORTRAIT) { if (mThumbnailInfo.screenOrientation == Configuration.ORIENTATION_PORTRAIT) { // If we are in the same orientation as the screenshot, just scale it to the // width of the task view @@ -306,9 +290,11 @@ public class TaskViewThumbnail extends View { /** * Binds the thumbnail view to the task. */ - void bindToTask(Task t, boolean disabledInSafeMode) { + void bindToTask(Task t, boolean disabledInSafeMode, int displayOrientation, Rect displayRect) { mTask = t; mDisabledInSafeMode = disabledInSafeMode; + mDisplayOrientation = displayOrientation; + mDisplayRect.set(displayRect); if (t.colorBackground != 0) { mBgFillPaint.setColor(t.colorBackground); }