diff options
author | Issei Suzuki <issei@google.com> | 2019-11-21 14:53:41 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2019-11-21 14:53:41 +0000 |
commit | 17c36347cc929a5dd40558fe14eeea14676253b4 (patch) | |
tree | 33c7c995ee12d4ef9f884d02b99b327d18d90231 | |
parent | 57db484acb3723f66c781ef39ee7dff3afd896a8 (diff) | |
parent | 1669ea4bc8e9c24cd7ca8497162a5e9656134f4c (diff) |
Merge "Clean up visibility related flags in ActivityRecord"
21 files changed, 158 insertions, 152 deletions
diff --git a/core/proto/android/server/windowmanagerservice.proto b/core/proto/android/server/windowmanagerservice.proto index 56e879090665..1a4a7ce0f634 100644 --- a/core/proto/android/server/windowmanagerservice.proto +++ b/core/proto/android/server/windowmanagerservice.proto @@ -235,7 +235,7 @@ message AppWindowTokenProto { optional WindowContainerThumbnailProto thumbnail = 6; optional bool fills_parent = 7; optional bool app_stopped = 8; - optional bool hidden_requested = 9; + optional bool visible_requested = 9; optional bool client_hidden = 10; optional bool defer_hiding_client = 11; optional bool reported_drawn = 12; diff --git a/data/etc/services.core.protolog.json b/data/etc/services.core.protolog.json index ed19a37de460..5c48d9166303 100644 --- a/data/etc/services.core.protolog.json +++ b/data/etc/services.core.protolog.json @@ -73,6 +73,12 @@ "group": "WM_ERROR", "at": "com\/android\/server\/wm\/WindowManagerService.java" }, + "-1972506791": { + "message": "Set freezing of %s: hidden=%b freezing=%b visibleRequested=%b. %s", + "level": "INFO", + "group": "WM_DEBUG_ORIENTATION", + "at": "com\/android\/server\/wm\/ActivityRecord.java" + }, "-1963461591": { "message": "Removing %s from %s", "level": "VERBOSE", @@ -877,6 +883,12 @@ "group": "WM_DEBUG_ORIENTATION", "at": "com\/android\/server\/wm\/ActivityRecord.java" }, + "-229838822": { + "message": "setAppVisibility(%s, visible=%b): %s hidden=%b mVisibleRequested=%b Callers=%s", + "level": "VERBOSE", + "group": "WM_DEBUG_APP_TRANSITIONS", + "at": "com\/android\/server\/wm\/ActivityRecord.java" + }, "-198463978": { "message": "updateRotationUnchecked: alwaysSendConfiguration=%b forceRelayout=%b", "level": "VERBOSE", @@ -1201,12 +1213,6 @@ "group": "WM_DEBUG_ORIENTATION", "at": "com\/android\/server\/wm\/WindowManagerService.java" }, - "358613119": { - "message": "setAppVisibility(%s, visible=%b): %s hidden=%b hiddenRequested=%b Callers=%s", - "level": "VERBOSE", - "group": "WM_DEBUG_APP_TRANSITIONS", - "at": "com\/android\/server\/wm\/ActivityRecord.java" - }, "371641947": { "message": "Window Manager Crash %s", "level": "WTF", @@ -1489,12 +1495,6 @@ "group": "WM_DEBUG_RECENTS_ANIMATIONS", "at": "com\/android\/server\/wm\/RecentsAnimation.java" }, - "857751535": { - "message": "commitVisibility: %s: hidden=%b hiddenRequested=%b", - "level": "VERBOSE", - "group": "WM_DEBUG_APP_TRANSITIONS", - "at": "com\/android\/server\/wm\/ActivityRecord.java" - }, "873914452": { "message": "goodToGo()", "level": "DEBUG", @@ -1987,10 +1987,10 @@ "group": "WM_DEBUG_REMOTE_ANIMATIONS", "at": "com\/android\/server\/wm\/RemoteAnimationController.java" }, - "1966564525": { - "message": "Set freezing of %s: hidden=%b freezing=%b hiddenRequested=%b. %s", - "level": "INFO", - "group": "WM_DEBUG_ORIENTATION", + "1965198071": { + "message": "commitVisibility: %s: hidden=%b visibleRequested=%b", + "level": "VERBOSE", + "group": "WM_DEBUG_APP_TRANSITIONS", "at": "com\/android\/server\/wm\/ActivityRecord.java" }, "1984470582": { diff --git a/services/core/java/com/android/server/wm/ActivityMetricsLogger.java b/services/core/java/com/android/server/wm/ActivityMetricsLogger.java index 73034b020a76..0a861ade2900 100644 --- a/services/core/java/com/android/server/wm/ActivityMetricsLogger.java +++ b/services/core/java/com/android/server/wm/ActivityMetricsLogger.java @@ -548,7 +548,7 @@ class ActivityMetricsLogger { private static boolean hasActivityToBeDrawn(Task t) { for (int i = t.getChildCount() - 1; i >= 0; --i) { final ActivityRecord r = t.getChildAt(i); - if (r.visible && !r.mDrawn && !r.finishing) { + if (r.mVisibleRequested && !r.mDrawn && !r.finishing) { return true; } } diff --git a/services/core/java/com/android/server/wm/ActivityRecord.java b/services/core/java/com/android/server/wm/ActivityRecord.java index fcdb3b065ae6..f24fa077bb6c 100644 --- a/services/core/java/com/android/server/wm/ActivityRecord.java +++ b/services/core/java/com/android/server/wm/ActivityRecord.java @@ -176,7 +176,6 @@ import static com.android.server.wm.AppWindowTokenProto.CLIENT_HIDDEN; import static com.android.server.wm.AppWindowTokenProto.DEFER_HIDING_CLIENT; import static com.android.server.wm.AppWindowTokenProto.FILLS_PARENT; import static com.android.server.wm.AppWindowTokenProto.FROZEN_BOUNDS; -import static com.android.server.wm.AppWindowTokenProto.HIDDEN_REQUESTED; import static com.android.server.wm.AppWindowTokenProto.HIDDEN_SET_FROM_TRANSFERRED_STARTING_WINDOW; import static com.android.server.wm.AppWindowTokenProto.IS_ANIMATING; import static com.android.server.wm.AppWindowTokenProto.IS_WAITING_FOR_TRANSITION_START; @@ -191,6 +190,7 @@ import static com.android.server.wm.AppWindowTokenProto.STARTING_DISPLAYED; import static com.android.server.wm.AppWindowTokenProto.STARTING_MOVED; import static com.android.server.wm.AppWindowTokenProto.STARTING_WINDOW; import static com.android.server.wm.AppWindowTokenProto.THUMBNAIL; +import static com.android.server.wm.AppWindowTokenProto.VISIBLE_REQUESTED; import static com.android.server.wm.AppWindowTokenProto.WINDOW_TOKEN; import static com.android.server.wm.IdentifierProto.HASH_CODE; import static com.android.server.wm.IdentifierProto.TITLE; @@ -461,7 +461,6 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A private boolean keysPaused; // has key dispatching been paused for it? int launchMode; // the launch mode activity attribute. int lockTaskLaunchMode; // the lockTaskMode manifest attribute, subject to override - boolean visible; // does this activity's window need to be shown? boolean visibleIgnoringKeyguard; // is this activity visible, ignoring the fact that Keyguard // might hide this activity? // True if the hidden state of this token was forced to false due to a transferred starting @@ -621,11 +620,11 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A // case do not clear allDrawn until the animation completes. boolean deferClearAllDrawn; - // Is this window's surface needed? This is almost like hidden, except - // it will sometimes be true a little earlier: when the token has + // Is this window's surface needed? This is almost like visible, except + // it will sometimes be true a little earlier: when the activity record has // been shown, but is still waiting for its app transition to execute // before making its windows shown. - boolean hiddenRequested; + boolean mVisibleRequested; // Last visibility state we reported to the app token. boolean reportedVisible; @@ -832,7 +831,6 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A pw.print(" finishing="); pw.println(finishing); pw.print(prefix); pw.print("keysPaused="); pw.print(keysPaused); pw.print(" inHistory="); pw.print(inHistory); - pw.print(" visible="); pw.print(visible); pw.print(" sleeping="); pw.print(sleeping); pw.print(" idle="); pw.print(idle); pw.print(" mStartingWindowState="); @@ -856,7 +854,8 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A } pw.print(prefix); pw.print(" mOccludesParent="); pw.print(mOccludesParent); pw.print(" mOrientation="); pw.println(mOrientation); - pw.println(prefix + "hiddenRequested=" + hiddenRequested + " mClientHidden=" + mClientHidden + pw.println(prefix + "mVisibleRequested=" + mVisibleRequested + + " mClientHidden=" + mClientHidden + ((mDeferHidingClient) ? " mDeferHidingClient=" + mDeferHidingClient : "") + " reportedDrawn=" + reportedDrawn + " reportedVisible=" + reportedVisible); if (paused) { @@ -1483,7 +1482,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A // Application tokens start out hidden. setHidden(true); - hiddenRequested = true; + mVisibleRequested = false; ColorDisplayService.ColorDisplayServiceInternal cds = LocalServices.getService( ColorDisplayService.ColorDisplayServiceInternal.class); @@ -1512,7 +1511,6 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A deferRelaunchUntilPaused = false; keysPaused = false; inHistory = false; - visible = false; nowVisible = false; mDrawn = false; idle = false; @@ -2189,7 +2187,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A * 2. App is delayed closing since it might enter PIP. */ boolean isClosingOrEnteringPip() { - return (isAnimating(TRANSITION | PARENTS) && hiddenRequested) || mWillCloseOrEnterPip; + return (isAnimating(TRANSITION | PARENTS) && !mVisibleRequested) || mWillCloseOrEnterPip; } /** * @return Whether AppOps allows this package to enter picture-in-picture. @@ -2448,7 +2446,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A mAtmService.getLockTaskController().clearLockedTask(task); } } else if (!isState(PAUSING)) { - if (visible) { + if (mVisibleRequested) { // Prepare and execute close transition. prepareActivityHideTransitionAnimation(transit); } @@ -2527,12 +2525,13 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A // TODO(b/137329632): find the next activity directly underneath this one, not just anywhere final ActivityRecord next = getDisplay().topRunningActivity( true /* considerKeyguardState */); - final boolean isVisible = visible || nowVisible; + final boolean isVisible = mVisibleRequested || nowVisible; // isNextNotYetVisible is to check if the next activity is invisible, or it has been // requested to be invisible but its windows haven't reported as invisible. If so, it // implied that the current finishing activity should be added into stopping list rather // than destroy immediately. - final boolean isNextNotYetVisible = next != null && (!next.nowVisible || !next.visible); + final boolean isNextNotYetVisible = next != null + && (!next.nowVisible || !next.mVisibleRequested); if (isVisible && isNextNotYetVisible) { // Add this activity to the list of stopping activities. It will be processed and // destroyed when the next activity reports idle. @@ -3214,7 +3213,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A } if (!fromActivity.isHidden()) { setHidden(false); - hiddenRequested = false; + mVisibleRequested = true; mHiddenSetFromTransferredStartingWindow = true; } setClientHidden(fromActivity.mClientHidden); @@ -3263,7 +3262,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A if (fromActivity == this) { return; } - if (fromActivity.hiddenRequested && transferStartingWindow(fromActivity.token)) { + if (!fromActivity.mVisibleRequested && transferStartingWindow(fromActivity.token)) { return; } } @@ -3778,6 +3777,10 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A return opts; } + boolean allowMoveToFront() { + return pendingOptions == null || !pendingOptions.getAvoidMoveToFront(); + } + void removeUriPermissionsLocked() { if (uriPermissions != null) { uriPermissions.removeUriPermissions(); @@ -3814,7 +3817,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A return; } mDeferHidingClient = deferHidingClient; - if (!mDeferHidingClient && !visible) { + if (!mDeferHidingClient && !mVisibleRequested) { // Hiding the client is no longer deferred and the app isn't visible still, go ahead and // update the visibility. setVisibility(false); @@ -3834,20 +3837,17 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A + appToken); return; } + if (visible) { + mDeferHidingClient = false; + } setVisibility(visible, mDeferHidingClient); mAtmService.addWindowLayoutReasons( ActivityTaskManagerService.LAYOUT_REASON_VISIBILITY_CHANGED); mStackSupervisor.getActivityMetricsLogger().notifyVisibilityChanged(this); - } - - // TODO: Look into merging with #commitVisibility() - void setVisible(boolean newVisible) { - visible = newVisible; - mDeferHidingClient = !visible && mDeferHidingClient; - setVisibility(visible); mStackSupervisor.mAppVisibilitiesChangedSinceLastPause = true; } + @VisibleForTesting void setVisibility(boolean visible, boolean deferHidingClient) { final AppTransition appTransition = getDisplayContent().mAppTransition; @@ -3858,7 +3858,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A // transition can be selected. // TODO: Probably a good idea to separate the concept of opening/closing apps from the // concept of setting visibility... - if (!visible && hiddenRequested) { + if (!visible && !mVisibleRequested) { if (!deferHidingClient && mLastDeferHidingClient) { // We previously deferred telling the client to hide itself when visibility was @@ -3870,8 +3870,8 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A } ProtoLog.v(WM_DEBUG_APP_TRANSITIONS, - "setAppVisibility(%s, visible=%b): %s hidden=%b hiddenRequested=%b Callers=%s", - appToken, visible, appTransition, isHidden(), hiddenRequested, + "setAppVisibility(%s, visible=%b): %s hidden=%b mVisibleRequested=%b Callers=%s", + appToken, visible, appTransition, isHidden(), mVisibleRequested, Debug.getCallers(6)); final DisplayContent displayContent = getDisplayContent(); @@ -3882,7 +3882,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A } displayContent.mChangingApps.remove(this); waitingToShow = false; - hiddenRequested = !visible; + mVisibleRequested = visible; mLastDeferHidingClient = deferHidingClient; if (!visible) { @@ -4021,7 +4021,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A } setHidden(!visible); - hiddenRequested = !visible; + mVisibleRequested = visible; visibilityChanged = true; if (!visible) { stopFreezingScreen(true, true); @@ -4039,8 +4039,8 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A } ProtoLog.v(WM_DEBUG_APP_TRANSITIONS, - "commitVisibility: %s: hidden=%b hiddenRequested=%b", this, - isHidden(), hiddenRequested); + "commitVisibility: %s: hidden=%b visibleRequested=%b", this, + isHidden(), mVisibleRequested); if (changed) { displayContent.getInputMonitor().setUpdateInputWindowsNeededLw(); @@ -4380,7 +4380,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A updateOptionsLocked(returningOptions); stack.mUndrawnActivitiesBelowTopTranslucent.add(this); } - setVisible(true); + setVisibility(true); sleeping = false; app.postPendingUiCleanMsg(true); if (reportToClient) { @@ -4416,7 +4416,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A } void makeInvisible() { - if (!visible) { + if (!mVisibleRequested) { if (DEBUG_VISIBILITY) Slog.v(TAG_VISIBILITY, "Already invisible: " + this); return; } @@ -4438,7 +4438,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A final boolean deferHidingClient = canEnterPictureInPicture && !isState(STOPPING, STOPPED, PAUSED); setDeferHidingClient(deferHidingClient); - setVisible(false); + setVisibility(false); switch (getState()) { case STOPPING: @@ -4625,8 +4625,8 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A * state to match that fact. */ void completeResumeLocked() { - final boolean wasVisible = visible; - setVisible(true); + final boolean wasVisible = mVisibleRequested; + setVisibility(true); if (!wasVisible) { // Visibility has changed, so take a note of it so we call the TaskStackChangedListener mStackSupervisor.mAppVisibilitiesChangedSinceLastPause = true; @@ -4710,15 +4710,16 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A } setState(STOPPING, "stopIfPossible"); if (DEBUG_VISIBILITY) { - Slog.v(TAG_VISIBILITY, "Stopping visible=" + visible + " for " + this); + Slog.v(TAG_VISIBILITY, "Stopping visibleRequested=" + + mVisibleRequested + " for " + this); } - if (!visible) { - setVisible(false); + if (!mVisibleRequested) { + setVisibility(false); } EventLogTags.writeAmStopActivity( mUserId, System.identityHashCode(this), shortComponentName); mAtmService.getLifecycleManager().scheduleTransaction(app.getThread(), appToken, - StopActivityItem.obtain(visible, configChangeFlags)); + StopActivityItem.obtain(mVisibleRequested, configChangeFlags)); if (stack.shouldSleepOrShutDownActivities()) { setSleeping(true); } @@ -4881,10 +4882,10 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A void startFreezingScreen() { ProtoLog.i(WM_DEBUG_ORIENTATION, - "Set freezing of %s: hidden=%b freezing=%b hiddenRequested=%b. %s", - appToken, isHidden(), mFreezingScreen, hiddenRequested, + "Set freezing of %s: hidden=%b freezing=%b visibleRequested=%b. %s", + appToken, isHidden(), mFreezingScreen, mVisibleRequested, new RuntimeException().fillInStackTrace()); - if (!hiddenRequested) { + if (mVisibleRequested) { if (!mFreezingScreen) { mFreezingScreen = true; mWmService.registerAppFreezeListener(this); @@ -5163,7 +5164,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A Slog.v(TAG, "Not displayed: s=" + winAnimator.mSurfaceController + " pv=" + w.isVisibleByPolicy() + " mDrawState=" + winAnimator.drawStateToString() - + " ph=" + w.isParentWindowHidden() + " th=" + hiddenRequested + + " ph=" + w.isParentWindowHidden() + " th=" + mVisibleRequested + " a=" + isAnimating(TRANSITION)); } } @@ -5271,7 +5272,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A * currently pausing, or is resumed. */ public boolean isInterestingToUserLocked() { - return visible || nowVisible || mState == PAUSING || mState == RESUMED; + return mVisibleRequested || nowVisible || mState == PAUSING || mState == RESUMED; } void setSleeping(boolean _sleeping) { @@ -5345,7 +5346,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A // We're not ready for this kind of thing. return false; } - if (visible) { + if (mVisibleRequested) { // The user would notice this! return false; } @@ -5903,7 +5904,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A "AppWindowToken"); clearThumbnail(); - setClientHidden(isHidden() && hiddenRequested); + setClientHidden(isHidden() && !mVisibleRequested); getDisplayContent().computeImeTargetIfNeeded(this); @@ -6499,7 +6500,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A if (display == null) { return; } - if (visible) { + if (mVisibleRequested) { // It may toggle the UI for user to restart the size compatibility mode activity. display.handleActivitySizeCompatModeIfNeeded(this); } else if (mCompatDisplayInsets != null) { @@ -6796,7 +6797,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A } else { if (DEBUG_SWITCH || DEBUG_CONFIGURATION) Slog.v(TAG_CONFIGURATION, "Config is relaunching " + this); - if (DEBUG_STATES && !visible) { + if (DEBUG_STATES && !mVisibleRequested) { Slog.v(TAG_STATES, "Config is relaunching invisible activity " + this + " called by " + Debug.getCallers(4)); } @@ -6982,7 +6983,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A // Reset the existing override configuration so it can be updated according to the latest // configuration. clearSizeCompatMode(); - if (visible) { + if (mVisibleRequested) { // Configuration will be ensured when becoming visible, so if it is already visible, // then the manual update is needed. updateSizeCompatMode(); @@ -6995,7 +6996,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A // The restarting state avoids removing this record when process is died. setState(RESTARTING_PROCESS, "restartActivityProcess"); - if (!visible || mHaveState) { + if (!mVisibleRequested || mHaveState) { // Kill its process immediately because the activity should be in background. // The activity state will be update to {@link #DESTROYED} in // {@link ActivityStack#cleanUp} when handling process died. @@ -7286,7 +7287,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A writeToProto(proto, APP_WINDOW_TOKEN, WindowTraceLogLevel.ALL); writeIdentifierToProto(proto, IDENTIFIER); proto.write(STATE, mState.toString()); - proto.write(VISIBLE, visible); + proto.write(VISIBLE, mVisibleRequested); proto.write(FRONT_OF_TASK, isRootOfTask()); if (hasProcess()) { proto.write(PROC_ID, app.getPid()); @@ -7322,7 +7323,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A } proto.write(FILLS_PARENT, mOccludesParent); proto.write(APP_STOPPED, mAppStopped); - proto.write(HIDDEN_REQUESTED, hiddenRequested); + proto.write(VISIBLE_REQUESTED, mVisibleRequested); proto.write(CLIENT_HIDDEN, mClientHidden); proto.write(DEFER_HIDING_CLIENT, mDeferHidingClient); proto.write(REPORTED_DRAWN, reportedDrawn); diff --git a/services/core/java/com/android/server/wm/ActivityServiceConnectionsHolder.java b/services/core/java/com/android/server/wm/ActivityServiceConnectionsHolder.java index c56a9e2ac560..6e75f9c9167f 100644 --- a/services/core/java/com/android/server/wm/ActivityServiceConnectionsHolder.java +++ b/services/core/java/com/android/server/wm/ActivityServiceConnectionsHolder.java @@ -73,7 +73,7 @@ public class ActivityServiceConnectionsHolder<T> { public boolean isActivityVisible() { synchronized (mService.mGlobalLock) { - return mActivity.visible || mActivity.isState(RESUMED, PAUSING); + return mActivity.mVisibleRequested || mActivity.isState(RESUMED, PAUSING); } } diff --git a/services/core/java/com/android/server/wm/ActivityStack.java b/services/core/java/com/android/server/wm/ActivityStack.java index d7e6852cb78f..ac94125469ba 100644 --- a/services/core/java/com/android/server/wm/ActivityStack.java +++ b/services/core/java/com/android/server/wm/ActivityStack.java @@ -1693,7 +1693,8 @@ class ActivityStack extends WindowContainer<Task> implements BoundsAnimationTarg prev = prev.completeFinishing("completePausedLocked"); } else if (prev.hasProcess()) { if (DEBUG_PAUSE) Slog.v(TAG_PAUSE, "Enqueue pending stop if needed: " + prev - + " wasStopping=" + wasStopping + " visible=" + prev.visible); + + " wasStopping=" + wasStopping + + " visibleRequested=" + prev.mVisibleRequested); if (prev.deferRelaunchUntilPaused) { // Complete the deferred relaunch that was waiting for pause to complete. if (DEBUG_PAUSE) Slog.v(TAG_PAUSE, "Re-launching after pause: " + prev); @@ -1703,7 +1704,7 @@ class ActivityStack extends WindowContainer<Task> implements BoundsAnimationTarg // We can't clobber it, because the stop confirmation will not be handled. // We don't need to schedule another stop, we only need to let it happen. prev.setState(STOPPING, "completePausedLocked"); - } else if (!prev.visible || shouldSleepOrShutDownActivities()) { + } else if (!prev.mVisibleRequested || shouldSleepOrShutDownActivities()) { // Clear out any deferred client hide we might currently have. prev.setDeferHidingClient(false); // If we were visible then resumeTopActivities will release resources before @@ -1824,7 +1825,7 @@ class ActivityStack extends WindowContainer<Task> implements BoundsAnimationTarg boolean isTopActivityVisible() { final ActivityRecord topActivity = getTopNonFinishingActivity(); - return topActivity != null && topActivity.visible; + return topActivity != null && topActivity.mVisibleRequested; } /** @@ -1965,7 +1966,7 @@ class ActivityStack extends WindowContainer<Task> implements BoundsAnimationTarg for (int taskNdx = getChildCount() - 1; taskNdx >= 0; --taskNdx) { final Task task = getChildAt(taskNdx); ActivityRecord r = task.topRunningActivityLocked(); - if (r == null || r.finishing || !r.visible) { + if (r == null || r.finishing || !r.mVisibleRequested) { task.mLayerRank = -1; } else { task.mLayerRank = baseLayer + layer++; @@ -2054,7 +2055,7 @@ class ActivityStack extends WindowContainer<Task> implements BoundsAnimationTarg if (!r.attachedToProcess()) { makeVisibleAndRestartIfNeeded(starting, configChanges, isTop, resumeTopActivity && isTop, r); - } else if (r.visible) { + } else if (r.mVisibleRequested) { // If this activity is already visible, then there is nothing to do here. if (DEBUG_VISIBILITY) Slog.v(TAG_VISIBILITY, "Skipping: already visible at " + r); @@ -2231,16 +2232,16 @@ class ActivityStack extends WindowContainer<Task> implements BoundsAnimationTarg // invisible. If the app is already visible, it must have died while it was visible. In this // case, we'll show the dead window but will not restart the app. Otherwise we could end up // thrashing. - if (isTop || !r.visible) { + if (isTop || !r.mVisibleRequested) { // This activity needs to be visible, but isn't even running... // get it started and resume if no other stack in this stack is resumed. if (DEBUG_VISIBILITY) Slog.v(TAG_VISIBILITY, "Start and freeze screen for " + r); if (r != starting) { r.startFreezingScreenLocked(configChanges); } - if (!r.visible || r.mLaunchTaskBehind) { + if (!r.mVisibleRequested || r.mLaunchTaskBehind) { if (DEBUG_VISIBILITY) Slog.v(TAG_VISIBILITY, "Starting and making visible: " + r); - r.setVisible(true); + r.setVisibility(true); } if (r != starting) { mStackSupervisor.startSpecificActivityLocked(r, andResume, true /* checkConfig */); @@ -2683,7 +2684,8 @@ class ActivityStack extends WindowContainer<Task> implements BoundsAnimationTarg if (next.attachedToProcess()) { if (DEBUG_SWITCH) Slog.v(TAG_SWITCH, "Resume running: " + next - + " stopped=" + next.stopped + " visible=" + next.visible); + + " stopped=" + next.stopped + + " visibleRequested=" + next.mVisibleRequested); // If the previous activity is translucent, force a visibility update of // the next activity, so that it's added to WM's opening app list, and @@ -2698,7 +2700,7 @@ class ActivityStack extends WindowContainer<Task> implements BoundsAnimationTarg && !lastFocusedStack.mLastPausedActivity.occludesParent())); // This activity is now becoming visible. - if (!next.visible || next.stopped || lastActivityTranslucent) { + if (!next.mVisibleRequested || next.stopped || lastActivityTranslucent) { next.setVisibility(true); } @@ -2753,7 +2755,7 @@ class ActivityStack extends WindowContainer<Task> implements BoundsAnimationTarg // Do over! mStackSupervisor.scheduleResumeTopActivities(); } - if (!next.visible || next.stopped) { + if (!next.mVisibleRequested || next.stopped) { next.setVisibility(true); } next.completeResumeLocked(); @@ -3422,7 +3424,7 @@ class ActivityStack extends WindowContainer<Task> implements BoundsAnimationTarg final ActivityRecord top = stack.topRunningActivityLocked(); - if (stack.isActivityTypeHome() && (top == null || !top.visible)) { + if (stack.isActivityTypeHome() && (top == null || !top.mVisibleRequested)) { // If we will be focusing on the home stack next and its current top activity isn't // visible, then use the move the home stack task to top to make the activity visible. stack.getDisplay().moveHomeActivityToTop(reason); @@ -3919,7 +3921,10 @@ class ActivityStack extends WindowContainer<Task> implements BoundsAnimationTarg "Record #" + targetIndex + " " + r + ": app=" + r.app); if (r.app == app) { - if (r.visible) { + if (r.isVisible() || r.mVisibleRequested) { + // While an activity launches a new activity, it's possible that the old + // activity is already requested to be hidden (mVisibleRequested=false), but + // this visibility is not yet committed, so isVisible()=true. hasVisibleActivities = true; } final boolean remove; @@ -3935,8 +3940,8 @@ class ActivityStack extends WindowContainer<Task> implements BoundsAnimationTarg // Don't currently have state for the activity, or // it is finishing -- always remove it. remove = true; - } else if (!r.visible && r.launchCount > 2 && - r.lastLaunchTime > (SystemClock.uptimeMillis() - 60000)) { + } else if (!r.mVisibleRequested && r.launchCount > 2 + && r.lastLaunchTime > (SystemClock.uptimeMillis() - 60000)) { // We have launched this activity too many times since it was // able to run, so give up and remove it. // (Note if the activity is visible, we don't remove the record. @@ -3972,7 +3977,7 @@ class ActivityStack extends WindowContainer<Task> implements BoundsAnimationTarg // it died, we leave the dead window on screen so it's basically visible. // This is needed when user later tap on the dead window, we need to stop // other apps when user transfers focus to the restarted activity. - r.nowVisible = r.visible; + r.nowVisible = r.mVisibleRequested; } r.cleanUp(true /* cleanServices */, true /* setState */); if (remove) { @@ -4155,7 +4160,7 @@ class ActivityStack extends WindowContainer<Task> implements BoundsAnimationTarg * Ensures all visible activities at or below the input activity have the right configuration. */ void ensureVisibleActivitiesConfigurationLocked(ActivityRecord start, boolean preserveWindow) { - if (start == null || !start.visible) { + if (start == null || !start.mVisibleRequested) { return; } @@ -4550,7 +4555,7 @@ class ActivityStack extends WindowContainer<Task> implements BoundsAnimationTarg final ActivityRecord a = task.getChildAt(activityNdx); if (a.info.packageName.equals(packageName)) { a.forceNewConfig = true; - if (starting != null && a == starting && a.visible) { + if (starting != null && a == starting && a.mVisibleRequested) { a.startFreezingScreenLocked(CONFIG_SCREEN_LAYOUT); } } diff --git a/services/core/java/com/android/server/wm/ActivityStackSupervisor.java b/services/core/java/com/android/server/wm/ActivityStackSupervisor.java index 530fdcf066a9..6ea80d259a4d 100644 --- a/services/core/java/com/android/server/wm/ActivityStackSupervisor.java +++ b/services/core/java/com/android/server/wm/ActivityStackSupervisor.java @@ -773,12 +773,11 @@ public class ActivityStackSupervisor implements RecentTasks.Callbacks { } if (r.getActivityStack().checkKeyguardVisibility(r, true /* shouldBeVisible */, - true /* isTop */)) { - // We only set the visibility to true if the activity is allowed to be visible - // based on - // keyguard state. This avoids setting this into motion in window manager that is - // later cancelled due to later calls to ensure visible activities that set - // visibility back to false. + true /* isTop */) && r.allowMoveToFront()) { + // We only set the visibility to true if the activity is not being launched in + // background, and is allowed to be visible based on keyguard state. This avoids + // setting this into motion in window manager that is later cancelled due to later + // calls to ensure visible activities that set visibility back to false. r.setVisibility(true); } diff --git a/services/core/java/com/android/server/wm/DisplayContent.java b/services/core/java/com/android/server/wm/DisplayContent.java index db41968a6c74..cbbf66bbd556 100644 --- a/services/core/java/com/android/server/wm/DisplayContent.java +++ b/services/core/java/com/android/server/wm/DisplayContent.java @@ -645,11 +645,11 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo final ActivityRecord activity = w.mActivityRecord; if (gone) Slog.v(TAG, " GONE: mViewVisibility=" + w.mViewVisibility + " mRelayoutCalled=" + w.mRelayoutCalled + " hidden=" + w.mToken.isHidden() - + " hiddenRequested=" + (activity != null && activity.hiddenRequested) + + " visibleRequested=" + (activity != null && activity.mVisibleRequested) + " parentHidden=" + w.isParentWindowHidden()); else Slog.v(TAG, " VIS: mViewVisibility=" + w.mViewVisibility + " mRelayoutCalled=" + w.mRelayoutCalled + " hidden=" + w.mToken.isHidden() - + " hiddenRequested=" + (activity != null && activity.hiddenRequested) + + " visibleRequested=" + (activity != null && activity.mVisibleRequested) + " parentHidden=" + w.isParentWindowHidden()); } diff --git a/services/core/java/com/android/server/wm/RecentsAnimation.java b/services/core/java/com/android/server/wm/RecentsAnimation.java index 948ed7941880..a17bd24294c5 100644 --- a/services/core/java/com/android/server/wm/RecentsAnimation.java +++ b/services/core/java/com/android/server/wm/RecentsAnimation.java @@ -107,7 +107,7 @@ class RecentsAnimation implements RecentsAnimationCallbacks, mTargetActivityType); ActivityRecord targetActivity = getTargetActivity(targetStack); if (targetActivity != null) { - if (targetActivity.visible || targetActivity.isTopRunningActivity()) { + if (targetActivity.mVisibleRequested || targetActivity.isTopRunningActivity()) { // The activity is ready. return; } @@ -189,7 +189,7 @@ class RecentsAnimation implements RecentsAnimationCallbacks, // Send launch hint if we are actually launching the target. If it's already visible // (shouldn't happen in general) we don't need to send it. - if (targetActivity == null || !targetActivity.visible) { + if (targetActivity == null || !targetActivity.mVisibleRequested) { mService.mRootActivityContainer.sendPowerHintForLaunchStartIfNeeded( true /* forceSend */, targetActivity); } diff --git a/services/core/java/com/android/server/wm/Task.java b/services/core/java/com/android/server/wm/Task.java index ba3b8b7d6787..6ddd943dcf68 100644 --- a/services/core/java/com/android/server/wm/Task.java +++ b/services/core/java/com/android/server/wm/Task.java @@ -2204,7 +2204,7 @@ class Task extends WindowContainer<ActivityRecord> implements ConfigurationConta void addStartingWindowsForVisibleActivities(boolean taskSwitch) { for (int activityNdx = getChildCount() - 1; activityNdx >= 0; --activityNdx) { final ActivityRecord r = getChildAt(activityNdx); - if (r.visible) { + if (r.mVisibleRequested) { r.showStartingWindow(null /* prev */, false /* newTask */, taskSwitch); } } @@ -2508,7 +2508,7 @@ class Task extends WindowContainer<ActivityRecord> implements ConfigurationConta for (int i = mChildren.size() - 1; i >= 0; i--) { final ActivityRecord token = mChildren.get(i); // skip hidden (or about to hide) apps - if (token.mIsExiting || token.isClientHidden() || token.hiddenRequested) { + if (token.mIsExiting || token.isClientHidden() || !token.mVisibleRequested) { continue; } final WindowState win = token.findMainWindow(); @@ -2728,7 +2728,7 @@ class Task extends WindowContainer<ActivityRecord> implements ConfigurationConta for (int i = mChildren.size() - 1; i >= 0; i--) { final ActivityRecord token = mChildren.get(i); // skip hidden (or about to hide) apps - if (!token.mIsExiting && !token.isClientHidden() && !token.hiddenRequested) { + if (!token.mIsExiting && !token.isClientHidden() && token.mVisibleRequested) { return token; } } diff --git a/services/core/java/com/android/server/wm/WallpaperController.java b/services/core/java/com/android/server/wm/WallpaperController.java index 3632284fdeb6..ef7940368f15 100644 --- a/services/core/java/com/android/server/wm/WallpaperController.java +++ b/services/core/java/com/android/server/wm/WallpaperController.java @@ -532,9 +532,9 @@ class WallpaperController { } final boolean newTargetHidden = wallpaperTarget.mActivityRecord != null - && wallpaperTarget.mActivityRecord.hiddenRequested; + && !wallpaperTarget.mActivityRecord.mVisibleRequested; final boolean oldTargetHidden = prevWallpaperTarget.mActivityRecord != null - && prevWallpaperTarget.mActivityRecord.hiddenRequested; + && !prevWallpaperTarget.mActivityRecord.mVisibleRequested; if (DEBUG_WALLPAPER_LIGHT) Slog.v(TAG, "Animating wallpapers:" + " old: " + prevWallpaperTarget + " hidden=" + oldTargetHidden + " new: " + wallpaperTarget diff --git a/services/core/java/com/android/server/wm/WindowProcessController.java b/services/core/java/com/android/server/wm/WindowProcessController.java index 41e88c8f763b..c1783efbffb3 100644 --- a/services/core/java/com/android/server/wm/WindowProcessController.java +++ b/services/core/java/com/android/server/wm/WindowProcessController.java @@ -533,7 +533,7 @@ public class WindowProcessController extends ConfigurationContainer<Configuratio synchronized (mAtm.mGlobalLockWithoutBoost) { for (int i = mActivities.size() - 1; i >= 0; --i) { final ActivityRecord r = mActivities.get(i); - if (r.visible) { + if (r.mVisibleRequested) { return true; } } @@ -555,7 +555,7 @@ public class WindowProcessController extends ConfigurationContainer<Configuratio continue; } ActivityRecord topActivity = task.getTopNonFinishingActivity(); - if (topActivity != null && topActivity.visible) { + if (topActivity != null && topActivity.mVisibleRequested) { return true; } } @@ -589,7 +589,7 @@ public class WindowProcessController extends ConfigurationContainer<Configuratio // - no longer visible OR // - not focusable (in PiP mode for instance) if (topDisplay == null - || !mPreQTopResumedActivity.visible + || !mPreQTopResumedActivity.mVisibleRequested || !mPreQTopResumedActivity.isFocusable()) { canUpdate = true; } @@ -739,7 +739,7 @@ public class WindowProcessController extends ConfigurationContainer<Configuratio } // Don't consider any activities that are currently not in a state where they // can be destroyed. - if (r.visible || !r.stopped || !r.hasSavedState() + if (r.mVisibleRequested || !r.stopped || !r.hasSavedState() || r.isState(STARTED, RESUMED, PAUSING, PAUSED, STOPPING)) { if (DEBUG_RELEASE) Slog.d(TAG_RELEASE, "Not releasing in-use activity: " + r); continue; @@ -793,7 +793,7 @@ public class WindowProcessController extends ConfigurationContainer<Configuratio continue; } } - if (r.visible) { + if (r.mVisibleRequested) { final Task task = r.getTask(); if (task != null && minTaskLayer > 0) { final int layer = task.mLayerRank; diff --git a/services/core/java/com/android/server/wm/WindowState.java b/services/core/java/com/android/server/wm/WindowState.java index d41e70692eba..0f1f906ef2e2 100644 --- a/services/core/java/com/android/server/wm/WindowState.java +++ b/services/core/java/com/android/server/wm/WindowState.java @@ -1560,7 +1560,7 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP */ // TODO: Can we consolidate this with #isVisible() or have a more appropriate name for this? boolean isWinVisibleLw() { - return (mActivityRecord == null || !mActivityRecord.hiddenRequested + return (mActivityRecord == null || mActivityRecord.mVisibleRequested || mActivityRecord.isAnimating(TRANSITION)) && isVisible(); } @@ -1591,7 +1591,7 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP final ActivityRecord atoken = mActivityRecord; return (mHasSurface || (!mRelayoutCalled && mViewVisibility == View.VISIBLE)) && isVisibleByPolicy() && !isParentWindowHidden() - && (atoken == null || !atoken.hiddenRequested) + && (atoken == null || atoken.mVisibleRequested) && !mAnimatingExit && !mDestroying; } @@ -1606,7 +1606,7 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP } final ActivityRecord atoken = mActivityRecord; if (atoken != null) { - return ((!isParentWindowHidden() && !atoken.hiddenRequested) + return ((!isParentWindowHidden() && atoken.mVisibleRequested) || isAnimating(TRANSITION | PARENTS)); } return !isParentWindowHidden() || isAnimating(TRANSITION | PARENTS); @@ -1673,7 +1673,7 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP public boolean isDisplayedLw() { final ActivityRecord atoken = mActivityRecord; return isDrawnLw() && isVisibleByPolicy() - && ((!isParentWindowHidden() && (atoken == null || !atoken.hiddenRequested)) + && ((!isParentWindowHidden() && (atoken == null || atoken.mVisibleRequested)) || isAnimating(TRANSITION | PARENTS)); } @@ -1691,7 +1691,7 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP return mViewVisibility == View.GONE || !mRelayoutCalled || (atoken == null && mToken.isHidden()) - || (atoken != null && atoken.hiddenRequested) + || (atoken != null && !atoken.mVisibleRequested) || isParentWindowGoneForLayout() || (mAnimatingExit && !isAnimatingLw()) || mDestroying; @@ -2183,7 +2183,8 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP + " parentHidden=" + isParentWindowHidden() + " exiting=" + mAnimatingExit + " destroying=" + mDestroying); if (mActivityRecord != null) { - Slog.i(TAG_WM, " mActivityRecord.hiddenRequested=" + mActivityRecord.hiddenRequested); + Slog.i(TAG_WM, " mActivityRecord.visibleRequested=" + + mActivityRecord.mVisibleRequested); } } } @@ -2631,14 +2632,14 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP return showBecauseOfActivity || showBecauseOfWindow; } - /** @return false if this window desires touch events. */ + /** @return {@code false} if this window desires touch events. */ boolean cantReceiveTouchInput() { if (mActivityRecord == null || mActivityRecord.getTask() == null) { return false; } return mActivityRecord.getTask().getTaskStack().shouldIgnoreInput() - || mActivityRecord.hiddenRequested + || !mActivityRecord.mVisibleRequested || isAnimatingToRecents(); } @@ -4167,8 +4168,8 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP + " starting=" + (mAttrs.type == TYPE_APPLICATION_STARTING) + " during animation: policyVis=" + isVisibleByPolicy() + " parentHidden=" + isParentWindowHidden() - + " tok.hiddenRequested=" - + (mActivityRecord != null && mActivityRecord.hiddenRequested) + + " tok.visibleRequested=" + + (mActivityRecord != null && mActivityRecord.mVisibleRequested) + " tok.hidden=" + (mActivityRecord != null && mActivityRecord.isHidden()) + " animating=" + isAnimating(TRANSITION | PARENTS) + " tok animating=" @@ -4576,7 +4577,7 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP + " pv=" + isVisibleByPolicy() + " mDrawState=" + mWinAnimator.mDrawState + " ph=" + isParentWindowHidden() - + " th=" + (mActivityRecord != null ? mActivityRecord.hiddenRequested : false) + + " th=" + (mActivityRecord != null && mActivityRecord.mVisibleRequested) + " a=" + isAnimating(TRANSITION | PARENTS)); } } diff --git a/services/tests/wmtests/src/com/android/server/wm/ActivityMetricsLaunchObserverTests.java b/services/tests/wmtests/src/com/android/server/wm/ActivityMetricsLaunchObserverTests.java index 3c619f73aa6f..734761fd8048 100644 --- a/services/tests/wmtests/src/com/android/server/wm/ActivityMetricsLaunchObserverTests.java +++ b/services/tests/wmtests/src/com/android/server/wm/ActivityMetricsLaunchObserverTests.java @@ -160,7 +160,7 @@ public class ActivityMetricsLaunchObserverTests extends ActivityTestsBase { public void testOnActivityLaunchCancelled_hasDrawn() { onActivityLaunched(); - mTopActivity.visible = mTopActivity.mDrawn = true; + mTopActivity.mVisibleRequested = mTopActivity.mDrawn = true; // Cannot time already-visible activities. mActivityMetricsLogger.notifyActivityLaunched(START_TASK_TO_FRONT, mTopActivity); @@ -171,7 +171,7 @@ public class ActivityMetricsLaunchObserverTests extends ActivityTestsBase { @Test public void testOnActivityLaunchCancelled_finishedBeforeDrawn() { - mTopActivity.visible = mTopActivity.mDrawn = true; + mTopActivity.mVisibleRequested = mTopActivity.mDrawn = true; // Suppress resume when creating the record because we want to notify logger manually. mSupervisor.beginDeferResume(); 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 6c63d419ceed..a2e423369fcd 100644 --- a/services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java +++ b/services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java @@ -591,7 +591,7 @@ public class ActivityRecordTests extends ActivityTestsBase { // Prepare the activity record to be ready for immediate removal. It should be invisible and // have no process. Otherwise, request to finish it will send a message to client first. mActivity.setState(STOPPED, "test"); - mActivity.visible = false; + mActivity.mVisibleRequested = false; mActivity.nowVisible = false; // Set process to 'null' to allow immediate removal, but don't call mActivity.setProcess() - // this will cause NPE when updating task's process. @@ -600,7 +600,7 @@ public class ActivityRecordTests extends ActivityTestsBase { // Put a visible activity on top, so the finishing activity doesn't have to wait until the // next activity reports idle to destroy it. final ActivityRecord topActivity = new ActivityBuilder(mService).setTask(mTask).build(); - topActivity.visible = true; + topActivity.mVisibleRequested = true; topActivity.nowVisible = true; topActivity.setState(RESUMED, "test"); @@ -686,7 +686,7 @@ public class ActivityRecordTests extends ActivityTestsBase { @Test public void testFinishActivityIfPossible_visibleResumedPreparesAppTransition() { mActivity.finishing = false; - mActivity.visible = true; + mActivity.mVisibleRequested = true; mActivity.setState(RESUMED, "test"); mActivity.finishIfPossible("test", false /* oomAdj */); @@ -702,7 +702,7 @@ public class ActivityRecordTests extends ActivityTestsBase { @Test public void testFinishActivityIfPossible_visibleNotResumedExecutesAppTransition() { mActivity.finishing = false; - mActivity.visible = true; + mActivity.mVisibleRequested = true; mActivity.setState(PAUSED, "test"); mActivity.finishIfPossible("test", false /* oomAdj */); @@ -720,7 +720,7 @@ public class ActivityRecordTests extends ActivityTestsBase { // Put an activity on top of test activity to make it invisible and prevent us from // accidentally resuming the topmost one again. new ActivityBuilder(mService).build(); - mActivity.visible = false; + mActivity.mVisibleRequested = false; mActivity.setState(STOPPED, "test"); mActivity.finishIfPossible("test", false /* oomAdj */); @@ -772,7 +772,7 @@ public class ActivityRecordTests extends ActivityTestsBase { @Test public void testCompleteFinishing_keepStateOfNextInvisible() { final ActivityRecord currentTop = mActivity; - currentTop.visible = currentTop.nowVisible = true; + currentTop.mVisibleRequested = currentTop.nowVisible = true; // Simulates that {@code currentTop} starts an existing activity from background (so its // state is stopped) and the starting flow just goes to place it at top. @@ -798,13 +798,13 @@ public class ActivityRecordTests extends ActivityTestsBase { @Test public void testCompleteFinishing_waitForNextVisible() { final ActivityRecord topActivity = new ActivityBuilder(mService).setTask(mTask).build(); - topActivity.visible = true; + topActivity.mVisibleRequested = true; topActivity.nowVisible = true; topActivity.finishing = true; topActivity.setState(PAUSED, "true"); // Mark the bottom activity as not visible, so that we will wait for it before removing // the top one. - mActivity.visible = false; + mActivity.mVisibleRequested = false; mActivity.nowVisible = false; mActivity.setState(STOPPED, "test"); @@ -823,13 +823,13 @@ public class ActivityRecordTests extends ActivityTestsBase { @Test public void testCompleteFinishing_noWaitForNextVisible_alreadyInvisible() { final ActivityRecord topActivity = new ActivityBuilder(mService).setTask(mTask).build(); - topActivity.visible = false; + topActivity.mVisibleRequested = false; topActivity.nowVisible = false; topActivity.finishing = true; topActivity.setState(PAUSED, "true"); // Mark the bottom activity as not visible, so that we would wait for it before removing // the top one. - mActivity.visible = false; + mActivity.mVisibleRequested = false; mActivity.nowVisible = false; mActivity.setState(STOPPED, "test"); @@ -845,12 +845,12 @@ public class ActivityRecordTests extends ActivityTestsBase { @Test public void testCompleteFinishing_waitForIdle() { final ActivityRecord topActivity = new ActivityBuilder(mService).setTask(mTask).build(); - topActivity.visible = true; + topActivity.mVisibleRequested = true; topActivity.nowVisible = true; topActivity.finishing = true; topActivity.setState(PAUSED, "true"); // Mark the bottom activity as already visible, so that there is no need to wait for it. - mActivity.visible = true; + mActivity.mVisibleRequested = true; mActivity.nowVisible = true; mActivity.setState(RESUMED, "test"); @@ -866,12 +866,12 @@ public class ActivityRecordTests extends ActivityTestsBase { @Test public void testCompleteFinishing_noWaitForNextVisible_stopped() { final ActivityRecord topActivity = new ActivityBuilder(mService).setTask(mTask).build(); - topActivity.visible = false; + topActivity.mVisibleRequested = false; topActivity.nowVisible = false; topActivity.finishing = true; topActivity.setState(STOPPED, "true"); // Mark the bottom activity as already visible, so that there is no need to wait for it. - mActivity.visible = true; + mActivity.mVisibleRequested = true; mActivity.nowVisible = true; mActivity.setState(RESUMED, "test"); @@ -887,12 +887,12 @@ public class ActivityRecordTests extends ActivityTestsBase { @Test public void testCompleteFinishing_noWaitForNextVisible_nonFocusedStack() { final ActivityRecord topActivity = new ActivityBuilder(mService).setTask(mTask).build(); - topActivity.visible = true; + topActivity.mVisibleRequested = true; topActivity.nowVisible = true; topActivity.finishing = true; topActivity.setState(PAUSED, "true"); // Mark the bottom activity as already visible, so that there is no need to wait for it. - mActivity.visible = true; + mActivity.mVisibleRequested = true; mActivity.nowVisible = true; mActivity.setState(RESUMED, "test"); @@ -901,7 +901,7 @@ public class ActivityRecordTests extends ActivityTestsBase { final ActivityStack stack = new StackBuilder(mRootActivityContainer).build(); final ActivityRecord focusedActivity = stack.getChildAt(0).getChildAt(0); focusedActivity.nowVisible = true; - focusedActivity.visible = true; + focusedActivity.mVisibleRequested = true; focusedActivity.setState(RESUMED, "test"); stack.mResumedActivity = focusedActivity; diff --git a/services/tests/wmtests/src/com/android/server/wm/ActivityStackTests.java b/services/tests/wmtests/src/com/android/server/wm/ActivityStackTests.java index aa9dd9de5fda..3a6ed5400f61 100644 --- a/services/tests/wmtests/src/com/android/server/wm/ActivityStackTests.java +++ b/services/tests/wmtests/src/com/android/server/wm/ActivityStackTests.java @@ -1006,7 +1006,7 @@ public class ActivityStackTests extends ActivityTestsBase { // There is still an activity1 in stack1 so the activity2 should be added to finishing list // that will be destroyed until idle. - stack2.getTopNonFinishingActivity().visible = true; + stack2.getTopNonFinishingActivity().mVisibleRequested = true; final ActivityRecord activity2 = finishTopActivity(stack2); assertEquals(STOPPING, activity2.getState()); assertThat(mSupervisor.mStoppingActivities).contains(activity2); 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 466dc9bd0088..5070fb62b45f 100644 --- a/services/tests/wmtests/src/com/android/server/wm/DisplayContentTests.java +++ b/services/tests/wmtests/src/com/android/server/wm/DisplayContentTests.java @@ -395,7 +395,7 @@ public class DisplayContentTests extends WindowTestsBase { assertEquals(window1, mWm.mRoot.getTopFocusedDisplayContent().mCurrentFocus); // Make sure top focused display not changed if there is a focused app. - window1.mActivityRecord.hiddenRequested = true; + window1.mActivityRecord.mVisibleRequested = false; window1.getDisplayContent().setFocusedApp(window1.mActivityRecord); updateFocusedWindow(); assertTrue(!window1.isFocused()); 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 b2cb8c9216ee..d48b9d74c002 100644 --- a/services/tests/wmtests/src/com/android/server/wm/RecentsAnimationTest.java +++ b/services/tests/wmtests/src/com/android/server/wm/RecentsAnimationTest.java @@ -106,12 +106,12 @@ public class RecentsAnimationTest extends ActivityTestsBase { RecentsAnimationCallbacks recentsAnimation = startRecentsActivity( mRecentsComponent, true /* getRecentsAnimation */); // The launch-behind state should make the recents activity visible. - assertTrue(recentActivity.visible); + assertTrue(recentActivity.mVisibleRequested); // Simulate the animation is cancelled without changing the stack order. recentsAnimation.onAnimationFinished(REORDER_KEEP_IN_PLACE, false /* sendUserLeaveHint */); // The non-top recents activity should be invisible by the restored launch-behind state. - assertFalse(recentActivity.visible); + assertFalse(recentActivity.mVisibleRequested); } @Test @@ -158,7 +158,7 @@ public class RecentsAnimationTest extends ActivityTestsBase { // The activity is started in background so it should be invisible and will be stopped. assertThat(recentsActivity).isNotNull(); assertThat(mSupervisor.mStoppingActivities).contains(recentsActivity); - assertFalse(recentsActivity.visible); + assertFalse(recentsActivity.mVisibleRequested); // Assume it is stopped to test next use case. recentsActivity.activityStoppedLocked(null /* newIcicle */, null /* newPersistentState */, @@ -361,7 +361,7 @@ public class RecentsAnimationTest extends ActivityTestsBase { true); // Ensure we find the task for the right user and it is made visible - assertTrue(otherUserHomeActivity.visible); + assertTrue(otherUserHomeActivity.mVisibleRequested); } private void startRecentsActivity() { 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 ecd9a834d5b3..b9e1d4b733b3 100644 --- a/services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java +++ b/services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java @@ -84,7 +84,7 @@ public class SizeCompatTests extends ActivityTestsBase { public void testRestartProcessIfVisible() { setUpApp(new TestActivityDisplay.Builder(mService, 1000, 2500).build()); doNothing().when(mSupervisor).scheduleRestartTimeout(mActivity); - mActivity.visible = true; + mActivity.mVisibleRequested = true; mActivity.setSavedState(null /* savedState */); mActivity.setState(ActivityStack.ActivityState.RESUMED, "testRestart"); prepareUnresizable(1.5f /* maxAspect */, SCREEN_ORIENTATION_UNSPECIFIED); @@ -167,7 +167,7 @@ public class SizeCompatTests extends ActivityTestsBase { .setResizeMode(RESIZE_MODE_UNRESIZEABLE) .setMaxAspectRatio(1.5f) .build(); - mActivity.visible = true; + mActivity.mVisibleRequested = true; final Rect originalBounds = new Rect(mActivity.getBounds()); final int originalDpi = mActivity.getConfiguration().densityDpi; @@ -320,7 +320,7 @@ public class SizeCompatTests extends ActivityTestsBase { prepareUnresizable(1.5f, SCREEN_ORIENTATION_UNSPECIFIED); mActivity.setState(STOPPED, "testSizeCompatMode"); - mActivity.visible = false; + mActivity.mVisibleRequested = false; mActivity.app.setReportedProcState(ActivityManager.PROCESS_STATE_CACHED_ACTIVITY); // Make the parent bounds to be different so the activity is in size compatibility mode. mTask.getWindowConfiguration().setAppBounds(new Rect(0, 0, 600, 1200)); @@ -383,7 +383,7 @@ public class SizeCompatTests extends ActivityTestsBase { compatTokens.clear(); // Make the activity resizable again by restarting it activity.info.resizeMode = ActivityInfo.RESIZE_MODE_RESIZEABLE; - activity.visible = true; + activity.mVisibleRequested = true; activity.restartProcessIfVisible(); // The full lifecycle isn't hooked up so manually set state to resumed activity.setState(ActivityStack.ActivityState.RESUMED, "testHandleActivitySizeCompatMode"); @@ -400,7 +400,7 @@ public class SizeCompatTests extends ActivityTestsBase { */ private void prepareUnresizable(float maxAspect, int screenOrientation) { mActivity.info.resizeMode = RESIZE_MODE_UNRESIZEABLE; - mActivity.visible = true; + mActivity.mVisibleRequested = true; if (maxAspect >= 0) { mActivity.info.maxAspectRatio = maxAspect; } diff --git a/services/tests/wmtests/src/com/android/server/wm/WindowStateTests.java b/services/tests/wmtests/src/com/android/server/wm/WindowStateTests.java index 9e0d3a78c756..1b5a24d75e76 100644 --- a/services/tests/wmtests/src/com/android/server/wm/WindowStateTests.java +++ b/services/tests/wmtests/src/com/android/server/wm/WindowStateTests.java @@ -569,7 +569,7 @@ public class WindowStateTests extends WindowTestsBase { @Test public void testCantReceiveTouchWhenAppTokenHiddenRequested() { final WindowState win0 = createWindow(null, TYPE_APPLICATION, "win0"); - win0.mActivityRecord.hiddenRequested = true; + win0.mActivityRecord.mVisibleRequested = false; assertTrue(win0.cantReceiveTouchInput()); } diff --git a/services/tests/wmtests/src/com/android/server/wm/WindowTestUtils.java b/services/tests/wmtests/src/com/android/server/wm/WindowTestUtils.java index 797a6bc7e087..34a2369c67b3 100644 --- a/services/tests/wmtests/src/com/android/server/wm/WindowTestUtils.java +++ b/services/tests/wmtests/src/com/android/server/wm/WindowTestUtils.java @@ -75,7 +75,7 @@ class WindowTestUtils { activity.onDisplayChanged(dc); activity.setOccludesParent(true); activity.setHidden(false); - activity.hiddenRequested = false; + activity.mVisibleRequested = true; } static TestWindowToken createTestWindowToken(int type, DisplayContent dc) { |