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

Commit 1f2a9a75 authored by Winson Chung's avatar Winson Chung
Browse files

Set cookie-based pending task listener if possible

- In LaunchIntoOrConvertFromBubble transition, we should add the
  task listener using the launch cookie to prevent races between
  the task organizer receiving the task, and the transition receiving
  the task (and kicking off the bubbles animation)

Bug: 411271022
Flag: com.android.wm.shell.enable_create_any_bubble
Test: Manual, bubble multiple tasks
Change-Id: I1f8cea54b85e38b47c7a590b5eb903af8daf1f12
parent 82e454bf
Loading
Loading
Loading
Loading
+9 −7
Original line number Diff line number Diff line
@@ -554,9 +554,9 @@ public class BubbleTransitions {
            mPlayConvertTaskAnimation = false;
            for (int i = info.getChanges().size() - 1; i >= 0; i--) {
                final TransitionInfo.Change chg = info.getChanges().get(i);
                final boolean isTaskToConvertToBubble = (chg.getTaskInfo() != null)
                final boolean isLaunchedTask = (chg.getTaskInfo() != null)
                        && (chg.getMode() == TRANSIT_CHANGE || isOpeningMode(chg.getMode()));
                if (isTaskToConvertToBubble) {
                if (isLaunchedTask) {
                    mStartBounds.set(chg.getStartAbsBounds());
                    // Converting a task into taskview, so treat as "new"
                    mFinishWct = new WindowContainerTransaction();
@@ -794,6 +794,11 @@ public class BubbleTransitions {
                    }
                }

                // Add the task view task listener manually since we aren't going through
                // TaskViewTransitions (which normally sets up the listener via a pending launch cookie
                mTaskOrganizer.setPendingLaunchCookieListener(mLaunchCookie.binder,
                        mBubble.getTaskView().getController());

                // We use a stub transition here since we don't know what is incoming, but it
                // won't actually match any transition when queried in TaskViewTransitions,
                // which is Ok since we don't want TaskViewTransitions to handle this anyways.
@@ -857,10 +862,10 @@ public class BubbleTransitions {
            mPlayConvertTaskAnimation = false;
            for (int i = info.getChanges().size() - 1; i >= 0; i--) {
                final TransitionInfo.Change chg = info.getChanges().get(i);
                final boolean isTaskToConvertToBubble = (chg.getTaskInfo() != null)
                final boolean isLaunchedTask = (chg.getTaskInfo() != null)
                        && (chg.getMode() == TRANSIT_CHANGE || isOpeningMode(chg.getMode()))
                        && (chg.getTaskInfo().launchCookies.contains(mLaunchCookie.binder));
                if (isTaskToConvertToBubble) {
                if (isLaunchedTask) {
                    mStartBounds.set(chg.getStartAbsBounds());
                    // Converting a task into taskview, so treat as "new"
                    mFinishWct = new WindowContainerTransaction();
@@ -967,9 +972,6 @@ public class BubbleTransitions {
            }
            mTaskViewTransitions.prepareOpenAnimation(tv, true /* new */, startT, mFinishT,
                    (ActivityManager.RunningTaskInfo) mTaskInfo, mTaskLeash, mFinishWct);
            // Add the task view task listener manually since we aren't going through
            // TaskViewTransitions (which normally sets up the listener via a pending launch cookie
            mTaskOrganizer.addListenerForTaskId(tv, mTaskInfo.taskId);

            if (mFinishWct.isEmpty()) {
                mFinishWct = null;