Fixing issue 4727712, widget list isn't always synced correctly
Change-Id: Iac7fc94d78915e53174ddc4b44854a45da72c443
diff --git a/src/com/android/launcher2/AppsCustomizePagedView.java b/src/com/android/launcher2/AppsCustomizePagedView.java
index 1da6fe0..8158624 100644
--- a/src/com/android/launcher2/AppsCustomizePagedView.java
+++ b/src/com/android/launcher2/AppsCustomizePagedView.java
@@ -324,6 +324,19 @@
}
public void onPackagesUpdated() {
+ // TODO: this isn't ideal, but we actually need to delay here. This call is triggered
+ // by a broadcast receiver, and in order for it to work correctly, we need to know that
+ // the AppWidgetService has already received and processed the same broadcast. Since there
+ // is no guarantee about ordering of broadcast receipt, we just delay here. Ideally,
+ // we should have a more precise way of ensuring the AppWidgetService is up to date.
+ postDelayed(new Runnable() {
+ public void run() {
+ updatePackages();
+ }
+ }, 500);
+ }
+
+ public void updatePackages() {
// Get the list of widgets and shortcuts
boolean wasEmpty = mWidgets.isEmpty();
mWidgets.clear();