Adding widgetFeatures so that a provider can indicate a set of
supported features Bug: 63931362 Bug: 36537581 Test: Added CTS for new APIs Change-Id: I2bd3278bfdf40d88fc8e6f72bfbc7505c64accff
This commit is contained in:
@@ -1505,6 +1505,7 @@ package android {
|
||||
field public static final deprecated int weekSeparatorLineColor = 16843590; // 0x1010346
|
||||
field public static final int weightSum = 16843048; // 0x1010128
|
||||
field public static final int widgetCategory = 16843716; // 0x10103c4
|
||||
field public static final int widgetFeatures = 16844153; // 0x1010579
|
||||
field public static final int widgetLayout = 16843243; // 0x10101eb
|
||||
field public static final int width = 16843097; // 0x1010159
|
||||
field public static final int windowActionBar = 16843469; // 0x10102cd
|
||||
@@ -7348,6 +7349,8 @@ package android.appwidget {
|
||||
field public static final int WIDGET_CATEGORY_HOME_SCREEN = 1; // 0x1
|
||||
field public static final int WIDGET_CATEGORY_KEYGUARD = 2; // 0x2
|
||||
field public static final int WIDGET_CATEGORY_SEARCHBOX = 4; // 0x4
|
||||
field public static final int WIDGET_FEATURE_HIDE_FROM_PICKER = 2; // 0x2
|
||||
field public static final int WIDGET_FEATURE_RECONFIGURABLE = 1; // 0x1
|
||||
field public int autoAdvanceViewId;
|
||||
field public android.content.ComponentName configure;
|
||||
field public int icon;
|
||||
@@ -7363,6 +7366,7 @@ package android.appwidget {
|
||||
field public int resizeMode;
|
||||
field public int updatePeriodMillis;
|
||||
field public int widgetCategory;
|
||||
field public int widgetFeatures;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -17,15 +17,17 @@
|
||||
package android.appwidget;
|
||||
|
||||
import android.annotation.NonNull;
|
||||
import android.app.PendingIntent;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.pm.ActivityInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.res.ResourceId;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import android.content.ComponentName;
|
||||
import android.os.UserHandle;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.util.TypedValue;
|
||||
@@ -68,6 +70,23 @@ public class AppWidgetProviderInfo implements Parcelable {
|
||||
*/
|
||||
public static final int WIDGET_CATEGORY_SEARCHBOX = 4;
|
||||
|
||||
/**
|
||||
* The widget can be reconfigured anytime after it is bound by starting the
|
||||
* {@link #configure} activity.
|
||||
*
|
||||
* @see #widgetFeatures
|
||||
*/
|
||||
public static final int WIDGET_FEATURE_RECONFIGURABLE = 1;
|
||||
|
||||
/**
|
||||
* The widget is added directly by the app, and the host may hide this widget when providing
|
||||
* the user with the list of available widgets to choose from.
|
||||
*
|
||||
* @see AppWidgetManager#requestPinAppWidget(ComponentName, Bundle, PendingIntent)
|
||||
* @see #widgetFeatures
|
||||
*/
|
||||
public static final int WIDGET_FEATURE_HIDE_FROM_PICKER = 2;
|
||||
|
||||
/**
|
||||
* Identity of this AppWidget component. This component should be a {@link
|
||||
* android.content.BroadcastReceiver}, and it will be sent the AppWidget intents
|
||||
@@ -209,6 +228,15 @@ public class AppWidgetProviderInfo implements Parcelable {
|
||||
*/
|
||||
public int widgetCategory;
|
||||
|
||||
/**
|
||||
* Flags indicating various features supported by the widget. These are hints to the widget
|
||||
* host, and do not actually change the behavior of the widget.
|
||||
*
|
||||
* @see #WIDGET_FEATURE_RECONFIGURABLE
|
||||
* @see #WIDGET_FEATURE_HIDE_FROM_PICKER
|
||||
*/
|
||||
public int widgetFeatures;
|
||||
|
||||
/** @hide */
|
||||
public ActivityInfo providerInfo;
|
||||
|
||||
@@ -221,9 +249,7 @@ public class AppWidgetProviderInfo implements Parcelable {
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public AppWidgetProviderInfo(Parcel in) {
|
||||
if (0 != in.readInt()) {
|
||||
this.provider = new ComponentName(in);
|
||||
}
|
||||
this.provider = in.readTypedObject(ComponentName.CREATOR);
|
||||
this.minWidth = in.readInt();
|
||||
this.minHeight = in.readInt();
|
||||
this.minResizeWidth = in.readInt();
|
||||
@@ -231,16 +257,15 @@ public class AppWidgetProviderInfo implements Parcelable {
|
||||
this.updatePeriodMillis = in.readInt();
|
||||
this.initialLayout = in.readInt();
|
||||
this.initialKeyguardLayout = in.readInt();
|
||||
if (0 != in.readInt()) {
|
||||
this.configure = new ComponentName(in);
|
||||
}
|
||||
this.configure = in.readTypedObject(ComponentName.CREATOR);
|
||||
this.label = in.readString();
|
||||
this.icon = in.readInt();
|
||||
this.previewImage = in.readInt();
|
||||
this.autoAdvanceViewId = in.readInt();
|
||||
this.resizeMode = in.readInt();
|
||||
this.widgetCategory = in.readInt();
|
||||
this.providerInfo = in.readParcelable(null);
|
||||
this.providerInfo = in.readTypedObject(ActivityInfo.CREATOR);
|
||||
this.widgetFeatures = in.readInt();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -308,13 +333,8 @@ public class AppWidgetProviderInfo implements Parcelable {
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public void writeToParcel(android.os.Parcel out, int flags) {
|
||||
if (this.provider != null) {
|
||||
out.writeInt(1);
|
||||
this.provider.writeToParcel(out, flags);
|
||||
} else {
|
||||
out.writeInt(0);
|
||||
}
|
||||
public void writeToParcel(Parcel out, int flags) {
|
||||
out.writeTypedObject(this.provider, flags);
|
||||
out.writeInt(this.minWidth);
|
||||
out.writeInt(this.minHeight);
|
||||
out.writeInt(this.minResizeWidth);
|
||||
@@ -322,19 +342,15 @@ public class AppWidgetProviderInfo implements Parcelable {
|
||||
out.writeInt(this.updatePeriodMillis);
|
||||
out.writeInt(this.initialLayout);
|
||||
out.writeInt(this.initialKeyguardLayout);
|
||||
if (this.configure != null) {
|
||||
out.writeInt(1);
|
||||
this.configure.writeToParcel(out, flags);
|
||||
} else {
|
||||
out.writeInt(0);
|
||||
}
|
||||
out.writeTypedObject(this.configure, flags);
|
||||
out.writeString(this.label);
|
||||
out.writeInt(this.icon);
|
||||
out.writeInt(this.previewImage);
|
||||
out.writeInt(this.autoAdvanceViewId);
|
||||
out.writeInt(this.resizeMode);
|
||||
out.writeInt(this.widgetCategory);
|
||||
out.writeParcelable(this.providerInfo, flags);
|
||||
out.writeTypedObject(this.providerInfo, flags);
|
||||
out.writeInt(this.widgetFeatures);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -357,6 +373,7 @@ public class AppWidgetProviderInfo implements Parcelable {
|
||||
that.resizeMode = this.resizeMode;
|
||||
that.widgetCategory = this.widgetCategory;
|
||||
that.providerInfo = this.providerInfo;
|
||||
that.widgetFeatures = this.widgetFeatures;
|
||||
return that;
|
||||
}
|
||||
|
||||
|
||||
@@ -7571,6 +7571,15 @@
|
||||
<flag name="keyguard" value="0x2" />
|
||||
<flag name="searchbox" value="0x4" />
|
||||
</attr>
|
||||
<!-- Flags indicating various features supported by the widget. These are hints to the
|
||||
widget host, and do not actually change the behavior of the widget. -->
|
||||
<attr name="widgetFeatures" format="integer">
|
||||
<!-- The widget can be reconfigured anytime after it is bound -->
|
||||
<flag name="reconfigurable" value="0x1" />
|
||||
<!-- The widget is added directly by the app, and does not need to appear in
|
||||
the global list of available widgets -->
|
||||
<flag name="hide_from_picker" value="0x2" />
|
||||
</attr>
|
||||
</declare-styleable>
|
||||
|
||||
<!-- =============================== -->
|
||||
|
||||
@@ -2858,6 +2858,7 @@
|
||||
<public name="versionMajor" />
|
||||
<!-- @hide @SystemApi -->
|
||||
<public name="isVrOnly"/>
|
||||
<public name="widgetFeatures" />
|
||||
</public-group>
|
||||
|
||||
<public-group type="style" first-id="0x010302e0">
|
||||
|
||||
@@ -2506,6 +2506,8 @@ class AppWidgetServiceImpl extends IAppWidgetService.Stub implements WidgetBacku
|
||||
info.widgetCategory = sa.getInt(
|
||||
com.android.internal.R.styleable.AppWidgetProviderInfo_widgetCategory,
|
||||
AppWidgetProviderInfo.WIDGET_CATEGORY_HOME_SCREEN);
|
||||
info.widgetFeatures = sa.getInt(
|
||||
com.android.internal.R.styleable.AppWidgetProviderInfo_widgetFeatures, 0);
|
||||
|
||||
sa.recycle();
|
||||
} catch (IOException | PackageManager.NameNotFoundException | XmlPullParserException e) {
|
||||
|
||||
Reference in New Issue
Block a user