ADB Shell View System properties (used to determine a particular operating system)

Source: Internet
Author: User

In general, it is necessary to determine the device type and system version in the development of Android programs. 1, equipment type judgmentFor example, the judgment belongs to Google Nexus 5,nexus 7,MIUI V5, MIUI V6, Samsung devices, Meizu devices, etc. This type of problem is used by Android.os.Build.MODEL to judge that Android.os.Build.MODEL is a string variable that can determine what device the Android device belongs to based on some special fields in the string, such as determining the Nexus 7, code into public static Boolean isN7 () {
Return "Nexus 7". Equals (Android.os.Build.MODEL);
So usually in the development process if you do not know the model value of a device, write a test program output Android.os.Build.MODEL value, and then use this value in my program to participate in the judgment. 2. System version judgment (API version)For example, the judgment system belongs to 2.3, 3.0, 4.4, 5.0, etc., this attribute is judged using the system's Android.os.Build.VERSION.SDK_INT variable. The most common scenario is the API version used to determine some of the system functions, for example, some methods only have a higher version of the API, the use of the lower version will cause the program to crash. But there is another scenario that leads to a third way to fix the usage scenario: most of the operating systems are open-source, and Google's Android is the default, but don't forget the Meizu flyme OS and Xiaomi Miui, which are variants of Android. If using non-Xiaomi mobile phone also installed MIUI, the latter is non-Meizu mobile phone installed Meizu FlyMe OS, this situation how to judge it. Take Meizu: Obviously this time can not be used to determine the type of device, because the non-Meizu device installed Meizu system. So this time can only judge this operating system is Meizu FlyMe OS, its operating system should have some of its own features, so as long as you find a unique feature can solve the above problem. 3, Judge the special operating system---Get the system properties to study (Meizu as an example)Enter the ADB shell to get the Meizu system properties:
    • First enter CMD and enter the ADB shell command into the ADB shell (provided that the ADB must be configured in the system environment variable)
C:\users\administrator> adb Shell
[Email protected]:/$
    • Go to the System directory
[Email protected]:/$ CD System
CD system
[Email Protected]:/system $
    • Viewing System Properties
[Email Protected]:/system $ Cat Build.prop
Cat Build.prop
# Begin Build Properties
# Autogenerated by flyme_os_4. ..... There's a lot more.
    • Filter for attributes that contain flyme characters because, since it is a Meizu operating system, the word flyme is most representative of its properties
[Email Protected]:/system $ Cat Build.prop | grep Flyme
Cat Build.prop | grep Flyme flyme_os_4. OS 4.4.4 ktu84p m76. flyme_os_4.
2124636 Release-keys flyme_os_4.2.2.1
[Email Protected]:/system $ Handsome Select to four properties:
    • For a different installation of the Meizu OS device, repeat the above steps. Eventually it will be found that the attribute can be used as the only feature of a Meizu operating system (since this attribute value will almost contain the FlyMe field, which is exactly what we want). We can use this attribute to distinguish it from other systems.
    • The final step, of course, is how to take out this attribute value.
Judge is the Meizu operating system public static Boolean Ismeizuflymeos () {
Return Getmeizuflymeosflag (). toLowerCase (). Contains ("FlyMe");
} /**
* Get Meizu system operation version ID
public static String Getmeizuflymeosflag () {
Return Getsystemproperty ("", "" ");
} private static string Getsystemproperty (string key, string defaultvalue) {
try {
class<?> CLZ = Class.forName (" android.os.SystemProperties");
Method get = Clz.getmethod ("Get", String.class, String.class);
Return (String) Get.invoke (CLZ, Key, DefaultValue);
} catch (ClassNotFoundException e) {
} catch (Nosuchmethodexception e) {
} catch (Illegalaccessexception e) {
} catch (IllegalArgumentException e) {
} catch (InvocationTargetException e) {
return defaultvalue;
The following are some methods of Xiaomi operating system/**
* Get MIUI version name
public static String Getmiuiversionname () {
Return Getsystemproperty ( "", null);
}//MIUI V5 version public static Boolean isV5 () {
if ("V5". Equalsignorecase (Getmiuiversionname ())) {
return true;
return false;

ADB Shell View System properties (used to determine a particular operating system)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.