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

Commit 175ef1cf authored by Riddle Hsu's avatar Riddle Hsu Committed by Automerger Merge Worker
Browse files

Merge "Simplify the association of shared starting window" into tm-qpr-dev am: bf4367fd

parents 84ade52c bf4367fd
Loading
Loading
Loading
Loading
+28 −43
Original line number Diff line number Diff line
@@ -812,7 +812,6 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
    StartingData mStartingData;
    WindowState mStartingWindow;
    StartingSurfaceController.StartingSurface mStartingSurface;
    boolean startingDisplayed;
    boolean startingMoved;

    /** The last set {@link DropInputMode} for this activity surface. */
@@ -821,13 +820,6 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
    /** Whether the input to this activity will be dropped during the current playing animation. */
    private boolean mIsInputDroppedForAnimation;

    /**
     * If it is non-null, it requires all activities who have the same starting data to be drawn
     * to remove the starting window.
     * TODO(b/189385912): Remove starting window related fields after migrating them to task.
     */
    private StartingData mSharedStartingData;

    boolean mHandleExitSplashScreen;
    @TransferSplashScreenState
    int mTransferringSplashScreenState = TRANSFER_SPLASH_SCREEN_IDLE;
@@ -1200,14 +1192,11 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
            pw.print(" firstWindowDrawn="); pw.print(firstWindowDrawn);
            pw.print(" mIsExiting="); pw.println(mIsExiting);
        }
        if (mSharedStartingData != null) {
            pw.println(prefix + "mSharedStartingData=" + mSharedStartingData);
        }
        if (mStartingWindow != null || mStartingSurface != null
                || startingDisplayed || startingMoved || mVisibleSetFromTransferredStartingWindow) {
        if (mStartingWindow != null || mStartingData != null || mStartingSurface != null
                || startingMoved || mVisibleSetFromTransferredStartingWindow) {
            pw.print(prefix); pw.print("startingWindow="); pw.print(mStartingWindow);
            pw.print(" startingSurface="); pw.print(mStartingSurface);
            pw.print(" startingDisplayed="); pw.print(startingDisplayed);
            pw.print(" startingDisplayed="); pw.print(isStartingWindowDisplayed());
            pw.print(" startingMoved="); pw.print(startingMoved);
            pw.println(" mVisibleSetFromTransferredStartingWindow="
                    + mVisibleSetFromTransferredStartingWindow);
@@ -2690,13 +2679,23 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        }
    }

    boolean isStartingWindowDisplayed() {
        final StartingData data = mStartingData != null ? mStartingData : task != null
                ? task.mSharedStartingData : null;
        return data != null && data.mIsDisplayed;
    }

    /** Called when the starting window is added to this activity. */
    void attachStartingWindow(@NonNull WindowState startingWindow) {
        startingWindow.mStartingData = mStartingData;
        mStartingWindow = startingWindow;
        if (mStartingData != null) {
            if (mStartingData.mAssociatedTask != null) {
                // The snapshot type may have called associateStartingDataWithTask().
        if (mStartingData != null && mStartingData.mAssociatedTask != null) {
                attachStartingSurfaceToAssociatedTask();
            } else if (isEmbedded()) {
                associateStartingWindowWithTaskIfNeeded();
            }
        }
    }

@@ -2711,11 +2710,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
    /** Called when the starting window is not added yet but its data is known to fill the task. */
    private void associateStartingDataWithTask() {
        mStartingData.mAssociatedTask = task;
        task.forAllActivities(r -> {
            if (r.mVisibleRequested && !r.firstWindowDrawn) {
                r.mSharedStartingData = mStartingData;
            }
        });
        task.mSharedStartingData = mStartingData;
    }

    /** Associates and attaches an added starting window to the current task. */
@@ -2746,10 +2741,8 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A

    void removeStartingWindowAnimation(boolean prepareAnimation) {
        mTransferringSplashScreenState = TRANSFER_SPLASH_SCREEN_IDLE;
        if (mSharedStartingData != null) {
            mSharedStartingData.mAssociatedTask.forAllActivities(r -> {
                r.mSharedStartingData = null;
            });
        if (task != null) {
            task.mSharedStartingData = null;
        }
        if (mStartingWindow == null) {
            if (mStartingData != null) {
@@ -2772,7 +2765,6 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
            mStartingData = null;
            mStartingSurface = null;
            mStartingWindow = null;
            startingDisplayed = false;
            if (surface == null) {
                ProtoLog.v(WM_DEBUG_STARTING_WINDOW, "startingWindow was set but "
                        + "startingSurface==null, couldn't remove");
@@ -4257,7 +4249,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
     * @return {@code true} if starting window is in app's hierarchy.
     */
    boolean hasStartingWindow() {
        if (startingDisplayed || mStartingData != null) {
        if (mStartingData != null) {
            return true;
        }
        for (int i = mChildren.size() - 1; i >= 0; i--) {
@@ -4355,10 +4347,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A

                // Transfer the starting window over to the new token.
                mStartingData = fromActivity.mStartingData;
                mSharedStartingData = fromActivity.mSharedStartingData;
                mStartingSurface = fromActivity.mStartingSurface;
                startingDisplayed = fromActivity.startingDisplayed;
                fromActivity.startingDisplayed = false;
                mStartingWindow = tStartingWindow;
                reportedVisible = fromActivity.reportedVisible;
                fromActivity.mStartingData = null;
@@ -4424,7 +4413,6 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
            ProtoLog.v(WM_DEBUG_STARTING_WINDOW,
                    "Moving pending starting from %s to %s", fromActivity, this);
            mStartingData = fromActivity.mStartingData;
            mSharedStartingData = fromActivity.mSharedStartingData;
            fromActivity.mStartingData = null;
            fromActivity.startingMoved = true;
            scheduleAddStartingWindow();
@@ -6534,14 +6522,11 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        // Remove starting window directly if is in a pure task. Otherwise if it is associated with
        // a task (e.g. nested task fragment), then remove only if all visible windows in the task
        // are drawn.
        final Task associatedTask =
                mSharedStartingData != null ? mSharedStartingData.mAssociatedTask : null;
        final Task associatedTask = task.mSharedStartingData != null ? task : null;
        if (associatedTask == null) {
            removeStartingWindow();
        } else if (associatedTask.getActivity(r -> r.mVisibleRequested && !r.firstWindowDrawn
                // Don't block starting window removal if an Activity can't be a starting window
                // target.
                && r.mSharedStartingData != null) == null) {
        } else if (associatedTask.getActivity(
                r -> r.mVisibleRequested && !r.firstWindowDrawn) == null) {
            // The last drawn activity may not be the one that owns the starting window.
            final ActivityRecord r = associatedTask.topActivityContainsStartingWindow();
            if (r != null) {
@@ -6756,7 +6741,6 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        if (mLastTransactionSequence != mWmService.mTransactionSequence) {
            mLastTransactionSequence = mWmService.mTransactionSequence;
            mNumDrawnWindows = 0;
            startingDisplayed = false;

            // There is the main base application window, even if it is exiting, wait for it
            mNumInterestingWindows = findMainWindow(false /* includeStartingApp */) != null ? 1 : 0;
@@ -6800,9 +6784,9 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
                        isInterestingAndDrawn = true;
                    }
                }
            } else if (w.isDrawn()) {
            } else if (mStartingData != null && w.isDrawn()) {
                // The starting window for this container is drawn.
                startingDisplayed = true;
                mStartingData.mIsDisplayed = true;
            }
        }

@@ -7550,7 +7534,8 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A

        ProtoLog.v(WM_DEBUG_ANIM, "Animation done in %s"
                + ": reportedVisible=%b okToDisplay=%b okToAnimate=%b startingDisplayed=%b",
                this, reportedVisible, okToDisplay(), okToAnimate(), startingDisplayed);
                this, reportedVisible, okToDisplay(), okToAnimate(),
                isStartingWindowDisplayed());

        // clean up thumbnail window
        if (mThumbnail != null) {
@@ -9649,7 +9634,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        if (mStartingWindow != null) {
            mStartingWindow.writeIdentifierToProto(proto, STARTING_WINDOW);
        }
        proto.write(STARTING_DISPLAYED, startingDisplayed);
        proto.write(STARTING_DISPLAYED, isStartingWindowDisplayed());
        proto.write(STARTING_MOVED, startingMoved);
        proto.write(VISIBLE_SET_FROM_TRANSFERRED_STARTING_WINDOW,
                mVisibleSetFromTransferredStartingWindow);
+2 −2
Original line number Diff line number Diff line
@@ -1229,11 +1229,11 @@ public class AppTransitionController {
            ProtoLog.v(WM_DEBUG_APP_TRANSITIONS,
                    "Check opening app=%s: allDrawn=%b startingDisplayed=%b "
                            + "startingMoved=%b isRelaunching()=%b startingWindow=%s",
                    activity, activity.allDrawn, activity.startingDisplayed,
                    activity, activity.allDrawn, activity.isStartingWindowDisplayed(),
                    activity.startingMoved, activity.isRelaunching(),
                    activity.mStartingWindow);
            final boolean allDrawn = activity.allDrawn && !activity.isRelaunching();
            if (!allDrawn && !activity.startingDisplayed && !activity.startingMoved) {
            if (!allDrawn && !activity.isStartingWindowDisplayed() && !activity.startingMoved) {
                return false;
            }
            if (allDrawn) {
+3 −0
Original line number Diff line number Diff line
@@ -38,6 +38,9 @@ public abstract class StartingData {
     */
    Task mAssociatedTask;

    /** Whether the starting window is drawn. */
    boolean mIsDisplayed;

    protected StartingData(WindowManagerService service, int typeParams) {
        mService = service;
        mTypeParams = typeParams;
+10 −0
Original line number Diff line number Diff line
@@ -358,6 +358,13 @@ class Task extends TaskFragment {

    int mLockTaskUid = -1;  // The uid of the application that called startLockTask().

    /**
     * If non-null, the starting window should cover the associated task. It is assigned when the
     * parent activity of starting window is put in a partial area of the task. This field will be
     * cleared when all visible activities in this task are drawn.
     */
    StartingData mSharedStartingData;

    /** The process that had previously hosted the root activity of this task.
     * Used to know that we should try harder to keep this process around, in case the
     * user wants to return to it. */
@@ -3689,6 +3696,9 @@ class Task extends TaskFragment {
        if (mRootProcess != null) {
            pw.print(prefix); pw.print("mRootProcess="); pw.println(mRootProcess);
        }
        if (mSharedStartingData != null) {
            pw.println(prefix + "mSharedStartingData=" + mSharedStartingData);
        }
        pw.print(prefix); pw.print("taskId=" + mTaskId);
        pw.println(" rootTaskId=" + getRootTaskId());
        pw.print(prefix); pw.println("hasChildPipActivity=" + (mChildPipActivity != null));
+4 −4
Original line number Diff line number Diff line
@@ -1890,10 +1890,10 @@ class TaskFragment extends WindowContainer<WindowContainer> {
    RemoteAnimationTarget createRemoteAnimationTarget(
            RemoteAnimationController.RemoteAnimationRecord record) {
        final ActivityRecord activity = record.getMode() == RemoteAnimationTarget.MODE_OPENING
                // There may be a trampoline activity without window on top of the existing task
                // which is moving to front. Exclude the finishing activity so the window of next
                // activity can be chosen to create the animation target.
                ? getTopNonFinishingActivity()
                // There may be a launching (e.g. trampoline or embedded) activity without a window
                // on top of the existing task which is moving to front. Exclude finishing activity
                // so the window of next activity can be chosen to create the animation target.
                ? getActivity(r -> !r.finishing && r.hasChild())
                : getTopMostActivity();
        return activity != null ? activity.createRemoteAnimationTarget(record) : null;
    }
Loading