Merge "Update initial staged split UX." into tm-dev am: 8d06bb8991

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Launcher3/+/17251578

Change-Id: Id2caa24f746921861d8b79fc297bb440588bde1c
diff --git a/OWNERS b/OWNERS
index 7f98ea6..eb4f2e3 100644
--- a/OWNERS
+++ b/OWNERS
@@ -7,13 +7,6 @@
 alexchau@google.com
 andraskloczl@google.com
 patmanning@google.com
-petrcermak@google.com
-pbdr@google.com
-kideckel@google.com
-stevenckng@google.com
-ydixit@google.com
-boadway@google.com
-alinazaidi@google.com
 adamcohen@google.com
 hyunyoungs@google.com
 mrcasey@google.com
diff --git a/proguard.flags b/proguard.flags
index a450183..1f5c065 100644
--- a/proguard.flags
+++ b/proguard.flags
@@ -54,7 +54,7 @@
 -dontwarn com.android.internal.util.**
 
 ################ Do not optimize recents lib #############
--keep class com.android.systemui.** {
+-keep class com.android.systemui.shared.** {
   *;
 }
 
diff --git a/quickstep/res/layout/predicted_hotseat_edu.xml b/quickstep/res/layout/predicted_hotseat_edu.xml
index e4e3956..f0c12f1 100644
--- a/quickstep/res/layout/predicted_hotseat_edu.xml
+++ b/quickstep/res/layout/predicted_hotseat_edu.xml
@@ -42,6 +42,7 @@
             android:paddingLeft="@dimen/bottom_sheet_edu_padding"
             android:paddingRight="@dimen/bottom_sheet_edu_padding"
             android:text="@string/hotseat_edu_title_migrate"
+            android:fontFamily="google-sans"
             android:textAlignment="center"
             android:textColor="@android:color/white"
             android:textSize="20sp" />
diff --git a/quickstep/src/com/android/launcher3/model/QuickstepModelDelegate.java b/quickstep/src/com/android/launcher3/model/QuickstepModelDelegate.java
index 0e534f4..8424564 100644
--- a/quickstep/src/com/android/launcher3/model/QuickstepModelDelegate.java
+++ b/quickstep/src/com/android/launcher3/model/QuickstepModelDelegate.java
@@ -15,6 +15,20 @@
  */
 package com.android.launcher3.model;
 
+import static android.app.admin.DevicePolicyResources.Strings.Launcher.ALL_APPS_PERSONAL_TAB;
+import static android.app.admin.DevicePolicyResources.Strings.Launcher.ALL_APPS_PERSONAL_TAB_ACCESSIBILITY;
+import static android.app.admin.DevicePolicyResources.Strings.Launcher.ALL_APPS_WORK_TAB;
+import static android.app.admin.DevicePolicyResources.Strings.Launcher.ALL_APPS_WORK_TAB_ACCESSIBILITY;
+import static android.app.admin.DevicePolicyResources.Strings.Launcher.DISABLED_BY_ADMIN_MESSAGE;
+import static android.app.admin.DevicePolicyResources.Strings.Launcher.WIDGETS_PERSONAL_TAB;
+import static android.app.admin.DevicePolicyResources.Strings.Launcher.WIDGETS_WORK_TAB;
+import static android.app.admin.DevicePolicyResources.Strings.Launcher.WORK_FOLDER_NAME;
+import static android.app.admin.DevicePolicyResources.Strings.Launcher.WORK_PROFILE_EDU;
+import static android.app.admin.DevicePolicyResources.Strings.Launcher.WORK_PROFILE_EDU_ACCEPT;
+import static android.app.admin.DevicePolicyResources.Strings.Launcher.WORK_PROFILE_ENABLE_BUTTON;
+import static android.app.admin.DevicePolicyResources.Strings.Launcher.WORK_PROFILE_PAUSED_DESCRIPTION;
+import static android.app.admin.DevicePolicyResources.Strings.Launcher.WORK_PROFILE_PAUSED_TITLE;
+import static android.app.admin.DevicePolicyResources.Strings.Launcher.WORK_PROFILE_PAUSE_BUTTON;
 import static android.text.format.DateUtils.DAY_IN_MILLIS;
 import static android.text.format.DateUtils.formatElapsedTime;
 
@@ -32,6 +46,7 @@
 import static java.util.stream.Collectors.toCollection;
 
 import android.app.StatsManager;
+import android.app.admin.DevicePolicyManager;
 import android.app.prediction.AppPredictionContext;
 import android.app.prediction.AppPredictionManager;
 import android.app.prediction.AppPredictor;
@@ -136,6 +151,42 @@
     }
 
     @Override
