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

Commit bc94c3d5 authored by Evan Rosky's avatar Evan Rosky
Browse files

Wrap IRemoteTransition in a parcelable to enable extra properties

This is in preparation for attaching some extra meta information
to remote transitions (eg. process token). Most of this refactor
just replaces references to the raw interface with references
to the wrapper class.

There is also a small refactor in RemoteTransitionHandler to
better-manage death-recipients. It is possible to have >1 filter
and >1 pendings referencing the same remote simultaneously, so
this arrangement properly handles the 1-to-many possibility.

Bug: 183993977
Test: refactor, so existing tests pass
Change-Id: Icae8f2128e0ffdf7aee51284cba106963450e3e7
Merged-In: Icae8f2128e0ffdf7aee51284cba106963450e3e7
parent 88bf3ce5
Loading
Loading
Loading
Loading
+8 −9
Original line number Diff line number Diff line
@@ -55,7 +55,7 @@ import android.view.RemoteAnimationAdapter;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.window.IRemoteTransition;
import android.window.RemoteTransition;
import android.window.SplashScreen;
import android.window.WindowContainerToken;

@@ -426,7 +426,7 @@ public class ActivityOptions {
    private IAppTransitionAnimationSpecsFuture mSpecsFuture;
    private RemoteAnimationAdapter mRemoteAnimationAdapter;
    private IBinder mLaunchCookie;
    private IRemoteTransition mRemoteTransition;
    private RemoteTransition mRemoteTransition;
    private boolean mOverrideTaskTransition;
    private String mSplashScreenThemeResName;
    @SplashScreen.SplashScreenStyle
@@ -1054,7 +1054,7 @@ public class ActivityOptions {
     */
    @RequiresPermission(CONTROL_REMOTE_APP_TRANSITION_ANIMATIONS)
    public static ActivityOptions makeRemoteAnimation(RemoteAnimationAdapter remoteAnimationAdapter,
            IRemoteTransition remoteTransition) {
            RemoteTransition remoteTransition) {
        final ActivityOptions opts = new ActivityOptions();
        opts.mRemoteAnimationAdapter = remoteAnimationAdapter;
        opts.mAnimationType = ANIM_REMOTE_ANIMATION;
@@ -1064,11 +1064,11 @@ public class ActivityOptions {

    /**
     * Create an {@link ActivityOptions} instance that lets the application control the entire
     * transition using a {@link IRemoteTransition}.
     * transition using a {@link RemoteTransition}.
     * @hide
     */
    @RequiresPermission(CONTROL_REMOTE_APP_TRANSITION_ANIMATIONS)
    public static ActivityOptions makeRemoteTransition(IRemoteTransition remoteTransition) {
    public static ActivityOptions makeRemoteTransition(RemoteTransition remoteTransition) {
        final ActivityOptions opts = new ActivityOptions();
        opts.mRemoteTransition = remoteTransition;
        return opts;
@@ -1181,8 +1181,7 @@ public class ActivityOptions {
        }
        mRemoteAnimationAdapter = opts.getParcelable(KEY_REMOTE_ANIMATION_ADAPTER);
        mLaunchCookie = opts.getBinder(KEY_LAUNCH_COOKIE);
        mRemoteTransition = IRemoteTransition.Stub.asInterface(opts.getBinder(
                KEY_REMOTE_TRANSITION));
        mRemoteTransition = opts.getParcelable(KEY_REMOTE_TRANSITION);
        mOverrideTaskTransition = opts.getBoolean(KEY_OVERRIDE_TASK_TRANSITION);
        mSplashScreenThemeResName = opts.getString(KEY_SPLASH_SCREEN_THEME);
        mRemoveWithTaskOrganizer = opts.getBoolean(KEY_REMOVE_WITH_TASK_ORGANIZER);
@@ -1348,7 +1347,7 @@ public class ActivityOptions {
    }

    /** @hide */
    public IRemoteTransition getRemoteTransition() {
    public RemoteTransition getRemoteTransition() {
        return mRemoteTransition;
    }

@@ -1965,7 +1964,7 @@ public class ActivityOptions {
            b.putBinder(KEY_LAUNCH_COOKIE, mLaunchCookie);
        }
        if (mRemoteTransition != null) {
            b.putBinder(KEY_REMOTE_TRANSITION, mRemoteTransition.asBinder());
            b.putParcelable(KEY_REMOTE_TRANSITION, mRemoteTransition);
        }
        if (mOverrideTaskTransition) {
            b.putBoolean(KEY_OVERRIDE_TASK_TRANSITION, mOverrideTaskTransition);
+19 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2021 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;

parcelable RemoteTransition;
+158 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2021 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.annotation.NonNull;
import android.annotation.Nullable;
import android.os.IBinder;
import android.os.Parcelable;

import com.android.internal.util.DataClass;

/**
 * Represents a remote transition animation and information required to run it (eg. the app thread
 * that needs to be boosted).
 * @hide
 */
@DataClass(genToString = true, genSetters = true, genAidl = true)
public class RemoteTransition implements Parcelable {

    /** The actual remote-transition interface used to run the transition animation. */
    private @NonNull IRemoteTransition mRemoteTransition;

    /** Get the IBinder associated with the underlying IRemoteTransition. */
    public @Nullable IBinder asBinder() {
        return mRemoteTransition.asBinder();
    }



    // Code below generated by codegen v1.0.23.
    //
    // DO NOT MODIFY!
    // CHECKSTYLE:OFF Generated code
    //
    // To regenerate run:
    // $ codegen $ANDROID_BUILD_TOP/frameworks/base/core/java/android/window/RemoteTransition.java
    //
    // To exclude the generated code from IntelliJ auto-formatting enable (one-time):
    //   Settings > Editor > Code Style > Formatter Control
    //@formatter:off


    /**
     * Creates a new RemoteTransition.
     *
     * @param remoteTransition
     *   The actual remote-transition interface used to run the transition animation.
     */
    @DataClass.Generated.Member
    public RemoteTransition(
            @NonNull IRemoteTransition remoteTransition) {
        this.mRemoteTransition = remoteTransition;
        com.android.internal.util.AnnotationValidations.validate(
                NonNull.class, null, mRemoteTransition);

        // onConstructed(); // You can define this method to get a callback
    }

    /**
     * The actual remote-transition interface used to run the transition animation.
     */
    @DataClass.Generated.Member
    public @NonNull IRemoteTransition getRemoteTransition() {
        return mRemoteTransition;
    }

    /**
     * The actual remote-transition interface used to run the transition animation.
     */
    @DataClass.Generated.Member
    public @NonNull RemoteTransition setRemoteTransition(@NonNull IRemoteTransition value) {
        mRemoteTransition = value;
        com.android.internal.util.AnnotationValidations.validate(
                NonNull.class, null, mRemoteTransition);
        return this;
    }

    @Override
    @DataClass.Generated.Member
    public String toString() {
        // You can override field toString logic by defining methods like:
        // String fieldNameToString() { ... }

        return "RemoteTransition { " +
                "remoteTransition = " + mRemoteTransition +
        " }";
    }

    @Override
    @DataClass.Generated.Member
    public void writeToParcel(@NonNull android.os.Parcel dest, int flags) {
        // You can override field parcelling by defining methods like:
        // void parcelFieldName(Parcel dest, int flags) { ... }

        dest.writeStrongInterface(mRemoteTransition);
    }

    @Override
    @DataClass.Generated.Member
    public int describeContents() { return 0; }

    /** @hide */
    @SuppressWarnings({"unchecked", "RedundantCast"})
    @DataClass.Generated.Member
    protected RemoteTransition(@NonNull android.os.Parcel in) {
        // You can override field unparcelling by defining methods like:
        // static FieldType unparcelFieldName(Parcel in) { ... }

        IRemoteTransition remoteTransition = IRemoteTransition.Stub.asInterface(in.readStrongBinder());

        this.mRemoteTransition = remoteTransition;
        com.android.internal.util.AnnotationValidations.validate(
                NonNull.class, null, mRemoteTransition);

        // onConstructed(); // You can define this method to get a callback
    }

    @DataClass.Generated.Member
    public static final @NonNull Parcelable.Creator<RemoteTransition> CREATOR
            = new Parcelable.Creator<RemoteTransition>() {
        @Override
        public RemoteTransition[] newArray(int size) {
            return new RemoteTransition[size];
        }

        @Override
        public RemoteTransition createFromParcel(@NonNull android.os.Parcel in) {
            return new RemoteTransition(in);
        }
    };

    @DataClass.Generated(
            time = 1630613039043L,
            codegenVersion = "1.0.23",
            sourceFile = "frameworks/base/core/java/android/window/RemoteTransition.java",
            inputSignatures = "private @android.annotation.NonNull android.window.IRemoteTransition mRemoteTransition\npublic @android.annotation.Nullable android.os.IBinder asBinder()\nclass RemoteTransition extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genToString=true, genSetters=true, genAidl=true)")
    @Deprecated
    private void __metadata() {}


    //@formatter:on
    // End of generated code

}
+10 −10
Original line number Diff line number Diff line
@@ -40,11 +40,11 @@ public final class TransitionRequestInfo implements Parcelable {
    private @Nullable ActivityManager.RunningTaskInfo mTriggerTask;

    /** If non-null, a remote-transition associated with the source of this transition. */
    private @Nullable IRemoteTransition mRemoteTransition;
    private @Nullable RemoteTransition mRemoteTransition;



    // Code below generated by codegen v1.0.22.
    // Code below generated by codegen v1.0.23.
    //
    // DO NOT MODIFY!
    // CHECKSTYLE:OFF Generated code
@@ -72,7 +72,7 @@ public final class TransitionRequestInfo implements Parcelable {
    public TransitionRequestInfo(
            @WindowManager.TransitionType int type,
            @Nullable ActivityManager.RunningTaskInfo triggerTask,
            @Nullable IRemoteTransition remoteTransition) {
            @Nullable RemoteTransition remoteTransition) {
        this.mType = type;
        com.android.internal.util.AnnotationValidations.validate(
                WindowManager.TransitionType.class, null, mType);
@@ -103,7 +103,7 @@ public final class TransitionRequestInfo implements Parcelable {
     * If non-null, a remote-transition associated with the source of this transition.
     */
    @DataClass.Generated.Member
    public @Nullable IRemoteTransition getRemoteTransition() {
    public @Nullable RemoteTransition getRemoteTransition() {
        return mRemoteTransition;
    }

@@ -121,7 +121,7 @@ public final class TransitionRequestInfo implements Parcelable {
     * If non-null, a remote-transition associated with the source of this transition.
     */
    @DataClass.Generated.Member
    public @android.annotation.NonNull TransitionRequestInfo setRemoteTransition(@android.annotation.NonNull IRemoteTransition value) {
    public @android.annotation.NonNull TransitionRequestInfo setRemoteTransition(@android.annotation.NonNull RemoteTransition value) {
        mRemoteTransition = value;
        return this;
    }
@@ -151,7 +151,7 @@ public final class TransitionRequestInfo implements Parcelable {
        dest.writeByte(flg);
        dest.writeInt(mType);
        if (mTriggerTask != null) dest.writeTypedObject(mTriggerTask, flags);
        if (mRemoteTransition != null) dest.writeStrongInterface(mRemoteTransition);
        if (mRemoteTransition != null) dest.writeTypedObject(mRemoteTransition, flags);
    }

    @Override
@@ -168,7 +168,7 @@ public final class TransitionRequestInfo implements Parcelable {
        byte flg = in.readByte();
        int type = in.readInt();
        ActivityManager.RunningTaskInfo triggerTask = (flg & 0x2) == 0 ? null : (ActivityManager.RunningTaskInfo) in.readTypedObject(ActivityManager.RunningTaskInfo.CREATOR);
        IRemoteTransition remoteTransition = (flg & 0x4) == 0 ? null : IRemoteTransition.Stub.asInterface(in.readStrongBinder());
        RemoteTransition remoteTransition = (flg & 0x4) == 0 ? null : (RemoteTransition) in.readTypedObject(RemoteTransition.CREATOR);

        this.mType = type;
        com.android.internal.util.AnnotationValidations.validate(
@@ -194,10 +194,10 @@ public final class TransitionRequestInfo implements Parcelable {
    };

    @DataClass.Generated(
            time = 1610060387917L,
            codegenVersion = "1.0.22",
            time = 1629321632222L,
            codegenVersion = "1.0.23",
            sourceFile = "frameworks/base/core/java/android/window/TransitionRequestInfo.java",
            inputSignatures = "private final @android.view.WindowManager.TransitionType int mType\nprivate @android.annotation.Nullable android.app.ActivityManager.RunningTaskInfo mTriggerTask\nprivate @android.annotation.Nullable android.window.IRemoteTransition mRemoteTransition\nclass TransitionRequestInfo extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genToString=true, genSetters=true, genAidl=true)")
            inputSignatures = "private final @android.view.WindowManager.TransitionType int mType\nprivate @android.annotation.Nullable android.app.ActivityManager.RunningTaskInfo mTriggerTask\nprivate @android.annotation.Nullable android.window.RemoteTransition mRemoteTransition\nclass TransitionRequestInfo extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genToString=true, genSetters=true, genAidl=true)")
    @Deprecated
    private void __metadata() {}

+2 −2
Original line number Diff line number Diff line
@@ -22,7 +22,7 @@ import android.os.Bundle;
import android.os.UserHandle;
import android.view.RemoteAnimationAdapter;
import android.view.RemoteAnimationTarget;
import android.window.IRemoteTransition;
import android.window.RemoteTransition;

import com.android.wm.shell.splitscreen.ISplitScreenListener;

@@ -82,7 +82,7 @@ interface ISplitScreen {
     * Starts tasks simultaneously in one transition.
     */
    oneway void startTasks(int mainTaskId, in Bundle mainOptions, int sideTaskId,
            in Bundle sideOptions, int sidePosition, in IRemoteTransition remoteTransition) = 10;
            in Bundle sideOptions, int sidePosition, in RemoteTransition remoteTransition) = 10;

    /**
     * Version of startTasks using legacy transition system.
Loading