Minor improvements on autofill javadocs and logging.
Test: m update-api
Bug: 69456547
Change-Id: I2cab6d7d6ecbe7c1842a5be37af923dd20355b73
diff --git a/core/java/android/service/autofill/Dataset.java b/core/java/android/service/autofill/Dataset.java
index 331130e..cb20e71 100644
--- a/core/java/android/service/autofill/Dataset.java
+++ b/core/java/android/service/autofill/Dataset.java
@@ -216,7 +216,12 @@
}
/**
- * Requires a dataset authentication before autofilling the activity with this dataset.
+ * Triggers a custom UI before before autofilling the screen with the contents of this
+ * dataset.
+ *
+ * <p><b>Note:</b> Although the name of this method suggests that it should be used just for
+ * authentication flow, it can be used for other advanced flows; see {@link AutofillService}
+ * for examples.
*
* <p>This method is called when you need to provide an authentication
* UI for the data set. For example, when a data set contains credit card information
@@ -335,9 +340,11 @@
/**
* Sets the value of a field using an <a href="#Filtering">explicit filter</a>.
*
- * <p>This method is typically used when the dataset is not authenticated and the field
- * value is not {@link AutofillValue#isText() text} but the service still wants to allow
- * the user to filter it out.
+ * <p>This method is typically used when the dataset is authenticated and the service
+ * does not know its value but wants to hide the dataset after the user enters a minimum
+ * number of characters. For example, if the dataset represents a credit card number and the
+ * service does not want to show the "Tap to authenticate" message until the user tapped
+ * 4 digits, in which case the filter would be {@code Pattern.compile("\\d.{4,}")}.
*
* @param id id returned by {@link
* android.app.assist.AssistStructure.ViewNode#getAutofillId()}.
@@ -364,11 +371,11 @@
* Sets the value of a field, using a custom {@link RemoteViews presentation} to
* visualize it and a <a href="#Filtering">explicit filter</a>.
*
- * <p>Typically used to allow filtering on
- * {@link Dataset.Builder#setAuthentication(IntentSender) authenticated datasets}. For
- * example, if the dataset represents a credit card number and the service does not want to
- * show the "Tap to authenticate" message until the user tapped 4 digits, in which case
- * the filter would be {@code Pattern.compile("\\d.{4,}")}.
+ * <p>This method is typically used when the dataset is authenticated and the service
+ * does not know its value but wants to hide the dataset after the user enters a minimum
+ * number of characters. For example, if the dataset represents a credit card number and the
+ * service does not want to show the "Tap to authenticate" message until the user tapped
+ * 4 digits, in which case the filter would be {@code Pattern.compile("\\d.{4,}")}.
*
* @param id id returned by {@link
* android.app.assist.AssistStructure.ViewNode#getAutofillId()}.
diff --git a/core/java/android/service/autofill/FillResponse.java b/core/java/android/service/autofill/FillResponse.java
index 4e6a884..a648307 100644
--- a/core/java/android/service/autofill/FillResponse.java
+++ b/core/java/android/service/autofill/FillResponse.java
@@ -180,8 +180,12 @@
private boolean mDestroyed;
/**
- * Requires a fill response authentication before autofilling the screen with
- * any data set in this response.
+ * Triggers a custom UI before before autofilling the screen with any data set in this
+ * response.
+ *
+ * <p><b>Note:</b> Although the name of this method suggests that it should be used just for
+ * authentication flow, it can be used for other advanced flows; see {@link AutofillService}
+ * for examples.
*
* <p>This is typically useful when a user interaction is required to unlock their
* data vault if you encrypt the data set labels and data set data. It is recommended
diff --git a/core/java/android/service/autofill/SaveInfo.java b/core/java/android/service/autofill/SaveInfo.java
index bc4b3fc..0b50f07 100644
--- a/core/java/android/service/autofill/SaveInfo.java
+++ b/core/java/android/service/autofill/SaveInfo.java
@@ -599,9 +599,9 @@
* credit card number:
*
* <pre class="prettyprint">
- * builder.addSanitizer(
- * new TextValueSanitizer(Pattern.compile("^(\\d{4}\s?\\d{4}\s?\\d{4}\s?\\d{4})$"),
- * "$1$2$3$4"), ccNumberId);
+ * builder.addSanitizer(new TextValueSanitizer(
+ * Pattern.compile("^(\\d{4})\\s?(\\d{4})\\s?(\\d{4})\\s?(\\d{4})$", "$1$2$3$4")),
+ * ccNumberId);
* </pre>
*
* <p>The same sanitizer can be reused to sanitize multiple fields. For example, to trim
@@ -614,9 +614,9 @@
* </pre>
*
* <p>The sanitizer can also be used as an alternative for a
- * {@link #setValidator(Validator) validator}&mdashif any of the {@code ids} is a
- * {@link #SaveInfo.Builder(int, AutofillId[]) required id} and the {@code sanitizer} fail
- * for it, then the save UI is not shown.
+ * {@link #setValidator(Validator) validator}. If any of the {@code ids} is a
+ * {@link #SaveInfo.Builder(int, AutofillId[]) required id} and the {@code sanitizer} fails
+ * because of it, then the save UI is not shown.
*
* @param sanitizer an implementation provided by the Android System.
* @param ids id of fields whose value will be sanitized.
diff --git a/core/java/android/service/autofill/TextValueSanitizer.java b/core/java/android/service/autofill/TextValueSanitizer.java
index a3a98d8..e5ad77a 100644
--- a/core/java/android/service/autofill/TextValueSanitizer.java
+++ b/core/java/android/service/autofill/TextValueSanitizer.java
@@ -37,7 +37,8 @@
* <p>For example, to remove spaces from groups of 4-digits in a credit card:
*
* <pre class="prettyprint">
- * new TextValueSanitizer(Pattern.compile("^(\\d{4}\s?\\d{4}\s?\\d{4}\s?\\d{4})$"), "$1$2$3$4")
+ * new TextValueSanitizer(Pattern.compile("^(\\d{4})\\s?(\\d{4})\\s?(\\d{4})\\s?(\\d{4})$",
+ * "$1$2$3$4")
* </pre>
*/
public final class TextValueSanitizer extends InternalSanitizer implements
diff --git a/core/java/android/view/autofill/AutofillManager.java b/core/java/android/view/autofill/AutofillManager.java
index 9241ec0..547e0db 100644
--- a/core/java/android/view/autofill/AutofillManager.java
+++ b/core/java/android/view/autofill/AutofillManager.java
@@ -908,6 +908,7 @@
}
synchronized (mLock) {
if (mSaveOnFinish) {
+ if (sDebug) Log.d(TAG, "Committing session on finish() as requested by service");
commitLocked();
} else {
if (sDebug) Log.d(TAG, "Cancelling session on finish() as requested by service");
@@ -955,6 +956,7 @@
* methods such as {@link android.app.Activity#finish()}.
*/
public void cancel() {
+ if (sVerbose) Log.v(TAG, "cancel() called by app");
if (!hasAutofillFeature()) {
return;
}