Loading core/java/android/service/autofill/FillContext.java +28 −4 Original line number Diff line number Diff line Loading @@ -106,15 +106,15 @@ public final class FillContext implements Parcelable { } /** * Finds {@link ViewNode}s that have the requested ids. * Finds {@link ViewNode ViewNodes} that have the requested ids. * * @param ids The ids of the node to find * @param ids The ids of the node to find. * * @return The nodes indexed in the same way as the ids * @return The nodes indexed in the same way as the ids. * * @hide */ @NonNull public ViewNode[] findViewNodesByAutofillIds(@NonNull AutofillId... ids) { @NonNull public ViewNode[] findViewNodesByAutofillIds(@NonNull AutofillId[] ids) { final LinkedList<ViewNode> nodesToProcess = new LinkedList<>(); final ViewNode[] foundNodes = new AssistStructure.ViewNode[ids.length]; Loading Loading @@ -178,6 +178,30 @@ public final class FillContext implements Parcelable { return foundNodes; } /** * Finds the {@link ViewNode} that has the requested {@code id}, if any. * * @hide */ @Nullable public ViewNode findViewNodeByAutofillId(@NonNull AutofillId id) { final LinkedList<ViewNode> nodesToProcess = new LinkedList<>(); final int numWindowNodes = mStructure.getWindowNodeCount(); for (int i = 0; i < numWindowNodes; i++) { nodesToProcess.add(mStructure.getWindowNodeAt(i).getRootViewNode()); } while (!nodesToProcess.isEmpty()) { final ViewNode node = nodesToProcess.removeFirst(); if (id.equals(node.getAutofillId())) { return node; } for (int i = 0; i < node.getChildCount(); i++) { nodesToProcess.addLast(node.getChildAt(i)); } } return null; } public static final Parcelable.Creator<FillContext> CREATOR = new Parcelable.Creator<FillContext>() { @Override Loading services/autofill/java/com/android/server/autofill/Session.java +6 −6 Original line number Diff line number Diff line Loading @@ -255,7 +255,9 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState final ViewNode node = nodes[i]; if (node == null) { Slog.w(TAG, "fillStructureWithAllowedValues(): no node for " + viewState.id); if (sVerbose) { Slog.v(TAG, "fillStructureWithAllowedValues(): no node for " + viewState.id); } continue; } Loading Loading @@ -862,11 +864,9 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState final int numContexts = mContexts.size(); for (int i = 0; i < numContexts; i++) { final FillContext context = mContexts.get(i); // TODO: create a function that gets just one node so it doesn't create an array // unnecessarily final ViewNode[] nodes = context.findViewNodesByAutofillIds(id); if (nodes != null) { AutofillValue candidate = nodes[0].getAutofillValue(); final ViewNode node = context.findViewNodeByAutofillId(id); if (node != null) { final AutofillValue candidate = node.getAutofillValue(); if (sDebug) { Slog.d(TAG, "getValueFromContexts(" + id + ") at " + i + ": " + candidate); } Loading Loading
core/java/android/service/autofill/FillContext.java +28 −4 Original line number Diff line number Diff line Loading @@ -106,15 +106,15 @@ public final class FillContext implements Parcelable { } /** * Finds {@link ViewNode}s that have the requested ids. * Finds {@link ViewNode ViewNodes} that have the requested ids. * * @param ids The ids of the node to find * @param ids The ids of the node to find. * * @return The nodes indexed in the same way as the ids * @return The nodes indexed in the same way as the ids. * * @hide */ @NonNull public ViewNode[] findViewNodesByAutofillIds(@NonNull AutofillId... ids) { @NonNull public ViewNode[] findViewNodesByAutofillIds(@NonNull AutofillId[] ids) { final LinkedList<ViewNode> nodesToProcess = new LinkedList<>(); final ViewNode[] foundNodes = new AssistStructure.ViewNode[ids.length]; Loading Loading @@ -178,6 +178,30 @@ public final class FillContext implements Parcelable { return foundNodes; } /** * Finds the {@link ViewNode} that has the requested {@code id}, if any. * * @hide */ @Nullable public ViewNode findViewNodeByAutofillId(@NonNull AutofillId id) { final LinkedList<ViewNode> nodesToProcess = new LinkedList<>(); final int numWindowNodes = mStructure.getWindowNodeCount(); for (int i = 0; i < numWindowNodes; i++) { nodesToProcess.add(mStructure.getWindowNodeAt(i).getRootViewNode()); } while (!nodesToProcess.isEmpty()) { final ViewNode node = nodesToProcess.removeFirst(); if (id.equals(node.getAutofillId())) { return node; } for (int i = 0; i < node.getChildCount(); i++) { nodesToProcess.addLast(node.getChildAt(i)); } } return null; } public static final Parcelable.Creator<FillContext> CREATOR = new Parcelable.Creator<FillContext>() { @Override Loading
services/autofill/java/com/android/server/autofill/Session.java +6 −6 Original line number Diff line number Diff line Loading @@ -255,7 +255,9 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState final ViewNode node = nodes[i]; if (node == null) { Slog.w(TAG, "fillStructureWithAllowedValues(): no node for " + viewState.id); if (sVerbose) { Slog.v(TAG, "fillStructureWithAllowedValues(): no node for " + viewState.id); } continue; } Loading Loading @@ -862,11 +864,9 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState final int numContexts = mContexts.size(); for (int i = 0; i < numContexts; i++) { final FillContext context = mContexts.get(i); // TODO: create a function that gets just one node so it doesn't create an array // unnecessarily final ViewNode[] nodes = context.findViewNodesByAutofillIds(id); if (nodes != null) { AutofillValue candidate = nodes[0].getAutofillValue(); final ViewNode node = context.findViewNodeByAutofillId(id); if (node != null) { final AutofillValue candidate = node.getAutofillValue(); if (sDebug) { Slog.d(TAG, "getValueFromContexts(" + id + ") at " + i + ": " + candidate); } Loading