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

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

Clean up visibility related flags in ActivityRecord

- Replace mClientHidden by mClientVisible

Test: Refactoring, all existing tests pass.
Bug: 80414790
Change-Id: Ica79662b7c2d85d6862b96d1e6cedfde704a2c15
parent e4a34f68
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -236,7 +236,7 @@ message AppWindowTokenProto {
    optional bool fills_parent = 7;
    optional bool app_stopped = 8;
    optional bool visible_requested = 9;
    optional bool client_hidden = 10;
    optional bool client_visible = 10;
    optional bool defer_hiding_client = 11;
    optional bool reported_drawn = 12;
    optional bool reported_visible = 13;
+6 −6
Original line number Diff line number Diff line
@@ -55,6 +55,12 @@
      "group": "WM_DEBUG_REMOTE_ANIMATIONS",
      "at": "com\/android\/server\/wm\/RemoteAnimationController.java"
    },
    "-2006946193": {
      "message": "setClientVisible: %s clientVisible=%b Callers=%s",
      "level": "VERBOSE",
      "group": "WM_DEBUG_APP_TRANSITIONS",
      "at": "com\/android\/server\/wm\/ActivityRecord.java"
    },
    "-2002500255": {
      "message": "Defer removing snapshot surface in %dms",
      "level": "VERBOSE",
@@ -307,12 +313,6 @@
      "group": "WM_DEBUG_ADD_REMOVE",
      "at": "com\/android\/server\/wm\/ActivityRecord.java"
    },
    "-1456549051": {
      "message": "setClientHidden: %s clientHidden=%b Callers=%s",
      "level": "VERBOSE",
      "group": "WM_DEBUG_APP_TRANSITIONS",
      "at": "com\/android\/server\/wm\/ActivityRecord.java"
    },
    "-1455600136": {
      "message": "Attempted to add Dream window with unknown token %s.  Aborting.",
      "level": "WARN",
+20 −19
Original line number Diff line number Diff line
@@ -173,7 +173,7 @@ import static com.android.server.wm.ActivityTaskManagerService.RELAUNCH_REASON_W
import static com.android.server.wm.ActivityTaskManagerService.getInputDispatchingTimeoutLocked;
import static com.android.server.wm.AppWindowTokenProto.ALL_DRAWN;
import static com.android.server.wm.AppWindowTokenProto.APP_STOPPED;
import static com.android.server.wm.AppWindowTokenProto.CLIENT_HIDDEN;
import static com.android.server.wm.AppWindowTokenProto.CLIENT_VISIBLE;
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;
@@ -465,13 +465,13 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
    private boolean mVisible;        // Should this token's windows be visible?
    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
    // True if the visible state of this token was forced to true due to a transferred starting
    // window.
    private boolean mVisibleSetFromTransferredStartingWindow;
    // TODO: figure out how to consolidate with the same variable in ActivityRecord.
    private boolean mDeferHidingClient; // If true we told WM to defer reporting to the client
                                        // process that it is hidden.
    private boolean mLastDeferHidingClient; // If true we will defer setting mClientHidden to true
    private boolean mLastDeferHidingClient; // If true we will defer setting mClientVisible to false
                                           // and reporting to the client that it is hidden.
    boolean sleeping;       // have we told the activity to sleep?
    boolean nowVisible;     // is this activity's window visible?
@@ -536,8 +536,8 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A

    private Task mLastParent;

    // Have we told the window clients to hide themselves?
    private boolean mClientHidden;
    // Have we told the window clients to show themselves?
    private boolean mClientVisible;

    boolean firstWindowDrawn;
    // Last drawn state we reported to the app token.
@@ -861,7 +861,7 @@ 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 + "mVisibleRequested=" + mVisibleRequested
                + " mClientHidden=" + mClientHidden
                + " mClientVisible=" + mClientVisible
                + ((mDeferHidingClient) ? " mDeferHidingClient=" + mDeferHidingClient : "")
                + " reportedDrawn=" + reportedDrawn + " reportedVisible=" + reportedVisible);
        if (paused) {
@@ -1520,6 +1520,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        inHistory = false;
        nowVisible = false;
        mDrawn = false;
        mClientVisible = true;
        idle = false;
        hasBeenLaunched = false;
        mStackSupervisor = supervisor;
@@ -3232,7 +3233,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
                    mVisibleRequested = true;
                    mVisibleSetFromTransferredStartingWindow = true;
                }
                setClientHidden(fromActivity.mClientHidden);
                setClientVisible(fromActivity.mClientVisible);

                transferAnimation(fromActivity);