+    @WorkerThread
+    public void loadStringCache(StringCache cache) {
+        cache.loadDefaultStrings(mContext);
+
+        cache.workProfileEdu = getEnterpriseString(WORK_PROFILE_EDU, cache.workProfileEdu);
+        cache.workProfileEduAccept = getEnterpriseString(
+                WORK_PROFILE_EDU_ACCEPT, cache.workProfileEduAccept);
+        cache.workProfilePausedTitle = getEnterpriseString(
+                WORK_PROFILE_PAUSED_TITLE, cache.workProfilePausedTitle);
+        cache.workProfilePausedDescription = getEnterpriseString(
+                WORK_PROFILE_PAUSED_DESCRIPTION, cache.workProfilePausedDescription);
+        cache.workProfilePauseButton = getEnterpriseString(
+                WORK_PROFILE_PAUSE_BUTTON, cache.workProfilePauseButton);
+        cache.workProfileEnableButton = getEnterpriseString(
+                WORK_PROFILE_ENABLE_BUTTON, cache.workProfileEnableButton);
+        cache.allAppsWorkTab = getEnterpriseString(ALL_APPS_WORK_TAB, cache.allAppsWorkTab);
+        cache.allAppsPersonalTab = getEnterpriseString(
+                ALL_APPS_PERSONAL_TAB, cache.allAppsPersonalTab);
+        cache.allAppsWorkTabAccessibility = getEnterpriseString(
+                ALL_APPS_WORK_TAB_ACCESSIBILITY, cache.allAppsWorkTabAccessibility);
+        cache.allAppsPersonalTabAccessibility = getEnterpriseString(
+                ALL_APPS_PERSONAL_TAB_ACCESSIBILITY, cache.allAppsPersonalTabAccessibility);
+        cache.workFolderName = getEnterpriseString(WORK_FOLDER_NAME, cache.workFolderName);
+        cache.widgetsWorkTab = getEnterpriseString(WIDGETS_WORK_TAB, cache.widgetsWorkTab);
+        cache.widgetsPersonalTab = getEnterpriseString(
+                WIDGETS_PERSONAL_TAB, cache.widgetsPersonalTab);
+        cache.disabledByAdminMessage = getEnterpriseString(
+                DISABLED_BY_ADMIN_MESSAGE, cache.disabledByAdminMessage);
+    }
+
+    private String getEnterpriseString(String updatableStringId, String defaultString) {
+        DevicePolicyManager dpm = mContext.getSystemService(DevicePolicyManager.class);
+        return dpm.getString(updatableStringId, () -> defaultString);
+    }
+
+    @Override
     public void workspaceLoadComplete() {
         super.workspaceLoadComplete();
         recreatePredictors();
diff --git a/quickstep/src/com/android/launcher3/taskbar/DesktopTaskbarRecentAppsController.java b/quickstep/src/com/android/launcher3/taskbar/DesktopTaskbarRecentAppsController.java
new file mode 100644
index 0000000..acfbea3
--- /dev/null
+++ b/quickstep/src/com/android/launcher3/taskbar/DesktopTaskbarRecentAppsController.java
@@ -0,0 +1,153 @@
+/*
+ * 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.launcher3.taskbar;
+
+import android.app.ActivityManager;
+import android.content.ComponentName;
+import android.util.SparseArray;
+
+import com.android.launcher3.model.data.AppInfo;
+import com.android.launcher3.model.data.ItemInfo;
+import com.android.launcher3.model.data.WorkspaceItemInfo;
+import com.android.quickstep.RecentsModel;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * Provides recent apps functionality specifically in a desktop environment.
+ */
+public class DesktopTaskbarRecentAppsController extends TaskbarRecentAppsController {
+
+    private final TaskbarActivityContext mContext;
+    private ArrayList<ItemInfo> mRunningApps = new ArrayList<>();
+    private AppInfo[] mApps;
+
+    public DesktopTaskbarRecentAppsController(TaskbarActivityContext context) {
+        mContext = context;
+    }
+
+    @Override
+    protected void onDestroy() {
+        super.onDestroy();
+        mApps = null;
+    }
+
+    @Override
+    protected void setApps(AppInfo[] apps) {
+        mApps = apps;
+    }
+
+    @Override
+    protected boolean isEnabled() {
+        return true;
+    }
+
+    /**
+     * Set mRunningApps to hold currently running applications using the list of currently running
+     * tasks. Filtering is also done to ignore applications that are already on the taskbar in the
+     * original hotseat.
+     */
+    @Override
+    protected void updateRunningApps(SparseArray<ItemInfo> hotseatItems) {
+        ArrayList<AppInfo> runningApps = getRunningAppsFromTasks();
+        ArrayList<ItemInfo> filteredRunningApps = new ArrayList<>();
+        for (AppInfo runningApp : runningApps) {
+            boolean shouldAddOnTaskbar = true;
+            for (int i = 0; i < hotseatItems.size(); i++) {
+                if (hotseatItems.keyAt(i) >= mControllers.taskbarActivityContext.getDeviceProfile()
+                        .numShownHotseatIcons) {
+                    break;
+                }
+                if (hotseatItems.valueAt(i).getTargetPackage()
+                        .equals(runningApp.getTargetPackage())) {
+                    shouldAddOnTaskbar = false;
+                    break;
+                }
+            }
+            if (shouldAddOnTaskbar) {
+                filteredRunningApps.add(new WorkspaceItemInfo(runningApp));
+            }
+        }
+        mRunningApps = filteredRunningApps;
+        mControllers.taskbarViewController.commitRunningAppsToUI();
+    }
+
+    /**
+     * Returns a copy of hotseatItems with the addition of currently running applications.
+     */
+    @Override
+    protected ItemInfo[] updateHotseatItemInfos(ItemInfo[] hotseatItemInfos) {
+        // hotseatItemInfos.length would be 0 if deviceProfile.numShownHotseatIcons is 0, so we
+        // don't want to show anything in the hotseat
+        if (hotseatItemInfos.length == 0) return hotseatItemInfos;
+
+        int runningAppsIndex = 0;
+        ItemInfo[] newHotseatItemsInfo = Arrays.copyOf(
+                hotseatItemInfos, hotseatItemInfos.length + mRunningApps.size());
+        for (int i = hotseatItemInfos.length; i < newHotseatItemsInfo.length; i++) {
+            newHotseatItemsInfo[i] = mRunningApps.get(runningAppsIndex);
+            runningAppsIndex++;
+        }
+        return newHotseatItemsInfo;
+    }
+
+
+    /**
+     * Returns a list of running applications from the list of currently running tasks.
+     */
+    private ArrayList<AppInfo> getRunningAppsFromTasks() {
+        ArrayList<ActivityManager.RunningTaskInfo> tasks =
+                RecentsModel.INSTANCE.get(mContext).getRunningTasks();
+        ArrayList<AppInfo> runningApps = new ArrayList<>();
+        // early return if apps is empty, since we would have no AppInfo to compare
+        if (mApps == null)  {
+            return runningApps;
+        }
+
+        Set<String> seenPackages = new HashSet<>();
+        for (ActivityManager.RunningTaskInfo taskInfo : tasks) {
+            if (taskInfo.realActivity == null) continue;
+
+            // If a different task for the same package has already been handled, skip this one
+            String taskPackage = taskInfo.realActivity.getPackageName();
+            if (seenPackages.contains(taskPackage)) continue;
+
+            // Otherwise, get the corresponding AppInfo and add it to the list
+            seenPackages.add(taskPackage);
+            AppInfo app = getAppInfo(taskInfo.realActivity);
+            if (app == null) continue;
+            runningApps.add(app);
+        }
+        return runningApps;
+    }
+
+    /**
+     * Retrieves the corresponding AppInfo for the activity.
+     */
+    private AppInfo getAppInfo(ComponentName activity) {
+        String packageName = activity.getPackageName();
+        for (AppInfo app : mApps) {
+            if (!packageName.equals(app.getTargetPackage())) {
+                continue;
+            }
+            return app;
+        }
+        return null;
+    }
+}
diff --git a/quickstep/src/com/android/launcher3/taskbar/DesktopTaskbarUIController.java b/quickstep/src/com/android/launcher3/taskbar/DesktopTaskbarUIController.java
index cf56248..17e8a49c8 100644
--- a/quickstep/src/com/android/launcher3/taskbar/DesktopTaskbarUIController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/DesktopTaskbarUIController.java
@@ -32,11 +32,14 @@
 
     @Override
     protected void init(TaskbarControllers taskbarControllers) {
+        super.init(taskbarControllers);
         mLauncher.getHotseat().setIconsAlpha(0f);
+        mControllers.taskbarViewController.updateRunningApps();
     }
 
     @Override
     protected void onDestroy() {
+        super.onDestroy();
         mLauncher.getHotseat().setIconsAlpha(1f);
     }
 }
