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

Commit 2996ef5f authored by Evan Rosky's avatar Evan Rosky
Browse files

Hook up nav-bar attach/detach logic to Shell Transitions

For the Recents gesture animation, the navbar gets attached to
the app while dragging. The actual navbar attach/detach logic
lives in Core, so this change basically hacks the logic into
the core-side of shell transitions. This is ugly and should
be a temporary solution until that behavior can move to Shell.

This also had to add an ugly API on IATM because the lifecycle
of the navbar reparent is different from the transition lifecycle
in this instance because of LiveTiles.

Bug: 188595497
Test: With shell transit enabled, open app, swipe up to recents.
      Observe navbar attached to app during drag and put back
      on screen afterwards. Also, no more crash.
Change-Id: I1aba53314329e3fd7678a7e8a5fc8ffa0294e395
parent d939d3b4
Loading
Loading
Loading
Loading
+13 −0
Original line number Original line Diff line number Diff line
@@ -475,6 +475,19 @@ public class ActivityTaskManager {
        }
        }
    }
    }


    /**
     * Detaches the navigation bar from the app it was attached to during a transition.
     * @hide
     */
    @RequiresPermission(android.Manifest.permission.CONTROL_REMOTE_APP_TRANSITION_ANIMATIONS)
    public void detachNavigationBarFromApp(@NonNull IBinder transition) {
        try {
            getService().detachNavigationBarFromApp(transition);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }

    /**
    /**
     * Information you can retrieve about a root task in the system.
     * Information you can retrieve about a root task in the system.
     * @hide
     * @hide
+6 −0
Original line number Original line Diff line number Diff line
@@ -330,4 +330,10 @@ interface IActivityTaskManager {
     * When the Picture-in-picture state has changed.
     * When the Picture-in-picture state has changed.
     */
     */
    void onPictureInPictureStateChanged(in PictureInPictureUiState pipState);
    void onPictureInPictureStateChanged(in PictureInPictureUiState pipState);

    /**
     * Re-attach navbar to the display during a recents transition.
     * TODO(188595497): Remove this once navbar attachment is in shell.
     */
    void detachNavigationBarFromApp(in IBinder transition);
}
}
+9 −1
Original line number Original line Diff line number Diff line
@@ -466,6 +466,13 @@ public interface WindowManager extends ViewManager {
     */
     */
    int TRANSIT_FLAG_KEYGUARD_LOCKED = 0x40;
    int TRANSIT_FLAG_KEYGUARD_LOCKED = 0x40;


    /**
     * Transition flag: Indicates that this transition is for recents animation.
     * TODO(b/188669821): Remove once special-case logic moves to shell.
     * @hide
     */
    int TRANSIT_FLAG_IS_RECENTS = 0x80;

    /**
    /**
     * @hide
     * @hide
     */
     */
@@ -476,7 +483,8 @@ public interface WindowManager extends ViewManager {
            TRANSIT_FLAG_KEYGUARD_GOING_AWAY_SUBTLE_ANIMATION,
            TRANSIT_FLAG_KEYGUARD_GOING_AWAY_SUBTLE_ANIMATION,
            TRANSIT_FLAG_APP_CRASHED,
            TRANSIT_FLAG_APP_CRASHED,
            TRANSIT_FLAG_OPEN_BEHIND,
            TRANSIT_FLAG_OPEN_BEHIND,
            TRANSIT_FLAG_KEYGUARD_LOCKED
            TRANSIT_FLAG_KEYGUARD_LOCKED,
            TRANSIT_FLAG_IS_RECENTS
    })
    })
    @Retention(RetentionPolicy.SOURCE)
    @Retention(RetentionPolicy.SOURCE)
    @interface TransitionFlags {}
    @interface TransitionFlags {}
+17 −2
Original line number Original line Diff line number Diff line
@@ -25,6 +25,7 @@ import static android.view.WindowManager.TRANSIT_TO_FRONT;
import android.annotation.NonNull;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.Nullable;
import android.annotation.SuppressLint;
import android.annotation.SuppressLint;
import android.app.ActivityTaskManager;
import android.graphics.Rect;
import android.graphics.Rect;
import android.os.IBinder;
import android.os.IBinder;
import android.os.Parcelable;
import android.os.Parcelable;
@@ -135,7 +136,7 @@ public class RemoteTransitionCompat implements Parcelable {
                }
                }
                t.apply();
                t.apply();
                mRecentsSession.setup(controller, info, finishedCallback, pausingTask,
                mRecentsSession.setup(controller, info, finishedCallback, pausingTask,
                        leashMap);
                        leashMap, mToken);
                recents.onAnimationStart(mRecentsSession, apps, wallpapers, new Rect(0, 0, 0, 0),
                recents.onAnimationStart(mRecentsSession, apps, wallpapers, new Rect(0, 0, 0, 0),
                        new Rect());
                        new Rect());
            }
            }
