Improvements on ViewNodes received on partitioned requests:

- Fixed focus
- Added autofillValue for nodes previously autofilled

BUG: 35707731

Test: existing CtsAutoFillServiceTestCases pass
Test: more tests on PartitionedActivityTest

Change-Id: If4390d002d44c82e3de0339a634041f3998e804e
This commit is contained in:
Felipe Leme
2017-03-31 17:26:34 -07:00
parent aaca304a31
commit cde040ae95
3 changed files with 79 additions and 15 deletions

View File

@@ -599,6 +599,10 @@ public class AssistStructure implements Parcelable {
boolean mSanitized;
HtmlInfo mHtmlInfo;
// POJO used to override some autofill-related values when the node is parcelized.
// Not written to parcel.
AutofillOverlay mAutofillOverlay;
int mX;
int mY;
int mScrollX;
@@ -756,6 +760,7 @@ public class AssistStructure implements Parcelable {
boolean writeSensitive = true;
int flags = mFlags & ~FLAGS_ALL_CONTROL;
if (mId != View.NO_ID) {
flags |= FLAGS_HAS_ID;
}
@@ -810,6 +815,13 @@ public class AssistStructure implements Parcelable {
// Remove 'checked' from sanitized autofill request.
writtenFlags = flags & ~FLAGS_CHECKED;
}
if (mAutofillOverlay != null) {
if (mAutofillOverlay.focused) {
writtenFlags |= ViewNode.FLAGS_FOCUSED;
} else {
writtenFlags &= ~ViewNode.FLAGS_FOCUSED;
}
}
out.writeInt(writtenFlags);
if ((flags&FLAGS_HAS_ID) != 0) {
@@ -829,7 +841,14 @@ public class AssistStructure implements Parcelable {
out.writeParcelable(mAutofillId, 0);
out.writeInt(mAutofillType);
out.writeStringArray(mAutofillHints);
final AutofillValue sanitizedValue = writeSensitive ? mAutofillValue : null;
final AutofillValue sanitizedValue;
if (mAutofillOverlay != null && mAutofillOverlay.value != null) {
sanitizedValue = mAutofillOverlay.value;
} else if (writeSensitive) {
sanitizedValue = mAutofillValue;
} else {
sanitizedValue = null;
}
out.writeParcelable(sanitizedValue, 0);
out.writeStringArray(mAutofillOptions);
if (mHtmlInfo instanceof Parcelable) {
@@ -959,6 +978,11 @@ public class AssistStructure implements Parcelable {
return mAutofillValue;
}
/** @hide **/
public void setAutofillOverlay(AutofillOverlay overlay) {
mAutofillOverlay = overlay;
}
/**
* Gets the options that can be used to autofill this structure.
*
@@ -1340,6 +1364,16 @@ public class AssistStructure implements Parcelable {
}
}
/**
* POJO used to override some autofill-related values when the node is parcelized.
*
* @hide
*/
static public class AutofillOverlay {
public boolean focused;
public AutofillValue value;
}
static class ViewNodeBuilder extends ViewStructure {
final AssistStructure mAssist;
final ViewNode mNode;