diff --git a/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java b/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java
index 7ab59b8..e13fcf2 100644
--- a/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java
@@ -237,6 +237,12 @@
                         & Configuration.UI_MODE_NIGHT_MASK;
                 boolean isDarkTheme = mode == Configuration.UI_MODE_NIGHT_YES;
                 mTaskbarNavButtonDarkIntensity.updateValue(isDarkTheme ? 0 : 1);
+
+                if (mIsImeRenderingNavButtons) {
+                    // Hide the back button while the IME is visible during SUW
+                    mPropertyHolders.add(new StatePropertyHolder(mBackButton,
+                            flags -> (flags & FLAG_IME_VISIBLE) == 0));
+                }
             } else if (isInKidsMode) {
                 int iconSize = mContext.getResources().getDimensionPixelSize(
                         R.dimen.taskbar_icon_size_kids);
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java
index 0f3a6ee..8bc2c6c 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java
@@ -170,13 +170,15 @@
 
         mAccessibilityDelegate = new TaskbarShortcutMenuAccessibilityDelegate(this);
 
+        final boolean isDesktopMode = getPackageManager().hasSystemFeature(FEATURE_PC);
+
         // Construct controllers.
         mControllers = new TaskbarControllers(this,
                 new TaskbarDragController(this),
                 buttonController,
-                getPackageManager().hasSystemFeature(FEATURE_PC)
-                        ? new DesktopNavbarButtonsViewController(this, navButtonsView) :
-                        new NavbarButtonsViewController(this, navButtonsView),
+                isDesktopMode
+                        ? new DesktopNavbarButtonsViewController(this, navButtonsView)
+                        : new NavbarButtonsViewController(this, navButtonsView),
                 new RotationButtonController(this,
                         c.getColor(R.color.taskbar_nav_icon_light_color),
                         c.getColor(R.color.taskbar_nav_icon_dark_color),
@@ -197,7 +199,10 @@
                 new TaskbarAutohideSuspendController(this),
                 new TaskbarPopupController(this),
                 new TaskbarForceVisibleImmersiveController(this),
-                new TaskbarAllAppsController(this));
+                new TaskbarAllAppsController(this),
+                isDesktopMode
+                        ? new DesktopTaskbarRecentAppsController(this)
+                        : TaskbarRecentAppsController.DEFAULT);
     }
 
     public void init(TaskbarSharedState sharedState) {
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarControllers.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarControllers.java
index a5999cc..0eab7ae 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarControllers.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarControllers.java
@@ -50,6 +50,7 @@
     public final TaskbarPopupController taskbarPopupController;
     public final TaskbarForceVisibleImmersiveController taskbarForceVisibleImmersiveController;
     public final TaskbarAllAppsController taskbarAllAppsController;
+    public final TaskbarRecentAppsController taskbarRecentAppsController;
 
     @Nullable private LoggableTaskbarController[] mControllersToLog = null;
 
@@ -75,7 +76,8 @@
             TaskbarAutohideSuspendController taskbarAutoHideSuspendController,
             TaskbarPopupController taskbarPopupController,
             TaskbarForceVisibleImmersiveController taskbarForceVisibleImmersiveController,
-            TaskbarAllAppsController taskbarAllAppsController) {
+            TaskbarAllAppsController taskbarAllAppsController,
+            TaskbarRecentAppsController taskbarRecentAppsController) {
         this.taskbarActivityContext = taskbarActivityContext;
         this.taskbarDragController = taskbarDragController;
         this.navButtonController = navButtonController;
@@ -93,6 +95,7 @@
         this.taskbarPopupController = taskbarPopupController;
         this.taskbarForceVisibleImmersiveController = taskbarForceVisibleImmersiveController;
         this.taskbarAllAppsController = taskbarAllAppsController;
+        this.taskbarRecentAppsController = taskbarRecentAppsController;
     }
 
     /**
@@ -117,6 +120,7 @@
         taskbarPopupController.init(this);
         taskbarForceVisibleImmersiveController.init(this);
         taskbarAllAppsController.init(this, sharedState);
+        taskbarRecentAppsController.init(this);
 
         mControllersToLog = new LoggableTaskbarController[] {
                 taskbarDragController, navButtonController, navbarButtonsViewController,
@@ -153,6 +157,7 @@
         taskbarPopupController.onDestroy();
         taskbarForceVisibleImmersiveController.onDestroy();
         taskbarAllAppsController.onDestroy();
+        taskbarRecentAppsController.onDestroy();
 
         mControllersToLog = null;
     }
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarModelCallbacks.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarModelCallbacks.java
index 62392ee..af8825e 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarModelCallbacks.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarModelCallbacks.java
@@ -29,6 +29,7 @@
 import com.android.launcher3.util.IntSet;
 import com.android.launcher3.util.ItemInfoMatcher;
 import com.android.launcher3.util.LauncherBindableItemsContainer;
+import com.android.quickstep.RecentsModel;
 
 import java.io.PrintWriter;
 import java.util.ArrayList;
@@ -41,7 +42,7 @@
  * Launcher model Callbacks for rendering taskbar.
  */
 public class TaskbarModelCallbacks implements
