• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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## Attributes
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| Readable| Writable| Description|
26| -------- | -------- | -------- | -------- | -------- |
27| deviceType | string | Yes| No| 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: wearable|
28| manufacture | string | Yes| No| Device manufacturer.<br>Example: HUAWEI|
29| brand | string | Yes| No| 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| No| Marketing name.<br>Example: Mate XX|
31| productSeries | string | Yes| No| Product series.<br>Example: TAS|
32| productModel | string | Yes| No| Product model.<br>**Atomic service API**: This API can be used in atomic services since API version 11.<br>Example: TAS-AL00|
33| softwareModel | string | Yes| No| Software model.<br>Example: TAS-AL00|
34| hardwareModel | string | Yes| No| Hardware model.<br>Example: TASA00CVN1|
35| hardwareProfile<sup>(deprecated) </sup> | string | Yes| No| Hardware profile.<br>**NOTE**<br>This API is supported since API version 6 and deprecated since API version 9.|
36| serial | string | Yes| No| Device SN, available only for system applications.<br>**NOTE**<br>The device SN can be used as the unique identifier of a device.<br>**Required permissions**: ohos.permission.sec.ACCESS_UDID<br>Example: The SN varies with the device.|
37| bootloaderVersion | string | Yes| No| Bootloader version.<br>Example: bootloater|
38| abiList | string | Yes| No| Application binary interface (Abi) list.<br>Example: arm64-v8a|
39| securityPatchTag | string | Yes| No| Security patch tag.<br>Example: 2021-01-01|
40| displayVersion | string | Yes| No| Product version.<br>Example: XXX X.X.X.X|
41| incrementalVersion | string | Yes| No| Incremental version.|
42| osReleaseType | string | Yes| No| 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: Canary\\Beta\\Release|
43| osFullName | string | Yes| No| 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: Openharmony-5.0.0.1|
44| majorVersion | number | Yes| No| 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.<br>Example: 5|
45| seniorVersion | number | Yes| No| 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.<br>Example: 0|
46| featureVersion | number | Yes| No| 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.<br>Example: 0|
47| buildVersion | number | Yes| No| 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.<br>Example: 1|
48| sdkApiVersion | number | Yes| No| SDK API version.<br>Example: 12|
49| firstApiVersion | number | Yes| No| First API version.<br>Example: 3|
50| versionId | string | Yes| No| Version ID. It consists of the following fields: **deviceType**, **manufacture**, **brand**, **productSeries**, **osFullName**, **productModel**, **softwareModel**, **sdkApiVersion**, **incrementalVersion**, and **buildType**.|
51| buildType | string | Yes| No| Build type.<br>Example: release:nolog|
52| buildUser | string | Yes| No| Build user.|
53| buildHost | string | Yes| No| Build host.|
54| buildTime | string | Yes| No| Build time.|
55| buildRootHash | string | Yes| No| Build root hash.|
56| udid<sup>7+</sup> | string | Yes| No| Device UDID, available only for system applications.<br>**NOTE**<br>The data length is 65 bytes. The UDID can be used as the unique identifier of a device.<br>**Required permissions**: ohos.permission.sec.ACCESS_UDID |
57| distributionOSName<sup>10+</sup> | String | Yes| No| Distribution OS name.<!--Del--> It is defined by the issuer.<!--DelEnd-->.|
58| distributionOSVersion<sup>10+</sup> | String | Yes| No| Distribution OS version.<!--Del--> It is defined by the issuer.<!--DelEnd-->.<!--RP1--><!--RP1End-->  |
59| distributionOSApiVersion<sup>10+</sup> | number| Yes| No| Distribution OS API version.<!--Del--> It is defined by the issuer.<!--DelEnd-->.|
60| distributionOSApiName<sup>13+</sup> | String | Yes| No| Distribution OS API name.<!--Del--> It is defined by the issuer.<!--DelEnd-->.|
61| distributionOSReleaseType<sup>10+</sup> | String | Yes| No| Distribution OS release type.<!--Del--> It is defined by the issuer.<!--DelEnd-->.|
62| ODID<sup>12+</sup> | String | Yes| No|Vendor Anonymous 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.|
63
64**Example**
65
66```ts
67    import { deviceInfo } from '@kit.BasicServicesKit';
68
69    let deviceTypeInfo: string = deviceInfo.deviceType;
70    console.info('the value of the deviceType is :' + deviceTypeInfo);
71
72    let manufactureInfo: string = deviceInfo.manufacture;
73    console.info('the value of the manufactureInfo is :' + manufactureInfo);
74
75    let brandInfo: string = deviceInfo.brand;
76    console.info('the value of the device brand is :' + brandInfo);
77
78    let marketNameInfo: string = deviceInfo.marketName;
79    console.info('the value of the deviceInfo marketName is :' + marketNameInfo);
80
81    let productSeriesInfo: string = deviceInfo.productSeries;
82    console.info('the value of the deviceInfo productSeries is :' + productSeriesInfo);
83
84    let productModelInfo: string = deviceInfo.productModel;
85    console.info('the value of the deviceInfo productModel is :' + productModelInfo);
86
87    let softwareModelInfo: string = deviceInfo.softwareModel;
88    console.info('the value of the deviceInfo softwareModel is :' + softwareModelInfo);
89
90    let hardwareModelInfo: string = deviceInfo.hardwareModel;
91    console.info('the value of the deviceInfo hardwareModel is :' + hardwareModelInfo);
92
93    let serialInfo: string = deviceInfo.serial;
94    console.info('the value of the deviceInfo serial is :' + serialInfo);
95
96    let bootloaderVersionInfo: string = deviceInfo.bootloaderVersion;
97    console.info('the value of the deviceInfo bootloaderVersion is :' + bootloaderVersionInfo);
98
99    let abiListInfo: string = deviceInfo.abiList;
100    console.info('the value of the deviceInfo abiList is :' + abiListInfo);
101
102    let securityPatchTagInfo: string = deviceInfo.securityPatchTag;
103    console.info('the value of the deviceInfo securityPatchTag is :' + securityPatchTagInfo);
104
105    let displayVersionInfo: string = deviceInfo.displayVersion;
106    console.info('the value of the deviceInfo displayVersion is :' + displayVersionInfo);
107
108    let incrementalVersionInfo: string = deviceInfo.incrementalVersion;
109    console.info('the value of the deviceInfo incrementalVersion is :' + incrementalVersionInfo);
110
111    let osReleaseTypeInfo: string = deviceInfo.osReleaseType;
112    console.info('the value of the deviceInfo osReleaseType is :' + osReleaseTypeInfo);
113
114    let osFullNameInfo: string = deviceInfo.osFullName;
115    console.info('the value of the deviceInfo osFullName is :' + osFullNameInfo);
116
117    let majorVersionInfo: number = deviceInfo.majorVersion;
118    console.info('the value of the deviceInfo majorVersion is :' + majorVersionInfo);
119
120    let seniorVersionInfo: number = deviceInfo.seniorVersion;
121    console.info('the value of the deviceInfo seniorVersion is :' + seniorVersionInfo);
122
123    let featureVersionInfo: number = deviceInfo.featureVersion;
124    console.info('the value of the deviceInfo featureVersion is :' + featureVersionInfo);
125
126    let buildVersionInfo: number = deviceInfo.buildVersion;
127    console.info('the value of the deviceInfo buildVersion is :' + buildVersionInfo);
128
129    let sdkApiVersionInfo: number = deviceInfo.sdkApiVersion;
130    console.info('the value of the deviceInfo sdkApiVersion is :' + sdkApiVersionInfo);
131
132    let firstApiVersionInfo: number = deviceInfo.firstApiVersion;
133    console.info('the value of the deviceInfo firstApiVersion is :' + firstApiVersionInfo);
134
135    let versionIdInfo: string = deviceInfo.versionId;
136    console.info('the value of the deviceInfo versionId is :' + versionIdInfo);
137
138    let buildTypeInfo: string = deviceInfo.buildType;
139    console.info('the value of the deviceInfo buildType is :' + buildTypeInfo);
140
141    let buildUserInfo: string = deviceInfo.buildUser;
142    console.info('the value of the deviceInfo buildUser is :' + buildUserInfo);
143
144    let buildHostInfo: string = deviceInfo.buildHost;
145    console.info('the value of the deviceInfo buildHost is :' + buildHostInfo);
146
147    let buildTimeInfo: string = deviceInfo.buildTime;
148    console.info('the value of the deviceInfo buildTime is :' + buildTimeInfo);
149
150    let buildRootHashInfo: string = deviceInfo.buildRootHash;
151    console.info('the value of the deviceInfo buildRootHash is :' + buildRootHashInfo);
152
153    let udid: string = deviceInfo.udid;
154    console.info('the value of the deviceInfo udid is :' + udid);
155
156    let distributionOSName: string = deviceInfo.distributionOSName
157    console.info('the value of the deviceInfo distributionOSName is :' + distributionOSName);
158
159    let distributionOSVersion: string = deviceInfo.distributionOSVersion
160    console.info('the value of the deviceInfo distributionOSVersion is :' + distributionOSVersion);
161
162    let distributionOSApiVersion: number = deviceInfo.distributionOSApiVersion
163    console.info('the value of the deviceInfo distributionOSApiVersion is :' + distributionOSApiVersion);
164
165    let distributionOSApiName: number = deviceInfo.distributionOSApiName
166    console.info('the value of the deviceInfo distributionOSApiName is :' + distributionOSApiName);
167
168    let distributionOSReleaseType: string = deviceInfo.distributionOSReleaseType
169    console.info('the value of the deviceInfo distributionOSReleaseType is :' + distributionOSReleaseType);
170
171    let odid: string = deviceInfo.ODID;
172    console.info('the value of the deviceInfo odid is :' + odid);
173
174```
175