android.os.Build 常用常量

在做項目的時候,經常需要採集一些設備信息,但又不經常用,所以有時候會查詢需求滿足的接口是哪個,所以週末就針對此整理了一下

Build.ID; //Either a changelist number, or a label like "M4-rc20".
Build.DISPLAY; //A build ID string meant for displaying to the user(設置-關於手機-版本號)
Build.PRODUCT; //The name of the overall product.(整個產品的名稱)
Build.DEVICE; //The name of the industrial design.(工業設計名稱--設備名稱)
Build.BOARD; //The name of the underlying board, like "goldfish".(主板名稱)
Build.MANUFACTURER; //The manufacturer of the product/hardware.(硬件製造商)
Build.BRAND; //The consumer-visible brand with which the product/hardware will be associated, if any.(設備品牌)
Build.MODEL; //The end-user-visible name for the end product.(終端用戶可見的設備型號)
Build.BOOTLOADER; //The system bootloader version number.(系統程序的版本號)
Build.HARDWARE; // The name of the hardware (from the kernel command line or /proc).(硬件名稱)
Build.SERIAL; // A hardware serial number, if available.Alphanumeric only, case-insensitive.(硬件序列號)
Build.TYPE; //The type of build, like "user" or "eng".(設備版本類型)
Build.TAGS; //Comma-separated tags describing the build, like "unsigned,debug".(設備標籤,未簽名/測試)
/** A string that uniquely identifies this build.  Do not attempt to parse this value.
         * 設備唯一標示,是由build的多個設備信息拼接而成
         * getString("ro.product.brand") + '/' +//BRAND
         * getString("ro.product.name") + '/' +//PRODUCT
         * getString("ro.product.device") + ':' +//DEVICE
         * getString("ro.build.version.release") + '/' +//VERSION.RELEASE
         * getString("ro.build.id") + '/' +//ID
         * getString("ro.build.version.incremental") + ':' +//VERSION.INCREMENTAL
         * getString("ro.build.type") + '/' +//TYPE
         * getString("ro.build.tags")
         * */
Build.FINGERPRINT;

// The following properties only make sense for internal engineering builds.
//主要for工程師調試版本
Build.HOST;
Build.USER;
Build.TIME;

Build.VERSION.INCREMENTAL; //The internal value used by the underlying source control to represent this build.E.g., a perforce changelist number or a git hash.
Build.VERSION.SDK_INT; //The user-visible SDK version of the framework;
  * its possible  values are defined in {@link Build.VERSION_CODES}.
Build.VERSION.CODENAME //The current development codename, or the string "REL" if this is a release build.
Build.VERSION.RELEASE; //The user-visible version string.  E.g., "1.0" or "3.4b5". (Android SDK version)
Build.VERSION.BASE_OS; //The base OS build the product is based on.

補充,Build.TYPE返回結果表示:

user表示用戶版,有限的訪問權限,適合product環境;adb默認是關閉的
userdebug,和user類似,具有root和debug權限;
eng 表示工程師版, 可調試;adb默認是打開的

看英文描述有時候並不能確定返回的值是否滿足自己的需求,故針對此寫了測試用例,查看了返回結果,針對結果看描述就會更清楚其表達