-        BgDataModel.Callbacks, LauncherBindableItemsContainer {
+        BgDataModel.Callbacks, LauncherBindableItemsContainer, RecentsModel.RunningTasksListener {
 
     private final SparseArray<ItemInfo> mHotseatItems = new SparseArray<>();
     private List<ItemInfo> mPredictedItems = Collections.emptyList();
@@ -60,6 +61,16 @@
 
     public void init(TaskbarControllers controllers) {
         mControllers = controllers;
+        if (mControllers.taskbarRecentAppsController.isEnabled()) {
+            RecentsModel.INSTANCE.get(mContext).registerRunningTasksListener(this);
+        }
+    }
+
+    /**
+     * Unregisters listeners in this class.
+     */
+    public void unregisterListeners() {
+        RecentsModel.INSTANCE.get(mContext).unregisterRunningTasksListener();
     }
 
     @Override
@@ -184,6 +195,8 @@
                 isHotseatEmpty = false;
             }
         }
+        hotseatItemInfos = mControllers.taskbarRecentAppsController
+                .updateHotseatItemInfos(hotseatItemInfos);
         mContainer.updateHotseatItems(hotseatItemInfos);
 
         final boolean finalIsHotseatEmpty = isHotseatEmpty;
@@ -195,6 +208,21 @@
     }
 
     @Override
+    public void onRunningTasksChanged() {
+        updateRunningApps();
+    }
+
+    /** Called when there's a change in running apps to update the UI. */
+    public void commitRunningAppsToUI() {
+        commitItemsToUI();
+    }
+
+    /** Call TaskbarRecentAppsController to update running apps with mHotseatItems. */
+    public void updateRunningApps() {
+        mControllers.taskbarRecentAppsController.updateRunningApps(mHotseatItems);
+    }
+
+    @Override
     public void bindDeepShortcutMap(HashMap<ComponentKey, Integer> deepShortcutMapCopy) {
         mControllers.taskbarPopupController.setDeepShortcutMap(deepShortcutMapCopy);
     }
