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