summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/LauncherModel.java
diff options
context:
space:
mode:
authorSunny Goyal <sunnygoyal@google.com>2015-05-06 16:53:21 -0700
committerSunny Goyal <sunnygoyal@google.com>2015-05-06 16:54:08 -0700
commit77919b93b98f5afa1b39546861197d6065847224 (patch)
tree74cbf761fbecead52a19c6c0a28e0931edabb636 /src/com/android/launcher3/LauncherModel.java
parent1d08f70441999c66b76c97e48b4149e1433be3c3 (diff)
downloadandroid_packages_apps_Trebuchet-77919b93b98f5afa1b39546861197d6065847224.tar.gz
android_packages_apps_Trebuchet-77919b93b98f5afa1b39546861197d6065847224.tar.bz2
android_packages_apps_Trebuchet-77919b93b98f5afa1b39546861197d6065847224.zip
Updating the icon cache after all apps has been bound.
> Updating the cache DB version to reset existing cache. Bug: 20834835 Change-Id: I298ca9ddcc4dd270b25b767447ecde01ef41a916
Diffstat (limited to 'src/com/android/launcher3/LauncherModel.java')
-rw-r--r--src/com/android/launcher3/LauncherModel.java102
1 files changed, 63 insertions, 39 deletions
diff --git a/src/com/android/launcher3/LauncherModel.java b/src/com/android/launcher3/LauncherModel.java
index 0138a913a..ddbae3a18 100644
--- a/src/com/android/launcher3/LauncherModel.java
+++ b/src/com/android/launcher3/LauncherModel.java
@@ -2767,6 +2767,7 @@ public class LauncherModel extends BroadcastReceiver
}
if (!mAllAppsLoaded) {
loadAllApps();
+ updateAllAppsIconsCache();
synchronized (LoaderTask.this) {
if (mStopped) {
return;
@@ -2821,9 +2822,6 @@ public class LauncherModel extends BroadcastReceiver
return;
}
- final Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
- mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);
-
final List<UserHandleCompat> profiles = mUserManager.getUserProfiles();
// Clear the list of apps
@@ -2843,42 +2841,6 @@ public class LauncherModel extends BroadcastReceiver
return;
}
- // Update icon cache
- HashSet<String> updatedPackages = mIconCache.updateDBIcons(user, apps);
-
- // If any package icon has changed (app was updated while launcher was dead),
- // update the corresponding shortcuts.
- if (!updatedPackages.isEmpty()) {
- final ArrayList<ShortcutInfo> updates = new ArrayList<ShortcutInfo>();
- synchronized (sBgLock) {
- for (ItemInfo info : sBgItemsIdMap) {
- if (info instanceof ShortcutInfo && user.equals(info.user)
- && info.itemType == LauncherSettings.Favorites.ITEM_TYPE_APPLICATION) {
- ShortcutInfo si = (ShortcutInfo) info;
- ComponentName cn = si.getTargetComponent();
- if (cn != null && updatedPackages.contains(cn.getPackageName())) {
- si.updateIcon(mIconCache);
- updates.add(si);
- }
- }
- }
- }
-
- if (!updates.isEmpty()) {
- final UserHandleCompat userFinal = user;
- mHandler.post(new Runnable() {
-
- public void run() {
- Callbacks cb = getCallback();
- if (cb != null) {
- cb.bindShortcutsChanged(
- updates, new ArrayList<ShortcutInfo>(), userFinal);
- }
- }
- });
- }
- }
-
// Create the ApplicationInfos
for (int i = 0; i < apps.size(); i++) {
LauncherActivityInfoCompat app = apps.get(i);
@@ -2929,6 +2891,68 @@ public class LauncherModel extends BroadcastReceiver
}
}
+ private void updateAllAppsIconsCache() {
+ final ArrayList<AppInfo> updatedApps = new ArrayList<>();
+
+ for (UserHandleCompat user : mUserManager.getUserProfiles()) {
+ // Query for the set of apps
+ final List<LauncherActivityInfoCompat> apps = mLauncherApps.getActivityList(null, user);
+ // Fail if we don't have any apps
+ // TODO: Fix this. Only fail for the current user.
+ if (apps == null || apps.isEmpty()) {
+ return;
+ }
+
+ // Update icon cache
+ HashSet<String> updatedPackages = mIconCache.updateDBIcons(user, apps);
+
+ // If any package icon has changed (app was updated while launcher was dead),
+ // update the corresponding shortcuts.
+ if (!updatedPackages.isEmpty()) {
+ final ArrayList<ShortcutInfo> updatedShortcuts = new ArrayList<>();
+ synchronized (sBgLock) {
+ for (ItemInfo info : sBgItemsIdMap) {
+ if (info instanceof ShortcutInfo && user.equals(info.user)
+ && info.itemType == LauncherSettings.Favorites.ITEM_TYPE_APPLICATION) {
+ ShortcutInfo si = (ShortcutInfo) info;
+ ComponentName cn = si.getTargetComponent();
+ if (cn != null && updatedPackages.contains(cn.getPackageName())) {
+ si.updateIcon(mIconCache);
+ updatedShortcuts.add(si);
+ }
+ }
+ }
+ mBgAllAppsList.updateIconsAndLabels(updatedPackages, user, updatedApps);
+ }
+
+ if (!updatedShortcuts.isEmpty()) {
+ final UserHandleCompat userFinal = user;
+ mHandler.post(new Runnable() {
+
+ public void run() {
+ Callbacks cb = getCallback();
+ if (cb != null) {
+ cb.bindShortcutsChanged(updatedShortcuts,
+ new ArrayList<ShortcutInfo>(), userFinal);
+ }
+ }
+ });
+ }
+ }
+ }
+ if (!updatedApps.isEmpty()) {
+ mHandler.post(new Runnable() {
+
+ public void run() {
+ Callbacks cb = getCallback();
+ if (cb != null) {
+ cb.bindAppsUpdated(updatedApps);
+ }
+ }
+ });
+ }
+ }
+
public void dumpState() {
synchronized (sBgLock) {
Log.d(TAG, "mLoaderTask.mContext=" + mContext);