summaryrefslogtreecommitdiff
path: root/core/java/android/appwidget/AppWidgetHost.java
diff options
context:
space:
mode:
authorSunny Goyal <sunnygoyal@google.com>2016-05-11 18:22:20 -0700
committerSunny Goyal <sunnygoyal@google.com>2016-05-16 17:23:00 -0700
commit6d1b41d477ec9426f84ea2dad27cdbb714761da2 (patch)
treec1d7af938fe2d17c5b7039ea7fd4519571402f78 /core/java/android/appwidget/AppWidgetHost.java
parent27f5e091d0fe7dbb19c85398e756326a08d28d11 (diff)
Maintaining diff for all widget operations instead of just the Views update
When the widget starts lisnening again, it receives all the pending updates until that point (restricted to the requested widgetIds). When startListening is called for the first time, the widgetIds is empty and it does not get any updated. Further calls to startlisting will give the missed updates for the bound widgets Bug: 23892701 Change-Id: I3aa06d3e33a0861c19cfd5ced567d5bb3b93d906
Diffstat (limited to 'core/java/android/appwidget/AppWidgetHost.java')
-rw-r--r--core/java/android/appwidget/AppWidgetHost.java22
1 files changed, 15 insertions, 7 deletions
diff --git a/core/java/android/appwidget/AppWidgetHost.java b/core/java/android/appwidget/AppWidgetHost.java
index 2d9f4a71b005..cd144695a989 100644
--- a/core/java/android/appwidget/AppWidgetHost.java
+++ b/core/java/android/appwidget/AppWidgetHost.java
@@ -34,7 +34,6 @@ import android.os.Message;
import android.os.Process;
import android.os.RemoteException;
import android.os.ServiceManager;
-import android.os.SystemClock;
import android.util.DisplayMetrics;
import android.util.SparseArray;
import android.util.TypedValue;
@@ -187,19 +186,28 @@ public class AppWidgetHost {
idsToUpdate[i] = mViews.keyAt(i);
}
}
- List<RemoteViews> updatedViews;
- int[] updatedIds = new int[idsToUpdate.length];
+ List<PendingHostUpdate> updates;
try {
- updatedViews = sService.startListening(
- mCallbacks, mContextOpPackageName, mHostId, idsToUpdate, updatedIds).getList();
+ updates = sService.startListening(
+ mCallbacks, mContextOpPackageName, mHostId, idsToUpdate).getList();
}
catch (RemoteException e) {
throw new RuntimeException("system server dead?", e);
}
- int N = updatedViews.size();
+ int N = updates.size();
for (int i = 0; i < N; i++) {
- updateAppWidgetView(updatedIds[i], updatedViews.get(i));
+ PendingHostUpdate update = updates.get(i);
+ switch (update.type) {
+ case PendingHostUpdate.TYPE_VIEWS_UPDATE:
+ updateAppWidgetView(update.appWidgetId, update.views);
+ break;
+ case PendingHostUpdate.TYPE_PROVIDER_CHANGED:
+ onProviderChanged(update.appWidgetId, update.widgetInfo);
+ break;
+ case PendingHostUpdate.TYPE_VIEW_DATA_CHANGED:
+ viewDataChanged(update.appWidgetId, update.viewId);
+ }
}
}