Add multi-instance state to item infos

- Add legacy resource for supported multi-instance apps that
  matches the current SystemUI resource of the same name, and will
  be removed as apps migrate to the V manifest property to declare
  multi-instance support
- Load the multi-instance state from PackageManager when the db is
  first loaded or when packages are updated
- The multi-instance check is then used to determine if an app pair
  can be saved (ie. whether the action can be shown)

Bug: 323112914
Test: atest NexusLauncherTests

Change-Id: I565b4bee4ab5f7040910306b1fd60a4fc3bf9a1c
This commit is contained in:
Winson Chung
2024-05-08 21:14:57 +00:00
parent bfdd7d27c0
commit 94e8ad0731
22 changed files with 277 additions and 122 deletions

View File

@@ -73,6 +73,7 @@ import com.android.launcher3.shortcuts.ShortcutKey;
import com.android.launcher3.util.ApiWrapper;
import com.android.launcher3.util.Executors;
import com.android.launcher3.util.IntSparseArrayMap;
import com.android.launcher3.util.PackageManagerHelper;
import com.android.launcher3.util.PersistedItemArray;
import com.android.quickstep.logging.SettingsChangeLogger;
import com.android.quickstep.logging.StatsLogCompatManager;
@@ -150,7 +151,8 @@ public class QuickstepModelDelegate extends ModelDelegate {
// TODO: Implement caching and preloading
WorkspaceItemFactory factory =
new WorkspaceItemFactory(mApp, ums, pinnedShortcuts, numColumns, state.containerId);
new WorkspaceItemFactory(mApp, ums, mPmHelper, pinnedShortcuts, numColumns,
state.containerId);
FixedContainerItems fci = new FixedContainerItems(state.containerId,
state.storage.read(mApp.getContext(), factory, ums.allUsers::get));
if (FeatureFlags.CHANGE_MODEL_DELEGATE_LOADING_ORDER.get()) {
@@ -530,6 +532,7 @@ public class QuickstepModelDelegate extends ModelDelegate {
private final LauncherAppState mAppState;
private final UserManagerState mUMS;
private final PackageManagerHelper mPmHelper;
private final Map<ShortcutKey, ShortcutInfo> mPinnedShortcuts;
private final int mMaxCount;
private final int mContainer;
@@ -537,9 +540,11 @@ public class QuickstepModelDelegate extends ModelDelegate {
private int mReadCount = 0;
protected WorkspaceItemFactory(LauncherAppState appState, UserManagerState ums,
Map<ShortcutKey, ShortcutInfo> pinnedShortcuts, int maxCount, int container) {
PackageManagerHelper pmHelper, Map<ShortcutKey, ShortcutInfo> pinnedShortcuts,
int maxCount, int container) {
mAppState = appState;
mUMS = ums;
mPmHelper = pmHelper;
mPinnedShortcuts = pinnedShortcuts;
mMaxCount = maxCount;
mContainer = container;
@@ -563,6 +568,7 @@ public class QuickstepModelDelegate extends ModelDelegate {
lai,
UserCache.INSTANCE.get(mAppState.getContext()).getUserInfo(user),
ApiWrapper.INSTANCE.get(mAppState.getContext()),
mPmHelper,
mUMS.isUserQuiet(user));
info.container = mContainer;
mAppState.getIconCache().getTitleAndIcon(info, lai, false);