Make it clear which type of AutoFillValue is set
throw and handle errors if the wrong value is set for a view
Test: android.autofillservice.cts.AutofillValueTest
Change-Id: Ida80da7913a210bede6c47d6b7a6f215a012a84c
diff --git a/core/java/android/widget/CompoundButton.java b/core/java/android/widget/CompoundButton.java
index d246405..ae58e2a 100644
--- a/core/java/android/widget/CompoundButton.java
+++ b/core/java/android/widget/CompoundButton.java
@@ -28,6 +28,7 @@
import android.os.Parcel;
import android.os.Parcelable;
import android.util.AttributeSet;
+import android.util.Log;
import android.view.Gravity;
import android.view.SoundEffectConstants;
import android.view.ViewDebug;
@@ -55,6 +56,7 @@
* </p>
*/
public abstract class CompoundButton extends Button implements Checkable {
+ private static final String LOG_TAG = CompoundButton.class.getSimpleName();
private boolean mChecked;
private boolean mBroadcasting;
@@ -585,7 +587,11 @@
public void autofill(AutofillValue value) {
if (!isEnabled()) return;
- setChecked(value.getToggleValue());
+ if (value.isToggle()) {
+ setChecked(value.getToggleValue());
+ } else {
+ Log.w(LOG_TAG, value + " could not be autofilled into " + this);
+ }
}
@Override