当前位置: 动力学知识库 > 问答 > 编程问答 >

android - How to recognize that CyanogenMod is on a board?

问题描述:

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

网友答案:

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

网友答案:

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.

网友答案:

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.

网友答案:

Th following code will work. I have tested it.

public static boolean isCyanogenMod() {
    try {
        return Class.forName("cyanogenmod.os.Build") != null;
    } catch (Exception ignored) {}

    return false;
}
网友答案:

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).

网友答案:

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

分享给朋友:
您可能感兴趣的文章:
随机阅读: