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

Commit 024c645a authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Pass extras Bundle in onRecentsAnimationStart" into main

parents b6bb1c9f c562feec
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import android.graphics.Rect;
import android.view.RemoteAnimationTarget;
import android.view.IRecentsAnimationController;
import android.window.TaskSnapshot;
import android.os.Bundle;

/**
 * Interface that is used to callback from window manager to the process that runs a recents
@@ -57,7 +58,7 @@ oneway interface IRecentsAnimationRunner {
    @UnsupportedAppUsage(maxTargetSdk = 30, trackingBug = 170729553)
    void onAnimationStart(in IRecentsAnimationController controller,
            in RemoteAnimationTarget[] apps, in RemoteAnimationTarget[] wallpapers,
            in Rect homeContentInsets, in Rect minimizedHomeBounds) = 2;
            in Rect homeContentInsets, in Rect minimizedHomeBounds, in Bundle extras) = 2;

    /**
     * Called when the task of an activity that has been started while the recents animation
+11 −0
Original line number Diff line number Diff line
@@ -203,6 +203,17 @@ public class RecentTasksController implements TaskStackListenerCallback,
        }
    }

    @Nullable
    public SplitBounds getSplitBoundsForTaskId(int taskId) {
        if (taskId == INVALID_TASK_ID) {
            return null;
        }

        // We could do extra verification of requiring both taskIds of a pair and verifying that
        // the same split bounds object is returned... but meh. Seems unnecessary.
        return mTaskSplitBoundsMap.get(taskId);
    }

    @Override
    public Context getContext() {
        return mContext;
+12 −1
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.wm.shell.recents;

import static android.app.ActivityTaskManager.INVALID_TASK_ID;
import static android.app.WindowConfiguration.ACTIVITY_TYPE_HOME;
import static android.app.WindowConfiguration.ACTIVITY_TYPE_RECENTS;
import static android.view.WindowManager.TRANSIT_CHANGE;
@@ -23,6 +24,8 @@ import static android.view.WindowManager.TRANSIT_FLAG_KEYGUARD_LOCKED;
import static android.view.WindowManager.TRANSIT_SLEEP;
import static android.view.WindowManager.TRANSIT_TO_FRONT;

import static com.android.wm.shell.util.SplitBounds.KEY_EXTRA_SPLIT_BOUNDS;

import android.annotation.Nullable;
import android.annotation.SuppressLint;
import android.app.ActivityManager;
@@ -69,6 +72,8 @@ public class RecentsTransitionHandler implements Transitions.TransitionHandler {

    private final Transitions mTransitions;
    private final ShellExecutor mExecutor;
    @Nullable
    private final RecentTasksController mRecentTasksController;
    private IApplicationThread mAnimApp = null;
    private final ArrayList<RecentsController> mControllers = new ArrayList<>();

@@ -82,6 +87,7 @@ public class RecentsTransitionHandler implements Transitions.TransitionHandler {
            @Nullable RecentTasksController recentTasksController) {
        mTransitions = transitions;
        mExecutor = transitions.getMainExecutor();
        mRecentTasksController = recentTasksController;
        if (!Transitions.ENABLE_SHELL_TRANSITIONS) return;
        if (recentTasksController == null) return;
        shellInit.addInitCallback(() -> {
@@ -417,6 +423,7 @@ public class RecentsTransitionHandler implements Transitions.TransitionHandler {
            mLeashMap = new ArrayMap<>();
            mKeyguardLocked = (info.getFlags() & TRANSIT_FLAG_KEYGUARD_LOCKED) != 0;

            int closingSplitTaskId = INVALID_TASK_ID;
            final ArrayList<RemoteAnimationTarget> apps = new ArrayList<>();
            final ArrayList<RemoteAnimationTarget> wallpapers = new ArrayList<>();
            TransitionUtil.LeafTaskFilter leafTaskFilter = new TransitionUtil.LeafTaskFilter();
@@ -443,6 +450,7 @@ public class RecentsTransitionHandler implements Transitions.TransitionHandler {
                    apps.add(target);
                    if (TransitionUtil.isClosingType(change.getMode())) {
                        mPausingTasks.add(new TaskState(change, target.leash));
                        closingSplitTaskId = change.getTaskInfo().taskId;
                        if (taskInfo.topActivityType == ACTIVITY_TYPE_HOME) {
                            ProtoLog.v(ShellProtoLogGroup.WM_SHELL_RECENTS_TRANSITION,
                                    "  adding pausing leaf home taskId=%d", taskInfo.taskId);
@@ -500,13 +508,16 @@ public class RecentsTransitionHandler implements Transitions.TransitionHandler {
                }
            }
            t.apply();
            Bundle b = new Bundle(1 /*capacity*/);
            b.putParcelable(KEY_EXTRA_SPLIT_BOUNDS,
                    mRecentTasksController.getSplitBoundsForTaskId(closingSplitTaskId));
            try {
                ProtoLog.v(ShellProtoLogGroup.WM_SHELL_RECENTS_TRANSITION,
                        "[%d] RecentsController.start: calling onAnimationStart", mInstanceId);
                mListener.onAnimationStart(this,
                        apps.toArray(new RemoteAnimationTarget[apps.size()]),
                        wallpapers.toArray(new RemoteAnimationTarget[wallpapers.size()]),
                        new Rect(0, 0, 0, 0), new Rect());
                        new Rect(0, 0, 0, 0), new Rect(), b);
            } catch (RemoteException e) {
                Slog.e(TAG, "Error starting recents animation", e);
                cancel("onAnimationStart() failed");
+2 −0
Original line number Diff line number Diff line
@@ -26,6 +26,8 @@ import java.util.Objects;
 * tasks/leashes/etc in Launcher
 */
public class SplitBounds implements Parcelable {
    public static final String KEY_EXTRA_SPLIT_BOUNDS = "key_SplitBounds";

    public final Rect leftTopBounds;
    public final Rect rightBottomBounds;
    /** This rect represents the actual gap between the two apps */
+32 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.wm.shell.recents;

import static android.app.ActivityManager.RECENT_IGNORE_UNAVAILABLE;
import static android.app.ActivityTaskManager.INVALID_TASK_ID;
import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN;
import static android.app.WindowConfiguration.WINDOWING_MODE_MULTI_WINDOW;

@@ -367,6 +368,37 @@ public class RecentTasksControllerTest extends ShellTestCase {
        verify(mRecentTasksController).notifyRecentTasksChanged();
    }

    @Test
    public void getNullSplitBoundsNonSplitTask() {
        SplitBounds sb = mRecentTasksController.getSplitBoundsForTaskId(3);
        assertNull("splitBounds should be null for non-split task", sb);
    }

    @Test
    public void getNullSplitBoundsInvalidTask() {
        SplitBounds sb = mRecentTasksController.getSplitBoundsForTaskId(INVALID_TASK_ID);
        assertNull("splitBounds should be null for invalid taskID", sb);
    }

    @Test
    public void getSplitBoundsForSplitTask() {
        SplitBounds pair1Bounds = mock(SplitBounds.class);
        SplitBounds pair2Bounds = mock(SplitBounds.class);

        mRecentTasksController.addSplitPair(1, 2, pair1Bounds);
        mRecentTasksController.addSplitPair(4, 3, pair2Bounds);

        SplitBounds splitBounds2 = mRecentTasksController.getSplitBoundsForTaskId(2);
        SplitBounds splitBounds1 = mRecentTasksController.getSplitBoundsForTaskId(1);
        assertEquals("Different splitBounds for same pair", splitBounds1, splitBounds2);
        assertEquals(splitBounds1, pair1Bounds);

        SplitBounds splitBounds3 = mRecentTasksController.getSplitBoundsForTaskId(3);
        SplitBounds splitBounds4 = mRecentTasksController.getSplitBoundsForTaskId(4);
        assertEquals("Different splitBounds for same pair", splitBounds3, splitBounds4);
        assertEquals(splitBounds4, pair2Bounds);
    }

    /**
     * Helper to create a task with a given task id.
     */
Loading