From 6d1b41d477ec9426f84ea2dad27cdbb714761da2 Mon Sep 17 00:00:00 2001 From: Sunny Goyal Date: Wed, 11 May 2016 18:22:20 -0700 Subject: 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 --- core/java/android/appwidget/AppWidgetHost.java | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) (limited to 'core/java/android/appwidget/AppWidgetHost.java') 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 updatedViews; - int[] updatedIds = new int[idsToUpdate.length]; + List 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); + } } } -- cgit v1.2.3