diff options
| author | Felipe Leme <felipeal@google.com> | 2017-02-22 17:26:06 -0800 |
|---|---|---|
| committer | Felipe Leme <felipeal@google.com> | 2017-02-22 19:15:38 -0800 |
| commit | c01a873c4f68518be4698077c7eb593a6a3b9f4c (patch) | |
| tree | 266463b69872a7efde15ba082dce977aaf5979fe /core/java/android/widget/CompoundButton.java | |
| parent | d09ccb8db6c541f2d349b923bf9b38f1081aaa8d (diff) | |
Added sanitization for CompoundButton and RadioGroup.
Bug: 33269702
Bug: 33550221
Test: CtsAutoFillServiceTestCases (with new tests) pass
Change-Id: Ie2c8d2784227371588aa02973b8ef3ac1a6950aa
Diffstat (limited to 'core/java/android/widget/CompoundButton.java')
| -rw-r--r-- | core/java/android/widget/CompoundButton.java | 14 |
1 files changed, 14 insertions, 0 deletions
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; |
