diff options
| author | Winson Chung <winsonc@google.com> | 2011-01-11 18:05:01 -0800 |
|---|---|---|
| committer | Winson Chung <winsonc@google.com> | 2011-01-18 22:57:09 -0800 |
| commit | 81f39eb6e76d0be1dd341af835e8002a0f80524e (patch) | |
| tree | c4e0d4f4e531b779ae0ea16b1eb3cd783c633564 /core/java/android/widget/RemoteViews.java | |
| parent | 5fb60c7af2cbf59a99ae324c4284c7860b37c723 (diff) | |
Refactoring app widgets to address security/performance issues.
- Moving the service binding to AppWidgetService to prevent arbitrary apps from binding to widget services
- Requiring RemoteViewsServices to require android.permission.BIND_REMOTEVIEWS permission
Change-Id: Id135bafba998299eb278067712b8a5d8487cfd04
Diffstat (limited to 'core/java/android/widget/RemoteViews.java')
| -rw-r--r-- | core/java/android/widget/RemoteViews.java | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/core/java/android/widget/RemoteViews.java b/core/java/android/widget/RemoteViews.java index 8f2531172c4a..c336ccbbd988 100644 --- a/core/java/android/widget/RemoteViews.java +++ b/core/java/android/widget/RemoteViews.java @@ -59,6 +59,12 @@ public class RemoteViews implements Parcelable, Filter { private static final String LOG_TAG = "RemoteViews"; /** + * The intent extra that contains the appWidgetId. + * @hide + */ + static final String EXTRA_REMOTEADAPTER_APPWIDGET_ID = "remoteAdapterAppWidgetId"; + + /** * The package name of the package containing the layout * resource. (Added to the parcel) */ @@ -1276,6 +1282,22 @@ public class RemoteViews implements Parcelable, Filter { * providing data to the RemoteViewsAdapter */ public void setRemoteAdapter(int viewId, Intent intent) { + // Do nothing. This method will be removed after all widgets have been updated to the + // new API. + } + + /** + * Equivalent to calling {@link android.widget.AbsListView#setRemoteViewsAdapter(Intent)}. + * + * @param appWidgetId The id of the app widget which contains the specified view + * @param viewId The id of the view whose text should change + * @param intent The intent of the service which will be + * providing data to the RemoteViewsAdapter + */ + public void setRemoteAdapter(int appWidgetId, int viewId, Intent intent) { + // Embed the AppWidget Id for use in RemoteViewsAdapter when connecting to the intent + // RemoteViewsService + intent.putExtra(EXTRA_REMOTEADAPTER_APPWIDGET_ID, appWidgetId); setIntent(viewId, "setRemoteViewsAdapter", intent); } |
