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

Commit 863e696e authored by Riddle Hsu's avatar Riddle Hsu
Browse files

Use task as reference layer for recents input consumer

So even if there is activity switch inside the task which is animating
by the recents transition, the recents input consumer can always has
the layer above the live-tile task.

Also avoid changing mRecentsDisplayId when restoring parent surface of
navigation bar. Because there can be multiple transitions run at the
same time. If mRecentsDisplayId is set, it will also clear the active
recents record of InputMonitor, but actually the recents transition
hasn't finished yet.

Bug: 319244888
Test: Launch an activity which will launch another activity in
      the same task after 3s. Enter recents (either swipe-up
      or press recents key) before the next activity is started.
      After the next activity is started in the recents overview,
      trigger back event, it should return from recents to the
      current app instead of no response.
Change-Id: Iedf14b0a345293cf7b11523aa9b4e38a1c821754
parent 68101dbb
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -112,7 +112,7 @@ final class InputMonitor {
     * z-layering reference so that we can place the recents input consumer above it.
     */
    private WeakReference<ActivityRecord> mActiveRecentsActivity = null;
    private WeakReference<ActivityRecord> mActiveRecentsLayerRef = null;
    private WeakReference<Task> mActiveRecentsLayerRef = null;

    private class UpdateInputWindows implements Runnable {
        @Override
@@ -389,9 +389,9 @@ final class InputMonitor {
    /**
     * Inform InputMonitor when recents is active so it can enable the recents input consumer.
     * @param activity The active recents activity. {@code null} means recents is not active.
     * @param layer An activity whose Z-layer is used as a reference for how to sort the consumer.
     * @param layer A task whose Z-layer is used as a reference for how to sort the consumer.
     */
    void setActiveRecents(@Nullable ActivityRecord activity, @Nullable ActivityRecord layer) {
    void setActiveRecents(@Nullable ActivityRecord activity, @Nullable Task layer) {
        final boolean clear = activity == null;
        final boolean wasActive = mActiveRecentsActivity != null && mActiveRecentsLayerRef != null;
        mActiveRecentsActivity = clear ? null : new WeakReference<>(activity);
+18 −17
Original line number Diff line number Diff line
@@ -1933,29 +1933,29 @@ class Transition implements BLASTSyncEngine.TransactionReadyListener {
                dc.getInputMonitor().getInputConsumer(INPUT_CONSUMER_RECENTS_ANIMATION);
        ActivityRecord recentsActivity = null;
        if (recentsAnimationInputConsumer != null) {
            // find the top-most going-away activity and the recents activity. The top-most
            // Find the top-most going-away task and the recents activity. The top-most
            // is used as layer reference while the recents is used for registering the consumer
            // override.
            ActivityRecord topActivity = null;
            Task topNonRecentsTask = null;
            for (int i = 0; i < info.getChanges().size(); ++i) {
                final TransitionInfo.Change change = info.getChanges().get(i);
                if (change.getTaskInfo() == null) continue;
                final Task task = Task.fromWindowContainerToken(
                        info.getChanges().get(i).getTaskInfo().token);
                final ActivityManager.RunningTaskInfo taskInfo =
                        info.getChanges().get(i).getTaskInfo();
                if (taskInfo == null) continue;
                final Task task = Task.fromWindowContainerToken(taskInfo.token);
                if (task == null) continue;
                final int activityType = change.getTaskInfo().topActivityType;
                final int activityType = taskInfo.topActivityType;
                final boolean isRecents = activityType == ACTIVITY_TYPE_HOME
                        || activityType == ACTIVITY_TYPE_RECENTS;
                if (isRecents && recentsActivity == null) {
                    recentsActivity = task.getTopVisibleActivity();
                } else if (!isRecents && topActivity == null) {
                    topActivity = task.getTopNonFinishingActivity();
                } else if (!isRecents && topNonRecentsTask == null) {
                    topNonRecentsTask = task;
                }
            }
            if (recentsActivity != null && topActivity != null) {
            if (recentsActivity != null && topNonRecentsTask != null) {
                recentsAnimationInputConsumer.mWindowHandle.touchableRegion.set(
                        topActivity.getBounds());
                dc.getInputMonitor().setActiveRecents(recentsActivity, topActivity);
                        topNonRecentsTask.getBounds());
                dc.getInputMonitor().setActiveRecents(recentsActivity, topNonRecentsTask);
            }
        }

@@ -2020,16 +2020,17 @@ class Transition implements BLASTSyncEngine.TransactionReadyListener {
        }
        mController.mNavigationBarAttachedToApp = false;

        if (mRecentsDisplayId == INVALID_DISPLAY) {
            Slog.e(TAG, "Reparented navigation bar without a valid display");
            mRecentsDisplayId = DEFAULT_DISPLAY;
        int recentsDisplayId = mRecentsDisplayId;
        if (recentsDisplayId == INVALID_DISPLAY) {
            Slog.i(TAG, "Restore parent surface of navigation bar by another transition");
            recentsDisplayId = DEFAULT_DISPLAY;
        }

        final DisplayContent dc =
                mController.mAtm.mRootWindowContainer.getDisplayContent(mRecentsDisplayId);
                mController.mAtm.mRootWindowContainer.getDisplayContent(recentsDisplayId);
        final StatusBarManagerInternal bar = dc.getDisplayPolicy().getStatusBarManagerInternal();
        if (bar != null) {
            bar.setNavigationBarLumaSamplingEnabled(mRecentsDisplayId, true);
            bar.setNavigationBarLumaSamplingEnabled(recentsDisplayId, true);
        }
        final WindowState navWindow = dc.getDisplayPolicy().getNavigationBar();
        if (navWindow == null) return;