From 52642a88f6aa7a1924de2199eaa25fe14ffe4798 Mon Sep 17 00:00:00 2001 From: Riddle Hsu Date: Thu, 25 Feb 2021 20:14:30 +0800 Subject: [PATCH] Remove frozen bounds of activity and task Since unifying of hierarchy, the configuration of Activity and windows are updated together. There won't be temporal inconsistent bounds any more. History commit: 0429f35 Also remove the update of override config even there are no changes. Because performDisplayOverrideConfigUpdate was changed to not always call setNewDisplayOverrideConfiguration for years. So the original purpose of the change is gone. History commit: c646717 Bug: 159103089 Bug: 163976519 Test: CtsWindowManagerDeviceTestCases Change-Id: Ie5711ab4bcff7bf572cf6410df9bc8aaa5688e11 --- .../android/server/windowmanagerservice.proto | 2 +- .../com/android/server/wm/ActivityRecord.java | 69 ------------------- .../server/wm/ActivityTaskManagerService.java | 8 --- .../server/wm/ConfigurationContainer.java | 15 ++-- .../com/android/server/wm/DisplayContent.java | 4 -- .../server/wm/RootWindowContainer.java | 28 ++------ .../core/java/com/android/server/wm/Task.java | 20 ------ .../com/android/server/wm/WindowState.java | 41 +---------- 8 files changed, 18 insertions(+), 169 deletions(-) diff --git a/core/proto/android/server/windowmanagerservice.proto b/core/proto/android/server/windowmanagerservice.proto index ec502c3c272fd..f26bf7cdb6c1d 100644 --- a/core/proto/android/server/windowmanagerservice.proto +++ b/core/proto/android/server/windowmanagerservice.proto @@ -337,7 +337,7 @@ message ActivityRecordProto { optional bool starting_displayed = 20; optional bool starting_moved = 201; optional bool visible_set_from_transferred_starting_window = 22; - repeated .android.graphics.RectProto frozen_bounds = 23; + repeated .android.graphics.RectProto frozen_bounds = 23 [deprecated=true]; optional bool visible = 24; reserved 25; // configuration_container optional IdentifierProto identifier = 26 [deprecated=true]; diff --git a/services/core/java/com/android/server/wm/ActivityRecord.java b/services/core/java/com/android/server/wm/ActivityRecord.java index dd9619ae815ac..83c94d40dd73e 100644 --- a/services/core/java/com/android/server/wm/ActivityRecord.java +++ b/services/core/java/com/android/server/wm/ActivityRecord.java @@ -129,7 +129,6 @@ import static com.android.server.wm.ActivityRecordProto.CLIENT_VISIBLE; import static com.android.server.wm.ActivityRecordProto.DEFER_HIDING_CLIENT; import static com.android.server.wm.ActivityRecordProto.FILLS_PARENT; import static com.android.server.wm.ActivityRecordProto.FRONT_OF_TASK; -import static com.android.server.wm.ActivityRecordProto.FROZEN_BOUNDS; import static com.android.server.wm.ActivityRecordProto.IS_ANIMATING; import static com.android.server.wm.ActivityRecordProto.IS_WAITING_FOR_TRANSITION_START; import static com.android.server.wm.ActivityRecordProto.LAST_ALL_DRAWN; @@ -340,7 +339,6 @@ import java.io.File; import java.io.IOException; import java.io.PrintWriter; import java.lang.ref.WeakReference; -import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Arrays; import java.util.HashSet; @@ -716,9 +714,6 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A // windows, where the app hasn't had time to set a value on the window. int mRotationAnimationHint = -1; - ArrayDeque mFrozenBounds = new ArrayDeque<>(); - ArrayDeque mFrozenMergedConfig = new ArrayDeque<>(); - private AppSaturationInfo mLastAppSaturationInfo; private final ColorDisplayService.ColorTransformController mColorTransformController = @@ -1015,10 +1010,6 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A pw.println(" mVisibleSetFromTransferredStartingWindow=" + mVisibleSetFromTransferredStartingWindow); } - if (!mFrozenBounds.isEmpty()) { - pw.print(prefix); pw.print("mFrozenBounds="); pw.println(mFrozenBounds); - pw.print(prefix); pw.print("mFrozenMergedConfig="); pw.println(mFrozenMergedConfig); - } if (mPendingRelaunchCount != 0) { pw.print(prefix); pw.print("mPendingRelaunchCount="); pw.println(mPendingRelaunchCount); } @@ -3344,56 +3335,18 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A return mPendingRelaunchCount > 0; } - boolean shouldFreezeBounds() { - // For freeform windows, we can't freeze the bounds at the moment because this would make - // the resizing unresponsive. - if (task == null || task.inFreeformWindowingMode()) { - return false; - } - - // We freeze the bounds while drag resizing to deal with the time between - // the divider/drag handle being released, and the handling it's new - // configuration. If we are relaunched outside of the drag resizing state, - // we need to be careful not to do this. - return task.isDragResizing(); - } - @VisibleForTesting void startRelaunching() { if (mPendingRelaunchCount == 0) { mRelaunchStartTime = SystemClock.elapsedRealtime(); } - if (shouldFreezeBounds()) { - freezeBounds(); - } - clearAllDrawn(); mPendingRelaunchCount++; } - /** - * Freezes the task bounds. The size of this task reported the app will be fixed to the bounds - * freezed by {@link Task#prepareFreezingBounds} until {@link #unfreezeBounds} gets called, even - * if they change in the meantime. If the bounds are already frozen, the bounds will be frozen - * with a queue. - */ - private void freezeBounds() { - mFrozenBounds.offer(new Rect(task.mPreparedFrozenBounds)); - - if (task.mPreparedFrozenMergedConfig.equals(Configuration.EMPTY)) { - // We didn't call prepareFreezingBounds on the task, so use the current value. - mFrozenMergedConfig.offer(new Configuration(task.getConfiguration())); - } else { - mFrozenMergedConfig.offer(new Configuration(task.mPreparedFrozenMergedConfig)); - } - // Calling unset() to make it equal to Configuration.EMPTY. - task.mPreparedFrozenMergedConfig.unset(); - } - void finishRelaunching() { mTaskSupervisor.getActivityMetricsLogger().notifyActivityRelaunched(this); - unfreezeBounds(); if (mPendingRelaunchCount > 0) { mPendingRelaunchCount--; @@ -3415,29 +3368,10 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A if (mPendingRelaunchCount == 0) { return; } - unfreezeBounds(); mPendingRelaunchCount = 0; mRelaunchStartTime = 0; } - /** - * Unfreezes the previously frozen bounds. See {@link #freezeBounds}. - */ - private void unfreezeBounds() { - if (mFrozenBounds.isEmpty()) { - return; - } - mFrozenBounds.remove(); - if (!mFrozenMergedConfig.isEmpty()) { - mFrozenMergedConfig.remove(); - } - for (int i = mChildren.size() - 1; i >= 0; i--) { - final WindowState win = mChildren.get(i); - win.onUnfreezeBounds(); - } - mWmService.mWindowPlacerLocked.performSurfacePlacement(); - } - /** * Perform clean-up of service connections in an activity record. */ @@ -8080,9 +8014,6 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A proto.write(STARTING_MOVED, startingMoved); proto.write(VISIBLE_SET_FROM_TRANSFERRED_STARTING_WINDOW, mVisibleSetFromTransferredStartingWindow); - for (Rect bounds : mFrozenBounds) { - bounds.dumpDebug(proto, FROZEN_BOUNDS); - } proto.write(STATE, mState.toString()); proto.write(FRONT_OF_TASK, isRootOfTask()); diff --git a/services/core/java/com/android/server/wm/ActivityTaskManagerService.java b/services/core/java/com/android/server/wm/ActivityTaskManagerService.java index b803fc37a4217..126e34cd14d07 100644 --- a/services/core/java/com/android/server/wm/ActivityTaskManagerService.java +++ b/services/core/java/com/android/server/wm/ActivityTaskManagerService.java @@ -4036,17 +4036,9 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { int updateGlobalConfigurationLocked(@NonNull Configuration values, boolean initLocale, boolean persistent, int userId) { - final DisplayContent defaultDisplay = - mRootWindowContainer.getDisplayContent(DEFAULT_DISPLAY); - mTempConfig.setTo(getGlobalConfiguration()); final int changes = mTempConfig.updateFrom(values); if (changes == 0) { - // Since calling to Activity.setRequestedOrientation leads to freezing the window with - // setting WindowManagerService.mWaitingForConfig to true, it is important that we call - // performDisplayOverrideConfigUpdate in order to send the new display configuration - // (even if there are no actual changes) to unfreeze the window. - defaultDisplay.performDisplayOverrideConfigUpdate(values); return 0; } diff --git a/services/core/java/com/android/server/wm/ConfigurationContainer.java b/services/core/java/com/android/server/wm/ConfigurationContainer.java index 309b5ec25f0ff..62a00802896f2 100644 --- a/services/core/java/com/android/server/wm/ConfigurationContainer.java +++ b/services/core/java/com/android/server/wm/ConfigurationContainer.java @@ -141,14 +141,17 @@ public abstract class ConfigurationContainer { mChangeListeners.get(i).onMergedOverrideConfigurationChanged( mMergedOverrideConfiguration); } - dispatchConfigurationToChildren(); + for (int i = getChildCount() - 1; i >= 0; --i) { + dispatchConfigurationToChild(getChildAt(i), mFullConfiguration); + } } - void dispatchConfigurationToChildren() { - for (int i = getChildCount() - 1; i >= 0; --i) { - final ConfigurationContainer child = getChildAt(i); - child.onConfigurationChanged(mFullConfiguration); - } + /** + * Dispatches the configuration to child when {@link #onConfigurationChanged(Configuration)} is + * called. This allows the derived classes to override how to dispatch the configuration. + */ + void dispatchConfigurationToChild(E child, Configuration config) { + child.onConfigurationChanged(config); } /** diff --git a/services/core/java/com/android/server/wm/DisplayContent.java b/services/core/java/com/android/server/wm/DisplayContent.java index eff4ea6536bd2..9d5c5bed04195 100644 --- a/services/core/java/com/android/server/wm/DisplayContent.java +++ b/services/core/java/com/android/server/wm/DisplayContent.java @@ -2943,10 +2943,6 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp return dockFrame.bottom - imeFrame.top; } - void prepareFreezingTaskBounds() { - forAllRootTasks(Task::prepareFreezingTaskBounds); - } - void rotateBounds(@Rotation int oldRotation, @Rotation int newRotation, Rect inOutBounds) { // Get display bounds on oldRotation as parent bounds for the rotation. getBounds(mTmpRect, oldRotation); diff --git a/services/core/java/com/android/server/wm/RootWindowContainer.java b/services/core/java/com/android/server/wm/RootWindowContainer.java index 3f9ea1fd2afd7..0e8cadbcbcdde 100644 --- a/services/core/java/com/android/server/wm/RootWindowContainer.java +++ b/services/core/java/com/android/server/wm/RootWindowContainer.java @@ -650,28 +650,12 @@ class RootWindowContainer extends WindowContainer } @Override - void dispatchConfigurationToChildren() { - final Configuration configuration = getConfiguration(); - for (int i = getChildCount() - 1; i >= 0; i--) { - final DisplayContent displayContent = getChildAt(i); - if (displayContent.isDefaultDisplay) { - // The global configuration is also the override configuration of default display. - displayContent.performDisplayOverrideConfigUpdate(configuration); - } else { - displayContent.onConfigurationChanged(configuration); - } - } - } - - @Override - public void onConfigurationChanged(Configuration newParentConfig) { - prepareFreezingTaskBounds(); - super.onConfigurationChanged(newParentConfig); - } - - private void prepareFreezingTaskBounds() { - for (int i = mChildren.size() - 1; i >= 0; i--) { - mChildren.get(i).prepareFreezingTaskBounds(); + void dispatchConfigurationToChild(DisplayContent child, Configuration config) { + if (child.isDefaultDisplay) { + // The global configuration is also the override configuration of default display. + child.performDisplayOverrideConfigUpdate(config); + } else { + child.onConfigurationChanged(config); } } diff --git a/services/core/java/com/android/server/wm/Task.java b/services/core/java/com/android/server/wm/Task.java index 29c7ff118595d..8f0984c613adc 100644 --- a/services/core/java/com/android/server/wm/Task.java +++ b/services/core/java/com/android/server/wm/Task.java @@ -500,9 +500,6 @@ class Task extends WindowContainer { // TODO: Make final int mUserId; - final Rect mPreparedFrozenBounds = new Rect(); - final Configuration mPreparedFrozenMergedConfig = new Configuration(); - // Id of the previous display the root task was on. int mPrevDisplayId = INVALID_DISPLAY; @@ -1183,10 +1180,6 @@ class Task extends WindowContainer { mTaskSupervisor.mNoAnimActivities.add(topActivity); } - // We might trigger a configuration change. Save the current task bounds for freezing. - // TODO: Should this call be moved inside the resize method in WM? - toRootTask.prepareFreezingTaskBounds(); - if (toRootTaskWindowingMode == WINDOWING_MODE_SPLIT_SCREEN_PRIMARY && moveRootTaskMode == REPARENT_KEEP_ROOT_TASK_AT_FRONT) { // Move recents to front so it is not behind root home task when going into docked @@ -3482,15 +3475,6 @@ class Task extends WindowContainer { return isResizeable(); } - /** - * Prepares the task bounds to be frozen with the current size. See - * {@link ActivityRecord#freezeBounds}. - */ - void prepareFreezingBounds() { - mPreparedFrozenBounds.set(getBounds()); - mPreparedFrozenMergedConfig.setTo(getConfiguration()); - } - @Override void getAnimationFrames(Rect outFrame, Rect outInsets, Rect outStableInsets, Rect outSurfaceInsets) { @@ -7624,10 +7608,6 @@ class Task extends WindowContainer { }); } - void prepareFreezingTaskBounds() { - forAllLeafTasks(Task::prepareFreezingBounds, true /* traverseTopToBottom */); - } - private int setBounds(Rect existing, Rect bounds) { if (equivalentBounds(existing, bounds)) { return BOUNDS_CHANGE_NONE; diff --git a/services/core/java/com/android/server/wm/WindowState.java b/services/core/java/com/android/server/wm/WindowState.java index 9ae5beb625f82..4f5b00186a54f 100644 --- a/services/core/java/com/android/server/wm/WindowState.java +++ b/services/core/java/com/android/server/wm/WindowState.java @@ -1190,16 +1190,6 @@ class WindowState extends WindowContainer implements WindowManagerP layoutYDiff = 0; } else { windowFrames.mContainingFrame.set(getBounds()); - if (mActivityRecord != null && !mActivityRecord.mFrozenBounds.isEmpty()) { - - // If the bounds are frozen, we still want to translate the window freely and only - // freeze the size. - Rect frozen = mActivityRecord.mFrozenBounds.peek(); - windowFrames.mContainingFrame.right = - windowFrames.mContainingFrame.left + frozen.width(); - windowFrames.mContainingFrame.bottom = - windowFrames.mContainingFrame.top + frozen.height(); - } // IME is up and obscuring this window. Adjust the window position so it is visible. if (isImeTarget) { if (inFreeformWindowingMode()) { @@ -2068,23 +2058,6 @@ class WindowState extends WindowContainer implements WindowManagerP super.onResize(); } - void onUnfreezeBounds() { - for (int i = mChildren.size() - 1; i >= 0; --i) { - final WindowState c = mChildren.get(i); - c.onUnfreezeBounds(); - } - - if (!mHasSurface) { - return; - } - - mLayoutNeeded = true; - setDisplayLayoutNeeded(); - if (!mWmService.mResizingWindows.contains(this)) { - mWmService.mResizingWindows.add(this); - } - } - /** * If the window has moved due to its containing content frame changing, then notify the * listeners and optionally animate it. Simply checking a change of position is not enough, @@ -3579,10 +3552,6 @@ class WindowState extends WindowContainer implements WindowManagerP @Override public Configuration getConfiguration() { - if (mActivityRecord != null && mActivityRecord.mFrozenMergedConfig.size() > 0) { - return mActivityRecord.mFrozenMergedConfig.peek(); - } - // If the process has not registered to any display area to listen to the configuration // change, we can simply return the mFullConfiguration as default. if (!registeredForDisplayAreaConfigChanges()) { @@ -3936,14 +3905,8 @@ class WindowState extends WindowContainer implements WindowManagerP return true; } - // If the bounds are currently frozen, it means that the layout size that the app sees - // and the bounds we clip this window to might be different. In order to avoid holes, we - // simulate that we are still resizing so the app fills the hole with the resizing - // background. - return (getDisplayContent().mDividerControllerLocked.isResizing() - || mActivityRecord != null && !mActivityRecord.mFrozenBounds.isEmpty()) && - !task.inFreeformWindowingMode() && !isGoneForLayout(); - + return getDisplayContent().mDividerControllerLocked.isResizing() + && !task.inFreeformWindowingMode() && !isGoneForLayout(); } void setDragResizing() {