keygoogle nexus5小米6 原生系統小米3 MIUI系統
android.os.Build#IDM4B30ZOPR1.170623.027MMB29M
android.os.Build#DISPLAYM4B30Zsagit-eng 8.0.0 OPR1.170623.027 2017.12.20_aosp-debug test-keysMMB29M test-keys
android.os.Build#PRODUCThammerheadsagitcancro
android.os.Build#DEVICEhammerheadsagitcancro
android.os.Build#BOARDhammerheadmsm8998MSM8974
android.os.Build#MANUFACTURERLGEXiaomiXiaomi
android.os.Build#BRANDgoogleXiaomiXiaomi
android.os.Build#MODELNexus 5MI 6MI 3W
android.os.Build#BOOTLOADERHHZ20hunknownunknown
android.os.Build#HARDWAREhammerheadqcomqcom
android.os.Build#SERIAL037abc3e09318c78c3b4ba0d584db4
android.os.Build#TYPEuserenguser
android.os.Build#TAGSrelease-keystest-keystest-keys
android.os.Build#FINGERPRINTgoogle/hammerhead/hammerhead:6.0.1/M4B30Z/3437181:user/release-keysXiaomi/sagit/sagit:8.0.0/OPR1.170623.027/2017.12.20_aosp-debug:eng/test-keysXiaomi/cancro/cancro:6.0.1/MMB29M/7.12.16:user/test-keys
android.os.Build#HOSTwpdu6.hot.corp.google.comc3-miui-sdk-fe01.bjc3-miui-ota-bd122.bj
android.os.Build#USERandroid-buildworkbuilder
android.os.Build#TIME47820342200015137379700001513410304000
android.os.Build#VERSION.INCREMENTAL34371812017.12.20_aosp-debug7.12.16
android.os.Build#VERSION.SDK_INT232623
android.os.Build#VERSION.CODENAMERELRELREL
android.os.Build#VERSION.RELEASE6.0.18.0.06.0.1
android.os.Build#VERSION.BASE_OS   

上述數據源log打印數據如下

