diff options
27 files changed, 161 insertions, 280 deletions
| diff --git a/services/core/java/com/android/server/wm/ActivityRecord.java b/services/core/java/com/android/server/wm/ActivityRecord.java index 145eb3b8464c..ca8afe1972e9 100644 --- a/services/core/java/com/android/server/wm/ActivityRecord.java +++ b/services/core/java/com/android/server/wm/ActivityRecord.java @@ -223,7 +223,6 @@ import static com.android.server.wm.ActivityTaskManagerService.RELAUNCH_REASON_F  import static com.android.server.wm.ActivityTaskManagerService.RELAUNCH_REASON_NONE;  import static com.android.server.wm.ActivityTaskManagerService.RELAUNCH_REASON_WINDOWING_MODE_RESIZE;  import static com.android.server.wm.ActivityTaskManagerService.getInputDispatchingTimeoutMillisLocked; -import static com.android.server.wm.ActivityTaskSupervisor.PRESERVE_WINDOWS;  import static com.android.server.wm.IdentifierProto.HASH_CODE;  import static com.android.server.wm.IdentifierProto.TITLE;  import static com.android.server.wm.IdentifierProto.USER_ID; @@ -949,7 +948,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A      private int mConfigurationSeq;      /** -     * Temp configs used in {@link #ensureActivityConfiguration(int, boolean)} +     * Temp configs used in {@link #ensureActivityConfiguration()}       */      private final Configuration mTmpConfig = new Configuration();      private final Rect mTmpBounds = new Rect(); @@ -1511,7 +1510,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A                  updatePictureInPictureMode(null, false);              } else {                  mLastReportedMultiWindowMode = inMultiWindowMode; -                ensureActivityConfiguration(0 /* globalChanges */, PRESERVE_WINDOWS); +                ensureActivityConfiguration();              }          }      } @@ -1530,8 +1529,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A              // precede the configuration change from the resize.              mLastReportedPictureInPictureMode = inPictureInPictureMode;              mLastReportedMultiWindowMode = inPictureInPictureMode; -            ensureActivityConfiguration(0 /* globalChanges */, PRESERVE_WINDOWS, -                    true /* ignoreVisibility */); +            ensureActivityConfiguration(true /* ignoreVisibility */);              if (inPictureInPictureMode && findMainWindow() == null) {                  // Prevent malicious app entering PiP without valid WindowState, which can in turn                  // result a non-touchable PiP window since the InputConsumer for PiP requires it. @@ -3107,7 +3105,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A          // {@link #returningOptions} of the activity under this one can be applied in          // {@link #handleAlreadyVisible()}.          if (changed || !occludesParent) { -            mRootWindowContainer.ensureActivitiesVisible(null, 0, !PRESERVE_WINDOWS); +            mRootWindowContainer.ensureActivitiesVisible();          }          return changed;      } @@ -3747,8 +3745,8 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A              }              if (ensureVisibility) { -                mDisplayContent.ensureActivitiesVisible(null /* starting */, 0 /* configChanges */, -                        false /* preserveWindows */, true /* notifyClients */); +                mDisplayContent.ensureActivitiesVisible(null /* starting */, +                        true /* notifyClients */);              }          } @@ -4165,8 +4163,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A          if (rootTask != null && rootTask.shouldSleepOrShutDownActivities()) {              // Activity is always relaunched to either resumed or paused state. If it was              // relaunched while hidden (by keyguard or smth else), it should be stopped. -            rootTask.ensureActivitiesVisible(null /* starting */, 0 /* configChanges */, -                    false /* preserveWindows */); +            rootTask.ensureActivitiesVisible(null /* starting */);          }      } @@ -4681,14 +4678,12 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A      void setShowWhenLocked(boolean showWhenLocked) {          mShowWhenLocked = showWhenLocked; -        mAtmService.mRootWindowContainer.ensureActivitiesVisible(null /* starting */, -                0 /* configChanges */, false /* preserveWindows */); +        mAtmService.mRootWindowContainer.ensureActivitiesVisible();      }      void setInheritShowWhenLocked(boolean inheritShowWhenLocked) {          mInheritShownWhenLocked = inheritShowWhenLocked; -        mAtmService.mRootWindowContainer.ensureActivitiesVisible(null /* starting */, -                0 /* configChanges */, false /* preserveWindows */); +        mAtmService.mRootWindowContainer.ensureActivitiesVisible();      }      /** @@ -6413,7 +6408,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A          }          mDisplayContent.handleActivitySizeCompatModeIfNeeded(this); -        mRootWindowContainer.ensureActivitiesVisible(null, 0, !PRESERVE_WINDOWS); +        mRootWindowContainer.ensureActivitiesVisible();      }      /** @@ -7894,7 +7889,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A      void applyFixedRotationTransform(DisplayInfo info, DisplayFrames displayFrames,              Configuration config) {          super.applyFixedRotationTransform(info, displayFrames, config); -        ensureActivityConfiguration(0 /* globalChanges */, false /* preserveWindow */); +        ensureActivityConfiguration();      }      /** @@ -7989,7 +7984,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A          startFreezingScreen(originalDisplayRotation);          // This activity may relaunch or perform configuration change so once it has reported drawn,          // the screen can be unfrozen. -        ensureActivityConfiguration(0 /* globalChanges */, !PRESERVE_WINDOWS); +        ensureActivityConfiguration();          if (mTransitionController.isCollecting(this)) {              // In case the task was changed from PiP but still keeps old transform.              task.resetSurfaceControlTransforms(); @@ -8017,7 +8012,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A          // the request is handled at task level with letterbox.          if (!getMergedOverrideConfiguration().equals(                  mLastReportedConfiguration.getMergedConfiguration())) { -            ensureActivityConfiguration(0 /* globalChanges */, false /* preserveWindow */, +            ensureActivityConfiguration(                      false /* ignoreVisibility */, true /* isRequestedOrientationChanged */);              if (mTransitionController.inPlayingTransition(this)) {                  mTransitionController.mValidateActivityCompat.add(this); @@ -9525,14 +9520,12 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A          return mLastReportedDisplayId != getDisplayId();      } -    boolean ensureActivityConfiguration(int globalChanges, boolean preserveWindow) { -        return ensureActivityConfiguration(globalChanges, preserveWindow, -                false /* ignoreVisibility */, false /* isRequestedOrientationChanged */); +    boolean ensureActivityConfiguration() { +        return ensureActivityConfiguration(false /* ignoreVisibility */);      } -    boolean ensureActivityConfiguration(int globalChanges, boolean preserveWindow, -            boolean ignoreVisibility) { -        return ensureActivityConfiguration(globalChanges, preserveWindow, ignoreVisibility, +    boolean ensureActivityConfiguration(boolean ignoreVisibility) { +        return ensureActivityConfiguration(ignoreVisibility,                  false /* isRequestedOrientationChanged */);      } @@ -9540,9 +9533,6 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A       * Make sure the given activity matches the current configuration. Ensures the HistoryRecord       * is updated with the correct configuration and all other bookkeeping is handled.       * -     * @param globalChanges The changes to the global configuration. -     * @param preserveWindow If the activity window should be preserved on screen if the activity -     *                       is relaunched.       * @param ignoreVisibility If we should try to relaunch the activity even if it is invisible       *                         (stopped state). This is useful for the case where we know the       *                         activity will be visible soon and we want to ensure its configuration @@ -9552,8 +9542,8 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A       * @return False if the activity was relaunched and true if it wasn't relaunched because we       *         can't or the app handles the specific configuration that is changing.       */ -    boolean ensureActivityConfiguration(int globalChanges, boolean preserveWindow, -            boolean ignoreVisibility, boolean isRequestedOrientationChanged) { +    boolean ensureActivityConfiguration(boolean ignoreVisibility, +            boolean isRequestedOrientationChanged) {          final Task rootTask = getRootTask();          if (rootTask.mConfigWillChange) {              ProtoLog.v(WM_DEBUG_CONFIGURATION, "Skipping config check " @@ -9667,10 +9657,21 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A          if (shouldRelaunchLocked(changes, mTmpConfig)) {              // Aha, the activity isn't handling the change, so DIE DIE DIE.              configChangeFlags |= changes; -            startFreezingScreenLocked(globalChanges); +            if (mVisible && mAtmService.mTmpUpdateConfigurationResult.mIsUpdating +                    && !mTransitionController.isShellTransitionsEnabled()) { +                startFreezingScreenLocked(mAtmService.mTmpUpdateConfigurationResult.changes); +            } +            final boolean displayMayChange = mTmpConfig.windowConfiguration.getDisplayRotation() +                    != getWindowConfiguration().getDisplayRotation() +                    || !mTmpConfig.windowConfiguration.getMaxBounds().equals( +                            getWindowConfiguration().getMaxBounds()); +            final boolean isAppResizeOnly = !displayMayChange +                    && (changes & ~(CONFIG_SCREEN_SIZE | CONFIG_SMALLEST_SCREEN_SIZE +                            | CONFIG_ORIENTATION | CONFIG_SCREEN_LAYOUT)) == 0;              // Do not preserve window if it is freezing screen because the original window won't be              // able to update drawn state that causes freeze timeout. -            preserveWindow &= isResizeOnlyChange(changes) && !mFreezingScreen; +            // TODO(b/258618073): Always preserve if possible. +            final boolean preserveWindow = isAppResizeOnly && !mFreezingScreen;              final boolean hasResizeChange = hasResizeChange(changes & ~info.getRealConfigChanged());              if (hasResizeChange) {                  final boolean isDragResizing = task.isDragResizing(); @@ -9834,11 +9835,6 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A          return changes;      } -    private static boolean isResizeOnlyChange(int change) { -        return (change & ~(CONFIG_SCREEN_SIZE | CONFIG_SMALLEST_SCREEN_SIZE | CONFIG_ORIENTATION -                | CONFIG_SCREEN_LAYOUT)) == 0; -    } -      private static boolean hasResizeChange(int change) {          return (change & (CONFIG_SCREEN_SIZE | CONFIG_SMALLEST_SCREEN_SIZE | CONFIG_ORIENTATION                  | CONFIG_SCREEN_LAYOUT)) != 0; @@ -9882,8 +9878,6 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A                      task.mTaskId, shortComponentName, Integer.toHexString(configChangeFlags));          } -        startFreezingScreenLocked(0); -          try {              ProtoLog.i(WM_DEBUG_STATES, "Moving to %s Relaunching %s callers=%s" ,                      (andResume ? "RESUMED" : "PAUSED"), this, Debug.getCallers(6)); diff --git a/services/core/java/com/android/server/wm/ActivityStarter.java b/services/core/java/com/android/server/wm/ActivityStarter.java index 92c8c0b3b9f5..d90d017a5570 100644 --- a/services/core/java/com/android/server/wm/ActivityStarter.java +++ b/services/core/java/com/android/server/wm/ActivityStarter.java @@ -73,7 +73,6 @@ import static com.android.server.wm.ActivityTaskManagerDebugConfig.TAG_WITH_CLAS  import static com.android.server.wm.ActivityTaskManagerService.ANIMATE;  import static com.android.server.wm.ActivityTaskSupervisor.DEFER_RESUME;  import static com.android.server.wm.ActivityTaskSupervisor.ON_TOP; -import static com.android.server.wm.ActivityTaskSupervisor.PRESERVE_WINDOWS;  import static com.android.server.wm.BackgroundActivityStartController.BAL_ALLOW_DEFAULT;  import static com.android.server.wm.BackgroundActivityStartController.BAL_BLOCK;  import static com.android.server.wm.LaunchParamsController.LaunchParamsModifier.PHASE_BOUNDS; @@ -1860,8 +1859,7 @@ class ActivityStarter {                  // over is removed.                  // Passing {@code null} as the start parameter ensures all activities are made                  // visible. -                mTargetRootTask.ensureActivitiesVisible(null /* starting */, -                        0 /* configChanges */, !PRESERVE_WINDOWS); +                mTargetRootTask.ensureActivitiesVisible(null /* starting */);                  // Go ahead and tell window manager to execute app transition for this activity                  // since the app transition will not be triggered through the resume channel.                  mTargetRootTask.mDisplayContent.executeAppTransition(); @@ -2868,7 +2866,7 @@ class ActivityStarter {                  mRootWindowContainer.resumeFocusedTasksTopActivities(mTargetRootTask, null,                          mOptions, mTransientLaunch);              } else { -                mRootWindowContainer.ensureActivitiesVisible(null, 0, !PRESERVE_WINDOWS); +                mRootWindowContainer.ensureActivitiesVisible();              }          } else {              ActivityOptions.abort(mOptions); diff --git a/services/core/java/com/android/server/wm/ActivityTaskManagerService.java b/services/core/java/com/android/server/wm/ActivityTaskManagerService.java index dbae29bd37c9..f43c1b01e87c 100644 --- a/services/core/java/com/android/server/wm/ActivityTaskManagerService.java +++ b/services/core/java/com/android/server/wm/ActivityTaskManagerService.java @@ -118,7 +118,6 @@ import static com.android.server.wm.ActivityTaskManagerService.H.REPORT_TIME_TRA  import static com.android.server.wm.ActivityTaskManagerService.UiHandler.DISMISS_DIALOG_UI_MSG;  import static com.android.server.wm.ActivityTaskSupervisor.DEFER_RESUME;  import static com.android.server.wm.ActivityTaskSupervisor.ON_TOP; -import static com.android.server.wm.ActivityTaskSupervisor.PRESERVE_WINDOWS;  import static com.android.server.wm.ActivityTaskSupervisor.REMOVE_FROM_RECENTS;  import static com.android.server.wm.BackgroundActivityStartController.BalVerdict;  import static com.android.server.wm.LockTaskController.LOCK_TASK_AUTH_DONT_LOCK; @@ -496,16 +495,13 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {      final UpdateConfigurationResult mTmpUpdateConfigurationResult =              new UpdateConfigurationResult(); +    // TODO(b/258618073): Remove this and make the related methods return whether config is changed.      static final class UpdateConfigurationResult {          // Configuration changes that were updated.          int changes;          // If the activity was relaunched to match the new configuration.          boolean activityRelaunched; - -        void reset() { -            changes = 0; -            activityRelaunched = false; -        } +        boolean mIsUpdating;      }      /** Current sequencing integer of the configuration, for skipping old configurations. */ @@ -3834,8 +3830,7 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {                      Settings.System.clearConfiguration(values);                  }                  updateConfigurationLocked(values, null, false, false /* persistent */, -                        UserHandle.USER_NULL, false /* deferResume */, -                        mTmpUpdateConfigurationResult); +                        UserHandle.USER_NULL, false /* deferResume */);                  return mTmpUpdateConfigurationResult.changes != 0;              } finally {                  Binder.restoreCallingIdentity(origId); @@ -4507,12 +4502,6 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {          }      } -    private boolean updateConfigurationLocked(Configuration values, ActivityRecord starting, -            boolean initLocale, boolean persistent, int userId, boolean deferResume) { -        return updateConfigurationLocked(values, starting, initLocale, persistent, userId, -                deferResume, null /* result */); -    } -      /**       * Do either or both things: (1) change the current configuration, and (2)       * make sure the given activity is running with the (now) current @@ -4524,8 +4513,7 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {       *               for that particular user       */      boolean updateConfigurationLocked(Configuration values, ActivityRecord starting, -            boolean initLocale, boolean persistent, int userId, boolean deferResume, -            ActivityTaskManagerService.UpdateConfigurationResult result) { +            boolean initLocale, boolean persistent, int userId, boolean deferResume) {          int changes = 0;          boolean kept = true; @@ -4533,19 +4521,18 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {          try {              if (values != null) {                  changes = updateGlobalConfigurationLocked(values, initLocale, persistent, userId); +                mTmpUpdateConfigurationResult.changes = changes; +                mTmpUpdateConfigurationResult.mIsUpdating = true;              }              if (!deferResume) {                  kept = ensureConfigAndVisibilityAfterUpdate(starting, changes);              }          } finally { +            mTmpUpdateConfigurationResult.mIsUpdating = false;              continueWindowLayout();          } - -        if (result != null) { -            result.changes = changes; -            result.activityRelaunched = !kept; -        } +        mTmpUpdateConfigurationResult.activityRelaunched = !kept;          return kept;      } @@ -5325,12 +5312,10 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {              }              if (starting != null) { -                kept = starting.ensureActivityConfiguration(changes, -                        false /* preserveWindow */); +                kept = starting.ensureActivityConfiguration();                  // And we need to make sure at this point that all other activities                  // are made visible with the correct configuration. -                mRootWindowContainer.ensureActivitiesVisible(starting, changes, -                        !PRESERVE_WINDOWS); +                mRootWindowContainer.ensureActivitiesVisible(starting);              }          } diff --git a/services/core/java/com/android/server/wm/ActivityTaskSupervisor.java b/services/core/java/com/android/server/wm/ActivityTaskSupervisor.java index 10efb9491bed..1872f6e1fdb8 100644 --- a/services/core/java/com/android/server/wm/ActivityTaskSupervisor.java +++ b/services/core/java/com/android/server/wm/ActivityTaskSupervisor.java @@ -1462,7 +1462,7 @@ public class ActivityTaskSupervisor implements RecentTasks.Callbacks {                  }                  mLaunchingActivityWakeLock.release();              } -            mRootWindowContainer.ensureActivitiesVisible(null, 0, !PRESERVE_WINDOWS); +            mRootWindowContainer.ensureActivitiesVisible();          }          // Atomically retrieve all of the other things to do. @@ -1603,7 +1603,7 @@ public class ActivityTaskSupervisor implements RecentTasks.Callbacks {           */          rootTask.cancelAnimation();          rootTask.setForceHidden(FLAG_FORCE_HIDDEN_FOR_PINNED_TASK, true /* set */); -        rootTask.ensureActivitiesVisible(null, 0, PRESERVE_WINDOWS); +        rootTask.ensureActivitiesVisible(null /* starting */);          activityIdleInternal(null /* idleActivity */, false /* fromTimeout */,                  true /* processPausingActivities */, null /* configuration */); @@ -1622,7 +1622,7 @@ public class ActivityTaskSupervisor implements RecentTasks.Callbacks {              // Follow on the workaround: activities are kept force hidden till the new windowing              // mode is set.              rootTask.setForceHidden(FLAG_FORCE_HIDDEN_FOR_PINNED_TASK, false /* set */); -            mRootWindowContainer.ensureActivitiesVisible(null, 0, PRESERVE_WINDOWS); +            mRootWindowContainer.ensureActivitiesVisible();              mRootWindowContainer.resumeFocusedTasksTopActivities();          } finally {              mService.continueWindowLayout(); @@ -2026,7 +2026,7 @@ public class ActivityTaskSupervisor implements RecentTasks.Callbacks {          final Task rootTask = r.getRootTask();          if (rootTask.getDisplayArea().allResumedActivitiesComplete()) { -            mRootWindowContainer.ensureActivitiesVisible(null, 0, !PRESERVE_WINDOWS); +            mRootWindowContainer.ensureActivitiesVisible();              // Make sure activity & window visibility should be identical              // for all displays in this stage.              mRootWindowContainer.executeAppTransitionForAllDisplay(); @@ -2042,7 +2042,7 @@ public class ActivityTaskSupervisor implements RecentTasks.Callbacks {          mRecentTasks.add(task);          mService.getTaskChangeNotificationController().notifyTaskStackChanged(); -        rootTask.ensureActivitiesVisible(null, 0, !PRESERVE_WINDOWS); +        rootTask.ensureActivitiesVisible(null /* starting */);          // When launching tasks behind, update the last active time of the top task after the new          // task has been shown briefly diff --git a/services/core/java/com/android/server/wm/BackNavigationController.java b/services/core/java/com/android/server/wm/BackNavigationController.java index c3f1e41d4c5e..22d17b596c4c 100644 --- a/services/core/java/com/android/server/wm/BackNavigationController.java +++ b/services/core/java/com/android/server/wm/BackNavigationController.java @@ -1614,7 +1614,7 @@ class BackNavigationController {                  "Setting Activity.mLauncherTaskBehind to true. Activity=%s", activity);          activity.mTaskSupervisor.mStoppingActivities.remove(activity);          activity.getDisplayContent().ensureActivitiesVisible(null /* starting */, -                0 /* configChanges */, false /* preserveWindows */, true); +                true /* notifyClients */);      }      private static void restoreLaunchBehind(@NonNull ActivityRecord activity) { diff --git a/services/core/java/com/android/server/wm/DisplayContent.java b/services/core/java/com/android/server/wm/DisplayContent.java index f8dc9c79dda7..e7ecf520425d 100644 --- a/services/core/java/com/android/server/wm/DisplayContent.java +++ b/services/core/java/com/android/server/wm/DisplayContent.java @@ -779,7 +779,7 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp      /**       * Used to prevent recursions when calling -     * {@link #ensureActivitiesVisible(ActivityRecord, int, boolean, boolean)} +     * {@link #ensureActivitiesVisible(ActivityRecord, boolean)}       */      private boolean mInEnsureActivitiesVisible = false; @@ -1713,7 +1713,7 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp          if (handled && requestingContainer instanceof ActivityRecord) {              final ActivityRecord activityRecord = (ActivityRecord) requestingContainer;              final boolean kept = updateDisplayOverrideConfigurationLocked(config, activityRecord, -                    false /* deferResume */, null /* result */); +                    false /* deferResume */);              if (!kept) {                  mRootWindowContainer.resumeFocusedTasksTopActivities();              } @@ -1721,7 +1721,7 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp              // We have a new configuration to push so we need to update ATMS for now.              // TODO: Clean up display configuration push between ATMS and WMS after unification.              updateDisplayOverrideConfigurationLocked(config, null /* starting */, -                    false /* deferResume */, null); +                    false /* deferResume */);          }          return handled;      } @@ -6333,7 +6333,7 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp          Settings.System.clearConfiguration(values);          updateDisplayOverrideConfigurationLocked(values, null /* starting */, -                false /* deferResume */, mAtmService.mTmpUpdateConfigurationResult); +                false /* deferResume */);          return mAtmService.mTmpUpdateConfigurationResult.changes != 0;      } @@ -6342,8 +6342,7 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp       * new one will be computed in WM based on current display info.       */      boolean updateDisplayOverrideConfigurationLocked(Configuration values, -            ActivityRecord starting, boolean deferResume, -            ActivityTaskManagerService.UpdateConfigurationResult result) { +            ActivityRecord starting, boolean deferResume) {          int changes = 0;          boolean kept = true; @@ -6361,19 +6360,19 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp                  } else {                      changes = performDisplayOverrideConfigUpdate(values);                  } +                mAtmService.mTmpUpdateConfigurationResult.changes = changes; +                mAtmService.mTmpUpdateConfigurationResult.mIsUpdating = true;              }              if (!deferResume) {                  kept = mAtmService.ensureConfigAndVisibilityAfterUpdate(starting, changes);              }          } finally { +            mAtmService.mTmpUpdateConfigurationResult.mIsUpdating = false;              mAtmService.continueWindowLayout();          } -        if (result != null) { -            result.changes = changes; -            result.activityRelaunched = !kept; -        } +        mAtmService.mTmpUpdateConfigurationResult.activityRelaunched = !kept;          return kept;      } @@ -6569,8 +6568,7 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp      } -    void ensureActivitiesVisible(ActivityRecord starting, int configChanges, -            boolean preserveWindows, boolean notifyClients) { +    void ensureActivitiesVisible(ActivityRecord starting, boolean notifyClients) {          if (mInEnsureActivitiesVisible) {              // Don't do recursive work.              return; @@ -6579,8 +6577,7 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp          try {              mInEnsureActivitiesVisible = true;              forAllRootTasks(rootTask -> { -                rootTask.ensureActivitiesVisible(starting, configChanges, preserveWindows, -                        notifyClients); +                rootTask.ensureActivitiesVisible(starting, notifyClients);              });              if (mTransitionController.useShellTransitionsRotation()                      && mTransitionController.isCollecting() @@ -6619,7 +6616,7 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp          if (!wasTransitionSet) {              prepareAppTransition(TRANSIT_NONE);          } -        mRootWindowContainer.ensureActivitiesVisible(null, 0, false /* preserveWindows */); +        mRootWindowContainer.ensureActivitiesVisible();          // If there was a transition set already we don't want to interfere with it as we might be          // starting it too early. diff --git a/services/core/java/com/android/server/wm/EnsureActivitiesVisibleHelper.java b/services/core/java/com/android/server/wm/EnsureActivitiesVisibleHelper.java index 9cc311dc6c8e..f40eb24fd5eb 100644 --- a/services/core/java/com/android/server/wm/EnsureActivitiesVisibleHelper.java +++ b/services/core/java/com/android/server/wm/EnsureActivitiesVisibleHelper.java @@ -33,8 +33,6 @@ class EnsureActivitiesVisibleHelper {      private boolean mAboveTop;      private boolean mContainerShouldBeVisible;      private boolean mBehindFullyOccludedContainer; -    private int mConfigChanges; -    private boolean mPreserveWindows;      private boolean mNotifyClients;      EnsureActivitiesVisibleHelper(TaskFragment container) { @@ -45,14 +43,10 @@ class EnsureActivitiesVisibleHelper {       * Update all attributes except {@link mTaskFragment} to use in subsequent calculations.       *       * @param starting The activity that is being started -     * @param configChanges Parts of the configuration that changed for this activity for evaluating -     *                      if the screen should be frozen. -     * @param preserveWindows Flag indicating whether windows should be preserved when updating.       * @param notifyClients Flag indicating whether the configuration and visibility changes shoulc       *                      be sent to the clients.       */ -    void reset(ActivityRecord starting, int configChanges, boolean preserveWindows, -            boolean notifyClients) { +    void reset(ActivityRecord starting, boolean notifyClients) {          mStarting = starting;          mTopRunningActivity = mTaskFragment.topRunningActivity();          // If the top activity is not fullscreen, then we need to make sure any activities under it @@ -60,33 +54,26 @@ class EnsureActivitiesVisibleHelper {          mAboveTop = mTopRunningActivity != null;          mContainerShouldBeVisible = mTaskFragment.shouldBeVisible(mStarting);          mBehindFullyOccludedContainer = !mContainerShouldBeVisible; -        mConfigChanges = configChanges; -        mPreserveWindows = preserveWindows;          mNotifyClients = notifyClients;      }      /**       * Update and commit visibility with an option to also update the configuration of visible       * activities. -     * @see Task#ensureActivitiesVisible(ActivityRecord, int, boolean) -     * @see RootWindowContainer#ensureActivitiesVisible(ActivityRecord, int, boolean) +     * @see Task#ensureActivitiesVisible(ActivityRecord) +     * @see RootWindowContainer#ensureActivitiesVisible()       * @param starting The top most activity in the task.       *                 The activity is either starting or resuming.       *                 Caller should ensure starting activity is visible.       * -     * @param configChanges Parts of the configuration that changed for this activity for evaluating -     *                      if the screen should be frozen. -     * @param preserveWindows Flag indicating whether windows should be preserved when updating.       * @param notifyClients Flag indicating whether the configuration and visibility changes shoulc       *                      be sent to the clients.       */ -    void process(@Nullable ActivityRecord starting, int configChanges, boolean preserveWindows, -            boolean notifyClients) { -        reset(starting, configChanges, preserveWindows, notifyClients); +    void process(@Nullable ActivityRecord starting, boolean notifyClients) { +        reset(starting, notifyClients);          if (DEBUG_VISIBILITY) { -            Slog.v(TAG_VISIBILITY, "ensureActivitiesVisible behind " + mTopRunningActivity -                    + " configChanges=0x" + Integer.toHexString(configChanges)); +            Slog.v(TAG_VISIBILITY, "ensureActivitiesVisible behind " + mTopRunningActivity);          }          if (mTopRunningActivity != null && mTaskFragment.asTask() != null) {              // TODO(14709632): Check if this needed to be implemented in TaskFragment. @@ -107,8 +94,7 @@ class EnsureActivitiesVisibleHelper {              final TaskFragment childTaskFragment = child.asTaskFragment();              if (childTaskFragment != null                      && childTaskFragment.getTopNonFinishingActivity() != null) { -                childTaskFragment.updateActivityVisibilities(starting, configChanges, -                        preserveWindows, notifyClients); +                childTaskFragment.updateActivityVisibilities(starting, notifyClients);                  // The TaskFragment should fully occlude the activities below if the bounds                  // equals to its parent task, unless it is translucent.                  mBehindFullyOccludedContainer |= @@ -188,13 +174,11 @@ class EnsureActivitiesVisibleHelper {              // First: if this is not the current activity being started, make              // sure it matches the current configuration.              if (r != mStarting && mNotifyClients) { -                r.ensureActivityConfiguration(0 /* globalChanges */, mPreserveWindows, -                        true /* ignoreVisibility */); +                r.ensureActivityConfiguration(true /* ignoreVisibility */);              }              if (!r.attachedToProcess()) { -                makeVisibleAndRestartIfNeeded(mStarting, mConfigChanges, -                        resumeTopActivity && isTop, r); +                makeVisibleAndRestartIfNeeded(mStarting, resumeTopActivity && isTop, r);              } else if (r.isVisibleRequested()) {                  // If this activity is already visible, then there is nothing to do here.                  if (DEBUG_VISIBILITY) { @@ -213,8 +197,6 @@ class EnsureActivitiesVisibleHelper {              } else {                  r.makeVisibleIfNeeded(mStarting, mNotifyClients);              } -            // Aggregate current change flags. -            mConfigChanges |= r.configChangeFlags;          } else {              if (DEBUG_VISIBILITY) {                  Slog.v(TAG_VISIBILITY, "Make invisible? " + r @@ -242,16 +224,13 @@ class EnsureActivitiesVisibleHelper {          }      } -    private void makeVisibleAndRestartIfNeeded(ActivityRecord starting, int configChanges, +    private void makeVisibleAndRestartIfNeeded(ActivityRecord starting,              boolean andResume, ActivityRecord r) {          // This activity needs to be visible, but isn't even running...          // get it started and resume if no other root task in this root task is resumed.          if (DEBUG_VISIBILITY) {              Slog.v(TAG_VISIBILITY, "Start and freeze screen for " + r);          } -        if (r != starting) { -            r.startFreezingScreenLocked(configChanges); -        }          if (!r.isVisibleRequested() || r.mLaunchTaskBehind) {              if (DEBUG_VISIBILITY) {                  Slog.v(TAG_VISIBILITY, "Starting and making visible: " + r); diff --git a/services/core/java/com/android/server/wm/KeyguardController.java b/services/core/java/com/android/server/wm/KeyguardController.java index cbc7b836d250..6d1180497fed 100644 --- a/services/core/java/com/android/server/wm/KeyguardController.java +++ b/services/core/java/com/android/server/wm/KeyguardController.java @@ -43,7 +43,6 @@ import static android.view.WindowManagerPolicyConstants.KEYGUARD_GOING_AWAY_FLAG  import static com.android.server.policy.WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER;  import static com.android.server.wm.ActivityTaskManagerDebugConfig.TAG_ATM;  import static com.android.server.wm.ActivityTaskManagerDebugConfig.TAG_WITH_CLASS_NAME; -import static com.android.server.wm.ActivityTaskSupervisor.PRESERVE_WINDOWS;  import static com.android.server.wm.KeyguardControllerProto.AOD_SHOWING;  import static com.android.server.wm.KeyguardControllerProto.KEYGUARD_GOING_AWAY;  import static com.android.server.wm.KeyguardControllerProto.KEYGUARD_PER_DISPLAY; @@ -239,7 +238,7 @@ class KeyguardController {          // Update the sleep token first such that ensureActivitiesVisible has correct sleep token          // state when evaluating visibilities.          updateKeyguardSleepToken(); -        mRootWindowContainer.ensureActivitiesVisible(null, 0, !PRESERVE_WINDOWS); +        mRootWindowContainer.ensureActivitiesVisible();          InputMethodManagerInternal.get().updateImeWindowStatus(false /* disableImeIcon */,                  displayId);          setWakeTransitionReady(); @@ -291,7 +290,7 @@ class KeyguardController {              // Some stack visibility might change (e.g. docked stack)              mRootWindowContainer.resumeFocusedTasksTopActivities(); -            mRootWindowContainer.ensureActivitiesVisible(null, 0, !PRESERVE_WINDOWS); +            mRootWindowContainer.ensureActivitiesVisible();              mRootWindowContainer.addStartingWindowsForVisibleActivities();              mWindowManager.executeAppTransition();          } finally { diff --git a/services/core/java/com/android/server/wm/RecentsAnimation.java b/services/core/java/com/android/server/wm/RecentsAnimation.java index 5269d35529bd..7b23004ae952 100644 --- a/services/core/java/com/android/server/wm/RecentsAnimation.java +++ b/services/core/java/com/android/server/wm/RecentsAnimation.java @@ -28,7 +28,6 @@ import static android.os.Trace.TRACE_TAG_WINDOW_MANAGER;  import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_RECENTS_ANIMATIONS;  import static com.android.server.wm.ActivityRecord.State.STOPPED;  import static com.android.server.wm.ActivityRecord.State.STOPPING; -import static com.android.server.wm.ActivityTaskSupervisor.PRESERVE_WINDOWS;  import static com.android.server.wm.RecentsAnimationController.REORDER_KEEP_IN_PLACE;  import static com.android.server.wm.RecentsAnimationController.REORDER_MOVE_TO_ORIGINAL_POSITION;  import static com.android.server.wm.RecentsAnimationController.REORDER_MOVE_TO_TOP; @@ -126,8 +125,7 @@ class RecentsAnimation implements RecentsAnimationCallbacks, OnRootTaskOrderChan                  // The activity may be relaunched if it cannot handle the current configuration                  // changes. The activity will be paused state if it is relaunched, otherwise it                  // keeps the original stopped state. -                targetActivity.ensureActivityConfiguration(0 /* globalChanges */, -                        false /* preserveWindow */, true /* ignoreVisibility */); +                targetActivity.ensureActivityConfiguration(true /* ignoreVisibility */);                  ProtoLog.d(WM_DEBUG_RECENTS_ANIMATIONS, "Updated config=%s",                          targetActivity.getConfiguration());              } @@ -261,7 +259,7 @@ class RecentsAnimation implements RecentsAnimationCallbacks, OnRootTaskOrderChan              // If we updated the launch-behind state, update the visibility of the activities after              // we fetch the visible tasks to be controlled by the animation -            mService.mRootWindowContainer.ensureActivitiesVisible(null, 0, PRESERVE_WINDOWS); +            mService.mRootWindowContainer.ensureActivitiesVisible();              ActivityOptions options = null;              if (eventTime > 0) { @@ -380,8 +378,7 @@ class RecentsAnimation implements RecentsAnimationCallbacks, OnRootTaskOrderChan                          // transition (the target activity will be one of closing apps).                          if (!controller.shouldDeferCancelWithScreenshot()                                  && !targetRootTask.isFocusedRootTaskOnDisplay()) { -                            targetRootTask.ensureActivitiesVisible(null /* starting */, -                                    0 /* starting */, false /* preserveWindows */); +                            targetRootTask.ensureActivitiesVisible(null /* starting */);                          }                          // Keep target root task in place, nothing changes, so ignore the transition                          // logic below @@ -389,7 +386,7 @@ class RecentsAnimation implements RecentsAnimationCallbacks, OnRootTaskOrderChan                      }                      mWindowManager.prepareAppTransitionNone(); -                    mService.mRootWindowContainer.ensureActivitiesVisible(null, 0, false); +                    mService.mRootWindowContainer.ensureActivitiesVisible();                      mService.mRootWindowContainer.resumeFocusedTasksTopActivities();                      // No reason to wait for the pausing activity in this case, as the hiding of diff --git a/services/core/java/com/android/server/wm/RootWindowContainer.java b/services/core/java/com/android/server/wm/RootWindowContainer.java index 9a75dae3569e..ca66a66057a3 100644 --- a/services/core/java/com/android/server/wm/RootWindowContainer.java +++ b/services/core/java/com/android/server/wm/RootWindowContainer.java @@ -63,7 +63,6 @@ import static com.android.server.wm.ActivityTaskManagerService.TAG_SWITCH;  import static com.android.server.wm.ActivityTaskManagerService.isPip2ExperimentEnabled;  import static com.android.server.wm.ActivityTaskSupervisor.DEFER_RESUME;  import static com.android.server.wm.ActivityTaskSupervisor.ON_TOP; -import static com.android.server.wm.ActivityTaskSupervisor.PRESERVE_WINDOWS;  import static com.android.server.wm.ActivityTaskSupervisor.dumpHistoryList;  import static com.android.server.wm.ActivityTaskSupervisor.printThisActivity;  import static com.android.server.wm.KeyguardController.KEYGUARD_SLEEP_TOKEN_TAG; @@ -1753,8 +1752,7 @@ class RootWindowContainer extends WindowContainer<DisplayContent>          // activities are affecting configuration now.          // Passing null here for 'starting' param value, so that visibility of actual starting          // activity will be properly updated. -        ensureActivitiesVisible(null /* starting */, 0 /* configChanges */, -                false /* preserveWindows */, false /* notifyClients */); +        ensureActivitiesVisible(null /* starting */, false /* notifyClients */);          if (displayId == INVALID_DISPLAY) {              // The caller didn't provide a valid display id, skip updating config. @@ -1778,7 +1776,7 @@ class RootWindowContainer extends WindowContainer<DisplayContent>          if (displayContent != null) {              // Update the configuration of the activities on the display.              return displayContent.updateDisplayOverrideConfigurationLocked(config, starting, -                    deferResume, null /* result */); +                    deferResume);          } else {              return true;          } @@ -1865,16 +1863,18 @@ class RootWindowContainer extends WindowContainer<DisplayContent>       * Make sure that all activities that need to be visible in the system actually are and update       * their configuration.       */ -    void ensureActivitiesVisible(ActivityRecord starting, int configChanges, -            boolean preserveWindows) { -        ensureActivitiesVisible(starting, configChanges, preserveWindows, true /* notifyClients */); +    void ensureActivitiesVisible() { +        ensureActivitiesVisible(null /* starting */); +    } + +    void ensureActivitiesVisible(ActivityRecord starting) { +        ensureActivitiesVisible(starting, true /* notifyClients */);      }      /** -     * @see #ensureActivitiesVisible(ActivityRecord, int, boolean) +     * @see #ensureActivitiesVisible()       */ -    void ensureActivitiesVisible(ActivityRecord starting, int configChanges, -            boolean preserveWindows, boolean notifyClients) { +    void ensureActivitiesVisible(ActivityRecord starting, boolean notifyClients) {          if (mTaskSupervisor.inActivityVisibilityUpdate()                  || mTaskSupervisor.isRootVisibilityUpdateDeferred()) {              // Don't do recursive work. @@ -1885,8 +1885,7 @@ class RootWindowContainer extends WindowContainer<DisplayContent>              // First the front root tasks. In case any are not fullscreen and are in front of home.              for (int displayNdx = getChildCount() - 1; displayNdx >= 0; --displayNdx) {                  final DisplayContent display = getChildAt(displayNdx); -                display.ensureActivitiesVisible(starting, configChanges, preserveWindows, -                        notifyClients); +                display.ensureActivitiesVisible(starting, notifyClients);              }          } finally {              mTaskSupervisor.endActivityVisibilityUpdate(); @@ -2237,7 +2236,7 @@ class RootWindowContainer extends WindowContainer<DisplayContent>              try {                  if (localVisibilityDeferred) {                      mTaskSupervisor.setDeferRootVisibilityUpdate(false); -                    ensureActivitiesVisible(null, 0, false /* preserveWindows */); +                    ensureActivitiesVisible();                  }              } finally {                  transitionController.continueTransitionReady(); @@ -2370,7 +2369,7 @@ class RootWindowContainer extends WindowContainer<DisplayContent>              // It may be nothing to resume because there are pausing activities or all the top              // activities are resumed. Then it still needs to make sure all visible activities are              // running in case the tasks were reordered or there are non-top visible activities. -            ensureActivitiesVisible(null /* starting */, 0 /* configChanges */, !PRESERVE_WINDOWS); +            ensureActivitiesVisible();          }      } @@ -2542,8 +2541,7 @@ class RootWindowContainer extends WindowContainer<DisplayContent>                      // display orientation can be updated first if needed. Otherwise there may                      // have redundant configuration changes due to apply outdated display                      // orientation (from keyguard) to activity. -                    rootTask.ensureActivitiesVisible(null /* starting */, 0 /* configChanges */, -                            false /* preserveWindows */); +                    rootTask.ensureActivitiesVisible(null /* starting */);                  }              });          } @@ -2885,8 +2883,7 @@ class RootWindowContainer extends WindowContainer<DisplayContent>              if (allowDelay) {                  result[0] &= task.goToSleepIfPossible(shuttingDown);              } else { -                task.ensureActivitiesVisible(null /* starting */, 0 /* configChanges */, -                        !PRESERVE_WINDOWS); +                task.ensureActivitiesVisible(null /* starting */);              }          });          return result[0]; @@ -3774,8 +3771,7 @@ class RootWindowContainer extends WindowContainer<DisplayContent>                  }              }              if (!mHasActivityStarted) { -                ensureActivitiesVisible(null /* starting */, 0 /* configChanges */, -                        false /* preserveWindows */); +                ensureActivitiesVisible();              }              return mHasActivityStarted;          } diff --git a/services/core/java/com/android/server/wm/Task.java b/services/core/java/com/android/server/wm/Task.java index dbfcc22c6903..c674176e766d 100644 --- a/services/core/java/com/android/server/wm/Task.java +++ b/services/core/java/com/android/server/wm/Task.java @@ -90,7 +90,6 @@ import static com.android.server.wm.ActivityTaskManagerDebugConfig.TAG_WITH_CLAS  import static com.android.server.wm.ActivityTaskManagerService.H.FIRST_ACTIVITY_TASK_MSG;  import static com.android.server.wm.ActivityTaskSupervisor.DEFER_RESUME;  import static com.android.server.wm.ActivityTaskSupervisor.ON_TOP; -import static com.android.server.wm.ActivityTaskSupervisor.PRESERVE_WINDOWS;  import static com.android.server.wm.ActivityTaskSupervisor.REMOVE_FROM_RECENTS;  import static com.android.server.wm.ActivityTaskSupervisor.printThisActivity;  import static com.android.server.wm.IdentifierProto.HASH_CODE; @@ -760,7 +759,7 @@ class Task extends TaskFragment {              return;          }          mResizeMode = resizeMode; -        mRootWindowContainer.ensureActivitiesVisible(null, 0, !PRESERVE_WINDOWS); +        mRootWindowContainer.ensureActivitiesVisible();          mRootWindowContainer.resumeFocusedTasksTopActivities();          updateTaskDescription();      } @@ -801,15 +800,14 @@ class Task extends TaskFragment {              if (setBounds(bounds, forced) != BOUNDS_CHANGE_NONE) {                  final ActivityRecord r = topRunningActivityLocked();                  if (r != null) { -                    kept = r.ensureActivityConfiguration(0 /* globalChanges */, -                            preserveWindow); +                    kept = r.ensureActivityConfiguration();                      // Preserve other windows for resizing because if resizing happens when there                      // is a dialog activity in the front, the activity that still shows some                      // content to the user will become black and cause flickers. Note in most cases                      // this won't cause tons of irrelevant windows being preserved because only                      // activities in this task may experience a bounds change. Configs for other                      // activities stay the same. -                    mRootWindowContainer.ensureActivitiesVisible(r, 0, preserveWindow); +                    mRootWindowContainer.ensureActivitiesVisible(r);                      if (!kept) {                          mRootWindowContainer.resumeFocusedTasksTopActivities();                      } @@ -915,7 +913,7 @@ class Task extends TaskFragment {          if (!deferResume) {              // The task might have already been running and its visibility needs to be synchronized              // with the visibility of the root task / windows. -            root.ensureActivitiesVisible(null, 0, PRESERVE_WINDOWS); +            root.ensureActivitiesVisible();              root.resumeFocusedTasksTopActivities();          } @@ -4752,7 +4750,7 @@ class Task extends TaskFragment {          }          if (!mTaskSupervisor.isRootVisibilityUpdateDeferred()) { -            mRootWindowContainer.ensureActivitiesVisible(null, 0, PRESERVE_WINDOWS); +            mRootWindowContainer.ensureActivitiesVisible();              mRootWindowContainer.resumeFocusedTasksTopActivities();          }      } @@ -4793,8 +4791,7 @@ class Task extends TaskFragment {          mRootWindowContainer.resumeFocusedTasksTopActivities();          // Update visibility of activities before notifying WM. This way it won't try to resize          // windows that are no longer visible. -        mRootWindowContainer.ensureActivitiesVisible(null /* starting */, 0 /* configChanges */, -                !PRESERVE_WINDOWS); +        mRootWindowContainer.ensureActivitiesVisible();      }      final boolean isOnHomeDisplay() { @@ -4938,41 +4935,27 @@ class Task extends TaskFragment {       * @param starting The top most activity in the task.       *                 The activity is either starting or resuming.       *                 Caller should ensure starting activity is visible. -     * @param preserveWindows Flag indicating whether windows should be preserved when updating -     *                        configuration in {@link EnsureActivitiesVisibleHelper}. -     * @param configChanges Parts of the configuration that changed for this activity for evaluating -     *                      if the screen should be frozen as part of -     *                      {@link EnsureActivitiesVisibleHelper}. -     *       */ -    void ensureActivitiesVisible(@Nullable ActivityRecord starting, int configChanges, -            boolean preserveWindows) { -        ensureActivitiesVisible(starting, configChanges, preserveWindows, true /* notifyClients */); +    void ensureActivitiesVisible(@Nullable ActivityRecord starting) { +        ensureActivitiesVisible(starting, true /* notifyClients */);      }      /**       * Ensure visibility with an option to also update the configuration of visible activities. -     * @see #ensureActivitiesVisible(ActivityRecord, int, boolean) -     * @see RootWindowContainer#ensureActivitiesVisible(ActivityRecord, int, boolean) +     * @see #ensureActivitiesVisible(ActivityRecord) +     * @see RootWindowContainer#ensureActivitiesVisible()       * @param starting The top most activity in the task.       *                 The activity is either starting or resuming.       *                 Caller should ensure starting activity is visible.       * @param notifyClients Flag indicating whether the visibility updates should be sent to the       *                      clients in {@link EnsureActivitiesVisibleHelper}. -     * @param preserveWindows Flag indicating whether windows should be preserved when updating -     *                        configuration in {@link EnsureActivitiesVisibleHelper}. -     * @param configChanges Parts of the configuration that changed for this activity for evaluating -     *                      if the screen should be frozen as part of -     *                      {@link EnsureActivitiesVisibleHelper}.       */      // TODO: Should be re-worked based on the fact that each task as a root task in most cases. -    void ensureActivitiesVisible(@Nullable ActivityRecord starting, int configChanges, -            boolean preserveWindows, boolean notifyClients) { +    void ensureActivitiesVisible(@Nullable ActivityRecord starting, boolean notifyClients) {          mTaskSupervisor.beginActivityVisibilityUpdate();          try {              forAllLeafTasks(task -> { -                task.updateActivityVisibilities(starting, configChanges, preserveWindows, -                        notifyClients); +                task.updateActivityVisibilities(starting, notifyClients);              }, true /* traverseTopToBottom */);              if (mTranslucentActivityWaiting != null && @@ -5273,7 +5256,7 @@ class Task extends TaskFragment {              // tell WindowManager that r is visible even though it is at the back of the root              // task.              r.setVisibility(true); -            ensureActivitiesVisible(null, 0, !PRESERVE_WINDOWS); +            ensureActivitiesVisible(null /* starting */);              // If launching behind, the app will start regardless of what's above it, so mark it              // as unknown even before prior `pause`. This also prevents a race between set-ready              // and activityPause. Launch-behind is basically only used for dream now. diff --git a/services/core/java/com/android/server/wm/TaskDisplayArea.java b/services/core/java/com/android/server/wm/TaskDisplayArea.java index c57983c53d37..90a3b25303f5 100644 --- a/services/core/java/com/android/server/wm/TaskDisplayArea.java +++ b/services/core/java/com/android/server/wm/TaskDisplayArea.java @@ -1777,13 +1777,11 @@ final class TaskDisplayArea extends DisplayArea<WindowContainer> {          void onRootTaskOrderChanged(Task rootTask);      } -    void ensureActivitiesVisible(ActivityRecord starting, int configChanges, -            boolean preserveWindows, boolean notifyClients) { +    void ensureActivitiesVisible(ActivityRecord starting, boolean notifyClients) {          mAtmService.mTaskSupervisor.beginActivityVisibilityUpdate();          try {              forAllRootTasks(rootTask -> { -                rootTask.ensureActivitiesVisible(starting, configChanges, preserveWindows, -                        notifyClients); +                rootTask.ensureActivitiesVisible(starting, notifyClients);              });          } finally {              mAtmService.mTaskSupervisor.endActivityVisibilityUpdate(); diff --git a/services/core/java/com/android/server/wm/TaskFragment.java b/services/core/java/com/android/server/wm/TaskFragment.java index 5d019122d52e..d425bdf5613f 100644 --- a/services/core/java/com/android/server/wm/TaskFragment.java +++ b/services/core/java/com/android/server/wm/TaskFragment.java @@ -57,7 +57,6 @@ import static com.android.server.wm.ActivityTaskManagerDebugConfig.POSTFIX_SWITC  import static com.android.server.wm.ActivityTaskManagerDebugConfig.POSTFIX_TRANSITION;  import static com.android.server.wm.ActivityTaskManagerDebugConfig.TAG_ATM;  import static com.android.server.wm.ActivityTaskManagerDebugConfig.TAG_WITH_CLASS_NAME; -import static com.android.server.wm.ActivityTaskSupervisor.PRESERVE_WINDOWS;  import static com.android.server.wm.ActivityTaskSupervisor.printThisActivity;  import static com.android.server.wm.IdentifierProto.HASH_CODE;  import static com.android.server.wm.IdentifierProto.TITLE; @@ -950,8 +949,7 @@ class TaskFragment extends WindowContainer<WindowContainer> {          }          if (shouldSleep) { -            updateActivityVisibilities(null /* starting */, 0 /* configChanges */, -                    !PRESERVE_WINDOWS, true /* notifyClients */); +            updateActivityVisibilities(null /* starting */, true /* notifyClients */);          }          return shouldSleep; @@ -1218,12 +1216,11 @@ class TaskFragment extends WindowContainer<WindowContainer> {          return top != null && top.mLaunchTaskBehind;      } -    final void updateActivityVisibilities(@Nullable ActivityRecord starting, int configChanges, -            boolean preserveWindows, boolean notifyClients) { +    final void updateActivityVisibilities(@Nullable ActivityRecord starting, +            boolean notifyClients) {          mTaskSupervisor.beginActivityVisibilityUpdate();          try { -            mEnsureActivitiesVisibleHelper.process( -                    starting, configChanges, preserveWindows, notifyClients); +            mEnsureActivitiesVisibleHelper.process(starting, notifyClients);          } finally {              mTaskSupervisor.endActivityVisibilityUpdate();          } @@ -1249,8 +1246,7 @@ class TaskFragment extends WindowContainer<WindowContainer> {          if (mResumedActivity == next && next.isState(RESUMED)                  && taskDisplayArea.allResumedActivitiesComplete()) {              // Ensure the visibility gets updated before execute app transition. -            taskDisplayArea.ensureActivitiesVisible(null /* starting */, 0 /* configChanges */, -                    false /* preserveWindows */, true /* notifyClients */); +            taskDisplayArea.ensureActivitiesVisible(null /* starting */, true /* notifyClients */);              // Make sure we have executed any pending transitions, since there              // should be nothing left to do at this point.              executeAppTransition(options); @@ -1907,7 +1903,7 @@ class TaskFragment extends WindowContainer<WindowContainer> {              prev.resumeKeyDispatchingLocked();          } -        mRootWindowContainer.ensureActivitiesVisible(resuming, 0, !PRESERVE_WINDOWS); +        mRootWindowContainer.ensureActivitiesVisible(resuming);          // Notify when the task stack has changed, but only if visibilities changed (not just          // focus). Also if there is an active root pinned task - we always want to notify it about diff --git a/services/core/java/com/android/server/wm/Transition.java b/services/core/java/com/android/server/wm/Transition.java index 3117db5f27f0..b12855e2bb49 100644 --- a/services/core/java/com/android/server/wm/Transition.java +++ b/services/core/java/com/android/server/wm/Transition.java @@ -1136,8 +1136,7 @@ class Transition implements BLASTSyncEngine.TransactionReadyListener {              // The transient hide tasks could be occluded now, e.g. returning to home. So trigger              // the update to make the activities in the tasks invisible-requested, then the next              // step can continue to commit the visibility. -            mController.mAtm.mRootWindowContainer.ensureActivitiesVisible(null /* starting */, -                    0 /* configChanges */, true /* preserveWindows */); +            mController.mAtm.mRootWindowContainer.ensureActivitiesVisible();              // Record all the now-hiding activities so that they are committed. Just use              // mParticipants because we can avoid a new list this way.              for (int i = 0; i < mTransientHideTasks.size(); ++i) { @@ -2863,8 +2862,7 @@ class Transition implements BLASTSyncEngine.TransactionReadyListener {       * check whether to deliver the new configuration to clients.       */      @Nullable -    ArrayList<ActivityRecord> applyDisplayChangeIfNeeded() { -        ArrayList<ActivityRecord> activitiesMayChange = null; +    void applyDisplayChangeIfNeeded(@NonNull ArraySet<WindowContainer<?>> activitiesMayChange) {          for (int i = mParticipants.size() - 1; i >= 0; --i) {              final WindowContainer<?> wc = mParticipants.valueAt(i);              final DisplayContent dc = wc.asDisplayContent(); @@ -2881,18 +2879,13 @@ class Transition implements BLASTSyncEngine.TransactionReadyListener {              // If the update is deferred, sendNewConfiguration won't deliver new configuration to              // clients, then it is the caller's responsibility to deliver the changes.              if (mController.mAtm.mTaskSupervisor.isRootVisibilityUpdateDeferred()) { -                if (activitiesMayChange == null) { -                    activitiesMayChange = new ArrayList<>(); -                } -                final ArrayList<ActivityRecord> visibleActivities = activitiesMayChange;                  dc.forAllActivities(r -> {                      if (r.isVisibleRequested()) { -                        visibleActivities.add(r); +                        activitiesMayChange.add(r);                      }                  });              }          } -        return activitiesMayChange;      }      boolean getLegacyIsReady() { diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java index c1310a6880fd..dda33f3f501b 100644 --- a/services/core/java/com/android/server/wm/WindowManagerService.java +++ b/services/core/java/com/android/server/wm/WindowManagerService.java @@ -3105,7 +3105,7 @@ public class WindowManagerService extends IWindowManager.Stub          try {              synchronized (mGlobalLock) {                  if (mAtmService.mKeyguardController.isKeyguardShowing(DEFAULT_DISPLAY)) { -                    mRoot.ensureActivitiesVisible(null, 0, false /* preserveWindows */); +                    mRoot.ensureActivitiesVisible();                  }              }          } finally { diff --git a/services/core/java/com/android/server/wm/WindowOrganizerController.java b/services/core/java/com/android/server/wm/WindowOrganizerController.java index 4b99432b2943..9e4a31c3773a 100644 --- a/services/core/java/com/android/server/wm/WindowOrganizerController.java +++ b/services/core/java/com/android/server/wm/WindowOrganizerController.java @@ -65,7 +65,6 @@ import static android.window.WindowContainerTransaction.HierarchyOp.HIERARCHY_OP  import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_WINDOW_ORGANIZER;  import static com.android.server.wm.ActivityRecord.State.PAUSING;  import static com.android.server.wm.ActivityTaskManagerService.enforceTaskPermission; -import static com.android.server.wm.ActivityTaskSupervisor.PRESERVE_WINDOWS;  import static com.android.server.wm.ActivityTaskSupervisor.REMOVE_FROM_RECENTS;  import static com.android.server.wm.Task.FLAG_FORCE_HIDDEN_FOR_PINNED_TASK;  import static com.android.server.wm.Task.FLAG_FORCE_HIDDEN_FOR_TASK_ORG; @@ -571,14 +570,15 @@ class WindowOrganizerController extends IWindowOrganizerController.Stub          mService.deferWindowLayout();          mService.mTaskSupervisor.setDeferRootVisibilityUpdate(true /* deferUpdate */);          try { -            final ArrayList<ActivityRecord> activitiesMayChange = -                    transition != null ? transition.applyDisplayChangeIfNeeded() : null; -            if (activitiesMayChange != null) { -                effects |= TRANSACT_EFFECTS_CLIENT_CONFIG; +            final ArraySet<WindowContainer<?>> haveConfigChanges = new ArraySet<>(); +            if (transition != null) { +                transition.applyDisplayChangeIfNeeded(haveConfigChanges); +                if (!haveConfigChanges.isEmpty()) { +                    effects |= TRANSACT_EFFECTS_CLIENT_CONFIG; +                }              }              final List<WindowContainerTransaction.HierarchyOp> hops = t.getHierarchyOps();              final int hopSize = hops.size(); -            final ArraySet<WindowContainer<?>> haveConfigChanges = new ArraySet<>();              Iterator<Map.Entry<IBinder, WindowContainerTransaction.Change>> entries =                      t.getChanges().entrySet().iterator();              while (entries.hasNext()) { @@ -626,7 +626,7 @@ class WindowOrganizerController extends IWindowOrganizerController.Stub                      // When removing pip, make sure that onStop is sent to the app ahead of                      // onPictureInPictureModeChanged.                      // See also PinnedStackTests#testStopBeforeMultiWindowCallbacksOnDismiss -                    wc.asTask().ensureActivitiesVisible(null, 0, PRESERVE_WINDOWS); +                    wc.asTask().ensureActivitiesVisible(null /* starting */);                      wc.asTask().mTaskSupervisor.processStoppingAndFinishingActivities(                              null /* launchedActivity */, false /* processPausingActivities */,                              "force-stop-on-removing-pip"); @@ -692,29 +692,16 @@ class WindowOrganizerController extends IWindowOrganizerController.Stub              if ((effects & TRANSACT_EFFECTS_LIFECYCLE) != 0) {                  mService.mTaskSupervisor.setDeferRootVisibilityUpdate(false /* deferUpdate */);                  // Already calls ensureActivityConfig -                mService.mRootWindowContainer.ensureActivitiesVisible(null, 0, PRESERVE_WINDOWS); +                mService.mRootWindowContainer.ensureActivitiesVisible();                  mService.mRootWindowContainer.resumeFocusedTasksTopActivities();              } else if ((effects & TRANSACT_EFFECTS_CLIENT_CONFIG) != 0) {                  for (int i = haveConfigChanges.size() - 1; i >= 0; --i) {                      haveConfigChanges.valueAt(i).forAllActivities(r -> { -                        r.ensureActivityConfiguration(0, PRESERVE_WINDOWS); -                        if (activitiesMayChange != null) { -                            activitiesMayChange.remove(r); +                        if (r.isVisibleRequested()) { +                            r.ensureActivityConfiguration(true /* ignoreVisibility */);                          }                      });                  } -                // TODO(b/258618073): Combine with haveConfigChanges after confirming that there -                //  is no problem to always preserve window. Currently this uses the parameters -                //  as ATMS#ensureConfigAndVisibilityAfterUpdate. -                if (activitiesMayChange != null) { -                    for (int i = activitiesMayChange.size() - 1; i >= 0; --i) { -                        final ActivityRecord ar = activitiesMayChange.get(i); -                        if (!ar.isVisibleRequested()) continue; -                        ar.ensureActivityConfiguration(0 /* globalChanges */, -                                !PRESERVE_WINDOWS, true /* ignoreVisibility */, -                                false /* isRequestedOrientationChanged */); -                    } -                }              }              if (effects != 0) { diff --git a/services/core/java/com/android/server/wm/WindowProcessController.java b/services/core/java/com/android/server/wm/WindowProcessController.java index 5721750fbf63..9e2e460b8ae4 100644 --- a/services/core/java/com/android/server/wm/WindowProcessController.java +++ b/services/core/java/com/android/server/wm/WindowProcessController.java @@ -989,7 +989,7 @@ public class WindowProcessController extends ConfigurationContainer<Configuratio              if (packageName.equals(r.packageName)                      && r.applyAppSpecificConfig(nightMode, localesOverride, gender)                      && r.isVisibleRequested()) { -                r.ensureActivityConfiguration(0 /* globalChanges */, true /* preserveWindow */); +                r.ensureActivityConfiguration();              }          }      } @@ -1723,7 +1723,7 @@ public class WindowProcessController extends ConfigurationContainer<Configuratio              overrideConfig.assetsSeq = assetSeq;              r.onRequestedOverrideConfigurationChanged(overrideConfig);              if (r.isVisibleRequested()) { -                r.ensureActivityConfiguration(0, true); +                r.ensureActivityConfiguration();              }          }      } diff --git a/services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java b/services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java index 718c59875c1a..b20c51f50337 100644 --- a/services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java +++ b/services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java @@ -320,7 +320,7 @@ public class ActivityRecordTests extends WindowTestsBase {      }      private void ensureActivityConfiguration(ActivityRecord activity) { -        activity.ensureActivityConfiguration(0 /* globalChanges */, false /* preserveWindow */); +        activity.ensureActivityConfiguration();      }      @Test @@ -718,7 +718,7 @@ public class ActivityRecordTests extends WindowTestsBase {          // Clear size compat.          activity.clearSizeCompatMode(); -        activity.ensureActivityConfiguration(0 /* globalChanges */, false /* preserveWindow */); +        activity.ensureActivityConfiguration();          mDisplayContent.sendNewConfiguration();          // Relaunching the app should still respect the orientation request. @@ -819,8 +819,7 @@ public class ActivityRecordTests extends WindowTestsBase {              task.onConfigurationChanged(newConfig); -            activity.ensureActivityConfiguration(0 /* globalChanges */, -                    false /* preserveWindow */, true /* ignoreVisibility */); +            activity.ensureActivityConfiguration(true /* ignoreVisibility */);              final ActivityConfigurationChangeItem expected =                      ActivityConfigurationChangeItem.obtain(activity.token, @@ -1563,8 +1562,7 @@ public class ActivityRecordTests extends WindowTestsBase {          topActivity.nowVisible = true;          topActivity.setState(RESUMED, "true");          doCallRealMethod().when(mRootWindowContainer).ensureActivitiesVisible( -                any() /* starting */, anyInt() /* configChanges */, -                anyBoolean() /* preserveWindows */, anyBoolean() /* notifyClients */); +                any() /* starting */, anyBoolean() /* notifyClients */);          topActivity.setShowWhenLocked(true);          // Verify the stack-top activity is occluded keyguard. @@ -1624,7 +1622,6 @@ public class ActivityRecordTests extends WindowTestsBase {          secondActivity.finishing = true;          secondActivity.completeFinishing("test");          verify(secondActivity.mDisplayContent).ensureActivitiesVisible(null /* starting */, -                0 /* configChanges */ , false /* preserveWindows */,                  true /* notifyClients */);          // Finish the first activity @@ -1632,7 +1629,6 @@ public class ActivityRecordTests extends WindowTestsBase {          firstActivity.setVisibleRequested(true);          firstActivity.completeFinishing("test");          verify(firstActivity.mDisplayContent, times(2)).ensureActivitiesVisible(null /* starting */, -                0 /* configChanges */ , false /* preserveWindows */,                  true /* notifyClients */);          // Remove the translucent activity and clear invocations for next test @@ -1960,6 +1956,7 @@ public class ActivityRecordTests extends WindowTestsBase {          display.continueUpdateOrientationForDiffOrienLaunchingApp();          assertTrue(display.isFixedRotationLaunchingApp(activity)); +        activity.stopFreezingScreen(true /* unfreezeSurfaceNow */, true /* force */);          // Simulate the rotation has been updated to previous one, e.g. sensor updates before the          // remote rotation is completed.          doReturn(originalRotation).when(displayRotation).rotationForOrientation( @@ -1970,14 +1967,12 @@ public class ActivityRecordTests extends WindowTestsBase {          activity.finishFixedRotationTransform();          final ScreenRotationAnimation rotationAnim = display.getRotationAnimation();          assertNotNull(rotationAnim); -        rotationAnim.setRotation(display.getPendingTransaction(), originalRotation);          // Because the display doesn't rotate, the rotated activity needs to cancel the fixed          // rotation. There should be a rotation animation to cover the change of activity.          verify(activity).onCancelFixedRotationTransform(rotatedInfo.rotation);          assertTrue(activity.isFreezingScreen());          assertFalse(displayRotation.isRotatingSeamlessly()); -        assertTrue(rotationAnim.isRotating());          // Simulate the remote rotation has completed and the configuration doesn't change, then          // the rotated activity should also be restored by clearing the transform. @@ -3697,7 +3692,7 @@ public class ActivityRecordTests extends WindowTestsBase {          doReturn(false).when(activity).showToCurrentUser();          spyOn(taskFragment);          doReturn(false).when(taskFragment).shouldBeVisible(any()); -        display.ensureActivitiesVisible(null, 0, false, false); +        display.ensureActivitiesVisible(null /* starting */, false /* notifyClients */);          assertFalse(activity.isVisibleRequested());      } diff --git a/services/tests/wmtests/src/com/android/server/wm/DisplayContentTests.java b/services/tests/wmtests/src/com/android/server/wm/DisplayContentTests.java index dfe79bf1e3e6..6497ee9cb1f2 100644 --- a/services/tests/wmtests/src/com/android/server/wm/DisplayContentTests.java +++ b/services/tests/wmtests/src/com/android/server/wm/DisplayContentTests.java @@ -75,7 +75,6 @@ import static com.android.dx.mockito.inline.extended.ExtendedMockito.doReturn;  import static com.android.dx.mockito.inline.extended.ExtendedMockito.mock;  import static com.android.dx.mockito.inline.extended.ExtendedMockito.never;  import static com.android.dx.mockito.inline.extended.ExtendedMockito.reset; -import static com.android.dx.mockito.inline.extended.ExtendedMockito.same;  import static com.android.dx.mockito.inline.extended.ExtendedMockito.spyOn;  import static com.android.dx.mockito.inline.extended.ExtendedMockito.verify;  import static com.android.server.wm.ActivityTaskSupervisor.ON_TOP; @@ -490,7 +489,7 @@ public class DisplayContentTests extends WindowTestsBase {          newOverrideConfig.fontScale += 0.3;          defaultDisplay.updateDisplayOverrideConfigurationLocked(newOverrideConfig, -                null /* starting */, false /* deferResume */, null /* result */); +                null /* starting */, false /* deferResume */);          // Check that global configuration is updated, as we've updated default display's config.          Configuration globalConfig = mWm.mRoot.getConfiguration(); @@ -499,7 +498,7 @@ public class DisplayContentTests extends WindowTestsBase {          // Return back to original values.          defaultDisplay.updateDisplayOverrideConfigurationLocked(currentConfig, -                null /* starting */, false /* deferResume */, null /* result */); +                null /* starting */, false /* deferResume */);          globalConfig = mWm.mRoot.getConfiguration();          assertEquals(currentConfig.densityDpi, globalConfig.densityDpi);          assertEquals(currentConfig.fontScale, globalConfig.fontScale, 0.1 /* delta */); @@ -1176,7 +1175,7 @@ public class DisplayContentTests extends WindowTestsBase {          activity.setRequestedOrientation(newOrientation);          verify(dc, never()).updateDisplayOverrideConfigurationLocked(any(), eq(activity), -                anyBoolean(), same(null)); +                anyBoolean());          assertEquals(ROTATION_180, dc.getRotation());      } @@ -2123,10 +2122,8 @@ public class DisplayContentTests extends WindowTestsBase {          // Once transition starts, rotation is applied and transition shows DC rotating.          testPlayer.startTransition();          waitUntilHandlersIdle(); -        verify(activity1).ensureActivityConfiguration(anyInt(), anyBoolean(), anyBoolean(), -                anyBoolean()); -        verify(activity2).ensureActivityConfiguration(anyInt(), anyBoolean(), anyBoolean(), -                anyBoolean()); +        verify(activity1).ensureActivityConfiguration(anyBoolean(), anyBoolean()); +        verify(activity2).ensureActivityConfiguration(anyBoolean(), anyBoolean());          assertNotEquals(origRot, dc.getConfiguration().windowConfiguration.getRotation());          assertNotNull(testPlayer.mLastReady);          assertTrue(testPlayer.mController.isPlaying()); @@ -2248,11 +2245,11 @@ public class DisplayContentTests extends WindowTestsBase {              // The assertion will fail if DisplayArea#ensureActivitiesVisible is called twice.              assertFalse(called[0]);              called[0] = true; -            mDisplayContent.ensureActivitiesVisible(null, 0, false, false); +            mDisplayContent.ensureActivitiesVisible(null, false);              return null; -        }).when(mockTda).ensureActivitiesVisible(any(), anyInt(), anyBoolean(), anyBoolean()); +        }).when(mockTda).ensureActivitiesVisible(any(), anyBoolean()); -        mDisplayContent.ensureActivitiesVisible(null, 0, false, false); +        mDisplayContent.ensureActivitiesVisible(null, false);      }      @Test diff --git a/services/tests/wmtests/src/com/android/server/wm/RecentsAnimationTest.java b/services/tests/wmtests/src/com/android/server/wm/RecentsAnimationTest.java index 8de45b039f62..32b3558ba397 100644 --- a/services/tests/wmtests/src/com/android/server/wm/RecentsAnimationTest.java +++ b/services/tests/wmtests/src/com/android/server/wm/RecentsAnimationTest.java @@ -106,8 +106,7 @@ public class RecentsAnimationTest extends WindowTestsBase {          topActivity.getRootTask().moveToFront("testRecentsActivityVisiblility");          doCallRealMethod().when(mRootWindowContainer).ensureActivitiesVisible( -                any() /* starting */, anyInt() /* configChanges */, -                anyBoolean() /* preserveWindows */, anyBoolean() /* notifyClients */); +                any() /* starting */, anyBoolean() /* notifyClients */);          RecentsAnimationCallbacks recentsAnimation = startRecentsActivity(                  mRecentsComponent, true /* getRecentsAnimation */); @@ -178,8 +177,7 @@ public class RecentsAnimationTest extends WindowTestsBase {          mAtm.startRecentsActivity(recentsIntent, 0 /* eventTime */,                  null /* recentsAnimationRunner */); -        verify(recentsActivity).ensureActivityConfiguration(anyInt() /* globalChanges */, -                anyBoolean() /* preserveWindow */, eq(true) /* ignoreVisibility */); +        verify(recentsActivity).ensureActivityConfiguration(eq(true) /* ignoreVisibility */);          assertThat(mSupervisor.mStoppingActivities).contains(recentsActivity);      } @@ -199,8 +197,7 @@ public class RecentsAnimationTest extends WindowTestsBase {                  "testRestartRecentsActivity");          doCallRealMethod().when(mRootWindowContainer).ensureActivitiesVisible( -                any() /* starting */, anyInt() /* configChanges */, -                anyBoolean() /* preserveWindows */, anyBoolean() /* notifyClients */); +                any() /* starting */, anyBoolean() /* notifyClients */);          doReturn(app).when(mAtm).getProcessController(eq(recentActivity.processName), anyInt());          doNothing().when(mClientLifecycleManager).scheduleTransaction(any()); @@ -354,8 +351,7 @@ public class RecentsAnimationTest extends WindowTestsBase {          doReturn(TEST_USER_ID).when(mAtm).getCurrentUserId();          doCallRealMethod().when(mRootWindowContainer).ensureActivitiesVisible( -                any() /* starting */, anyInt() /* configChanges */, -                anyBoolean() /* preserveWindows */, anyBoolean() /* notifyClients */); +                any() /* starting */, anyBoolean() /* notifyClients */);          startRecentsActivity(otherUserHomeActivity.getTask().getBaseIntent().getComponent(),                  true); diff --git a/services/tests/wmtests/src/com/android/server/wm/RootTaskTests.java b/services/tests/wmtests/src/com/android/server/wm/RootTaskTests.java index 89cd7266915c..b5883b1aefe5 100644 --- a/services/tests/wmtests/src/com/android/server/wm/RootTaskTests.java +++ b/services/tests/wmtests/src/com/android/server/wm/RootTaskTests.java @@ -823,8 +823,7 @@ public class RootTaskTests extends WindowTestsBase {                  .build();          doReturn(false).when(secondActivity).occludesParent(); -        homeRootTask.ensureActivitiesVisible(null /* starting */, 0 /* configChanges */, -                false /* preserveWindows */); +        homeRootTask.ensureActivitiesVisible(null /* starting */);          assertTrue(firstActivity.shouldBeVisible());      } @@ -1419,8 +1418,7 @@ public class RootTaskTests extends WindowTestsBase {          // Any common path that updates activity visibility should clear the unknown visibility          // records that are no longer visible according to hierarchy. -        task.ensureActivitiesVisible(null /* starting */, 0 /* configChanges */, -                false /* preserveWindows */); +        task.ensureActivitiesVisible(null /* starting */);          // Assume the top activity relayouted, just remove it directly.          unknownAppVisibilityController.appRemovedOrHidden(activities[1]);          // All unresolved records should be removed. @@ -1441,8 +1439,7 @@ public class RootTaskTests extends WindowTestsBase {          doNothing().when(mSupervisor).startSpecificActivity(any(), anyBoolean(),                  anyBoolean()); -        task.ensureActivitiesVisible(null /* starting */, 0 /* configChanges */, -                false /* preserveWindows */); +        task.ensureActivitiesVisible(null /* starting */);          verify(mSupervisor).startSpecificActivity(any(), eq(false) /* andResume */,                  anyBoolean());      } diff --git a/services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java b/services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java index c3102e08489d..5518c604446d 100644 --- a/services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java +++ b/services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java @@ -947,7 +947,7 @@ public class SizeCompatTests extends WindowTestsBase {          // Recompute the natural configuration in the new display.          mActivity.clearSizeCompatMode(); -        mActivity.ensureActivityConfiguration(0 /* globalChanges */, false /* preserveWindow */); +        mActivity.ensureActivityConfiguration();          // Because the display cannot rotate, the portrait activity will fit the short side of          // display with keeping portrait bounds [200, 0 - 700, 1000] in center.          assertEquals(newDisplayBounds.height(), currentBounds.height()); @@ -4858,7 +4858,7 @@ public class SizeCompatTests extends WindowTestsBase {          }          // Make sure to use the provided configuration to construct the size compat fields.          activity.clearSizeCompatMode(); -        activity.ensureActivityConfiguration(0 /* globalChanges */, false /* preserveWindow */); +        activity.ensureActivityConfiguration();          // Make sure the display configuration reflects the change of activity.          if (activity.mDisplayContent.updateOrientation()) {              activity.mDisplayContent.sendNewConfiguration(); diff --git a/services/tests/wmtests/src/com/android/server/wm/SystemServicesTestRule.java b/services/tests/wmtests/src/com/android/server/wm/SystemServicesTestRule.java index 8cd9ff359111..90493d4dc95f 100644 --- a/services/tests/wmtests/src/com/android/server/wm/SystemServicesTestRule.java +++ b/services/tests/wmtests/src/com/android/server/wm/SystemServicesTestRule.java @@ -375,8 +375,7 @@ public class SystemServicesTestRule implements TestRule {          // Always keep things awake.          doReturn(true).when(mWmService.mRoot).hasAwakeDisplay();          // Called when moving activity to pinned stack. -        doNothing().when(mWmService.mRoot).ensureActivitiesVisible(any(), -                anyInt(), anyBoolean(), anyBoolean()); +        doNothing().when(mWmService.mRoot).ensureActivitiesVisible(any(), anyBoolean());          spyOn(mWmService.mDisplayWindowSettings);          spyOn(mWmService.mDisplayWindowSettingsProvider); diff --git a/services/tests/wmtests/src/com/android/server/wm/TaskFragmentTest.java b/services/tests/wmtests/src/com/android/server/wm/TaskFragmentTest.java index ec068bed1a3b..00e22fd7142a 100644 --- a/services/tests/wmtests/src/com/android/server/wm/TaskFragmentTest.java +++ b/services/tests/wmtests/src/com/android/server/wm/TaskFragmentTest.java @@ -269,8 +269,7 @@ public class TaskFragmentTest extends WindowTestsBase {          mTaskFragment.getTask().addChild(activityBelow, 0);          // Ensure the activity below is visible -        mTaskFragment.getTask().ensureActivitiesVisible(null /* starting */, 0 /* configChanges */, -                false /* preserveWindows */); +        mTaskFragment.getTask().ensureActivitiesVisible(null /* starting */);          assertEquals(true, activityBelow.isVisibleRequested());      } diff --git a/services/tests/wmtests/src/com/android/server/wm/TaskTests.java b/services/tests/wmtests/src/com/android/server/wm/TaskTests.java index da7612b17dc9..45e1e9579f3b 100644 --- a/services/tests/wmtests/src/com/android/server/wm/TaskTests.java +++ b/services/tests/wmtests/src/com/android/server/wm/TaskTests.java @@ -339,16 +339,14 @@ public class TaskTests extends WindowTestsBase {          // Check visibility of occluded tasks          doReturn(false).when(leafTask1).shouldBeVisible(any());          doReturn(true).when(leafTask2).shouldBeVisible(any()); -        rootTask.ensureActivitiesVisible( -                null /* starting */ , 0 /* configChanges */, false /* preserveWindows */); +        rootTask.ensureActivitiesVisible(null /* starting */);          assertFalse(activity1.isVisible());          assertTrue(activity2.isVisible());          // Check visibility of not occluded tasks          doReturn(true).when(leafTask1).shouldBeVisible(any());          doReturn(true).when(leafTask2).shouldBeVisible(any()); -        rootTask.ensureActivitiesVisible( -                null /* starting */ , 0 /* configChanges */, false /* preserveWindows */); +        rootTask.ensureActivitiesVisible(null /* starting */);          assertTrue(activity1.isVisible());          assertTrue(activity2.isVisible());      } diff --git a/services/tests/wmtests/src/com/android/server/wm/TransitionTests.java b/services/tests/wmtests/src/com/android/server/wm/TransitionTests.java index 71447e72de8c..fddd77176bd9 100644 --- a/services/tests/wmtests/src/com/android/server/wm/TransitionTests.java +++ b/services/tests/wmtests/src/com/android/server/wm/TransitionTests.java @@ -1495,8 +1495,7 @@ public class TransitionTests extends WindowTestsBase {          verify(taskSnapshotController, times(0)).recordSnapshot(eq(task1));          enteringAnimReports.clear(); -        doCallRealMethod().when(mWm.mRoot).ensureActivitiesVisible(any(), -                anyInt(), anyBoolean(), anyBoolean()); +        doCallRealMethod().when(mWm.mRoot).ensureActivitiesVisible(any(), anyBoolean());          final boolean[] wasInFinishingTransition = { false };          controller.registerLegacyListener(new WindowManagerInternal.AppTransitionListener() {              @Override diff --git a/services/tests/wmtests/src/com/android/server/wm/WindowProcessControllerTests.java b/services/tests/wmtests/src/com/android/server/wm/WindowProcessControllerTests.java index e31ee1174656..8e3dbb4a200c 100644 --- a/services/tests/wmtests/src/com/android/server/wm/WindowProcessControllerTests.java +++ b/services/tests/wmtests/src/com/android/server/wm/WindowProcessControllerTests.java @@ -38,7 +38,6 @@ import static org.junit.Assert.assertFalse;  import static org.junit.Assert.assertNull;  import static org.junit.Assert.assertTrue;  import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.anyBoolean;  import static org.mockito.ArgumentMatchers.anyInt;  import static org.mockito.ArgumentMatchers.eq;  import static org.mockito.Mockito.clearInvocations; @@ -432,7 +431,7 @@ public class WindowProcessControllerTests extends WindowTestsBase {          mWpc.updateAppSpecificSettingsForAllActivitiesInPackage(DEFAULT_COMPONENT_PACKAGE_NAME,                  Configuration.UI_MODE_NIGHT_YES, LocaleList.forLanguageTags("en-XA"),                  GRAMMATICAL_GENDER_NOT_SPECIFIED); -        verify(activity).ensureActivityConfiguration(anyInt(), anyBoolean()); +        verify(activity).ensureActivityConfiguration();      }      @Test @@ -443,7 +442,7 @@ public class WindowProcessControllerTests extends WindowTestsBase {                  Configuration.UI_MODE_NIGHT_YES, LocaleList.forLanguageTags("en-XA"),                  GRAMMATICAL_GENDER_NOT_SPECIFIED);          verify(activity, never()).applyAppSpecificConfig(anyInt(), any(), anyInt()); -        verify(activity, never()).ensureActivityConfiguration(anyInt(), anyBoolean()); +        verify(activity, never()).ensureActivityConfiguration();      }      @Test |