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> 未特殊说明的字段,数据长度最大值为96字节。 19 20**系统能力**:SystemCapability.Startup.SystemInfo。 21 22**权限**:以下各项所需要的权限有所不同,详见下表。 23 24| 名称 | 类型 | 可读 | 可写 | 说明 | 25| -------- | -------- | -------- | -------- | -------- | 26| deviceType | string | 是 | 否 | 设备类型,只允许查询,结果不能用于业务代码开发。 | 27| manufacture | string | 是 | 否 | 设备厂家名称。 | 28| brand | string | 是 | 否 | 设备品牌名称。 | 29| marketName | string | 是 | 否 | 外部产品系列。 | 30| productSeries | string | 是 | 否 | 产品系列。 | 31| productModel | string | 是 | 否 | 认证型号。 | 32| softwareModel | string | 是 | 否 | 内部软件子型号。 | 33| hardwareModel | string | 是 | 否 | 硬件版本号。 | 34| hardwareProfile<sup>(deprecated) </sup> | string | 是 | 否 | 硬件Profile。<br/>**说明**:<br/>从API version 6 开始支持,从API version 9 开始废弃。 | 35| serial | string | 是 | 否 | 设备序列号,仅限系统应用使用。<br/>**使用权限**:ohos.permission.sec.ACCESS_UDID | 36| bootloaderVersion | string | 是 | 否 | Bootloader版本号。 | 37| abiList | string | 是 | 否 | 应用二进制接口(Abi)列表。 | 38| securityPatchTag | string | 是 | 否 | 安全补丁级别。 | 39| displayVersion | string | 是 | 否 | 产品版本。 | 40| incrementalVersion | string | 是 | 否 | 差异版本号。 | 41| osReleaseType | string | 是 | 否 | 系统的发布类型,取值为:<br/>- Canary:面向特定开发者发布的早期预览版本,不承诺API稳定性。<br/>- Beta:面向开发者公开发布的Beta版本,不承诺API稳定性。<br/>- Release:面向开发者公开发布的正式版本,承诺API稳定性。 | 42| osFullName | string | 是 | 否 | 系统版本。 | 43| majorVersion | number | 是 | 否 | Major版本号,随主版本更新增加。 | 44| seniorVersion | number | 是 | 否 | Senior版本号,随局部架构、重大特性增加。 | 45| featureVersion | number | 是 | 否 | Feature版本号,标识规划的新特性版本。 | 46| buildVersion | number | 是 | 否 | Build版本号,标识编译构建的版本号。 | 47| sdkApiVersion | number | 是 | 否 | 系统软件API版本。 | 48| firstApiVersion | number | 是 | 否 | 首个版本系统软件API版本。 | 49| versionId | string | 是 | 否 | 版本ID。 | 50| buildType | string | 是 | 否 | 构建类型。 | 51| buildUser | string | 是 | 否 | 构建用户。 | 52| buildHost | string | 是 | 否 | 构建主机。 | 53| buildTime | string | 是 | 否 | 构建时间。 | 54| buildRootHash | string | 是 | 否 | 构建版本Hash。 | 55| udid<sup>7+</sup> | string | 是 | 否 | 设备Udid,仅限系统应用使用。<br/>**说明**:数据长度为65字节。<br/>**使用权限**:ohos.permission.sec.ACCESS_UDID | 56| distributionOSName<sup>10+</sup> | String | 是 | 否 | 发行版系统名称。 | 57| distributionOSVersion<sup>10+</sup> | String | 是 | 否 | 发行版系统版本号。 | 58| distributionOSApiVersion<sup>10+</sup> | number| 是 | 否 | 发行版系统api版本。 | 59| distributionOSReleaseType<sup>10+</sup> | String | 是 | 否 | 发行版系统类型。 | 60 61**示例** 62 63```ts 64 import deviceinfo from '@ohos.deviceInfo'; 65 66 let deviceTypeInfo: string = deviceinfo.deviceType; 67 console.info('the value of the deviceType is :' + deviceTypeInfo); 68 69 let manufactureInfo: string = deviceinfo.manufacture; 70 console.info('the value of the manufactureInfo is :' + manufactureInfo); 71 72 let brandInfo: string = deviceinfo.brand; 73 console.info('the value of the device brand is :' + brandInfo); 74 75 let marketNameInfo: string = deviceinfo.marketName; 76 console.info('the value of the deviceinfo marketName is :' + marketNameInfo); 77 78 let productSeriesInfo: string = deviceinfo.productSeries; 79 console.info('the value of the deviceinfo productSeries is :' + productSeriesInfo); 80 81 let productModelInfo: string = deviceinfo.productModel; 82 console.info('the value of the deviceinfo productModel is :' + productModelInfo); 83 84 let softwareModelInfo: string = deviceinfo.softwareModel; 85 console.info('the value of the deviceinfo softwareModel is :' + softwareModelInfo); 86 87 let hardwareModelInfo: string = deviceinfo.hardwareModel; 88 console.info('the value of the deviceinfo hardwareModel is :' + hardwareModelInfo); 89 90 let hardwareProfileInfo: string = deviceinfo.hardwareProfile; 91 console.info('the value of the deviceinfo hardwareProfile is :' + hardwareProfileInfo); 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 distributionOSReleaseType: string = deviceinfo.distributionOSReleaseType 166 console.info('the value of the deviceinfo distributionOSReleaseType is :' + distributionOSReleaseType); 167 168``` 169