summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/IconCache.java
diff options
context:
space:
mode:
authorSunny Goyal <sunnygoyal@google.com>2015-09-14 21:55:16 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2015-09-14 21:55:16 +0000
commit54d17dff6db6847b33bf07e1af6fbaa2e3bbe19d (patch)
tree82db2e21449fd52665d7cff5f67b72ea655d185f /src/com/android/launcher3/IconCache.java
parentedd51ad30741098e2110e3d0533085b02cbe752c (diff)
parent00e827c70cb4213ee05140157006a37d12662448 (diff)
downloadandroid_packages_apps_Trebuchet-54d17dff6db6847b33bf07e1af6fbaa2e3bbe19d.tar.gz
android_packages_apps_Trebuchet-54d17dff6db6847b33bf07e1af6fbaa2e3bbe19d.tar.bz2
android_packages_apps_Trebuchet-54d17dff6db6847b33bf07e1af6fbaa2e3bbe19d.zip
am 00e827c7: am 5fcaab43: am ea9ad5ce: Merge remote-tracking branch \'origin/ub-launcher3-burnaby\' into mnc-dev
* commit '00e827c70cb4213ee05140157006a37d12662448': (76 commits) Restoring provider behavior for reloading app on old devices > For older devices, launcher will only reload in case of inserts with specific query parameters > For older devices, launcehr will notify content observers of any internal inserts > Chaning TAG for Launcher provider as max logging tag is only 23 characters Removing items which are on invalid screen Preventing null pointer crash when opening a folder Revert workaround for move to default screen on home intent. Fixing NPE in recycler view scroll bar. Adding workaround for regression caused by ag/752175 Adding gradle script for Android Studio Override the overscroll color for the widget rows. Adding graphic for all apps empty search screen. Using GET_UNINSTALLED_PACKAGES flag when getting packageInfo for a managed profile app Revert "Adding viewId for the QSB" Adding viewId for the QSB Fixing issue with missing scroll bar after fast-scrolling and searching. Fixing an issue where you would inadvertently start fastscrolling. Pending bind callbacks should be cleared before starting the loader, similar to startBinding Fixing widgets container inactive scroll bar color. Making the detached scrollbar catch up faster to the actual scroll position. Updating theme to use the light theme by default, instead of wallpaper theme > This allows us to use all the goodness of material theme > Cursor in folder edit text is no longer 1px wide Updating the target sdk to launcher Using the usermanager api to get creation time ...
Diffstat (limited to 'src/com/android/launcher3/IconCache.java')
-rw-r--r--src/com/android/launcher3/IconCache.java47
1 files changed, 31 insertions, 16 deletions
diff --git a/src/com/android/launcher3/IconCache.java b/src/com/android/launcher3/IconCache.java
index 916418f18..59ab8397d 100644
--- a/src/com/android/launcher3/IconCache.java
+++ b/src/com/android/launcher3/IconCache.java
@@ -540,7 +540,7 @@ public class IconCache {
mCache.put(cacheKey, entry);
// Check the DB first.
- if (!getEntryFromDB(componentName, user, entry, useLowResIcon)) {
+ if (!getEntryFromDB(cacheKey, entry, useLowResIcon)) {
if (info != null) {
entry.icon = Utilities.createIconBitmap(info.getBadgedIcon(mIconDpi), mContext);
} else {
@@ -579,7 +579,14 @@ public class IconCache {
Bitmap icon, CharSequence title) {
removeFromMemCacheLocked(packageName, user);
- CacheEntry entry = getEntryForPackageLocked(packageName, user, false);
+ ComponentKey cacheKey = getPackageKey(packageName, user);
+ CacheEntry entry = mCache.get(cacheKey);
+
+ // For icon caching, do not go through DB. Just update the in-memory entry.
+ if (entry == null) {
+ entry = new CacheEntry();
+ mCache.put(cacheKey, entry);
+ }
if (!TextUtils.isEmpty(title)) {
entry.title = title;
}
@@ -588,15 +595,18 @@ public class IconCache {
}
}
+ private static ComponentKey getPackageKey(String packageName, UserHandleCompat user) {
+ ComponentName cn = new ComponentName(packageName, packageName + EMPTY_CLASS_NAME);
+ return new ComponentKey(cn, user);
+ }
+
/**
* Gets an entry for the package, which can be used as a fallback entry for various components.
* This method is not thread safe, it must be called from a synchronized method.
- *
*/
private CacheEntry getEntryForPackageLocked(String packageName, UserHandleCompat user,
boolean useLowResIcon) {
- ComponentName cn = new ComponentName(packageName, packageName + EMPTY_CLASS_NAME);
- ComponentKey cacheKey = new ComponentKey(cn, user);
+ ComponentKey cacheKey = getPackageKey(packageName, user);
CacheEntry entry = mCache.get(cacheKey);
if (entry == null || (entry.isLowResIcon && !useLowResIcon)) {
@@ -604,9 +614,11 @@ public class IconCache {
boolean entryUpdated = true;
// Check the DB first.
- if (!getEntryFromDB(cn, user, entry, useLowResIcon)) {
+ if (!getEntryFromDB(cacheKey, entry, useLowResIcon)) {
try {
- PackageInfo info = mPackageManager.getPackageInfo(packageName, 0);
+ int flags = UserHandleCompat.myUserHandle().equals(user) ? 0 :
+ PackageManager.GET_UNINSTALLED_PACKAGES;
+ PackageInfo info = mPackageManager.getPackageInfo(packageName, flags);
ApplicationInfo appInfo = info.applicationInfo;
if (appInfo == null) {
throw new NameNotFoundException("ApplicationInfo is null");
@@ -622,7 +634,8 @@ public class IconCache {
// package updates.
ContentValues values =
newContentValues(entry.icon, entry.title.toString(), mPackageBgColor);
- addIconToDB(values, cn, info, mUserManager.getSerialNumberForUser(user));
+ addIconToDB(values, cacheKey.componentName, info,
+ mUserManager.getSerialNumberForUser(user));
} catch (NameNotFoundException e) {
if (DEBUG) Log.d(TAG, "Application not installed " + packageName);
@@ -649,7 +662,7 @@ public class IconCache {
* @param dpi the native density of the icon
*/
public void preloadIcon(ComponentName componentName, Bitmap icon, int dpi, String label,
- long userSerial) {
+ long userSerial, InvariantDeviceProfile idp) {
// TODO rescale to the correct native DPI
try {
PackageManager packageManager = mContext.getPackageManager();
@@ -660,21 +673,22 @@ public class IconCache {
// pass
}
- ContentValues values = newContentValues(icon, label, Color.TRANSPARENT);
+ ContentValues values = newContentValues(
+ Bitmap.createScaledBitmap(icon, idp.iconBitmapSize, idp.iconBitmapSize, true),
+ label, Color.TRANSPARENT);
values.put(IconDB.COLUMN_COMPONENT, componentName.flattenToString());
values.put(IconDB.COLUMN_USER, userSerial);
mIconDb.getWritableDatabase().insertWithOnConflict(IconDB.TABLE_NAME, null, values,
SQLiteDatabase.CONFLICT_REPLACE);
}
- private boolean getEntryFromDB(ComponentName component, UserHandleCompat user,
- CacheEntry entry, boolean lowRes) {
+ private boolean getEntryFromDB(ComponentKey cacheKey, CacheEntry entry, boolean lowRes) {
Cursor c = mIconDb.getReadableDatabase().query(IconDB.TABLE_NAME,
new String[] {lowRes ? IconDB.COLUMN_ICON_LOW_RES : IconDB.COLUMN_ICON,
IconDB.COLUMN_LABEL},
IconDB.COLUMN_COMPONENT + " = ? AND " + IconDB.COLUMN_USER + " = ?",
- new String[] {component.flattenToString(),
- Long.toString(mUserManager.getSerialNumberForUser(user))},
+ new String[] {cacheKey.componentName.flattenToString(),
+ Long.toString(mUserManager.getSerialNumberForUser(cacheKey.user))},
null, null, null);
try {
if (c.moveToNext()) {
@@ -685,7 +699,8 @@ public class IconCache {
entry.title = "";
entry.contentDescription = "";
} else {
- entry.contentDescription = mUserManager.getBadgedLabelForUser(entry.title, user);
+ entry.contentDescription = mUserManager.getBadgedLabelForUser(
+ entry.title, cacheKey.user);
}
return true;
}
@@ -774,7 +789,7 @@ public class IconCache {
}
private static final class IconDB extends SQLiteOpenHelper {
- private final static int DB_VERSION = 6;
+ private final static int DB_VERSION = 7;
private final static String TABLE_NAME = "icons";
private final static String COLUMN_ROWID = "rowid";