Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f8c7ced9 authored by Issei Suzuki's avatar Issei Suzuki
Browse files

Clean up visibility related flags in ActivityRecord

- Replace visible and hiddenRequested flag by a single flag
  mVisibleRequested.
- Merge setVisible() into setVisiblity().

Test: Refactoring, all existing tests pass.
Bug: 80414790
Change-Id: I2a959632430d90ef5c0f738aa791ef230c4a21f1
parent b814d6b3
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -235,7 +235,7 @@ message AppWindowTokenProto {
    optional WindowContainerThumbnailProto thumbnail = 6;
    optional WindowContainerThumbnailProto thumbnail = 6;
    optional bool fills_parent = 7;
    optional bool fills_parent = 7;
    optional bool app_stopped = 8;
    optional bool app_stopped = 8;
    optional bool hidden_requested = 9;
    optional bool visible_requested = 9;
    optional bool client_hidden = 10;
    optional bool client_hidden = 10;
    optional bool defer_hiding_client = 11;
    optional bool defer_hiding_client = 11;
    optional bool reported_drawn = 12;
    optional bool reported_drawn = 12;
+16 −16
Original line number Original line Diff line number Diff line
@@ -73,6 +73,12 @@
      "group": "WM_ERROR",
      "group": "WM_ERROR",
      "at": "com\/android\/server\/wm\/WindowManagerService.java"
      "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": {
    "-1963461591": {
      "message": "Removing %s from %s",
      "message": "Removing %s from %s",
      "level": "VERBOSE",
      "level": "VERBOSE",
@@ -883,6 +889,12 @@
      "group": "WM_DEBUG_ORIENTATION",
      "group": "WM_DEBUG_ORIENTATION",
      "at": "com\/android\/server\/wm\/ActivityRecord.java"
      "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": {
    "-198463978": {
      "message": "updateRotationUnchecked: alwaysSendConfiguration=%b forceRelayout=%b",
      "message": "updateRotationUnchecked: alwaysSendConfiguration=%b forceRelayout=%b",
      "level": "VERBOSE",
      "level": "VERBOSE",
@@ -1207,12 +1219,6 @@
      "group": "WM_DEBUG_ORIENTATION",
      "group": "WM_DEBUG_ORIENTATION",
      "at": "com\/android\/server\/wm\/WindowManagerService.java"
      "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": {
    "371641947": {
      "message": "Window Manager Crash %s",
      "message": "Window Manager Crash %s",
      "level": "WTF",
      "level": "WTF",
@@ -1501,12 +1507,6 @@
      "group": "WM_DEBUG_RECENTS_ANIMATIONS",
      "group": "WM_DEBUG_RECENTS_ANIMATIONS",
      "at": "com\/android\/server\/wm\/RecentsAnimation.java"
      "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": {
    "873914452": {
      "message": "goodToGo()",
      "message": "goodToGo()",
      "level": "DEBUG",
      "level": "DEBUG",
@@ -1993,10 +1993,10 @@
      "group": "WM_DEBUG_REMOTE_ANIMATIONS",
      "group": "WM_DEBUG_REMOTE_ANIMATIONS",
      "at": "com\/android\/server\/wm\/RemoteAnimationController.java"
      "at": "com\/android\/server\/wm\/RemoteAnimationController.java"
    },
    },
    "1966564525": {
    "1965198071": {
      "message": "Set freezing of %s: hidden=%b freezing=%b hiddenRequested=%b. %s",
      "message": "commitVisibility: %s: hidden=%b visibleRequested=%b",
      "level": "INFO",
      "level": "VERBOSE",
      "group": "WM_DEBUG_ORIENTATION",
      "group": "WM_DEBUG_APP_TRANSITIONS",
      "at": "com\/android\/server\/wm\/ActivityRecord.java"
      "at": "com\/android\/server\/wm\/ActivityRecord.java"
    },
    },
    "1984470582": {
    "1984470582": {
+1 −1
Original line number Original line Diff line number Diff line
@@ -548,7 +548,7 @@ class ActivityMetricsLogger {
    private static boolean hasActivityToBeDrawn(Task t) {
    private static boolean hasActivityToBeDrawn(Task t) {
        for (int i = t.getChildCount() - 1; i >= 0; --i) {
        for (int i = t.getChildCount() - 1; i >= 0; --i) {
            final ActivityRecord r = t.getChildAt(i);
            final ActivityRecord r = t.getChildAt(i);
            if (r.visible && !r.mDrawn && !r.finishing) {
            if (r.mVisibleRequested && !r.mDrawn && !r.finishing) {
                return true;
                return true;
            }
            }
        }
        }
+53 −52
Original line number Original line Diff line number Diff line
@@ -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.DEFER_HIDING_CLIENT;
import static com.android.server.wm.AppWindowTokenProto.FILLS_PARENT;
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.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.HIDDEN_SET_FROM_TRANSFERRED_STARTING_WINDOW;
import static com.android.server.wm.AppWindowTokenProto.IS_ANIMATING;
import static com.android.server.wm.AppWindowTokenProto.IS_ANIMATING;
import static com.android.server.wm.AppWindowTokenProto.IS_WAITING_FOR_TRANSITION_START;
import static com.android.server.wm.AppWindowTokenProto.IS_WAITING_FOR_TRANSITION_START;
@@ -192,6 +191,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_MOVED;
import static com.android.server.wm.AppWindowTokenProto.STARTING_WINDOW;
import static com.android.server.wm.AppWindowTokenProto.STARTING_WINDOW;
import static com.android.server.wm.AppWindowTokenProto.THUMBNAIL;
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.AppWindowTokenProto.WINDOW_TOKEN;
import static com.android.server.wm.IdentifierProto.HASH_CODE;
import static com.android.server.wm.IdentifierProto.HASH_CODE;
import static com.android.server.wm.IdentifierProto.TITLE;
import static com.android.server.wm.IdentifierProto.TITLE;
@@ -462,7 +462,6 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
    private boolean keysPaused;     // has key dispatching been paused for it?
    private boolean keysPaused;     // has key dispatching been paused for it?
    int launchMode;         // the launch mode activity attribute.
    int launchMode;         // the launch mode activity attribute.
    int lockTaskLaunchMode; // the lockTaskMode manifest attribute, subject to override
    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
    boolean visibleIgnoringKeyguard; // is this activity visible, ignoring the fact that Keyguard
                                     // might hide this activity?
                                     // might hide this activity?
    // True if the hidden state of this token was forced to false due to a transferred starting
    // True if the hidden state of this token was forced to false due to a transferred starting
@@ -622,11 +621,11 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
    // case do not clear allDrawn until the animation completes.
    // case do not clear allDrawn until the animation completes.
    boolean deferClearAllDrawn;
    boolean deferClearAllDrawn;


    // Is this window's surface needed?  This is almost like hidden, except
    // Is this window's surface needed?  This is almost like visible, except
    // it will sometimes be true a little earlier: when the token has
    // 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
    // been shown, but is still waiting for its app transition to execute
    // before making its windows shown.
    // before making its windows shown.
    boolean hiddenRequested;
    boolean mVisibleRequested;


    // Last visibility state we reported to the app token.
    // Last visibility state we reported to the app token.
    boolean reportedVisible;
    boolean reportedVisible;
@@ -836,7 +835,6 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
                pw.print(" finishing="); pw.println(finishing);
                pw.print(" finishing="); pw.println(finishing);
        pw.print(prefix); pw.print("keysPaused="); pw.print(keysPaused);
        pw.print(prefix); pw.print("keysPaused="); pw.print(keysPaused);
                pw.print(" inHistory="); pw.print(inHistory);
                pw.print(" inHistory="); pw.print(inHistory);
                pw.print(" visible="); pw.print(visible);
                pw.print(" sleeping="); pw.print(sleeping);
                pw.print(" sleeping="); pw.print(sleeping);
                pw.print(" idle="); pw.print(idle);
                pw.print(" idle="); pw.print(idle);
                pw.print(" mStartingWindowState=");
                pw.print(" mStartingWindowState=");
@@ -860,7 +858,8 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        }
        }
        pw.print(prefix); pw.print(" mOccludesParent="); pw.print(mOccludesParent);
        pw.print(prefix); pw.print(" mOccludesParent="); pw.print(mOccludesParent);
        pw.print(" mOrientation="); pw.println(mOrientation);
        pw.print(" mOrientation="); pw.println(mOrientation);
        pw.println(prefix + "hiddenRequested=" + hiddenRequested + " mClientHidden=" + mClientHidden
        pw.println(prefix + "mVisibleRequested=" + mVisibleRequested
                + " mClientHidden=" + mClientHidden
                + ((mDeferHidingClient) ? " mDeferHidingClient=" + mDeferHidingClient : "")
                + ((mDeferHidingClient) ? " mDeferHidingClient=" + mDeferHidingClient : "")
                + " reportedDrawn=" + reportedDrawn + " reportedVisible=" + reportedVisible);
                + " reportedDrawn=" + reportedDrawn + " reportedVisible=" + reportedVisible);
        if (paused) {
        if (paused) {
@@ -1488,7 +1487,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A


        // Application tokens start out hidden.
        // Application tokens start out hidden.
        setHidden(true);
        setHidden(true);
        hiddenRequested = true;
        mVisibleRequested = false;


        ColorDisplayService.ColorDisplayServiceInternal cds = LocalServices.getService(
        ColorDisplayService.ColorDisplayServiceInternal cds = LocalServices.getService(
                ColorDisplayService.ColorDisplayServiceInternal.class);
                ColorDisplayService.ColorDisplayServiceInternal.class);
@@ -1517,7 +1516,6 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        deferRelaunchUntilPaused = false;
        deferRelaunchUntilPaused = false;
        keysPaused = false;
        keysPaused = false;
        inHistory = false;
        inHistory = false;
        visible = false;
        nowVisible = false;
        nowVisible = false;
        mDrawn = false;
        mDrawn = false;
        idle = false;
        idle = false;
@@ -2200,7 +2198,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
     * 2. App is delayed closing since it might enter PIP.
     * 2. App is delayed closing since it might enter PIP.
     */
     */
    boolean isClosingOrEnteringPip() {
    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.
     * @return Whether AppOps allows this package to enter picture-in-picture.
@@ -2459,7 +2457,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
                    mAtmService.getLockTaskController().clearLockedTask(task);
                    mAtmService.getLockTaskController().clearLockedTask(task);
                }
                }
            } else if (!isState(PAUSING)) {
            } else if (!isState(PAUSING)) {
                if (visible) {
                if (mVisibleRequested) {
                    // Prepare and execute close transition.
                    // Prepare and execute close transition.
                    prepareActivityHideTransitionAnimation(transit);
                    prepareActivityHideTransitionAnimation(transit);
                }
                }
@@ -2538,12 +2536,13 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        // TODO(b/137329632): find the next activity directly underneath this one, not just anywhere
        // TODO(b/137329632): find the next activity directly underneath this one, not just anywhere
        final ActivityRecord next = getDisplay().topRunningActivity(
        final ActivityRecord next = getDisplay().topRunningActivity(
                true /* considerKeyguardState */);
                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
        // 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
        // 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
        // implied that the current finishing activity should be added into stopping list rather
        // than destroy immediately.
        // than destroy immediately.
        final boolean isNextNotYetVisible = next != null && (!next.nowVisible || !next.visible);
        final boolean isNextNotYetVisible = next != null
                && (!next.nowVisible || !next.mVisibleRequested);
        if (isVisible && isNextNotYetVisible) {
        if (isVisible && isNextNotYetVisible) {
            // Add this activity to the list of stopping activities. It will be processed and
            // Add this activity to the list of stopping activities. It will be processed and
            // destroyed when the next activity reports idle.
            // destroyed when the next activity reports idle.
@@ -3228,7 +3227,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
                }
                }
                if (!fromActivity.isHidden()) {
                if (!fromActivity.isHidden()) {
                    setHidden(false);
                    setHidden(false);
                    hiddenRequested = false;
                    mVisibleRequested = true;
                    mHiddenSetFromTransferredStartingWindow = true;
                    mHiddenSetFromTransferredStartingWindow = true;
                }
                }
                setClientHidden(fromActivity.mClientHidden);
                setClientHidden(fromActivity.mClientHidden);
@@ -3277,7 +3276,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
            if (fromActivity == this) {
            if (fromActivity == this) {
                return;
                return;
            }
            }
            if (fromActivity.hiddenRequested && transferStartingWindow(fromActivity.token)) {
            if (!fromActivity.mVisibleRequested && transferStartingWindow(fromActivity.token)) {
                return;
                return;
            }
            }
        }
        }
@@ -3792,6 +3791,10 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        return opts;
        return opts;
    }
    }


    boolean allowMoveToFront() {
        return pendingOptions == null || !pendingOptions.getAvoidMoveToFront();
    }

    void removeUriPermissionsLocked() {
    void removeUriPermissionsLocked() {
        if (uriPermissions != null) {
        if (uriPermissions != null) {
            uriPermissions.removeUriPermissions();
            uriPermissions.removeUriPermissions();
@@ -3828,7 +3831,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
            return;
            return;
        }
        }
        mDeferHidingClient = deferHidingClient;
        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
            // Hiding the client is no longer deferred and the app isn't visible still, go ahead and
            // update the visibility.
            // update the visibility.
            setVisibility(false);
            setVisibility(false);
@@ -3848,20 +3851,17 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
                    + appToken);
                    + appToken);
            return;
            return;
        }
        }
        if (visible) {
            mDeferHidingClient = false;
        }
        setVisibility(visible, mDeferHidingClient);
        setVisibility(visible, mDeferHidingClient);
        mAtmService.addWindowLayoutReasons(
        mAtmService.addWindowLayoutReasons(
                ActivityTaskManagerService.LAYOUT_REASON_VISIBILITY_CHANGED);
                ActivityTaskManagerService.LAYOUT_REASON_VISIBILITY_CHANGED);
        mStackSupervisor.getActivityMetricsLogger().notifyVisibilityChanged(this);
        mStackSupervisor.getActivityMetricsLogger().notifyVisibilityChanged(this);
    }

    // TODO: Look into merging with #commitVisibility()
    void setVisible(boolean newVisible) {
        visible = newVisible;
        mDeferHidingClient = !visible && mDeferHidingClient;
        setVisibility(visible);
        mStackSupervisor.mAppVisibilitiesChangedSinceLastPause = true;
        mStackSupervisor.mAppVisibilitiesChangedSinceLastPause = true;
    }
    }


    @VisibleForTesting
    void setVisibility(boolean visible, boolean deferHidingClient) {
    void setVisibility(boolean visible, boolean deferHidingClient) {
        final AppTransition appTransition = getDisplayContent().mAppTransition;
        final AppTransition appTransition = getDisplayContent().mAppTransition;


@@ -3872,7 +3872,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        // transition can be selected.
        // transition can be selected.
        // TODO: Probably a good idea to separate the concept of opening/closing apps from the
        // TODO: Probably a good idea to separate the concept of opening/closing apps from the
        // concept of setting visibility...
        // concept of setting visibility...
        if (!visible && hiddenRequested) {
        if (!visible && !mVisibleRequested) {


            if (!deferHidingClient && mLastDeferHidingClient) {
            if (!deferHidingClient && mLastDeferHidingClient) {
                // We previously deferred telling the client to hide itself when visibility was
                // We previously deferred telling the client to hide itself when visibility was
@@ -3884,8 +3884,8 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        }
        }


        ProtoLog.v(WM_DEBUG_APP_TRANSITIONS,
        ProtoLog.v(WM_DEBUG_APP_TRANSITIONS,
                "setAppVisibility(%s, visible=%b): %s hidden=%b hiddenRequested=%b Callers=%s",
                "setAppVisibility(%s, visible=%b): %s hidden=%b mVisibleRequested=%b Callers=%s",
                appToken, visible, appTransition, isHidden(), hiddenRequested,
                appToken, visible, appTransition, isHidden(), mVisibleRequested,
                Debug.getCallers(6));
                Debug.getCallers(6));


        final DisplayContent displayContent = getDisplayContent();
        final DisplayContent displayContent = getDisplayContent();
@@ -3896,7 +3896,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        }
        }
        displayContent.mChangingApps.remove(this);
        displayContent.mChangingApps.remove(this);
        waitingToShow = false;
        waitingToShow = false;
        hiddenRequested = !visible;
        mVisibleRequested = visible;
        mLastDeferHidingClient = deferHidingClient;
        mLastDeferHidingClient = deferHidingClient;


        if (!visible) {
        if (!visible) {
@@ -4035,7 +4035,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
            }
            }


            setHidden(!visible);
            setHidden(!visible);
            hiddenRequested = !visible;
            mVisibleRequested = visible;
            visibilityChanged = true;
            visibilityChanged = true;
            if (!visible) {
            if (!visible) {
                stopFreezingScreen(true, true);
                stopFreezingScreen(true, true);
@@ -4053,8 +4053,8 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
            }
            }


            ProtoLog.v(WM_DEBUG_APP_TRANSITIONS,
            ProtoLog.v(WM_DEBUG_APP_TRANSITIONS,
                    "commitVisibility: %s: hidden=%b hiddenRequested=%b", this,
                    "commitVisibility: %s: hidden=%b visibleRequested=%b", this,
                    isHidden(), hiddenRequested);
                    isHidden(), mVisibleRequested);


            if (changed) {
            if (changed) {
                displayContent.getInputMonitor().setUpdateInputWindowsNeededLw();
                displayContent.getInputMonitor().setUpdateInputWindowsNeededLw();
@@ -4399,7 +4399,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
                updateOptionsLocked(returningOptions);
                updateOptionsLocked(returningOptions);
                stack.mUndrawnActivitiesBelowTopTranslucent.add(this);
                stack.mUndrawnActivitiesBelowTopTranslucent.add(this);
            }
            }
            setVisible(true);
            setVisibility(true);
            sleeping = false;
            sleeping = false;
            app.postPendingUiCleanMsg(true);
            app.postPendingUiCleanMsg(true);
            if (reportToClient) {
            if (reportToClient) {
@@ -4435,7 +4435,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
    }
    }


    void makeInvisible() {
    void makeInvisible() {
        if (!visible) {
        if (!mVisibleRequested) {
            if (DEBUG_VISIBILITY) Slog.v(TAG_VISIBILITY, "Already invisible: " + this);
            if (DEBUG_VISIBILITY) Slog.v(TAG_VISIBILITY, "Already invisible: " + this);
            return;
            return;
        }
        }
@@ -4457,7 +4457,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
            final boolean deferHidingClient = canEnterPictureInPicture
            final boolean deferHidingClient = canEnterPictureInPicture
                    && !isState(STOPPING, STOPPED, PAUSED);
                    && !isState(STOPPING, STOPPED, PAUSED);
            setDeferHidingClient(deferHidingClient);
            setDeferHidingClient(deferHidingClient);
            setVisible(false);
            setVisibility(false);


            switch (getState()) {
            switch (getState()) {
                case STOPPING:
                case STOPPING:
@@ -4644,8 +4644,8 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
     * state to match that fact.
     * state to match that fact.
     */
     */
    void completeResumeLocked() {
    void completeResumeLocked() {
        final boolean wasVisible = visible;
        final boolean wasVisible = mVisibleRequested;
        setVisible(true);
        setVisibility(true);
        if (!wasVisible) {
        if (!wasVisible) {
            // Visibility has changed, so take a note of it so we call the TaskStackChangedListener
            // Visibility has changed, so take a note of it so we call the TaskStackChangedListener
            mStackSupervisor.mAppVisibilitiesChangedSinceLastPause = true;
            mStackSupervisor.mAppVisibilitiesChangedSinceLastPause = true;
@@ -4729,15 +4729,16 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
            }
            }
            setState(STOPPING, "stopIfPossible");
            setState(STOPPING, "stopIfPossible");
            if (DEBUG_VISIBILITY) {
            if (DEBUG_VISIBILITY) {
                Slog.v(TAG_VISIBILITY, "Stopping visible=" + visible + " for " + this);
                Slog.v(TAG_VISIBILITY, "Stopping visibleRequested="
                        + mVisibleRequested + " for " + this);
            }
            }
            if (!visible) {
            if (!mVisibleRequested) {
                setVisible(false);
                setVisibility(false);
            }
            }
            EventLogTags.writeAmStopActivity(
            EventLogTags.writeAmStopActivity(
                    mUserId, System.identityHashCode(this), shortComponentName);
                    mUserId, System.identityHashCode(this), shortComponentName);
            mAtmService.getLifecycleManager().scheduleTransaction(app.getThread(), appToken,
            mAtmService.getLifecycleManager().scheduleTransaction(app.getThread(), appToken,
                    StopActivityItem.obtain(visible, configChangeFlags));
                    StopActivityItem.obtain(mVisibleRequested, configChangeFlags));
            if (stack.shouldSleepOrShutDownActivities()) {
            if (stack.shouldSleepOrShutDownActivities()) {
                setSleeping(true);
                setSleeping(true);
            }
            }
@@ -4900,10 +4901,10 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A


    void startFreezingScreen() {
    void startFreezingScreen() {
        ProtoLog.i(WM_DEBUG_ORIENTATION,
        ProtoLog.i(WM_DEBUG_ORIENTATION,
                "Set freezing of %s: hidden=%b freezing=%b hiddenRequested=%b. %s",
                "Set freezing of %s: hidden=%b freezing=%b visibleRequested=%b. %s",
                appToken, isHidden(), mFreezingScreen, hiddenRequested,
                appToken, isHidden(), mFreezingScreen, mVisibleRequested,
                new RuntimeException().fillInStackTrace());
                new RuntimeException().fillInStackTrace());
        if (!hiddenRequested) {
        if (mVisibleRequested) {
            if (!mFreezingScreen) {
            if (!mFreezingScreen) {
                mFreezingScreen = true;
                mFreezingScreen = true;
                mWmService.registerAppFreezeListener(this);
                mWmService.registerAppFreezeListener(this);
@@ -5182,7 +5183,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
                    Slog.v(TAG, "Not displayed: s=" + winAnimator.mSurfaceController
                    Slog.v(TAG, "Not displayed: s=" + winAnimator.mSurfaceController
                            + " pv=" + w.isVisibleByPolicy()
                            + " pv=" + w.isVisibleByPolicy()
                            + " mDrawState=" + winAnimator.drawStateToString()
                            + " mDrawState=" + winAnimator.drawStateToString()
                            + " ph=" + w.isParentWindowHidden() + " th=" + hiddenRequested
                            + " ph=" + w.isParentWindowHidden() + " th=" + mVisibleRequested
                            + " a=" + isAnimating(TRANSITION));
                            + " a=" + isAnimating(TRANSITION));
                }
                }
            }
            }
@@ -5290,7 +5291,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
     * currently pausing, or is resumed.
     * currently pausing, or is resumed.
     */
     */
    public boolean isInterestingToUserLocked() {
    public boolean isInterestingToUserLocked() {
        return visible || nowVisible || mState == PAUSING || mState == RESUMED;
        return mVisibleRequested || nowVisible || mState == PAUSING || mState == RESUMED;
    }
    }


    void setSleeping(boolean _sleeping) {
    void setSleeping(boolean _sleeping) {
@@ -5364,7 +5365,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
            // We're not ready for this kind of thing.
            // We're not ready for this kind of thing.
            return false;
            return false;
        }
        }
        if (visible) {
        if (mVisibleRequested) {
            // The user would notice this!
            // The user would notice this!
            return false;
            return false;
        }
        }
@@ -5922,7 +5923,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
                "AppWindowToken");
                "AppWindowToken");


        clearThumbnail();
        clearThumbnail();
        setClientHidden(isHidden() && hiddenRequested);
        setClientHidden(isHidden() && !mVisibleRequested);


        getDisplayContent().computeImeTargetIfNeeded(this);
        getDisplayContent().computeImeTargetIfNeeded(this);


@@ -6519,7 +6520,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        if (display == null) {
        if (display == null) {
            return;
            return;
        }
        }
        if (visible) {
        if (mVisibleRequested) {
            // It may toggle the UI for user to restart the size compatibility mode activity.
            // It may toggle the UI for user to restart the size compatibility mode activity.
            display.handleActivitySizeCompatModeIfNeeded(this);
            display.handleActivitySizeCompatModeIfNeeded(this);
        } else if (mCompatDisplayInsets != null) {
        } else if (mCompatDisplayInsets != null) {
@@ -6816,7 +6817,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
            } else {
            } else {
                if (DEBUG_SWITCH || DEBUG_CONFIGURATION) Slog.v(TAG_CONFIGURATION,
                if (DEBUG_SWITCH || DEBUG_CONFIGURATION) Slog.v(TAG_CONFIGURATION,
                        "Config is relaunching " + this);
                        "Config is relaunching " + this);
                if (DEBUG_STATES && !visible) {
                if (DEBUG_STATES && !mVisibleRequested) {
                    Slog.v(TAG_STATES, "Config is relaunching invisible activity " + this
                    Slog.v(TAG_STATES, "Config is relaunching invisible activity " + this
                            + " called by " + Debug.getCallers(4));
                            + " called by " + Debug.getCallers(4));
                }
                }
@@ -7002,7 +7003,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        // Reset the existing override configuration so it can be updated according to the latest
        // Reset the existing override configuration so it can be updated according to the latest
        // configuration.
        // configuration.
        clearSizeCompatMode();
        clearSizeCompatMode();
        if (visible) {
        if (mVisibleRequested) {
            // Configuration will be ensured when becoming visible, so if it is already visible,
            // Configuration will be ensured when becoming visible, so if it is already visible,
            // then the manual update is needed.
            // then the manual update is needed.
            updateSizeCompatMode();
            updateSizeCompatMode();
@@ -7015,7 +7016,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        // The restarting state avoids removing this record when process is died.
        // The restarting state avoids removing this record when process is died.
        setState(RESTARTING_PROCESS, "restartActivityProcess");
        setState(RESTARTING_PROCESS, "restartActivityProcess");


        if (!visible || mHaveState) {
        if (!mVisibleRequested || mHaveState) {
            // Kill its process immediately because the activity should be in background.
            // Kill its process immediately because the activity should be in background.
            // The activity state will be update to {@link #DESTROYED} in
            // The activity state will be update to {@link #DESTROYED} in
            // {@link ActivityStack#cleanUp} when handling process died.
            // {@link ActivityStack#cleanUp} when handling process died.
@@ -7306,7 +7307,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        writeToProto(proto, APP_WINDOW_TOKEN, WindowTraceLogLevel.ALL);
        writeToProto(proto, APP_WINDOW_TOKEN, WindowTraceLogLevel.ALL);
        writeIdentifierToProto(proto, IDENTIFIER);
        writeIdentifierToProto(proto, IDENTIFIER);
        proto.write(STATE, mState.toString());
        proto.write(STATE, mState.toString());
        proto.write(VISIBLE, visible);
        proto.write(VISIBLE, mVisibleRequested);
        proto.write(FRONT_OF_TASK, isRootOfTask());
        proto.write(FRONT_OF_TASK, isRootOfTask());
        if (hasProcess()) {
        if (hasProcess()) {
            proto.write(PROC_ID, app.getPid());
            proto.write(PROC_ID, app.getPid());
@@ -7342,7 +7343,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        }
        }
        proto.write(FILLS_PARENT, mOccludesParent);
        proto.write(FILLS_PARENT, mOccludesParent);
        proto.write(APP_STOPPED, mAppStopped);
        proto.write(APP_STOPPED, mAppStopped);
        proto.write(HIDDEN_REQUESTED, hiddenRequested);
        proto.write(VISIBLE_REQUESTED, mVisibleRequested);
        proto.write(CLIENT_HIDDEN, mClientHidden);
        proto.write(CLIENT_HIDDEN, mClientHidden);
        proto.write(DEFER_HIDING_CLIENT, mDeferHidingClient);
        proto.write(DEFER_HIDING_CLIENT, mDeferHidingClient);
        proto.write(REPORTED_DRAWN, reportedDrawn);
        proto.write(REPORTED_DRAWN, reportedDrawn);
+1 −1
Original line number Original line Diff line number Diff line
@@ -73,7 +73,7 @@ public class ActivityServiceConnectionsHolder<T> {


    public boolean isActivityVisible() {
    public boolean isActivityVisible() {
        synchronized (mService.mGlobalLock) {
        synchronized (mService.mGlobalLock) {
            return mActivity.visible || mActivity.isState(RESUMED, PAUSING);
            return mActivity.mVisibleRequested || mActivity.isState(RESUMED, PAUSING);
        }
        }
    }
    }


Loading