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 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 dumpStructureWindows(JSONArray windows) throws JSONException { for (int i=0; i<structure.getWindowNodeCount(); i++) { windows.put( dumpStructureWindow(structure.getWindowNodeAt(i), new JSONObject())); } return (windows); }
throws JSONException { json.put("accessibilityFocused", wrap(node.isAccessibilityFocused())); json.put("activated", wrap(node.isActivated())); json.put("alpha", wrap(node.getAlpha())); json.put("assistBlocked", wrap(node.isAssistBlocked())); json.put("checkable", wrap(node.isCheckable())); json.put("checked", wrap(node.isChecked())); json.put("className", wrap(node.getClassName())); json.put("clickable", wrap(node.isClickable())); json.put("contentDescription", wrap(node.getContentDescription())); json.put("contextClickable", wrap(node.isContextClickable())); json.put("elevation", wrap(node.getElevation())); json.put("enabled", wrap(node.isEnabled())); if (node.getExtras()!=null) { json.put("extras", dumpBundle(node.getExtras(), new JSONObject())); json.put("focusable", wrap(node.isFocusable())); json.put("focused", wrap(node.isFocused())); json.put("height", wrap(node.getHeight())); json.put("hint", wrap(node.getHint())); json.put("id", wrap(node.getId())); json.put("idEntry", wrap(node.getIdEntry())); json.put("idPackage", wrap(node.getIdPackage())); json.put("idType", wrap(node.getIdType()));
for (int i=0; i<assistStructure.getWindowNodeCount(); i++) { AssistStructure.WindowNode node=assistStructure.getWindowNodeAt(i); AutofillId temp=collectViewIds(node.getRootViewNode(), ids);
public static void dumpStructure(AssistStructure structure) { int nodeCount = structure.getWindowNodeCount(); Log.v(TAG, "dumpStructure(): component=" + structure.getActivityComponent() + " numberNodes=" + nodeCount); for (int i = 0; i < nodeCount; i++) { Log.v(TAG, "node #" + i); WindowNode node = structure.getWindowNodeAt(i); dumpNode(" ", node.getRootViewNode()); } }
private JSONObject dumpStructureWindow( AssistStructure.WindowNode window, JSONObject json) throws JSONException { json.put("displayId", wrap(window.getDisplayId())); json.put("height", wrap(window.getHeight())); json.put("left", wrap(window.getLeft())); json.put("title", wrap(window.getTitle())); json.put("top", wrap(window.getTop())); json.put("width", wrap(window.getWidth())); json.put("root", dumpStructureNode(window.getRootViewNode(), new JSONObject())); return (json); }
Result parse() { result = new Result(); usernameCandidate = null; for (int i=0; i<structure.getWindowNodeCount(); ++i) { AssistStructure.WindowNode windowNode = structure.getWindowNodeAt(i); result.title.add(windowNode.getTitle()); result.webDomain.add(windowNode.getRootViewNode().getWebDomain()); parseViewNode(windowNode.getRootViewNode()); } // If not explicit username field found, add the field just before password field. if (result.username.isEmpty() && result.email.isEmpty() && !result.password.isEmpty() && usernameCandidate != null) result.username.add(usernameCandidate); return result; }
private JSONObject dumpContent(JSONObject json) throws JSONException { JSONObject extras=new JSONObject(); if (content.getExtras()!=null) { json.put("extras", extras); dumpBundle(content.getExtras(), extras); } if (content.getIntent()!=null) { json.put("intent", content.getIntent().toUri(Intent.URI_INTENT_SCHEME)); } json.put("structuredData", wrap(content.getStructuredData())); json.put("webUri", wrap(content.getWebUri())); return (json); }
@TargetApi(23) @Override public void onProvideAssistContent(AssistContent outContent) { super.onProvideAssistContent(outContent); outContent.setWebUri(Uri.parse("https://commonsware.com")); try { JSONObject json=new JSONObject() .put("@type", "Book") .put("author", "https://commonsware.com/mmurphy") .put("publisher", "CommonsWare, LLC") .put("name", "The Busy Coder's Guide to Android Development"); outContent.setStructuredData(json.toString()); } catch (JSONException e) { Log.e(getClass().getSimpleName(), "Um, what happened here?", e); } } }
throws JSONException { json.put("accessibilityFocused", wrap(node.isAccessibilityFocused())); json.put("activated", wrap(node.isActivated())); 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())); json.put("autofillType", wrap(node.getAutofillType())); json.put("autofillValue", wrap(node.getAutofillValue())); json.put("checkable", wrap(node.isCheckable())); json.put("checked", wrap(node.isChecked())); json.put("className", wrap(node.getClassName())); json.put("clickable", wrap(node.isClickable())); json.put("contentDescription", wrap(node.getContentDescription())); json.put("contextClickable", wrap(node.isContextClickable())); json.put("elevation", wrap(node.getElevation())); json.put("enabled", wrap(node.isEnabled())); if (node.getExtras()!=null) { json.put("extras", dumpBundle(node.getExtras(), new JSONObject())); json.put("focusable", wrap(node.isFocusable())); json.put("focused", wrap(node.isFocused())); json.put("height", wrap(node.getHeight()));
/** * Traverses through the {@link AssistStructure} and does something at each {@link ViewNode}. * * @param processor contains action to be performed on each {@link ViewNode}. */ public void parse(NodeProcessor processor) { for (AssistStructure structure : mStructures) { int nodes = structure.getWindowNodeCount(); for (int i = 0; i < nodes; i++) { AssistStructure.ViewNode viewNode = structure.getWindowNodeAt(i).getRootViewNode(); traverseRoot(viewNode, processor); } } }
/** * Gets a node if it matches the filter criteria for the given id. */ public static ViewNode findNodeByFilter(@NonNull AssistStructure structure, @NonNull Object id, @NonNull NodeFilter filter) { logv("Parsing request for activity %s", structure.getActivityComponent()); final int nodes = structure.getWindowNodeCount(); for (int i = 0; i < nodes; i++) { final WindowNode windowNode = structure.getWindowNodeAt(i); final ViewNode rootNode = windowNode.getRootViewNode(); final ViewNode node = findNodeByFilter(rootNode, id, filter); if (node != null) { return node; } } return null; }
protected JSONObject dumpStructureWindow( AssistStructure.WindowNode window, JSONObject json) throws JSONException { json.put("displayId", wrap(window.getDisplayId())); json.put("height", wrap(window.getHeight())); json.put("left", wrap(window.getLeft())); json.put("title", wrap(window.getTitle())); json.put("top", wrap(window.getTop())); json.put("width", wrap(window.getWidth())); json.put("root", dumpStructureNode(window.getRootViewNode(), new JSONObject())); return(json); }
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); }
protected JSONArray dumpStructureWindows(AssistStructure structure, JSONArray windows) throws JSONException { for (int i=0; i<structure.getWindowNodeCount(); i++) { windows.put( dumpStructureWindow(structure.getWindowNodeAt(i), new JSONObject())); } return(windows); }
@NonNull private ArrayMap<String, AutofillId> getAutofillableFields(@NonNull AssistStructure structure) { ArrayMap<String, AutofillId> fields = new ArrayMap<>(); int nodes = structure.getWindowNodeCount(); for (int i = 0; i < nodes; i++) { ViewNode node = structure.getWindowNodeAt(i).getRootViewNode(); addAutofillableFields(fields, node); } return fields; }
public static void dumpStructure(AssistStructure structure) { if (logVerboseEnabled()) { int nodeCount = structure.getWindowNodeCount(); logv("dumpStructure(): component=%s numberNodes=%d", structure.getActivityComponent(), nodeCount); for (int i = 0; i < nodeCount; i++) { logv("node #%d", i); WindowNode node = structure.getWindowNodeAt(i); dumpNode(new StringBuilder(), " ", node.getRootViewNode(), 0); } } }
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); } } }
/** * Parses the {@link AssistStructure} representing the activity being autofilled, and returns a * map of autofillable fields (represented by their autofill ids) mapped by the hint associate * with them. * * <p>An autofillable field is a {@link ViewNode} whose {@link #getHint(ViewNode)} metho */ @NonNull private Map<String, AutofillId> getAutofillableFields(@NonNull AssistStructure structure) { Map<String, AutofillId> fields = new ArrayMap<>(); int nodes = structure.getWindowNodeCount(); for (int i = 0; i < nodes; i++) { ViewNode node = structure.getWindowNodeAt(i).getRootViewNode(); addAutofillableFields(fields, node); } return fields; }