summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/api/system-current.txt2
-rw-r--r--core/java/android/app/smartspace/SmartspaceTarget.java58
2 files changed, 55 insertions, 5 deletions
diff --git a/core/api/system-current.txt b/core/api/system-current.txt
index 1a7810adc5b4..250d329c8761 100644
--- a/core/api/system-current.txt
+++ b/core/api/system-current.txt
@@ -2451,6 +2451,7 @@ package android.app.smartspace {
method public int getFeatureType();
method @Nullable public android.app.smartspace.SmartspaceAction getHeaderAction();
method @NonNull public java.util.List<android.app.smartspace.SmartspaceAction> getIconGrid();
+ method @FlaggedApi("android.app.smartspace.flags.remote_views") @Nullable public android.widget.RemoteViews getRemoteViews();
method public float getScore();
method @Nullable public android.net.Uri getSliceUri();
method @NonNull public String getSmartspaceTargetId();
@@ -2525,6 +2526,7 @@ package android.app.smartspace {
method @NonNull public android.app.smartspace.SmartspaceTarget.Builder setFeatureType(int);
method @NonNull public android.app.smartspace.SmartspaceTarget.Builder setHeaderAction(@NonNull android.app.smartspace.SmartspaceAction);
method @NonNull public android.app.smartspace.SmartspaceTarget.Builder setIconGrid(@NonNull java.util.List<android.app.smartspace.SmartspaceAction>);
+ method @FlaggedApi("android.app.smartspace.flags.remote_views") @NonNull public android.app.smartspace.SmartspaceTarget.Builder setRemoteViews(@NonNull android.widget.RemoteViews);
method @NonNull public android.app.smartspace.SmartspaceTarget.Builder setScore(float);
method @NonNull public android.app.smartspace.SmartspaceTarget.Builder setSensitive(boolean);
method @NonNull public android.app.smartspace.SmartspaceTarget.Builder setShouldShowExpanded(boolean);
diff --git a/core/java/android/app/smartspace/SmartspaceTarget.java b/core/java/android/app/smartspace/SmartspaceTarget.java
index 3c66a15399d3..f6f65c73dfb9 100644
--- a/core/java/android/app/smartspace/SmartspaceTarget.java
+++ b/core/java/android/app/smartspace/SmartspaceTarget.java
@@ -16,10 +16,12 @@
package android.app.smartspace;
import android.annotation.CurrentTimeMillisLong;
+import android.annotation.FlaggedApi;
import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.SystemApi;
+import android.app.smartspace.flags.Flags;
import android.app.smartspace.uitemplatedata.BaseTemplateData;
import android.appwidget.AppWidgetProviderInfo;
import android.content.ComponentName;
@@ -27,6 +29,7 @@ import android.net.Uri;
import android.os.Parcel;
import android.os.Parcelable;
import android.os.UserHandle;
+import android.widget.RemoteViews;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@@ -41,7 +44,8 @@ import java.util.Objects;
* {@link SmartspaceAction} as their type because they can have associated actions.
*
* <p><b>NOTE: </b>
- * If {@link mWidget} is set, it should be preferred over all other properties.
+ * If either {@link mRemoteViews} or {@link mWidget} is set, it should be preferred over all
+ * other properties. (An exception is thrown if both are set.)
* Else, if {@link mSliceUri} is set, it should be preferred over all other data properties.
* Otherwise, the instance should be treated as a data object.
*
@@ -133,6 +137,9 @@ public final class SmartspaceTarget implements Parcelable {
private final AppWidgetProviderInfo mWidget;
@Nullable
+ private final RemoteViews mRemoteViews;
+
+ @Nullable
private final BaseTemplateData mTemplateData;
public static final int FEATURE_UNDEFINED = 0;
@@ -288,6 +295,7 @@ public final class SmartspaceTarget implements Parcelable {
this.mSliceUri = in.readTypedObject(Uri.CREATOR);
this.mWidget = in.readTypedObject(AppWidgetProviderInfo.CREATOR);
this.mTemplateData = in.readParcelable(/* loader= */null, BaseTemplateData.class);
+ this.mRemoteViews = in.readTypedObject(RemoteViews.CREATOR);
}
private SmartspaceTarget(String smartspaceTargetId,
@@ -298,7 +306,7 @@ public final class SmartspaceTarget implements Parcelable {
boolean shouldShowExpanded, String sourceNotificationKey,
ComponentName componentName, UserHandle userHandle,
String associatedSmartspaceTargetId, Uri sliceUri,
- AppWidgetProviderInfo widget, BaseTemplateData templateData) {
+ AppWidgetProviderInfo widget, BaseTemplateData templateData, RemoteViews remoteViews) {
mSmartspaceTargetId = smartspaceTargetId;
mHeaderAction = headerAction;
mBaseAction = baseAction;
@@ -317,6 +325,7 @@ public final class SmartspaceTarget implements Parcelable {
mSliceUri = sliceUri;
mWidget = widget;
mTemplateData = templateData;
+ mRemoteViews = remoteViews;
}
/**
@@ -461,6 +470,15 @@ public final class SmartspaceTarget implements Parcelable {
}
/**
+ * Returns the {@link RemoteViews} to show over the target.
+ */
+ @FlaggedApi(Flags.FLAG_REMOTE_VIEWS)
+ @Nullable
+ public RemoteViews getRemoteViews() {
+ return mRemoteViews;
+ }
+
+ /**
* @see Parcelable.Creator
*/
@NonNull
@@ -496,6 +514,7 @@ public final class SmartspaceTarget implements Parcelable {
dest.writeTypedObject(this.mSliceUri, flags);
dest.writeTypedObject(this.mWidget, flags);
dest.writeParcelable(this.mTemplateData, flags);
+ dest.writeTypedObject(this.mRemoteViews, flags);
}
@Override
@@ -524,6 +543,7 @@ public final class SmartspaceTarget implements Parcelable {
+ ", mSliceUri=" + mSliceUri
+ ", mWidget=" + mWidget
+ ", mTemplateData=" + mTemplateData
+ + ", mRemoteViews=" + mRemoteViews
+ '}';
}
@@ -550,7 +570,8 @@ public final class SmartspaceTarget implements Parcelable {
that.mAssociatedSmartspaceTargetId)
&& Objects.equals(mSliceUri, that.mSliceUri)
&& Objects.equals(mWidget, that.mWidget)
- && Objects.equals(mTemplateData, that.mTemplateData);
+ && Objects.equals(mTemplateData, that.mTemplateData)
+ && Objects.equals(mRemoteViews, that.mRemoteViews);
}
@Override
@@ -558,7 +579,7 @@ public final class SmartspaceTarget implements Parcelable {
return Objects.hash(mSmartspaceTargetId, mHeaderAction, mBaseAction, mCreationTimeMillis,
mExpiryTimeMillis, mScore, mActionChips, mIconGrid, mFeatureType, mSensitive,
mShouldShowExpanded, mSourceNotificationKey, mComponentName, mUserHandle,
- mAssociatedSmartspaceTargetId, mSliceUri, mWidget, mTemplateData);
+ mAssociatedSmartspaceTargetId, mSliceUri, mWidget, mTemplateData, mRemoteViews);
}
/**
@@ -588,6 +609,8 @@ public final class SmartspaceTarget implements Parcelable {
private AppWidgetProviderInfo mWidget;
private BaseTemplateData mTemplateData;
+ private RemoteViews mRemoteViews;
+
/**
* A builder for {@link SmartspaceTarget}.
*
@@ -727,9 +750,15 @@ public final class SmartspaceTarget implements Parcelable {
*
* <p><b>NOTE: </b> If {@link mWidget} is set, all other @Nullable params should be
* ignored.
+ *
+ * @throws An {@link IllegalStateException} is thrown if {@link mRemoteViews} is set.
*/
@NonNull
public Builder setWidget(@NonNull AppWidgetProviderInfo widget) {
+ if (mRemoteViews != null) {
+ throw new IllegalStateException(
+ "Widget providers and RemoteViews cannot be used at the same time.");
+ }
this.mWidget = widget;
return this;
}
@@ -745,6 +774,25 @@ public final class SmartspaceTarget implements Parcelable {
}
/**
+ * Sets the {@link RemoteViews}.
+ *
+ * <p><b>NOTE: </b> If {@link RemoteViews} is set, all other @Nullable params should be
+ * ignored.
+ *
+ * @throws An {@link IllegalStateException} is thrown if {@link mWidget} is set.
+ */
+ @FlaggedApi(Flags.FLAG_REMOTE_VIEWS)
+ @NonNull
+ public Builder setRemoteViews(@NonNull RemoteViews remoteViews) {
+ if (mWidget != null) {
+ throw new IllegalStateException(
+ "Widget providers and RemoteViews cannot be used at the same time.");
+ }
+ mRemoteViews = remoteViews;
+ return this;
+ }
+
+ /**
* Builds a new {@link SmartspaceTarget}.
*
* @throws IllegalStateException when non null fields are set as null.
@@ -760,7 +808,7 @@ public final class SmartspaceTarget implements Parcelable {
mHeaderAction, mBaseAction, mCreationTimeMillis, mExpiryTimeMillis, mScore,
mActionChips, mIconGrid, mFeatureType, mSensitive, mShouldShowExpanded,
mSourceNotificationKey, mComponentName, mUserHandle,
- mAssociatedSmartspaceTargetId, mSliceUri, mWidget, mTemplateData);
+ mAssociatedSmartspaceTargetId, mSliceUri, mWidget, mTemplateData, mRemoteViews);
}
}
}