Merge remote-tracking branch 'aosp/android12L-release' into 12.1-dev
This commit is contained in:
@@ -16,7 +16,6 @@
|
||||
|
||||
package com.android.launcher3.model;
|
||||
|
||||
import static com.android.launcher3.config.FeatureFlags.MULTI_DB_GRID_MIRATION_ALGO;
|
||||
import static com.android.launcher3.model.BgDataModel.Callbacks.FLAG_HAS_SHORTCUT_PERMISSION;
|
||||
import static com.android.launcher3.model.BgDataModel.Callbacks.FLAG_QUIET_MODE_CHANGE_PERMISSION;
|
||||
import static com.android.launcher3.model.BgDataModel.Callbacks.FLAG_QUIET_MODE_ENABLED;
|
||||
@@ -44,6 +43,7 @@ import android.content.pm.ShortcutInfo;
|
||||
import android.graphics.Point;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.os.Trace;
|
||||
import android.os.UserHandle;
|
||||
import android.os.UserManager;
|
||||
import android.text.TextUtils;
|
||||
@@ -52,6 +52,8 @@ import android.util.Log;
|
||||
import android.util.LongSparseArray;
|
||||
import android.util.TimingLogger;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.android.launcher3.DeviceProfile;
|
||||
import com.android.launcher3.InvariantDeviceProfile;
|
||||
import com.android.launcher3.LauncherAppState;
|
||||
@@ -73,6 +75,7 @@ import com.android.launcher3.icons.cache.IconCacheUpdateHandler;
|
||||
import com.android.launcher3.logging.FileLog;
|
||||
import com.android.launcher3.model.data.AppInfo;
|
||||
import com.android.launcher3.model.data.FolderInfo;
|
||||
import com.android.launcher3.model.data.IconRequestInfo;
|
||||
import com.android.launcher3.model.data.ItemInfo;
|
||||
import com.android.launcher3.model.data.ItemInfoWithIcon;
|
||||
import com.android.launcher3.model.data.LauncherAppWidgetInfo;
|
||||
@@ -80,13 +83,14 @@ import com.android.launcher3.model.data.WorkspaceItemInfo;
|
||||
import com.android.launcher3.pm.InstallSessionHelper;
|
||||
import com.android.launcher3.pm.PackageInstallInfo;
|
||||
import com.android.launcher3.pm.UserCache;
|
||||
import com.android.launcher3.provider.ImportDataTask;
|
||||
import com.android.launcher3.qsb.QsbContainerView;
|
||||
import com.android.launcher3.shortcuts.ShortcutKey;
|
||||
import com.android.launcher3.shortcuts.ShortcutRequest;
|
||||
import com.android.launcher3.shortcuts.ShortcutRequest.QueryResult;
|
||||
import com.android.launcher3.util.ComponentKey;
|
||||
import com.android.launcher3.util.IOUtils;
|
||||
import com.android.launcher3.util.IntArray;
|
||||
import com.android.launcher3.util.IntSet;
|
||||
import com.android.launcher3.util.LooperIdleLock;
|
||||
import com.android.launcher3.util.PackageManagerHelper;
|
||||
import com.android.launcher3.util.PackageUserKey;
|
||||
@@ -177,10 +181,13 @@ public class LoaderTask implements Runnable {
|
||||
private void sendFirstScreenActiveInstallsBroadcast() {
|
||||
ArrayList<ItemInfo> firstScreenItems = new ArrayList<>();
|
||||
ArrayList<ItemInfo> allItems = mBgDataModel.getAllWorkspaceItems();
|
||||
// Screen set is never empty
|
||||
final int firstScreen = mBgDataModel.collectWorkspaceScreens().get(0);
|
||||
|
||||
filterCurrentWorkspaceItems(firstScreen, allItems, firstScreenItems,
|
||||
// Screen set is never empty
|
||||
IntArray allScreens = mBgDataModel.collectWorkspaceScreens();
|
||||
final int firstScreen = allScreens.get(0);
|
||||
IntSet firstScreens = IntSet.wrap(firstScreen);
|
||||
|
||||
filterCurrentWorkspaceItems(firstScreens, allItems, firstScreenItems,
|
||||
new ArrayList<>() /* otherScreenItems are ignored */);
|
||||
mFirstScreenBroadcast.sendBroadcasts(mApp.getContext(), firstScreenItems);
|
||||
}
|
||||
@@ -195,9 +202,15 @@ public class LoaderTask implements Runnable {
|
||||
|
||||
Object traceToken = TraceHelper.INSTANCE.beginSection(TAG);
|
||||
TimingLogger logger = new TimingLogger(TAG, "run");
|
||||
LoaderMemoryLogger memoryLogger = new LoaderMemoryLogger();
|
||||
try (LauncherModel.LoaderTransaction transaction = mApp.getModel().beginLoader(this)) {
|
||||
List<ShortcutInfo> allShortcuts = new ArrayList<>();
|
||||
loadWorkspace(allShortcuts);
|
||||
Trace.beginSection("LoadWorkspace");
|
||||
try {
|
||||
loadWorkspace(allShortcuts, memoryLogger);
|
||||
} finally {
|
||||
Trace.endSection();
|
||||
}
|
||||
logASplit(logger, "loadWorkspace");
|
||||
|
||||
// Sanitize data re-syncs widgets/shortcuts based on the workspace loaded from db.
|
||||
@@ -211,7 +224,7 @@ public class LoaderTask implements Runnable {
|
||||
}
|
||||
|
||||
verifyNotStopped();
|
||||
mResults.bindWorkspace();
|
||||
mResults.bindWorkspace(true /* incrementBindId */);
|
||||
logASplit(logger, "bindWorkspace");
|
||||
|
||||
mModelDelegate.workspaceLoadComplete();
|
||||
@@ -225,7 +238,13 @@ public class LoaderTask implements Runnable {
|
||||
verifyNotStopped();
|
||||
|
||||
// second step
|
||||
List<LauncherActivityInfo> allActivityList = loadAllApps();
|
||||
Trace.beginSection("LoadAllApps");
|
||||
List<LauncherActivityInfo> allActivityList;
|
||||
try {
|
||||
allActivityList = loadAllApps();
|
||||
} finally {
|
||||
Trace.endSection();
|
||||
}
|
||||
logASplit(logger, "loadAllApps");
|
||||
|
||||
verifyNotStopped();
|
||||
@@ -298,9 +317,13 @@ public class LoaderTask implements Runnable {
|
||||
|
||||
mModelDelegate.modelLoadComplete();
|
||||
transaction.commit();
|
||||
memoryLogger.clearLogs();
|
||||
} catch (CancellationException e) {
|
||||
// Loader stopped, ignore
|
||||
logASplit(logger, "Cancelled");
|
||||
} catch (Exception e) {
|
||||
memoryLogger.printLogs();
|
||||
throw e;
|
||||
} finally {
|
||||
logger.dumpToLog();
|
||||
}
|
||||
@@ -312,13 +335,21 @@ public class LoaderTask implements Runnable {
|
||||
this.notify();
|
||||
}
|
||||
|
||||
private void loadWorkspace(List<ShortcutInfo> allDeepShortcuts) {
|
||||
private void loadWorkspace(List<ShortcutInfo> allDeepShortcuts, LoaderMemoryLogger logger) {
|
||||
loadWorkspace(allDeepShortcuts, LauncherSettings.Favorites.CONTENT_URI,
|
||||
null /* selection */);
|
||||
null /* selection */, logger);
|
||||
}
|
||||
|
||||
protected void loadWorkspace(List<ShortcutInfo> allDeepShortcuts, Uri contentUri,
|
||||
String selection) {
|
||||
protected void loadWorkspace(
|
||||
List<ShortcutInfo> allDeepShortcuts, Uri contentUri, String selection) {
|
||||
loadWorkspace(allDeepShortcuts, contentUri, selection, null);
|
||||
}
|
||||
|
||||
protected void loadWorkspace(
|
||||
List<ShortcutInfo> allDeepShortcuts,
|
||||
Uri contentUri,
|
||||
String selection,
|
||||
@Nullable LoaderMemoryLogger logger) {
|
||||
final Context context = mApp.getContext();
|
||||
final ContentResolver contentResolver = context.getContentResolver();
|
||||
final PackageManagerHelper pmHelper = new PackageManagerHelper(context);
|
||||
@@ -327,16 +358,7 @@ public class LoaderTask implements Runnable {
|
||||
final WidgetManagerHelper widgetHelper = new WidgetManagerHelper(context);
|
||||
|
||||
boolean clearDb = false;
|
||||
try {
|
||||
ImportDataTask.performImportIfPossible(context);
|
||||
} catch (Exception e) {
|
||||
// Migration failed. Clear workspace.
|
||||
clearDb = true;
|
||||
}
|
||||
|
||||
if (!clearDb && (MULTI_DB_GRID_MIRATION_ALGO.get()
|
||||
? !GridSizeMigrationTaskV2.migrateGridIfNeeded(context)
|
||||
: !GridSizeMigrationTask.migrateGridIfNeeded(context))) {
|
||||
if (!GridSizeMigrationTaskV2.migrateGridIfNeeded(context)) {
|
||||
// Migration failed. Clear workspace.
|
||||
clearDb = true;
|
||||
}
|
||||
@@ -421,6 +443,7 @@ public class LoaderTask implements Runnable {
|
||||
LauncherAppWidgetProviderInfo widgetProviderInfo;
|
||||
Intent intent;
|
||||
String targetPkg;
|
||||
List<IconRequestInfo<WorkspaceItemInfo>> iconRequestInfos = new ArrayList<>();
|
||||
|
||||
while (!mStopped && c.moveToNext()) {
|
||||
try {
|
||||
@@ -543,7 +566,10 @@ public class LoaderTask implements Runnable {
|
||||
} else if (c.itemType ==
|
||||
LauncherSettings.Favorites.ITEM_TYPE_APPLICATION) {
|
||||
info = c.getAppShortcutInfo(
|
||||
intent, allowMissingTarget, useLowResIcon);
|
||||
intent,
|
||||
allowMissingTarget,
|
||||
useLowResIcon,
|
||||
!FeatureFlags.ENABLE_BULK_WORKSPACE_ICON_LOADING.get());
|
||||
} else if (c.itemType ==
|
||||
LauncherSettings.Favorites.ITEM_TYPE_DEEP_SHORTCUT) {
|
||||
|
||||
@@ -580,6 +606,7 @@ public class LoaderTask implements Runnable {
|
||||
&& pmHelper.isAppSuspended(targetPkg, c.user)) {
|
||||
disabledState |= FLAG_DISABLED_SUSPENDED;
|
||||
}
|
||||
info.options = c.getInt(optionsIndex);
|
||||
|
||||
// App shortcuts that used to be automatically added to Launcher
|
||||
// didn't always have the correct intent flags set, so do that
|
||||
@@ -595,6 +622,8 @@ public class LoaderTask implements Runnable {
|
||||
}
|
||||
|
||||
if (info != null) {
|
||||
iconRequestInfos.add(c.createIconRequestInfo(info, useLowResIcon));
|
||||
|
||||
c.applyCommonProperties(info);
|
||||
|
||||
info.intent = intent;
|
||||
@@ -628,7 +657,7 @@ public class LoaderTask implements Runnable {
|
||||
}
|
||||
}
|
||||
|
||||
c.checkAndAddItem(info, mBgDataModel);
|
||||
c.checkAndAddItem(info, mBgDataModel, logger);
|
||||
} else {
|
||||
throw new RuntimeException("Unexpected null WorkspaceItemInfo");
|
||||
}
|
||||
@@ -647,7 +676,7 @@ public class LoaderTask implements Runnable {
|
||||
// no special handling required for restored folders
|
||||
c.markRestored();
|
||||
|
||||
c.checkAndAddItem(folderInfo, mBgDataModel);
|
||||
c.checkAndAddItem(folderInfo, mBgDataModel, logger);
|
||||
break;
|
||||
|
||||
case LauncherSettings.Favorites.ITEM_TYPE_APPWIDGET:
|
||||
@@ -798,8 +827,9 @@ public class LoaderTask implements Runnable {
|
||||
if (appWidgetInfo.restoreStatus !=
|
||||
LauncherAppWidgetInfo.RESTORE_COMPLETED) {
|
||||
appWidgetInfo.pendingItemInfo = WidgetsModel.newPendingItemInfo(
|
||||
appWidgetInfo.providerName);
|
||||
appWidgetInfo.pendingItemInfo.user = appWidgetInfo.user;
|
||||
mApp.getContext(),
|
||||
appWidgetInfo.providerName,
|
||||
appWidgetInfo.user);
|
||||
mIconCache.getTitleAndIconForApp(
|
||||
appWidgetInfo.pendingItemInfo, false);
|
||||
}
|
||||
@@ -812,6 +842,21 @@ public class LoaderTask implements Runnable {
|
||||
Log.e(TAG, "Desktop items loading interrupted", e);
|
||||
}
|
||||
}
|
||||
if (FeatureFlags.ENABLE_BULK_WORKSPACE_ICON_LOADING.get()) {
|
||||
Trace.beginSection("LoadWorkspaceIconsInBulk");
|
||||
try {
|
||||
mIconCache.getTitlesAndIconsInBulk(iconRequestInfos);
|
||||
for (IconRequestInfo<WorkspaceItemInfo> iconRequestInfo :
|
||||
iconRequestInfos) {
|
||||
WorkspaceItemInfo wai = iconRequestInfo.itemInfo;
|
||||
if (mIconCache.isDefaultIcon(wai.bitmap, wai.user)) {
|
||||
iconRequestInfo.loadWorkspaceIcon(mApp.getContext());
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
Trace.endSection();
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
IOUtils.closeSilently(c);
|
||||
}
|
||||
@@ -915,6 +960,8 @@ public class LoaderTask implements Runnable {
|
||||
List<LauncherActivityInfo> allActivityList = new ArrayList<>();
|
||||
// Clear the list of apps
|
||||
mBgAllAppsList.clear();
|
||||
|
||||
List<IconRequestInfo<AppInfo>> iconRequestInfos = new ArrayList<>();
|
||||
for (UserHandle user : profiles) {
|
||||
// Query for the set of apps
|
||||
final List<LauncherActivityInfo> apps = mLauncherApps.getActivityList(null, user);
|
||||
@@ -927,18 +974,43 @@ public class LoaderTask implements Runnable {
|
||||
// Create the ApplicationInfos
|
||||
for (int i = 0; i < apps.size(); i++) {
|
||||
LauncherActivityInfo app = apps.get(i);
|
||||
// This builds the icon bitmaps.
|
||||
mBgAllAppsList.add(new AppInfo(app, user, quietMode), app);
|
||||
AppInfo appInfo = new AppInfo(app, user, quietMode);
|
||||
|
||||
iconRequestInfos.add(new IconRequestInfo<>(
|
||||
appInfo, app, /* useLowResIcon= */ false));
|
||||
mBgAllAppsList.add(
|
||||
appInfo, app, !FeatureFlags.ENABLE_BULK_ALL_APPS_ICON_LOADING.get());
|
||||
}
|
||||
allActivityList.addAll(apps);
|
||||
}
|
||||
|
||||
|
||||
if (FeatureFlags.PROMISE_APPS_IN_ALL_APPS.get()) {
|
||||
// get all active sessions and add them to the all apps list
|
||||
for (PackageInstaller.SessionInfo info :
|
||||
mSessionHelper.getAllVerifiedSessions()) {
|
||||
mBgAllAppsList.addPromiseApp(mApp.getContext(),
|
||||
PackageInstallInfo.fromInstallingState(info));
|
||||
AppInfo promiseAppInfo = mBgAllAppsList.addPromiseApp(
|
||||
mApp.getContext(),
|
||||
PackageInstallInfo.fromInstallingState(info),
|
||||
!FeatureFlags.ENABLE_BULK_ALL_APPS_ICON_LOADING.get());
|
||||
|
||||
if (promiseAppInfo != null) {
|
||||
iconRequestInfos.add(new IconRequestInfo<>(
|
||||
promiseAppInfo,
|
||||
/* launcherActivityInfo= */ null,
|
||||
promiseAppInfo.usingLowResIcon()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (FeatureFlags.ENABLE_BULK_ALL_APPS_ICON_LOADING.get()) {
|
||||
Trace.beginSection("LoadAllAppsIconsInBulk");
|
||||
try {
|
||||
mIconCache.getTitlesAndIconsInBulk(iconRequestInfos);
|
||||
iconRequestInfos.forEach(iconRequestInfo ->
|
||||
mBgAllAppsList.updateSectionName(iconRequestInfo.itemInfo));
|
||||
} finally {
|
||||
Trace.endSection();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1001,7 +1073,10 @@ public class LoaderTask implements Runnable {
|
||||
deviceProfile.getCellSize(cellSize);
|
||||
FileLog.d(TAG, "DeviceProfile available width: " + deviceProfile.availableWidthPx
|
||||
+ ", available height: " + deviceProfile.availableHeightPx
|
||||
+ ", cellLayoutBorderSpacingPx: " + deviceProfile.cellLayoutBorderSpacingPx
|
||||
+ ", cellLayoutBorderSpacePx Horizontal: "
|
||||
+ deviceProfile.cellLayoutBorderSpacePx.x
|
||||
+ ", cellLayoutBorderSpacePx Vertical: "
|
||||
+ deviceProfile.cellLayoutBorderSpacePx.y
|
||||
+ ", cellSize: " + cellSize);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user