diff --git a/services/core/java/com/android/server/am/ActivityStackSupervisor.java b/services/core/java/com/android/server/am/ActivityStackSupervisor.java index c143474ce0c80..9562f94f5015e 100644 --- a/services/core/java/com/android/server/am/ActivityStackSupervisor.java +++ b/services/core/java/com/android/server/am/ActivityStackSupervisor.java @@ -400,7 +400,7 @@ public final class ActivityStackSupervisor implements DisplayListener { // The default minimal size that will be used if the activity doesn't specify its minimal size. // It will be calculated when the default display gets added. - private int mDefaultMinimalSizeOfResizeableTask = -1; + int mDefaultMinimalSizeOfResizeableTask = -1; // Whether tasks have moved and we need to rank the tasks before next OOM scoring private boolean mTaskLayersChanged = true; @@ -2039,8 +2039,6 @@ public final class ActivityStackSupervisor implements DisplayListener { return true; } - adjustForMinimalTaskDimensions(task, bounds); - // If this is a forced resize, let it go through even if the bounds is not changing, // as we might need a relayout due to surface size change (to/from fullscreen). final boolean forced = (resizeMode & RESIZE_MODE_FORCED) != 0; @@ -2074,7 +2072,7 @@ public final class ActivityStackSupervisor implements DisplayListener { // to be relaunched due to configuration change. boolean kept = true; if (overrideConfig != null) { - ActivityRecord r = task.topRunningActivityLocked(); + final ActivityRecord r = task.topRunningActivityLocked(); if (r != null) { final ActivityStack stack = task.stack; kept = stack.ensureActivityConfigurationLocked(r, 0, preserveWindow); @@ -2085,44 +2083,12 @@ public final class ActivityStackSupervisor implements DisplayListener { } } } - mWindowManager.resizeTask(task.taskId, bounds, task.mOverrideConfig, kept, forced); + mWindowManager.resizeTask(task.taskId, task.mBounds, task.mOverrideConfig, kept, forced); Trace.traceEnd(TRACE_TAG_ACTIVITY_MANAGER); return kept; } - private void adjustForMinimalTaskDimensions(TaskRecord task, Rect bounds) { - if (bounds == null) { - return; - } - int minimalSize = task.mMinimalSize == -1 ? mDefaultMinimalSizeOfResizeableTask - : task.mMinimalSize; - final boolean adjustWidth = minimalSize > bounds.width(); - final boolean adjustHeight = minimalSize > bounds.height(); - if (!(adjustWidth || adjustHeight)) { - return; - } - Rect taskBounds = task.mBounds; - if (adjustWidth) { - if (taskBounds != null && bounds.right == taskBounds.right) { - bounds.left = bounds.right - minimalSize; - } else { - // Either left bounds match, or neither match, or the previous bounds were - // fullscreen and we default to keeping left. - bounds.right = bounds.left + minimalSize; - } - } - if (adjustHeight) { - if (taskBounds != null && bounds.bottom == taskBounds.bottom) { - bounds.top = bounds.bottom - minimalSize; - } else { - // Either top bounds match, or neither match, or the previous bounds were - // fullscreen and we default to keeping top. - bounds.bottom = bounds.top + minimalSize; - } - } - } - ActivityStack createStackOnDisplay(int stackId, int displayId, boolean onTop) { ActivityDisplay activityDisplay = mActivityDisplays.get(displayId); if (activityDisplay == null) { diff --git a/services/core/java/com/android/server/am/TaskRecord.java b/services/core/java/com/android/server/am/TaskRecord.java index add1b9642affd..37a549a960a79 100644 --- a/services/core/java/com/android/server/am/TaskRecord.java +++ b/services/core/java/com/android/server/am/TaskRecord.java @@ -245,6 +245,7 @@ final class TaskRecord { Rect mBounds = null; private final Rect mTmpStableBounds = new Rect(); private final Rect mTmpNonDecorBounds = new Rect(); + private final Rect mTmpRect = new Rect(); private final Rect mTmpRect2 = new Rect(); // Last non-fullscreen bounds the task was launched in or resized to. @@ -1314,6 +1315,38 @@ final class TaskRecord { return task; } + private void adjustForMinimalTaskDimensions(Rect bounds) { + if (bounds == null) { + return; + } + final int minimalSize = mMinimalSize == -1 + ? mService.mStackSupervisor.mDefaultMinimalSizeOfResizeableTask : mMinimalSize; + final boolean adjustWidth = minimalSize > bounds.width(); + final boolean adjustHeight = minimalSize > bounds.height(); + if (!(adjustWidth || adjustHeight)) { + return; + } + + if (adjustWidth) { + if (mBounds != null && bounds.right == mBounds.right) { + bounds.left = bounds.right - minimalSize; + } else { + // Either left bounds match, or neither match, or the previous bounds were + // fullscreen and we default to keeping left. + bounds.right = bounds.left + minimalSize; + } + } + if (adjustHeight) { + if (mBounds != null && bounds.bottom == mBounds.bottom) { + bounds.top = bounds.bottom - minimalSize; + } else { + // Either top bounds match, or neither match, or the previous bounds were + // fullscreen and we default to keeping top. + bounds.bottom = bounds.top + minimalSize; + } + } + } + /** * Update task's override configuration based on the bounds. * @param bounds The bounds of the task. @@ -1346,15 +1379,17 @@ final class TaskRecord { mBounds = null; mOverrideConfig = Configuration.EMPTY; } else { + mTmpRect.set(bounds); + adjustForMinimalTaskDimensions(mTmpRect); if (mBounds == null) { - mBounds = new Rect(bounds); + mBounds = new Rect(mTmpRect); } else { - mBounds.set(bounds); + mBounds.set(mTmpRect); } if (stack == null || StackId.persistTaskBounds(stack.mStackId)) { mLastNonFullscreenBounds = mBounds; } - mOverrideConfig = calculateOverrideConfig(bounds, insetBounds); + mOverrideConfig = calculateOverrideConfig(mTmpRect, insetBounds); } if (mFullscreen != oldFullscreen) {