summaryrefslogtreecommitdiffstats
path: root/src/com
diff options
context:
space:
mode:
authorSunny Goyal <sunnygoyal@google.com>2015-07-13 19:54:53 -0700
committerSunny Goyal <sunnygoyal@google.com>2015-07-20 12:00:22 -0700
commit53f9672b30b8a36bfae9f6492f732ccfb87723a4 (patch)
tree6e5ec02530a2f15469135b15e28778104d5c2466 /src/com
parente3fe3f89ee956e8d7995c569948cb70765ec19b8 (diff)
downloadandroid_packages_apps_Trebuchet-53f9672b30b8a36bfae9f6492f732ccfb87723a4.tar.gz
android_packages_apps_Trebuchet-53f9672b30b8a36bfae9f6492f732ccfb87723a4.tar.bz2
android_packages_apps_Trebuchet-53f9672b30b8a36bfae9f6492f732ccfb87723a4.zip
Fixing widget restore
> Widget restore active flag was not cleared when the app was downloaded > Icon from session info was not getting cached Bug: 22413379 Change-Id: Ie096b929252200675a76dadd8c25cc3aa433671b
Diffstat (limited to 'src/com')
-rw-r--r--src/com/android/launcher3/IconCache.java35
-rw-r--r--src/com/android/launcher3/LauncherModel.java10
2 files changed, 31 insertions, 14 deletions
diff --git a/src/com/android/launcher3/IconCache.java b/src/com/android/launcher3/IconCache.java
index 916418f18..193f458b5 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,7 +614,7 @@ 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);
ApplicationInfo appInfo = info.applicationInfo;
@@ -622,7 +632,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);
@@ -667,14 +678,13 @@ public class IconCache {
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 +695,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;
}
diff --git a/src/com/android/launcher3/LauncherModel.java b/src/com/android/launcher3/LauncherModel.java
index b60477fa0..0b67310fa 100644
--- a/src/com/android/launcher3/LauncherModel.java
+++ b/src/com/android/launcher3/LauncherModel.java
@@ -2163,7 +2163,11 @@ public class LauncherModel extends BroadcastReceiver
appWidgetInfo = new LauncherAppWidgetInfo(appWidgetId,
provider.provider);
- int status = restoreStatus;
+ // The provider is available. So the widget is either
+ // available or not available. We do not need to track
+ // any future restore updates.
+ int status = restoreStatus &
+ ~LauncherAppWidgetInfo.FLAG_RESTORE_STARTED;
if (!wasProviderReady) {
// If provider was not previously ready, update the
// status and UI flag.
@@ -3155,7 +3159,9 @@ public class LauncherModel extends BroadcastReceiver
if (mUser.equals(widgetInfo.user)
&& widgetInfo.hasRestoreFlag(LauncherAppWidgetInfo.FLAG_PROVIDER_NOT_READY)
&& packageSet.contains(widgetInfo.providerName.getPackageName())) {
- widgetInfo.restoreStatus &= ~LauncherAppWidgetInfo.FLAG_PROVIDER_NOT_READY;
+ widgetInfo.restoreStatus &=
+ ~LauncherAppWidgetInfo.FLAG_PROVIDER_NOT_READY &
+ ~LauncherAppWidgetInfo.FLAG_RESTORE_STARTED;
widgets.add(widgetInfo);
updateItemInDatabase(context, widgetInfo);
}