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

Commit 430a1115 authored by Issei Suzuki's avatar Issei Suzuki
Browse files

Revert "Clean up visibility related flags in ActivityRecord"

This reverts commit f8c7ced9.

Reason for revert: broke dev test (com.roidapp.photogrid)
Fixes: 144403961
parent 7b9e2579
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 visible_requested = 9;
    optional bool hidden_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,12 +73,6 @@
      "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",
@@ -889,12 +883,6 @@
      "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",
@@ -1219,6 +1207,12 @@
      "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",
@@ -1507,6 +1501,12 @@
      "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"
    },
    },
    "1965198071": {
    "1966564525": {
      "message": "commitVisibility: %s: hidden=%b visibleRequested=%b",
      "message": "Set freezing of %s: hidden=%b freezing=%b hiddenRequested=%b. %s",
      "level": "VERBOSE",
      "level": "INFO",
      "group": "WM_DEBUG_APP_TRANSITIONS",
      "group": "WM_DEBUG_ORIENTATION",
      "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.mVisibleRequested && !r.mDrawn && !r.finishing) {
            if (r.visible && !r.mDrawn && !r.finishing) {
                return true;
                return true;
            }
            }
        }
        }
+52 −53
Original line number Original line Diff line number Diff line
@@ -176,6 +176,7 @@ 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;
@@ -191,7 +192,6 @@ 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,6 +462,7 @@ 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
@@ -621,11 +622,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 visible, except
    // Is this window's surface needed?  This is almost like hidden, except
    // it will sometimes be true a little earlier: when the activity record has
    // it will sometimes be true a little earlier: when the token 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 mVisibleRequested;
    boolean hiddenRequested;


    // Last visibility state we reported to the app token.
    // Last visibility state we reported to the app token.
    boolean reportedVisible;
    boolean reportedVisible;
