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

Commit 6bf1cff1 authored by Andreas Gampe's avatar Andreas Gampe
Browse files

Frameworks: Add warning to SystemProperties.get

Add a warning that calling get() is unsafe when the system property
may not contain a valid UTF-encoded string.

Bug: 63177684
Test: m
Change-Id: I68e3096d770a32fe204be5c130a3ada9d3db7c0b
parent c283ba74
Loading
Loading
Loading
Loading
+13 −4
Original line number Diff line number Diff line
@@ -85,8 +85,12 @@ public class SystemProperties {
    private static native void native_report_sysprop_change();

    /**
     * Get the value for the given key.
     * @return an empty string if the key isn't found
     * Get the String value for the given {@code key}.
     *
     * <b>WARNING:</b> Do not use this method if the value may not be a valid UTF string! This
     * method will crash in native code.
     *
     * @return an empty string if the {@code key} isn't found
     */
    public static String get(String key) {
        if (TRACK_KEY_ACCESS) onKeyAccess(key);
@@ -94,8 +98,13 @@ public class SystemProperties {
    }

    /**
     * Get the value for the given key.
     * @return if the key isn't found, return def if it isn't null, or an empty string otherwise
     * Get the String value for the given {@code key}.
     *
     * <b>WARNING:</b> Do not use this method if the value may not be a valid UTF string! This
     * method will crash in native code.
     *
     * @return if the {@code key} isn't found, return {@code def} if it isn't null, or an empty
     * string otherwise
     */
    public static String get(String key, String def) {
        if (TRACK_KEY_ACCESS) onKeyAccess(key);