in AutofillFramework/afservice/src/main/java/com/example/android/autofill/service/simple/DebugService.java [175:219]
protected String getHint(@NonNull ViewNode node) {
// First try the explicit autofill hints...
String[] hints = node.getAutofillHints();
if (hints != null) {
// We're simple, we only care about the first hint
return hints[0].toLowerCase();
}
// Then try some rudimentary heuristics based on other node properties
String viewHint = node.getHint();
String hint = inferHint(node, viewHint);
if (hint != null) {
Log.d(TAG, "Found hint using view hint(" + viewHint + "): " + hint);
return hint;
} else if (!TextUtils.isEmpty(viewHint)) {
Log.v(TAG, "No hint using view hint: " + viewHint);
}
String resourceId = node.getIdEntry();
hint = inferHint(node, resourceId);
if (hint != null) {
Log.d(TAG, "Found hint using resourceId(" + resourceId + "): " + hint);
return hint;
} else if (!TextUtils.isEmpty(resourceId)) {
Log.v(TAG, "No hint using resourceId: " + resourceId);
}
CharSequence text = node.getText();
CharSequence className = node.getClassName();
if (text != null && className != null && className.toString().contains("EditText")) {
hint = inferHint(node, text.toString());
if (hint != null) {
// NODE: text should not be logged, as it could contain PII
Log.d(TAG, "Found hint using text(" + text + "): " + hint);
return hint;
}
} else if (!TextUtils.isEmpty(text)) {
// NODE: text should not be logged, as it could contain PII
Log.v(TAG, "No hint using text: " + text + " and class " + className);
}
return null;
}