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

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

Clean up visibility related flags in WindowToken

- Replace isHidden() and setHidden() by isVisible() and setVisible()
  in accordance with variable names.
- Move isVisible() from AppRecord to WindowToken

Test: Refactoring CL, existing tests pass.
Bug: 80414790
Change-Id: Ie77bf1d00336e655b1fbee15d419c6959da2e0c9
parent f8c7ced9
Loading
Loading
Loading
Loading
+2 −1
Original line number Original line Diff line number Diff line
@@ -126,11 +126,12 @@ message ActivityRecordProto {
    optional .com.android.server.wm.ConfigurationContainerProto configuration_container = 1 [deprecated=true];
    optional .com.android.server.wm.ConfigurationContainerProto configuration_container = 1 [deprecated=true];
    optional .com.android.server.wm.IdentifierProto identifier = 2;
    optional .com.android.server.wm.IdentifierProto identifier = 2;
    optional string state = 3;
    optional string state = 3;
    optional bool visible = 4;
    optional bool visible_requested = 4;
    optional bool front_of_task = 5;
    optional bool front_of_task = 5;
    optional int32 proc_id = 6;
    optional int32 proc_id = 6;
    optional bool translucent = 7;
    optional bool translucent = 7;
    optional .com.android.server.wm.AppWindowTokenProto app_window_token = 8;
    optional .com.android.server.wm.AppWindowTokenProto app_window_token = 8;
    optional bool visible = 9;
}
}


