Fixes #1940691. Sync packages when home receives a reinstall notification.

Home was only updating known activities. This change makes home also check for
removed activities and added activities.
This commit is contained in:
Romain Guy 2009-06-24 13:45:46 -07:00
parent 1ce1a24cba
commit b132a97cb7
1 changed files with 24 additions and 15 deletions

View File

@ -244,6 +244,8 @@ public class LauncherModel {
} }
} }
if (syncLocked(launcher, packageName)) changed = true;
if (changed) { if (changed) {
adapter.sort(new ApplicationInfoComparator()); adapter.sort(new ApplicationInfoComparator());
adapter.notifyDataSetChanged(); adapter.notifyDataSetChanged();
@ -268,26 +270,33 @@ public class LauncherModel {
} }
if (packageName != null && packageName.length() > 0) { if (packageName != null && packageName.length() > 0) {
final PackageManager packageManager = launcher.getPackageManager(); if (syncLocked(launcher, packageName)) {
final List<ResolveInfo> matches = findActivitiesForPackage(packageManager, packageName);
if (matches.size() > 0) {
final ApplicationsAdapter adapter = mApplicationsAdapter; final ApplicationsAdapter adapter = mApplicationsAdapter;
adapter.sort(new ApplicationInfoComparator());
// Find disabled activities and remove them from the adapter adapter.notifyDataSetChanged();
boolean removed = removeDisabledActivities(packageName, matches, adapter);
// Find enable activities and add them to the adapter
// Also updates existing activities with new labels/icons
boolean added = addEnabledAndUpdateActivities(matches, adapter, launcher);
if (added || removed) {
adapter.sort(new ApplicationInfoComparator());
adapter.notifyDataSetChanged();
}
} }
} }
} }
private boolean syncLocked(Launcher launcher, String packageName) {
final PackageManager packageManager = launcher.getPackageManager();
final List<ResolveInfo> matches = findActivitiesForPackage(packageManager, packageName);
if (matches.size() > 0) {
final ApplicationsAdapter adapter = mApplicationsAdapter;
// Find disabled activities and remove them from the adapter
boolean removed = removeDisabledActivities(packageName, matches, adapter);
// Find enable activities and add them to the adapter
// Also updates existing activities with new labels/icons
boolean added = addEnabledAndUpdateActivities(matches, adapter, launcher);
return added || removed;
}
return false;
}
private static List<ResolveInfo> findActivitiesForPackage(PackageManager packageManager, private static List<ResolveInfo> findActivitiesForPackage(PackageManager packageManager,
String packageName) { String packageName) {