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

Commit 7a8889a8 authored by Wale Ogunwale's avatar Wale Ogunwale
Browse files

Remove Task#numFullscreen & ActivityRecord#sendingToBottom/remove (70/n)

- Task#numberFullscreen was only used in one location where we
needed to figure-out if the task has occluding activities.
Just use the hierarchy to figure that out vs. keeping track of
a variable that adds confusion.
- ActivityRecord#sendingToBottom was used to prevent focus and
orientation changes from activity moved to the bottom, however
since we are traversing the hierarchy from top-to-bottom we
should process activities on-top first vs the onces that have
already moved to the bottom.
- ActivityRecord#remove is no longer needed as the object won't
be connected to the hierarchy when it is removed.

Test: They pass!
Bug: 80414790
Bug: 35699615
Change-Id: I23f6501a65bf745dc0fb819c30543cd21241fa91
parent 18325cf2
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -244,7 +244,8 @@ message AppWindowTokenProto {
    optional int32 num_drawn_windows = 15;
    optional bool all_drawn = 16;
    optional bool last_all_drawn = 17;
    optional bool removed = 18;
    // Will be removed soon
    optional bool removed = 18 [deprecated=true];
    optional IdentifierProto starting_window = 19;
    optional bool starting_displayed = 20;
    optional bool starting_moved = 21;
+6 −12
Original line number Diff line number Diff line
@@ -169,12 +169,6 @@
      "group": "WM_DEBUG_RESIZE",
      "at": "com\/android\/server\/wm\/WindowState.java"
    },
    "-1797409732": {
      "message": "Skipping %s because %s",
      "level": "VERBOSE",
      "group": "WM_DEBUG_FOCUS",
      "at": "com\/android\/server\/wm\/DisplayContent.java"
    },
    "-1782453012": {
      "message": "Checking theme of starting window: 0x%x",
      "level": "VERBOSE",
@@ -1453,12 +1447,6 @@
      "group": "WM_DEBUG_RECENTS_ANIMATIONS",
      "at": "com\/android\/server\/wm\/RecentsAnimation.java"
    },
    "789829331": {
      "message": "Aborted starting %s: removed=%b startingData=%s",
      "level": "VERBOSE",
      "group": "WM_DEBUG_STARTING_WINDOW",
      "at": "com\/android\/server\/wm\/ActivityRecord.java"
    },
    "791468751": {
      "message": "Pausing rotation during re-position",
      "level": "DEBUG",
@@ -1927,6 +1915,12 @@
      "group": "WM_ERROR",
      "at": "com\/android\/server\/wm\/WindowManagerService.java"
    },
    "1822843721": {
      "message": "Aborted starting %s: startingData=%s",
      "level": "VERBOSE",
      "group": "WM_DEBUG_STARTING_WINDOW",
      "at": "com\/android\/server\/wm\/ActivityRecord.java"
    },
    "1831008694": {
      "message": "Loading animation for app transition. transit=%s enter=%b frame=%s insets=%s surfaceInsets=%s",
      "level": "DEBUG",
+11 −29
Original line number Diff line number Diff line
@@ -185,7 +185,6 @@ import static com.android.server.wm.AppWindowTokenProto.LAST_SURFACE_SHOWING;
import static com.android.server.wm.AppWindowTokenProto.NAME;
import static com.android.server.wm.AppWindowTokenProto.NUM_DRAWN_WINDOWS;
import static com.android.server.wm.AppWindowTokenProto.NUM_INTERESTING_WINDOWS;
import static com.android.server.wm.AppWindowTokenProto.REMOVED;
import static com.android.server.wm.AppWindowTokenProto.REPORTED_DRAWN;
import static com.android.server.wm.AppWindowTokenProto.REPORTED_VISIBLE;
import static com.android.server.wm.AppWindowTokenProto.STARTING_DISPLAYED;
@@ -631,9 +630,6 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
    // Last visibility state we reported to the app token.
    boolean reportedVisible;

    // Set to true when the token has been removed from the window mgr.
    boolean removed;

    boolean mDisablePreviewScreenshots;

    // Information about an application starting window if displayed.
@@ -878,9 +874,8 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
            pw.print(" lastAllDrawn="); pw.print(mLastAllDrawn);
            pw.println(")");
        }
        if (mStartingData != null || removed || firstWindowDrawn || mIsExiting) {
        if (mStartingData != null || firstWindowDrawn || mIsExiting) {
            pw.print(prefix); pw.print("startingData="); pw.print(mStartingData);
            pw.print(" removed="); pw.print(removed);
            pw.print(" firstWindowDrawn="); pw.print(firstWindowDrawn);
            pw.print(" mIsExiting="); pw.println(mIsExiting);
        }
@@ -1750,12 +1745,10 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
            if (surface != null) {
                boolean abort = false;
                synchronized (mWmService.mGlobalLock) {
                    // If the window was successfully added, then
                    // we need to remove it.
                    if (removed || mStartingData == null) {
                        ProtoLog.v(WM_DEBUG_STARTING_WINDOW,
                                "Aborted starting %s: removed=%b startingData=%s",
                                ActivityRecord.this, removed, mStartingData);
                    // If the window was successfully added, then we need to remove it.
                    if (mStartingData == null) {
                        ProtoLog.v(WM_DEBUG_STARTING_WINDOW, "Aborted starting %s: startingData=%s",
                                ActivityRecord.this, mStartingData);

                        startingWindow = null;
                        mStartingData = null;
@@ -2010,13 +2003,9 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        setMainWindowOpaque(occludesParent);
        mWmService.mWindowPlacerLocked.requestTraversal();

        if (changed && task != null) {
            if (!occludesParent) {
        if (changed && task != null && !occludesParent) {
            getActivityStack().convertActivityToTranslucent(this);
        }
            // Keep track of the number of fullscreen activities in this task.
            task.numFullscreen += occludesParent ? +1 : -1;
        }
        // Always ensure visibility if this activity doesn't occlude parent, so the
        // {@link #returningOptions} of the activity under this one can be applied in
        // {@link #handleAlreadyVisible()}.
@@ -3040,7 +3029,6 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
            removeIfPossible();
        }

        removed = true;
        stopFreezingScreen(true, true);

        final DisplayContent dc = getDisplayContent();
@@ -4134,11 +4122,6 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        scheduleAnimation();
    }

    @Override
    void onAppTransitionDone() {
        sendingToBottom = false;
    }

    /**
     * See {@link Activity#setDisablePreviewScreenshots}.
     */
@@ -6090,10 +6073,10 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
            return mOrientation;
        }

        // The {@link ActivityRecord} should only specify an orientation when it is not closing or
        // going to the bottom. Allowing closing {@link ActivityRecord} to participate can lead to
        // an Activity in another task being started in the wrong orientation during the transition.
        if (!(sendingToBottom || getDisplayContent().mClosingApps.contains(this))
        // The {@link ActivityRecord} should only specify an orientation when it is not closing.
        // Allowing closing {@link ActivityRecord} to participate can lead to an Activity in another
        // task being started in the wrong orientation during the transition.
        if (!getDisplayContent().mClosingApps.contains(this)
                && (isVisible() || getDisplayContent().mOpeningApps.contains(this))) {
            return mOrientation;
        }
@@ -7348,7 +7331,6 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        proto.write(NUM_DRAWN_WINDOWS, mNumDrawnWindows);
        proto.write(ALL_DRAWN, allDrawn);
        proto.write(LAST_ALL_DRAWN, mLastAllDrawn);
        proto.write(REMOVED, removed);
        if (startingWindow != null) {
            startingWindow.writeIdentifierToProto(proto, STARTING_WINDOW);
        }
+7 −20
Original line number Diff line number Diff line
@@ -2896,7 +2896,7 @@ class ActivityStack extends WindowContainer<Task> implements BoundsAnimationTarg
        Task task = null;
        if (!newTask) {
            // If starting in an existing task, find where that is...
            boolean startIt = true;
            boolean isOccluded = false;
            for (int taskNdx = getChildCount() - 1; taskNdx >= 0; --taskNdx) {
                task = getChildAt(taskNdx);
                if (task.getTopNonFinishingActivity() == null) {
@@ -2904,10 +2904,10 @@ class ActivityStack extends WindowContainer<Task> implements BoundsAnimationTarg
                    continue;
                }
                if (task == rTask) {
                    // Here it is!  Now, if this is not yet visible to the
                    // user, then just add it without starting; it will
                    // get started when the user navigates back to it.
                    if (!startIt) {
                    // Here it is!  Now, if this is not yet visible (occluded by another task) to
                    // the user, then just add it without starting; it will get started when the
                    // user navigates back to it.
                    if (isOccluded) {
                        if (DEBUG_ADD_REMOVE) Slog.i(TAG, "Adding activity " + r + " to task "
                                + task, new RuntimeException("here").fillInStackTrace());
                        rTask.positionChildAtTop(r);
@@ -2915,8 +2915,8 @@ class ActivityStack extends WindowContainer<Task> implements BoundsAnimationTarg
                        return;
                    }
                    break;
                } else if (task.numFullscreen > 0) {
                    startIt = false;
                } else if (!isOccluded) {
                    isOccluded = task.forAllActivities(ActivityRecord::occludesParent);
                }
            }
        }
@@ -4670,9 +4670,6 @@ class ActivityStack extends WindowContainer<Task> implements BoundsAnimationTarg
        }
        positionChildAt(position, task, includingParents);
        task.updateTaskMovement(toTop);
        if (getDisplayContent().mAppTransition.isTransitionSet()) {
            task.setSendingToBottom(!toTop);
        }
        getDisplayContent().layoutAndAssignWindowLayersIfNeeded();


@@ -5214,9 +5211,6 @@ class ActivityStack extends WindowContainer<Task> implements BoundsAnimationTarg
        child.updateTaskMovement(true);

        final DisplayContent displayContent = getDisplayContent();
        if (displayContent.mAppTransition.isTransitionSet()) {
            child.setSendingToBottom(false);
        }
        displayContent.layoutAndAssignWindowLayersIfNeeded();
    }

@@ -5238,10 +5232,6 @@ class ActivityStack extends WindowContainer<Task> implements BoundsAnimationTarg
        }

        positionChildAt(POSITION_BOTTOM, child, includingParents);

        if (getDisplayContent().mAppTransition.isTransitionSet()) {
            child.setSendingToBottom(true);
        }
        getDisplayContent().layoutAndAssignWindowLayersIfNeeded();
    }

@@ -5284,9 +5274,6 @@ class ActivityStack extends WindowContainer<Task> implements BoundsAnimationTarg
        task.updateTaskMovement(isTop);
        if (isTop) {
            final DisplayContent displayContent = getDisplayContent();
            if (displayContent.mAppTransition.isTransitionSet()) {
                task.setSendingToBottom(false);
            }
            displayContent.layoutAndAssignWindowLayersIfNeeded();
        }
    }
+0 −7
Original line number Diff line number Diff line
@@ -601,13 +601,6 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo

        final ActivityRecord activity = w.mActivityRecord;

        // If this window's application has been removed, just skip it.
        if (activity!= null && (activity.removed || activity.sendingToBottom)) {
            ProtoLog.v(WM_DEBUG_FOCUS, "Skipping %s because %s", activity,
                    (activity.removed ? "removed" : "sendingToBottom"));
            return false;
        }

        if (focusedApp == null) {
            ProtoLog.v(WM_DEBUG_FOCUS_LIGHT,
                    "findFocusedWindow: focusedApp=null using new focus @ %s", w);
Loading