diff --git a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NavBarToHomeTouchController.java b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NavBarToHomeTouchController.java
index 4d3b057..7bfb76a 100644
--- a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NavBarToHomeTouchController.java
+++ b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NavBarToHomeTouchController.java
@@ -48,8 +48,8 @@
 import com.android.launcher3.touch.SingleAxisSwipeDetector;
 import com.android.launcher3.util.TouchController;
 import com.android.quickstep.TaskUtils;
+import com.android.quickstep.TopTaskTracker;
 import com.android.quickstep.util.AnimatorControllerWithResistance;
-import com.android.quickstep.util.AssistantUtilities;
 import com.android.quickstep.util.OverviewToHomeAnim;
 import com.android.quickstep.views.RecentsView;
 
@@ -112,7 +112,8 @@
             return true;
         }
         if (FeatureFlags.ASSISTANT_GIVES_LAUNCHER_FOCUS.get()
-                && AssistantUtilities.isExcludedAssistantRunning()) {
+                && TopTaskTracker.INSTANCE.get(mLauncher).getCachedTopTask(false)
+                        .isExcludedAssistant()) {
             return true;
         }
         return false;
diff --git a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java
index 6e80402..2ae0646 100644
--- a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java
+++ b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java
@@ -102,7 +102,6 @@
 import com.android.quickstep.util.AnimatorControllerWithResistance;
 import com.android.quickstep.util.InputConsumerProxy;
 import com.android.quickstep.util.InputProxyHandlerFactory;
-import com.android.quickstep.util.LauncherSplitScreenListener;
 import com.android.quickstep.util.MotionPauseDetector;
 import com.android.quickstep.util.ProtoTracer;
 import com.android.quickstep.util.RecentsOrientedState;
@@ -114,6 +113,7 @@
 import com.android.quickstep.util.VibratorWrapper;
 import com.android.quickstep.views.RecentsView;
 import com.android.quickstep.views.TaskView;
+import com.android.systemui.shared.recents.model.Task;
 import com.android.systemui.shared.recents.model.ThumbnailData;
 import com.android.systemui.shared.system.ActivityManagerWrapper;
 import com.android.systemui.shared.system.InputConsumerController;
@@ -564,24 +564,12 @@
     }
 
     protected void notifyGestureAnimationStartToRecents() {
-        ActivityManager.RunningTaskInfo[] runningTasks;
+        Task[] runningTasks;
         if (mIsSwipeForStagedSplit) {
-            int[] splitTaskIds =
-                    LauncherSplitScreenListener.INSTANCE.getNoCreate().getRunningSplitTaskIds();
-            runningTasks = new ActivityManager.RunningTaskInfo[splitTaskIds.length];
-            for (int i = 0; i < splitTaskIds.length; i++) {
-                int taskId = splitTaskIds[i];
-                // Order matters here, we want first indexed RunningTaskInfo to be leftTop task
-                for (ActivityManager.RunningTaskInfo rti : mGestureState.getRunningTasks()) {
-                    if (taskId == rti.taskId) {
-                        runningTasks[i] = rti;
-                        break;
-                    }
-
-                }
-            }
+            int[] splitTaskIds = TopTaskTracker.INSTANCE.get(mContext).getRunningSplitTaskIds();
+            runningTasks = mGestureState.getRunningTask().getPlaceholderTasks(splitTaskIds);
         } else {
-            runningTasks = new ActivityManager.RunningTaskInfo[]{mGestureState.getRunningTask()};
+            runningTasks = mGestureState.getRunningTask().getPlaceholderTasks();
         }
         mRecentsView.onGestureAnimationStart(runningTasks, mDeviceState.getRotationTouchHelper());
     }
