Question

I'm writing an app that needs to distinguish between Android Stock ROM and other ROMs like SenseUI, etc.

How can I do that within my application?

Thanks.

Was it helpful?

Solution

I found that querying ro.product.brand using getprop yields exactly what I needed.

/**
 * Returns the ROM manufacturer.
 *
 * @return The ROM manufacturer, or NULL if not found.
 */
public static String getROMManufacturer() {
    String line;
    BufferedReader input = null;
    try {
        Process p = Runtime.getRuntime().exec("getprop ro.product.brand");
        input = new BufferedReader(new InputStreamReader(p.getInputStream()), 1024);
        line = input.readLine();
        input.close();
    }
    catch (IOException ex) {
        Log.e(TAG, "Unable to read sysprop ro.product.brand", ex);
        return null;
    }
    finally {
        if (input != null) {
            try {
                input.close();
            }
            catch (IOException e) {
                Log.e(TAG, "Exception while closing InputStream", e);
            }
        }
    }
    return line;
}

For stock ROMs the value we get back is google
For SenseUI for example, we will get back HTC

The above method will return the only google or HTC etc...

I hope it helped someone else as well.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top