1# DeviceInfo Adaptation 2 3## DeviceInfo parameters and mapping APIs 4 5| Parameter| API| Description| 6|----------|------- |------| 7| const.product.devicetype | const char\* GetDeviceType(void) | Obtains the device type.| 8| const.product.manufacturer | const char\* GetManufacture(void) | Obtains the device manufacturer.| 9| const.product.brand | const char\* GetBrand(void) | Obtains the device brand.| 10| const.product.name | const char\* GetMarketName(void) | Obtains the device marketing name.| 11| const.build.product | const char\* GetProductSeries(void) | Obtains the device series name.| 12| const.product.model | const char\* GetProductModel(void) | Obtains the device authentication model.| 13| const.software.model | const char\* GetSoftwareModel(void) | Obtains the device software model.| 14| const.product.hardwareversion | const char\* GetHardwareModel(void) | Obtains the device hardware model.| 15| const.product.hardwareprofile | const char\* GetHardwareProfile(void) | Obtains the device hardware profile.| 16| ohos.boot.sn | const char\* GetSerial(void) | Obtains the serial number (SN) of the device.| 17| const.product.software.version | const char\* GetDisplayVersion(void) | Obtains the software version visible to users.| 18| const.product.bootloader.version | const char\* GetBootloaderVersion(void) | Obtains the bootloader version of the device.| 19| const.product.udid | int GetDevUdid(char \*udid, int size) | Obtains the UDID of the device through **DeviceInfo** or through calculation if the attempt to obtain the UDID through **DeviceInfo** fails.| 20| | const char *AclGetSerial(void); | Obtains the SN of the device (with ACL check).| 21| | int AclGetDevUdid(char *udid, int size); | Obtains the UDID of the device (with ACL check).| 22 23## DeviceInfo Source 24 25### Adaptation of OHOS Fixed-value Parameters 26 27- OHOS fixed-value parameters: 28 29 ``` 30 const.ohos.version.security_patch 31 const.ohos.releasetype 32 const.ohos.apiversion 33 const.ohos.fullname 34 ``` 35 36- Description of adaptation: 37 38 OHOS fixed-value parameters are filled by the OHOS and do not need to be adapted by vendors. Currently, these parameters are defined in the **/base/startup/init/services/etc/param/ohos_const/ohos.para** file. 39 40### Adaptation of Vendor Fixed-value Parameters 41 42- Vendor fixed-value parameters: 43 44 ``` 45 const.product.devicetype 46 const.product.manufacturer 47 const.product.brand 48 const.product.name 49 const.build.product 50 const.product.model 51 const.software.model 52 const.product.hardwareversion 53 const.product.hardwareprofile 54 const.product.software.version 55 const.product.bootloader.version 56 const.build.characteristics 57 ... ... 58 59 ``` 60 61 62- Description of adaptation: 63 64 Adapt parameters in the **vendor** directory based on actual requirements. 65 66 (1) Take RK3568 as an example for standard-system devices. Adapt parameters in the **/vendor/hihope/rk3568/etc/para/hardware_rk3568.para** file and install the file to the specified directory. 67 68 ``` 69 ohos_prebuilt_etc("para_for_chip_prod") { 70 source = "./para/hardware_rk3568.para" 71 install_images = [ chip_prod_base_dir ] 72 relative_install_dir = "para" 73 part_name = "product_rk3568" 74 } 75 ``` 76 77 (2) For mini- and small-system devices, adapt parameters in the respective **hals/utils/sys_param/vendor.para** file. For example: 78 79 ``` 80 const.product.manufacturer=Talkweb 81 82 const.product.brand=Talkweb 83 84 const.product.name=Niobe 85 86 const.build.product=Niobe 87 88 const.product.model=Niobe407 89 90 const.software.model="2.0.0" 91 92 const.product.hardwareversion="1.0.0" 93 94 const.product.hardwareprofile="RAM:192K,ROM:1M,ETH:true" 95 ... ... 96 ``` 97 98### Adaptation of Vendor Dynamic-value Parameters 99 100- Currently, three ways are provided to obtain vendor dynamic-value parameters: cmdline, macro definition, and **BUILD.gn** definition. 101 102 1. cmdline: Values that are read from cmdline include **ohos.boot.hardware**, **ohos.boot.bootslots**, and **ohos.boot.sn**. The way to obtain **ohos.boot.sn** differs according to the system type as follows: 103 104 (1) For standard-system devices: **ohos.boot.sn** is read from cmdline (generated by U-Boot). If the SN is obtained, the value is directly read; if the file path is obtained, the value is read from the file. If the preceding attempt fails, the value is read from the default SN files; that is, **/sys/block/mmcblk0/device/cid** and **/proc/bootdevice/cid**. 105 106 (2) For mini- and small-system devices: These devices may come with their own special algorithms. Therefore, **HalGetSerial()** can be used to obtain the SN from the **hal_sys_param.c** file in the **hals/utils/sys_param** directory. 107 108 2. Macro definition: Obtain parameter values by compiling macro definitions. Currently, this mode is available only for mini- and small-system devices. For example: 109 110 ``` 111 defines = [ 112 "INCREMENTAL_VERSION=\"${ohos_version}\"", 113 "BUILD_TYPE=\"${ohos_build_type}\"", 114 "BUILD_USER=\"${ohos_build_user}\"", 115 "BUILD_TIME=\"${ohos_build_time}\"", 116 "BUILD_HOST=\"${ohos_build_host}\"", 117 "BUILD_ROOTHASH=\"${ohos_build_roothash}\"", 118 ] 119 ``` 120 121 3. **BUILD.gn** definition: Obtain parameter values from the **/base/startup/init/services/etc/BUILD.gn** file. For example: 122 123 ``` 124 if (target_cpu == "arm64") { 125 extra_paras += [ "const.product.cpu.abilist=arm64-v8a" ] 126 } 127 if (build_variant == "user") { 128 extra_paras += [ 129 "const.secure=1", 130 "const.debuggable=0", 131 ] 132 } else if (build_variant == "root") { 133 extra_paras += [ 134 "const.secure=0", 135 "const.debuggable=1", 136 ] 137 } 138 if (device_type != "default") { 139 extra_paras += [ 140 "const.product.devicetype=${device_type}", 141 "const.build.characteristics=${device_type}", 142 ] 143 } 144 module_install_dir = "etc/param" 145 } 146 ``` 147#### Notes 148 149 (1) For small-system devices, add the compilation of **vendor.para** to the **hals/utils/sys_param/BUILD.gn** file. 150 151 ``` 152 copy("vendor.para") { 153 sources = [ "./vendor.para" ] 154 outputs = [ "$root_out_dir/vendor/etc/param/vendor.para" ] 155 } 156 ``` 157 158 (2) For mini-system devices, a file system is not available and therefore, the **hal_sys_param.c** and **vendor.para** files are converted into header files and are compiled to the system during compilation. 159