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

Commit ff701a6a authored by Torne (Richard Coles)'s avatar Torne (Richard Coles)
Browse files

Parse system properties that are lists correctly.

String.split() returns a one-element array of the empty string if the
input is the empty string, not a zero-element array. Introduce a
getStringList function to handle this consistently in the cases where
system properties are parsed as comma separated lists.

The main result is that SUPPORTED_64_BIT_ABIS will now correctly be
empty on a 32-bit only device.

Change-Id: I6f74b48d0a6ced3cd6d49c05aad6a4b7e0b074d2
parent 6c9eee87
Loading
Loading
Loading
Loading
+13 −5
Original line number Original line Diff line number Diff line
@@ -96,8 +96,7 @@ public class Build {
     *
     *
     * See {@link #SUPPORTED_32_BIT_ABIS} and {@link #SUPPORTED_64_BIT_ABIS}.
     * See {@link #SUPPORTED_32_BIT_ABIS} and {@link #SUPPORTED_64_BIT_ABIS}.
     */
     */
    public static final String[] SUPPORTED_ABIS = SystemProperties.get("ro.product.cpu.abilist")
    public static final String[] SUPPORTED_ABIS = getStringList("ro.product.cpu.abilist", ",");
            .split(",");


    /**
    /**
     * An ordered list of <b>32 bit</b> ABIs supported by this device. The most preferred ABI
     * An ordered list of <b>32 bit</b> ABIs supported by this device. The most preferred ABI
@@ -106,7 +105,7 @@ public class Build {
     * See {@link #SUPPORTED_ABIS} and {@link #SUPPORTED_64_BIT_ABIS}.
     * See {@link #SUPPORTED_ABIS} and {@link #SUPPORTED_64_BIT_ABIS}.
     */
     */
    public static final String[] SUPPORTED_32_BIT_ABIS =
    public static final String[] SUPPORTED_32_BIT_ABIS =
            SystemProperties.get("ro.product.cpu.abilist32").split(",");
            getStringList("ro.product.cpu.abilist32", ",");


    /**
    /**
     * An ordered list of <b>64 bit</b> ABIs supported by this device. The most preferred ABI
     * An ordered list of <b>64 bit</b> ABIs supported by this device. The most preferred ABI
@@ -115,7 +114,7 @@ public class Build {
     * See {@link #SUPPORTED_ABIS} and {@link #SUPPORTED_32_BIT_ABIS}.
     * See {@link #SUPPORTED_ABIS} and {@link #SUPPORTED_32_BIT_ABIS}.
     */
     */
    public static final String[] SUPPORTED_64_BIT_ABIS =
    public static final String[] SUPPORTED_64_BIT_ABIS =
            SystemProperties.get("ro.product.cpu.abilist64").split(",");
            getStringList("ro.product.cpu.abilist64", ",");




    /** Various version strings. */
    /** Various version strings. */
@@ -155,7 +154,7 @@ public class Build {
        public static final String CODENAME = getString("ro.build.version.codename");
        public static final String CODENAME = getString("ro.build.version.codename");


        private static final String[] ALL_CODENAMES
        private static final String[] ALL_CODENAMES
                = getString("ro.build.version.all_codenames").split(",");
                = getStringList("ro.build.version.all_codenames", ",");


        /**
        /**
         * @hide
         * @hide
@@ -614,6 +613,15 @@ public class Build {
        return SystemProperties.get(property, UNKNOWN);
        return SystemProperties.get(property, UNKNOWN);
    }
    }


    private static String[] getStringList(String property, String separator) {
        String value = SystemProperties.get(property);
        if (value.isEmpty()) {
            return new String[0];
        } else {
            return value.split(separator);
        }
    }

    private static long getLong(String property) {
    private static long getLong(String property) {
        try {
        try {
            return Long.parseLong(SystemProperties.get(property));
            return Long.parseLong(SystemProperties.get(property));