json.put("alpha", wrap(node.getAlpha())); json.put("assistBlocked", wrap(node.isAssistBlocked())); json.put("autofillHints", wrap(node.getAutofillHints())); json.put("autofillId", wrap(node.getAutofillId())); json.put("autofillOptions", wrap(node.getAutofillOptions()));
private AutofillId collectViewIds(AssistStructure.ViewNode node, Set<AutofillId> ids) { AutofillId result=null; if (node.getAutofillHints()!=null && node.getAutofillHints().length>0) { result=node.getAutofillId(); ids.add(result); } for (int i=0; i<node.getChildCount(); i++) { AutofillId temp=collectViewIds(node.getChildAt(i), ids); if (result==null) { result=temp; } } return(result); }
/** * Adds any autofillable view from the {@link ViewNode} and its descendants to the map. */ private void addAutofillableFields(@NonNull Map<String, AutofillId> fields, @NonNull ViewNode node) { String[] hints = node.getAutofillHints(); if (hints != null) { // We're simple, we only care about the first hint String hint = hints[0].toLowerCase(); if (hint != null) { AutofillId id = node.getAutofillId(); if (!fields.containsKey(hint)) { Log.v(TAG, "Setting hint '" + hint + "' on " + id); fields.put(hint, id); } else { Log.v(TAG, "Ignoring hint '" + hint + "' on " + id + " because it was already set"); } } } int childrenSize = node.getChildCount(); for (int i = 0; i < childrenSize; i++) { addAutofillableFields(fields, node.getChildAt(i)); } }
String[] afHints = node.getAutofillHints(); CharSequence[] options = node.getAutofillOptions(); builder.append(prefix).append("afType: ").append(getAutofillTypeAsString(node.getAutofillType()))
String[] afHints = node.getAutofillHints(); CharSequence[] options = node.getAutofillOptions(); builder.append(prefix).append("afType: ").append(getTypeAsString(node.getAutofillType()))
String[] hints = node.getAutofillHints(); if (hints != null) {
private void parseAutofillFields(AssistStructure.ViewNode viewNode, DatasetWithFilledAutofillFields datasetWithFilledAutofillFields, int partition) { String[] hints = viewNode.getAutofillHints(); if (hints == null || hints.length == 0) { return; } AutofillValue autofillValue = viewNode.getAutofillValue(); String textValue = null; Long dateValue = null; Boolean toggleValue = null; CharSequence[] autofillOptions = null; Integer listIndex = null; if (autofillValue != null) { if (autofillValue.isText()) { // Using toString of AutofillValue.getTextValue in order to save it to // SharedPreferences. textValue = autofillValue.getTextValue().toString(); } else if (autofillValue.isDate()) { dateValue = autofillValue.getDateValue(); } else if (autofillValue.isList()) { autofillOptions = viewNode.getAutofillOptions(); listIndex = autofillValue.getListValue(); } else if (autofillValue.isToggle()) { toggleValue = autofillValue.getToggleValue(); } } appendViewMetadata(datasetWithFilledAutofillFields, hints, partition, textValue, dateValue, toggleValue, autofillOptions, listIndex); }
private void parseViewNode(AssistStructure.ViewNode node) { String[] hints = node.getAutofillHints(); if (hints != null && hints.length > 0) { if (Arrays.stream(hints).anyMatch(View.AUTOFILL_HINT_USERNAME::equals)) result.username.add(node.getAutofillId()); else if (Arrays.stream(hints).anyMatch(View.AUTOFILL_HINT_EMAIL_ADDRESS::equals)) result.email.add(node.getAutofillId()); else if (Arrays.stream(hints).anyMatch(View.AUTOFILL_HINT_PASSWORD::equals)) result.password.add(node.getAutofillId()); else Log.d(TAG, "unsupported hints"); } else if (node.getAutofillType() == View.AUTOFILL_TYPE_TEXT) { int inputType = node.getInputType(); if ((inputType & InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS) > 0) result.email.add(node.getAutofillId()); else if ((inputType & InputType.TYPE_TEXT_VARIATION_PASSWORD) > 0) result.password.add(node.getAutofillId()); else if (result.password.isEmpty()) usernameCandidate = node.getAutofillId(); } for (int i=0; i<node.getChildCount(); ++i) parseViewNode(node.getChildAt(i)); }
private void parseAutofillFields(AssistStructure.ViewNode viewNode, HashMap<String, FieldTypeWithHeuristics> fieldTypesByAutofillHint, Map<String, FilledAutofillField> filledAutofillFieldsByTypeName, Dataset.Builder builder, MutableBoolean setValueAtLeastOnce) { String[] rawHints = viewNode.getAutofillHints(); if (rawHints == null || rawHints.length == 0) { logv("No af hints at ViewNode - %s", viewNode.getIdEntry()); return; } String fieldTypeName = AutofillHints.getFieldTypeNameFromAutofillHints( fieldTypesByAutofillHint, Arrays.asList(rawHints)); if (fieldTypeName == null) { return; } FilledAutofillField field = filledAutofillFieldsByTypeName.get(fieldTypeName); if (field == null) { return; } bindValueToNode(viewNode, field, builder, setValueAtLeastOnce); }
private void addAutofillableFields(@NonNull Map<String, AutofillId> fields, @NonNull ViewNode node) { String[] hints = node.getAutofillHints(); if (hints != null) { // We're simple, we only care about the first hint String hint = hints[0]; AutofillId id = node.getAutofillId(); if (!fields.containsKey(hint)) { Log.v(TAG, "Setting hint '" + hint + "' on " + id); fields.put(hint, id); } else { Log.v(TAG, "Ignoring hint '" + hint + "' on " + id + " because it was already set"); } } int childrenSize = node.getChildCount(); for (int i = 0; i < childrenSize; i++) { addAutofillableFields(fields, node.getChildAt(i)); } }
private void parseNode(AssistStructure.ViewNode root, List<String> allHints, MutableInt autofillSaveType, List<AutofillId> autofillIds, List<AutofillId> focusedAutofillIds) { String[] hints = root.getAutofillHints(); if (hints != null) { for (String hint : hints) { FieldTypeWithHeuristics fieldTypeWithHints = mFieldTypesByAutofillHint.get(hint); if (fieldTypeWithHints != null && fieldTypeWithHints.fieldType != null) { allHints.add(hint); autofillSaveType.value |= fieldTypeWithHints.fieldType.getSaveInfo(); autofillIds.add(root.getAutofillId()); } } } if (root.isFocused()) { focusedAutofillIds.add(root.getAutofillId()); } } }