@@ -150,25 +150,33 @@ public class AppWidgetManager {
150150 public static final String EXTRA_APPWIDGET_ID = "appWidgetId" ;
151151
152152 /**
153- * An bundle extra that contains the lower bound on the current width, in dips, of a widget instance.
153+ * A bundle extra that contains the lower bound on the current width, in dips, of a widget instance.
154154 */
155155 public static final String OPTION_APPWIDGET_MIN_WIDTH = "appWidgetMinWidth" ;
156156
157157 /**
158- * An bundle extra that contains the lower bound on the current height, in dips, of a widget instance.
158+ * A bundle extra that contains the lower bound on the current height, in dips, of a widget instance.
159159 */
160160 public static final String OPTION_APPWIDGET_MIN_HEIGHT = "appWidgetMinHeight" ;
161161
162162 /**
163- * An bundle extra that contains the upper bound on the current width, in dips, of a widget instance.
163+ * A bundle extra that contains the upper bound on the current width, in dips, of a widget instance.
164164 */
165165 public static final String OPTION_APPWIDGET_MAX_WIDTH = "appWidgetMaxWidth" ;
166166
167167 /**
168- * An bundle extra that contains the upper bound on the current width, in dips, of a widget instance.
168+ * A bundle extra that contains the upper bound on the current width, in dips, of a widget instance.
169169 */
170170 public static final String OPTION_APPWIDGET_MAX_HEIGHT = "appWidgetMaxHeight" ;
171171
172+ /**
173+ * A bundle extra that hints to the AppWidgetProvider the category of host that owns this
174+ * this widget. Can have the value {@link
175+ * AppWidgetProviderInfo#WIDGET_CATEGORY_HOME_SCREEN} or {@link
176+ * AppWidgetProviderInfo#WIDGET_CATEGORY_KEYGUARD}.
177+ */
178+ public static final String OPTION_APPWIDGET_HOST_CATEGORY = "appWidgetCategory" ;
179+
172180 /**
173181 * An intent extra which points to a bundle of extra information for a particular widget id.
174182 * In particular this bundle can contain EXTRA_APPWIDGET_WIDTH and EXTRA_APPWIDGET_HEIGHT.
@@ -568,7 +576,31 @@ public AppWidgetProviderInfo getAppWidgetInfo(int appWidgetId) {
568576 */
569577 public void bindAppWidgetId (int appWidgetId , ComponentName provider ) {
570578 try {
571- sService .bindAppWidgetId (appWidgetId , provider );
579+ sService .bindAppWidgetId (appWidgetId , provider , null );
580+ }
581+ catch (RemoteException e ) {
582+ throw new RuntimeException ("system server dead?" , e );
583+ }
584+ }
585+
586+ /**
587+ * Set the component for a given appWidgetId.
588+ *
589+ * <p class="note">You need the BIND_APPWIDGET permission or the user must have enabled binding
590+ * widgets always for your component. This method is used by the AppWidget picker and
591+ * should not be used by other apps.
592+ *
593+ * @param appWidgetId The AppWidget instance for which to set the RemoteViews.
594+ * @param provider The {@link android.content.BroadcastReceiver} that will be the AppWidget
595+ * provider for this AppWidget.
596+ * @param options Bundle containing options for the AppWidget. See also
597+ * {@link #updateAppWidgetOptions(int, Bundle)}
598+ *
599+ * @hide
600+ */
601+ public void bindAppWidgetId (int appWidgetId , ComponentName provider , Bundle options ) {
602+ try {
603+ sService .bindAppWidgetId (appWidgetId , provider , options );
572604 }
573605 catch (RemoteException e ) {
574606 throw new RuntimeException ("system server dead?" , e );
@@ -594,7 +626,37 @@ public boolean bindAppWidgetIdIfAllowed(int appWidgetId, ComponentName provider)
594626 }
595627 try {
596628 return sService .bindAppWidgetIdIfAllowed (
597- mContext .getPackageName (), appWidgetId , provider );
629+ mContext .getPackageName (), appWidgetId , provider , null );
630+ }
631+ catch (RemoteException e ) {
632+ throw new RuntimeException ("system server dead?" , e );
633+ }
634+ }
635+
636+ /**
637+ * Set the component for a given appWidgetId.
638+ *
639+ * <p class="note">You need the BIND_APPWIDGET permission or the user must have enabled binding
640+ * widgets always for your component. Should be used by apps that host widgets; if this
641+ * method returns false, call {@link #ACTION_APPWIDGET_BIND} to request permission to
642+ * bind
643+ *
644+ * @param appWidgetId The AppWidget instance for which to set the RemoteViews.
645+ * @param provider The {@link android.content.BroadcastReceiver} that will be the AppWidget
646+ * provider for this AppWidget.
647+ * @param options Bundle containing options for the AppWidget. See also
648+ * {@link #updateAppWidgetOptions(int, Bundle)}
649+ *
650+ * @return true if this component has permission to bind the AppWidget
651+ */
652+ public boolean bindAppWidgetIdIfAllowed (int appWidgetId , ComponentName provider ,
653+ Bundle options ) {
654+ if (mContext == null ) {
655+ return false ;
656+ }
657+ try {
658+ return sService .bindAppWidgetIdIfAllowed (
659+ mContext .getPackageName (), appWidgetId , provider , options );
598660 }
599661 catch (RemoteException e ) {
600662 throw new RuntimeException ("system server dead?" , e );
0 commit comments