in AutofillFramework/afservice/src/main/java/com/example/android/autofill/service/data/ClientAutofillDataBuilder.java [116:159]
private void appendViewMetadata(@NonNull DatasetWithFilledAutofillFields
datasetWithFilledAutofillFields, @NonNull String[] hints, int partition,
@Nullable String textValue, @Nullable Long dateValue, @Nullable Boolean toggleValue,
@Nullable CharSequence[] autofillOptions, @Nullable Integer listIndex) {
for (int i = 0; i < hints.length; i++) {
String hint = hints[i];
// Then check if the "actual" hint is supported.
FieldTypeWithHeuristics fieldTypeWithHeuristics = mFieldTypesByAutofillHint.get(hint);
if (fieldTypeWithHeuristics != null) {
FieldType fieldType = fieldTypeWithHeuristics.fieldType;
if (!AutofillHints.matchesPartition(fieldType.getPartition(), partition)) {
continue;
}
// Only add the field if the hint is supported by the type.
if (textValue != null) {
if (!fieldType.getAutofillTypes().ints.contains(View.AUTOFILL_TYPE_TEXT)) {
loge("Text is invalid type for hint '%s'", hint);
}
}
if (autofillOptions != null && listIndex != null &&
autofillOptions.length > listIndex) {
if (!fieldType.getAutofillTypes().ints.contains(View.AUTOFILL_TYPE_LIST)) {
loge("List is invalid type for hint '%s'", hint);
}
textValue = autofillOptions[listIndex].toString();
}
if (dateValue != null) {
if (!fieldType.getAutofillTypes().ints.contains(View.AUTOFILL_TYPE_DATE)) {
loge("Date is invalid type for hint '%s'", hint);
}
}
if (toggleValue != null) {
if (!fieldType.getAutofillTypes().ints.contains(View.AUTOFILL_TYPE_TOGGLE)) {
loge("Toggle is invalid type for hint '%s'", hint);
}
}
String datasetId = datasetWithFilledAutofillFields.autofillDataset.getId();
datasetWithFilledAutofillFields.add(new FilledAutofillField(datasetId,
fieldType.getTypeName(), textValue, dateValue, toggleValue));
} else {
loge("Invalid hint: %s", hint);
}
}
}