@@ -202,6 +230,7 @@
     @Override
     public void bindAllApplications(AppInfo[] apps, int flags) {
         mControllers.taskbarAllAppsController.setApps(apps, flags);
+        mControllers.taskbarRecentAppsController.setApps(apps);
     }
 
     protected void dumpLogs(String prefix, PrintWriter pw) {
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarRecentAppsController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarRecentAppsController.java
new file mode 100644
index 0000000..8445cff
--- /dev/null
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarRecentAppsController.java
@@ -0,0 +1,63 @@
+/*
+ * 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.launcher3.taskbar;
+
+import android.util.SparseArray;
+
+import androidx.annotation.CallSuper;
+
+import com.android.launcher3.model.data.AppInfo;
+import com.android.launcher3.model.data.ItemInfo;
+
+/**
+ * Base class for providing recent apps functionality
+ */
+public class TaskbarRecentAppsController {
+
+    public static final TaskbarRecentAppsController DEFAULT = new TaskbarRecentAppsController();
+
+    // Initialized in init.
+    protected TaskbarControllers mControllers;
+
+    @CallSuper
+    protected void init(TaskbarControllers taskbarControllers) {
+        mControllers = taskbarControllers;
+    }
+
+    @CallSuper
+    protected void onDestroy() {
+        mControllers = null;
+    }
+
+    /** Stores the current {@link AppInfo} instances, no-op except in desktop environment. */
+    protected void setApps(AppInfo[] apps) { }
+
+    /**
+     * Indicates whether recent apps functionality is enabled, should return false except in
+     * desktop environment.
+     */
+    protected boolean isEnabled() {
+        return false;
+    }
+
+    /** Called to update hotseatItems, no-op except in desktop environment. */
+    protected ItemInfo[] updateHotseatItemInfos(ItemInfo[] hotseatItems) {
+        return hotseatItems;
+    }
+
+    /** Called to update the list of currently running apps, no-op except in desktop environment. */
+    protected void updateRunningApps(SparseArray<ItemInfo> hotseatItems) { }
+}
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java
index a89061b..7fca048 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java
@@ -107,6 +107,7 @@
 
     public void onDestroy() {
         LauncherAppState.getInstance(mActivity).getModel().removeCallbacks(mModelCallbacks);
+        mModelCallbacks.unregisterListeners();
     }
 
     public boolean areIconsVisible() {
@@ -298,6 +299,16 @@
         mModelCallbacks.dumpLogs(prefix + "\t", pw);
     }
 
+    /** Called when there's a change in running apps to update the UI. */
+    public void commitRunningAppsToUI() {
+        mModelCallbacks.commitRunningAppsToUI();
+    }
+
+    /** Call TaskbarModelCallbacks to update running apps. */
+    public void updateRunningApps() {
+        mModelCallbacks.updateRunningApps();
+    }
+
     /**
      * Callbacks for {@link TaskbarView} to interact with its controller.
      */
diff --git a/quickstep/src/com/android/quickstep/RecentTasksList.java b/quickstep/src/com/android/quickstep/RecentTasksList.java
index 097850f..d0ad221 100644
--- a/quickstep/src/com/android/quickstep/RecentTasksList.java
+++ b/quickstep/src/com/android/quickstep/RecentTasksList.java
@@ -62,6 +62,10 @@
     private TaskLoadResult mResultsBg = INVALID_RESULT;
     private TaskLoadResult mResultsUi = INVALID_RESULT;
 
+    private RecentsModel.RunningTasksListener mRunningTasksListener;
+    // Tasks are stored in order of least recently launched to most recently launched.
+    private ArrayList<ActivityManager.RunningTaskInfo> mRunningTasks;
+
     public RecentTasksList(LooperExecutor mainThreadExecutor,
             KeyguardManagerCompat keyguardManager, SystemUiProxy sysUiProxy) {
         mMainThreadExecutor = mainThreadExecutor;
@@ -73,7 +77,26 @@
             public void onRecentTasksChanged() throws RemoteException {
                 mMainThreadExecutor.execute(RecentTasksList.this::onRecentTasksChanged);
             }
+
+            @Override
+            public void onRunningTaskAppeared(ActivityManager.RunningTaskInfo taskInfo) {
+                mMainThreadExecutor.execute(() -> {
+                    RecentTasksList.this.onRunningTaskAppeared(taskInfo);
+                });
+            }
+
+            @Override
+            public void onRunningTaskVanished(ActivityManager.RunningTaskInfo taskInfo) {
+                mMainThreadExecutor.execute(() -> {
+                    RecentTasksList.this.onRunningTaskVanished(taskInfo);
+                });
+            }
         });
+        // We may receive onRunningTaskAppeared events later for tasks which have already been
+        // included in the list returned by mSysUiProxy.getRunningTasks(), or may receive
+        // onRunningTaskVanished for tasks not included in the returned list. These cases will be
+        // addressed when the tasks are added to/removed from mRunningTasks.
+        initRunningTasks(mSysUiProxy.getRunningTasks(Integer.MAX_VALUE));
     }
 
     @VisibleForTesting
@@ -154,6 +177,59 @@
         mChangeId++;
     }
 
+     /**
+     * Registers a listener for running tasks
+     */
+    public void registerRunningTasksListener(RecentsModel.RunningTasksListener listener) {
+        mRunningTasksListener = listener;
+    }
+
+    /**
+     * Removes the previously registered running tasks listener
+     */
+    public void unregisterRunningTasksListener() {
+        mRunningTasksListener = null;
+    }
+
+    private void initRunningTasks(ArrayList<ActivityManager.RunningTaskInfo> runningTasks) {
+        // Tasks are retrieved in order of most recently launched/used to least recently launched.
+        mRunningTasks = new ArrayList<>(runningTasks);
+        Collections.reverse(mRunningTasks);
+    }
+
+    /**
+     * Gets the set of running tasks.
+     */
+    public ArrayList<ActivityManager.RunningTaskInfo> getRunningTasks() {
+        return mRunningTasks;
+    }
+
+    private void onRunningTaskAppeared(ActivityManager.RunningTaskInfo taskInfo) {
+        // Make sure this task is not already in the list
+        for (ActivityManager.RunningTaskInfo existingTask : mRunningTasks) {
+            if (taskInfo.taskId == existingTask.taskId) {
+                return;
+            }
+        }
+        mRunningTasks.add(taskInfo);
+        if (mRunningTasksListener != null) {
+            mRunningTasksListener.onRunningTasksChanged();
+        }
+    }
+
+    private void onRunningTaskVanished(ActivityManager.RunningTaskInfo taskInfo) {
+        // Find the task from the list of running tasks, if it exists
+        for (ActivityManager.RunningTaskInfo existingTask : mRunningTasks) {
+            if (existingTask.taskId != taskInfo.taskId) continue;
+
+            mRunningTasks.remove(existingTask);
+            if (mRunningTasksListener != null) {
+                mRunningTasksListener.onRunningTasksChanged();
+            }
+            return;
+        }
+    }
+
     /**
      * Loads and creates a list of all the recent tasks.
      */
diff --git a/quickstep/src/com/android/quickstep/RecentsModel.java b/quickstep/src/com/android/quickstep/RecentsModel.java
index 5d77a6e..964f8ea 100644
--- a/quickstep/src/com/android/quickstep/RecentsModel.java
+++ b/quickstep/src/com/android/quickstep/RecentsModel.java
@@ -241,4 +241,35 @@
          */
         void onTaskIconChanged(String pkg, UserHandle user);
     }
+
+    /**
+     * Registers a listener for running tasks
+     */
+    public void registerRunningTasksListener(RunningTasksListener listener) {
+        mTaskList.registerRunningTasksListener(listener);
+    }
+
+    /**
+     * Removes the previously registered running tasks listener
+     */
+    public void unregisterRunningTasksListener() {
+        mTaskList.unregisterRunningTasksListener();
+    }
+
+    /**
+     * Gets the set of running tasks.
+     */
+    public ArrayList<ActivityManager.RunningTaskInfo> getRunningTasks() {
+        return mTaskList.getRunningTasks();
+    }
+
+    /**
+     * Listener for receiving running tasks changes
+     */
+    public interface RunningTasksListener {
+        /**
+         * Called when there's a change to running tasks
+         */
+        void onRunningTasksChanged();
+    }
 }
diff --git a/quickstep/src/com/android/quickstep/SystemUiProxy.java b/quickstep/src/com/android/quickstep/SystemUiProxy.java
index 5ef89d3..1b50469 100644
--- a/quickstep/src/com/android/quickstep/SystemUiProxy.java
+++ b/quickstep/src/com/android/quickstep/SystemUiProxy.java
@@ -20,12 +20,14 @@
 import static com.android.launcher3.util.DisplayController.CHANGE_NAVIGATION_MODE;
 import static com.android.launcher3.util.Executors.MAIN_EXECUTOR;
 
+import android.app.ActivityManager;
 import android.app.PendingIntent;
 import android.app.PictureInPictureParams;
 import android.content.ComponentName;
 import android.content.Context;
 import android.content.Intent;
 import android.content.pm.ActivityInfo;
+import android.content.pm.PackageManager;
 import android.graphics.Bitmap;
 import android.graphics.Insets;
 import android.graphics.Rect;
@@ -108,12 +110,14 @@
     private boolean mLastNavButtonAnimate;
     private boolean mHasNavButtonAlphaBeenSet = false;
     private Runnable mPendingSetNavButtonAlpha = null;
+    private Context mContext;
 
     // TODO(141886704): Find a way to remove this
     private int mLastSystemUiStateFlags;
 
     public SystemUiProxy(Context context) {
         DisplayController.INSTANCE.get(context).addChangeListener(this);
+        mContext = context;
     }
 
     @Override
@@ -889,4 +893,20 @@
         }
         return new ArrayList<>();
     }
+
+    /**
+     * Gets the set of running tasks.
+     */
+    public ArrayList<ActivityManager.RunningTaskInfo> getRunningTasks(int numTasks) {
+        if (mRecentTasks != null
+                && mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_PC)) {
+            try {
+                return new ArrayList<ActivityManager.RunningTaskInfo>(
+                        Arrays.asList(mRecentTasks.getRunningTasks(numTasks)));
+            } catch (RemoteException e) {
+                Log.w(TAG, "Failed call getRunningTasks", e);
+            }
+        }
+        return new ArrayList<>();
+    }
 }
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index 2f9b563..4c77c33 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -2182,10 +2182,6 @@
 
         IntSet result = new IntSet();
         if (visibleIds.isEmpty()) {
-            if (TestProtocol.sDebugTracing) {
-                Log.d(TestProtocol.NULL_INT_SET, "getPagesToBindSynchronously (1): "
-                        + result);
-            }
             return result;
         }
         for (int id : orderedScreenIds.toArray()) {
@@ -2206,10 +2202,6 @@
             // pages being hidden in single panel.
             result.add(pairId);
         }
-        if (TestProtocol.sDebugTracing) {
-            Log.d(TestProtocol.NULL_INT_SET, "getPagesToBindSynchronously (2): "
-                    + result);
-        }
         return result;
     }
 
diff --git a/src/com/android/launcher3/LauncherModel.java b/src/com/android/launcher3/LauncherModel.java
index ee6f51e..3db5dcd 100644
--- a/src/com/android/launcher3/LauncherModel.java
+++ b/src/com/android/launcher3/LauncherModel.java
@@ -347,12 +347,6 @@
     public void addCallbacks(Callbacks callbacks) {
         Preconditions.assertUIThread();
         synchronized (mCallbacksList) {
-            if (TestProtocol.sDebugTracing) {
-                Log.d(TestProtocol.NULL_INT_SET, "addCallbacks pointer: "
-                        + callbacks
-                        + ", name: "
-                        + callbacks.getClass().getName(), new Exception());
-            }
             mCallbacksList.add(callbacks);
         }
     }
diff --git a/src/com/android/launcher3/model/BaseLoaderResults.java b/src/com/android/launcher3/model/BaseLoaderResults.java
index 5b278ab..db417a7 100644
--- a/src/com/android/launcher3/model/BaseLoaderResults.java
+++ b/src/com/android/launcher3/model/BaseLoaderResults.java
@@ -32,7 +32,6 @@
 import com.android.launcher3.model.data.AppInfo;
 import com.android.launcher3.model.data.ItemInfo;
 import com.android.launcher3.model.data.LauncherAppWidgetInfo;
-import com.android.launcher3.testing.TestProtocol;
 import com.android.launcher3.util.IntArray;
 import com.android.launcher3.util.IntSet;
 import com.android.launcher3.util.LooperExecutor;
@@ -174,20 +173,8 @@
             ArrayList<LauncherAppWidgetInfo> currentAppWidgets = new ArrayList<>();
             ArrayList<LauncherAppWidgetInfo> otherAppWidgets = new ArrayList<>();
 
-            if (TestProtocol.sDebugTracing) {
-                Log.d(TestProtocol.NULL_INT_SET, "bind (1) currentScreenIds: "
-                        + currentScreenIds
-                        + ", pointer: "
-                        + mCallbacks
-                        + ", name: "
-                        + mCallbacks.getClass().getName());
-            }
             filterCurrentWorkspaceItems(currentScreenIds, mWorkspaceItems, currentWorkspaceItems,
                     otherWorkspaceItems);
