private JSONArray dumpStructureNodes( AssistStructure.ViewNode node, JSONArray children) throws JSONException { for (int i=0; i<node.getChildCount(); i++) { children.put(dumpStructureNode(node.getChildAt(i), new JSONObject())); } return (children); }
private JSONArray dumpStructureNodes( AssistStructure.ViewNode node, JSONArray children) throws JSONException { for (int i=0; i<node.getChildCount(); i++) { children.put(dumpStructureNode(node.getChildAt(i), new JSONObject())); } return(children); }
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); }
.append('\n'); int numberChildren = node.getChildCount(); builder.append(prefix).append("# children: ").append(numberChildren) .append("\ttext: ").append(node.getText())
.append('\n'); int numberChildren = node.getChildCount(); builder.append(prefix).append("# children: ").append(numberChildren) .append("\ttext: ").append(node.getText())
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)); } }
/** * Gets a node if it matches the filter criteria for the given id. */ public static ViewNode findNodeByFilter(@NonNull ViewNode node, @NonNull Object id, @NonNull NodeFilter filter) { if (filter.matches(node, id)) { return node; } final int childrenSize = node.getChildCount(); if (childrenSize > 0) { for (int i = 0; i < childrenSize; i++) { final ViewNode found = findNodeByFilter(node.getChildAt(i), id, filter); if (found != null) { return found; } } } return null; }
private void traverseRoot(AssistStructure.ViewNode viewNode, NodeProcessor processor) { processor.processNode(viewNode); int childrenSize = viewNode.getChildCount(); if (childrenSize > 0) { for (int i = 0; i < childrenSize; i++) { traverseRoot(viewNode.getChildAt(i), processor); } } }