diff options
author | Sunny Goyal <sunnygoyal@google.com> | 2015-02-18 16:46:50 -0800 |
---|---|---|
committer | Sunny Goyal <sunnygoyal@google.com> | 2015-02-26 19:08:44 +0000 |
commit | 4fbc3828c5ae1e8c5789ede974447fa365f3c5a1 (patch) | |
tree | 9e570b85d5550537b17c85fd1d579fcc43b6136f /src/com/android/launcher3/LauncherBackupHelper.java | |
parent | ed46c093cf1f34a2056846ac826b19fa2335ec18 (diff) | |
download | android_packages_apps_Trebuchet-4fbc3828c5ae1e8c5789ede974447fa365f3c5a1.tar.gz android_packages_apps_Trebuchet-4fbc3828c5ae1e8c5789ede974447fa365f3c5a1.tar.bz2 android_packages_apps_Trebuchet-4fbc3828c5ae1e8c5789ede974447fa365f3c5a1.zip |
Updating IconCache to maintain a persistent of icons
> IconDB maintains a DB of icons keyed on ComponentName + User
> During loader, icons & labels are loaded first from the DB, and
if the entry doesn't exist, loaded using packageManager
> After the loader completes, IconDB updates any entry which might have
changed, while the launcher was dead.
Change-Id: I7a6021cb6d1ca1e66fa5a0bdd21e1543e0cf66fc
Diffstat (limited to 'src/com/android/launcher3/LauncherBackupHelper.java')
-rw-r--r-- | src/com/android/launcher3/LauncherBackupHelper.java | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/src/com/android/launcher3/LauncherBackupHelper.java b/src/com/android/launcher3/LauncherBackupHelper.java index 353bf3f00..97ff32790 100644 --- a/src/com/android/launcher3/LauncherBackupHelper.java +++ b/src/com/android/launcher3/LauncherBackupHelper.java @@ -144,6 +144,7 @@ public class LauncherBackupHelper implements BackupHelper { private final HashSet<String> mExistingKeys; private final ArrayList<Key> mKeys; private final ItemTypeMatcher[] mItemTypeMatchers; + private final long mUserSerial; private IconCache mIconCache; private BackupManager mBackupManager; @@ -161,6 +162,9 @@ public class LauncherBackupHelper implements BackupHelper { mKeys = new ArrayList<Key>(); restoreSuccessful = true; mItemTypeMatchers = new ItemTypeMatcher[CommonAppTypeParser.SUPPORTED_TYPE_COUNT]; + + UserManagerCompat userManager = UserManagerCompat.getInstance(mContext); + mUserSerial = userManager.getSerialNumberForUser(UserHandleCompat.myUserHandle()); } private void dataChanged() { @@ -297,6 +301,12 @@ public class LauncherBackupHelper implements BackupHelper { if (!restoreSuccessful) { return; } + if (!initializeIconCache()) { + // During restore we do not need an initialized instance of IconCache. We can create + // a temporary icon cache here, as the process will be rebooted after restore + // is complete. + mIconCache = new IconCache(mContext); + } int dataSize = data.size(); if (mBuffer.length < dataSize) { @@ -601,7 +611,8 @@ public class LauncherBackupHelper implements BackupHelper { Log.w(TAG, "failed to unpack icon for " + key.name); } if (VERBOSE) Log.v(TAG, "saving restored icon as: " + key.name); - IconCache.preloadIcon(mContext, ComponentName.unflattenFromString(key.name), icon, res.dpi); + mIconCache.preloadIcon(ComponentName.unflattenFromString(key.name), icon, res.dpi, + "" /* label */, mUserSerial); } /** @@ -693,8 +704,8 @@ public class LauncherBackupHelper implements BackupHelper { if (icon == null) { Log.w(TAG, "failed to unpack widget icon for " + key.name); } else { - IconCache.preloadIcon(mContext, ComponentName.unflattenFromString(widget.provider), - icon, widget.icon.dpi); + mIconCache.preloadIcon(ComponentName.unflattenFromString(widget.provider), + icon, widget.icon.dpi, widget.label, mUserSerial); } } @@ -1145,9 +1156,11 @@ public class LauncherBackupHelper implements BackupHelper { final LauncherAppState appState = LauncherAppState.getInstanceNoCreate(); if (appState == null) { - Throwable stackTrace = new Throwable(); - stackTrace.fillInStackTrace(); - Log.w(TAG, "Failed to get app state during backup/restore", stackTrace); + if (DEBUG) { + Throwable stackTrace = new Throwable(); + stackTrace.fillInStackTrace(); + Log.w(TAG, "Failed to get app state during backup/restore", stackTrace); + } return false; } mIconCache = appState.getIconCache(); |