@@ -801,7 +789,7 @@
             RecentsAnimationTargets targets) {
         super.onRecentsAnimationStart(controller, targets);
         ActiveGestureLog.INSTANCE.addLog("startRecentsAnimationCallback", targets.apps.length);
-        mRemoteTargetHandles = mTargetGluer.assignTargetsForSplitScreen(targets);
+        mRemoteTargetHandles = mTargetGluer.assignTargetsForSplitScreen(mContext, targets);
         mRecentsAnimationController = controller;
         mRecentsAnimationTargets = targets;
 
@@ -1380,7 +1368,7 @@
     private SwipePipToHomeAnimator createWindowAnimationToPip(HomeAnimationFactory homeAnimFactory,
             RemoteAnimationTargetCompat runningTaskTarget, float startProgress) {
         // Directly animate the app to PiP (picture-in-picture) mode
-        final ActivityManager.RunningTaskInfo taskInfo = mGestureState.getRunningTask();
+        final ActivityManager.RunningTaskInfo taskInfo = runningTaskTarget.taskInfo;
         final RecentsOrientedState orientationState = mRemoteTargetHandles[0].getTaskViewSimulator()
                 .getOrientationState();
         final int windowRotation = calculateWindowRotation(runningTaskTarget, orientationState);
@@ -1782,8 +1770,7 @@
                     new PictureInPictureSurfaceTransaction.Builder()
                             .setAlpha(0f)
                             .build();
-            int[] taskIds =
-                        LauncherSplitScreenListener.INSTANCE.getNoCreate().getRunningSplitTaskIds();
+            int[] taskIds = TopTaskTracker.INSTANCE.get(mContext).getRunningSplitTaskIds();
             for (int taskId : taskIds) {
                 mRecentsAnimationController.setFinishTaskTransaction(taskId,
                         tx, null /* overlay */);
diff --git a/quickstep/src/com/android/quickstep/FallbackSwipeHandler.java b/quickstep/src/com/android/quickstep/FallbackSwipeHandler.java
index 9828467..ee5bb44 100644
--- a/quickstep/src/com/android/quickstep/FallbackSwipeHandler.java
+++ b/quickstep/src/com/android/quickstep/FallbackSwipeHandler.java
@@ -30,7 +30,7 @@
 
 import android.animation.ObjectAnimator;
 import android.annotation.TargetApi;
-import android.app.ActivityManager;
+import android.app.ActivityManager.RunningTaskInfo;
 import android.app.ActivityOptions;
 import android.content.ActivityNotFoundException;
 import android.content.Context;
@@ -69,7 +69,6 @@
 import com.android.quickstep.util.TransformParams;
 import com.android.quickstep.util.TransformParams.BuilderProxy;
 import com.android.systemui.shared.recents.model.Task.TaskKey;
-import com.android.systemui.shared.system.ActivityManagerWrapper;
 import com.android.systemui.shared.system.InputConsumerController;
 import com.android.systemui.shared.system.RemoteAnimationTargetCompat;
 import com.android.systemui.shared.system.SyncRtSurfaceTransactionApplierCompat.SurfaceParams;
@@ -109,7 +108,7 @@
         super(context, deviceState, taskAnimationManager, gestureState, touchTimeMs,
                 continuingLastGesture, inputConsumer);
 
-        mRunningOverHome = ActivityManagerWrapper.isHomeTask(mGestureState.getRunningTask());
+        mRunningOverHome = mGestureState.getRunningTask().isHomeTask();
         if (mRunningOverHome) {
             runActionOnRemoteHandles(remoteTargetHandle ->
                     remoteTargetHandle.getTransformParams().setHomeBuilderProxy(
@@ -150,16 +149,17 @@
             return new FallbackPipToHomeAnimationFactory();
         }
         mActiveAnimationFactory = new FallbackHomeAnimationFactory(duration);
-        startHomeIntent(mActiveAnimationFactory);
+        startHomeIntent(mActiveAnimationFactory, runningTaskTarget);
         return mActiveAnimationFactory;
     }
 
     private void startHomeIntent(
-            @Nullable FallbackHomeAnimationFactory gestureContractAnimationFactory) {
+            @Nullable FallbackHomeAnimationFactory gestureContractAnimationFactory,
+            @Nullable RemoteAnimationTargetCompat runningTaskTarget) {
         ActivityOptions options = ActivityOptions.makeCustomAnimation(mContext, 0, 0);
         Intent intent = new Intent(mGestureState.getHomeIntent());
-        if (gestureContractAnimationFactory != null) {
-            gestureContractAnimationFactory.addGestureContract(intent);
+        if (gestureContractAnimationFactory != null && runningTaskTarget != null) {
+            gestureContractAnimationFactory.addGestureContract(intent, runningTaskTarget.taskInfo);
         }
         try {
             mContext.startActivity(intent, options.toBundle());
@@ -187,7 +187,8 @@
             // the PiP task appearing.
             recentsCallback = () -> {
                 callback.run();
-                startHomeIntent(null /* gestureContractAnimationFactory */);
+                startHomeIntent(
+                        null /* gestureContractAnimationFactory */, null /* runningTaskTarget */);
             };
         } else {
             recentsCallback = callback;
@@ -212,7 +213,7 @@
         if (mRunningOverHome) {
             if (DisplayController.getNavigationMode(mContext).hasGestures) {
                 mRecentsView.onGestureAnimationStartOnHome(
-                        new ActivityManager.RunningTaskInfo[]{mGestureState.getRunningTask()},
+                        mGestureState.getRunningTask().getPlaceholderTasks(),
                         mDeviceState.getRotationTouchHelper());
             }
         } else {
@@ -396,12 +397,12 @@
             }
         }
 
-        private void addGestureContract(Intent intent) {
-            if (mRunningOverHome || mGestureState.getRunningTask() == null) {
+        private void addGestureContract(Intent intent, RunningTaskInfo runningTaskInfo) {
+            if (mRunningOverHome || runningTaskInfo == null) {
                 return;
             }
 
-            TaskKey key = new TaskKey(mGestureState.getRunningTask());
+            TaskKey key = new TaskKey(runningTaskInfo);
             if (key.getComponent() != null) {
                 if (sMessageReceiver == null) {
                     sMessageReceiver = new StaticMessageReceiver();
diff --git a/quickstep/src/com/android/quickstep/GestureState.java b/quickstep/src/com/android/quickstep/GestureState.java
index ed0623d..3b52e91 100644
--- a/quickstep/src/com/android/quickstep/GestureState.java
+++ b/quickstep/src/com/android/quickstep/GestureState.java
@@ -22,7 +22,6 @@
 
 import android.annotation.Nullable;
 import android.annotation.TargetApi;
-import android.app.ActivityManager;
 import android.content.Intent;
 import android.os.Build;
 
@@ -30,6 +29,7 @@
 import com.android.launcher3.statemanager.StatefulActivity;
 import com.android.launcher3.tracing.GestureStateProto;
 import com.android.launcher3.tracing.SwipeHandlerProto;
+import com.android.quickstep.TopTaskTracker.CachedTaskInfo;
 import com.android.quickstep.util.ActiveGestureLog;
 import com.android.systemui.shared.recents.model.ThumbnailData;
 import com.android.systemui.shared.system.RemoteAnimationTargetCompat;
@@ -135,8 +135,7 @@
     private final MultiStateCallback mStateCallback;
     private final int mGestureId;
 
-    private ActivityManager.RunningTaskInfo mRunningTask;
-    private ActivityManager.RunningTaskInfo[] mRunningTasks;
+    private CachedTaskInfo mRunningTask;
     private GestureEndTarget mEndTarget;
     private RemoteAnimationTargetCompat mLastAppearedTaskTarget;
     private Set<Integer> mPreviouslyAppearedTaskIds = new HashSet<>();
@@ -232,42 +231,25 @@
     /**
      * @return the running task for this gesture.
      */
-    public ActivityManager.RunningTaskInfo getRunningTask() {
+    public CachedTaskInfo getRunningTask() {
         return mRunningTask;
     }
 
     /**
-     * This will array will contain the task returned by {@link #getRunningTask()}
-     * @return the running tasks for this gesture.
-     */
-    public ActivityManager.RunningTaskInfo[] getRunningTasks() {
-        return mRunningTasks;
-    }
-
-    /**
      * @return the running task id for this gesture.
      */
     public int getRunningTaskId() {
-        return mRunningTask != null ? mRunningTask.taskId : -1;
+        return mRunningTask != null ? mRunningTask.getTaskId() : -1;
     }
 
     /**
      * Updates the running task for the gesture to be the given {@param runningTask}.
      */
-    public void updateRunningTask(ActivityManager.RunningTaskInfo runningTask) {
+    public void updateRunningTask(CachedTaskInfo runningTask) {
         mRunningTask = runningTask;
     }
 
     /**
-     * TODO(b/210903248) refactor to consolidate w/ method above
-     * Updates the running task for the gesture to be the given {@param runningTask}.
-     */
-    public void updateRunningTasks(ActivityManager.RunningTaskInfo[] runningTasks) {
-        mRunningTasks = runningTasks;
-        updateRunningTask(runningTasks[0]);
-    }
-
-    /**
      * Updates the last task that appeared during this gesture.
      */
     public void updateLastAppearedTaskTarget(RemoteAnimationTargetCompat lastAppearedTaskTarget) {
@@ -339,7 +321,7 @@
      * user controlled gesture.
      */
     public void setHandlingAtomicEvent(boolean handlingAtomicEvent) {
-        mHandlingAtomicEvent = true;
+        mHandlingAtomicEvent = handlingAtomicEvent;
     }
 
     /**
diff --git a/quickstep/src/com/android/quickstep/RecentsAnimationDeviceState.java b/quickstep/src/com/android/quickstep/RecentsAnimationDeviceState.java
index 7ad60bb..920ed71 100644
--- a/quickstep/src/com/android/quickstep/RecentsAnimationDeviceState.java
+++ b/quickstep/src/com/android/quickstep/RecentsAnimationDeviceState.java
@@ -45,14 +45,11 @@
 import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_SCREEN_PINNING;
 import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_STATUS_BAR_KEYGUARD_SHOWING_OCCLUDED;
 
-import android.app.ActivityManager;
 import android.app.ActivityTaskManager;
 import android.content.BroadcastReceiver;
-import android.content.ComponentName;
 import android.content.Context;
 import android.content.Intent;
 import android.content.IntentFilter;
-import android.content.res.Resources;
 import android.graphics.Region;
 import android.inputmethodservice.InputMethodService;
 import android.net.Uri;
@@ -61,18 +58,17 @@
 import android.os.SystemProperties;
 import android.os.UserManager;
 import android.provider.Settings;
-import android.text.TextUtils;
 import android.view.MotionEvent;
 
 import androidx.annotation.BinderThread;
 
-import com.android.launcher3.R;
 import com.android.launcher3.Utilities;
 import com.android.launcher3.util.DisplayController;
 import com.android.launcher3.util.DisplayController.DisplayInfoChangeListener;
 import com.android.launcher3.util.DisplayController.Info;
 import com.android.launcher3.util.DisplayController.NavigationMode;
 import com.android.launcher3.util.SettingsCache;
+import com.android.quickstep.TopTaskTracker.CachedTaskInfo;
 import com.android.quickstep.util.NavBarPosition;
 import com.android.systemui.shared.system.ActivityManagerWrapper;
 import com.android.systemui.shared.system.QuickStepContract;
@@ -83,7 +79,6 @@
 
 import java.io.PrintWriter;
 import java.util.ArrayList;
-import java.util.List;
 
 /**
  * Manages the state of the system during a swipe up gesture.
@@ -97,7 +92,6 @@
     private final int mDisplayId;
     private final RotationTouchHelper mRotationTouchHelper;
     private final TaskStackChangeListener mPipListener;
-    private final List<ComponentName> mGestureBlockedActivities;
     // Cache for better performance since it doesn't change at runtime.
     private final boolean mCanImeRenderGesturalNavButtons =
             InputMethodService.canImeRenderGesturalNavButtons();
@@ -129,6 +123,7 @@
         }
     };
 
+    private int mGestureBlockingTaskId = -1;
     private Region mExclusionRegion;
     private SystemGestureExclusionListenerCompat mExclusionListener;
 
@@ -178,22 +173,6 @@
         onDisplayInfoChanged(context, mDisplayController.getInfo(), CHANGE_ALL);
         runOnDestroy(() -> mDisplayController.removeChangeListener(this));
 
-        // Add any blocked activities
-        String[] blockingActivities;
-        try {
-            blockingActivities =
-                    context.getResources().getStringArray(R.array.gesture_blocking_activities);
-        } catch (Resources.NotFoundException e) {
-            blockingActivities = new String[0];
-        }
-        mGestureBlockedActivities = new ArrayList<>(blockingActivities.length);
-        for (String blockingActivity : blockingActivities) {
-            if (!TextUtils.isEmpty(blockingActivity)) {
-                mGestureBlockedActivities.add(
-                        ComponentName.unflattenFromString(blockingActivity));
-            }
-        }
-
         SettingsCache settingsCache = SettingsCache.INSTANCE.get(mContext);
         if (mIsOneHandedModeSupported) {
             Uri oneHandedUri = Settings.Secure.getUriFor(ONE_HANDED_ENABLED);
@@ -367,11 +346,17 @@
     }
 
     /**
-     * @return whether the given running task info matches the gesture-blocked activity.
+     * Sets the task id where gestures should be blocked
      */
-    public boolean isGestureBlockedActivity(ActivityManager.RunningTaskInfo runningTaskInfo) {
-        return runningTaskInfo != null
-                && mGestureBlockedActivities.contains(runningTaskInfo.topActivity);
+    public void setGestureBlockingTaskId(int taskId) {
+        mGestureBlockingTaskId = taskId;
+    }
+
+    /**
+     * @return whether the given running task info matches the gesture-blocked task.
+     */
+    public boolean isGestureBlockedTask(CachedTaskInfo taskInfo) {
+        return taskInfo != null && taskInfo.getTaskId() == mGestureBlockingTaskId;
     }
 
     /**
diff --git a/quickstep/src/com/android/quickstep/RemoteTargetGluer.java b/quickstep/src/com/android/quickstep/RemoteTargetGluer.java
index afb4d4d..c3ea256 100644
--- a/quickstep/src/com/android/quickstep/RemoteTargetGluer.java
+++ b/quickstep/src/com/android/quickstep/RemoteTargetGluer.java
@@ -22,7 +22,6 @@
 
 import com.android.launcher3.util.SplitConfigurationOptions.StagedSplitBounds;
 import com.android.quickstep.util.AnimatorControllerWithResistance;
-import com.android.quickstep.util.LauncherSplitScreenListener;
 import com.android.quickstep.util.TaskViewSimulator;
 import com.android.quickstep.util.TransformParams;
 import com.android.systemui.shared.system.RemoteAnimationTargetCompat;
@@ -50,8 +49,7 @@
      * running tasks
      */
     public RemoteTargetGluer(Context context, BaseActivityInterface sizingStrategy) {
-        int[] splitIds = LauncherSplitScreenListener.INSTANCE.getNoCreate()
-                .getRunningSplitTaskIds();
+        int[] splitIds = TopTaskTracker.INSTANCE.get(context).getRunningSplitTaskIds();
         mRemoteTargetHandles = createHandles(context, sizingStrategy, splitIds.length == 2 ? 2 : 1);
     }
 
@@ -73,7 +71,7 @@
      * Length of targets.apps should match that of {@link #mRemoteTargetHandles}.
      *
      * If split screen may be active when this is called, you might want to use
-     * {@link #assignTargetsForSplitScreen(RemoteAnimationTargets)}
+     * {@link #assignTargetsForSplitScreen(Context, RemoteAnimationTargets)}
      */
     public RemoteTargetHandle[] assignTargets(RemoteAnimationTargets targets) {
         for (int i = 0; i < mRemoteTargetHandles.length; i++) {
@@ -90,9 +88,9 @@
      * apps in targets.apps to that of the _active_ split screened tasks.
      * See {@link #assignTargetsForSplitScreen(RemoteAnimationTargets, int[])}
      */
-    public RemoteTargetHandle[] assignTargetsForSplitScreen(RemoteAnimationTargets targets) {
-        int[] splitIds = LauncherSplitScreenListener.INSTANCE.getNoCreate()
-                .getRunningSplitTaskIds();
+    public RemoteTargetHandle[] assignTargetsForSplitScreen(
+            Context context, RemoteAnimationTargets targets) {
+        int[] splitIds = TopTaskTracker.INSTANCE.get(context).getRunningSplitTaskIds();
         return assignTargetsForSplitScreen(targets, splitIds);
     }
 
diff --git a/quickstep/src/com/android/quickstep/SwipeUpAnimationLogic.java b/quickstep/src/com/android/quickstep/SwipeUpAnimationLogic.java
index 8862073..088e1cf 100644
--- a/quickstep/src/com/android/quickstep/SwipeUpAnimationLogic.java
+++ b/quickstep/src/com/android/quickstep/SwipeUpAnimationLogic.java
@@ -37,7 +37,6 @@
 import com.android.launcher3.touch.PagedOrientationHandler;
 import com.android.quickstep.RemoteTargetGluer.RemoteTargetHandle;
 import com.android.quickstep.util.AnimatorControllerWithResistance;
-import com.android.quickstep.util.LauncherSplitScreenListener;
 import com.android.quickstep.util.RectFSpringAnim;
 import com.android.quickstep.util.TaskViewSimulator;
 import com.android.quickstep.util.TransformParams;
@@ -82,8 +81,7 @@
         mGestureState = gestureState;
 
         mIsSwipeForStagedSplit = ENABLE_SPLIT_SELECT.get() &&
-                LauncherSplitScreenListener.INSTANCE.getNoCreate()
-                        .getRunningSplitTaskIds().length > 1;
+                TopTaskTracker.INSTANCE.get(context).getRunningSplitTaskIds().length > 1;
 
         mTargetGluer = new RemoteTargetGluer(mContext, mGestureState.getActivityInterface());
         mRemoteTargetHandles = mTargetGluer.getRemoteTargetHandles();
diff --git a/quickstep/src/com/android/quickstep/TaskAnimationManager.java b/quickstep/src/com/android/quickstep/TaskAnimationManager.java
index 4bb2400..b8334a9 100644
--- a/quickstep/src/com/android/quickstep/TaskAnimationManager.java
+++ b/quickstep/src/com/android/quickstep/TaskAnimationManager.java
@@ -35,6 +35,7 @@
 
 import com.android.launcher3.Utilities;
 import com.android.launcher3.config.FeatureFlags;
+import com.android.quickstep.TopTaskTracker.CachedTaskInfo;
 import com.android.quickstep.views.RecentsView;
 import com.android.systemui.shared.recents.model.ThumbnailData;
 import com.android.systemui.shared.system.ActivityManagerWrapper;
@@ -234,9 +235,8 @@
             // Allowing to pause Home if Home is top activity and Recents is not Home. So when user
             // start home when recents animation is playing, the home activity can be resumed again
             // to let the transition controller collect Home activity.
-            ActivityManager.RunningTaskInfo rti = gestureState.getRunningTask();
-            boolean homeIsOnTop = rti != null && rti.topActivity != null
-                    && rti.topActivity.equals(gestureState.getHomeIntent().getComponent());
+            CachedTaskInfo cti = gestureState.getRunningTask();
+            boolean homeIsOnTop = cti != null && cti.isHomeTask();
             if (!homeIsOnTop) {
                 options.setTransientLaunch();
             }
diff --git a/quickstep/src/com/android/quickstep/TopTaskTracker.java b/quickstep/src/com/android/quickstep/TopTaskTracker.java
new file mode 100644
index 0000000..80bc329
--- /dev/null
+++ b/quickstep/src/com/android/quickstep/TopTaskTracker.java
@@ -0,0 +1,248 @@
+/*
+ * 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 com.android.quickstep;
+
+import static android.app.WindowConfiguration.ACTIVITY_TYPE_HOME;
+import static android.content.Intent.ACTION_CHOOSER;
+import static android.content.Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS;
+
+import static com.android.launcher3.util.SplitConfigurationOptions.STAGE_POSITION_TOP_OR_LEFT;
+import static com.android.systemui.shared.system.RemoteAnimationTargetCompat.ACTIVITY_TYPE_ASSISTANT;
+
+import android.app.ActivityManager.RunningTaskInfo;
+import android.content.Context;
+
+import androidx.annotation.UiThread;
+
+import com.android.launcher3.util.MainThreadInitializedObject;
+import com.android.launcher3.util.SplitConfigurationOptions;
+import com.android.launcher3.util.SplitConfigurationOptions.StagePosition;
+import com.android.launcher3.util.SplitConfigurationOptions.StageType;
+import com.android.launcher3.util.SplitConfigurationOptions.StagedSplitTaskPosition;
+import com.android.launcher3.util.TraceHelper;
+import com.android.systemui.shared.recents.model.Task;
+import com.android.systemui.shared.recents.model.Task.TaskKey;
+import com.android.systemui.shared.system.ActivityManagerWrapper;
+import com.android.systemui.shared.system.TaskStackChangeListener;
+import com.android.systemui.shared.system.TaskStackChangeListeners;
+import com.android.wm.shell.splitscreen.ISplitScreenListener;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+
+/**
+ * This class tracked the top-most task and  some 'approximate' task history to allow faster
+ * system state estimation during touch interaction
+ */
+public class TopTaskTracker extends ISplitScreenListener.Stub implements TaskStackChangeListener {
+
+    public static MainThreadInitializedObject<TopTaskTracker> INSTANCE =
+            new MainThreadInitializedObject<>(TopTaskTracker::new);
+
+    private static final int HISTORY_SIZE = 5;
+
+    // Ordered list with first item being the most recent task.
+    private final LinkedList<RunningTaskInfo> mOrderedTaskList = new LinkedList<>();
+
+    private final StagedSplitTaskPosition mMainStagePosition = new StagedSplitTaskPosition();
+    private final StagedSplitTaskPosition mSideStagePosition = new StagedSplitTaskPosition();
+
+    private TopTaskTracker(Context context) {
+        mMainStagePosition.stageType = SplitConfigurationOptions.STAGE_TYPE_MAIN;
+        mSideStagePosition.stageType = SplitConfigurationOptions.STAGE_TYPE_SIDE;
+
+        TaskStackChangeListeners.getInstance().registerTaskStackListener(this);
+        SystemUiProxy.INSTANCE.get(context).registerSplitScreenListener(this);
+    }
+
+    @Override
+    public void onTaskRemoved(int taskId) {
+        mOrderedTaskList.removeIf(rto -> rto.taskId == taskId);
+    }
+
+    @Override
+    public void onTaskMovedToFront(RunningTaskInfo taskInfo) {
+        mOrderedTaskList.removeIf(rto -> rto.taskId == taskInfo.taskId);
+        mOrderedTaskList.addFirst(taskInfo);
+        if (mOrderedTaskList.size() >= HISTORY_SIZE) {
+            // If we grow in size, remove the last taskInfo which is not part of the split task.
+            Iterator<RunningTaskInfo> itr = mOrderedTaskList.descendingIterator();
+            while (itr.hasNext()) {
+                RunningTaskInfo info = itr.next();
+                if (info.taskId != taskInfo.taskId
+                        && info.taskId != mMainStagePosition.taskId
+                        && info.taskId != mSideStagePosition.taskId) {
+                    itr.remove();
+                    return;
+                }
+            }
+        }
+    }
+
+    @Override
+    public void onStagePositionChanged(@StageType int stage, @StagePosition int position) {
+        if (stage == SplitConfigurationOptions.STAGE_TYPE_MAIN) {
+            mMainStagePosition.stagePosition = position;
+        } else {
+            mSideStagePosition.stagePosition = position;
+        }
+    }
+
+    @Override
+    public void onTaskStageChanged(int taskId, @StageType int stage, boolean visible) {
+        // If task is not visible but we are tracking it, stop tracking it
+        if (!visible) {
+            if (mMainStagePosition.taskId == taskId) {
+                resetTaskId(mMainStagePosition);
+            } else if (mSideStagePosition.taskId == taskId) {
+                resetTaskId(mSideStagePosition);
+            } // else it's an un-tracked child
+            return;
+        }
+
+        // If stage has moved to undefined, stop tracking the task
+        if (stage == SplitConfigurationOptions.STAGE_TYPE_UNDEFINED) {
+            resetTaskId(taskId == mMainStagePosition.taskId
+                    ? mMainStagePosition : mSideStagePosition);
+            return;
+        }
+
+        if (stage == SplitConfigurationOptions.STAGE_TYPE_MAIN) {
+            mMainStagePosition.taskId = taskId;
+        } else {
+            mSideStagePosition.taskId = taskId;
+        }
+    }
+
+    private void resetTaskId(StagedSplitTaskPosition taskPosition) {
+        taskPosition.taskId = -1;
+    }
+
+    /**
+     * @return index 0 will be task in left/top position, index 1 in right/bottom position.
+     *         Will return empty array if device is not in staged split
+     */
+    public int[] getRunningSplitTaskIds() {
+        if (mMainStagePosition.taskId == -1 || mSideStagePosition.taskId == -1) {
+            return new int[]{};
+        }
+        int[] out = new int[2];
+        if (mMainStagePosition.stagePosition == STAGE_POSITION_TOP_OR_LEFT) {
+            out[0] = mMainStagePosition.taskId;
+            out[1] = mSideStagePosition.taskId;
+        } else {
+            out[1] = mMainStagePosition.taskId;
+            out[0] = mSideStagePosition.taskId;
+        }
+        return out;
+    }
+
+
+    /**
+     * Returns the CachedTaskInfo for the top most task
+     */
+    @UiThread
+    public CachedTaskInfo getCachedTopTask(boolean filterOnlyVisibleRecents) {
+        if (filterOnlyVisibleRecents) {
+            // Since we only know about the top most task, any filtering may not be applied on the
+            // cache. The second to top task may change while the top task is still the same.
+            RunningTaskInfo[] tasks = TraceHelper.allowIpcs("getCachedTopTask.true", () ->
+                    ActivityManagerWrapper.getInstance().getRunningTasks(true));
+            return new CachedTaskInfo(Arrays.asList(tasks));
+        }
+
+        if (mOrderedTaskList.isEmpty()) {
+            RunningTaskInfo[] tasks = TraceHelper.allowIpcs("getCachedTopTask.false", () ->
+                    ActivityManagerWrapper.getInstance().getRunningTasks(
+                            false /* filterOnlyVisibleRecents */));
+            Collections.addAll(mOrderedTaskList, tasks);
+        }
+        return new CachedTaskInfo(new ArrayList<>(mOrderedTaskList));
+    }
+
+    /**
+     * Class to provide information about a task which can be safely cached and do not change
+     * during the lifecycle of the task.
+     */
+    public static class CachedTaskInfo {
+
+        private final RunningTaskInfo mTopTask;
+        private final List<RunningTaskInfo> mAllCachedTasks;
+
+        CachedTaskInfo(List<RunningTaskInfo> allCachedTasks) {
+            mAllCachedTasks = allCachedTasks;
+            mTopTask = allCachedTasks.get(0);
+        }
+
+        public int getTaskId() {
+            return mTopTask.taskId;
+        }
+
+        /**
+         * Returns true if the root of the task chooser activity
+         */
+        public boolean isRootChooseActivity() {
+            return ACTION_CHOOSER.equals(mTopTask.baseIntent.getAction());
+        }
+
+        /**
+         * Returns true if the given task holds an Assistant activity that is excluded from recents
+         */
+        public boolean isExcludedAssistant() {
+            return mTopTask.configuration.windowConfiguration
+                    .getActivityType() == ACTIVITY_TYPE_ASSISTANT
+                    && (mTopTask.baseIntent.getFlags() & FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS) != 0;
+        }
+
+        /**
+         * Returns true if this represents the HOME task
+         */
+        public boolean isHomeTask() {
+            return mTopTask.configuration.windowConfiguration
+                    .getActivityType() == ACTIVITY_TYPE_HOME;
+        }
+
+        /**
+         * Returns {@link Task} array which can be used as a placeholder until the true object
+         * is loaded by the model
+         */
+        public Task[] getPlaceholderTasks() {
+            return new Task[] {Task.from(new TaskKey(mTopTask), mTopTask, false)};
+        }
+
+        /**
+         * Returns {@link Task} array corresponding to the provided task ids which can be used as a
+         * placeholder until the true object is loaded by the model
+         */
+        public Task[] getPlaceholderTasks(int[] taskIds) {
+            Task[] result = new Task[taskIds.length];
+            for (int i = 0; i < taskIds.length; i++) {
+                final int index = i;
+                int taskId = taskIds[i];
+                mAllCachedTasks.forEach(rti -> {
+                    if (rti.taskId == taskId) {
+                        result[index] = Task.from(new TaskKey(rti), rti, false);
+                    }
+                });
+            }
+            return result;
+        }
+    }
+}
diff --git a/quickstep/src/com/android/quickstep/TouchInteractionService.java b/quickstep/src/com/android/quickstep/TouchInteractionService.java
index 3206825..0078d55 100644
--- a/quickstep/src/com/android/quickstep/TouchInteractionService.java
+++ b/quickstep/src/com/android/quickstep/TouchInteractionService.java
@@ -15,7 +15,6 @@
  */
 package com.android.quickstep;
 
-import static android.content.Intent.ACTION_CHOOSER;
 import static android.view.MotionEvent.ACTION_CANCEL;
 import static android.view.MotionEvent.ACTION_DOWN;
 import static android.view.MotionEvent.ACTION_UP;
@@ -41,7 +40,6 @@
 import android.app.PendingIntent;
 import android.app.RemoteAction;
 import android.app.Service;
-import android.content.ComponentName;
 import android.content.Intent;
 import android.content.SharedPreferences;
 import android.content.res.Configuration;
@@ -95,8 +93,6 @@
 import com.android.quickstep.inputconsumers.SysUiOverlayInputConsumer;
 import com.android.quickstep.inputconsumers.TaskbarStashInputConsumer;
 import com.android.quickstep.util.ActiveGestureLog;
-import com.android.quickstep.util.AssistantUtilities;
-import com.android.quickstep.util.LauncherSplitScreenListener;
 import com.android.quickstep.util.ProtoTracer;
 import com.android.quickstep.util.ProxyScreenStatusProvider;
 import com.android.quickstep.util.SplitScreenBounds;
@@ -314,6 +310,13 @@
         public void setSwipeUpProxy(Function<GestureState, AnimatedFloat> proxy) {
             mSwipeUpProxyProvider = proxy != null ? proxy : (i -> null);
         }
+
+        /**
+         * Sets the task id where gestures should be blocked
+         */
+        public void setGestureBlockedTaskId(int taskId) {
+            mDeviceState.setGestureBlockingTaskId(taskId);
+        }
     }
 
     private static boolean sConnected = false;
@@ -369,7 +372,6 @@
         mDeviceState.addNavigationModeChangedCallback(this::onNavigationModeChanged);
 
         ProtoTracer.INSTANCE.get(this).add(this);
-        LauncherSplitScreenListener.INSTANCE.get(this).init();
         sConnected = true;
     }
 
@@ -419,6 +421,9 @@
         onSystemUiFlagsChanged(mDeviceState.getSystemUiStateFlags());
         onAssistantVisibilityChanged();
 
+        // Initialize the task tracker
+        TopTaskTracker.INSTANCE.get(this);
+
         // Temporarily disable model preload
         // new ModelPreload().start(this);
         mBackGestureNotificationCounter = Math.max(0, Utilities.getDevicePrefs(this)
@@ -531,7 +536,6 @@
         getSystemService(AccessibilityManager.class)
                 .unregisterSystemAction(SYSTEM_ACTION_ID_ALL_APPS);
 
-        LauncherSplitScreenListener.INSTANCE.get(this).destroy();
         mTaskbarManager.destroy();
         sConnected = false;
         super.onDestroy();
@@ -633,7 +637,7 @@
 
     private InputConsumer tryCreateAssistantInputConsumer(InputConsumer base,
             GestureState gestureState, MotionEvent motionEvent) {
-        return mDeviceState.isGestureBlockedActivity(gestureState.getRunningTask())
+        return mDeviceState.isGestureBlockedTask(gestureState.getRunningTask())
                 ? base
                 : new AssistantInputConsumer(this, gestureState, base, mInputMonitorCompat,
                         mDeviceState, motionEvent);
@@ -648,8 +652,8 @@
             gestureState.updatePreviouslyAppearedTaskIds(
                     previousGestureState.getPreviouslyAppearedTaskIds());
         } else {
-            gestureState.updateRunningTasks(TraceHelper.allowIpcs("getRunningTask.0",
-                    () -> mAM.getRunningTasks(false /* filterOnlyVisibleRecents */)));
+            gestureState.updateRunningTask(
+                    TopTaskTracker.INSTANCE.get(this).getCachedTopTask(false));
         }
         return gestureState;
     }
@@ -743,17 +747,14 @@
         // Use overview input consumer for sharesheets on top of home.
         boolean forceOverviewInputConsumer = gestureState.getActivityInterface().isStarted()
                 && gestureState.getRunningTask() != null
-                && ACTION_CHOOSER.equals(gestureState.getRunningTask().baseIntent.getAction());
-        if (AssistantUtilities.isExcludedAssistant(gestureState.getRunningTask())) {
+                && gestureState.getRunningTask().isRootChooseActivity();
+        if (gestureState.getRunningTask() != null
+                && gestureState.getRunningTask().isExcludedAssistant()) {
             // In the case where we are in the excluded assistant state, ignore it and treat the
             // running activity as the task behind the assistant
-            gestureState.updateRunningTask(TraceHelper.allowIpcs("getRunningTask.assistant",
-                    () -> mAM.getRunningTask(true /* filterOnlyVisibleRecents */)));
-            ComponentName homeComponent = mOverviewComponentObserver.getHomeIntent().getComponent();
-            ComponentName runningComponent =
-                    gestureState.getRunningTask().baseIntent.getComponent();
-            forceOverviewInputConsumer =
-                    runningComponent != null && runningComponent.equals(homeComponent);
+            gestureState.updateRunningTask(TopTaskTracker.INSTANCE.get(this)
+                    .getCachedTopTask(true /* filterOnlyVisibleRecents */));
+            forceOverviewInputConsumer = gestureState.getRunningTask().isHomeTask();
         }
 
         if (ENABLE_QUICKSTEP_LIVE_TILE.get()
@@ -770,7 +771,7 @@
                 || forceOverviewInputConsumer) {
             return createOverviewInputConsumer(
                     previousGestureState, gestureState, event, forceOverviewInputConsumer);
-        } else if (mDeviceState.isGestureBlockedActivity(gestureState.getRunningTask())) {
+        } else if (mDeviceState.isGestureBlockedTask(gestureState.getRunningTask())) {
             return getDefaultInputConsumer();
         } else {
             return createOtherActivityInputConsumer(gestureState, event);
diff --git a/quickstep/src/com/android/quickstep/fallback/FallbackRecentsView.java b/quickstep/src/com/android/quickstep/fallback/FallbackRecentsView.java
index 48af802..c9ee2db 100644
--- a/quickstep/src/com/android/quickstep/fallback/FallbackRecentsView.java
+++ b/quickstep/src/com/android/quickstep/fallback/FallbackRecentsView.java
@@ -24,7 +24,6 @@
 
 import android.animation.AnimatorSet;
 import android.annotation.TargetApi;
-import android.app.ActivityManager.RunningTaskInfo;
 import android.content.Context;
 import android.os.Build;
 import android.util.AttributeSet;
@@ -50,7 +49,6 @@
 import com.android.quickstep.views.RecentsView;
 import com.android.quickstep.views.TaskView;
 import com.android.systemui.shared.recents.model.Task;
-import com.android.systemui.shared.recents.model.Task.TaskKey;
 
 import java.util.ArrayList;
 
@@ -58,7 +56,7 @@
 public class FallbackRecentsView extends RecentsView<RecentsActivity, RecentsState>
         implements StateListener<RecentsState> {
 
-    private RunningTaskInfo mHomeTaskInfo;
+    private Task mHomeTask;
 
     public FallbackRecentsView(Context context, AttributeSet attrs) {
         this(context, attrs, 0);
@@ -87,12 +85,12 @@
      * to the home task. This allows us to handle quick-switch similarly to a quick-switching
      * from a foreground task.
      */
-    public void onGestureAnimationStartOnHome(RunningTaskInfo[] homeTaskInfo,
+    public void onGestureAnimationStartOnHome(Task[] homeTask,
             RotationTouchHelper rotationTouchHelper) {
         // TODO(b/195607777) General fallback love, but this might be correct
         //  Home task should be defined as the front-most task info I think?
-        mHomeTaskInfo = homeTaskInfo[0];
-        onGestureAnimationStart(homeTaskInfo, rotationTouchHelper);
+        mHomeTask = homeTask[0];
+        onGestureAnimationStart(homeTask, rotationTouchHelper);
     }
 
     /**
@@ -105,8 +103,8 @@
             @Nullable AnimatorSet animatorSet, GestureState.GestureEndTarget endTarget,
             TaskViewSimulator[] taskViewSimulators) {
         super.onPrepareGestureEndAnimation(animatorSet, endTarget, taskViewSimulators);
-        if (mHomeTaskInfo != null && endTarget == RECENTS && animatorSet != null) {
-            TaskView tv = getTaskViewByTaskId(mHomeTaskInfo.taskId);
+        if (mHomeTask != null && endTarget == RECENTS && animatorSet != null) {
+            TaskView tv = getTaskViewByTaskId(mHomeTask.key.id);
             if (tv != null) {
                 PendingAnimation pa = createTaskDismissAnimation(tv, true, false, 150,
                         false /* dismissingForSplitSelection*/);
@@ -131,8 +129,8 @@
     public void setCurrentTask(int runningTaskViewId) {
         super.setCurrentTask(runningTaskViewId);
         int runningTaskId = getTaskIdsForRunningTaskView()[0];
-        if (mHomeTaskInfo != null && mHomeTaskInfo.taskId != runningTaskId) {
-            mHomeTaskInfo = null;
+        if (mHomeTask != null && mHomeTask.key.id != runningTaskId) {
+            mHomeTask = null;
             setRunningTaskHidden(false);
         }
     }
@@ -140,26 +138,26 @@
     @Nullable
     @Override
     protected TaskView getHomeTaskView() {
-        return mHomeTaskInfo != null ? getTaskViewByTaskId(mHomeTaskInfo.taskId) : null;
+        return mHomeTask != null ? getTaskViewByTaskId(mHomeTask.key.id) : null;
     }
 
     @Override
-    protected boolean shouldAddStubTaskView(RunningTaskInfo[] runningTaskInfos) {
-        if (runningTaskInfos.length > 1) {
+    protected boolean shouldAddStubTaskView(Task[] runningTasks) {
+        if (runningTasks.length > 1) {
             // can't be in split screen w/ home task
-            return super.shouldAddStubTaskView(runningTaskInfos);
+            return super.shouldAddStubTaskView(runningTasks);
         }
 
-        RunningTaskInfo runningTaskInfo = runningTaskInfos[0];
-        if (mHomeTaskInfo != null && runningTaskInfo != null &&
-                mHomeTaskInfo.taskId == runningTaskInfo.taskId
+        Task runningTask = runningTasks[0];
+        if (mHomeTask != null && runningTask != null
+                && mHomeTask.key.id == runningTask.key.id
                 && getTaskViewCount() == 0 && mLoadPlanEverApplied) {
             // Do not add a stub task if we are running over home with empty recents, so that we
             // show the empty recents message instead of showing a stub task and later removing it.
             // Ignore empty task signal if applyLoadPlan has never run.
             return false;
         }
-        return super.shouldAddStubTaskView(runningTaskInfos);
+        return super.shouldAddStubTaskView(runningTasks);
     }
 
     @Override
@@ -169,7 +167,7 @@
         // track the index of the next task appropriately, as if we are switching on any other app.
         // TODO(b/195607777) Confirm home task info is front-most task and not mixed in with others
         int runningTaskId = getTaskIdsForRunningTaskView()[0];
-        if (mHomeTaskInfo != null && mHomeTaskInfo.taskId == runningTaskId 
+        if (mHomeTask != null && mHomeTask.key.id == runningTaskId
                 && !taskGroups.isEmpty()) {
             // Check if the task list has running task
             boolean found = false;
@@ -182,9 +180,7 @@
             if (!found) {
                 ArrayList<GroupTask> newList = new ArrayList<>(taskGroups.size() + 1);
                 newList.addAll(taskGroups);
-                newList.add(new GroupTask(
-                        Task.from(new TaskKey(mHomeTaskInfo), mHomeTaskInfo, false),
-                        null, null));
+                newList.add(new GroupTask(mHomeTask, null, null));
                 taskGroups = newList;
             }
         }
@@ -193,7 +189,7 @@
 
     @Override
     public void setRunningTaskHidden(boolean isHidden) {
-        if (mHomeTaskInfo != null) {
+        if (mHomeTask != null) {
             // Always keep the home task hidden
             isHidden = true;
         }
diff --git a/quickstep/src/com/android/quickstep/interaction/AllSetActivity.java b/quickstep/src/com/android/quickstep/interaction/AllSetActivity.java
index 5ef9a9b..db19c45 100644
--- a/quickstep/src/com/android/quickstep/interaction/AllSetActivity.java
+++ b/quickstep/src/com/android/quickstep/interaction/AllSetActivity.java
@@ -21,7 +21,6 @@
 
 import android.animation.Animator;
 import android.app.Activity;
-import android.app.ActivityManager.RunningTaskInfo;
 import android.content.Context;
 import android.content.Intent;
 import android.content.res.Configuration;
@@ -224,8 +223,7 @@
         if (!state.getHomeIntent().getComponent().getPackageName().equals(getPackageName())) {
             return null;
         }
-        RunningTaskInfo rti = state.getRunningTask();
-        if (rti == null || !rti.topActivity.equals(getComponentName())) {
+        if (state.getRunningTaskId() != getTaskId()) {
             return null;
         }
         mSwipeProgress.updateValue(0);
diff --git a/quickstep/src/com/android/quickstep/interaction/GestureSandboxActivity.java b/quickstep/src/com/android/quickstep/interaction/GestureSandboxActivity.java
index 7daac81..bf7023c 100644
--- a/quickstep/src/com/android/quickstep/interaction/GestureSandboxActivity.java
+++ b/quickstep/src/com/android/quickstep/interaction/GestureSandboxActivity.java
@@ -31,9 +31,11 @@
 import com.android.launcher3.R;
 import com.android.launcher3.Utilities;
 import com.android.launcher3.logging.StatsLogManager;
+import com.android.quickstep.TouchInteractionService.TISBinder;
 import com.android.quickstep.interaction.TutorialController.TutorialType;
+import com.android.quickstep.util.TISBindHelper;
 
-import java.util.List;
+import java.util.Arrays;
 
 /** Shows the gesture interactive sandbox in full screen mode. */
 public class GestureSandboxActivity extends FragmentActivity {
@@ -52,6 +54,9 @@
     private SharedPreferences mSharedPrefs;
     private StatsLogManager mStatsLogManager;
 
+    private TISBindHelper mTISBindHelper;
+    private TISBinder mBinder;
+
     @Override
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
@@ -69,6 +74,8 @@
         getSupportFragmentManager().beginTransaction()
                 .add(R.id.gesture_tutorial_fragment_container, mFragment)
                 .commit();
+
+        mTISBindHelper = new TISBindHelper(this, this::onTISConnected);
     }
 
     @Override
@@ -206,7 +213,37 @@
             DisplayMetrics metrics = new DisplayMetrics();
             display.getMetrics(metrics);
             getWindow().setSystemGestureExclusionRects(
-                    List.of(new Rect(0, 0, metrics.widthPixels, metrics.heightPixels)));
+                    Arrays.asList(new Rect(0, 0, metrics.widthPixels, metrics.heightPixels)));
         }
     }
+
+    @Override
+    protected void onResume() {
+        super.onResume();
+        updateServiceState(true);
+    }
+
+    private void onTISConnected(TISBinder binder) {
+        mBinder = binder;
+        updateServiceState(isResumed());
+    }
+
+    @Override
+    protected void onPause() {
+        super.onPause();
+        updateServiceState(false);
+    }
+
+    private void updateServiceState(boolean isEnabled) {
+        if (mBinder != null) {
+            mBinder.setGestureBlockedTaskId(isEnabled ? getTaskId() : -1);
+        }
+    }
+
+    @Override
+    protected void onDestroy() {
+        super.onDestroy();
+        mTISBindHelper.onDestroy();
+        updateServiceState(false);
+    }
 }
diff --git a/quickstep/src/com/android/quickstep/util/AssistantUtilities.java b/quickstep/src/com/android/quickstep/util/AssistantUtilities.java
deleted file mode 100644
index 336f7d1..0000000
--- a/quickstep/src/com/android/quickstep/util/AssistantUtilities.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright (C) 2019 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 com.android.quickstep.util;
-
-import static com.android.systemui.shared.system.RemoteAnimationTargetCompat.ACTIVITY_TYPE_ASSISTANT;
-
-import android.annotation.TargetApi;
-import android.app.TaskInfo;
-import android.content.Intent;
-import android.os.Build;
-
-import com.android.systemui.shared.system.ActivityManagerWrapper;
-
-/**
- * Utility class for interacting with the Assistant.
- */
-@TargetApi(Build.VERSION_CODES.Q)
-public final class AssistantUtilities {
-
-    /** Returns true if an Assistant activity that is excluded from recents is running. */
-    public static boolean isExcludedAssistantRunning() {
-        return isExcludedAssistant(ActivityManagerWrapper.getInstance().getRunningTask());
-    }
-
-    /** Returns true if the given task holds an Assistant activity that is excluded from recents. */
-    public static boolean isExcludedAssistant(TaskInfo info) {
-        return info != null
-            && info.configuration.windowConfiguration.getActivityType() == ACTIVITY_TYPE_ASSISTANT
-            && (info.baseIntent.getFlags() & Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS) != 0;
-    }
-
-    private AssistantUtilities() {}
-}
diff --git a/quickstep/src/com/android/quickstep/util/LauncherSplitScreenListener.java b/quickstep/src/com/android/quickstep/util/LauncherSplitScreenListener.java
deleted file mode 100644
index affe625..0000000
--- a/quickstep/src/com/android/quickstep/util/LauncherSplitScreenListener.java
+++ /dev/null
@@ -1,119 +0,0 @@
-package com.android.quickstep.util;
-
-import static com.android.launcher3.util.SplitConfigurationOptions.STAGE_POSITION_TOP_OR_LEFT;
-
-import android.content.Context;
-import android.os.IBinder;
-
-import com.android.launcher3.util.MainThreadInitializedObject;
-import com.android.launcher3.util.SplitConfigurationOptions;
-import com.android.launcher3.util.SplitConfigurationOptions.StagePosition;
-import com.android.launcher3.util.SplitConfigurationOptions.StageType;
-import com.android.launcher3.util.SplitConfigurationOptions.StagedSplitTaskPosition;
-import com.android.quickstep.SystemUiProxy;
-import com.android.wm.shell.splitscreen.ISplitScreenListener;
-
-/**
- * Listeners for system wide split screen position and stage changes.
- *
- * Use {@link #getRunningSplitTaskIds()} to determine which tasks, if any, are actively in
- * staged split.
- */
-public class LauncherSplitScreenListener extends ISplitScreenListener.Stub {
-
-    public static final MainThreadInitializedObject<LauncherSplitScreenListener> INSTANCE =
-            new MainThreadInitializedObject<>(LauncherSplitScreenListener::new);
-
-    private static final int[] EMPTY_ARRAY = {};
-
-    private final StagedSplitTaskPosition mMainStagePosition = new StagedSplitTaskPosition();
-    private final StagedSplitTaskPosition mSideStagePosition = new StagedSplitTaskPosition();
-
-    /**
-     * Gets set to current split taskIDs whenever the task list is frozen, and set to empty array
-     * whenever task list unfreezes. This also gets set to empty array whenever the user swipes to
-     * home - in that case the task list does not unfreeze immediately after the gesture, so it's
-     * done via {@link #notifySwipingToHome()}.
-     *
-     * When not empty, this indicates that we need to load a GroupedTaskView as the most recent
-     * page, so user can quickswitch back to a grouped task.
-     */
-    private int[] mPersistentGroupedIds;
-
-    public LauncherSplitScreenListener(Context context) {
-        mMainStagePosition.stageType = SplitConfigurationOptions.STAGE_TYPE_MAIN;
-        mSideStagePosition.stageType = SplitConfigurationOptions.STAGE_TYPE_SIDE;
-    }
-
-    /** Also call {@link #destroy()} when done. */
-    public void init() {
-        SystemUiProxy.INSTANCE.getNoCreate().registerSplitScreenListener(this);
-    }
-
-    public void destroy() {
-        SystemUiProxy.INSTANCE.getNoCreate().unregisterSplitScreenListener(this);
-    }
-
-    /**
-     * @return index 0 will be task in left/top position, index 1 in right/bottom position.
-     *         Will return empty array if device is not in staged split
-     */
-    public int[] getRunningSplitTaskIds() {
-        if (mMainStagePosition.taskId == -1 || mSideStagePosition.taskId == -1) {
-            return new int[]{};
-        }
-        int[] out = new int[2];
-        if (mMainStagePosition.stagePosition == STAGE_POSITION_TOP_OR_LEFT) {
-            out[0] = mMainStagePosition.taskId;
-            out[1] = mSideStagePosition.taskId;
-        } else {
-            out[1] = mMainStagePosition.taskId;
-            out[0] = mSideStagePosition.taskId;
-        }
-        return out;
-    }
-
-    @Override
-    public void onStagePositionChanged(@StageType int stage, @StagePosition int position) {
-        if (stage == SplitConfigurationOptions.STAGE_TYPE_MAIN) {
-            mMainStagePosition.stagePosition = position;
-        } else {
-            mSideStagePosition.stagePosition = position;
-        }
-    }
-
-    @Override
-    public void onTaskStageChanged(int taskId, @StageType int stage, boolean visible) {
-        // If task is not visible but we are tracking it, stop tracking it
-        if (!visible) {
-            if (mMainStagePosition.taskId == taskId) {
-                resetTaskId(mMainStagePosition);
-            } else if (mSideStagePosition.taskId == taskId) {
-                resetTaskId(mSideStagePosition);
-            } // else it's an un-tracked child
-            return;
-        }
-
-        // If stage has moved to undefined, stop tracking the task
-        if (stage == SplitConfigurationOptions.STAGE_TYPE_UNDEFINED) {
-            resetTaskId(taskId == mMainStagePosition.taskId ?
-                    mMainStagePosition : mSideStagePosition);
-            return;
-        }
-
-        if (stage == SplitConfigurationOptions.STAGE_TYPE_MAIN) {
-            mMainStagePosition.taskId = taskId;
-        } else {
-            mSideStagePosition.taskId = taskId;
-        }
-    }
-
-    private void resetTaskId(StagedSplitTaskPosition taskPosition) {
-        taskPosition.taskId = -1;
-    }
-
-    @Override
-    public IBinder asBinder() {
-        return this;
-    }
-}
diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java
index ed00b8e..10da83f 100644
--- a/quickstep/src/com/android/quickstep/views/RecentsView.java
+++ b/quickstep/src/com/android/quickstep/views/RecentsView.java
@@ -64,8 +64,8 @@
 import android.animation.ObjectAnimator;
 import android.animation.PropertyValuesHolder;
 import android.animation.ValueAnimator;
+import android.annotation.SuppressLint;
 import android.annotation.TargetApi;
-import android.app.ActivityManager.RunningTaskInfo;
 import android.content.Context;
 import android.content.LocusId;
 import android.content.res.Configuration;
@@ -171,7 +171,6 @@
 import com.android.quickstep.util.VibratorWrapper;
 import com.android.systemui.plugins.ResourceProvider;
 import com.android.systemui.shared.recents.model.Task;
-import com.android.systemui.shared.recents.model.Task.TaskKey;
 import com.android.systemui.shared.recents.model.ThumbnailData;
 import com.android.systemui.shared.system.ActivityManagerWrapper;
 import com.android.systemui.shared.system.PackageManagerWrapper;
@@ -2080,8 +2079,8 @@
     /**
      * Called when a gesture from an app is starting.
      */
-    public void onGestureAnimationStart(RunningTaskInfo[] runningTaskInfo,
-            RotationTouchHelper rotationTouchHelper) {
+    public void onGestureAnimationStart(
+            Task[] runningTasks, RotationTouchHelper rotationTouchHelper) {
         mGestureActive = true;
         // This needs to be called before the other states are set since it can create the task view
         if (mOrientationState.setGestureActive(true)) {
@@ -2092,7 +2091,7 @@
             updateSizeAndPadding();
         }
 
-        showCurrentTask(runningTaskInfo);
+        showCurrentTask(runningTasks);
         setEnableFreeScroll(false);
         setEnableDrawingLiveTile(false);
         setRunningTaskHidden(true);
@@ -2208,10 +2207,10 @@
     /**
      * Returns true if we should add a stub taskView for the running task id
      */
-    protected boolean shouldAddStubTaskView(RunningTaskInfo[] runningTaskInfos) {
-        if (runningTaskInfos.length > 1) {
-            TaskView primaryTaskView = getTaskViewByTaskId(runningTaskInfos[0].taskId);
-            TaskView secondaryTaskView = getTaskViewByTaskId(runningTaskInfos[1].taskId);
+    protected boolean shouldAddStubTaskView(Task[] runningTasks) {
+        if (runningTasks.length > 1) {
+            TaskView primaryTaskView = getTaskViewByTaskId(runningTasks[0].key.id);
+            TaskView secondaryTaskView = getTaskViewByTaskId(runningTasks[1].key.id);
             int leftTopTaskViewId =
                     (primaryTaskView == null) ? -1 : primaryTaskView.getTaskViewId();
             int rightBottomTaskViewId =
@@ -2219,8 +2218,8 @@
             // Add a new stub view if both taskIds don't match any taskViews
             return leftTopTaskViewId != rightBottomTaskViewId || leftTopTaskViewId == -1;
         }
-        RunningTaskInfo runningTaskInfo = runningTaskInfos[0];
-        return runningTaskInfo != null && getTaskViewByTaskId(runningTaskInfo.taskId) == null;
+        Task runningTaskInfo = runningTasks[0];
+        return runningTaskInfo != null && getTaskViewByTaskId(runningTaskInfo.key.id) == null;
     }
 
     /**
@@ -2229,21 +2228,16 @@
      * All subsequent calls to reload will keep the task as the first item until {@link #reset()}
      * is called.  Also scrolls the view to this task.
      */
-    private void showCurrentTask(RunningTaskInfo[] runningTaskInfo) {
+    private void showCurrentTask(Task[] runningTasks) {
         int runningTaskViewId = -1;
-        boolean needGroupTaskView = runningTaskInfo.length > 1;
-        RunningTaskInfo taskInfo = runningTaskInfo[0];
-        if (shouldAddStubTaskView(runningTaskInfo)) {
+        boolean needGroupTaskView = runningTasks.length > 1;
+        if (shouldAddStubTaskView(runningTasks)) {
             boolean wasEmpty = getChildCount() == 0;
             // Add an empty view for now until the task plan is loaded and applied
             final TaskView taskView;
             if (needGroupTaskView) {
                 taskView = getTaskViewFromPool(true);
-                RunningTaskInfo secondaryTaskInfo = runningTaskInfo[1];
-                mTmpRunningTasks = new Task[]{
-                        Task.from(new TaskKey(taskInfo), taskInfo, false),
-                        Task.from(new TaskKey(secondaryTaskInfo), secondaryTaskInfo, false)
-                };
+                mTmpRunningTasks = new Task[]{runningTasks[0], runningTasks[1]};
                 addView(taskView, 0);
                 // When we create a placeholder task view mSplitBoundsConfig will be null, but with
                 // the actual app running we won't need to show the thumbnail until all the tasks
@@ -2255,7 +2249,7 @@
                 addView(taskView, 0);
                 // The temporary running task is only used for the duration between the start of the
                 // gesture and the task list is loaded and applied
-                mTmpRunningTasks = new Task[]{Task.from(new TaskKey(taskInfo), taskInfo, false)};
+                mTmpRunningTasks = new Task[]{runningTasks[0]};
                 taskView.bind(mTmpRunningTasks[0], mOrientationState);
             }
             runningTaskViewId = taskView.getTaskViewId();
@@ -2268,8 +2262,8 @@
             measure(makeMeasureSpec(getMeasuredWidth(), EXACTLY),
                     makeMeasureSpec(getMeasuredHeight(), EXACTLY));
             layout(getLeft(), getTop(), getRight(), getBottom());
-        } else if (getTaskViewByTaskId(taskInfo.taskId) != null) {
-            runningTaskViewId = getTaskViewByTaskId(taskInfo.taskId).getTaskViewId();
+        } else if (getTaskViewByTaskId(runningTasks[0].key.id) != null) {
+            runningTaskViewId = getTaskViewByTaskId(runningTasks[0].key.id).getTaskViewId();
         }
 
         boolean runningTaskTileHidden = mRunningTaskTileHidden;
@@ -4059,6 +4053,7 @@
     }
 
     /** TODO(b/181707736) More gracefully handle exiting split selection state */
+    @SuppressLint("WrongCall")
     protected void resetFromSplitSelectionState() {
         if (mSplitSelectSource != null || mSplitHiddenTaskViewIndex != -1) {
             if (mFirstFloatingTaskView != null) {
@@ -4433,7 +4428,8 @@
         }
 
         RemoteTargetGluer gluer = new RemoteTargetGluer(getContext(), getSizeStrategy());
-        mRemoteTargetHandles = gluer.assignTargetsForSplitScreen(recentsAnimationTargets);
+        mRemoteTargetHandles = gluer.assignTargetsForSplitScreen(
+                getContext(), recentsAnimationTargets);
         mSplitBoundsConfig = gluer.getStagedSplitBounds();
         // Add release check to the targets from the RemoteTargetGluer and not the targets
         // passed in because in the event we're in split screen, we use the passed in targets
@@ -4544,6 +4540,7 @@
     /**
      * Updates page scroll synchronously after measure and layout child views.
      */
+    @SuppressLint("WrongCall")
     public void updateScrollSynchronously() {
         // onMeasure is needed to update child's measured width which is used in scroll calculation,
         // in case TaskView sizes has changed when being focused/unfocused.
