Loading core/java/android/app/NotificationChannel.java +27 −0 Original line number Diff line number Diff line Loading @@ -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; /** Loading Loading @@ -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{" Loading core/java/android/text/TextUtils.java +19 −0 Original line number Diff line number Diff line Loading @@ -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; Loading core/tests/coretests/src/android/text/TextUtilsTest.java +7 −0 Original line number Diff line number Diff line Loading @@ -785,4 +785,11 @@ public class TextUtilsTest { assertEquals(2, TextUtils.length(" ")); assertEquals(6, TextUtils.length("Hello!")); } @Test public void testTrimToLengthWithEllipsis() { assertEquals("ABC...", TextUtils.trimToLengthWithEllipsis("ABCDEF", 3)); assertEquals("ABC", TextUtils.trimToLengthWithEllipsis("ABC", 3)); assertEquals("", TextUtils.trimToLengthWithEllipsis("", 3)); } } services/core/java/com/android/server/notification/RankingHelper.java +1 −3 Original line number Diff line number Diff line Loading @@ -1173,9 +1173,7 @@ public class RankingHelper implements RankingConfig { pw.println(); for (NotificationChannel channel : r.channels.values()) { pw.print(prefix); pw.print(" "); pw.print(" "); pw.println(channel); channel.dump(pw, " ", filter.redact); } for (NotificationChannelGroup group : r.groups.values()) { pw.print(prefix); Loading Loading
core/java/android/app/NotificationChannel.java +27 −0 Original line number Diff line number Diff line Loading @@ -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; /** Loading Loading @@ -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{" Loading
core/java/android/text/TextUtils.java +19 −0 Original line number Diff line number Diff line Loading @@ -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; Loading
core/tests/coretests/src/android/text/TextUtilsTest.java +7 −0 Original line number Diff line number Diff line Loading @@ -785,4 +785,11 @@ public class TextUtilsTest { assertEquals(2, TextUtils.length(" ")); assertEquals(6, TextUtils.length("Hello!")); } @Test public void testTrimToLengthWithEllipsis() { assertEquals("ABC...", TextUtils.trimToLengthWithEllipsis("ABCDEF", 3)); assertEquals("ABC", TextUtils.trimToLengthWithEllipsis("ABC", 3)); assertEquals("", TextUtils.trimToLengthWithEllipsis("", 3)); } }
services/core/java/com/android/server/notification/RankingHelper.java +1 −3 Original line number Diff line number Diff line Loading @@ -1173,9 +1173,7 @@ public class RankingHelper implements RankingConfig { pw.println(); for (NotificationChannel channel : r.channels.values()) { pw.print(prefix); pw.print(" "); pw.print(" "); pw.println(channel); channel.dump(pw, " ", filter.redact); } for (NotificationChannelGroup group : r.groups.values()) { pw.print(prefix); Loading