summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--api/current.txt3
-rw-r--r--api/system-current.txt3
-rw-r--r--api/test-current.txt3
-rw-r--r--core/java/android/service/autofill/SaveInfo.java42
-rw-r--r--services/autofill/java/com/android/server/autofill/Session.java3
5 files changed, 35 insertions, 19 deletions
diff --git a/api/current.txt b/api/current.txt
index 5b55fdc4b966..1df384023ddb 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -37122,6 +37122,7 @@ package android.service.autofill {
method public int describeContents();
method public void writeToParcel(android.os.Parcel, int);
field public static final android.os.Parcelable.Creator<android.service.autofill.SaveInfo> CREATOR;
+ field public static final int FLAG_SAVE_ON_ALL_VIEWS_INVISIBLE = 1; // 0x1
field public static final int SAVE_DATA_TYPE_ADDRESS = 2; // 0x2
field public static final int SAVE_DATA_TYPE_CREDIT_CARD = 4; // 0x4
field public static final int SAVE_DATA_TYPE_EMAIL_ADDRESS = 16; // 0x10
@@ -37134,9 +37135,9 @@ package android.service.autofill {
ctor public SaveInfo.Builder(int, android.view.autofill.AutofillId[]);
method public android.service.autofill.SaveInfo build();
method public android.service.autofill.SaveInfo.Builder setDescription(java.lang.CharSequence);
+ method public android.service.autofill.SaveInfo.Builder setFlags(int);
method public android.service.autofill.SaveInfo.Builder setNegativeAction(java.lang.CharSequence, android.content.IntentSender);
method public android.service.autofill.SaveInfo.Builder setOptionalIds(android.view.autofill.AutofillId[]);
- method public android.service.autofill.SaveInfo.Builder setSaveOnAllViewsInvisible(boolean);
}
public final class SaveRequest implements android.os.Parcelable {
diff --git a/api/system-current.txt b/api/system-current.txt
index 23a8cad152da..d98f38cabe57 100644
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -40234,6 +40234,7 @@ package android.service.autofill {
method public int describeContents();
method public void writeToParcel(android.os.Parcel, int);
field public static final android.os.Parcelable.Creator<android.service.autofill.SaveInfo> CREATOR;
+ field public static final int FLAG_SAVE_ON_ALL_VIEWS_INVISIBLE = 1; // 0x1
field public static final int SAVE_DATA_TYPE_ADDRESS = 2; // 0x2
field public static final int SAVE_DATA_TYPE_CREDIT_CARD = 4; // 0x4
field public static final int SAVE_DATA_TYPE_EMAIL_ADDRESS = 16; // 0x10
@@ -40246,9 +40247,9 @@ package android.service.autofill {
ctor public SaveInfo.Builder(int, android.view.autofill.AutofillId[]);
method public android.service.autofill.SaveInfo build();
method public android.service.autofill.SaveInfo.Builder setDescription(java.lang.CharSequence);
+ method public android.service.autofill.SaveInfo.Builder setFlags(int);
method public android.service.autofill.SaveInfo.Builder setNegativeAction(java.lang.CharSequence, android.content.IntentSender);
method public android.service.autofill.SaveInfo.Builder setOptionalIds(android.view.autofill.AutofillId[]);
- method public android.service.autofill.SaveInfo.Builder setSaveOnAllViewsInvisible(boolean);
}
public final class SaveRequest implements android.os.Parcelable {
diff --git a/api/test-current.txt b/api/test-current.txt
index 3373ab735a36..958c6203eea8 100644
--- a/api/test-current.txt
+++ b/api/test-current.txt
@@ -37275,6 +37275,7 @@ package android.service.autofill {
method public int describeContents();
method public void writeToParcel(android.os.Parcel, int);
field public static final android.os.Parcelable.Creator<android.service.autofill.SaveInfo> CREATOR;
+ field public static final int FLAG_SAVE_ON_ALL_VIEWS_INVISIBLE = 1; // 0x1
field public static final int SAVE_DATA_TYPE_ADDRESS = 2; // 0x2
field public static final int SAVE_DATA_TYPE_CREDIT_CARD = 4; // 0x4
field public static final int SAVE_DATA_TYPE_EMAIL_ADDRESS = 16; // 0x10
@@ -37287,9 +37288,9 @@ package android.service.autofill {
ctor public SaveInfo.Builder(int, android.view.autofill.AutofillId[]);
method public android.service.autofill.SaveInfo build();
method public android.service.autofill.SaveInfo.Builder setDescription(java.lang.CharSequence);
+ method public android.service.autofill.SaveInfo.Builder setFlags(int);
method public android.service.autofill.SaveInfo.Builder setNegativeAction(java.lang.CharSequence, android.content.IntentSender);
method public android.service.autofill.SaveInfo.Builder setOptionalIds(android.view.autofill.AutofillId[]);
- method public android.service.autofill.SaveInfo.Builder setSaveOnAllViewsInvisible(boolean);
}
public final class SaveRequest implements android.os.Parcelable {
diff --git a/core/java/android/service/autofill/SaveInfo.java b/core/java/android/service/autofill/SaveInfo.java
index 7f960dff0bdf..915d4f792a31 100644
--- a/core/java/android/service/autofill/SaveInfo.java
+++ b/core/java/android/service/autofill/SaveInfo.java
@@ -153,13 +153,27 @@ public final class SaveInfo implements Parcelable {
@Retention(RetentionPolicy.SOURCE)
@interface SaveDataType{}
+ /**
+ * Usually {@link AutofillService#onSaveRequest(AssistStructure, Bundle, SaveCallback)}
+ * is called once the activity finishes. If this flag is set it is called once all saved views
+ * become invisible.
+ */
+ public static final int FLAG_SAVE_ON_ALL_VIEWS_INVISIBLE = 0x1;
+
+ /** @hide */
+ @IntDef(
+ flag = true,
+ value = {FLAG_SAVE_ON_ALL_VIEWS_INVISIBLE})
+ @Retention(RetentionPolicy.SOURCE)
+ @interface SaveInfoFlags{}
+
private final @SaveDataType int mType;
private final CharSequence mNegativeActionTitle;
private final IntentSender mNegativeActionListener;
private final AutofillId[] mRequiredIds;
private final AutofillId[] mOptionalIds;
private final CharSequence mDescription;
- private final boolean mSaveOnAllViewsInvisible;
+ private final int mFlags;
private SaveInfo(Builder builder) {
mType = builder.mType;
@@ -168,7 +182,7 @@ public final class SaveInfo implements Parcelable {
mRequiredIds = builder.mRequiredIds;
mOptionalIds = builder.mOptionalIds;
mDescription = builder.mDescription;
- mSaveOnAllViewsInvisible = builder.mSaveOnAllViewsInvisible;
+ mFlags = builder.mFlags;
}
/** @hide */
@@ -197,8 +211,8 @@ public final class SaveInfo implements Parcelable {
}
/** @hide */
- public boolean saveOnAllViewsInvisible() {
- return mSaveOnAllViewsInvisible;
+ public @SaveInfoFlags int getFlags() {
+ return mFlags;
}
/** @hide */
@@ -219,7 +233,7 @@ public final class SaveInfo implements Parcelable {
private AutofillId[] mOptionalIds;
private CharSequence mDescription;
private boolean mDestroyed;
- private boolean mSaveOnAllViewsInvisible;
+ private int mFlags;
/**
* Creates a new builder.
@@ -268,17 +282,15 @@ public final class SaveInfo implements Parcelable {
}
/**
- * Usually {@link AutofillService#onSaveRequest(AssistStructure, Bundle, SaveCallback)}
- * is called once the activity finishes. If this property is set it is called once all
- * autofillable or saved views become invisible.
+ * Set flags changing the save behavior.
*
- * @param saveOnAllViewsInvisible Set to {@code true} if the data should be saved once
- * all the views become invisible.
+ * @param flags {@link #FLAG_SAVE_ON_ALL_VIEWS_INVISIBLE} or 0.
* @return This builder.
*/
- public @NonNull Builder setSaveOnAllViewsInvisible(boolean saveOnAllViewsInvisible) {
+ public @NonNull Builder setFlags(@SaveInfoFlags int flags) {
throwIfDestroyed();
- mSaveOnAllViewsInvisible = saveOnAllViewsInvisible;
+
+ mFlags = Preconditions.checkFlagsArgument(flags, FLAG_SAVE_ON_ALL_VIEWS_INVISIBLE);
return this;
}
@@ -378,7 +390,7 @@ public final class SaveInfo implements Parcelable {
.append(", requiredIds=").append(Arrays.toString(mRequiredIds))
.append(", optionalIds=").append(Arrays.toString(mOptionalIds))
.append(", description=").append(mDescription)
- .append(", saveOnNoVisibleTrackedViews=").append(mSaveOnAllViewsInvisible)
+ .append(", mFlags=").append(mFlags)
.append("]").toString();
}
@@ -399,7 +411,7 @@ public final class SaveInfo implements Parcelable {
parcel.writeParcelable(mNegativeActionListener, flags);
parcel.writeParcelableArray(mOptionalIds, flags);
parcel.writeCharSequence(mDescription);
- parcel.writeBoolean(mSaveOnAllViewsInvisible);
+ parcel.writeInt(mFlags);
}
public static final Parcelable.Creator<SaveInfo> CREATOR = new Parcelable.Creator<SaveInfo>() {
@@ -413,7 +425,7 @@ public final class SaveInfo implements Parcelable {
builder.setNegativeAction(parcel.readCharSequence(), parcel.readParcelable(null));
builder.setOptionalIds(parcel.readParcelableArray(null, AutofillId.class));
builder.setDescription(parcel.readCharSequence());
- builder.setSaveOnAllViewsInvisible(parcel.readBoolean());
+ builder.setFlags(parcel.readInt());
return builder.build();
}
diff --git a/services/autofill/java/com/android/server/autofill/Session.java b/services/autofill/java/com/android/server/autofill/Session.java
index 7c3f3245461c..6b3203ce04f9 100644
--- a/services/autofill/java/com/android/server/autofill/Session.java
+++ b/services/autofill/java/com/android/server/autofill/Session.java
@@ -764,7 +764,8 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
boolean saveOnAllViewsInvisible = false;
SaveInfo saveInfo = mResponses.valueAt(getLastResponseIndex()).getSaveInfo();
if (saveInfo != null) {
- saveOnAllViewsInvisible = saveInfo.saveOnAllViewsInvisible();
+ saveOnAllViewsInvisible =
+ (saveInfo.getFlags() & SaveInfo.FLAG_SAVE_ON_ALL_VIEWS_INVISIBLE) != 0;
// We only need to track views if we want to save once they become invisible.
if (saveOnAllViewsInvisible) {