@@ -178,10 +179,11 @@ public class RemoteTransitionCompat implements Parcelable {
        private TransitionInfo mInfo = null;
        private TransitionInfo mInfo = null;
        private SurfaceControl mOpeningLeash = null;
        private SurfaceControl mOpeningLeash = null;
        private ArrayMap<SurfaceControl, SurfaceControl> mLeashMap = null;
        private ArrayMap<SurfaceControl, SurfaceControl> mLeashMap = null;
        private IBinder mTransition = null;


        void setup(RecentsAnimationControllerCompat wrapped, TransitionInfo info,
        void setup(RecentsAnimationControllerCompat wrapped, TransitionInfo info,
                IRemoteTransitionFinishedCallback finishCB, WindowContainerToken pausingTask,
                IRemoteTransitionFinishedCallback finishCB, WindowContainerToken pausingTask,
                ArrayMap<SurfaceControl, SurfaceControl> leashMap) {
                ArrayMap<SurfaceControl, SurfaceControl> leashMap, IBinder transition) {
            if (mInfo != null) {
            if (mInfo != null) {
                throw new IllegalStateException("Trying to run a new recents animation while"
                throw new IllegalStateException("Trying to run a new recents animation while"
                        + " recents is already active.");
                        + " recents is already active.");
@@ -191,6 +193,7 @@ public class RemoteTransitionCompat implements Parcelable {
            mFinishCB = finishCB;
            mFinishCB = finishCB;
            mPausingTask = pausingTask;
            mPausingTask = pausingTask;
            mLeashMap = leashMap;
            mLeashMap = leashMap;
            mTransition = transition;
        }
        }


        @SuppressLint("NewApi")
        @SuppressLint("NewApi")
@@ -298,6 +301,7 @@ public class RemoteTransitionCompat implements Parcelable {
            mInfo = null;
            mInfo = null;
            mOpeningLeash = null;
            mOpeningLeash = null;
            mLeashMap = null;
            mLeashMap = null;
            mTransition = null;
        }
        }


        @Override public void setDeferCancelUntilNextTransition(boolean defer, boolean screenshot) {
        @Override public void setDeferCancelUntilNextTransition(boolean defer, boolean screenshot) {
@@ -318,6 +322,17 @@ public class RemoteTransitionCompat implements Parcelable {
        @Override public boolean removeTask(int taskId) {
        @Override public boolean removeTask(int taskId) {
            return mWrapped != null ? mWrapped.removeTask(taskId) : false;
            return mWrapped != null ? mWrapped.removeTask(taskId) : false;
        }
        }

        /**
         * @see IRecentsAnimationController#detachNavigationBarFromApp
         */
        @Override public void detachNavigationBarFromApp(boolean moveHomeToTop) {
            try {
                ActivityTaskManager.getService().detachNavigationBarFromApp(mTransition);
            } catch (RemoteException e) {
                Log.e(TAG, "Failed to detach the navigation bar from app", e);
            }
        }
    }
    }




+6 −0
Original line number Original line Diff line number Diff line
@@ -28,6 +28,7 @@ import static android.app.ActivityManager.START_RETURN_LOCK_TASK_MODE_VIOLATION;
import static android.app.ActivityManager.START_SUCCESS;
import static android.app.ActivityManager.START_SUCCESS;
import static android.app.ActivityManager.START_TASK_TO_FRONT;
import static android.app.ActivityManager.START_TASK_TO_FRONT;
import static android.app.ActivityTaskManager.INVALID_TASK_ID;
import static android.app.ActivityTaskManager.INVALID_TASK_ID;
import static android.app.WindowConfiguration.ACTIVITY_TYPE_HOME;
import static android.app.WindowConfiguration.WINDOWING_MODE_SPLIT_SCREEN_PRIMARY;
import static android.app.WindowConfiguration.WINDOWING_MODE_SPLIT_SCREEN_PRIMARY;
import static android.app.WindowConfiguration.WINDOWING_MODE_SPLIT_SCREEN_SECONDARY;
import static android.app.WindowConfiguration.WINDOWING_MODE_SPLIT_SCREEN_SECONDARY;
import static android.app.WindowConfiguration.WINDOWING_MODE_UNDEFINED;
import static android.app.WindowConfiguration.WINDOWING_MODE_UNDEFINED;
@@ -1547,6 +1548,11 @@ class ActivityStarter {
            newTransition.setRemoteTransition(remoteTransition);
            newTransition.setRemoteTransition(remoteTransition);
        }
        }
        mService.getTransitionController().collect(r);
        mService.getTransitionController().collect(r);
        // TODO(b/188669821): Remove when navbar reparenting moves to shell
        if (r.getActivityType() == ACTIVITY_TYPE_HOME && r.getOptions() != null
                && r.getOptions().getTransientLaunch()) {
            mService.getTransitionController().setIsLegacyRecents();
        }
        try {
        try {
            mService.deferWindowLayout();
            mService.deferWindowLayout();
            Trace.traceBegin(Trace.TRACE_TAG_WINDOW_MANAGER, "startActivityInner");
            Trace.traceBegin(Trace.TRACE_TAG_WINDOW_MANAGER, "startActivityInner");
Loading