@@ -835,6 +836,7 @@ 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=");
@@ -858,8 +860,7 @@ 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 + "mVisibleRequested=" + mVisibleRequested
        pw.println(prefix + "hiddenRequested=" + hiddenRequested + " mClientHidden=" + mClientHidden
                + " mClientHidden=" + mClientHidden
                + ((mDeferHidingClient) ? " mDeferHidingClient=" + mDeferHidingClient : "")
                + ((mDeferHidingClient) ? " mDeferHidingClient=" + mDeferHidingClient : "")
                + " reportedDrawn=" + reportedDrawn + " reportedVisible=" + reportedVisible);
                + " reportedDrawn=" + reportedDrawn + " reportedVisible=" + reportedVisible);
        if (paused) {
        if (paused) {
@@ -1487,7 +1488,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A


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


        ColorDisplayService.ColorDisplayServiceInternal cds = LocalServices.getService(
        ColorDisplayService.ColorDisplayServiceInternal cds = LocalServices.getService(
                ColorDisplayService.ColorDisplayServiceInternal.class);
                ColorDisplayService.ColorDisplayServiceInternal.class);
@@ -1516,6 +1517,7 @@ 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;
@@ -2198,7 +2200,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) && !mVisibleRequested) || mWillCloseOrEnterPip;
        return (isAnimating(TRANSITION | PARENTS) && hiddenRequested) || mWillCloseOrEnterPip;
    }
    }
    /**
    /**
     * @return Whether AppOps allows this package to enter picture-in-picture.
     * @return Whether AppOps allows this package to enter picture-in-picture.
@@ -2457,7 +2459,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 (mVisibleRequested) {
                if (visible) {
                    // Prepare and execute close transition.
                    // Prepare and execute close transition.
                    prepareActivityHideTransitionAnimation(transit);
                    prepareActivityHideTransitionAnimation(transit);
                }
                }
@@ -2536,13 +2538,12 @@ 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 = mVisibleRequested || nowVisible;
        final boolean isVisible = visible || 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
        final boolean isNextNotYetVisible = next != null && (!next.nowVisible || !next.visible);
                && (!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.
@@ -3225,7 +3226,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
                }
                }
                if (!fromActivity.isHidden()) {
                if (!fromActivity.isHidden()) {
                    setHidden(false);
                    setHidden(false);
                    mVisibleRequested = true;
                    hiddenRequested = false;
                    mHiddenSetFromTransferredStartingWindow = true;
                    mHiddenSetFromTransferredStartingWindow = true;
                }
                }
                setClientHidden(fromActivity.mClientHidden);
                setClientHidden(fromActivity.mClientHidden);
@@ -3274,7 +3275,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
            if (fromActivity == this) {
            if (fromActivity == this) {
                return;
                return;
            }
            }
            if (!fromActivity.mVisibleRequested && transferStartingWindow(fromActivity.token)) {
            if (fromActivity.hiddenRequested && transferStartingWindow(fromActivity.token)) {
                return;
                return;
            }
            }
        }
        }
@@ -3789,10 +3790,6 @@ 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();
@@ -3829,7 +3826,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
            return;
            return;
        }
        }
        mDeferHidingClient = deferHidingClient;
        mDeferHidingClient = deferHidingClient;
        if (!mDeferHidingClient && !mVisibleRequested) {
        if (!mDeferHidingClient && !visible) {
            // 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);
@@ -3849,17 +3846,20 @@ 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;


@@ -3870,7 +3870,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 && !mVisibleRequested) {
        if (!visible && hiddenRequested) {


            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
@@ -3882,8 +3882,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 mVisibleRequested=%b Callers=%s",
                "setAppVisibility(%s, visible=%b): %s hidden=%b hiddenRequested=%b Callers=%s",
                appToken, visible, appTransition, isHidden(), mVisibleRequested,
                appToken, visible, appTransition, isHidden(), hiddenRequested,
                Debug.getCallers(6));
                Debug.getCallers(6));


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


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


            setHidden(!visible);
            setHidden(!visible);
            mVisibleRequested = visible;
            hiddenRequested = !visible;
            visibilityChanged = true;
            visibilityChanged = true;
            if (!visible) {
            if (!visible) {
                stopFreezingScreen(true, true);
                stopFreezingScreen(true, true);
@@ -4051,8 +4051,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 visibleRequested=%b", this,
                    "commitVisibility: %s: hidden=%b hiddenRequested=%b", this,
                    isHidden(), mVisibleRequested);
                    isHidden(), hiddenRequested);


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


    void makeInvisible() {
    void makeInvisible() {
        if (!mVisibleRequested) {
        if (!visible) {
            if (DEBUG_VISIBILITY) Slog.v(TAG_VISIBILITY, "Already invisible: " + this);
            if (DEBUG_VISIBILITY) Slog.v(TAG_VISIBILITY, "Already invisible: " + this);
            return;
            return;
        }
        }
@@ -4455,7 +4455,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);
            setVisibility(false);
            setVisible(false);


            switch (getState()) {
            switch (getState()) {
                case STOPPING:
                case STOPPING:
@@ -4642,8 +4642,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 = mVisibleRequested;
        final boolean wasVisible = visible;
        setVisibility(true);
        setVisible(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;
@@ -4727,16 +4727,15 @@ 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 visibleRequested="
                Slog.v(TAG_VISIBILITY, "Stopping visible=" + visible + " for " + this);
                        + mVisibleRequested + " for " + this);
            }
            }
            if (!mVisibleRequested) {
            if (!visible) {
                setVisibility(false);
                setVisible(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(mVisibleRequested, configChangeFlags));
                    StopActivityItem.obtain(visible, configChangeFlags));
            if (stack.shouldSleepOrShutDownActivities()) {
            if (stack.shouldSleepOrShutDownActivities()) {
                setSleeping(true);
                setSleeping(true);
            }
            }
@@ -4899,10 +4898,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 visibleRequested=%b. %s",
                "Set freezing of %s: hidden=%b freezing=%b hiddenRequested=%b. %s",
                appToken, isHidden(), mFreezingScreen, mVisibleRequested,
                appToken, isHidden(), mFreezingScreen, hiddenRequested,
                new RuntimeException().fillInStackTrace());
                new RuntimeException().fillInStackTrace());
        if (mVisibleRequested) {
        if (!hiddenRequested) {
            if (!mFreezingScreen) {
            if (!mFreezingScreen) {
                mFreezingScreen = true;
                mFreezingScreen = true;
                mWmService.registerAppFreezeListener(this);
                mWmService.registerAppFreezeListener(this);
@@ -5181,7 +5180,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=" + mVisibleRequested
                            + " ph=" + w.isParentWindowHidden() + " th=" + hiddenRequested
                            + " a=" + isAnimating(TRANSITION));
                            + " a=" + isAnimating(TRANSITION));
                }
                }
            }
            }
@@ -5289,7 +5288,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 mVisibleRequested || nowVisible || mState == PAUSING || mState == RESUMED;
        return visible || nowVisible || mState == PAUSING || mState == RESUMED;
    }
    }


    void setSleeping(boolean _sleeping) {
    void setSleeping(boolean _sleeping) {
@@ -5363,7 +5362,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 (mVisibleRequested) {
        if (visible) {
            // The user would notice this!
            // The user would notice this!
            return false;
            return false;
        }
        }
@@ -5921,7 +5920,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
                "AppWindowToken");
                "AppWindowToken");


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


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


@@ -6518,7 +6517,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        if (display == null) {
        if (display == null) {
            return;
            return;
        }
        }
        if (mVisibleRequested) {
        if (visible) {
            // 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) {
@@ -6815,7 +6814,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 && !mVisibleRequested) {
                if (DEBUG_STATES && !visible) {
                    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));
                }
                }
@@ -7001,7 +7000,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 (mVisibleRequested) {
        if (visible) {
            // 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();
@@ -7014,7 +7013,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 (!mVisibleRequested || mHaveState) {
        if (!visible || 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.
@@ -7305,7 +7304,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, mVisibleRequested);
        proto.write(VISIBLE, visible);
        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());
@@ -7341,7 +7340,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(VISIBLE_REQUESTED, mVisibleRequested);
        proto.write(HIDDEN_REQUESTED, hiddenRequested);
        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.mVisibleRequested || mActivity.isState(RESUMED, PAUSING);
            return mActivity.visible || mActivity.isState(RESUMED, PAUSING);
        }
        }
    }
    }


Loading