1# @ohos.deviceInfo (设备信息)
2
3本模块提供终端设备信息查询,开发者不可配置。
4
5> **说明:**
6>
7> 本模块首批接口从API version 6开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
8> 部分参数返回值为default的,会在正式发布的版本中配置。
9> 本模块接口返回设备常量信息,建议应用只调用一次,不需要频繁调用。
10
11## 导入模块
12
13```ts
14import { deviceInfo } from '@kit.BasicServicesKit';
15```
16
17## 属性
18> **说明:**
19> 未特殊说明的字段,数据长度最大值为96字节。
20
21**系统能力**:SystemCapability.Startup.SystemInfo22
23**权限**:以下各项所需要的权限有所不同,详见下表。
24
25| 名称 | 类型 | 可读 | 可写 | 说明 |
26| -------- | -------- | -------- | -------- | -------- |
27| deviceType | string | 是 | 否 | 设备类型。详细请参考[deviceTypes标签](../../quick-start/module-configuration-file.md#devicetypes标签)。<br/>**原子化服务API**:从API version 11开始,该接口支持在原子化服务中使用。<br/>示例:wearable|
28| manufacture | string | 是 | 否 | 设备厂家名称。<br/>示例:HUAWEI |
29| brand | string | 是 | 否 | 设备品牌名称。<br/>**原子化服务API**:从API version 11开始,该接口支持在原子化服务中使用。<br/>示例:HUAWEI |
30| marketName | string | 是 | 否 | 外部产品系列。<br/>示例:Mate XX |
31| productSeries | string | 是 | 否 | 产品系列。<br/>示例:TAS |
32| productModel | string | 是 | 否 | 认证型号。<br/>**原子化服务API**:从API version 11开始,该接口支持在原子化服务中使用。<br/>示例:TAS-AL00 |
33| softwareModel | string | 是 | 否 | 内部软件子型号。<br/>示例:TAS-AL00 |
34| hardwareModel | string | 是 | 否 | 硬件版本号。<br/>示例:TASA00CVN1 |
35| hardwareProfile<sup>(deprecated) </sup> | string | 是 | 否 | 硬件Profile。<br/>**说明**:<br/>从API version 6 开始支持,从API version 9 开始废弃。 |
36| serial | string | 是 | 否 | 设备序列号,仅限系统应用使用。<br/>**说明**:可作为设备唯一识别码。<br/>**需要权限**:ohos.permission.sec.ACCESS_UDID <br/>示例:序列号随设备差异 |
37| bootloaderVersion | string | 是 | 否 | Bootloader版本号。<br/>示例:bootloater |
38| abiList | string | 是 | 否 | 应用二进制接口(Abi)。<br/>示例:arm64-v8a |
39| securityPatchTag | string | 是 | 否 | 安全补丁级别。<br/>示例:2021-01-01 |
40| displayVersion | string | 是 | 否 | 产品版本。<br/>示例:XXX X.X.X.X |
41| incrementalVersion | string | 是 | 否 | 差异版本号。 |
42| osReleaseType | string | 是 | 否 | 系统的发布类型,取值为:<br/>-&nbsp;Canary:面向特定开发者发布的早期预览版本,不承诺API稳定性。<br/>-&nbsp;Beta:面向开发者公开发布的Beta版本,不承诺API稳定性。<br/>-&nbsp;Release:面向开发者公开发布的正式版本,承诺API稳定性。<br/>示例:Canary\\Beta\\Release |
43| osFullName | string | 是 | 否 | 系统版本,版本格式OpenHarmony-x.x.x.x,x为数值。<br/>**原子化服务API**:从API version 11开始,该接口支持在原子化服务中使用。<br/>示例:Openharmony-5.0.0.1 |
44| majorVersion | number | 是 | 否 | Major版本号,随主版本更新增加,值为osFullName中的第一位数值,建议直接使用deviceInfo.majorVersion获取,不建议开发者解析osFullName获取。<br/>示例:5 |
45| seniorVersion | number | 是 | 否 | Senior版本号,随局部架构、重大特性增加,值为osFullName中的第二位数值,建议直接使用deviceInfo.seniorVersion获取,不建议开发者自主解析osFullName获取。<br/>示例:0 |
46| featureVersion | number | 是 | 否 | Feature版本号,标识规划的新特性版本,值为osFullName中的第三位数值,建议直接使用deviceInfo.featureVersion获取,不建议开发者自主解析osFullName获取。<br/>示例:0 |
47| buildVersion | number | 是 | 否 | Build版本号,标识编译构建的版本号,值为osFullName中的第四位数值,建议直接使用deviceInfo.buildVersion获取,不建议开发者自主解析osFullName获取。<br/>示例:1 |
48| sdkApiVersion | number | 是 | 否 | 系统软件API版本。<br/>示例:12 |
49| firstApiVersion | number | 是 | 否 | 首个版本系统软件API版本。<br/>示例:3 |
50| versionId | string | 是 | 否 | 版本ID。由deviceType、manufacture、brand、productSeries、osFullName、productModel、softwareModel、sdkApiVersion、incrementalVersion、buildType拼接组成。 |
51| buildType | string | 是 | 否 | 构建类型。<br/>示例:release:nolog |
52| buildUser | string | 是 | 否 | 构建用户。 |
53| buildHost | string | 是 | 否 | 构建主机。 |
54| buildTime | string | 是 | 否 | 构建时间。 |
55| buildRootHash | string | 是 | 否 | 构建版本Hash。 |
56| udid<sup>7+</sup> | string | 是 | 否 | 设备Udid,仅限系统应用使用。<br/>**说明**:数据长度为65字节。可作为设备唯一识别码。<br/>**需要权限**:ohos.permission.sec.ACCESS_UDID  |
57| distributionOSName<sup>10+</sup> | String | 是 | 否 | 发行版系统名称<!--Del-->,由发行方定义<!--DelEnd-->。 |
58| distributionOSVersion<sup>10+</sup> | String | 是 | 否 | 发行版系统版本号<!--Del-->,由发行方定义<!--DelEnd-->。<!--RP1--><!--RP1End-->  |
59| distributionOSApiVersion<sup>10+</sup> | number| 是 | 否 | 发行版系统api版本<!--Del-->,由发行方定义<!--DelEnd-->。 |
60| distributionOSApiName<sup>13+</sup> | String | 是 | 否 | 发行版系统api版本名称<!--Del-->,由发行方定义<!--DelEnd-->。 |
61| distributionOSReleaseType<sup>10+</sup> | String | 是 | 否 | 发行版系统类型<!--Del-->,由发行方定义<!--DelEnd-->。 |
62| ODID<sup>12+</sup> | String | 是 | 否 |开发者匿名设备标识符。<br/>**ODID值会在以下场景重新生成**:<br/>手机恢复出厂设置。<br/>同一设备上同一个开发者的应用全部卸载后重新安装时。<br/>**ODID生成规则**:<br/>同一设备上运行的同一个开发者的应用,ODID相同。<br/>同一个设备上不同开发者的应用,ODID不同。<br/>不同设备上同一个开发者的应用,ODID不同。<br/>不同设备上不同开发者的应用,ODID不同。<br/>**说明**:数据长度为37字节。 |
63
64**示例**
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