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

Commit 710ff711 authored by Evan Rosky's avatar Evan Rosky
Browse files

Add support/adapter for recents animation via shell transition

This does the basics to adapt recents animation to shell transition.

Replaces startRecentsActivity with a normal startActivity. Once
we make a full switch to shell transitions, we can hopefully remove
it.

Updates the TransitionHandlers in shell and RemoteTransitions to
support attaching a WindowContainerTransaction to a transition's
finish. For recents, this is used to move the "pausing" app (the
one getting animated into the recents carousel) back to the front
if the gesture doesn't go all-the-way into recents.

Bug: 162503077
Test: enable shell transit. launch an app, use gesture to open
      recents. use gesture to start going to recents, but then
      release early to return to the app.
      atest ShellTransitionTests
Change-Id: Ied54f1b2c70c5c129b2f5798117d6d8a85360998
parent f0d0d2af
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -987,6 +987,18 @@ public class ActivityOptions {
        return opts;
    }

    /**
     * Create an {@link ActivityOptions} instance that lets the application control the entire
     * transition using a {@link IRemoteTransition}.
     * @hide
     */
    @RequiresPermission(CONTROL_REMOTE_APP_TRANSITION_ANIMATIONS)
    public static ActivityOptions makeRemoteTransition(IRemoteTransition remoteTransition) {
        final ActivityOptions opts = new ActivityOptions();
        opts.mRemoteTransition = remoteTransition;
        return opts;
    }

    /** @hide */
    public boolean getLaunchTaskBehind() {
        return mAnimationType == ANIM_LAUNCH_TASK_BEHIND;
+2 −2
Original line number Diff line number Diff line
@@ -16,8 +16,8 @@

package android.window;

import android.view.IRemoteAnimationFinishedCallback;
import android.view.SurfaceControl;
import android.window.IRemoteTransitionFinishedCallback;
import android.window.TransitionInfo;

/**
@@ -42,5 +42,5 @@ oneway interface IRemoteTransition {
     * `finishCallback`.
     */
    void startAnimation(in TransitionInfo info, in SurfaceControl.Transaction t,
            in IRemoteAnimationFinishedCallback finishCallback);
            in IRemoteTransitionFinishedCallback finishCallback);
}
+29 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2020 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License
 */

package android.window;

import android.window.WindowContainerTransaction;

/**
 * Interface to be invoked by the controlling process when a remote transition has finished.
 *
 * @see IRemoteTransition
 * {@hide}
 */
interface IRemoteTransitionFinishedCallback {
    void onTransitionFinished(in WindowContainerTransaction wct);
}
+4 −3
Original line number Diff line number Diff line
@@ -64,7 +64,7 @@ public class SplitScreenTransitions implements Transitions.TransitionHandler {
    /** Keeps track of currently running animations */
    private final ArrayList<Animator> mAnimations = new ArrayList<>();

    private Runnable mFinishCallback = null;
    private Transitions.TransitionFinishCallback mFinishCallback = null;
    private SurfaceControl.Transaction mFinishTransaction;

    SplitScreenTransitions(@NonNull TransactionPool pool, @NonNull Transitions transitions,
@@ -203,7 +203,8 @@ public class SplitScreenTransitions implements Transitions.TransitionHandler {

    @Override
    public boolean startAnimation(@NonNull IBinder transition, @NonNull TransitionInfo info,
            @NonNull SurfaceControl.Transaction t, @NonNull Runnable finishCallback) {
            @NonNull SurfaceControl.Transaction t,
            @NonNull Transitions.TransitionFinishCallback finishCallback) {
        if (transition != mPendingDismiss && transition != mPendingEnter) {
            // If we're not in split-mode, just abort
            if (!mSplitScreen.isDividerVisible()) return false;
@@ -330,7 +331,7 @@ public class SplitScreenTransitions implements Transitions.TransitionHandler {
        mFinishTransaction.apply();
        mTransactionPool.release(mFinishTransaction);
        mFinishTransaction = null;
        mFinishCallback.run();
        mFinishCallback.onTransitionFinished(null /* wct */, null /* wctCB */);
        mFinishCallback = null;
        if (mAnimatingTransition == mPendingEnter) {
            mPendingEnter = null;
+3 −2
Original line number Diff line number Diff line
@@ -56,7 +56,8 @@ public class DefaultTransitionHandler implements Transitions.TransitionHandler {

    @Override
    public boolean startAnimation(@NonNull IBinder transition, @NonNull TransitionInfo info,
            @NonNull SurfaceControl.Transaction t, @NonNull Runnable finishCallback) {
            @NonNull SurfaceControl.Transaction t,
            @NonNull Transitions.TransitionFinishCallback finishCallback) {
        if (mAnimations.containsKey(transition)) {
            throw new IllegalStateException("Got a duplicate startAnimation call for "
                    + transition);
@@ -68,7 +69,7 @@ public class DefaultTransitionHandler implements Transitions.TransitionHandler {
        final Runnable onAnimFinish = () -> {
            if (!animations.isEmpty()) return;
            mAnimations.remove(transition);
            finishCallback.run();
            finishCallback.onTransitionFinished(null /* wct */, null /* wctCB */);
        };
        for (int i = info.getChanges().size() - 1; i >= 0; --i) {
            final TransitionInfo.Change change = info.getChanges().get(i);
Loading