How to get the custom ROM/Android OS Name from Android programatically

785 Views Asked by At

I wish to receive the custom ROM/Android OS name from device e.g. Let’s say if device is:

Oppo -> ColorOS

OnePlus -> OxygenOS

Huawei -> HarmonyOS

I've used the following methods also, but no success.

Build.DISPLAY -> ONEPLUS A6003_22_201116

Build.VERSION.BASE_OS -> "" // returns empty string

System.getProperty("os.name") -> Linux

System.getProperty("os.version") -> 4.9.179-perf+

System.getProperty("ro.modversion") -> null // returns null

1

There are 1 best solutions below

0
On

You can use the following method to check and get HarmonyOS:

public static boolean isHarmony(Context context) {
    try {
        int id = Resources.getSystem().getIdentifier("config_os_brand", "string", "android");
        return context.getString(id).equals("harmony");
    } catch (Exception e) {
        return false;
    }
}