• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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  - The standard system uses RK3568 as an example. Adapt the RK3568 in `/vendor/hihope/rk3568/etc/para/hardware_rk3568.para` and install it in 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  - For the mini and small systems, configure the parameters in the `hals/utils/sys_param/vendor.para` file of the corresponding product. 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
100Currently, three ways are provided to obtain vendor dynamic-value parameters: cmdline, macro definition, and **BUILD.gn** definition.
101
1021. 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   - For standard-system devices, **Serial** is read from **ohos.boot.sn**.
105
106     The value of **ohos.boot.sn** is read from cmdline (generated by U-Boot). If an SN is obtained, the value is directly read; if a 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`.
107
108   - For mini- and small-system devices, they 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.
109
1102. Macro definition: Obtain parameter values by compiling macro definitions. Currently, this mode is available only for mini- and small-system devices. For example:
111
112     ```
113     defines = [
114         "INCREMENTAL_VERSION=\"${ohos_version}\"",
115         "BUILD_TYPE=\"${ohos_build_type}\"",
116         "BUILD_USER=\"${ohos_build_user}\"",
117         "BUILD_TIME=\"${ohos_build_time}\"",
118         "BUILD_HOST=\"${ohos_build_host}\"",
119         "BUILD_ROOTHASH=\"${ohos_build_roothash}\"",
120     ]
121     ```
1223. `BUILD.gn` definition: Obtain parameter values from the `/base/startup/init/services/etc/BUILD.gn` file. For example:
123
124     ```
125     if (target_cpu == "arm64") {
126         extra_paras += [ "const.product.cpu.abilist=arm64-v8a" ]
127     }
128     if (build_variant == "user") {
129         extra_paras += [
130             "const.secure=1",
131             "const.debuggable=0",
132         ]
133     } else if (build_variant == "root") {
134         extra_paras += [
135             "const.secure=0",
136             "const.debuggable=1",
137         ]
138     }
139     if (device_type != "default") {
140         extra_paras += [
141             "const.product.devicetype=${device_type}",
142             "const.build.characteristics=${device_type}",
143         ]
144     }
145     module_install_dir = "etc/param"
146
147     ```
148#### Notes
149
1501. For small-system devices, add the compilation of `vendor.para` to the `hals/utils/sys_param/BUILD.gn` file.
151
152      ```
153      copy("vendor.para") {
154          sources = [ "./vendor.para" ]
155          outputs = [ "$root_out_dir/vendor/etc/param/vendor.para" ]
156      }
157      ```
158
1592. 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.
160