Renamed ViewStructure.setSanitized() to setDataIsSensitive().
Bug: 36126001
Test: CtsAutoFillServiceTestCases pass
Test: m update-api
Change-Id: I182355b63d8743cd8cd8612f29a9269e258283c2
diff --git a/core/java/android/app/assist/AssistStructure.java b/core/java/android/app/assist/AssistStructure.java
index 1f2ed00..bb37aad 100644
--- a/core/java/android/app/assist/AssistStructure.java
+++ b/core/java/android/app/assist/AssistStructure.java
@@ -1683,8 +1683,8 @@
}
@Override
- public void setSanitized(boolean sanitized) {
- mNode.mSanitized = sanitized;
+ public void setDataIsSensitive(boolean sensitive) {
+ mNode.mSanitized = !sensitive;
}
@Override
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index aa1cbf2..e9fb96d 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -7250,9 +7250,10 @@
* Called when assist structure is being retrieved from a view as part of an autofill request.
*
* <p>This method already provides most of what's needed for autofill, but should be overridden
+ * when:
* <ol>
* <li>The view contents does not include PII (Personally Identifiable Information), so it
- * can call {@link ViewStructure#setSanitized(boolean)} passing {@code true}.
+ * can call {@link ViewStructure#setDataIsSensitive(boolean)} passing {@code false}.
* <li>It must set fields such {@link ViewStructure#setText(CharSequence)},
* {@link ViewStructure#setAutofillOptions(String[])}, or {@link ViewStructure#setUrl(String)}.
* </ol>
diff --git a/core/java/android/view/ViewStructure.java b/core/java/android/view/ViewStructure.java
index bccaca2..7762e92 100644
--- a/core/java/android/view/ViewStructure.java
+++ b/core/java/android/view/ViewStructure.java
@@ -346,19 +346,27 @@
public abstract void setInputType(int inputType);
/**
- * Marks this node as sanitized so its content are sent on {@link
+ * Sets whether the data on this node is sensitive; if it is, then its content (text, autofill
+ * value, etc..) is striped before calls to {@link
* android.service.autofill.AutofillService#onFillRequest(android.app.assist.AssistStructure,
* Bundle, android.os.CancellationSignal, android.service.autofill.FillCallback)}.
*
- * <p>Only nodes that does not have PII (Personally Identifiable Information - sensitive data
- * such as email addresses, credit card numbers, passwords, etc...) should be marked
- * as sanitized; a good rule of thumb is to mark as sanitized nodes whose value were statically
- * set from resources.
+ * <p>By default, all nodes are assumed to be sensitive, and only nodes that does not have PII
+ * (Personally Identifiable Information - sensitive data such as email addresses, credit card
+ * numbers, passwords, etc...) should be marked as non-sensitive; a good rule of thumb is to
+ * mark as non-sensitive nodes whose value were statically set from resources.
+ *
+ * <p>Notice that the content of even sensitive nodes are sent to the service (through the
+ * {@link
+ * android.service.autofill.AutofillService#onSaveRequest(android.app.assist.AssistStructure,
+ * Bundle, android.service.autofill.SaveCallback)} call) when the user consented to save the
+ * data, so it is important to set the content of sensitive nodes as well, but mark them as
+ * sensitive.
*
* <p>Should only be set when the node is used for autofill purposes - it will be ignored
* when used for Assist.
*/
- public abstract void setSanitized(boolean sanitized);
+ public abstract void setDataIsSensitive(boolean sensitive);
/**
* Call when done populating a {@link ViewStructure} returned by
diff --git a/core/java/android/widget/CompoundButton.java b/core/java/android/widget/CompoundButton.java
index 81aec9c..6a95fe3 100644
--- a/core/java/android/widget/CompoundButton.java
+++ b/core/java/android/widget/CompoundButton.java
@@ -578,7 +578,7 @@
public void onProvideAutofillStructure(ViewStructure structure, int flags) {
super.onProvideAutofillStructure(structure, flags);
- structure.setSanitized(mCheckedFromResource);
+ structure.setDataIsSensitive(!mCheckedFromResource);
}
@Override
diff --git a/core/java/android/widget/RadioGroup.java b/core/java/android/widget/RadioGroup.java
index bd62d6c..8dcb419 100644
--- a/core/java/android/widget/RadioGroup.java
+++ b/core/java/android/widget/RadioGroup.java
@@ -421,7 +421,7 @@
@Override
public void onProvideAutofillStructure(ViewStructure structure, int flags) {
super.onProvideAutofillStructure(structure, flags);
- structure.setSanitized(mCheckedId == mInitialCheckedId);
+ structure.setDataIsSensitive(mCheckedId != mInitialCheckedId);
}
@Override
diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java
index ee70acc..20084f5 100644
--- a/core/java/android/widget/TextView.java
+++ b/core/java/android/widget/TextView.java
@@ -9900,7 +9900,7 @@
final boolean isPassword = hasPasswordTransformationMethod()
|| isPasswordInputType(getInputType());
if (forAutofill) {
- structure.setSanitized(mTextFromResource);
+ structure.setDataIsSensitive(!mTextFromResource);
}
if (!isPassword || forAutofill) {