4

I have checked a lot of fields from http://developer.android.com/reference/android/os/Build.html .

However I am not able to get clearly information that specific device use CyanogenMod.

this is what I get:

NETWORK_TYPE="0"
SDK_INT="10"
CODENAME="REL"
INCREMENTAL="eng.android.20110308.014205"
RELEASE="2.3.3"
SDK="10"
Build.BOARD=bravo
BOOTLOADER=0.93.0001
BRAND=htc_wwe
CPU_ABI=armeabi-v7a
CPU_ABI2=armeabi
DEVICE=bravo
DISPLAY=GRI40
FINGERPRINT=htc_wwe/htc_bravo/bravo/bravo:2.2/FRF91/226611:user/release-keys
HARDWARE=bravo
HOST=giulio-desktop
ID=FRF91
MANUFACTURER=HTC
MODEL=HTC Desire
PRODUCT=htc_bravo
RADIO=unknown
TAGS=release-keys
TIME=0
TYPE=userdebug
USER=android

NETWORK_TYPE="0"
SDK_INT="10"
CODENAME="REL"
INCREMENTAL="eng.shade.20110307.195429"
RELEASE="2.3.3"
SDK="10"
Build.BOARD=mahimahi
BOOTLOADER=0.35.0017
BRAND=google
CPU_ABI=armeabi-v7a
CPU_ABI2=armeabi
DEVICE=passion
DISPLAY=GRI40
FINGERPRINT=google/passion/passion:2.3.3/GRI40/102588:user/release-keys
HARDWARE=mahimahi
HOST=toxygene
ID=GRI40
MANUFACTURER=HTC
MODEL=Nexus One
PRODUCT=passion
RADIO=unknown
TAGS=test-keys
TIME=0
TYPE=user
USER=shade
noisy
  • 6,495
  • 10
  • 50
  • 92

5 Answers5

6

PackageManager.hasSystemFeature("com.cyanogenmod.android") will be more consistent.

Oasis Feng
  • 7,490
  • 3
  • 31
  • 44
3

It's a lot easier to read it from the system properties:

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

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

Alternatively, you could also rely on the Build.USER constant, which carries the name of the person who assembled the build. For CyanogenMod, this is often "shade" (another nickname of Steve Kondik aka Cyanogen).

There is also a special property ro.modversion, but as far as I can see you would need access to the SystemProperties internal class in order to read it programmatically.

mxk
  • 43,056
  • 28
  • 105
  • 132
1

On my device System.getProperty("os.version") is something like 3.0.64-CM-g9d16c8a. Checking for cyanogenmod in the version number does not work anymore. I have added more details in this post.

Community
  • 1
  • 1
kakopappa
  • 5,023
  • 5
  • 54
  • 73
0

The kernel gets swapped out all the time by end users so using System.getProperty("os.version") or reading from /proc/version are not good indicators of whether the device is running cyanogenmod. Let me rephrase, using those solely as the indicator is not a good idea. You'll need to use a combination of methods. As @kakopappa indicated in his other post where he reads os.version and /proc/version you should also check

android.os.Build.HOST

From my experience that has contained cyanogenmod in it 9 times out of 10. Just to be safe you'll want to use the other methods as well though since the HOST variable could be changed via build.prop -> ro.build.host

Daniel Ochoa
  • 1,792
  • 1
  • 16
  • 22
0

The easiest way which I found is to read file /proc/version, which contain information about kernel version.

Phones with cyanogenmod give something like:

Linux version 2.6.37.2-cyanogenmod-01149-g8cdf03e

reading this file not requires root privileges (runnung uname -r does).

noisy
  • 6,495
  • 10
  • 50
  • 92
  • This isn't the most robust answer as anyone can change out their kernel which would cause this answer to fail. – Daniel Ochoa Dec 22 '14 at 20:32
  • I get this error when I try to read `/proc/version` on Android 9: `java.io.FileNotFoundException: /proc/version (Permission denied)` – Sam Feb 07 '20 at 23:29