summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSunny Goyal <sunnygoyal@google.com>2014-10-14 18:07:33 (GMT)
committerSunny Goyal <sunnygoyal@google.com>2014-10-14 21:02:31 (GMT)
commit8cce9dd83aecd90920db751ab3f8fb6969f087c5 (patch)
treed6f7c80019c3a1407bdc5c8927ac20e9eca0db43
parent0c2918f4f4c4a9a6609b82cf23155ed51840f2c8 (diff)
downloadandroid_packages_apps_Trebuchet-8cce9dd83aecd90920db751ab3f8fb6969f087c5.zip
android_packages_apps_Trebuchet-8cce9dd83aecd90920db751ab3f8fb6969f087c5.tar.gz
android_packages_apps_Trebuchet-8cce9dd83aecd90920db751ab3f8fb6969f087c5.tar.bz2
DO NOT MERGE
Rechecking unrestored items when launcher gets created Bug: 17941096 Change-Id: Ic54464a9c64442d6784cda44ef22fa3d08e22f1f
-rw-r--r--src/com/android/launcher3/Launcher.java19
-rw-r--r--src/com/android/launcher3/LauncherModel.java59
-rw-r--r--src/com/android/launcher3/compat/PackageInstallerCompatVL.java3
3 files changed, 79 insertions, 2 deletions
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index 6603dce..42ec4fb 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -4610,6 +4610,7 @@ public class Launcher extends Activity
mIntentsOnWorkspaceFromUpgradePath = mWorkspace.getUniqueComponents(true, null);
}
PackageInstallerCompat.getInstance(this).onFinishBind();
+ mModel.recheckRestoredItems(this);
}
private void sendLoadingCompleteBroadcastIfNecessary() {
@@ -4719,6 +4720,24 @@ public class Launcher extends Activity
}
/**
+ * Packages were restored
+ */
+ public void bindAppsRestored(final ArrayList<AppInfo> apps) {
+ Runnable r = new Runnable() {
+ public void run() {
+ bindAppsRestored(apps);
+ }
+ };
+ if (waitUntilResume(r)) {
+ return;
+ }
+
+ if (mWorkspace != null) {
+ mWorkspace.updateShortcutsAndWidgets(apps);
+ }
+ }
+
+ /**
* Update the state of a package, typically related to install state.
*
* Implementation of the method from LauncherModel.Callbacks.
diff --git a/src/com/android/launcher3/LauncherModel.java b/src/com/android/launcher3/LauncherModel.java
index 60eb15f..c64506d 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;
diff --git a/src/com/android/launcher3/compat/PackageInstallerCompatVL.java b/src/com/android/launcher3/compat/PackageInstallerCompatVL.java
index a84bf02..16ad379 100644
--- a/src/com/android/launcher3/compat/PackageInstallerCompatVL.java
+++ b/src/com/android/launcher3/compat/PackageInstallerCompatVL.java
@@ -81,7 +81,6 @@ public class PackageInstallerCompatVL extends PackageInstallerCompat {
@Override
public void onStop() {
- mInstaller.unregisterSessionCallback(mCallback);
}
@Override
@@ -112,7 +111,7 @@ public class PackageInstallerCompatVL extends PackageInstallerCompat {
// Not yet ready
return;
}
- if ((mPendingReplays.size() == 0) && (newInfo == null)) {
+ if ((mPendingReplays.size() == 0) && (newInfo == null) && mPendingBadgeUpdates.isEmpty()) {
// Nothing to update
return;
}