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); }
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()); } }
@Override public void onLoaded( HashMap<String, FieldTypeWithHeuristics> fieldTypesByAutofillHint) { mAutofillDataBuilder = new ClientAutofillDataBuilder( fieldTypesByAutofillHint, getPackageName(), parser); ClientViewMetadataBuilder clientViewMetadataBuilder = new ClientViewMetadataBuilder(parser, fieldTypesByAutofillHint); mClientViewMetadata = clientViewMetadataBuilder.buildClientViewMetadata(); String packageName = latestStructure.getActivityComponent().getPackageName(); if (!mPackageVerificationRepository.putPackageSignatures(packageName)) { callback.onFailure(getString(R.string.invalid_package_signature)); return; } if (logVerboseEnabled()) { logv("onSaveRequest(): clientState=%s", bundleToString(request.getClientState())); } dumpStructure(latestStructure); checkWebDomainAndBuildAutofillData(packageName, callback); }
/** * 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; }
@Override public void onLoaded(HashMap<String, FieldTypeWithHeuristics> fieldTypesByAutofillHint) { DatasetAdapter datasetAdapter = new DatasetAdapter(parser); ClientViewMetadataBuilder clientViewMetadataBuilder = new ClientViewMetadataBuilder(parser, fieldTypesByAutofillHint); mClientViewMetadata = clientViewMetadataBuilder.buildClientViewMetadata(); mResponseAdapter = new ResponseAdapter(MyAutofillService.this, mClientViewMetadata, getPackageName(), datasetAdapter); String packageName = latestStructure.getActivityComponent().getPackageName(); if (!mPackageVerificationRepository.putPackageSignatures(packageName)) { callback.onFailure(getString(R.string.invalid_package_signature)); return; } if (logVerboseEnabled()) { logv("onFillRequest(): clientState=%s", bundleToString(request.getClientState())); dumpStructure(latestStructure); } cancellationSignal.setOnCancelListener(() -> logw("Cancel autofill not implemented in this sample.") ); fetchDataAndGenerateResponse(fieldTypesByAutofillHint, responseAuth, datasetAuth, manual, callback); }
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); }
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); } } }
for (int i=0; i<assistStructure.getWindowNodeCount(); i++) { AssistStructure.WindowNode node=assistStructure.getWindowNodeAt(i);
/** * 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); } } }
@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; }
/** * 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; }
/** * 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 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; }
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; }