diff options
Diffstat (limited to 'android/view/autofill/Helper.java')
-rw-r--r-- | android/view/autofill/Helper.java | 51 |
1 files changed, 30 insertions, 21 deletions
diff --git a/android/view/autofill/Helper.java b/android/view/autofill/Helper.java index 829e7f3a..4b2c53c7 100644 --- a/android/view/autofill/Helper.java +++ b/android/view/autofill/Helper.java @@ -16,11 +16,8 @@ package android.view.autofill; -import android.os.Bundle; - -import java.util.Arrays; -import java.util.Objects; -import java.util.Set; +import android.annotation.NonNull; +import android.annotation.Nullable; /** @hide */ public final class Helper { @@ -29,25 +26,37 @@ public final class Helper { public static boolean sDebug = false; public static boolean sVerbose = false; - public static final String REDACTED = "[REDACTED]"; + /** + * Appends {@code value} to the {@code builder} redacting its contents. + */ + public static void appendRedacted(@NonNull StringBuilder builder, + @Nullable CharSequence value) { + builder.append(getRedacted(value)); + } - static StringBuilder append(StringBuilder builder, Bundle bundle) { - if (bundle == null || !sDebug) { + /** + * Gets the redacted version of a value. + */ + @NonNull + public static String getRedacted(@Nullable CharSequence value) { + return (value == null) ? "null" : value.length() + "_chars"; + } + + /** + * Appends {@code values} to the {@code builder} redacting its contents. + */ + public static void appendRedacted(@NonNull StringBuilder builder, @Nullable String[] values) { + if (values == null) { builder.append("N/A"); - } else if (!sVerbose) { - builder.append(REDACTED); - } else { - final Set<String> keySet = bundle.keySet(); - builder.append("[Bundle with ").append(keySet.size()).append(" extras:"); - for (String key : keySet) { - final Object value = bundle.get(key); - builder.append(' ').append(key).append('='); - builder.append((value instanceof Object[]) - ? Arrays.toString((Objects[]) value) : value); - } - builder.append(']'); + return; + } + builder.append("["); + for (String value : values) { + builder.append(" '"); + appendRedacted(builder, value); + builder.append("'"); } - return builder; + builder.append(" ]"); } private Helper() { |