json.put("assistBlocked", wrap(node.isAssistBlocked())); json.put("autofillHints", wrap(node.getAutofillHints())); json.put("autofillId", wrap(node.getAutofillId())); json.put("autofillOptions", wrap(node.getAutofillOptions())); json.put("autofillType", wrap(node.getAutofillType()));
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); }
private static void dumpNode(String prefix, ViewNode node) { StringBuilder builder = new StringBuilder(); builder.append(prefix) .append("autoFillId: ").append(node.getAutofillId()) .append("\tidEntry: ").append(node.getIdEntry()) .append("\tid: ").append(node.getId())
void bindValueToNode(AssistStructure.ViewNode viewNode, FilledAutofillField field, Dataset.Builder builder, MutableBoolean setValueAtLeastOnce) { AutofillId autofillId = viewNode.getAutofillId(); if (autofillId == null) { logw("Autofill ID null for %s", viewNode.toString());
.append("autoFillId: ").append(node.getAutofillId()) .append("\tidEntry: ").append(node.getIdEntry()) .append("\tid: ").append(node.getId())
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)); }
/** * 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)); } }
/** * 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 hint = getHint(node); 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)); } }
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()); } } }
private boolean bindDatasetToFocusedNode(FilledAutofillField field, FieldType fieldType, Dataset.Builder builder) { MutableBoolean setValueAtLeastOnce = new MutableBoolean(false); mClientParser.parse((node) -> { if (node.isFocused() && node.getAutofillId() != null) { bindValueToNode(node, field, builder, setValueAtLeastOnce); } }); return setValueAtLeastOnce.value; }