• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# @ohos.deviceInfo (设备信息)
2
3本模块提供产品信息。
4
5> **说明:**
6>
7> 本模块首批接口从API version 6开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
8> 部分参数返回值为default的,会在正式发布的版本中配置。
9
10## 导入模块
11
12```ts
13import deviceInfo from '@ohos.deviceInfo';
14```
15
16## 属性
17
18**系统能力**:SystemCapability.Startup.SystemInfo19
20**权限**:以下各项所需要的权限有所不同,详见下表。
21
22| 名称 | 类型 | 可读 | 可写 | 说明 |
23| -------- | -------- | -------- | -------- | -------- |
24| deviceType | string | 是 | 否 | 设备类型,只允许查询,结果不能用于业务代码开发。 |
25| manufacture | string | 是 | 否 | 设备厂家名称。 |
26| brand | string | 是 | 否 | 设备品牌名称。 |
27| marketName | string | 是 | 否 | 外部产品系列。 |
28| productSeries | string | 是 | 否 | 产品系列。 |
29| productModel | string | 是 | 否 | 认证型号。 |
30| softwareModel | string | 是 | 否 | 内部软件子型号。 |
31| hardwareModel | string | 是 | 否 | 硬件版本号。 |
32| hardwareProfile | string | 是 | 否 | 硬件Profile。 |
33| serial | string | 是 | 否 | 设备序列号。<br/>**使用权限**:仅限系统应用使用 |
34| bootloaderVersion | string | 是 | 否 | Bootloader版本号。 |
35| abiList | string | 是 | 否 | 应用二进制接口(Abi)列表。 |
36| securityPatchTag | string | 是 | 否 | 安全补丁级别。 |
37| displayVersion | string | 是 | 否 | 产品版本。 |
38| incrementalVersion | string | 是 | 否 | 差异版本号。 |
39| osReleaseType | string | 是 | 否 | 系统的发布类型,取值为:<br/>-&nbsp;Canary:面向特定开发者发布的早期预览版本,不承诺API稳定性。<br/>-&nbsp;Beta:面向开发者公开发布的Beta版本,不承诺API稳定性。<br/>-&nbsp;Release:面向开发者公开发布的正式版本,承诺API稳定性。 |
40| osFullName | string | 是 | 否 | 系统版本。 |
41| majorVersion | number | 是 | 否 | Major版本号,随主版本更新增加。 |
42| seniorVersion | number | 是 | 否 | Senior版本号,随局部架构、重大特性增加。 |
43| featureVersion | number | 是 | 否 | Feature版本号,标识规划的新特性版本。 |
44| buildVersion | number | 是 | 否 | Build版本号,标识编译构建的版本号。 |
45| sdkApiVersion | number | 是 | 否 | 系统软件API版本。 |
46| firstApiVersion | number | 是 | 否 | 首个版本系统软件API版本。 |
47| versionId | string | 是 | 否 | 版本ID。 |
48| buildType | string | 是 | 否 | 构建类型。 |
49| buildUser | string | 是 | 否 | 构建用户。 |
50| buildHost | string | 是 | 否 | 构建主机。 |
51| buildTime | string | 是 | 否 | 构建时间。 |
52| buildRootHash | string | 是 | 否 | 构建版本Hash。 |
53| udid<sup>7+</sup> | string | 是 | 否 | 设备Udid。<br/>**使用权限**:仅限系统应用使用|
54| distributionOSName<sup>10+</sup> | String | 是 | 否 | 发行版系统名称。 |
55| distributionOSVersion<sup>10+</sup> | String | 是 | 否 | 发行版系统版本号。 |
56| distributionOSApiVersion<sup>10+</sup> | number| 是 | 否 | 发行版系统api版本。 |
57| distributionOSReleaseType<sup>10+</sup> | String | 是 | 否 | 发行版系统类型。 |
58
59**示例**
60
61```ts
62    import deviceinfo from '@ohos.deviceInfo';
63
64    let deviceTypeInfo: string = deviceinfo.deviceType;
65    console.info('the value of the deviceType is :' + deviceTypeInfo);
66
67    let manufactureInfo: string = deviceinfo.manufacture;
68    console.info('the value of the manufactureInfo is :' + manufactureInfo);
69
70    let brandInfo: string = deviceinfo.brand;
71    console.info('the value of the device brand is :' + brandInfo);
72
73    let marketNameInfo: string = deviceinfo.marketName;
74    console.info('the value of the deviceinfo marketName is :' + marketNameInfo);
75
76    let productSeriesInfo: string = deviceinfo.productSeries;
77    console.info('the value of the deviceinfo productSeries is :' + productSeriesInfo);
78
79    let productModelInfo: string = deviceinfo.productModel;
80    console.info('the value of the deviceinfo productModel is :' + productModelInfo);
81
82    let softwareModelInfo: string = deviceinfo.softwareModel;
83    console.info('the value of the deviceinfo softwareModel is :' + softwareModelInfo);
84
85    let hardwareModelInfo: string = deviceinfo.hardwareModel;
86    console.info('the value of the deviceinfo hardwareModel is :' + hardwareModelInfo);
87
88    let hardwareProfileInfo: string = deviceinfo.hardwareProfile;
89    console.info('the value of the deviceinfo hardwareProfile is :' + hardwareProfileInfo);
90
91    let serialInfo: string = deviceinfo.serial;
92    console.info('the value of the deviceinfo serial is :' + serialInfo);
93
94    let bootloaderVersionInfo: string = deviceinfo.bootloaderVersion;
95    console.info('the value of the deviceinfo bootloaderVersion is :' + bootloaderVersionInfo);
96
97    let abiListInfo: string = deviceinfo.abiList;
98    console.info('the value of the deviceinfo abiList is :' + abiListInfo);
99
100    let securityPatchTagInfo: string = deviceinfo.securityPatchTag;
101    console.info('the value of the deviceinfo securityPatchTag is :' + securityPatchTagInfo);
102
103    let displayVersionInfo: string = deviceinfo.displayVersion;
104    console.info('the value of the deviceinfo displayVersion is :' + displayVersionInfo);
105
106    let incrementalVersionInfo: string = deviceinfo.incrementalVersion;
107    console.info('the value of the deviceinfo incrementalVersion is :' + incrementalVersionInfo);
108
109    let osReleaseTypeInfo: string = deviceinfo.osReleaseType;
110    console.info('the value of the deviceinfo osReleaseType is :' + osReleaseTypeInfo);
111
112    let osFullNameInfo: string = deviceinfo.osFullName;
113    console.info('the value of the deviceinfo osFullName is :' + osFullNameInfo);
114
115    let majorVersionInfo: number = deviceinfo.majorVersion;
116    console.info('the value of the deviceinfo majorVersion is :' + majorVersionInfo);
117
118    let seniorVersionInfo: number = deviceinfo.seniorVersion;
119    console.info('the value of the deviceinfo seniorVersion is :' + seniorVersionInfo);
120
121    let featureVersionInfo: number = deviceinfo.featureVersion;
122    console.info('the value of the deviceinfo featureVersion is :' + featureVersionInfo);
123
124    let buildVersionInfo: number = deviceinfo.buildVersion;
125    console.info('the value of the deviceinfo buildVersion is :' + buildVersionInfo);
126
127    let sdkApiVersionInfo: number = deviceinfo.sdkApiVersion;
128    console.info('the value of the deviceinfo sdkApiVersion is :' + sdkApiVersionInfo);
129
130    let firstApiVersionInfo: number = deviceinfo.firstApiVersion;
131    console.info('the value of the deviceinfo firstApiVersion is :' + firstApiVersionInfo);
132
133    let versionIdInfo: string = deviceinfo.versionId;
134    console.info('the value of the deviceinfo versionId is :' + versionIdInfo);
135
136    let buildTypeInfo: string = deviceinfo.buildType;
137    console.info('the value of the deviceinfo buildType is :' + buildTypeInfo);
138
139    let buildUserInfo: string = deviceinfo.buildUser;
140    console.info('the value of the deviceinfo buildUser is :' + buildUserInfo);
141
142    let buildHostInfo: string = deviceinfo.buildHost;
143    console.info('the value of the deviceinfo buildHost is :' + buildHostInfo);
144
145    let buildTimeInfo: string = deviceinfo.buildTime;
146    console.info('the value of the deviceinfo buildTime is :' + buildTimeInfo);
147
148    let buildRootHashInfo: string = deviceinfo.buildRootHash;
149    console.info('the value of the deviceinfo buildRootHash is :' + buildRootHashInfo);
150
151    let udid: string = deviceinfo.udid;
152    console.info('the value of the deviceinfo udid is :' + udid);
153
154    let distributionOSName: string = deviceinfo.distributionOSName
155    console.info('the value of the deviceinfo distributionOSName is :' + distributionOSName);
156
157    let distributionOSVersion: string = deviceinfo.distributionOSVersion
158    console.info('the value of the deviceinfo distributionOSVersion is :' + distributionOSVersion);
159
160    let distributionOSApiVersion: number = deviceinfo.distributionOSApiVersion
161    console.info('the value of the deviceinfo distributionOSApiVersion is :' + distributionOSApiVersion);
162
163    let distributionOSReleaseType: string = deviceinfo.distributionOSReleaseType
164    console.info('the value of the deviceinfo distributionOSReleaseType is :' + distributionOSReleaseType);
165
166```
167