fix: Conflict incoming changes from 15-dev
This commit is contained in:
1 parent
14e352c827
commit
2e76c99dad
1726 files changed
+146970
-95027
No files matched your search
@@ -50,7 +50,6 @@ import androidx.core.util.Pair;
|
||||
|
||||
import com.android.launcher3.Flags;
|
||||
import com.android.launcher3.InvariantDeviceProfile;
|
||||
import com.android.launcher3.LauncherFiles;
|
||||
import com.android.launcher3.Utilities;
|
||||
import com.android.launcher3.dagger.ApplicationContext;
|
||||
import com.android.launcher3.dagger.LauncherAppSingleton;
|
||||
@@ -67,6 +66,8 @@ import com.android.launcher3.model.data.PackageItemInfo;
|
||||
import com.android.launcher3.model.data.WorkspaceItemInfo;
|
||||
import com.android.launcher3.pm.InstallSessionHelper;
|
||||
import com.android.launcher3.pm.UserCache;
|
||||
import com.android.launcher3.shortcuts.ShortcutKey;
|
||||
import com.android.launcher3.shortcuts.ShortcutRequest;
|
||||
import com.android.launcher3.util.CancellableTask;
|
||||
import com.android.launcher3.util.ComponentKey;
|
||||
import com.android.launcher3.util.DaggerSingletonTracker;
|
||||
@@ -86,8 +87,6 @@ import java.util.stream.Stream;
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
|
||||
import app.lawnchair.icons.LawnchairIconProvider;
|
||||
|
||||
/**
|
||||
* Cache of application icons. Icons can be made from any thread.
|
||||
*/
|
||||
@@ -97,12 +96,12 @@ public class IconCache extends BaseIconCache {
|
||||
// Shortcut extra which can point to a packageName and can be used to indicate an alternate
|
||||
// badge info. Launcher only reads this if the shortcut comes from a system app.
|
||||
public static final String EXTRA_SHORTCUT_BADGE_OVERRIDE_PACKAGE =
|
||||
"extra_shortcut_badge_override_package";
|
||||
"extra_shortcut_badge_override_package";
|
||||
|
||||
private static final String TAG = "Launcher.IconCache";
|
||||
|
||||
private final Predicate<ItemInfoWithIcon> mIsUsingFallbackOrNonDefaultIconCheck = w ->
|
||||
w.bitmap != null && (w.bitmap.isNullOrLowRes() || !isDefaultIcon(w.bitmap, w.user));
|
||||
w.bitmap != null && (w.bitmap.isNullOrLowRes() || !isDefaultIcon(w.bitmap, w.user));
|
||||
|
||||
private final LauncherApps mLauncherApps;
|
||||
private final UserCache mUserManager;
|
||||
@@ -115,40 +114,27 @@ public class IconCache extends BaseIconCache {
|
||||
|
||||
private int mPendingIconRequestCount = 0;
|
||||
|
||||
// Lawnchair: Apply 3p icon pack
|
||||
public IconCache(Context context, InvariantDeviceProfile idp, LauncherIcons.IconPool iconPool, DaggerSingletonTracker lifecycle) {
|
||||
this(
|
||||
context,
|
||||
idp,
|
||||
LauncherFiles.APP_ICONS_DB,
|
||||
UserCache.INSTANCE.get(context),
|
||||
new LawnchairIconProvider(context),
|
||||
InstallSessionHelper.INSTANCE.get(context),
|
||||
iconPool,
|
||||
lifecycle
|
||||
);
|
||||
}
|
||||
|
||||
@Inject
|
||||
public IconCache(
|
||||
@ApplicationContext Context context,
|
||||
InvariantDeviceProfile idp,
|
||||
@Nullable @Named("ICONS_DB") String dbFileName,
|
||||
UserCache userCache,
|
||||
LauncherIconProvider iconProvider,
|
||||
// TODO: Lawnchair stuff
|
||||
// IconProvider iconProvider,
|
||||
InstallSessionHelper installSessionHelper,
|
||||
LauncherIcons.IconPool iconPool,
|
||||
DaggerSingletonTracker lifecycle) {
|
||||
@ApplicationContext Context context,
|
||||
InvariantDeviceProfile idp,
|
||||
@Nullable @Named("ICONS_DB") String dbFileName,
|
||||
UserCache userCache,
|
||||
LauncherIconProvider iconProvider,
|
||||
// TODO: Lawnchair stuff
|
||||
// IconProvider iconProvider,
|
||||
InstallSessionHelper installSessionHelper,
|
||||
LauncherIcons.IconPool iconPool,
|
||||
InstantAppResolver instantAppResolver,
|
||||
DaggerSingletonTracker lifecycle) {
|
||||
super(context, dbFileName, MODEL_EXECUTOR.getLooper(),
|
||||
idp.fillResIconDpi, idp.iconBitmapSize, true /* inMemoryCache */, iconProvider);
|
||||
idp.fillResIconDpi, idp.iconBitmapSize, true /* inMemoryCache */, iconProvider);
|
||||
mLauncherApps = context.getSystemService(LauncherApps.class);
|
||||
mUserManager = userCache;
|
||||
mInstallSessionHelper = installSessionHelper;
|
||||
mIconPool = iconPool;
|
||||
|
||||
mInstantAppResolver = InstantAppResolver.newInstance(context);
|
||||
mInstantAppResolver = instantAppResolver;
|
||||
mWidgetCategoryBitmapInfos = new SparseArray<>();
|
||||
|
||||
mCancelledTask = new CancellableTask(() -> null, MAIN_EXECUTOR, c -> { });
|
||||
@@ -202,7 +188,7 @@ public class IconCache extends BaseIconCache {
|
||||
* Updates the entries related to the given package in memory and persistent DB.
|
||||
*/
|
||||
public synchronized void updateIconsForPkg(@NonNull final String packageName,
|
||||
@NonNull final UserHandle user) {
|
||||
@NonNull final UserHandle user) {
|
||||
List<LauncherActivityInfo> apps = mLauncherApps.getActivityList(packageName, user);
|
||||
if (Utilities.ATLEAST_V) {
|
||||
if (Flags.restoreArchivedAppIconsFromDb()
|
||||
@@ -235,21 +221,21 @@ public class IconCache extends BaseIconCache {
|
||||
*/
|
||||
@AnyThread
|
||||
public CancellableTask updateIconInBackground(final ItemInfoUpdateReceiver caller,
|
||||
final ItemInfoWithIcon info) {
|
||||
final ItemInfoWithIcon info, final CacheLookupFlag lookupFlag) {
|
||||
Supplier<ItemInfoWithIcon> task;
|
||||
if (info instanceof AppInfo || info instanceof WorkspaceItemInfo) {
|
||||
task = () -> {
|
||||
getTitleAndIcon(info, DEFAULT_LOOKUP_FLAG);
|
||||
getTitleAndIcon(info, lookupFlag);
|
||||
return info;
|
||||
};
|
||||
} else if (info instanceof PackageItemInfo pii) {
|
||||
task = () -> {
|
||||
getTitleAndIconForApp(pii, DEFAULT_LOOKUP_FLAG);
|
||||
getTitleAndIconForApp(pii, lookupFlag);
|
||||
return pii;
|
||||
};
|
||||
} else {
|
||||
Log.i(TAG, "Icon update not supported for "
|
||||
+ info == null ? "null" : info.getClass().getName());
|
||||
+ info == null ? "null" : info.getClass().getName());
|
||||
return mCancelledTask;
|
||||
}
|
||||
|
||||
@@ -265,7 +251,7 @@ public class IconCache extends BaseIconCache {
|
||||
}
|
||||
|
||||
CancellableTask<ItemInfoWithIcon> request = new CancellableTask<>(
|
||||
task, MAIN_EXECUTOR, caller::reapplyItemInfo, endRunnable);
|
||||
task, MAIN_EXECUTOR, caller::reapplyItemInfo, endRunnable);
|
||||
Utilities.postAsyncCallback(workerHandler, request);
|
||||
return request;
|
||||
}
|
||||
@@ -282,8 +268,8 @@ public class IconCache extends BaseIconCache {
|
||||
*/
|
||||
public synchronized void updateTitleAndIcon(AppInfo application) {
|
||||
CacheEntry entry = cacheLocked(application.componentName,
|
||||
application.user, () -> null, LauncherActivityCachingLogic.INSTANCE,
|
||||
application.getMatchingLookupFlag());
|
||||
application.user, () -> null, LauncherActivityCachingLogic.INSTANCE,
|
||||
application.getMatchingLookupFlag());
|
||||
if (entry.bitmap != null || !isDefaultIcon(entry.bitmap, application.user)) {
|
||||
applyCacheEntry(entry, application);
|
||||
}
|
||||
@@ -294,9 +280,9 @@ public class IconCache extends BaseIconCache {
|
||||
*/
|
||||
@SuppressWarnings("NewApi")
|
||||
public synchronized void getTitleAndIcon(ItemInfoWithIcon info,
|
||||
LauncherActivityInfo activityInfo, @NonNull CacheLookupFlag lookupFlag) {
|
||||
LauncherActivityInfo activityInfo, @NonNull CacheLookupFlag lookupFlag) {
|
||||
boolean isAppArchived = Flags.enableSupportForArchiving() && activityInfo != null
|
||||
&& activityInfo.getActivityInfo().isArchived;
|
||||
&& activityInfo.getActivityInfo().isArchived;
|
||||
// If we already have activity info, no need to use package icon
|
||||
getTitleAndIcon(info, () -> activityInfo, lookupFlag.withUsePackageIcon(isAppArchived));
|
||||
}
|
||||
@@ -321,14 +307,14 @@ public class IconCache extends BaseIconCache {
|
||||
* Shortcut entries are not kept in memory since they are not frequently used
|
||||
*/
|
||||
public <T extends ItemInfoWithIcon> void getShortcutIcon(T info, CacheableShortcutInfo si,
|
||||
@NonNull Predicate<T> fallbackIconCheck) {
|
||||
@NonNull Predicate<T> fallbackIconCheck) {
|
||||
UserHandle user = CacheableShortcutCachingLogic.INSTANCE.getUser(si);
|
||||
BitmapInfo bitmapInfo = cacheLocked(
|
||||
CacheableShortcutCachingLogic.INSTANCE.getComponent(si),
|
||||
user,
|
||||
() -> si,
|
||||
CacheableShortcutCachingLogic.INSTANCE,
|
||||
DEFAULT_LOOKUP_FLAG.withSkipAddToMemCache()).bitmap;
|
||||
CacheableShortcutCachingLogic.INSTANCE.getComponent(si),
|
||||
user,
|
||||
() -> si,
|
||||
CacheableShortcutCachingLogic.INSTANCE,
|
||||
DEFAULT_LOOKUP_FLAG.withSkipAddToMemCache().withThemeIcon()).bitmap;
|
||||
if (bitmapInfo.isNullOrLowRes()) {
|
||||
bitmapInfo = getDefaultIcon(user);
|
||||
}
|
||||
@@ -351,9 +337,9 @@ public class IconCache extends BaseIconCache {
|
||||
// Check for badge override first.
|
||||
String pkg = shortcutInfo.getPackage();
|
||||
String override = shortcutInfo.getExtras() == null ? null
|
||||
: shortcutInfo.getExtras().getString(EXTRA_SHORTCUT_BADGE_OVERRIDE_PACKAGE);
|
||||
: shortcutInfo.getExtras().getString(EXTRA_SHORTCUT_BADGE_OVERRIDE_PACKAGE);
|
||||
if (!TextUtils.isEmpty(override)
|
||||
&& mInstallSessionHelper.isTrustedPackage(pkg, shortcutInfo.getUserHandle())) {
|
||||
&& mInstallSessionHelper.isTrustedPackage(pkg, shortcutInfo.getUserHandle())) {
|
||||
pkg = override;
|
||||
} else {
|
||||
// Try component based badge before trying the normal package badge
|
||||
@@ -364,8 +350,8 @@ public class IconCache extends BaseIconCache {
|
||||
appInfo.user = shortcutInfo.getUserHandle();
|
||||
appInfo.componentName = cn;
|
||||
appInfo.intent = new Intent(Intent.ACTION_MAIN)
|
||||
.addCategory(Intent.CATEGORY_LAUNCHER)
|
||||
.setComponent(cn);
|
||||
.addCategory(Intent.CATEGORY_LAUNCHER)
|
||||
.setComponent(cn);
|
||||
getTitleAndIcon(appInfo, DEFAULT_LOOKUP_FLAG);
|
||||
return appInfo;
|
||||
}
|
||||
@@ -380,18 +366,31 @@ public class IconCache extends BaseIconCache {
|
||||
* corresponding activity is not found, it reverts to the package icon.
|
||||
*/
|
||||
public synchronized void getTitleAndIcon(
|
||||
@NonNull ItemInfoWithIcon info,
|
||||
@NonNull CacheLookupFlag lookupFlag) {
|
||||
@NonNull ItemInfoWithIcon info,
|
||||
@NonNull CacheLookupFlag lookupFlag) {
|
||||
// null info means not installed, but if we have a component from the intent then
|
||||
// we should still look in the cache for restored app icons.
|
||||
if (info.getTargetComponent() == null) {
|
||||
info.bitmap = getDefaultIcon(info.user);
|
||||
info.title = "";
|
||||
info.contentDescription = "";
|
||||
} else if (info.itemType == ITEM_TYPE_DEEP_SHORTCUT) {
|
||||
ShortcutKey sk = ShortcutKey.fromItemInfo(info);
|
||||
List<ShortcutInfo> sis = sk.buildRequest(context).query(ShortcutRequest.ALL);
|
||||
if (sis.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
ShortcutInfo si = sis.getFirst();
|
||||
CacheEntry entry = cacheLocked(sk.componentName, sk.user,
|
||||
() -> new CacheableShortcutInfo(si, context),
|
||||
CacheableShortcutCachingLogic.INSTANCE,
|
||||
lookupFlag.withSkipAddToMemCache());
|
||||
applyCacheEntry(entry, info);
|
||||
info.bitmap = info.bitmap.withBadgeInfo(getShortcutInfoBadge(si));
|
||||
} else {
|
||||
Intent intent = info.getIntent();
|
||||
getTitleAndIcon(info, () -> mLauncherApps.resolveActivity(intent, info.user),
|
||||
lookupFlag.withUsePackageIcon());
|
||||
lookupFlag.withUsePackageIcon());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -400,8 +399,8 @@ public class IconCache extends BaseIconCache {
|
||||
*/
|
||||
public synchronized String getTitleNoCache(CachedObject info) {
|
||||
CacheEntry entry = cacheLocked(info.getComponent(), info.getUser(), () -> info,
|
||||
CachedObjectCachingLogic.INSTANCE,
|
||||
DEFAULT_LOOKUP_FLAG.withUseLowRes().withSkipAddToMemCache());
|
||||
CachedObjectCachingLogic.INSTANCE,
|
||||
DEFAULT_LOOKUP_FLAG.withUseLowRes().withSkipAddToMemCache());
|
||||
return Utilities.trim(entry.title);
|
||||
}
|
||||
|
||||
@@ -409,11 +408,11 @@ public class IconCache extends BaseIconCache {
|
||||
* Fill in {@param mWorkspaceItemInfo} with the icon and label for {@param info}
|
||||
*/
|
||||
public synchronized void getTitleAndIcon(
|
||||
@NonNull ItemInfoWithIcon infoInOut,
|
||||
@NonNull Supplier<LauncherActivityInfo> activityInfoProvider,
|
||||
@NonNull CacheLookupFlag lookupFlag) {
|
||||
@NonNull ItemInfoWithIcon infoInOut,
|
||||
@NonNull Supplier<LauncherActivityInfo> activityInfoProvider,
|
||||
@NonNull CacheLookupFlag lookupFlag) {
|
||||
CacheEntry entry = cacheLocked(infoInOut.getTargetComponent(), infoInOut.user,
|
||||
activityInfoProvider, LauncherActivityCachingLogic.INSTANCE, lookupFlag);
|
||||
activityInfoProvider, LauncherActivityCachingLogic.INSTANCE, lookupFlag);
|
||||
applyCacheEntry(entry, infoInOut);
|
||||
}
|
||||
|
||||
@@ -425,64 +424,64 @@ public class IconCache extends BaseIconCache {
|
||||
* @param lookupFlag what flags to use when loading the icon.
|
||||
*/
|
||||
private <T extends ItemInfoWithIcon> Cursor createBulkQueryCursor(
|
||||
List<IconRequestInfo<T>> iconRequestInfos, UserHandle user, CacheLookupFlag lookupFlag)
|
||||
throws SQLiteException {
|
||||
List<IconRequestInfo<T>> iconRequestInfos, UserHandle user, CacheLookupFlag lookupFlag)
|
||||
throws SQLiteException {
|
||||
String[] queryParams = Stream.concat(
|
||||
iconRequestInfos.stream()
|
||||
.map(r -> r.itemInfo.getTargetComponent())
|
||||
.filter(Objects::nonNull)
|
||||
.distinct()
|
||||
.map(ComponentName::flattenToString),
|
||||
Stream.of(Long.toString(getSerialNumberForUser(user)))).toArray(String[]::new);
|
||||
iconRequestInfos.stream()
|
||||
.map(r -> r.itemInfo.getTargetComponent())
|
||||
.filter(Objects::nonNull)
|
||||
.distinct()
|
||||
.map(ComponentName::flattenToString),
|
||||
Stream.of(Long.toString(getSerialNumberForUser(user)))).toArray(String[]::new);
|
||||
String componentNameQuery = TextUtils.join(
|
||||
",", Collections.nCopies(queryParams.length - 1, "?"));
|
||||
",", Collections.nCopies(queryParams.length - 1, "?"));
|
||||
|
||||
return iconDb.query(
|
||||
toLookupColumns(lookupFlag),
|
||||
COLUMN_COMPONENT
|
||||
+ " IN ( " + componentNameQuery + " )"
|
||||
+ " AND " + COLUMN_USER + " = ?",
|
||||
queryParams);
|
||||
toLookupColumns(lookupFlag),
|
||||
COLUMN_COMPONENT
|
||||
+ " IN ( " + componentNameQuery + " )"
|
||||
+ " AND " + COLUMN_USER + " = ?",
|
||||
queryParams);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load and fill icons requested in iconRequestInfos using a single bulk sql query.
|
||||
*/
|
||||
public synchronized <T extends ItemInfoWithIcon> void getTitlesAndIconsInBulk(
|
||||
List<IconRequestInfo<T>> iconRequestInfos) {
|
||||
Map<Pair<UserHandle, Boolean>, List<IconRequestInfo<T>>> iconLoadSubsectionsMap =
|
||||
iconRequestInfos.stream()
|
||||
.filter(iconRequest -> {
|
||||
if (iconRequest.itemInfo.getTargetComponent() == null) {
|
||||
Log.i(TAG,
|
||||
"Skipping Item info with null component name: "
|
||||
+ iconRequest.itemInfo);
|
||||
iconRequest.itemInfo.bitmap = getDefaultIcon(
|
||||
iconRequest.itemInfo.user);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
})
|
||||
.collect(groupingBy(iconRequest ->
|
||||
Pair.create(iconRequest.itemInfo.user, iconRequest.useLowResIcon)));
|
||||
List<IconRequestInfo<T>> iconRequestInfos) {
|
||||
Map<Pair<UserHandle, CacheLookupFlag>, List<IconRequestInfo<T>>> iconLoadSubsectionsMap =
|
||||
iconRequestInfos.stream()
|
||||
.filter(iconRequest -> {
|
||||
if (iconRequest.itemInfo.getTargetComponent() == null) {
|
||||
Log.i(TAG,
|
||||
"Skipping Item info with null component name: "
|
||||
+ iconRequest.itemInfo);
|
||||
iconRequest.itemInfo.bitmap = getDefaultIcon(
|
||||
iconRequest.itemInfo.user);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
})
|
||||
.collect(groupingBy(iconRequest ->
|
||||
Pair.create(iconRequest.itemInfo.user, iconRequest.lookupFlag)));
|
||||
|
||||
Trace.beginSection("loadIconsInBulk");
|
||||
iconLoadSubsectionsMap.forEach((sectionKey, filteredList) -> {
|
||||
Map<ComponentName, List<IconRequestInfo<T>>> duplicateIconRequestsMap =
|
||||
filteredList.stream()
|
||||
.filter(iconRequest -> {
|
||||
// Filter out icons that should not share the same bitmap and title
|
||||
if (iconRequest.itemInfo.itemType == ITEM_TYPE_DEEP_SHORTCUT) {
|
||||
Log.e(TAG,
|
||||
"Skipping Item info for deep shortcut: "
|
||||
+ iconRequest.itemInfo,
|
||||
new IllegalStateException());
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
})
|
||||
.collect(groupingBy(iconRequest ->
|
||||
iconRequest.itemInfo.getTargetComponent()));
|
||||
filteredList.stream()
|
||||
.filter(iconRequest -> {
|
||||
// Filter out icons that should not share the same bitmap and title
|
||||
if (iconRequest.itemInfo.itemType == ITEM_TYPE_DEEP_SHORTCUT) {
|
||||
Log.e(TAG,
|
||||
"Skipping Item info for deep shortcut: "
|
||||
+ iconRequest.itemInfo,
|
||||
new IllegalStateException());
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
})
|
||||
.collect(groupingBy(iconRequest ->
|
||||
iconRequest.itemInfo.getTargetComponent()));
|
||||
|
||||
Trace.beginSection("loadIconSubsectionInBulk");
|
||||
loadIconSubsection(sectionKey, filteredList, duplicateIconRequestsMap);
|
||||
@@ -492,39 +491,38 @@ public class IconCache extends BaseIconCache {
|
||||
}
|
||||
|
||||
private <T extends ItemInfoWithIcon> void loadIconSubsection(
|
||||
Pair<UserHandle, Boolean> sectionKey,
|
||||
List<IconRequestInfo<T>> filteredList,
|
||||
Map<ComponentName, List<IconRequestInfo<T>>> duplicateIconRequestsMap) {
|
||||
Pair<UserHandle, CacheLookupFlag> sectionKey,
|
||||
List<IconRequestInfo<T>> filteredList,
|
||||
Map<ComponentName, List<IconRequestInfo<T>>> duplicateIconRequestsMap) {
|
||||
Trace.beginSection("loadIconSubsectionWithDatabase");
|
||||
CacheLookupFlag lookupFlag = DEFAULT_LOOKUP_FLAG.withUseLowRes(sectionKey.second);
|
||||
try (Cursor c = createBulkQueryCursor(
|
||||
filteredList,
|
||||
/* user = */ sectionKey.first,
|
||||
lookupFlag)) {
|
||||
filteredList,
|
||||
/* user = */ sectionKey.first,
|
||||
/* lookupFlag = */ sectionKey.second)) {
|
||||
// Database title and icon loading
|
||||
int componentNameColumnIndex = c.getColumnIndexOrThrow(COLUMN_COMPONENT);
|
||||
while (c.moveToNext()) {
|
||||
ComponentName cn = ComponentName.unflattenFromString(
|
||||
c.getString(componentNameColumnIndex));
|
||||
c.getString(componentNameColumnIndex));
|
||||
List<IconRequestInfo<T>> duplicateIconRequests =
|
||||
duplicateIconRequestsMap.get(cn);
|
||||
duplicateIconRequestsMap.get(cn);
|
||||
|
||||
if (cn != null) {
|
||||
if (duplicateIconRequests != null) {
|
||||
CacheEntry entry = cacheLocked(
|
||||
cn,
|
||||
/* user = */ sectionKey.first,
|
||||
() -> duplicateIconRequests.get(0).launcherActivityInfo,
|
||||
LauncherActivityCachingLogic.INSTANCE,
|
||||
lookupFlag,
|
||||
c);
|
||||
cn,
|
||||
/* user = */ sectionKey.first,
|
||||
() -> duplicateIconRequests.get(0).launcherActivityInfo,
|
||||
LauncherActivityCachingLogic.INSTANCE,
|
||||
sectionKey.second,
|
||||
c);
|
||||
|
||||
for (IconRequestInfo<T> iconRequest : duplicateIconRequests) {
|
||||
applyCacheEntry(entry, iconRequest.itemInfo);
|
||||
}
|
||||
} else {
|
||||
Log.e(TAG, "Found entry in icon database but no main activity "
|
||||
+ "entry for cn: " + cn);
|
||||
+ "entry for cn: " + cn);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -542,13 +540,13 @@ public class IconCache extends BaseIconCache {
|
||||
BitmapInfo icon = itemInfo.bitmap;
|
||||
boolean loadFallbackTitle = TextUtils.isEmpty(itemInfo.title);
|
||||
boolean loadFallbackIcon = icon == null
|
||||
|| isDefaultIcon(icon, itemInfo.user)
|
||||
|| icon == BitmapInfo.LOW_RES_INFO;
|
||||
|| isDefaultIcon(icon, itemInfo.user)
|
||||
|| icon == BitmapInfo.LOW_RES_INFO;
|
||||
|
||||
if (loadFallbackTitle || loadFallbackIcon) {
|
||||
Log.i(TAG,
|
||||
"Database bulk icon loading failed, using fallback bulk icon loading "
|
||||
+ "for: " + cn);
|
||||
"Database bulk icon loading failed, using fallback bulk icon loading "
|
||||
+ "for: " + cn);
|
||||
CacheEntry entry = new CacheEntry();
|
||||
LauncherActivityInfo lai = iconRequestInfo.launcherActivityInfo;
|
||||
|
||||
@@ -562,20 +560,20 @@ public class IconCache extends BaseIconCache {
|
||||
|
||||
if (loadFallbackIcon) {
|
||||
loadFallbackIcon(
|
||||
lai,
|
||||
entry,
|
||||
LauncherActivityCachingLogic.INSTANCE,
|
||||
/* usePackageIcon= */ false,
|
||||
/* usePackageTitle= */ loadFallbackTitle,
|
||||
cn,
|
||||
sectionKey.first);
|
||||
lai,
|
||||
entry,
|
||||
LauncherActivityCachingLogic.INSTANCE,
|
||||
DEFAULT_LOOKUP_FLAG.withUsePackageIcon(false),
|
||||
/* usePackageTitle= */ loadFallbackTitle,
|
||||
cn,
|
||||
sectionKey.first);
|
||||
}
|
||||
if (loadFallbackTitle && TextUtils.isEmpty(entry.title) && lai != null) {
|
||||
loadFallbackTitle(
|
||||
lai,
|
||||
entry,
|
||||
LauncherActivityCachingLogic.INSTANCE,
|
||||
sectionKey.first);
|
||||
lai,
|
||||
entry,
|
||||
LauncherActivityCachingLogic.INSTANCE,
|
||||
sectionKey.first);
|
||||
}
|
||||
|
||||
for (IconRequestInfo<T> iconRequest : duplicateIconRequestsMap.get(cn)) {
|
||||
@@ -590,17 +588,17 @@ public class IconCache extends BaseIconCache {
|
||||
* Fill in {@param infoInOut} with the corresponding icon and label.
|
||||
*/
|
||||
public synchronized void getTitleAndIconForApp(
|
||||
@NonNull final PackageItemInfo infoInOut,
|
||||
@NonNull CacheLookupFlag lookupFlag) {
|
||||
@NonNull final PackageItemInfo infoInOut,
|
||||
@NonNull CacheLookupFlag lookupFlag) {
|
||||
CacheEntry entry = getEntryForPackageLocked(
|
||||
infoInOut.packageName, infoInOut.user, lookupFlag);
|
||||
infoInOut.packageName, infoInOut.user, lookupFlag);
|
||||
applyCacheEntry(entry, infoInOut);
|
||||
if (infoInOut.widgetCategory == NO_CATEGORY) {
|
||||
return;
|
||||
}
|
||||
|
||||
WidgetSection widgetSection = WidgetSections.getWidgetSections(context)
|
||||
.get(infoInOut.widgetCategory);
|
||||
.get(infoInOut.widgetCategory);
|
||||
infoInOut.title = context.getString(widgetSection.mSectionTitle);
|
||||
infoInOut.contentDescription = getUserBadgedLabel(infoInOut.title, infoInOut.user);
|
||||
final BitmapInfo cachedBitmap = mWidgetCategoryBitmapInfos.get(infoInOut.widgetCategory);
|
||||
@@ -611,8 +609,8 @@ public class IconCache extends BaseIconCache {
|
||||
|
||||
try (LauncherIcons li = mIconPool.obtain()) {
|
||||
final BitmapInfo tempBitmap = li.createBadgedIconBitmap(
|
||||
context.getDrawable(widgetSection.mSectionDrawable),
|
||||
new BaseIconFactory.IconOptions());
|
||||
context.getDrawable(widgetSection.mSectionDrawable),
|
||||
new BaseIconFactory.IconOptions());
|
||||
mWidgetCategoryBitmapInfos.put(infoInOut.widgetCategory, tempBitmap);
|
||||
infoInOut.bitmap = getBadgedIcon(tempBitmap, infoInOut.user);
|
||||
} catch (Exception e) {
|
||||
@@ -622,7 +620,7 @@ public class IconCache extends BaseIconCache {
|
||||
}
|
||||
|
||||
private synchronized BitmapInfo getBadgedIcon(@Nullable final BitmapInfo bitmap,
|
||||
@NonNull final UserHandle user) {
|
||||
@NonNull final UserHandle user) {
|
||||
if (bitmap == null) {
|
||||
return getDefaultIcon(user);
|
||||
}
|
||||
@@ -630,7 +628,7 @@ public class IconCache extends BaseIconCache {
|
||||
}
|
||||
|
||||
protected void applyCacheEntry(@NonNull final CacheEntry entry,
|
||||
@NonNull final ItemInfoWithIcon info) {
|
||||
@NonNull final ItemInfoWithIcon info) {
|
||||
info.title = Utilities.trim(entry.title);
|
||||
info.contentDescription = entry.contentDescription;
|
||||
info.bitmap = entry.bitmap;
|
||||
@@ -662,13 +660,13 @@ public class IconCache extends BaseIconCache {
|
||||
|
||||
public void updateSessionCache(PackageUserKey key, PackageInstaller.SessionInfo info) {
|
||||
cachePackageInstallInfo(key.mPackageName, key.mUser, info.getAppIcon(),
|
||||
info.getAppLabel());
|
||||
info.getAppLabel());
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
synchronized boolean isItemInDb(ComponentKey cacheKey) {
|
||||
return getEntryFromDBLocked(cacheKey, new CacheEntry(), DEFAULT_LOOKUP_FLAG,
|
||||
LauncherActivityCachingLogic.INSTANCE);
|
||||
LauncherActivityCachingLogic.INSTANCE);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user