message KeyguardControllerProto {
message KeyguardControllerProto {
+2 −2
Original line number Original line Diff line number Diff line
@@ -248,8 +248,9 @@ message AppWindowTokenProto {
    optional IdentifierProto starting_window = 19;
    optional IdentifierProto starting_window = 19;
    optional bool starting_displayed = 20;
    optional bool starting_displayed = 20;
    optional bool starting_moved = 21;
    optional bool starting_moved = 21;
    optional bool hidden_set_from_transferred_starting_window = 22;
    optional bool visible_set_from_transferred_starting_window = 22;
    repeated .android.graphics.RectProto frozen_bounds = 23;
    repeated .android.graphics.RectProto frozen_bounds = 23;
    optional bool visible = 24;
}
}


/* represents WindowToken */
/* represents WindowToken */
@@ -259,7 +260,6 @@ message WindowTokenProto {
    optional WindowContainerProto window_container = 1;
    optional WindowContainerProto window_container = 1;
    optional int32 hash_code = 2;
    optional int32 hash_code = 2;
    repeated WindowStateProto windows = 3;
    repeated WindowStateProto windows = 3;
    optional bool hidden = 4;
    optional bool waiting_to_show = 5;
    optional bool waiting_to_show = 5;
    optional bool paused = 6;
    optional bool paused = 6;
}
}
+28 −28
Original line number Original line Diff line number Diff line
@@ -73,10 +73,10 @@
      "group": "WM_ERROR",
      "group": "WM_ERROR",
      "at": "com\/android\/server\/wm\/WindowManagerService.java"
      "at": "com\/android\/server\/wm\/WindowManagerService.java"
    },
    },
    "-1972506791": {
    "-1976550065": {
      "message": "Set freezing of %s: hidden=%b freezing=%b visibleRequested=%b. %s",
      "message": "commitVisibility: %s: visible=%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"
    },
    },
    "-1963461591": {
    "-1963461591": {
@@ -85,12 +85,6 @@
      "group": "WM_DEBUG_ADD_REMOVE",
      "group": "WM_DEBUG_ADD_REMOVE",
      "at": "com\/android\/server\/wm\/WindowManagerService.java"
      "at": "com\/android\/server\/wm\/WindowManagerService.java"
    },
    },
    "-1958209312": {
      "message": "Clear freezing of %s: hidden=%b freezing=%b",
      "level": "VERBOSE",
      "group": "WM_DEBUG_ORIENTATION",
      "at": "com\/android\/server\/wm\/ActivityRecord.java"
    },
    "-1953668890": {
    "-1953668890": {
      "message": "Can't start recents animation, nextAppTransition=%s",
      "message": "Can't start recents animation, nextAppTransition=%s",
      "level": "DEBUG",
      "level": "DEBUG",
@@ -553,12 +547,6 @@
      "group": "WM_DEBUG_STARTING_WINDOW",
      "group": "WM_DEBUG_STARTING_WINDOW",
      "at": "com\/android\/server\/wm\/WindowState.java"
      "at": "com\/android\/server\/wm\/WindowState.java"
    },
    },
    "-931184679": {
      "message": "Changing app %s hidden=%b performLayout=%b",
      "level": "VERBOSE",
      "group": "WM_DEBUG_APP_TRANSITIONS",
      "at": "com\/android\/server\/wm\/ActivityRecord.java"
    },
    "-928291778": {
    "-928291778": {
      "message": "applyAnimation: anim=%s nextAppTransition=%d transit=%s Callers=%s",
      "message": "applyAnimation: anim=%s nextAppTransition=%d transit=%s Callers=%s",
      "level": "VERBOSE",
      "level": "VERBOSE",
@@ -847,6 +835,12 @@
      "group": "WM_DEBUG_APP_TRANSITIONS",
      "group": "WM_DEBUG_APP_TRANSITIONS",
      "at": "com\/android\/server\/wm\/AppTransitionController.java"
      "at": "com\/android\/server\/wm\/AppTransitionController.java"
    },
    },
    "-374767836": {
      "message": "setAppVisibility(%s, visible=%b): %s visible=%b mVisibleRequested=%b Callers=%s",
      "level": "VERBOSE",
      "group": "WM_DEBUG_APP_TRANSITIONS",
      "at": "com\/android\/server\/wm\/ActivityRecord.java"
    },
    "-371630969": {
    "-371630969": {
      "message": "New wallpaper target=%s, oldWallpaper=%s, openingApps=%s, closingApps=%s",
      "message": "New wallpaper target=%s, oldWallpaper=%s, openingApps=%s, closingApps=%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",
@@ -1279,6 +1267,12 @@
      "group": "WM_DEBUG_SCREEN_ON",
      "group": "WM_DEBUG_SCREEN_ON",
      "at": "com\/android\/server\/wm\/WindowManagerService.java"
      "at": "com\/android\/server\/wm\/WindowManagerService.java"
    },
    },
    "466506262": {
      "message": "Clear freezing of %s: visible=%b freezing=%b",
      "level": "VERBOSE",
      "group": "WM_DEBUG_ORIENTATION",
      "at": "com\/android\/server\/wm\/ActivityRecord.java"
    },
    "474000473": {
    "474000473": {
      "message": "No stack above target stack=%s",
      "message": "No stack above target stack=%s",
      "level": "DEBUG",
      "level": "DEBUG",
@@ -1495,6 +1489,12 @@
      "group": "WM_DEBUG_REMOTE_ANIMATIONS",
      "group": "WM_DEBUG_REMOTE_ANIMATIONS",
      "at": "com\/android\/server\/wm\/RemoteAnimationController.java"
      "at": "com\/android\/server\/wm\/RemoteAnimationController.java"
    },
    },
    "841702299": {
      "message": "Changing app %s visible=%b performLayout=%b",
      "level": "VERBOSE",
      "group": "WM_DEBUG_APP_TRANSITIONS",
      "at": "com\/android\/server\/wm\/ActivityRecord.java"
    },
    "845234215": {
    "845234215": {
      "message": "App is requesting an orientation, return %d for display id=%d",
      "message": "App is requesting an orientation, return %d for display id=%d",
      "level": "VERBOSE",
      "level": "VERBOSE",
@@ -1903,6 +1903,12 @@
      "group": "WM_DEBUG_STARTING_WINDOW",
      "group": "WM_DEBUG_STARTING_WINDOW",
      "at": "com\/android\/server\/wm\/ActivityRecord.java"
      "at": "com\/android\/server\/wm\/ActivityRecord.java"
    },
    },
    "1746778201": {
      "message": "Set freezing of %s: visible=%b freezing=%b visibleRequested=%b. %s",
      "level": "INFO",
      "group": "WM_DEBUG_ORIENTATION",
      "at": "com\/android\/server\/wm\/ActivityRecord.java"
    },
    "1747941491": {
    "1747941491": {
      "message": "SURFACE controller=%s alpha=%f matrix=[%f*%f,%f*%f][%f*%f,%f*%f]: %s",
      "message": "SURFACE controller=%s alpha=%f matrix=[%f*%f,%f*%f][%f*%f,%f*%f]: %s",
      "level": "INFO",
      "level": "INFO",
@@ -1993,12 +1999,6 @@
      "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": {
      "message": "commitVisibility: %s: hidden=%b visibleRequested=%b",
      "level": "VERBOSE",
      "group": "WM_DEBUG_APP_TRANSITIONS",
      "at": "com\/android\/server\/wm\/ActivityRecord.java"
    },
    "1984470582": {
    "1984470582": {
      "message": "Creating TaskScreenshotAnimatable: task: %s width: %d height: %d",
      "message": "Creating TaskScreenshotAnimatable: task: %s width: %d height: %d",
      "level": "DEBUG",
      "level": "DEBUG",
+51 −46
Original line number Original line Diff line number Diff line
@@ -121,6 +121,7 @@ import static com.android.server.am.ActivityRecordProto.PROC_ID;
import static com.android.server.am.ActivityRecordProto.STATE;
import static com.android.server.am.ActivityRecordProto.STATE;
import static com.android.server.am.ActivityRecordProto.TRANSLUCENT;
import static com.android.server.am.ActivityRecordProto.TRANSLUCENT;
import static com.android.server.am.ActivityRecordProto.VISIBLE;
import static com.android.server.am.ActivityRecordProto.VISIBLE;
import static com.android.server.am.ActivityRecordProto.VISIBLE_REQUESTED;
import static com.android.server.am.EventLogTags.AM_RELAUNCH_ACTIVITY;
import static com.android.server.am.EventLogTags.AM_RELAUNCH_ACTIVITY;
import static com.android.server.am.EventLogTags.AM_RELAUNCH_RESUME_ACTIVITY;
import static com.android.server.am.EventLogTags.AM_RELAUNCH_RESUME_ACTIVITY;
import static com.android.server.policy.WindowManagerPolicy.FINISH_LAYOUT_REDO_ANIM;
import static com.android.server.policy.WindowManagerPolicy.FINISH_LAYOUT_REDO_ANIM;
@@ -176,7 +177,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_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;
import static com.android.server.wm.AppWindowTokenProto.LAST_ALL_DRAWN;
import static com.android.server.wm.AppWindowTokenProto.LAST_ALL_DRAWN;
@@ -191,7 +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.VISIBLE_SET_FROM_TRANSFERRED_STARTING_WINDOW;
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,11 +462,12 @@ 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
    private boolean mVisible;        // Should this token's windows be visible?
    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
    // window.
    // window.
    private boolean mHiddenSetFromTransferredStartingWindow;
    private boolean mVisibleSetFromTransferredStartingWindow;
    // TODO: figure out how to consolidate with the same variable in ActivityRecord.
    // 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
    private boolean mDeferHidingClient; // If true we told WM to defer reporting to the client
                                        // process that it is hidden.
                                        // process that it is hidden.
@@ -853,6 +854,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
            pw.println(requestedVrComponent);
            pw.println(requestedVrComponent);
        }
        }
        super.dump(pw, prefix, dumpAll);
        super.dump(pw, prefix, dumpAll);
        pw.print(" visible="); pw.print(mVisible);
        if (appToken != null) {
        if (appToken != null) {
            pw.println(prefix + "app=true mVoiceInteraction=" + mVoiceInteraction);
            pw.println(prefix + "app=true mVoiceInteraction=" + mVoiceInteraction);
        }
        }
@@ -884,13 +886,13 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
            pw.print(" mIsExiting="); pw.println(mIsExiting);
            pw.print(" mIsExiting="); pw.println(mIsExiting);
        }
        }
        if (startingWindow != null || startingSurface != null
        if (startingWindow != null || startingSurface != null
                || startingDisplayed || startingMoved || mHiddenSetFromTransferredStartingWindow) {
                || startingDisplayed || startingMoved || mVisibleSetFromTransferredStartingWindow) {
            pw.print(prefix); pw.print("startingWindow="); pw.print(startingWindow);
            pw.print(prefix); pw.print("startingWindow="); pw.print(startingWindow);
            pw.print(" startingSurface="); pw.print(startingSurface);
            pw.print(" startingSurface="); pw.print(startingSurface);
            pw.print(" startingDisplayed="); pw.print(startingDisplayed);
            pw.print(" startingDisplayed="); pw.print(startingDisplayed);
            pw.print(" startingMoved="); pw.print(startingMoved);
            pw.print(" startingMoved="); pw.print(startingMoved);
            pw.println(" mHiddenSetFromTransferredStartingWindow="
            pw.println(" mHiddenSetFromTransferredStartingWindow="
                    + mHiddenSetFromTransferredStartingWindow);
                    + mVisibleSetFromTransferredStartingWindow);
        }
        }
        if (!mFrozenBounds.isEmpty()) {
        if (!mFrozenBounds.isEmpty()) {
            pw.print(prefix); pw.print("mFrozenBounds="); pw.println(mFrozenBounds);
            pw.print(prefix); pw.print("mFrozenBounds="); pw.println(mFrozenBounds);
@@ -1486,7 +1488,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        }
        }


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


        ColorDisplayService.ColorDisplayServiceInternal cds = LocalServices.getService(
        ColorDisplayService.ColorDisplayServiceInternal cds = LocalServices.getService(
@@ -3212,7 +3214,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
                        "Removing starting %s from %s", tStartingWindow, fromActivity);
                        "Removing starting %s from %s", tStartingWindow, fromActivity);
                fromActivity.removeChild(tStartingWindow);
                fromActivity.removeChild(tStartingWindow);
                fromActivity.postWindowRemoveStartingWindowCleanup(tStartingWindow);
                fromActivity.postWindowRemoveStartingWindowCleanup(tStartingWindow);
                fromActivity.mHiddenSetFromTransferredStartingWindow = false;
                fromActivity.mVisibleSetFromTransferredStartingWindow = false;
                addWindow(tStartingWindow);
                addWindow(tStartingWindow);


                // Propagate other interesting state between the tokens. If the old token is displayed,
                // Propagate other interesting state between the tokens. If the old token is displayed,
