Loading go/src/com/android/launcher3/model/WidgetsModel.java +2 −2 Original line number Diff line number Diff line Loading @@ -22,7 +22,7 @@ import android.os.UserHandle; import androidx.annotation.Nullable; import com.android.launcher3.LauncherAppState; import com.android.launcher3.icons.ComponentWithLabel; import com.android.launcher3.icons.ComponentWithLabelAndIcon; import com.android.launcher3.util.PackageUserKey; import com.android.launcher3.widget.WidgetListRowEntry; Loading Loading @@ -59,7 +59,7 @@ public class WidgetsModel { * @param packageUser If null, all widgets and shortcuts are updated and returned, otherwise * only widgets and shortcuts associated with the package/user are. */ public List<ComponentWithLabel> update(LauncherAppState app, public List<ComponentWithLabelAndIcon> update(LauncherAppState app, @Nullable PackageUserKey packageUser) { return Collections.emptyList(); } Loading iconloaderlib/src/com/android/launcher3/icons/BaseIconFactory.java +11 −0 Original line number Diff line number Diff line Loading @@ -350,6 +350,17 @@ public class BaseIconFactory implements AutoCloseable { iconDpi); } /** * Badges the provided source with the badge info */ public BitmapInfo badgeBitmap(Bitmap source, BitmapInfo badgeInfo) { Bitmap icon = BitmapRenderer.createHardwareBitmap(mIconBitmapSize, mIconBitmapSize, (c) -> { getShadowGenerator().recreateIcon(source, c); badgeWithDrawable(c, new FixedSizeBitmapDrawable(badgeInfo.icon)); }); return BitmapInfo.of(icon, badgeInfo.color); } private int extractColor(Bitmap bitmap) { return mDisableColorExtractor ? 0 : mColorExtractor.findDominantColorByHue(bitmap); } Loading iconloaderlib/src/com/android/launcher3/icons/cache/BaseIconCache.java +8 −5 Original line number Diff line number Diff line Loading @@ -281,7 +281,8 @@ public abstract class BaseIconCache { ContentValues values = newContentValues(entry.bitmap, entry.title.toString(), componentName.getPackageName(), cachingLogic.getKeywords(object, mLocaleList)); addIconToDB(values, componentName, info, userSerial); addIconToDB(values, componentName, info, userSerial, cachingLogic.getLastUpdatedTime(object, info)); } /** Loading @@ -289,10 +290,10 @@ public abstract class BaseIconCache { * @param values {@link ContentValues} containing icon & title */ private void addIconToDB(ContentValues values, ComponentName key, PackageInfo info, long userSerial) { PackageInfo info, long userSerial, long lastUpdateTime) { values.put(IconDB.COLUMN_COMPONENT, key.flattenToString()); values.put(IconDB.COLUMN_USER, userSerial); values.put(IconDB.COLUMN_LAST_UPDATED, info.lastUpdateTime); values.put(IconDB.COLUMN_LAST_UPDATED, lastUpdateTime); values.put(IconDB.COLUMN_VERSION, info.versionCode); mIconDb.insertOrReplace(values); } Loading Loading @@ -362,7 +363,8 @@ public abstract class BaseIconCache { } if (object != null) { entry.title = cachingLogic.getLabel(object); entry.contentDescription = mPackageManager.getUserBadgedLabel(entry.title, user); entry.contentDescription = mPackageManager.getUserBadgedLabel( cachingLogic.getDescription(object, entry.title), user); } } } Loading Loading @@ -449,7 +451,8 @@ public abstract class BaseIconCache { // package updates. ContentValues values = newContentValues( iconInfo, entry.title.toString(), packageName, null); addIconToDB(values, cacheKey.componentName, info, getSerialNumberForUser(user)); addIconToDB(values, cacheKey.componentName, info, getSerialNumberForUser(user), info.lastUpdateTime); } catch (NameNotFoundException e) { if (DEBUG) Log.d(TAG, "Application not installed " + packageName); Loading iconloaderlib/src/com/android/launcher3/icons/cache/CachingLogic.java +4 −0 Original line number Diff line number Diff line Loading @@ -34,6 +34,10 @@ public interface CachingLogic<T> { CharSequence getLabel(T object); default CharSequence getDescription(T object, CharSequence fallback) { return fallback; } @NonNull BitmapInfo loadIcon(Context context, T object); Loading iconloaderlib/src/com/android/launcher3/icons/cache/IconCacheUpdateHandler.java +14 −3 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ import android.database.sqlite.SQLiteException; import android.os.SystemClock; import android.os.UserHandle; import android.text.TextUtils; import android.util.ArrayMap; import android.util.Log; import android.util.SparseBooleanArray; Loading Loading @@ -61,7 +62,7 @@ public class IconCacheUpdateHandler { private final HashMap<String, PackageInfo> mPkgInfoMap; private final BaseIconCache mIconCache; private final HashMap<UserHandle, Set<String>> mPackagesToIgnore = new HashMap<>(); private final ArrayMap<UserHandle, Set<String>> mPackagesToIgnore = new ArrayMap<>(); private final SparseBooleanArray mItemsToDelete = new SparseBooleanArray(); private boolean mFilterMode = MODE_SET_INVALID_ITEMS; Loading @@ -77,9 +78,17 @@ public class IconCacheUpdateHandler { createPackageInfoMap(); } public void setPackagesToIgnore(UserHandle userHandle, Set<String> packages) { /** * Sets a package to ignore for processing */ public void addPackagesToIgnore(UserHandle userHandle, String packageName) { Set<String> packages = mPackagesToIgnore.get(userHandle); if (packages == null) { packages = new HashSet<>(); mPackagesToIgnore.put(userHandle, packages); } packages.add(packageName); } private void createPackageInfoMap() { PackageManager pm = mIconCache.mPackageManager; Loading Loading @@ -181,6 +190,7 @@ public class IconCacheUpdateHandler { } continue; } if (app == null) { if (mFilterMode == MODE_SET_INVALID_ITEMS) { mIconCache.remove(component, user); Loading Loading @@ -263,6 +273,7 @@ public class IconCacheUpdateHandler { T app = mAppsToUpdate.pop(); String pkg = mCachingLogic.getComponent(app).getPackageName(); PackageInfo info = mPkgInfoMap.get(pkg); mIconCache.addIconToDBAndMemCache( app, mCachingLogic, info, mUserSerial, true /*replace existing*/); mUpdatedPackages.add(pkg); Loading Loading
go/src/com/android/launcher3/model/WidgetsModel.java +2 −2 Original line number Diff line number Diff line Loading @@ -22,7 +22,7 @@ import android.os.UserHandle; import androidx.annotation.Nullable; import com.android.launcher3.LauncherAppState; import com.android.launcher3.icons.ComponentWithLabel; import com.android.launcher3.icons.ComponentWithLabelAndIcon; import com.android.launcher3.util.PackageUserKey; import com.android.launcher3.widget.WidgetListRowEntry; Loading Loading @@ -59,7 +59,7 @@ public class WidgetsModel { * @param packageUser If null, all widgets and shortcuts are updated and returned, otherwise * only widgets and shortcuts associated with the package/user are. */ public List<ComponentWithLabel> update(LauncherAppState app, public List<ComponentWithLabelAndIcon> update(LauncherAppState app, @Nullable PackageUserKey packageUser) { return Collections.emptyList(); } Loading
iconloaderlib/src/com/android/launcher3/icons/BaseIconFactory.java +11 −0 Original line number Diff line number Diff line Loading @@ -350,6 +350,17 @@ public class BaseIconFactory implements AutoCloseable { iconDpi); } /** * Badges the provided source with the badge info */ public BitmapInfo badgeBitmap(Bitmap source, BitmapInfo badgeInfo) { Bitmap icon = BitmapRenderer.createHardwareBitmap(mIconBitmapSize, mIconBitmapSize, (c) -> { getShadowGenerator().recreateIcon(source, c); badgeWithDrawable(c, new FixedSizeBitmapDrawable(badgeInfo.icon)); }); return BitmapInfo.of(icon, badgeInfo.color); } private int extractColor(Bitmap bitmap) { return mDisableColorExtractor ? 0 : mColorExtractor.findDominantColorByHue(bitmap); } Loading
iconloaderlib/src/com/android/launcher3/icons/cache/BaseIconCache.java +8 −5 Original line number Diff line number Diff line Loading @@ -281,7 +281,8 @@ public abstract class BaseIconCache { ContentValues values = newContentValues(entry.bitmap, entry.title.toString(), componentName.getPackageName(), cachingLogic.getKeywords(object, mLocaleList)); addIconToDB(values, componentName, info, userSerial); addIconToDB(values, componentName, info, userSerial, cachingLogic.getLastUpdatedTime(object, info)); } /** Loading @@ -289,10 +290,10 @@ public abstract class BaseIconCache { * @param values {@link ContentValues} containing icon & title */ private void addIconToDB(ContentValues values, ComponentName key, PackageInfo info, long userSerial) { PackageInfo info, long userSerial, long lastUpdateTime) { values.put(IconDB.COLUMN_COMPONENT, key.flattenToString()); values.put(IconDB.COLUMN_USER, userSerial); values.put(IconDB.COLUMN_LAST_UPDATED, info.lastUpdateTime); values.put(IconDB.COLUMN_LAST_UPDATED, lastUpdateTime); values.put(IconDB.COLUMN_VERSION, info.versionCode); mIconDb.insertOrReplace(values); } Loading Loading @@ -362,7 +363,8 @@ public abstract class BaseIconCache { } if (object != null) { entry.title = cachingLogic.getLabel(object); entry.contentDescription = mPackageManager.getUserBadgedLabel(entry.title, user); entry.contentDescription = mPackageManager.getUserBadgedLabel( cachingLogic.getDescription(object, entry.title), user); } } } Loading Loading @@ -449,7 +451,8 @@ public abstract class BaseIconCache { // package updates. ContentValues values = newContentValues( iconInfo, entry.title.toString(), packageName, null); addIconToDB(values, cacheKey.componentName, info, getSerialNumberForUser(user)); addIconToDB(values, cacheKey.componentName, info, getSerialNumberForUser(user), info.lastUpdateTime); } catch (NameNotFoundException e) { if (DEBUG) Log.d(TAG, "Application not installed " + packageName); Loading
iconloaderlib/src/com/android/launcher3/icons/cache/CachingLogic.java +4 −0 Original line number Diff line number Diff line Loading @@ -34,6 +34,10 @@ public interface CachingLogic<T> { CharSequence getLabel(T object); default CharSequence getDescription(T object, CharSequence fallback) { return fallback; } @NonNull BitmapInfo loadIcon(Context context, T object); Loading
iconloaderlib/src/com/android/launcher3/icons/cache/IconCacheUpdateHandler.java +14 −3 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ import android.database.sqlite.SQLiteException; import android.os.SystemClock; import android.os.UserHandle; import android.text.TextUtils; import android.util.ArrayMap; import android.util.Log; import android.util.SparseBooleanArray; Loading Loading @@ -61,7 +62,7 @@ public class IconCacheUpdateHandler { private final HashMap<String, PackageInfo> mPkgInfoMap; private final BaseIconCache mIconCache; private final HashMap<UserHandle, Set<String>> mPackagesToIgnore = new HashMap<>(); private final ArrayMap<UserHandle, Set<String>> mPackagesToIgnore = new ArrayMap<>(); private final SparseBooleanArray mItemsToDelete = new SparseBooleanArray(); private boolean mFilterMode = MODE_SET_INVALID_ITEMS; Loading @@ -77,9 +78,17 @@ public class IconCacheUpdateHandler { createPackageInfoMap(); } public void setPackagesToIgnore(UserHandle userHandle, Set<String> packages) { /** * Sets a package to ignore for processing */ public void addPackagesToIgnore(UserHandle userHandle, String packageName) { Set<String> packages = mPackagesToIgnore.get(userHandle); if (packages == null) { packages = new HashSet<>(); mPackagesToIgnore.put(userHandle, packages); } packages.add(packageName); } private void createPackageInfoMap() { PackageManager pm = mIconCache.mPackageManager; Loading Loading @@ -181,6 +190,7 @@ public class IconCacheUpdateHandler { } continue; } if (app == null) { if (mFilterMode == MODE_SET_INVALID_ITEMS) { mIconCache.remove(component, user); Loading Loading @@ -263,6 +273,7 @@ public class IconCacheUpdateHandler { T app = mAppsToUpdate.pop(); String pkg = mCachingLogic.getComponent(app).getPackageName(); PackageInfo info = mPkgInfoMap.get(pkg); mIconCache.addIconToDBAndMemCache( app, mCachingLogic, info, mUserSerial, true /*replace existing*/); mUpdatedPackages.add(pkg); Loading