@@ -3887,7 +3888,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
                // We previously deferred telling the client to hide itself when visibility was
                // initially set to false. Now we would like it to hide, so go ahead and set it.
                mLastDeferHidingClient = deferHidingClient;
                setClientHidden(true);
                setClientVisible(false);
            }
            return;
        }
@@ -3932,7 +3933,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
                    waitingToShow = true;

                    // If the client isn't hidden, we don't need to reset the drawing state.
                    if (isClientHidden()) {
                    if (!isClientVisible()) {
                        // Let's reset the draw state in order to prevent the starting window to be
                        // immediately dismissed when the app still has the surface.
                        forAllWindows(w -> {
@@ -3952,7 +3953,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
            // we still need to tell the client to make its windows visible so they get drawn.
            // Otherwise, we will wait on performing the transition until all windows have been
            // drawn, they never will be, and we are sad.
            setClientHidden(false);
            setClientVisible(true);

            requestUpdateWallpaperIfNeeded();

@@ -4100,7 +4101,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
            // If we're becoming invisible, update the client visibility if we are not running an
            // animation. Otherwise, we'll update client visibility in onAnimationFinished.
            if (visible || !isAnimating()) {
                setClientHidden(!visible);
                setClientVisible(visible);
            }

            if (!displayContent.mClosingApps.contains(this)
@@ -5132,18 +5133,18 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        }
    }

    boolean isClientHidden() {
        return mClientHidden;
    boolean isClientVisible() {
        return mClientVisible;
    }

    void setClientHidden(boolean hideClient) {
        if (mClientHidden == hideClient || (hideClient && mDeferHidingClient)) {
    void setClientVisible(boolean clientVisible) {
        if (mClientVisible == clientVisible || (!clientVisible && mDeferHidingClient)) {
            return;
        }
        ProtoLog.v(WM_DEBUG_APP_TRANSITIONS,
                "setClientHidden: %s clientHidden=%b Callers=%s", this, hideClient,
                "setClientVisible: %s clientVisible=%b Callers=%s", this, clientVisible,
                Debug.getCallers(5));
        mClientHidden = hideClient;
        mClientVisible = clientVisible;
        sendAppVisibilityToClients();
    }

@@ -5926,7 +5927,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
                "AppWindowToken");

        clearThumbnail();
        setClientHidden(!isVisible() && !mVisibleRequested);
        setClientVisible(isVisible() || mVisibleRequested);

        getDisplayContent().computeImeTargetIfNeeded(this);

@@ -7348,7 +7349,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        proto.write(FILLS_PARENT, mOccludesParent);
        proto.write(APP_STOPPED, mAppStopped);
        proto.write(com.android.server.wm.AppWindowTokenProto.VISIBLE_REQUESTED, mVisibleRequested);
        proto.write(CLIENT_HIDDEN, mClientHidden);
        proto.write(CLIENT_VISIBLE, mClientVisible);
        proto.write(DEFER_HIDING_CLIENT, mDeferHidingClient);
        proto.write(REPORTED_DRAWN, reportedDrawn);
        proto.write(REPORTED_VISIBLE, reportedVisible);
+1 −1
Original line number Diff line number Diff line
@@ -3061,7 +3061,7 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
                wsa.destroySurface();
                mWmService.mForceRemoves.add(w);
                mTmpWindow = w;
            } else if (w.mActivityRecord != null && w.mActivityRecord.isClientHidden()) {
            } else if (w.mActivityRecord != null && !w.mActivityRecord.isClientVisible()) {
                Slog.w(TAG_WM, "LEAKED SURFACE (app token hidden): "
                        + w + " surface=" + wsa.mSurfaceController
                        + " token=" + w.mActivityRecord);
+4 −5
Original line number Diff line number Diff line
@@ -2527,7 +2527,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.mVisibleRequested) {
            if (token.mIsExiting || !token.isClientVisible() || !token.mVisibleRequested) {
                continue;
            }
            final WindowState win = token.findMainWindow();
@@ -2745,10 +2745,9 @@ class Task extends WindowContainer<ActivityRecord> implements ConfigurationConta

    ActivityRecord getTopVisibleActivity() {
        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.mVisibleRequested) {
                return token;
            final ActivityRecord activity = mChildren.get(i);
            if (!activity.mIsExiting && activity.isClientVisible() && activity.mVisibleRequested) {
                return activity;
            }
        }
        return null;
Loading