@@ -3225,10 +3227,10 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
                if (fromActivity.firstWindowDrawn) {
                if (fromActivity.firstWindowDrawn) {
                    firstWindowDrawn = true;
                    firstWindowDrawn = true;
                }
                }
                if (!fromActivity.isHidden()) {
                if (fromActivity.isVisible()) {
                    setHidden(false);
                    setVisible(true);
                    mVisibleRequested = true;
                    mVisibleRequested = true;
                    mHiddenSetFromTransferredStartingWindow = true;
                    mVisibleSetFromTransferredStartingWindow = true;
                }
                }
                setClientHidden(fromActivity.mClientHidden);
                setClientHidden(fromActivity.mClientHidden);


@@ -3842,7 +3844,14 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
    boolean isVisible() {
    boolean isVisible() {
        // If the activity isn't hidden then it is considered visible and there is no need to check
        // If the activity isn't hidden then it is considered visible and there is no need to check
        // its children windows to see if they are visible.
        // its children windows to see if they are visible.
        return !isHidden();
        return mVisible;
    }

    void setVisible(boolean visible) {
        if (visible != mVisible) {
            mVisible = visible;
            scheduleAnimation();
        }
    }
    }


    void setVisibility(boolean visible) {
    void setVisibility(boolean visible) {
@@ -3884,8 +3893,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 visible=%b mVisibleRequested=%b Callers=%s",
                appToken, visible, appTransition, isHidden(), mVisibleRequested,
                appToken, visible, appTransition, isVisible(), mVisibleRequested,
                Debug.getCallers(6));
                Debug.getCallers(6));


        final DisplayContent displayContent = getDisplayContent();
        final DisplayContent displayContent = getDisplayContent();
