summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher/LauncherProvider.java
diff options
context:
space:
mode:
authorJeffrey Sharkey <>2009-03-31 14:37:57 -0700
committerThe Android Open Source Project <initial-contribution@android.com>2009-03-31 14:37:57 -0700
commit2bbcae19224447c018b87bccff2b7f5e650d18d8 (patch)
tree7611574f12e387e4ba48e0270f0e9dbafc0c8e96 /src/com/android/launcher/LauncherProvider.java
parentc026e8ef0b0209342686f83aea983eda03dc252b (diff)
downloadandroid_packages_apps_Trebuchet-2bbcae19224447c018b87bccff2b7f5e650d18d8.tar.gz
android_packages_apps_Trebuchet-2bbcae19224447c018b87bccff2b7f5e650d18d8.tar.bz2
android_packages_apps_Trebuchet-2bbcae19224447c018b87bccff2b7f5e650d18d8.zip
AI 143776: am: CL 143622 Correctly startListening() for widget updates when first boot completes.
During the first boot upgrade, LauncherProvider will deleteHost() to clear out any old appWidgetId bindings. During the first boot, Launcher calls AppWidgetHost.startListening() to watch for widget updates. It also calls loadUserItems(), which loads data from LauncherProvider, triggering the database creation and deleteHost() call. Because deleteHost() removes any existing callbacks, any future widget updates are dropped on the floor. (This can currently be solved by rebooting, because there isn't an upgrade on subsequent boots.) This bug was particularly evident on vfpioneer-userdebug builds, as there aren't any configuration changes that cause Launcher to be destroyed and recreated. (When destroyed and recreated, we startListening() again, and LauncherProvider doesn't call deleteHost().) To handle this special case, Launcher creates a ContentObserver pointing at a specific URI, which the LauncherProvider notifies when the AppWidgetHost is reset through deleteHost(), allowing Launcher to correctly startListening() again. Original author: jsharkey Merged from: //branches/cupcake/... Automated import of CL 143776
Diffstat (limited to 'src/com/android/launcher/LauncherProvider.java')
-rw-r--r--src/com/android/launcher/LauncherProvider.java20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/com/android/launcher/LauncherProvider.java b/src/com/android/launcher/LauncherProvider.java
index e63ef3084..a27b74667 100644
--- a/src/com/android/launcher/LauncherProvider.java
+++ b/src/com/android/launcher/LauncherProvider.java
@@ -65,6 +65,14 @@ public class LauncherProvider extends ContentProvider {
static final String TABLE_FAVORITES = "favorites";
static final String PARAMETER_NOTIFY = "notify";
+ /**
+ * {@link Uri} triggered at any registered {@link ContentObserver} when
+ * {@link AppWidgetHost#deleteHost()} is called during database creation.
+ * Use this to recall {@link AppWidgetHost#startListening()} if needed.
+ */
+ static final Uri CONTENT_APPWIDGET_RESET_URI =
+ Uri.parse("content://" + AUTHORITY + "/appWidgetReset");
+
private SQLiteOpenHelper mOpenHelper;
@Override
@@ -176,6 +184,17 @@ public class LauncherProvider extends ContentProvider {
mAppWidgetHost = new AppWidgetHost(context, Launcher.APPWIDGET_HOST_ID);
}
+ /**
+ * Send notification that we've deleted the {@link AppWidgetHost},
+ * probably as part of the initial database creation. The receiver may
+ * want to re-call {@link AppWidgetHost#startListening()} to ensure
+ * callbacks are correctly set.
+ */
+ private void sendAppWidgetResetNotify() {
+ final ContentResolver resolver = mContext.getContentResolver();
+ resolver.notifyChange(CONTENT_APPWIDGET_RESET_URI, null);
+ }
+
@Override
public void onCreate(SQLiteDatabase db) {
if (LOGD) Log.d(LOG_TAG, "creating new launcher database");
@@ -204,6 +223,7 @@ public class LauncherProvider extends ContentProvider {
// Database was just created, so wipe any previous widgets
if (mAppWidgetHost != null) {
mAppWidgetHost.deleteHost();
+ sendAppWidgetResetNotify();
}
if (!convertDatabase(db)) {