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

Commit 0dfebbe4 authored by Chris Li's avatar Chris Li
Browse files

Fix open ActivityEmbedding split with Shell transition

1. Collect the TaskFragment when reparenting an activity into it.
2. Check adjacent TaskFragment for transition flag FLAG_TRANSLUCENT.
3. Offset the relative position for default animation.

Bug: 207070762
Test: pass existing
Change-Id: I62b533dbb087007e3ef126170691a59929eb75e1
parent bbb51619
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -3139,6 +3139,12 @@
      "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",
+5 −5
Original line number Diff line number Diff line
@@ -483,11 +483,11 @@ public class DefaultTransitionHandler implements Transitions.TransitionHandler {
                    postStartTransactionCallbacks.add(t ->
                            startSurfaceAnimation(animations, a, change.getLeash(), onAnimFinish,
                                    mTransactionPool, mMainExecutor, mAnimExecutor,
                                    null /* position */, cornerRadius, clipRect));
                                    change.getEndRelOffset(), cornerRadius, clipRect));
                } else {
                    startSurfaceAnimation(animations, a, change.getLeash(), onAnimFinish,
                            mTransactionPool, mMainExecutor, mAnimExecutor, null /* position */,
                            cornerRadius, clipRect);
                            mTransactionPool, mMainExecutor, mAnimExecutor,
                            change.getEndRelOffset(), cornerRadius, clipRect);
                }

                if (info.getAnimationOptions() != null) {
@@ -934,7 +934,7 @@ public class DefaultTransitionHandler implements Transitions.TransitionHandler {
        a.restrictDuration(MAX_ANIMATION_DURATION);
        a.scaleCurrentDuration(mTransitionAnimationScaleSetting);
        startSurfaceAnimation(animations, a, wt.getSurface(), finisher, mTransactionPool,
                mMainExecutor, mAnimExecutor, new Point(bounds.left, bounds.top),
                mMainExecutor, mAnimExecutor, change.getEndRelOffset(),
                cornerRadius, change.getEndAbsBounds());
    }

@@ -959,7 +959,7 @@ public class DefaultTransitionHandler implements Transitions.TransitionHandler {
        a.restrictDuration(MAX_ANIMATION_DURATION);
        a.scaleCurrentDuration(mTransitionAnimationScaleSetting);
        startSurfaceAnimation(animations, a, wt.getSurface(), finisher, mTransactionPool,
                mMainExecutor, mAnimExecutor, null /* position */,
                mMainExecutor, mAnimExecutor, change.getEndRelOffset(),
                cornerRadius, change.getEndAbsBounds());
    }

+4 −0
Original line number Diff line number Diff line
@@ -2973,6 +2973,10 @@ class ActivityStarter {
                newParent = candidateTf;
            }
        }
        if (newParent.canHaveEmbeddingActivityTransition(mStartActivity)) {
            // Make sure the embedded TaskFragment is included in the start activity transition.
            newParent.collectEmbeddedTaskFragmentIfNeeded();
        }
        if (mStartActivity.getTaskFragment() == null
                || mStartActivity.getTaskFragment() == newParent) {
            newParent.addChild(mStartActivity, POSITION_TOP);
+20 −0
Original line number Diff line number Diff line
@@ -2316,6 +2316,26 @@ class TaskFragment extends WindowContainer<WindowContainer> {
        return !startBounds.equals(getBounds());
    }

    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
    void setSurfaceControl(SurfaceControl sc) {
        super.setSurfaceControl(sc);
+21 −8
Original line number Diff line number Diff line
@@ -1149,6 +1149,26 @@ class Transition extends Binder implements BLASTSyncEngine.TransactionReadyListe
        return false;
    }

    private static boolean isTranslucent(@NonNull WindowContainer wc) {
        final TaskFragment taskFragment = wc.asTaskFragment();
        if (taskFragment != null) {
            if (taskFragment.isTranslucent(null /* starting */)) {
                return true;
            }
            final TaskFragment adjacentTaskFragment = taskFragment.getAdjacentTaskFragment();
            if (adjacentTaskFragment != null) {
                // Treat the TaskFragment as translucent if its adjacent TF is, otherwise everything
                // behind two adjacent TaskFragments are occluded.
                return adjacentTaskFragment.isTranslucent(null /* starting */);
            }
        }
        // TODO(b/172695805): hierarchical check. This is non-trivial because for containers
        //                    it is effected by child visibility but needs to work even
        //                    before visibility is committed. This means refactoring some
        //                    checks to use requested visibility.
        return !wc.fillsParent();
    }

    /**
     * Under some conditions (eg. all visible targets within a parent container are transitioning
     * the same way) the transition can be "promoted" to the parent container. This means an
@@ -1701,20 +1721,13 @@ class Transition extends Binder implements BLASTSyncEngine.TransactionReadyListe
            if (mShowWallpaper || wc.showWallpaper()) {
                flags |= FLAG_SHOW_WALLPAPER;
            }
            if (!wc.fillsParent()) {
                // TODO(b/172695805): hierarchical check. This is non-trivial because for containers
                //                    it is effected by child visibility but needs to work even
                //                    before visibility is committed. This means refactoring some
                //                    checks to use requested visibility.
            if (isTranslucent(wc)) {
                flags |= FLAG_TRANSLUCENT;
            }
            final Task task = wc.asTask();
            if (task != null && task.voiceSession != null) {
                flags |= FLAG_IS_VOICE_INTERACTION;
            }
            if (task != null && task.isTranslucent(null)) {
                flags |= FLAG_TRANSLUCENT;
            }
            final ActivityRecord record = wc.asActivityRecord();
            if (record != null) {
                if (record.mUseTransferredAnimation) {
Loading