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

Commit 4ec0b520 authored by Wei Sheng Shih's avatar Wei Sheng Shih Committed by Android (Google) Code Review
Browse files

Merge "[RESTRICT AUTOMERGE]BackGestureAnimation: a lightweight recents...

Merge "[RESTRICT AUTOMERGE]BackGestureAnimation: a lightweight recents animation controller" into tm-qpr-dev
parents 6dae9d46 c9c9a757
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -72,6 +72,7 @@ import android.view.IRemoteAnimationRunner;
import android.view.IWindowFocusObserver;
import android.view.RemoteAnimationDefinition;
import android.view.RemoteAnimationAdapter;
import android.window.BackAnimationAdaptor;
import android.window.IWindowOrganizerController;
import android.window.BackNavigationInfo;
import android.window.SplashScreenView;
@@ -356,5 +357,5 @@ interface IActivityTaskManager {
     * @param focusObserver a remote callback to nofify shell when the focused window lost focus.
     */
    android.window.BackNavigationInfo startBackNavigation(in boolean requestAnimation,
            in IWindowFocusObserver focusObserver);
            in IWindowFocusObserver focusObserver, in BackAnimationAdaptor adaptor);
}
+22 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2022 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;

/**
 * @hide
 */
parcelable BackAnimationAdaptor;
 No newline at end of file
+72 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2022 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.os.Parcel;
import android.os.Parcelable;

/**
 * Object that describes how to run a remote back animation.
 *
 * @hide
 */
public class BackAnimationAdaptor implements Parcelable {

    private final IBackAnimationRunner mRunner;
    @BackNavigationInfo.BackTargetType
    private final int mSupportType;

    public BackAnimationAdaptor(IBackAnimationRunner runner, int supportType) {
        mRunner = runner;
        mSupportType = supportType;
    }

    public BackAnimationAdaptor(Parcel in) {
        mRunner = IBackAnimationRunner.Stub.asInterface(in.readStrongBinder());
        mSupportType = in.readInt();
    }

    public IBackAnimationRunner getRunner() {
        return mRunner;
    }

    @BackNavigationInfo.BackTargetType public int getSupportType() {
        return mSupportType;
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeStrongInterface(mRunner);
        dest.writeInt(mSupportType);
    }

