Skip to content Skip to sidebar Skip to footer

Does Android Have Any Way To Detect Cyanogenmod And Its Version?

I'm working on an android media player which needs equalizer. However, equalizer is only available on Gingerbread and above, but cyanogenmod 6 has modified audioflinger to act as e

Solution 1:

You can read the os.version property and match against that:

Stringversion= System.getProperty("os.version");
if (version.contains("cyanogenmod")) {
    isCyanogenMode = true;
}

On my device, os.version is 2.6.37.6-cyanogenmod-01509-g8913be8.

Solution 2:

As of today, cyanogenmod's kernel does not contain cyanogenmod keyword in System.getProperty("os.version"); It is something like 3.0.64-CM-g9d16c8a. So I wrote this function.

privatebooleanisCyanogenMod(PackageManager pm) {
    booleanisCyanogenMod=false;
    Stringversion= System.getProperty("os.version");
    BufferedReaderreader=null;

    try {
        if (version.contains("cyanogenmod") || pm.hasSystemFeature("com.cyanogenmod.android")) {
            isCyanogenMod = true;
        }
        else {                
            // This does not require root
            reader = newBufferedReader(newFileReader("/proc/version"), 256);
            version = reader.readLine();

            if (version.contains("cyanogenmod")) {
                isCyanogenMod = true;
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    finally {
        if(reader != null) {
            try { reader.close(); } catch (IOException e) { }
        }
    }

    return isCyanogenMod;
}

Solution 3:

Well this is an old question, but I have recently come up with a better solution I believe.

publicstaticboolean isCyanogenMod() {
    try {
        returnClass.forName("cyanogenmod.os.Build") != null;
    } catch (Exception ignored) {
    }
    returnfalse;
}

Post a Comment for "Does Android Have Any Way To Detect Cyanogenmod And Its Version?"