-            if (TestProtocol.sDebugTracing) {
-                Log.d(TestProtocol.NULL_INT_SET, "bind (2) currentScreenIds: "
-                        + currentScreenIds);
-            }
             filterCurrentWorkspaceItems(currentScreenIds, mAppWidgets, currentAppWidgets,
                     otherAppWidgets);
             final InvariantDeviceProfile idp = mApp.getInvariantDeviceProfile();
diff --git a/src/com/android/launcher3/model/ModelDelegate.java b/src/com/android/launcher3/model/ModelDelegate.java
index 3bd9470..cc42258 100644
--- a/src/com/android/launcher3/model/ModelDelegate.java
+++ b/src/com/android/launcher3/model/ModelDelegate.java
@@ -90,9 +90,10 @@
      */
     @WorkerThread
     public void loadStringCache(StringCache cache) {
-        cache.loadStrings(mContext);
+        cache.loadDefaultStrings(mContext);
     }
 
+
     /**
      * Called during loader after workspace loading is complete
      */
diff --git a/src/com/android/launcher3/model/ModelUtils.java b/src/com/android/launcher3/model/ModelUtils.java
index ef5eef1..58aa9e5 100644
--- a/src/com/android/launcher3/model/ModelUtils.java
+++ b/src/com/android/launcher3/model/ModelUtils.java
@@ -31,7 +31,6 @@
 import com.android.launcher3.icons.LauncherIcons;
 import com.android.launcher3.model.data.ItemInfo;
 import com.android.launcher3.model.data.WorkspaceItemInfo;
-import com.android.launcher3.testing.TestProtocol;
 import com.android.launcher3.util.IntArray;
 import com.android.launcher3.util.IntSet;
 
