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

Commit a3bf7c40 authored by Jeff DeCew's avatar Jeff DeCew
Browse files

Limit the length of the ShortCriticalText

Change-Id: I50d82bcbee3fd12667dea6acbf6e8b538b478c2b
Flag: android.app.api_rich_ongoing
Fixes: 383545301
Test: atest SystemUITests
parent 1a0781a5
Loading
Loading
Loading
Loading
+13 −1
Original line number Diff line number Diff line
@@ -3322,6 +3322,18 @@ public class Notification implements Parcelable
        }
    }
    /**
     * Make sure this String is safe to put into a bundle.
     * @hide
     */
    public static String safeString(String str) {
        if (str == null) return str;
        if (str.length() > MAX_CHARSEQUENCE_LENGTH) {
            str = str.substring(0, MAX_CHARSEQUENCE_LENGTH);
        }
        return str;
    }
    /**
     * Make sure this CharSequence is safe to put into a bundle, which basically
     * means it had better not be some custom Parcelable implementation.
@@ -5051,7 +5063,7 @@ public class Notification implements Parcelable
        @FlaggedApi(Flags.FLAG_API_RICH_ONGOING)
        @NonNull
        public Builder setShortCriticalText(@Nullable String shortCriticalText) {
            mN.extras.putString(EXTRA_SHORT_CRITICAL_TEXT, shortCriticalText);
            mN.extras.putString(EXTRA_SHORT_CRITICAL_TEXT, safeString(shortCriticalText));
            return this;
        }