Don't print sensitive data on AssistStructure.dump()
Test: manual verification
Bug: 38205945
Change-Id: Ic184ee6da313a2c0f8e0dd11979f6985d8023140
diff --git a/core/java/android/app/assist/AssistStructure.java b/core/java/android/app/assist/AssistStructure.java
index eae9e1e..861c73d 100644
--- a/core/java/android/app/assist/AssistStructure.java
+++ b/core/java/android/app/assist/AssistStructure.java
@@ -1936,7 +1936,7 @@
}
/** @hide */
- public void dump() {
+ public void dump(boolean showSensitive) {
if (mActivityComponent == null) {
Log.i(TAG, "dump(): calling ensureData() first");
ensureData();
@@ -1949,11 +1949,11 @@
WindowNode node = getWindowNodeAt(i);
Log.i(TAG, "Window #" + i + " [" + node.getLeft() + "," + node.getTop()
+ " " + node.getWidth() + "x" + node.getHeight() + "]" + " " + node.getTitle());
- dump(" ", node.getRootViewNode());
+ dump(" ", node.getRootViewNode(), showSensitive);
}
}
- void dump(String prefix, ViewNode node) {
+ void dump(String prefix, ViewNode node, boolean showSensitive) {
Log.i(TAG, prefix + "View [" + node.getLeft() + "," + node.getTop()
+ " " + node.getWidth() + "x" + node.getHeight() + "]" + " " + node.getClassName());
int id = node.getId();
@@ -1992,12 +1992,15 @@
}
CharSequence text = node.getText();
if (text != null) {
+ final String safeText = node.isSanitized() || showSensitive ? text.toString()
+ : "REDACTED[" + text.length() + " chars]";
Log.i(TAG, prefix + " Text (sel " + node.getTextSelectionStart() + "-"
- + node.getTextSelectionEnd() + "): " + text);
+ + node.getTextSelectionEnd() + "): " + safeText);
Log.i(TAG, prefix + " Text size: " + node.getTextSize() + " , style: #"
+ node.getTextStyle());
Log.i(TAG, prefix + " Text color fg: #" + Integer.toHexString(node.getTextColor())
+ ", bg: #" + Integer.toHexString(node.getTextBackgroundColor()));
+ Log.i(TAG, prefix + " Input type: " + node.getInputType());
}
String webDomain = node.getWebDomain();
if (webDomain != null) {
@@ -2031,7 +2034,6 @@
Log.i(TAG, prefix + "Autofill info: id= " + autofillId
+ ", type=" + node.getAutofillType()
+ ", options=" + Arrays.toString(node.getAutofillOptions())
- + ", inputType=" + node.getInputType()
+ ", hints=" + Arrays.toString(node.getAutofillHints())
+ ", value=" + node.getAutofillValue()
+ ", sanitized=" + node.isSanitized());
@@ -2043,7 +2045,7 @@
String cprefix = prefix + " ";
for (int i=0; i<NCHILDREN; i++) {
ViewNode cnode = node.getChildAt(i);
- dump(cprefix, cnode);
+ dump(cprefix, cnode, showSensitive);
}
}
}
diff --git a/services/autofill/java/com/android/server/autofill/Session.java b/services/autofill/java/com/android/server/autofill/Session.java
index 4de293c..0122301 100644
--- a/services/autofill/java/com/android/server/autofill/Session.java
+++ b/services/autofill/java/com/android/server/autofill/Session.java
@@ -888,7 +888,7 @@
if (sVerbose) {
Slog.v(TAG, "Dumping structure of " + context + " before calling service.save()");
- context.getStructure().dump();
+ context.getStructure().dump(false);
}
}
@@ -1402,7 +1402,7 @@
pw.println(context.getStructure() + " (look at logcat)");
// TODO: add method on AssistStructure to dump on pw
- context.getStructure().dump();
+ context.getStructure().dump(false);
}
}
} else {
diff --git a/tests/VoiceInteraction/src/com/android/test/voiceinteraction/AssistVisualizer.java b/tests/VoiceInteraction/src/com/android/test/voiceinteraction/AssistVisualizer.java
index c1f0038..f0163be 100644
--- a/tests/VoiceInteraction/src/com/android/test/voiceinteraction/AssistVisualizer.java
+++ b/tests/VoiceInteraction/src/com/android/test/voiceinteraction/AssistVisualizer.java
@@ -107,7 +107,7 @@
public void logTree() {
if (mAssistStructure != null) {
- mAssistStructure.dump();
+ mAssistStructure.dump(true);
}
}