    public static final @android.annotation.NonNull Creator<BackAnimationAdaptor> CREATOR =
            new Creator<BackAnimationAdaptor>() {
        public BackAnimationAdaptor createFromParcel(Parcel in) {
            return new BackAnimationAdaptor(in);
        }

        public BackAnimationAdaptor[] newArray(int size) {
            return new BackAnimationAdaptor[size];
        }
    };
}
+25 −2
Original line number Diff line number Diff line
@@ -101,6 +101,8 @@ public final class BackNavigationInfo implements Parcelable {
    @Nullable
    private final IOnBackInvokedCallback mOnBackInvokedCallback;

    private final boolean mIsPrepareRemoteAnimation;

    /**
     * Create a new {@link BackNavigationInfo} instance.
     *
@@ -117,6 +119,9 @@ public final class BackNavigationInfo implements Parcelable {
     * @param onBackNavigationDone    The callback to be called once the client is done with the
     *                                back preview.
     * @param onBackInvokedCallback   The back callback registered by the current top level window.
     * @param isPrepareRemoteAnimation  Return whether the core is preparing a back gesture
     *                                  animation, if true, the caller of startBackNavigation should
     *                                  be expected to receive an animation start callback.
     */
    private BackNavigationInfo(@BackTargetType int type,
            @Nullable RemoteAnimationTarget departingAnimationTarget,
@@ -124,7 +129,8 @@ public final class BackNavigationInfo implements Parcelable {
            @Nullable HardwareBuffer screenshotBuffer,
            @Nullable WindowConfiguration taskWindowConfiguration,
            @Nullable RemoteCallback onBackNavigationDone,
            @Nullable IOnBackInvokedCallback onBackInvokedCallback) {
            @Nullable IOnBackInvokedCallback onBackInvokedCallback,
            boolean isPrepareRemoteAnimation) {
        mType = type;
        mDepartingAnimationTarget = departingAnimationTarget;
        mScreenshotSurface = screenshotSurface;
@@ -132,6 +138,7 @@ public final class BackNavigationInfo implements Parcelable {
        mTaskWindowConfiguration = taskWindowConfiguration;
        mOnBackNavigationDone = onBackNavigationDone;
        mOnBackInvokedCallback = onBackInvokedCallback;
        mIsPrepareRemoteAnimation = isPrepareRemoteAnimation;
    }

    private BackNavigationInfo(@NonNull Parcel in) {
@@ -142,6 +149,7 @@ public final class BackNavigationInfo implements Parcelable {
        mTaskWindowConfiguration = in.readTypedObject(WindowConfiguration.CREATOR);
        mOnBackNavigationDone = in.readTypedObject(RemoteCallback.CREATOR);
        mOnBackInvokedCallback = IOnBackInvokedCallback.Stub.asInterface(in.readStrongBinder());
        mIsPrepareRemoteAnimation = in.readBoolean();
    }

    @Override
@@ -153,6 +161,7 @@ public final class BackNavigationInfo implements Parcelable {
        dest.writeTypedObject(mTaskWindowConfiguration, flags);
        dest.writeTypedObject(mOnBackNavigationDone, flags);
        dest.writeStrongInterface(mOnBackInvokedCallback);
        dest.writeBoolean(mIsPrepareRemoteAnimation);
    }

    /**
@@ -221,6 +230,10 @@ public final class BackNavigationInfo implements Parcelable {
        return mOnBackInvokedCallback;
    }

    public boolean isPrepareRemoteAnimation() {
        return mIsPrepareRemoteAnimation;
    }

    /**
     * Callback to be called when the back preview is finished in order to notify the server that
     * it can clean up the resources created for the animation.
@@ -306,6 +319,8 @@ public final class BackNavigationInfo implements Parcelable {
        @Nullable
        private IOnBackInvokedCallback mOnBackInvokedCallback = null;

        private boolean mPrepareAnimation;

        /**
         * @see BackNavigationInfo#getType()
         */
@@ -365,13 +380,21 @@ public final class BackNavigationInfo implements Parcelable {
            return this;
        }

        /**
         * @param prepareAnimation Whether core prepare animation for shell.
         */
        public Builder setPrepareAnimation(boolean prepareAnimation) {
            mPrepareAnimation = prepareAnimation;
            return this;
        }

        /**
         * Builds and returns an instance of {@link BackNavigationInfo}
         */
        public BackNavigationInfo build() {
            return new BackNavigationInfo(mType, mDepartingAnimationTarget, mScreenshotSurface,
                    mScreenshotBuffer, mTaskWindowConfiguration, mOnBackNavigationDone,
                    mOnBackInvokedCallback);
                    mOnBackInvokedCallback, mPrepareAnimation);
        }
    }
}
+45 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2022 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.view.RemoteAnimationTarget;
import android.window.IBackNaviAnimationController;

/**
 * Interface that is used to callback from window manager to the process that runs a back gesture
 * animation to start or cancel it.
 *
 * {@hide}
 */
oneway interface IBackAnimationRunner {

    /**
     * Called when the system needs to cancel the current animation. This can be due to the
     * wallpaper not drawing in time, or the handler not finishing the animation within a predefined
     * amount of time.
     *
     */
    void onAnimationCancelled() = 1;

    /**
     * Called when the system is ready for the handler to start animating all the visible tasks.
     *
     */
    void onAnimationStart(in IBackNaviAnimationController controller, in int type,
            in RemoteAnimationTarget[] apps, in RemoteAnimationTarget[] wallpapers,
            in RemoteAnimationTarget[] nonApps) = 2;
}
Loading