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

Commit d00861c4 authored by Chris Li's avatar Chris Li
Browse files

Collect embedded TaskFragment window changes

To make sure the embedded TaskFragment surface will be updated when
Shell transition is enabled.

Bug: 207070762
Test: testApplyTransaction_collectTaskFragmentBeforeApplyChange
Change-Id: Id726b67cd30bd68e3ca4bc2665ab0a9024d76dab
parent fc9ccbb8
Loading
Loading
Loading
Loading
+0 −6
Original line number Diff line number Diff line
@@ -3193,12 +3193,6 @@
      "group": "WM_DEBUG_LOCKTASK",
      "at": "com\/android\/server\/wm\/LockTaskController.java"
    },
    "956467125": {
      "message": "Reparenting Activity to embedded TaskFragment, but the Activity is not collected",
      "level": "WARN",
      "group": "WM_DEBUG_WINDOW_TRANSITIONS",
      "at": "com\/android\/server\/wm\/WindowOrganizerController.java"
    },
    "958338552": {
      "message": "grantEmbeddedWindowFocus win=%s dropped focus so setting focus to null since no candidate was found",
      "level": "VERBOSE",
+1 −4
Original line number Diff line number Diff line
@@ -3018,10 +3018,7 @@ class ActivityStarter {
                newParent = candidateTf;
            }
        }
        if (newParent.canHaveEmbeddingActivityTransition(mStartActivity)) {
            // Make sure the embedded TaskFragment is included in the start activity transition.
            newParent.collectEmbeddedTaskFragmentIfNeeded();
        }
        newParent.mTransitionController.collect(newParent);
        if (mStartActivity.getTaskFragment() == null
                || mStartActivity.getTaskFragment() == newParent) {
            newParent.addChild(mStartActivity, POSITION_TOP);
+25 −28
Original line number Diff line number Diff line
@@ -2280,19 +2280,33 @@ class TaskFragment extends WindowContainer<WindowContainer> {

        super.onConfigurationChanged(newParentConfig);

        if (shouldStartChangeTransition(mTmpPrevBounds)) {
        final boolean shouldStartChangeTransition = shouldStartChangeTransition(mTmpPrevBounds);
        if (shouldStartChangeTransition) {
            initializeChangeTransition(mTmpPrevBounds);
        } else if (mTaskFragmentOrganizer != null) {
        }
        if (mTaskFragmentOrganizer != null) {
            if (mTransitionController.isShellTransitionsEnabled()
                    && !mTransitionController.isCollecting(this)) {
                // TaskFragmentOrganizer doesn't have access to the surface for security reasons, so
                // update the surface here if it is not collected by Shell transition.
                updateOrganizedTaskFragmentSurface();
            } else if (!mTransitionController.isShellTransitionsEnabled()
                    && !shouldStartChangeTransition) {
                // Update the surface here instead of in the organizer so that we can make sure
            // it can be synced with the surface freezer.
            final SurfaceControl.Transaction t = getSyncTransaction();
            updateSurfacePosition(t);
            updateOrganizedTaskFragmentSurfaceSize(t, false /* forceUpdate */);
                // it can be synced with the surface freezer for legacy app transition.
                updateOrganizedTaskFragmentSurface();
            }
        }

        sendTaskFragmentInfoChanged();
    }

    private void updateOrganizedTaskFragmentSurface() {
        final SurfaceControl.Transaction t = getSyncTransaction();
        updateSurfacePosition(t);
        updateOrganizedTaskFragmentSurfaceSize(t, false /* forceUpdate */);
    }

    /** Updates the surface size so that the sub windows cannot be shown out of bounds. */
    private void updateOrganizedTaskFragmentSurfaceSize(SurfaceControl.Transaction t,
            boolean forceUpdate) {
@@ -2347,33 +2361,16 @@ class TaskFragment extends WindowContainer<WindowContainer> {
                || endBounds.height() != startBounds.height();
    }

    boolean canHaveEmbeddingActivityTransition(@NonNull ActivityRecord child) {
        if (!isOrganizedTaskFragment() || !mTransitionController.isShellTransitionsEnabled()) {
            return false;
        }
        // The activity should request open transition when it is becoming visible.
        return child.isVisibleRequested();
    }

    void collectEmbeddedTaskFragmentIfNeeded() {
        if (!isOrganizedTaskFragment() || mTransitionController.isCollecting(this)) {
            return;
        }
        if (getChildCount() == 0) {
            // The TaskFragment is new created, and just becoming non-empty.
            mTransitionController.collectExistenceChange(this);
        } else {
            mTransitionController.collect(this);
        }
    @Override
    boolean isSyncFinished() {
        return super.isSyncFinished() && isReadyToTransit();
    }

    @Override
    void setSurfaceControl(SurfaceControl sc) {
        super.setSurfaceControl(sc);
        if (mTaskFragmentOrganizer != null) {
            final SurfaceControl.Transaction t = getSyncTransaction();
            updateSurfacePosition(t);
            updateOrganizedTaskFragmentSurfaceSize(t, false /* forceUpdate */);
            updateOrganizedTaskFragmentSurface();
            // If the TaskFragmentOrganizer was set before we created the SurfaceControl, we need to
            // emit the callbacks now.
            sendTaskFragmentAppeared();
+8 −0
Original line number Diff line number Diff line
@@ -226,6 +226,14 @@ class TransitionController {
        return mCollectingTransition != null;
    }

    /**
     * @return the collecting transition. {@code null} if there is no collecting transition.
     */
    @Nullable
    Transition getCollectingTransition() {
        return mCollectingTransition;
    }

    /**
     * @return the collecting transition sync Id. This should only be called when there is a
     * collecting transition.
+0 −1
Original line number Diff line number Diff line
@@ -2827,7 +2827,6 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer<
    void initializeChangeTransition(Rect startBounds, @Nullable SurfaceControl freezeTarget) {
        if (mDisplayContent.mTransitionController.isShellTransitionsEnabled()) {
            mDisplayContent.mTransitionController.collectVisibleChange(this);
            // TODO(b/207070762): request shell transition for activityEmbedding change.
            return;
        }
        mDisplayContent.prepareAppTransition(TRANSIT_CHANGE);
Loading