diff options
| -rw-r--r-- | core/java/android/app/assist/AssistStructure.java | 9 | ||||
| -rw-r--r-- | core/java/android/widget/CompoundButton.java | 14 | ||||
| -rw-r--r-- | core/java/android/widget/RadioGroup.java | 13 | ||||
| -rw-r--r-- | core/java/android/widget/TextView.java | 2 |
4 files changed, 35 insertions, 3 deletions
diff --git a/core/java/android/app/assist/AssistStructure.java b/core/java/android/app/assist/AssistStructure.java index 716bbe9458c0..483a7a121a9e 100644 --- a/core/java/android/app/assist/AssistStructure.java +++ b/core/java/android/app/assist/AssistStructure.java @@ -722,7 +722,14 @@ public class AssistStructure implements Parcelable { } pwriter.writeString(mClassName); - out.writeInt(flags); + + int writtenFlags = flags; + if ((flags&FLAGS_HAS_AUTO_FILL_DATA) != 0 && (mSanitized || !sanitizeOnWrite)) { + // Remove 'checked' from sanitized auto-fill request. + writtenFlags = flags & ~FLAGS_CHECKED; + } + + out.writeInt(writtenFlags); if ((flags&FLAGS_HAS_ID) != 0) { out.writeInt(mId); if (mId != 0) { diff --git a/core/java/android/widget/CompoundButton.java b/core/java/android/widget/CompoundButton.java index f2c2af511f81..887c59a2d71c 100644 --- a/core/java/android/widget/CompoundButton.java +++ b/core/java/android/widget/CompoundButton.java @@ -32,6 +32,7 @@ import android.view.Gravity; import android.view.SoundEffectConstants; import android.view.ViewDebug; import android.view.ViewHierarchyEncoder; +import android.view.ViewStructure; import android.view.accessibility.AccessibilityEvent; import android.view.accessibility.AccessibilityNodeInfo; import android.view.autofill.AutoFillManager; @@ -68,6 +69,10 @@ public abstract class CompoundButton extends Button implements Checkable { private OnCheckedChangeListener mOnCheckedChangeListener; private OnCheckedChangeListener mOnCheckedChangeWidgetListener; + // Indicates whether the toggle state was set from resources or dynamically, so it can be used + // to sanitize auto-fill requests. + private boolean mCheckedFromResource = false; + private static final int[] CHECKED_STATE_SET = { R.attr.state_checked }; @@ -109,6 +114,7 @@ public abstract class CompoundButton extends Button implements Checkable { final boolean checked = a.getBoolean( com.android.internal.R.styleable.CompoundButton_checked, false); setChecked(checked); + mCheckedFromResource = true; a.recycle(); @@ -148,6 +154,7 @@ public abstract class CompoundButton extends Button implements Checkable { @Override public void setChecked(boolean checked) { if (mChecked != checked) { + mCheckedFromResource = false; mChecked = checked; refreshDrawableState(); notifyViewAccessibilityStateChangedIfNeeded( @@ -569,6 +576,13 @@ public abstract class CompoundButton extends Button implements Checkable { // TODO(b/33197203): add unit/CTS tests for auto-fill methods (and make sure they handle enable) @Override + public void onProvideAutoFillStructure(ViewStructure structure, int flags) { + super.onProvideAutoFillStructure(structure, flags); + + structure.setSanitized(mCheckedFromResource); + } + + @Override public void autoFill(AutoFillValue value) { if (!isEnabled()) return; diff --git a/core/java/android/widget/RadioGroup.java b/core/java/android/widget/RadioGroup.java index 49253eb609cf..bba3a11042e0 100644 --- a/core/java/android/widget/RadioGroup.java +++ b/core/java/android/widget/RadioGroup.java @@ -24,6 +24,7 @@ import android.util.AttributeSet; import android.util.Log; import android.view.View; import android.view.ViewGroup; +import android.view.ViewStructure; import android.view.autofill.AutoFillManager; import android.view.autofill.AutoFillType; import android.view.autofill.AutoFillValue; @@ -66,6 +67,10 @@ public class RadioGroup extends LinearLayout { private OnCheckedChangeListener mOnCheckedChangeListener; private PassThroughHierarchyChangeListener mPassThroughListener; + // Indicates whether the child was set from resources or dynamically, so it can be used + // to sanitize auto-fill requests. + private int mInitialCheckedId = View.NO_ID; + /** * {@inheritDoc} */ @@ -89,8 +94,8 @@ public class RadioGroup extends LinearLayout { int value = attributes.getResourceId(R.styleable.RadioGroup_checkedButton, View.NO_ID); if (value != View.NO_ID) { mCheckedId = value; + mInitialCheckedId = value; } - final int index = attributes.getInt(com.android.internal.R.styleable.RadioGroup_orientation, VERTICAL); setOrientation(index); @@ -411,6 +416,12 @@ public class RadioGroup extends LinearLayout { // TODO(b/33197203): add unit/CTS tests for auto-fill methods (and make sure they handle enable) @Override + public void onProvideAutoFillStructure(ViewStructure structure, int flags) { + super.onProvideAutoFillStructure(structure, flags); + structure.setSanitized(mCheckedId == mInitialCheckedId); + } + + @Override public void autoFill(AutoFillValue value) { if (!isEnabled()) return; diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java index bf8de38a572c..5e6e0f921e92 100644 --- a/core/java/android/widget/TextView.java +++ b/core/java/android/widget/TextView.java @@ -727,7 +727,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener private boolean mHasPresetAutoSizeValues = false; // Indicates whether the text was set from resources or dynamically, so it can be used to - // sanitize auto-fill request. + // sanitize auto-fill requests. private boolean mTextFromResource = false; /** |