summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/LauncherModel.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android/launcher3/LauncherModel.java')
-rw-r--r--src/com/android/launcher3/LauncherModel.java59
1 files changed, 59 insertions, 0 deletions
diff --git a/src/com/android/launcher3/LauncherModel.java b/src/com/android/launcher3/LauncherModel.java
index 60eb15f9c..c64506d80 100644
--- a/src/com/android/launcher3/LauncherModel.java
+++ b/src/com/android/launcher3/LauncherModel.java
@@ -198,6 +198,7 @@ public class LauncherModel extends BroadcastReceiver
ArrayList<ItemInfo> addAnimated,
ArrayList<AppInfo> addedApps);
public void bindAppsUpdated(ArrayList<AppInfo> apps);
+ public void bindAppsRestored(ArrayList<AppInfo> apps);
public void updatePackageState(ArrayList<PackageInstallInfo> installInfo);
public void updatePackageBadge(String packageName);
public void bindComponentsRemoved(ArrayList<String> packageNames,
@@ -2949,6 +2950,64 @@ public class LauncherModel extends BroadcastReceiver
}
}
+ /**
+ * Workaround to re-check unrestored items, in-case they were installed but the Package-ADD
+ * runnable was missed by the launcher.
+ */
+ public void recheckRestoredItems(final Context context) {
+ Runnable r = new Runnable() {
+
+ @Override
+ public void run() {
+ LauncherAppsCompat launcherApps = LauncherAppsCompat.getInstance(context);
+ HashSet<String> installedPackages = new HashSet<String>();
+ UserHandleCompat user = UserHandleCompat.myUserHandle();
+ synchronized(sBgLock) {
+ for (ItemInfo info : sBgItemsIdMap.values()) {
+ if (info instanceof ShortcutInfo) {
+ ShortcutInfo si = (ShortcutInfo) info;
+ if (si.isPromise() && si.getTargetComponent() != null
+ && launcherApps.isPackageEnabledForProfile(
+ si.getTargetComponent().getPackageName(), user)) {
+ installedPackages.add(si.getTargetComponent().getPackageName());
+ }
+ } else if (info instanceof LauncherAppWidgetInfo) {
+ LauncherAppWidgetInfo widget = (LauncherAppWidgetInfo) info;
+ if (widget.hasRestoreFlag(LauncherAppWidgetInfo.FLAG_PROVIDER_NOT_READY)
+ && launcherApps.isPackageEnabledForProfile(
+ widget.providerName.getPackageName(), user)) {
+ installedPackages.add(widget.providerName.getPackageName());
+ }
+ }
+ }
+ }
+
+ if (!installedPackages.isEmpty()) {
+ final ArrayList<AppInfo> restoredApps = new ArrayList<AppInfo>();
+ for (String pkg : installedPackages) {
+ for (LauncherActivityInfoCompat info : launcherApps.getActivityList(pkg, user)) {
+ restoredApps.add(new AppInfo(context, info, user, mIconCache, null));
+ }
+ }
+
+ final Callbacks callbacks = mCallbacks != null ? mCallbacks.get() : null;
+ if (!restoredApps.isEmpty()) {
+ mHandler.post(new Runnable() {
+ public void run() {
+ Callbacks cb = mCallbacks != null ? mCallbacks.get() : null;
+ if (callbacks == cb && cb != null) {
+ callbacks.bindAppsRestored(restoredApps);
+ }
+ }
+ });
+ }
+
+ }
+ }
+ };
+ sWorker.post(r);
+ }
+
private class PackageUpdatedTask implements Runnable {
int mOp;
String[] mPackages;