1# @ohos.deviceInfo (Device Information) 2 3The **deviceInfo** module provides terminal device information query, which cannot be configured by developers. 4 5> **NOTE** 6> 7> The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version. 8> Some parameters whose return value is the default value are not yet available. 9> The APIs of this module return information about device constants. You are not expected to call these APIs frequently. 10 11## Modules to Import 12 13```ts 14import { deviceInfo } from '@kit.BasicServicesKit'; 15``` 16 17## Constants 18> **NOTE** 19> Unless otherwise specified, the maximum data length is 96 bytes. 20 21**System capability**: SystemCapability.Startup.SystemInfo 22 23**Required permissions**: The items in the table below require different system capabilities. 24 25| Name| Type| Read-Only| Description| 26| -------- | -------- | -------- | -------- | 27| deviceType | string | Yes| Device type. For details, see [deviceTypes tag](../../quick-start/module-configuration-file.md#devicetypes).<br>**Atomic service API**: This API can be used in atomic services since API version 11.<br>Example: <!--RP1-->wearable<!--RP1End-->| 28| manufacture | string | Yes| Device manufacturer.<br>Example: HUAWEI| 29| brand | string | Yes| Device brand.<br>**Atomic service API**: This API can be used in atomic services since API version 11.<br>Example: HUAWEI| 30| marketName | string | Yes| Marketing name.<br>Example: <!--RP2-->Mate XX<!--RP2End--> | 31| productSeries | string | Yes| Product series.<br>Example: <!--RP3-->TAS<!--RP3End--> | 32| productModel | string | Yes| Product model.<br>**Atomic service API**: This API can be used in atomic services since API version 11.<br>Example: <!--RP4-->TAS-AL00<!--RP4End--> | 33| productModelAlias<sup>14+</sup> | string | Yes| Product model alias.<br>**Atomic service API**: This API can be used in atomic services since API version 14.<br>Example: TAS-AL00| 34| softwareModel | string | Yes| Software model.<br>Example: <!--RP5-->TAS-AL00<!--RP5End--> | 35| hardwareModel | string | Yes| Hardware model.<br>Example: <!--RP6-->TASA00CVN1<!--RP6End--> | 36| hardwareProfile<sup>(deprecated) </sup> | string | Yes| Hardware profile.<br>**NOTE**<br>This API is supported since API version 6 and deprecated since API version 9.<br>Example: default| 37| serial | string | Yes| Device serial number (SN).<br>**NOTE**<br>The device SN can be used as the unique identifier of a device.<br>**Required permission**: ohos.permission.sec.ACCESS_UDID (for system applications and enterprise applications only)<br>Example: The SN varies with the device.| 38| bootloaderVersion | string | Yes| Bootloader version.<br>Example: bootloader| 39| abiList | string | Yes| Application binary interface (Abi) list.<br>Example: arm64-v8a| 40| securityPatchTag | string | Yes| Security patch tag.<br>Example: <!--RP7-->2021/01/01<!--RP7End--> | 41| displayVersion | string | Yes| Product version.<br>Example: <!--RP8-->XXX X.X.X.X<!--RP8End--> | 42| incrementalVersion | string | Yes| Incremental version.<br>Example: default| 43| osReleaseType | string | Yes| OS release type. The options are as follows:<br>- **Canary**: Preliminary release open only to specific developers. This release does not promise API stability and may require tolerance of instability.<br>- **Beta**: Release open to all developers. This release does not promise API stability and may require tolerance of instability.<br>- **Release**: Official release open to all developers. This release promises that all APIs are stable.<br>Example: <!--RP9-->Canary/Beta/Release<!--RP9End--> | 44| osFullName | string | Yes| System version. The version number is in the format of **OpenHarmony-x.x.x.x**, where **x** is a digit.<br>**Atomic service API**: This API can be used in atomic services since API version 11.<br>Example: <!--RP10-->Openharmony-5.0.0.1<!--RP10End--> | 45| majorVersion | number | Yes| Major version number, which increments with the main version. The value is the first digit in **osFullName**. You are advised to use **deviceInfo.majorVersion** instead of parsing **osFullName** to obtain the value, facilitating efficiency improvement.<br>Example: 5| 46| seniorVersion | number | Yes| Senior version number, which increments with architecture and feature updates. The value is the second digit in **osFullName**. You are advised to use **deviceInfo.seniorVersion** instead of parsing **osFullName** to obtain the value, facilitating efficiency improvement.<br>Example: 0| 47| featureVersion | number | Yes| Feature version number. The value is the third digit in **osFullName**. You are advised to use **deviceInfo.featureVersion** instead of parsing **osFullName** to obtain the value, facilitating efficiency improvement.<br>Example: 0| 48| buildVersion | number | Yes| Build version number. The value is the fourth digit in **osFullName**. You are advised to use **deviceInfo.buildVersion** instead of parsing **osFullName** to obtain the value, facilitating efficiency improvement.<br>Example: 1| 49| sdkApiVersion | number | Yes| SDK API version.<br>**Atomic service API**: This API can be used in atomic services since API version 14.<br>Example: 12| 50| firstApiVersion | number | Yes| First API version.<br>Example: 3| 51| versionId | string | Yes| Version ID. It consists of the following fields: **deviceType**, **manufacture**, **brand**, **productSeries**, **osFullName**, **productModel**, **softwareModel**, **sdkApiVersion**, **incrementalVersion**, and **buildType**.<br>Example: wearable/HUAWEI/HUAWEI/TAS/OpenHarmony-5.0.0.1/TAS-AL00/TAS-AL00/12/default/release:nolog| 52| buildType | string | Yes| Build type.<br>Example: default| 53| buildUser | string | Yes| Build user.<br>Example: default| 54| buildHost | string | Yes| Build host.<br>Example: default| 55| buildTime | string | Yes| Build time.<br>Example: default| 56| buildRootHash | string | Yes| Build root hash.<br>Example: default| 57| udid<sup>7+</sup> | string | Yes| Device UDID.<br>**NOTE**<br>The data length is 65 bytes. The UDID can be used as the unique identifier of a device.<br>**Required permission**: ohos.permission.sec.ACCESS_UDID (for system applications and enterprise applications only)<br>Example: 9D6AABD147XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXE5536412 | 58| distributionOSName<sup>10+</sup> | string | Yes| Distribution OS name.<!--Del--> It is defined by the issuer.<!--DelEnd--><br>Example: OpenHarmony| 59| distributionOSVersion<sup>10+</sup> | string | Yes| Distribution OS version.<!--Del--> It is defined by the issuer.<!--DelEnd--><!--RP11--><!--RP11End--><br>Example: 5.0.0 | 60| distributionOSApiVersion<sup>10+</sup> | number| Yes| Distribution OS API version.<!--Del--> It is defined by the issuer.<!--DelEnd--><br>Example: 50001| 61| distributionOSApiName<sup>13+</sup> | string | Yes| Distribution OS API name.<!--Del--> It is defined by the issuer.<!--DelEnd-->| 62| distributionOSReleaseType<sup>10+</sup> | string | Yes| Distribution OS release type.<!--Del--> It is defined by the issuer.<!--DelEnd--><br>Example: Release| 63| ODID<sup>12+</sup> | string | Yes|Open device identifier.<br>An ODID will be regenerated in the following scenarios:<br>Restore a phone to its factory settings.<br>Uninstall and reinstall all applications with the same **developerId** on one device.<br>An ODID is generated based on the following rules:<br>The value is generated based on the **groupId** parsed from the **developerId** in the signature information. As **groupId.developerId** is the rule, if no **groupId** exists, the **developerId** is used as the **groupId**.<br>Applications with the same **developerId** use the same ODID on one device.<br>Applications with different **developerId**s use different ODIDs on one device.<br>Applications with the same **developerId** use different ODIDs on different devices.<br>Applications with different **developerId**s use different ODIDs on different devices.<br>**NOTE**<br>The data length is 37 bytes.<br>Example: 1234a567-XXXX-XXXX-XXXX-XXXXXXXXXXXX| 64| diskSN<sup>15+</sup> | string | Yes| Disk SN.<br>**NOTE**<br>This field can be queried only on the 2-in-1 device. For other devices, the query result is empty.<br>**Required permissions**: ohos.permission.ACCESS_DISK_PHY_INFO<br>Example: 2502EM400567 | 65| performanceClass<sup>19+</sup> | [PerformanceClassLevel](#performanceclasslevel19) | Yes| Device capability level.| 66 67**Example** 68 69```ts 70 import { deviceInfo } from '@kit.BasicServicesKit'; 71 72 let deviceTypeInfo: string = deviceInfo.deviceType; 73 // Output: the value of the deviceType is :wearable 74 console.info('the value of the deviceType is :' + deviceTypeInfo); 75 76 let manufactureInfo: string = deviceInfo.manufacture; 77 // Output: the value of the manufacture is :HUAWEI 78 console.info('the value of the manufactureInfo is :' + manufactureInfo); 79 80 let brandInfo: string = deviceInfo.brand; 81 // Output: the value of the brand is :HUAWEI 82 console.info('the value of the device brand is :' + brandInfo); 83 84 let marketNameInfo: string = deviceInfo.marketName; 85 // Output: the value of the marketName is :Mate XX 86 console.info('the value of the deviceInfo marketName is :' + marketNameInfo); 87 88 let productSeriesInfo: string = deviceInfo.productSeries; 89 // Output: the value of the productSeries is :TAS 90 console.info('the value of the deviceInfo productSeries is :' + productSeriesInfo); 91 92 let productModelInfo: string = deviceInfo.productModel; 93 // Output: the value of the productModel is :TAS-AL00 94 console.info('the value of the deviceInfo productModel is :' + productModelInfo); 95 96 let productModelAliasInfo: string = deviceInfo.productModelAlias; 97 console.info('the value of the deviceInfo productModelAlias is :' + productModelAliasInfo); 98 99 let softwareModelInfo: string = deviceInfo.softwareModel; 100 // Output: the value of the softwareModel is :TAS-AL00 101 console.info('the value of the deviceInfo softwareModel is :' + softwareModelInfo); 102 103 let hardwareModelInfo: string = deviceInfo.hardwareModel; 104 // Output: the value of the hardwareModel is :TASA00CVN1 105 console.info('the value of the deviceInfo hardwareModel is :' + hardwareModelInfo); 106 107 let serialInfo: string = deviceInfo.serial; 108 // Output: the value of the serial is :The SN varies with the device. 109 console.info('the value of the deviceInfo serial is :' + serialInfo); 110 111 let bootloaderVersionInfo: string = deviceInfo.bootloaderVersion; 112 // Output: the value of the bootloaderVersion is :bootloader 113 console.info('the value of the deviceInfo bootloaderVersion is :' + bootloaderVersionInfo); 114 115 let abiListInfo: string = deviceInfo.abiList; 116 // Output: the value of the abiList is :arm64-v8a 117 console.info('the value of the deviceInfo abiList is :' + abiListInfo); 118 119 let securityPatchTagInfo: string = deviceInfo.securityPatchTag; 120 // Output: the value of the securityPatchTag is :2021/01/01 121 console.info('the value of the deviceInfo securityPatchTag is :' + securityPatchTagInfo); 122 123 let displayVersionInfo: string = deviceInfo.displayVersion; 124 // Output: the value of the displayVersion is :XXX X.X.X.X 125 console.info('the value of the deviceInfo displayVersion is :' + displayVersionInfo); 126 127 let incrementalVersionInfo: string = deviceInfo.incrementalVersion; 128 // Output: the value of the incrementalVersion is :default 129 console.info('the value of the deviceInfo incrementalVersion is :' + incrementalVersionInfo); 130 131 let osReleaseTypeInfo: string = deviceInfo.osReleaseType; 132 // Output: the value of the osReleaseType is :Release 133 console.info('the value of the deviceInfo osReleaseType is :' + osReleaseTypeInfo); 134 135 let osFullNameInfo: string = deviceInfo.osFullName; 136 // Output: the value of the osFullName is :OpenHarmony-5.0.0.1 137 console.info('the value of the deviceInfo osFullName is :' + osFullNameInfo); 138 139 let majorVersionInfo: number = deviceInfo.majorVersion; 140 // Output: the value of the majorVersion is :5 141 console.info('the value of the deviceInfo majorVersion is :' + majorVersionInfo); 142 143 let seniorVersionInfo: number = deviceInfo.seniorVersion; 144 // Output: the value of the seniorVersion is :0 145 console.info('the value of the deviceInfo seniorVersion is :' + seniorVersionInfo); 146 147 let featureVersionInfo: number = deviceInfo.featureVersion; 148 // Output: the value of the featureVersion is :0 149 console.info('the value of the deviceInfo featureVersion is :' + featureVersionInfo); 150 151 let buildVersionInfo: number = deviceInfo.buildVersion; 152 // Output: the value of the buildVersion is :1 153 console.info('the value of the deviceInfo buildVersion is :' + buildVersionInfo); 154 155 let sdkApiVersionInfo: number = deviceInfo.sdkApiVersion; 156 // Output: the value of the sdkApiVersion is :12 157 console.info('the value of the deviceInfo sdkApiVersion is :' + sdkApiVersionInfo); 158 159 let firstApiVersionInfo: number = deviceInfo.firstApiVersion; 160 // Output: the value of the firstApiVersion is :3 161 console.info('the value of the deviceInfo firstApiVersion is :' + firstApiVersionInfo); 162 163 let versionIdInfo: string = deviceInfo.versionId; 164 // Output: the value of the versionId is :wearable/HUAWEI/HUAWEI/TAS/OpenHarmony-5.0.0.1/TAS-AL00/TAS-AL00/12/default/release:nolog 165 console.info('the value of the deviceInfo versionId is :' + versionIdInfo); 166 167 let buildTypeInfo: string = deviceInfo.buildType; 168 // Output: the value of the buildType is :default 169 console.info('the value of the deviceInfo buildType is :' + buildTypeInfo); 170 171 let buildUserInfo: string = deviceInfo.buildUser; 172 // Output: the value of the buildUser is :default 173 console.info('the value of the deviceInfo buildUser is :' + buildUserInfo); 174 175 let buildHostInfo: string = deviceInfo.buildHost; 176 // Output: the value of the buildHost is :default 177 console.info('the value of the deviceInfo buildHost is :' + buildHostInfo); 178 179 let buildTimeInfo: string = deviceInfo.buildTime; 180 // Output: the value of the buildTime is :default 181 console.info('the value of the deviceInfo buildTime is :' + buildTimeInfo); 182 183 let buildRootHashInfo: string = deviceInfo.buildRootHash; 184 // Output: the value of the buildRootHash is :default 185 console.info('the value of the deviceInfo buildRootHash is :' + buildRootHashInfo); 186 187 let udid: string = deviceInfo.udid; 188 // Output: the value of the udid is :9D6AABD147XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXE5536412 189 console.info('the value of the deviceInfo udid is :' + udid); 190 191 let distributionOSName: string = deviceInfo.distributionOSName 192 // Output: the value of the distributionOSName is :OpenHarmony 193 console.info('the value of the deviceInfo distributionOSName is :' + distributionOSName); 194 195 let distributionOSVersion: string = deviceInfo.distributionOSVersion 196 // Output: the value of the distributionOSVersion is :5.0.0 197 console.info('the value of the deviceInfo distributionOSVersion is :' + distributionOSVersion); 198 199 let distributionOSApiVersion: number = deviceInfo.distributionOSApiVersion 200 // Output: the value of the distributionOSApiVersion is :500001 201 console.info('the value of the deviceInfo distributionOSApiVersion is :' + distributionOSApiVersion); 202 203 let distributionOSApiName: string = deviceInfo.distributionOSApiName 204 console.info('the value of the deviceInfo distributionOSApiName is :' + distributionOSApiName); 205 206 let distributionOSReleaseType: string = deviceInfo.distributionOSReleaseType 207 // Output: the value of the distributionOSReleaseType is :Release 208 console.info('the value of the deviceInfo distributionOSReleaseType is :' + distributionOSReleaseType); 209 210 let odid: string = deviceInfo.ODID; 211 // Output: the value of the ODID is :1234a567-XXXX-XXXX-XXXX-XXXXXXXXXXXX 212 console.info('the value of the deviceInfo odid is :' + odid); 213 214 let diskSN: string = deviceInfo.diskSN; 215 // Output: the value of the deviceInfo diskSN is :2502EM400567 216 console.info('the value of the deviceInfo diskSN is :' + diskSN); 217 218 let performanceClass = deviceInfo.performanceClass; 219 // Output: the value of the deviceInfo performanceClass is :0 220 console.info('the value of the deviceInfo performanceClass is :' + performanceClass); 221 222``` 223 224## PerformanceClassLevel<sup>19+</sup> 225 226Enumerates the device capability levels. 227 228**System capability**: SystemCapability.Startup.SystemInfo 229 230| Name | Value | Description | 231| ---------------------| ---- | -------------- | 232| CLASS_LEVEL_HIGH | 0 | High | 233| CLASS_LEVEL_MEDIUM | 1 | Medium | 234| CLASS_LEVEL_LOW | 2 | Low | 235 236## DeviceTypes<sup>20+</sup> 237 238Enumerates device types, which can be used to verify the return value of **deviceType**. 239 240**Atomic service API**: This API can be used in atomic services since API version 20. 241 242**System capability**: SystemCapability.Startup.SystemInfo 243 244| Name| Value | Description | 245| ---- | ---- | -------------------------- | 246| TYPE_DEFAULT | 'default' | Default device| 247| TYPE_PHONE | 'phone' | Smartphone| 248| TYPE_TABLET | 'tablet' | Tablet| 249| TYPE_2IN1 | '2in1' | PC/2-in-1 device| 250| TYPE_TV | 'tv' | Smart TV| 251| TYPE_WEARABLE | 'wearable' | Wearable| 252| TYPE_CAR | 'car' | Head unit| 253 254**Example** 255 256```ts 257 let deviceTypesInfo: string = deviceInfo.DeviceTypes.TYPE_DEFAULT; 258 // Output: the value of the DeviceTypes is :default 259 console.info('the value of the DeviceTypes is :' + deviceTypesInfo); 260 261 let deviceTypesInfo: string = deviceInfo.DeviceTypes.TYPE_PHONE; 262 // Output: the value of the DeviceTypes is :phone-type 263 console.info('the value of the DeviceTypes is :' + deviceTypesInfo); 264 265 let deviceTypesInfo: string = deviceInfo.DeviceTypes.TYPE_TABLET; 266 //Output: the value of the DeviceTypes is :tablet 267 console.info('the value of the DeviceTypes is :' + deviceTypesInfo); 268 269 let deviceTypesInfo: string = deviceInfo.DeviceTypes.TYPE_2IN1; 270 //Output: the value of the DeviceTypes is :2in1 271 console.info('the value of the DeviceTypes is :' + deviceTypesInfo); 272 273 let deviceTypesInfo: string = deviceInfo.DeviceTypes.TYPE_TV; 274 //Output: the value of the DeviceTypes is :tv 275 console.info('the value of the DeviceTypes is :' + deviceTypesInfo); 276 277 let deviceTypesInfo: string = deviceInfo.DeviceTypes.TYPE_WEARABLE; 278 // Output: the value of the DeviceTypes is :wearable 279 console.info('the value of the DeviceTypes is :' + deviceTypesInfo); 280 281 let deviceTypesInfo: string = deviceInfo.DeviceTypes.TYPE_CAR; 282 //Output: the value of the DeviceTypes is :car 283 console.info('the value of the DeviceTypes is :' + deviceTypesInfo); 284``` 285