private void AppendViewMetadata([NonNull] DatasetWithFilledAutofillFields datasetWithFilledAutofillFields, [NonNull] string[] hints, int partition, [Nullable] string textValue, [Nullable] long dateValue, [Nullable] bool toggleValue, [Nullable] string[] autofillOptions, [Nullable] int listIndex) { for (int i = 0; i < hints.Length; i++) { String hint = hints[i]; // Then check if the "actual" hint is supported. FieldTypeWithHeuristics fieldTypeWithHeuristics = mFieldTypesByAutofillHint[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((int)AutofillType.Text)) { Util.Loge("Text is invalid type for hint '%s'", hint); } } if (autofillOptions != null && listIndex != null && autofillOptions.Length > listIndex) { if (!fieldType.GetAutofillTypes().ints.Contains((int)AutofillType.List)) { Util.Loge("List is invalid type for hint '%s'", hint); } textValue = autofillOptions[listIndex]; } if (dateValue != null) { if (!fieldType.GetAutofillTypes().ints.Contains((int)AutofillType.Date)) { Util.Loge("Date is invalid type for hint '%s'", hint); } } if (toggleValue != null) { if (!fieldType.GetAutofillTypes().ints.Contains((int)AutofillType.Toggle)) { Util.Loge("Toggle is invalid type for hint '%s'", hint); } } String datasetId = datasetWithFilledAutofillFields.autofillDataset.GetId(); datasetWithFilledAutofillFields.Add(new FilledAutofillField(datasetId, mPackageName, fieldType.GetTypeName(), textValue, dateValue, toggleValue)); } else { Util.Loge("Invalid hint: %s", hint); } } }
private void ParseNode(AssistStructure.ViewNode root, List <String> allHints, MutableInt autofillSaveType, List <AutofillId> autofillIds, List <AutofillId> focusedAutofillIds) { String[] hints = root.GetAutofillHints(); if (hints != null) { foreach (string hint in hints) { FieldTypeWithHeuristics fieldTypeWithHints = mFieldTypesByAutofillHint[hint]; if (fieldTypeWithHints != null && fieldTypeWithHints.fieldType != null) { allHints.Add(hint); autofillSaveType.Value |= fieldTypeWithHints.fieldType.GetSaveInfo(); } } } if (root.IsFocused) { focusedAutofillIds.Add(root.AutofillId); } autofillIds.Add(root.AutofillId); }