Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d2961355 authored by Dan Sandler's avatar Dan Sandler Committed by Android (Google) Code Review
Browse files

Merge "Notification: Limit length of accepted strings" into lmp-dev

parents a4490181 535ec616
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -129,6 +129,14 @@ public class Notification implements Parcelable

    public static final int DEFAULT_LIGHTS = 4;

    /**
     * Maximum length of CharSequences accepted by Builder and friends.
     *
     * <p>
     * Avoids spamming the system with overly large strings such as full e-mails.
     */
    private static final int MAX_CHARSEQUENCE_LENGTH = 5 * 1024;

    /**
     * A timestamp related to this notification, in milliseconds since the epoch.
     *
@@ -1429,6 +1437,10 @@ public class Notification implements Parcelable
     * @hide
     */
    public static CharSequence safeCharSequence(CharSequence cs) {
        if (cs == null) return cs;
        if (cs.length() > MAX_CHARSEQUENCE_LENGTH) {
            cs = cs.subSequence(0, MAX_CHARSEQUENCE_LENGTH);
        }
        if (cs instanceof Parcelable) {
            Log.e(TAG, "warning: " + cs.getClass().getCanonicalName()
                    + " instance is a custom Parcelable and not allowed in Notification");