summaryrefslogtreecommitdiff
path: root/core/java/android/view/ViewHierarchyEncoder.java
diff options
context:
space:
mode:
authorSunny Goyal <sunnygoyal@google.com>2020-02-25 09:57:50 -0800
committerSunny Goyal <sunnygoyal@google.com>2020-02-25 10:00:37 -0800
commitc444b514bf50c2b53f97f3ccaa4b538238a0bcc9 (patch)
tree897f7c402d0ca87097f051a840af81b62f89addf /core/java/android/view/ViewHierarchyEncoder.java
parent27f83cdbcefd687632811996e25ece99f7e1ac69 (diff)
Removing possible user defined strings from bugreport view-dump
Bug: 64101886 Test: Verified build Change-Id: Ifad98a268fc17a2e1572ca3e0962a89447083294
Diffstat (limited to 'core/java/android/view/ViewHierarchyEncoder.java')
-rw-r--r--core/java/android/view/ViewHierarchyEncoder.java17
1 files changed, 17 insertions, 0 deletions
diff --git a/core/java/android/view/ViewHierarchyEncoder.java b/core/java/android/view/ViewHierarchyEncoder.java
index b0e0524a0d85..ace05a6b6bf9 100644
--- a/core/java/android/view/ViewHierarchyEncoder.java
+++ b/core/java/android/view/ViewHierarchyEncoder.java
@@ -66,10 +66,16 @@ public class ViewHierarchyEncoder {
private short mPropertyId = 1;
private Charset mCharset = Charset.forName("utf-8");
+ private boolean mUserPropertiesEnabled = true;
+
public ViewHierarchyEncoder(@NonNull ByteArrayOutputStream stream) {
mStream = new DataOutputStream(stream);
}
+ public void setUserPropertiesEnabled(boolean enabled) {
+ mUserPropertiesEnabled = enabled;
+ }
+
public void beginObject(@NonNull Object o) {
startPropertyMap();
addProperty("meta:__name__", o.getClass().getName());
@@ -121,6 +127,17 @@ public class ViewHierarchyEncoder {
}
/**
+ * Encodes a user defined property if they are allowed to be encoded
+ *
+ * @see #setUserPropertiesEnabled(boolean)
+ */
+ public void addUserProperty(@NonNull String name, @Nullable String s) {
+ if (mUserPropertiesEnabled) {
+ addProperty(name, s);
+ }
+ }
+
+ /**
* Writes the given name as the property name, and leaves it to the callee
* to fill in value for this property.
*/