Minor fixes on Autofill Framework:
- Removed default implementation of onProvideAutofillVirtualStructure() that
was using accessibility API (it's useless because without the View calling
AutofillManager.notifyViewEntered(), it would never be triggered).
- Fixed obsolete TODOs.
- Removed obsolete service class name constant.
- Removed unused debug constant.
Fixes: 37078783
Fixes: 33197203
Bug: 33802548
Bug: 35956626
Test: CtsAutoFillServiceTestCases pass
Merged-In: I834d34b8af8bf0d781dc7e0ffcd6e600bfa2d183
Change-Id: I834d34b8af8bf0d781dc7e0ffcd6e600bfa2d183
diff --git a/core/java/android/app/Activity.java b/core/java/android/app/Activity.java
index e4d2d13..2843dc2 100644
--- a/core/java/android/app/Activity.java
+++ b/core/java/android/app/Activity.java
@@ -696,9 +696,6 @@
private static final String TAG = "Activity";
private static final boolean DEBUG_LIFECYCLE = false;
- // TODO(b/33197203): set to false once stable
- private static final boolean DEBUG_AUTO_FILL = true;
-
/** Standard activity result: operation canceled. */
public static final int RESULT_CANCELED = 0;
/** Standard activity result: operation succeeded. */
diff --git a/core/java/android/app/ActivityThread.java b/core/java/android/app/ActivityThread.java
index 5022d7d..46ce94f 100644
--- a/core/java/android/app/ActivityThread.java
+++ b/core/java/android/app/ActivityThread.java
@@ -3004,7 +3004,7 @@
// - it needs an IAutoFillCallback
boolean forAutofill = cmd.requestType == ActivityManager.ASSIST_CONTEXT_AUTOFILL;
- // TODO(b/33197203): decide if lastSessionId logic applies to autofill sessions
+ // TODO: decide if lastSessionId logic applies to autofill sessions
if (mLastSessionId != cmd.sessionId) {
// Clear the existing structures
mLastSessionId = cmd.sessionId;
@@ -3032,8 +3032,6 @@
if (cmd.requestType == ActivityManager.ASSIST_CONTEXT_FULL || forAutofill) {
structure = new AssistStructure(r.activity, forAutofill);
Intent activityIntent = r.activity.getIntent();
- // TODO(b/33197203): re-evaluate conditions below for autofill. In particular,
- // FLAG_SECURE might be allowed on AUTO_FILL but not on AUTO_FILL_SAVE)
boolean notSecure = r.window == null ||
(r.window.getAttributes().flags
& WindowManager.LayoutParams.FLAG_SECURE) == 0;
@@ -3059,7 +3057,7 @@
structure = new AssistStructure();
}
- // TODO(b/33197203): decide if lastSessionId logic applies to autofill sessions
+ // TODO: decide if lastSessionId logic applies to autofill sessions
structure.setAcquisitionStartTime(startTime);
structure.setAcquisitionEndTime(SystemClock.uptimeMillis());
diff --git a/core/java/android/app/assist/AssistStructure.java b/core/java/android/app/assist/AssistStructure.java
index 7c1bcf0..d757f3e 100644
--- a/core/java/android/app/assist/AssistStructure.java
+++ b/core/java/android/app/assist/AssistStructure.java
@@ -600,7 +600,7 @@
String mIdType;
String mIdEntry;
- // TODO(b/33197203): once we have more flags, it might be better to store the individual
+ // TODO: once we have more flags, it might be better to store the individual
// fields (viewId and childId) of the field.
AutofillId mAutofillId;
@View.AutofillType int mAutofillType = View.AUTOFILL_TYPE_NONE;
@@ -639,7 +639,7 @@
static final int FLAGS_CONTEXT_CLICKABLE = 0x00004000;
static final int FLAGS_OPAQUE = 0x00008000;
- // TODO(b/33197203): autofill data is made of many fields and ideally we should verify
+ // TODO: autofill data is made of many fields and ideally we should verify
// one-by-one to optimize what's sent over, but there isn't enough flag bits for that, we'd
// need to create a 'flags2' or 'autoFillFlags' field and add these flags there.
// So, to keep thinkg simpler for now, let's just use on flag for all of them...
@@ -1043,8 +1043,6 @@
*/
public void updateAutofillValue(AutofillValue value) {
mAutofillValue = value;
- // TODO(b/33197203, b/33802548): decide whether to set text as well (so it would work
- // with "legacy" views) or just the autofill value
if (value.isText()) {
mText.mText = value.getTextValue();
}
diff --git a/core/java/android/service/autofill/AutofillService.java b/core/java/android/service/autofill/AutofillService.java
index 813c54f..5036178 100644
--- a/core/java/android/service/autofill/AutofillService.java
+++ b/core/java/android/service/autofill/AutofillService.java
@@ -36,9 +36,6 @@
import java.util.List;
-//TODO(b/33197203): improve javadoc (of both class and methods); in particular, make sure the
-//life-cycle (and how state could be maintained on server-side) is well documented.
-
/**
* Top-level service of the current autofill service for a given user.
*
@@ -50,19 +47,6 @@
/**
* The {@link Intent} that must be declared as handled by the service.
* To be supported, the service must also require the
- * {@link android.Manifest.permission#BIND_AUTO_FILL} permission so
- * that other applications can not abuse it.
- *
- * @hide
- * @deprecated TODO(b/35956626): remove once clients use AutofillService
- */
- @Deprecated
- @SdkConstant(SdkConstant.SdkConstantType.SERVICE_ACTION)
- public static final String OLD_SERVICE_INTERFACE = "android.service.autofill.AutoFillService";
-
- /**
- * The {@link Intent} that must be declared as handled by the service.
- * To be supported, the service must also require the
* {@link android.Manifest.permission#BIND_AUTOFILL} permission so
* that other applications can not abuse it.
*/
@@ -92,8 +76,6 @@
private static final int MSG_ON_FILL_REQUEST = 3;
private static final int MSG_ON_SAVE_REQUEST = 4;
- private static final int UNUSED_ARG = -1;
-
private final IAutoFillService mInterface = new IAutoFillService.Stub() {
@Override
public void onConnectedStateChanged(boolean connected) {
@@ -170,8 +152,7 @@
@Override
public final IBinder onBind(Intent intent) {
- if (SERVICE_INTERFACE.equals(intent.getAction())
- || OLD_SERVICE_INTERFACE.equals(intent.getAction())) {
+ if (SERVICE_INTERFACE.equals(intent.getAction())) {
return mInterface.asBinder();
}
Log.w(TAG, "Tried to bind to wrong intent: " + intent);
@@ -282,7 +263,6 @@
@Deprecated
public final void disableSelf() {
- // TODO(b/33197203): Remove when GCore has migrated off this API
getSystemService(AutofillManager.class).disableOwnedAutofillServices();
}
diff --git a/core/java/android/service/autofill/FillResponse.java b/core/java/android/service/autofill/FillResponse.java
index 68ce0b5..0e74ca4 100644
--- a/core/java/android/service/autofill/FillResponse.java
+++ b/core/java/android/service/autofill/FillResponse.java
@@ -242,7 +242,7 @@
public @NonNull Builder setAuthentication(@NonNull AutofillId[] ids,
@Nullable IntentSender authentication, @Nullable RemoteViews presentation) {
throwIfDestroyed();
- // TODO(b/33197203): assert ids is not null nor empty once old version is removed
+ // TODO(b/37424539): assert ids is not null nor empty once old version is removed
if (authentication == null ^ presentation == null) {
throw new IllegalArgumentException("authentication and presentation"
+ " must be both non-null or null");
@@ -254,7 +254,7 @@
}
/**
- * TODO(b/33197203): will be removed once clients use the version that takes ids
+ * TODO(b/37424539): will be removed once clients use the version that takes ids
* @hide
* @deprecated
*/
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index bcf0b90..d42c6db 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -7381,17 +7381,20 @@
* optimal implementation providing this data.
*/
public void onProvideVirtualStructure(ViewStructure structure) {
- onProvideVirtualStructureForAssistOrAutofill(structure, false);
+ AccessibilityNodeProvider provider = getAccessibilityNodeProvider();
+ if (provider != null) {
+ AccessibilityNodeInfo info = createAccessibilityNodeInfo();
+ structure.setChildCount(1);
+ ViewStructure root = structure.newChild(0);
+ populateVirtualStructure(root, provider, info);
+ info.recycle();
+ }
}
/**
* Called when assist structure is being retrieved from a view as part of an autofill request
* to generate additional virtual structure under this view.
*
- * <p>The default implementation uses {@link #getAccessibilityNodeProvider()} to try to
- * generate this from the view's virtual accessibility nodes, if any. You can override this
- * for a more optimal implementation providing this data.
- *
* <p>When implementing this method, subclasses must follow the rules below:
*
* <ol>
@@ -7415,27 +7418,10 @@
* @param flags optional flags (currently {@code 0}).
*/
public void onProvideAutofillVirtualStructure(ViewStructure structure, int flags) {
- onProvideVirtualStructureForAssistOrAutofill(structure, true);
- }
-
- private void onProvideVirtualStructureForAssistOrAutofill(ViewStructure structure,
- boolean forAutofill) {
- if (forAutofill) {
- setAutofillId(structure);
- }
- // NOTE: currently flags are only used for AutoFill; if they're used for Assist as well,
- // this method should take a boolean with the type of request.
- AccessibilityNodeProvider provider = getAccessibilityNodeProvider();
- if (provider != null) {
- AccessibilityNodeInfo info = createAccessibilityNodeInfo();
- structure.setChildCount(1);
- ViewStructure root = structure.newChild(0);
- if (forAutofill) {
- setAutofillId(root);
- }
- populateVirtualStructure(root, provider, info, forAutofill);
- info.recycle();
- }
+ // TODO(b/36171235): need a way to let apps set the ViewStructure without forcing them
+ // to call super() (in case they override both this method and dispatchProvide....
+ // Perhaps the best solution would simply make setAutofillId(ViewStructure) public.
+ setAutofillId(structure);
}
/**
@@ -7652,7 +7638,7 @@
}
private void populateVirtualStructure(ViewStructure structure,
- AccessibilityNodeProvider provider, AccessibilityNodeInfo info, boolean forAutofill) {
+ AccessibilityNodeProvider provider, AccessibilityNodeInfo info) {
structure.setId(AccessibilityNodeInfo.getVirtualDescendantId(info.getSourceNodeId()),
null, null, null);
Rect rect = structure.getTempRect();
@@ -7690,10 +7676,7 @@
CharSequence cname = info.getClassName();
structure.setClassName(cname != null ? cname.toString() : null);
structure.setContentDescription(info.getContentDescription());
- if (!forAutofill && (info.getText() != null || info.getError() != null)) {
- // TODO(b/33197203) (b/33269702): when sanitized, try to use the Accessibility API to
- // just set sanitized values (like text coming from resource files), rather than not
- // setting it at all.
+ if ((info.getText() != null || info.getError() != null)) {
structure.setText(info.getText(), info.getTextSelectionStart(),
info.getTextSelectionEnd());
}
@@ -7704,12 +7687,7 @@
AccessibilityNodeInfo cinfo = provider.createAccessibilityNodeInfo(
AccessibilityNodeInfo.getVirtualDescendantId(info.getChildId(i)));
ViewStructure child = structure.newChild(i);
- if (forAutofill) {
- // TODO(b/33197203): add CTS test to autofill virtual children based on
- // Accessibility API.
- child.setAutofillId(structure, i);
- }
- populateVirtualStructure(child, provider, cinfo, forAutofill);
+ populateVirtualStructure(child, provider, cinfo);
cinfo.recycle();
}
}
@@ -9598,13 +9576,10 @@
*
* @return Returns {@code false} if assist data collection for autofill is not blocked,
* else {@code true}.
- *
- * TODO(b/33197203): update / remove javadoc tags below
- * @see #setAssistBlocked(boolean)
- * @attr ref android.R.styleable#View_assistBlocked
*/
public boolean isAutofillBlocked() {
- return false; // TODO(b/33197203): properly implement it
+ // TODO(b/36171235): properly implement it using isImportantForAutofill()
+ return false;
}
/**
diff --git a/core/java/android/view/autofill/AutofillId.java b/core/java/android/view/autofill/AutofillId.java
index d678015..268f7f3 100644
--- a/core/java/android/view/autofill/AutofillId.java
+++ b/core/java/android/view/autofill/AutofillId.java
@@ -30,7 +30,6 @@
private final boolean mVirtual;
private final int mVirtualId;
- // TODO(b/33197203): use factory and cache values, since they're immutable
/** @hide */
public AutofillId(int id) {
mVirtual = false;
diff --git a/core/java/android/view/autofill/AutofillManager.java b/core/java/android/view/autofill/AutofillManager.java
index 981be21..b9d42f6 100644
--- a/core/java/android/view/autofill/AutofillManager.java
+++ b/core/java/android/view/autofill/AutofillManager.java
@@ -51,12 +51,10 @@
import java.util.Objects;
/**
- * App entry point to the AutoFill Framework.
+ * App entry point to the Autofill Framework.
*
* <p>It is safe to call into this from any thread.
*/
-// TODO(b/33197203): improve this javadoc
-//TODO(b/33197203): restrict manager calls to activity
public final class AutofillManager {
private static final String TAG = "AutofillManager";
@@ -107,7 +105,7 @@
*
* @deprecated Use {@link android.service.autofill.FillRequest#FLAG_MANUAL_REQUEST}
*/
- // TODO(b/33197203): remove (and change value of private flags)
+ // TODO(b/37563972): remove (and change value of private flags)
@Deprecated
public static final int FLAG_MANUAL_REQUEST = 0x1;
@@ -675,7 +673,7 @@
if (!hasAutofillFeature()) {
return;
}
- // TODO(b/33197203): the result code is being ignored, so this method is not reliably
+ // TODO: the result code is being ignored, so this method is not reliably
// handling the cases where it's not RESULT_OK: it works fine if the service does not
// set the EXTRA_AUTHENTICATION_RESULT extra, but it could cause weird results if the
// service set the extra and returned RESULT_CANCELED...
@@ -1323,8 +1321,6 @@
@Override
public void autofill(int sessionId, IBinder windowToken, List<AutofillId> ids,
List<AutofillValue> values) {
- // TODO(b/33197203): must keep the dataset so subsequent calls pass the same
- // dataset.extras to service
final AutofillManager afm = mAfm.get();
if (afm != null) {
afm.mContext.getMainThreadHandler().post(
diff --git a/core/java/android/view/autofill/AutofillValue.java b/core/java/android/view/autofill/AutofillValue.java
index e2dd7fe..b1a9d90 100644
--- a/core/java/android/view/autofill/AutofillValue.java
+++ b/core/java/android/view/autofill/AutofillValue.java
@@ -252,7 +252,6 @@
*
* <p>See {@link View#AUTOFILL_TYPE_TEXT} for more info.
*/
- // TODO(b/33197203): use cache
public static AutofillValue forText(@Nullable CharSequence value) {
return value == null ? null : new AutofillValue(AUTOFILL_TYPE_TEXT, value);
}
diff --git a/core/java/android/view/autofill/Helper.java b/core/java/android/view/autofill/Helper.java
index aa94de0..2b25ae7 100644
--- a/core/java/android/view/autofill/Helper.java
+++ b/core/java/android/view/autofill/Helper.java
@@ -25,7 +25,8 @@
/** @hide */
public final class Helper {
- public static final boolean DEBUG = true; // TODO(b/33197203): set to false when stable
+ // TODO(b/36141126): set to false and remove guard from places that should always be on
+ public static final boolean DEBUG = true;
public static final boolean VERBOSE = false;
public static final String REDACTED = "[REDACTED]";
diff --git a/core/java/android/widget/AbsSpinner.java b/core/java/android/widget/AbsSpinner.java
index f80c9e6..816c949 100644
--- a/core/java/android/widget/AbsSpinner.java
+++ b/core/java/android/widget/AbsSpinner.java
@@ -491,8 +491,6 @@
return AbsSpinner.class.getName();
}
- // TODO(b/33197203): add unit/CTS tests for auto-fill methods (and make sure they handle enable)
-
@Override
public void autofill(AutofillValue value) {
if (!isEnabled()) return;
diff --git a/core/java/android/widget/CompoundButton.java b/core/java/android/widget/CompoundButton.java
index c7ba7b5..0762b15 100644
--- a/core/java/android/widget/CompoundButton.java
+++ b/core/java/android/widget/CompoundButton.java
@@ -574,8 +574,6 @@
stream.addProperty("checked", isChecked());
}
- // TODO(b/33197203): add unit/CTS tests for autofill methods (and make sure they handle enable)
-
@Override
public void onProvideAutofillStructure(ViewStructure structure, int flags) {
super.onProvideAutofillStructure(structure, flags);
diff --git a/core/java/android/widget/DatePicker.java b/core/java/android/widget/DatePicker.java
index 463ff58..0dce079 100644
--- a/core/java/android/widget/DatePicker.java
+++ b/core/java/android/widget/DatePicker.java
@@ -764,8 +764,6 @@
void onValidationChanged(boolean valid);
}
- // TODO(b/33197203): add unit/CTS tests for autofill methods (and make sure they handle enable)
-
@Override
public void dispatchProvideAutofillStructure(ViewStructure structure, int flags) {
// This view is self-sufficient for autofill, so it needs to call
diff --git a/core/java/android/widget/RadioGroup.java b/core/java/android/widget/RadioGroup.java
index 08e6575..5c4d4d2 100644
--- a/core/java/android/widget/RadioGroup.java
+++ b/core/java/android/widget/RadioGroup.java
@@ -417,8 +417,6 @@
}
}
- // TODO(b/33197203): add unit/CTS tests for autofill methods (and make sure they handle enable)
-
@Override
public void onProvideAutofillStructure(ViewStructure structure, int flags) {
super.onProvideAutofillStructure(structure, flags);
diff --git a/core/java/android/widget/SimpleAdapter.java b/core/java/android/widget/SimpleAdapter.java
index 57e2ece..9190117 100644
--- a/core/java/android/widget/SimpleAdapter.java
+++ b/core/java/android/widget/SimpleAdapter.java
@@ -320,9 +320,6 @@
return mFilter;
}
- // TODO(b/33197203): implement getAutofillOptions
-
-
/**
* This class can be used by external clients of SimpleAdapter to bind
* values to views.
diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java
index f42d6c8..399cfac 100644
--- a/core/java/android/widget/TextView.java
+++ b/core/java/android/widget/TextView.java
@@ -10170,8 +10170,6 @@
structure.setInputType(getInputType());
}
- // TODO(b/33197203): add unit/CTS tests for autofill methods
-
boolean canRequestAutofill() {
final AutofillManager afm = mContext.getSystemService(AutofillManager.class);
if (afm != null) {
diff --git a/core/java/android/widget/TimePicker.java b/core/java/android/widget/TimePicker.java
index fb00c4392..df99fb4 100644
--- a/core/java/android/widget/TimePicker.java
+++ b/core/java/android/widget/TimePicker.java
@@ -519,8 +519,6 @@
}
}
- // TODO(b/33197203): add unit/CTS tests for autofill methods (and make sure they handle enable)
-
@Override
public void dispatchProvideAutofillStructure(ViewStructure structure, int flags) {
// This view is self-sufficient for autofill, so it needs to call