12-23 12:56:32.511 I/android.os.Build#ID: (29436): M4B30Z
12-23 12:56:32.511 I/android.os.Build#DISPLAY: (29436): M4B30Z
12-23 12:56:32.511 I/android.os.Build#PRODUCT: (29436): hammerhead
12-23 12:56:32.511 I/android.os.Build#DEVICE: (29436): hammerhead
12-23 12:56:32.511 I/android.os.Build#BOARD: (29436): hammerhead
12-23 12:56:32.511 I/android.os.Build#MANUFACTURER: (29436): LGE
12-23 12:56:32.511 I/android.os.Build#BRAND: (29436): google
12-23 12:56:32.511 I/android.os.Build#MODEL: (29436): Nexus 5
12-23 12:56:32.511 I/android.os.Build#BOOTLOADER: (29436): HHZ20h
12-23 12:56:32.511 I/android.os.Build#HARDWARE: (29436): hammerhead
12-23 12:56:32.511 I/android.os.Build#SERIAL: (29436): 037abc3e09318c78
12-23 12:56:32.511 I/android.os.Build#TYPE: (29436): user
12-23 12:56:32.511 I/android.os.Build#TAGS: (29436): release-keys
12-23 12:56:32.511 I/android.os.Build#FINGERPRINT: (29436): google/hammerhead/hammerhead:6.0.1/M4B30Z/3437181:user/release-keys
12-23 12:56:32.511 I/android.os.Build#HOST: (29436): wpdu6.hot.corp.google.com
12-23 12:56:32.511 I/android.os.Build#USER: (29436): android-build
12-23 12:56:32.512 I/android.os.Build#TIME: (29436): 1478203422000
12-23 12:56:32.512 I/android.os.Build#VERSION.INCREMENTAL: (29436): 3437181
12-23 12:56:32.512 I/android.os.Build#VERSION.SDK_INT: (29436): 23
12-23 12:56:32.512 I/android.os.Build#VERSION.CODENAME: (29436): REL
12-23 12:56:32.512 I/android.os.Build#VERSION.RELEASE: (29436): 6.0.1
12-23 05:18:00.959 I/android.os.Build#ID: (10108): OPR1.170623.027
12-23 05:18:00.959 I/android.os.Build#DISPLAY: (10108): sagit-eng 8.0.0 OPR1.170623.027 2017.12.20_aosp-debug test-keys
12-23 05:18:00.959 I/android.os.Build#PRODUCT: (10108): sagit
12-23 05:18:00.959 I/android.os.Build#DEVICE: (10108): sagit
12-23 05:18:00.960 I/android.os.Build#BOARD: (10108): msm8998
12-23 05:18:00.960 I/android.os.Build#MANUFACTURER: (10108): Xiaomi
12-23 05:18:00.960 I/android.os.Build#BRAND: (10108): Xiaomi
12-23 05:18:00.960 I/android.os.Build#MODEL: (10108): MI 6
12-23 05:18:00.960 I/android.os.Build#BOOTLOADER: (10108): unknown
12-23 05:18:00.960 I/android.os.Build#HARDWARE: (10108): qcom
12-23 05:18:00.960 I/android.os.Build#SERIAL: (10108): c3b4ba0d
12-23 05:18:00.960 I/android.os.Build#TYPE: (10108): eng
12-23 05:18:00.960 I/android.os.Build#TAGS: (10108): test-keys
12-23 05:18:00.960 I/android.os.Build#FINGERPRINT: (10108): Xiaomi/sagit/sagit:8.0.0/OPR1.170623.027/2017.12.20_aosp-debug:eng/test-keys
12-23 05:18:00.960 I/android.os.Build#HOST: (10108): c3-miui-sdk-fe01.bj
12-23 05:18:00.960 I/android.os.Build#USER: (10108): work
12-23 05:18:00.960 I/android.os.Build#TIME: (10108): 1513737970000
12-23 05:18:00.960 I/android.os.Build#VERSION.INCREMENTAL: (10108): 2017.12.20_aosp-debug
12-23 05:18:00.960 I/android.os.Build#VERSION.SDK_INT: (10108): 26
12-23 05:18:00.960 I/android.os.Build#VERSION.CODENAME: (10108): REL
12-23 05:18:00.960 I/android.os.Build#VERSION.RELEASE: (10108): 8.0.0
12-23 05:18:00.960 I/android.os.Build#VERSION.BASE_OS: (10108): 
12-23 12:55:05.725 I/android.os.Build#ID: (16606): MMB29M
12-23 12:55:05.725 I/android.os.Build#DISPLAY: (16606): MMB29M test-keys
12-23 12:55:05.725 I/android.os.Build#PRODUCT: (16606): cancro
12-23 12:55:05.725 I/android.os.Build#DEVICE: (16606): cancro
12-23 12:55:05.725 I/android.os.Build#BOARD: (16606): MSM8974
12-23 12:55:05.725 I/android.os.Build#MANUFACTURER: (16606): Xiaomi
12-23 12:55:05.725 I/android.os.Build#BRAND: (16606): Xiaomi
12-23 12:55:05.725 I/android.os.Build#MODEL: (16606): MI 3W
12-23 12:55:05.725 I/android.os.Build#BOOTLOADER: (16606): unknown
12-23 12:55:05.725 I/android.os.Build#HARDWARE: (16606): qcom
12-23 12:55:05.725 I/android.os.Build#SERIAL: (16606): 584db4
12-23 12:55:05.725 I/android.os.Build#TYPE: (16606): user
12-23 12:55:05.725 I/android.os.Build#TAGS: (16606): test-keys
12-23 12:55:05.725 I/android.os.Build#FINGERPRINT: (16606): Xiaomi/cancro/cancro:6.0.1/MMB29M/7.12.16:user/test-keys
12-23 12:55:05.725 I/android.os.Build#HOST: (16606): c3-miui-ota-bd122.bj
12-23 12:55:05.725 I/android.os.Build#USER: (16606): builder
12-23 12:55:05.725 I/android.os.Build#TIME: (16606): 1513410304000
12-23 12:55:05.727 I/android.os.Build#VERSION.INCREMENTAL: (16606): 7.12.16
12-23 12:55:05.727 I/android.os.Build#VERSION.SDK_INT: (16606): 23
12-23 12:55:05.727 I/android.os.Build#VERSION.CODENAME: (16606): REL
12-23 12:55:05.727 I/android.os.Build#VERSION.RELEASE: (16606): 6.0.1

轉自:https://blog.csdn.net/dzkdxyx/article/details/78879521




發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章