summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoe Onorato <joeo@android.com>2010-05-04 11:49:12 -0700
committerJoe Onorato <joeo@android.com>2010-05-04 11:49:12 -0700
commitf140be6c3c21dd0f6d2214929e89d60de31d2c04 (patch)
tree77564afd7045481716bebba8b4d4711298383584
parent3bb5e4d322a6a7cda45e868dbe307c2dc3cf688e (diff)
downloadframeworks_base-f140be6c3c21dd0f6d2214929e89d60de31d2c04.zip
frameworks_base-f140be6c3c21dd0f6d2214929e89d60de31d2c04.tar.gz
frameworks_base-f140be6c3c21dd0f6d2214929e89d60de31d2c04.tar.bz2
Call into app widget hosts when the provider is updated.
Change-Id: If0a2459901e88cf04810b23178e4673d44fa69cc
-rw-r--r--core/java/android/appwidget/AppWidgetHost.java10
-rw-r--r--core/java/android/appwidget/AppWidgetHostView.java16
2 files changed, 23 insertions, 3 deletions
diff --git a/core/java/android/appwidget/AppWidgetHost.java b/core/java/android/appwidget/AppWidgetHost.java
index 456ceb6..88adabd 100644
--- a/core/java/android/appwidget/AppWidgetHost.java
+++ b/core/java/android/appwidget/AppWidgetHost.java
@@ -231,8 +231,14 @@ public class AppWidgetHost {
/**
* Called when the AppWidget provider for a AppWidget has been upgraded to a new apk.
*/
- @SuppressWarnings({"UnusedDeclaration"})
protected void onProviderChanged(int appWidgetId, AppWidgetProviderInfo appWidget) {
+ AppWidgetHostView v;
+ synchronized (mViews) {
+ v = mViews.get(appWidgetId);
+ }
+ if (v != null) {
+ v.updateAppWidget(null, AppWidgetHostView.UPDATE_FLAGS_RESET);
+ }
}
void updateAppWidgetView(int appWidgetId, RemoteViews views) {
@@ -241,7 +247,7 @@ public class AppWidgetHost {
v = mViews.get(appWidgetId);
}
if (v != null) {
- v.updateAppWidget(views);
+ v.updateAppWidget(views, 0);
}
}
}
diff --git a/core/java/android/appwidget/AppWidgetHostView.java b/core/java/android/appwidget/AppWidgetHostView.java
index 792b289..5375193 100644
--- a/core/java/android/appwidget/AppWidgetHostView.java
+++ b/core/java/android/appwidget/AppWidgetHostView.java
@@ -46,6 +46,8 @@ public class AppWidgetHostView extends FrameLayout {
static final boolean LOGD = false;
static final boolean CROSSFADE = false;
+ static final int UPDATE_FLAGS_RESET = 0x00000001;
+
static final int VIEW_MODE_NOINIT = 0;
static final int VIEW_MODE_CONTENT = 1;
static final int VIEW_MODE_ERROR = 2;
@@ -150,7 +152,16 @@ public class AppWidgetHostView extends FrameLayout {
* AppWidget provider. Will animate into these new views as needed
*/
public void updateAppWidget(RemoteViews remoteViews) {
- if (LOGD) Log.d(TAG, "updateAppWidget called mOld=" + mOld);
+ updateAppWidget(remoteViews, 0);
+ }
+
+ void updateAppWidget(RemoteViews remoteViews, int flags) {
+ if (LOGD) Log.d(TAG, "updateAppWidget called mOld=" + mOld + " flags=0x"
+ + Integer.toHexString(flags));
+
+ if ((flags & UPDATE_FLAGS_RESET) != 0) {
+ mViewMode = VIEW_MODE_NOINIT;
+ }
boolean recycled = false;
View content = null;
@@ -323,6 +334,9 @@ public class AppWidgetHostView extends FrameLayout {
* Inflate and return the default layout requested by AppWidget provider.
*/
protected View getDefaultView() {
+ if (LOGD) {
+ Log.d(TAG, "getDefaultView");
+ }
View defaultView = null;
Exception exception = null;