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

Commit 04bceb99 authored by lumark's avatar lumark Committed by Ming-Shin Lu
Browse files

Trigger onTaskAppeared when a task started from recents becomes ready.

In quick switch flows, launcher will first swipe task snapshot
through recents animation, and then start new task with custom animation
options through startActivityFromRecents after gesture finish detected,
and then finish recents animation finally.

But that way user may experience flickering before the new task launch
and recents animation finish.

To improve quick switch flickering, we ignore the new task's custom
animation from recents and generate task remote animation target,
and then trigger a callback for launcher to control/animate this
task surface, more like a part of RecentsAnimation,

Also, adding removeTask method for launcher can flexibility remove the
new task animation target once no need to animate, so that launcher
can decide when to finish recents animation.

Bug: 152480470
Test: manual as below steps:
  1) Doing quick switch task.
  2) Make sure launcher can receive onTaskAppeared callback.
  3) Make sure launcher calls removeTask successfully.
  4) Make sure launcher can finish recents animation after 3).
Change-Id: I0692a280a49719229fa8871509bad37a1343a00f
parent edb826c2
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -192,6 +192,11 @@ public class RecentsAnimationPerfTest extends WindowManagerPerfTestBase {
                Assume.assumeNoException(
                        new AssertionError("onAnimationCanceled should not be called"));
            }

            @Override
            public void onTaskAppeared(RemoteAnimationTarget app) throws RemoteException {
                /* no-op */
            }
        };

        recentsSemaphore.tryAcquire();
+12 −0
Original line number Diff line number Diff line
@@ -114,4 +114,16 @@ interface IRecentsAnimationController {
     * animation is cancelled through fail safe mechanism.
     */
    void setWillFinishToHome(boolean willFinishToHome);

    /**
     * Stops controlling a task that is currently controlled by this recents animation.
     *
     * This method should be called when a task that has been received via {@link #onAnimationStart}
     * or {@link #onTaskAppeared} is no longer needed.  After calling this method, the task will
     * either disappear from the screen, or jump to its final position in case it was the top task.
     *
     * @param taskId Id of the Task target to remove
     * @return {@code true} when target removed successfully, {@code false} otherwise.
     */
    boolean removeTask(int taskId);
}
+6 −0
Original line number Diff line number Diff line
@@ -56,4 +56,10 @@ oneway interface IRecentsAnimationRunner {
    void onAnimationStart(in IRecentsAnimationController controller,
            in RemoteAnimationTarget[] apps, in RemoteAnimationTarget[] wallpapers,
            in Rect homeContentInsets, in Rect minimizedHomeBounds) = 2;

    /**
     * Called when the task of an activity that has been started while the recents animation
     * was running becomes ready for control.
     */
    void onTaskAppeared(in RemoteAnimationTarget app) = 3;
}
+18 −0
Original line number Diff line number Diff line
@@ -883,6 +883,12 @@
      "group": "WM_DEBUG_ORIENTATION",
      "at": "com\/android\/server\/wm\/ActivityRecord.java"
    },
    "-242787066": {
      "message": "addTaskToRecentsAnimationIfNeeded, control: %s, task: %s, transit: %s",
      "level": "DEBUG",
      "group": "WM_DEBUG_RECENTS_ANIMATIONS",
      "at": "com\/android\/server\/wm\/WindowContainer.java"
    },
    "-198463978": {
      "message": "updateRotationUnchecked: alwaysSendConfiguration=%b forceRelayout=%b",
      "level": "VERBOSE",
@@ -901,6 +907,12 @@
      "group": "WM_DEBUG_ORIENTATION",
      "at": "com\/android\/server\/wm\/ScreenRotationAnimation.java"
    },
    "-172900257": {
      "message": "addTaskToTargets, target: %s",
      "level": "DEBUG",
      "group": "WM_DEBUG_RECENTS_ANIMATIONS",
      "at": "com\/android\/server\/wm\/RecentsAnimationController.java"
    },
    "-167822951": {
      "message": "Attempted to add starting window to token with already existing starting window",
      "level": "WARN",
@@ -1513,6 +1525,12 @@
      "group": "WM_DEBUG_RECENTS_ANIMATIONS",
      "at": "com\/android\/server\/wm\/RecentsAnimation.java"
    },
    "854237232": {
      "message": "addTaskToRecentsAnimationIfNeeded, control: %s, task: %s, transit: %s",
      "level": "DEBUG",
      "group": "WM_DEBUG_RECENTS_ANIMATIONS",
      "at": "com\/android\/server\/wm\/Task.java"
    },
    "873914452": {
      "message": "goodToGo()",
      "level": "DEBUG",
+5 −0
Original line number Diff line number Diff line
@@ -261,6 +261,11 @@ public class ActivityManagerWrapper {
                        animationHandler.onAnimationCanceled(
                                taskSnapshot != null ? new ThumbnailData(taskSnapshot) : null);
                    }

                    @Override
                    public void onTaskAppeared(RemoteAnimationTarget app) {
                        animationHandler.onTaskAppeared(new RemoteAnimationTargetCompat(app));
                    }
                };
            }
            ActivityTaskManager.getService().startRecentsActivity(intent, receiver, runner);
Loading