@@ -67,10 +66,6 @@
                 (lhs, rhs) -> Integer.compare(lhs.container, rhs.container));
         for (T info : allWorkspaceItems) {
             if (info.container == LauncherSettings.Favorites.CONTAINER_DESKTOP) {
-                if (TestProtocol.sDebugTracing) {
-                    Log.d(TestProtocol.NULL_INT_SET, "filterCurrentWorkspaceItems: "
-                            + currentScreenIds);
-                }
                 if (currentScreenIds.contains(info.screenId)) {
                     currentScreenItems.add(info);
                     itemsOnScreen.add(info.id);
diff --git a/src/com/android/launcher3/model/StringCache.java b/src/com/android/launcher3/model/StringCache.java
index 2fc852d..11d3e70 100644
--- a/src/com/android/launcher3/model/StringCache.java
+++ b/src/com/android/launcher3/model/StringCache.java
@@ -16,100 +16,16 @@
 
 package com.android.launcher3.model;
 
-import android.app.admin.DevicePolicyManager;
 import android.content.Context;
-import android.os.Build;
-
-import androidx.annotation.RequiresApi;
 
 import com.android.launcher3.R;
-import com.android.launcher3.Utilities;
 
 /**
  *
- * Cache for the device policy strings used in Launcher.
+ * Cache for some of the string used in Launcher.
  */
 public class StringCache {
 
-    private static final String PREFIX = "Launcher.";
-
-    /**
-     * User on-boarding title for work profile apps.
-     */
-    private static final String WORK_PROFILE_EDU = PREFIX + "WORK_PROFILE_EDU";
-
-    /**
-     * Action label to finish work profile edu.
-     */
-    private static final String WORK_PROFILE_EDU_ACCEPT = PREFIX + "WORK_PROFILE_EDU_ACCEPT";
-
-    /**
-     * Title shown when user opens work apps tab while work profile is paused.
-     */
-    private static final String WORK_PROFILE_PAUSED_TITLE =
-            PREFIX + "WORK_PROFILE_PAUSED_TITLE";
-
-    /**
-     * Description shown when user opens work apps tab while work profile is paused.
-     */
-    private static final String WORK_PROFILE_PAUSED_DESCRIPTION =
-            PREFIX + "WORK_PROFILE_PAUSED_DESCRIPTION";
-
-    /**
-     * Shown on the button to pause work profile.
-     */
-    private static final String WORK_PROFILE_PAUSE_BUTTON =
-            PREFIX + "WORK_PROFILE_PAUSE_BUTTON";
-
-    /**
-     * Shown on the button to enable work profile.
-     */
-    private static final String WORK_PROFILE_ENABLE_BUTTON =
-            PREFIX + "WORK_PROFILE_ENABLE_BUTTON";
-
-    /**
-     * Label on launcher tab to indicate work apps.
-     */
-    private static final String ALL_APPS_WORK_TAB = PREFIX + "ALL_APPS_WORK_TAB";
-
-    /**
-     * Label on launcher tab to indicate personal apps.
-     */
-    private static final String ALL_APPS_PERSONAL_TAB = PREFIX + "ALL_APPS_PERSONAL_TAB";
-
-    /**
-     * Accessibility description for launcher tab to indicate work apps.
-     */
-    private static final String ALL_APPS_WORK_TAB_ACCESSIBILITY =
-            PREFIX + "ALL_APPS_WORK_TAB_ACCESSIBILITY";
-
-    /**
-     * Accessibility description for launcher tab to indicate personal apps.
-     */
-    private static final String ALL_APPS_PERSONAL_TAB_ACCESSIBILITY =
-            PREFIX + "ALL_APPS_PERSONAL_TAB_ACCESSIBILITY";
-
-    /**
-     * Work folder name.
-     */
-    private static final String WORK_FOLDER_NAME = PREFIX + "WORK_FOLDER_NAME";
-
-    /**
-     * Label on widget tab to indicate work app widgets.
-     */
-    private static final String WIDGETS_WORK_TAB = PREFIX + "WIDGETS_WORK_TAB";
-
-    /**
-     * Label on widget tab to indicate personal app widgets.
-     */
-    private static final String WIDGETS_PERSONAL_TAB = PREFIX + "WIDGETS_PERSONAL_TAB";
-
-    /**
-     * Message shown when a feature is disabled by the admin (e.g. changing wallpaper).
-     */
-    private static final String DISABLED_BY_ADMIN_MESSAGE =
-            PREFIX + "DISABLED_BY_ADMIN_MESSAGE";
-
     /**
      * User on-boarding title for work profile apps.
      */
@@ -183,51 +99,22 @@
     /**
      * Sets the default values for the strings.
      */
-    public void loadStrings(Context context) {
-        workProfileEdu = getEnterpriseString(
-                context, WORK_PROFILE_EDU, R.string.work_profile_edu_work_apps);
-        workProfileEduAccept = getEnterpriseString(
-                context, WORK_PROFILE_EDU_ACCEPT, R.string.work_profile_edu_accept);
-        workProfilePausedTitle = getEnterpriseString(
-                context, WORK_PROFILE_PAUSED_TITLE, R.string.work_apps_paused_title);
-        workProfilePausedDescription = getEnterpriseString(
-                context, WORK_PROFILE_PAUSED_DESCRIPTION, R.string.work_apps_paused_body);
-        workProfilePauseButton = getEnterpriseString(
-                context, WORK_PROFILE_PAUSE_BUTTON, R.string.work_apps_pause_btn_text);
-        workProfileEnableButton = getEnterpriseString(
-                context, WORK_PROFILE_ENABLE_BUTTON, R.string.work_apps_enable_btn_text);
-        allAppsWorkTab = getEnterpriseString(
-                context, ALL_APPS_WORK_TAB, R.string.all_apps_work_tab);
-        allAppsPersonalTab = getEnterpriseString(
-                context, ALL_APPS_PERSONAL_TAB, R.string.all_apps_personal_tab);
-        allAppsWorkTabAccessibility = getEnterpriseString(
-                context, ALL_APPS_WORK_TAB_ACCESSIBILITY, R.string.all_apps_button_work_label);
-        allAppsPersonalTabAccessibility = getEnterpriseString(
-                context, ALL_APPS_PERSONAL_TAB_ACCESSIBILITY,
+    public void loadDefaultStrings(Context context) {
+        workProfileEdu = context.getString(R.string.work_profile_edu_work_apps);
+        workProfileEduAccept = context.getString(R.string.work_profile_edu_accept);
+        workProfilePausedTitle = context.getString(R.string.work_apps_paused_title);
+        workProfilePausedDescription = context.getString(R.string.work_apps_paused_body);
+        workProfilePauseButton = context.getString(R.string.work_apps_pause_btn_text);
+        workProfileEnableButton = context.getString(R.string.work_apps_enable_btn_text);
+        allAppsWorkTab = context.getString(R.string.all_apps_work_tab);
+        allAppsPersonalTab = context.getString(R.string.all_apps_personal_tab);
+        allAppsWorkTabAccessibility = context.getString(R.string.all_apps_button_work_label);
+        allAppsPersonalTabAccessibility = context.getString(
                 R.string.all_apps_button_personal_label);
-        workFolderName = getEnterpriseString(
-                context, WORK_FOLDER_NAME, R.string.work_folder_name);
-        widgetsWorkTab = getEnterpriseString(
-                context, WIDGETS_WORK_TAB, R.string.widgets_full_sheet_work_tab);
-        widgetsPersonalTab = getEnterpriseString(
-                context, WIDGETS_PERSONAL_TAB, R.string.widgets_full_sheet_personal_tab);
-        disabledByAdminMessage = getEnterpriseString(
-                context, DISABLED_BY_ADMIN_MESSAGE, R.string.msg_disabled_by_admin);
-    }
-
-    private String getEnterpriseString(
-            Context context, String updatableStringId, int defaultStringId) {
-        return Utilities.ATLEAST_T
-                ? getUpdatableEnterpriseSting(context, updatableStringId, defaultStringId)
-                : context.getString(defaultStringId);
-    }
-
-    @RequiresApi(Build.VERSION_CODES.TIRAMISU)
-    private String getUpdatableEnterpriseSting(
-            Context context, String updatableStringId, int defaultStringId) {
-        DevicePolicyManager dpm = context.getSystemService(DevicePolicyManager.class);
-        return dpm.getResources().getString(
-                updatableStringId, () -> context.getString(defaultStringId));
+        workFolderName = context.getString(R.string.work_folder_name);
+        widgetsWorkTab = context.getString(R.string.widgets_full_sheet_work_tab);
+        widgetsPersonalTab = context.getString(R.string.widgets_full_sheet_personal_tab);
+        disabledByAdminMessage = context.getString(R.string.msg_disabled_by_admin);
     }
 
     @Override
diff --git a/src/com/android/launcher3/testing/TestProtocol.java b/src/com/android/launcher3/testing/TestProtocol.java
index faf5817..ac89df2 100644
--- a/src/com/android/launcher3/testing/TestProtocol.java
+++ b/src/com/android/launcher3/testing/TestProtocol.java
@@ -134,7 +134,6 @@
 
     public static final String PERMANENT_DIAG_TAG = "TaplTarget";
     public static final String NO_DROP_TARGET = "b/195031154";
-    public static final String NULL_INT_SET = "b/200572078";
     public static final String MISSING_PROMISE_ICON = "b/202985412";
 
     public static final String BAD_STATE = "b/223498680";