@@ -3915,11 +3924,11 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
            startingMoved = false;
            startingMoved = false;
            // If the token is currently hidden (should be the common case), or has been
            // If the token is currently hidden (should be the common case), or has been
            // stopped, then we need to set up to wait for its windows to be ready.
            // stopped, then we need to set up to wait for its windows to be ready.
            if (isHidden() || mAppStopped) {
            if (!isVisible() || mAppStopped) {
                clearAllDrawn();
                clearAllDrawn();


                // If the app was already visible, don't reset the waitingToShow state.
                // If the app was already visible, don't reset the waitingToShow state.
                if (isHidden()) {
                if (!isVisible()) {
                    waitingToShow = true;
                    waitingToShow = true;


                    // If the client isn't hidden, we don't need to reset the drawing state.
                    // If the client isn't hidden, we don't need to reset the drawing state.
@@ -3989,9 +3998,9 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
            boolean visible, int transit, boolean performLayout, boolean isVoiceInteraction) {
            boolean visible, int transit, boolean performLayout, boolean isVoiceInteraction) {


        boolean delayed = false;
        boolean delayed = false;
        // Reset the state of mHiddenSetFromTransferredStartingWindow since visibility is actually
        // Reset the state of mVisibleSetFromTransferredStartingWindow since visibility is actually
        // been set by the app now.
        // been set by the app now.
        mHiddenSetFromTransferredStartingWindow = false;
        mVisibleSetFromTransferredStartingWindow = false;


        // Allow for state changes and animation to be applied if:
        // Allow for state changes and animation to be applied if:
        // * token is transitioning visibility state
        // * token is transitioning visibility state
@@ -4001,7 +4010,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        // * or the token is the opening app and visible while opening task behind existing one.
        // * or the token is the opening app and visible while opening task behind existing one.
        final DisplayContent displayContent = getDisplayContent();
        final DisplayContent displayContent = getDisplayContent();
        boolean visibilityChanged = false;
        boolean visibilityChanged = false;
        if (isHidden() == visible || (isHidden() && mIsExiting)
        if (isVisible() != visible || (!isVisible() && mIsExiting)
                || (visible && waitingForReplacement())
                || (visible && waitingForReplacement())
                || (visible && displayContent.mOpeningApps.contains(this)
                || (visible && displayContent.mOpeningApps.contains(this)
                && displayContent.mAppTransition.getAppTransition() == TRANSIT_TASK_OPEN_BEHIND)) {
                && displayContent.mAppTransition.getAppTransition() == TRANSIT_TASK_OPEN_BEHIND)) {
@@ -4009,7 +4018,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
                    mWmService.mAccessibilityController;
                    mWmService.mAccessibilityController;
            boolean changed = false;
            boolean changed = false;
            ProtoLog.v(WM_DEBUG_APP_TRANSITIONS,
            ProtoLog.v(WM_DEBUG_APP_TRANSITIONS,
                    "Changing app %s hidden=%b performLayout=%b", this, isHidden(),
                    "Changing app %s visible=%b performLayout=%b", this, isVisible(),
                    performLayout);
                    performLayout);


            boolean runningAppAnimation = false;
            boolean runningAppAnimation = false;
@@ -4034,7 +4043,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
                changed |= win.onAppVisibilityChanged(visible, runningAppAnimation);
                changed |= win.onAppVisibilityChanged(visible, runningAppAnimation);
            }
            }


            setHidden(!visible);
            setVisible(visible);
            mVisibleRequested = visible;
            mVisibleRequested = visible;
            visibilityChanged = true;
            visibilityChanged = true;
            if (!visible) {
            if (!visible) {
@@ -4053,8 +4062,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: visible=%b visibleRequested=%b", this,
                    isHidden(), mVisibleRequested);
                    isVisible(), mVisibleRequested);


            if (changed) {
            if (changed) {
                displayContent.getInputMonitor().setUpdateInputWindowsNeededLw();
                displayContent.getInputMonitor().setUpdateInputWindowsNeededLw();
@@ -4118,7 +4127,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
            // no animation but there will still be a transition set.
            // no animation but there will still be a transition set.
            // We still need to delay hiding the surface such that it
            // We still need to delay hiding the surface such that it
            // can be synchronized with showing the next surface in the transition.
            // can be synchronized with showing the next surface in the transition.
            if (isHidden() && !delayed && !displayContent.mAppTransition.isTransitionSet()) {
            if (!isVisible() && !delayed && !displayContent.mAppTransition.isTransitionSet()) {
                SurfaceControl.openTransaction();
                SurfaceControl.openTransaction();
                for (int i = mChildren.size() - 1; i >= 0; i--) {
                for (int i = mChildren.size() - 1; i >= 0; i--) {
                    mChildren.get(i).mWinAnimator.hide("immediately hidden");
                    mChildren.get(i).mWinAnimator.hide("immediately hidden");
@@ -4130,12 +4139,6 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        return delayed;
        return delayed;
    }
    }


    @Override
    void setHidden(boolean hidden) {
        super.setHidden(hidden);
        scheduleAnimation();
    }

    @Override
    @Override
    void onAppTransitionDone() {
    void onAppTransitionDone() {
        sendingToBottom = false;
        sendingToBottom = false;
@@ -4901,8 +4904,8 @@ 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: visible=%b freezing=%b visibleRequested=%b. %s",
                appToken, isHidden(), mFreezingScreen, mVisibleRequested,
                appToken, isVisible(), mFreezingScreen, mVisibleRequested,
                new RuntimeException().fillInStackTrace());
                new RuntimeException().fillInStackTrace());
        if (mVisibleRequested) {
        if (mVisibleRequested) {
            if (!mFreezingScreen) {
            if (!mFreezingScreen) {
@@ -4940,8 +4943,8 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
                return;
                return;
            }
            }
            ProtoLog.v(WM_DEBUG_ORIENTATION,
            ProtoLog.v(WM_DEBUG_ORIENTATION,
                        "Clear freezing of %s: hidden=%b freezing=%b", appToken,
                        "Clear freezing of %s: visible=%b freezing=%b", appToken,
                                isHidden(), isFreezingScreen());
                                isVisible(), isFreezingScreen());
            stopFreezingScreen(true, force);
            stopFreezingScreen(true, force);
        }
        }
    }
    }
@@ -5101,7 +5104,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        boolean nowGone = mReportedVisibilityResults.nowGone;
        boolean nowGone = mReportedVisibilityResults.nowGone;


        boolean nowDrawn = numInteresting > 0 && numDrawn >= numInteresting;
        boolean nowDrawn = numInteresting > 0 && numDrawn >= numInteresting;
        boolean nowVisible = numInteresting > 0 && numVisible >= numInteresting && !isHidden();
        boolean nowVisible = numInteresting > 0 && numVisible >= numInteresting && isVisible();
        if (!nowGone) {
        if (!nowGone) {
            // If the app is not yet gone, then it can only become visible/drawn.
            // If the app is not yet gone, then it can only become visible/drawn.
            if (!nowDrawn) {
            if (!nowDrawn) {
@@ -5462,11 +5465,11 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
            // well there is no point now.
            // well there is no point now.
            ProtoLog.v(WM_DEBUG_STARTING_WINDOW, "Nulling last startingData");
            ProtoLog.v(WM_DEBUG_STARTING_WINDOW, "Nulling last startingData");
            mStartingData = null;
            mStartingData = null;
            if (mHiddenSetFromTransferredStartingWindow) {
            if (mVisibleSetFromTransferredStartingWindow) {
                // We set the hidden state to false for the token from a transferred starting window.
                // We set the visible state to true for the token from a transferred starting
                // We now reset it back to true since the starting window was the last window in the
                // window. We now reset it back to false since the starting window was the last
                // token.
                // window in the token.
                setHidden(true);
                setVisible(false);
            }
            }
        } else if (mChildren.size() == 1 && startingSurface != null && !isRelaunching()) {
        } else if (mChildren.size() == 1 && startingSurface != null && !isRelaunching()) {
            // If this is the last window except for a starting transition window,
            // If this is the last window except for a starting transition window,
@@ -5804,7 +5807,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A


    @Override
    @Override
    void prepareSurfaces() {
    void prepareSurfaces() {
        final boolean show = !isHidden() || isAnimating();
        final boolean show = isVisible() || isAnimating();


        if (mSurfaceControl != null) {
        if (mSurfaceControl != null) {
            if (show && !mLastSurfaceShowing) {
            if (show && !mLastSurfaceShowing) {
@@ -5923,7 +5926,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
                "AppWindowToken");
                "AppWindowToken");


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


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


@@ -7307,12 +7310,13 @@ 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_REQUESTED, 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());
        }
        }
        proto.write(TRANSLUCENT, !occludesParent());
        proto.write(TRANSLUCENT, !occludesParent());
        proto.write(VISIBLE, mVisible);
    }
    }


    public void writeToProto(ProtoOutputStream proto, long fieldId) {
    public void writeToProto(ProtoOutputStream proto, long fieldId) {
@@ -7343,7 +7347,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(com.android.server.wm.AppWindowTokenProto.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);
@@ -7358,11 +7362,12 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        }
        }
        proto.write(STARTING_DISPLAYED, startingDisplayed);
        proto.write(STARTING_DISPLAYED, startingDisplayed);
        proto.write(STARTING_MOVED, startingMoved);
        proto.write(STARTING_MOVED, startingMoved);
        proto.write(HIDDEN_SET_FROM_TRANSFERRED_STARTING_WINDOW,
        proto.write(VISIBLE_SET_FROM_TRANSFERRED_STARTING_WINDOW,
                mHiddenSetFromTransferredStartingWindow);
                mVisibleSetFromTransferredStartingWindow);
        for (Rect bounds : mFrozenBounds) {
        for (Rect bounds : mFrozenBounds) {
            bounds.writeToProto(proto, FROZEN_BOUNDS);
            bounds.writeToProto(proto, FROZEN_BOUNDS);
        }
        }
        proto.write(com.android.server.wm.AppWindowTokenProto.VISIBLE, mVisible);
        proto.end(token);
        proto.end(token);
    }
    }


+4 −3
Original line number Original line Diff line number Diff line
@@ -688,15 +688,16 @@ public class AppTransitionController {
     * compare z-order.
     * compare z-order.
     *
     *
     * @param apps The list of apps to search.
     * @param apps The list of apps to search.
     * @param ignoreHidden If set to true, ignores apps that are {@link ActivityRecord#isHidden}.
     * @param ignoreInvisible If set to true, ignores apps that are not
     *                        {@link ActivityRecord#isVisible}.
     * @return The top {@link ActivityRecord}.
     * @return The top {@link ActivityRecord}.
     */
     */
    private ActivityRecord getTopApp(ArraySet<ActivityRecord> apps, boolean ignoreHidden) {
    private ActivityRecord getTopApp(ArraySet<ActivityRecord> apps, boolean ignoreInvisible) {
        int topPrefixOrderIndex = Integer.MIN_VALUE;
        int topPrefixOrderIndex = Integer.MIN_VALUE;
        ActivityRecord topApp = null;
        ActivityRecord topApp = null;
        for (int i = apps.size() - 1; i >= 0; i--) {
        for (int i = apps.size() - 1; i >= 0; i--) {
            final ActivityRecord app = apps.valueAt(i);
            final ActivityRecord app = apps.valueAt(i);
            if (ignoreHidden && app.isHidden()) {
            if (ignoreInvisible && !app.isVisible()) {
                continue;
                continue;
            }
            }
            final int prefixOrderIndex = app.getPrefixOrderIndex();
            final int prefixOrderIndex = app.getPrefixOrderIndex();
Loading