diff options
| author | Aaron Heuckroth <nesciosquid@google.com> | 2018-07-10 18:05:34 +0000 |
|---|---|---|
| committer | Android (Google) Code Review <android-gerrit@google.com> | 2018-07-10 18:05:34 +0000 |
| commit | 09d6bd8a665da92e182e8aee80779d6ae19dedcd (patch) | |
| tree | 641391bb69b16fe3e4aaa6f03ecd88b358f26b23 /core/java/android | |
| parent | 62ed48e8ee1cffb9f967fcbcf72ae5fb961aa3b2 (diff) | |
| parent | 51d3288431806a86d3fc8850f53d9b88d449033d (diff) | |
Merge "Move channel logging to dump method and redact name."
Diffstat (limited to 'core/java/android')
| -rw-r--r-- | core/java/android/app/NotificationChannel.java | 27 | ||||
| -rw-r--r-- | core/java/android/text/TextUtils.java | 19 |
2 files changed, 46 insertions, 0 deletions
diff --git a/core/java/android/app/NotificationChannel.java b/core/java/android/app/NotificationChannel.java index 1ad305441539..03fd139e12ff 100644 --- a/core/java/android/app/NotificationChannel.java +++ b/core/java/android/app/NotificationChannel.java @@ -38,6 +38,7 @@ import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlSerializer; import java.io.IOException; +import java.io.PrintWriter; import java.util.Arrays; /** @@ -942,6 +943,32 @@ public final class NotificationChannel implements Parcelable { return result; } + /** @hide */ + public void dump(PrintWriter pw, String prefix, boolean redacted) { + String redactedName = redacted ? TextUtils.trimToLengthWithEllipsis(mName, 3) : mName; + String output = "NotificationChannel{" + + "mId='" + mId + '\'' + + ", mName=" + redactedName + + ", mDescription=" + (!TextUtils.isEmpty(mDesc) ? "hasDescription " : "") + + ", mImportance=" + mImportance + + ", mBypassDnd=" + mBypassDnd + + ", mLockscreenVisibility=" + mLockscreenVisibility + + ", mSound=" + mSound + + ", mLights=" + mLights + + ", mLightColor=" + mLightColor + + ", mVibration=" + Arrays.toString(mVibration) + + ", mUserLockedFields=" + Integer.toHexString(mUserLockedFields) + + ", mFgServiceShown=" + mFgServiceShown + + ", mVibrationEnabled=" + mVibrationEnabled + + ", mShowBadge=" + mShowBadge + + ", mDeleted=" + mDeleted + + ", mGroup='" + mGroup + '\'' + + ", mAudioAttributes=" + mAudioAttributes + + ", mBlockableSystem=" + mBlockableSystem + + '}'; + pw.println(prefix + output); + } + @Override public String toString() { return "NotificationChannel{" diff --git a/core/java/android/text/TextUtils.java b/core/java/android/text/TextUtils.java index 6b2f80241df3..dde4c1d2801f 100644 --- a/core/java/android/text/TextUtils.java +++ b/core/java/android/text/TextUtils.java @@ -2091,6 +2091,25 @@ public class TextUtils { return (T) text.subSequence(0, size); } + /** + * Trims the {@code text} to the first {@code size} characters and adds an ellipsis if the + * resulting string is shorter than the input. This will result in an output string which is + * longer than {@code size} for most inputs. + * + * @param size length of the result, should be greater than 0 + * + * @hide + */ + @Nullable + public static <T extends CharSequence> T trimToLengthWithEllipsis(@Nullable T text, + @IntRange(from = 1) int size) { + T trimmed = trimToSize(text, size); + if (trimmed.length() < text.length()) { + trimmed = (T) (trimmed.toString() + "..."); + } + return trimmed; + } + private static Object sLock = new Object(); private static char[] sTemp = null; |
