Simplified autofill() methods by returning void instead of boolean.
Test: CtsAutoFillServiceTestCases pass
Change-Id: Ic94e6686e291fed60ef6715bd160f9b568bf0ea6
diff --git a/api/current.txt b/api/current.txt
index 6234168..42167fa 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -45159,8 +45159,8 @@
method public void addTouchables(java.util.ArrayList<android.view.View>);
method public android.view.ViewPropertyAnimator animate();
method public void announceForAccessibility(java.lang.CharSequence);
- method public boolean autofill(android.view.autofill.AutofillValue);
- method public boolean autofill(android.util.SparseArray<android.view.autofill.AutofillValue>);
+ method public void autofill(android.view.autofill.AutofillValue);
+ method public void autofill(android.util.SparseArray<android.view.autofill.AutofillValue>);
method protected boolean awakenScrollBars();
method protected boolean awakenScrollBars(int);
method protected boolean awakenScrollBars(int, boolean);
diff --git a/api/system-current.txt b/api/system-current.txt
index 6a6b279..66484ab 100644
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -48614,8 +48614,8 @@
method public void addTouchables(java.util.ArrayList<android.view.View>);
method public android.view.ViewPropertyAnimator animate();
method public void announceForAccessibility(java.lang.CharSequence);
- method public boolean autofill(android.view.autofill.AutofillValue);
- method public boolean autofill(android.util.SparseArray<android.view.autofill.AutofillValue>);
+ method public void autofill(android.view.autofill.AutofillValue);
+ method public void autofill(android.util.SparseArray<android.view.autofill.AutofillValue>);
method protected boolean awakenScrollBars();
method protected boolean awakenScrollBars(int);
method protected boolean awakenScrollBars(int, boolean);
diff --git a/api/test-current.txt b/api/test-current.txt
index 1f342e6..5036103 100644
--- a/api/test-current.txt
+++ b/api/test-current.txt
@@ -45533,8 +45533,8 @@
method public void addTouchables(java.util.ArrayList<android.view.View>);
method public android.view.ViewPropertyAnimator animate();
method public void announceForAccessibility(java.lang.CharSequence);
- method public boolean autofill(android.view.autofill.AutofillValue);
- method public boolean autofill(android.util.SparseArray<android.view.autofill.AutofillValue>);
+ method public void autofill(android.view.autofill.AutofillValue);
+ method public void autofill(android.util.SparseArray<android.view.autofill.AutofillValue>);
method protected boolean awakenScrollBars();
method protected boolean awakenScrollBars(int);
method protected boolean awakenScrollBars(int, boolean);
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index e924f77..23fcb55 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -7447,11 +7447,8 @@
* </pre>
*
* @param value value to be autofilled.
- *
- * @return {@code true} if the view was successfully autofilled, {@code false} otherwise
*/
- public boolean autofill(@SuppressWarnings("unused") AutofillValue value) {
- return false;
+ public void autofill(@SuppressWarnings("unused") AutofillValue value) {
}
/**
@@ -7461,12 +7458,8 @@
* {@link #onProvideAutofillVirtualStructure(ViewStructure, int)} for more info.
*
* @param values map of values to be autofilled, keyed by virtual child id.
- *
- * @return {@code true} if the view was successfully autofilled, {@code false} otherwise
*/
- public boolean autofill(
- @NonNull @SuppressWarnings("unused") SparseArray<AutofillValue>values) {
- return false;
+ public void autofill(@NonNull @SuppressWarnings("unused") SparseArray<AutofillValue> values) {
}
/**
diff --git a/core/java/android/view/autofill/AutofillManager.java b/core/java/android/view/autofill/AutofillManager.java
index b4d2c6b..37ca5b3 100644
--- a/core/java/android/view/autofill/AutofillManager.java
+++ b/core/java/android/view/autofill/AutofillManager.java
@@ -554,9 +554,8 @@
}
valuesByParent.put(id.getVirtualChildId(), value);
} else {
- if (view.autofill(value)) {
- numApplied++;
- }
+ view.autofill(value);
+ numApplied++;
}
}
@@ -564,9 +563,8 @@
for (int i = 0; i < virtualValues.size(); i++) {
final View parent = virtualValues.keyAt(i);
final SparseArray<AutofillValue> childrenValues = virtualValues.valueAt(i);
- if (parent.autofill(childrenValues)) {
- numApplied += childrenValues.size();
- }
+ parent.autofill(childrenValues);
+ numApplied += childrenValues.size();
}
}
diff --git a/core/java/android/widget/AbsSpinner.java b/core/java/android/widget/AbsSpinner.java
index 8f662ba..352e7de 100644
--- a/core/java/android/widget/AbsSpinner.java
+++ b/core/java/android/widget/AbsSpinner.java
@@ -526,15 +526,15 @@
}
@Override
- public boolean autofill(AutofillValue value) {
- if (!isEnabled()) return false;
+ public void autofill(AutofillValue value) {
+ if (!isEnabled()) return;
- if (value.isList()) {
- setSelection(value.getListValue());
- } else {
+ if (!value.isList()) {
Log.w(LOG_TAG, value + " could not be autofilled into " + this);
+ return;
}
- return true;
+
+ setSelection(value.getListValue());
}
@Override
diff --git a/core/java/android/widget/CompoundButton.java b/core/java/android/widget/CompoundButton.java
index 9dc61ab..c7ba7b5 100644
--- a/core/java/android/widget/CompoundButton.java
+++ b/core/java/android/widget/CompoundButton.java
@@ -584,16 +584,15 @@
}
@Override
- public boolean autofill(AutofillValue value) {
- if (!isEnabled()) return false;
+ public void autofill(AutofillValue value) {
+ if (!isEnabled()) return;
- if (value.isToggle()) {
- setChecked(value.getToggleValue());
- } else {
+ if (!value.isToggle()) {
Log.w(LOG_TAG, value + " could not be autofilled into " + this);
+ return;
}
- return true;
+ setChecked(value.getToggleValue());
}
@Override
diff --git a/core/java/android/widget/DatePicker.java b/core/java/android/widget/DatePicker.java
index 7d04f35..463ff58 100644
--- a/core/java/android/widget/DatePicker.java
+++ b/core/java/android/widget/DatePicker.java
@@ -775,16 +775,15 @@
}
@Override
- public boolean autofill(AutofillValue value) {
- if (!isEnabled()) return false;
+ public void autofill(AutofillValue value) {
+ if (!isEnabled()) return;
- if (value.isDate()) {
- mDelegate.updateDate(value.getDateValue());
- } else {
+ if (!value.isDate()) {
Log.w(LOG_TAG, value + " could not be autofilled into " + this);
+ return;
}
- return true;
+ mDelegate.updateDate(value.getDateValue());
}
@Override
diff --git a/core/java/android/widget/RadioGroup.java b/core/java/android/widget/RadioGroup.java
index a7574c7..08e6575 100644
--- a/core/java/android/widget/RadioGroup.java
+++ b/core/java/android/widget/RadioGroup.java
@@ -426,24 +426,22 @@
}
@Override
- public boolean autofill(AutofillValue value) {
- if (!isEnabled()) return false;
+ public void autofill(AutofillValue value) {
+ if (!isEnabled()) return;
- int index;
- if (value.isList()) {
- index = value.getListValue();
- } else {
+ if (!value.isList()) {
Log.w(LOG_TAG, value + " could not be autofilled into " + this);
- return false;
+ return;
}
+ final int index = value.getListValue();
final View child = getChildAt(index);
if (child == null) {
Log.w(VIEW_LOG_TAG, "RadioGroup.autoFill(): no child with index " + index);
- return false;
+ return;
}
+
check(child.getId());
- return true;
}
@Override
diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java
index bc7c79d..02afee3 100644
--- a/core/java/android/widget/TextView.java
+++ b/core/java/android/widget/TextView.java
@@ -10050,17 +10050,13 @@
}
@Override
- public boolean autofill(AutofillValue value) {
- if (value.isText()) {
- if (isTextEditable()) {
- setText(value.getTextValue(), mBufferType, true, 0);
- return true;
- }
- } else {
+ public void autofill(AutofillValue value) {
+ if (!value.isText() || !isTextEditable()) {
Log.w(LOG_TAG, value + " could not be autofilled into " + this);
+ return;
}
- return false;
+ setText(value.getTextValue(), mBufferType, true, 0);
}
@Override
diff --git a/core/java/android/widget/TimePicker.java b/core/java/android/widget/TimePicker.java
index 1e97e3b..0289dad 100644
--- a/core/java/android/widget/TimePicker.java
+++ b/core/java/android/widget/TimePicker.java
@@ -530,16 +530,14 @@
}
@Override
- public boolean autofill(AutofillValue value) {
- if (!isEnabled()) return false;
+ public void autofill(AutofillValue value) {
+ if (!isEnabled()) return;
- if (value.isDate()) {
- mDelegate.setDate(value.getDateValue());
- } else {
+ if (!value.isDate()) {
Log.w(LOG_TAG, value + " could not be autofilled into " + this);
}
- return true;
+ mDelegate.setDate(value.getDateValue());
}
@Override