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

Commit afbe3207 authored by Winson Chung's avatar Winson Chung Committed by Android (Google) Code Review
Browse files

Merge "Clean up remote animation definitions when activity is destroyed"

parents 27392455 10fc25da
Loading
Loading
Loading
Loading
+14 −1
Original line number Diff line number Diff line
@@ -8674,7 +8674,6 @@ public class Activity extends ContextThemeWrapper
     * @hide
     */
    @RequiresPermission(CONTROL_REMOTE_APP_TRANSITION_ANIMATIONS)
    @UnsupportedAppUsage
    public void registerRemoteAnimations(RemoteAnimationDefinition definition) {
        try {
            ActivityTaskManager.getService().registerRemoteAnimations(mToken, definition);
@@ -8683,6 +8682,20 @@ public class Activity extends ContextThemeWrapper
        }
    }

    /**
     * Unregisters all remote animations for this activity.
     *
     * @hide
     */
    @RequiresPermission(CONTROL_REMOTE_APP_TRANSITION_ANIMATIONS)
    public void unregisterRemoteAnimations() {
        try {
            ActivityTaskManager.getService().unregisterRemoteAnimations(mToken);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }

    class HostCallbacks extends FragmentHostCallback<Activity> {
        public HostCallbacks() {
            super(Activity.this /*activity*/);
+5 −0
Original line number Diff line number Diff line
@@ -436,6 +436,11 @@ interface IActivityTaskManager {
     */
    void registerRemoteAnimations(in IBinder token, in RemoteAnimationDefinition definition);

    /**
     * Unregisters all remote animations for a specific activity.
     */
    void unregisterRemoteAnimations(in IBinder token);

    /**
     * Registers a remote animation to be run for all activity starts from a certain package during
     * a short predefined amount of time.
+17 −0
Original line number Diff line number Diff line
@@ -22,9 +22,12 @@ import android.annotation.Nullable;
import android.app.WindowConfiguration;
import android.app.WindowConfiguration.ActivityType;
import android.compat.annotation.UnsupportedAppUsage;
import android.os.IBinder;
import android.os.Parcel;
import android.os.Parcelable;
import android.os.RemoteException;
import android.util.ArraySet;
import android.util.Slog;
import android.util.SparseArray;
import android.view.WindowManager.TransitionType;

@@ -124,6 +127,20 @@ public class RemoteAnimationDefinition implements Parcelable {
        }
    }

    /**
     * Links the death of the runner to the provided death recipient.
     */
    public void linkToDeath(IBinder.DeathRecipient deathRecipient) {
        try {
            for (int i = 0; i < mTransitionAnimationMap.size(); i++) {
                mTransitionAnimationMap.valueAt(i).adapter.getRunner().asBinder()
                        .linkToDeath(deathRecipient, 0 /* flags */);
            }
        } catch (RemoteException e) {
            Slog.e("RemoteAnimationDefinition", "Failed to link to death recipient");
        }
    }

    @Override
    public int describeContents() {
        return 0;
+7 −0
Original line number Diff line number Diff line
@@ -36,6 +36,13 @@ public class ActivityCompat {
        mWrapped.registerRemoteAnimations(definition.getWrapped());
    }

    /**
     * @see Activity#unregisterRemoteAnimations
     */
    public void unregisterRemoteAnimations() {
        mWrapped.unregisterRemoteAnimations();
    }

    /**
     * @see android.view.ViewDebug#dumpv2(View, ByteArrayOutputStream)
     */
+7 −0
Original line number Diff line number Diff line
@@ -6060,6 +6060,13 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A

    void registerRemoteAnimations(RemoteAnimationDefinition definition) {
        mRemoteAnimationDefinition = definition;
        if (definition != null) {
            definition.linkToDeath(this::unregisterRemoteAnimations);
        }
    }

    void unregisterRemoteAnimations() {
        mRemoteAnimationDefinition = null;
    }

    RemoteAnimationDefinition getRemoteAnimationDefinition() {
Loading