diff options
| author | Winson Chung <winsonc@google.com> | 2010-07-16 11:18:17 -0700 |
|---|---|---|
| committer | Winson Chung <winsonc@google.com> | 2010-07-19 14:48:31 -0700 |
| commit | 499cb9f516062b654952d282f211bee44c31a3c2 (patch) | |
| tree | 3c9bac8b31275e886bfbd07805c38839c185eab2 /services/java/com/android/server/AppWidgetService.java | |
| parent | b5b37f3bcc3065959c27e588f065dfb33a061e1d (diff) | |
| download | frameworks_base-499cb9f516062b654952d282f211bee44c31a3c2.zip frameworks_base-499cb9f516062b654952d282f211bee44c31a3c2.tar.gz frameworks_base-499cb9f516062b654952d282f211bee44c31a3c2.tar.bz2 | |
Initial changes to allow collections in widgets.
Change-Id: I3cfa899bae88cd252912cecebc12e93c27a3b7c9
Diffstat (limited to 'services/java/com/android/server/AppWidgetService.java')
| -rw-r--r-- | services/java/com/android/server/AppWidgetService.java | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/services/java/com/android/server/AppWidgetService.java b/services/java/com/android/server/AppWidgetService.java index 1674221..3059732 100644 --- a/services/java/com/android/server/AppWidgetService.java +++ b/services/java/com/android/server/AppWidgetService.java @@ -425,6 +425,23 @@ class AppWidgetService extends IAppWidgetService.Stub } } + public void notifyAppWidgetViewDataChanged(int[] appWidgetIds, RemoteViews views, int viewId) { + if (appWidgetIds == null) { + return; + } + if (appWidgetIds.length == 0) { + return; + } + final int N = appWidgetIds.length; + + synchronized (mAppWidgetIds) { + for (int i=0; i<N; i++) { + AppWidgetId id = lookupAppWidgetIdLocked(appWidgetIds[i]); + notifyAppWidgetViewDataChangedInstanceLocked(id, views, viewId); + } + } + } + public void updateAppWidgetProvider(ComponentName provider, RemoteViews views) { synchronized (mAppWidgetIds) { Provider p = lookupProviderLocked(provider); @@ -462,6 +479,27 @@ class AppWidgetService extends IAppWidgetService.Stub } } + void notifyAppWidgetViewDataChangedInstanceLocked(AppWidgetId id, RemoteViews views, int viewId) { + // allow for stale appWidgetIds and other badness + // lookup also checks that the calling process can access the appWidgetId + // drop unbound appWidgetIds (shouldn't be possible under normal circumstances) + if (id != null && id.provider != null && !id.provider.zombie && !id.host.zombie) { + id.views = views; + + // is anyone listening? + if (id.host.callbacks != null) { + try { + // the lock is held, but this is a oneway call + id.host.callbacks.viewDataChanged(id.appWidgetId, views, viewId); + } catch (RemoteException e) { + // It failed; remove the callback. No need to prune because + // we know that this host is still referenced by this instance. + id.host.callbacks = null; + } + } + } + } + public int[] startListening(IAppWidgetHost callbacks, String packageName, int hostId, List<RemoteViews> updatedViews) { int callingUid = enforceCallingUid(packageName); |
