harmony 鸿蒙@ohos.deviceInfo (Device Information)
@ohos.deviceInfo (Device Information)
The deviceInfo module provides terminal device information query, which cannot be configured by developers.
NOTE
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. Some parameters whose return value is the default value are not yet available. The APIs of this module return information about device constants. You are not expected to call these APIs frequently.
Modules to Import
import { deviceInfo } from '@kit.BasicServicesKit';
Attributes
NOTE Unless otherwise specified, the maximum data length is 96 bytes.
System capability: SystemCapability.Startup.SystemInfo
Required permissions: The items in the table below require different system capabilities.
Name | Type | Readable | Writable | Description |
---|---|---|---|---|
deviceType | string | Yes | No | Device type. For details, see deviceTypes tag. Atomic service API: This API can be used in atomic services since API version 11. Example: wearable |
manufacture | string | Yes | No | Device manufacturer. Example: HUAWEI |
brand | string | Yes | No | Device brand. Atomic service API: This API can be used in atomic services since API version 11. Example: HUAWEI |
marketName | string | Yes | No | Marketing name. Example: Mate XX |
productSeries | string | Yes | No | Product series. Example: TAS |
productModel | string | Yes | No | Product model. Atomic service API: This API can be used in atomic services since API version 11. Example: TAS-AL00 |
productModelAlias14+ | string | Yes | No | Product model alias. Atomic service API: This API can be used in atomic services since API version 14. Example: TAS-AL00 |
softwareModel | string | Yes | No | Software model. Example: TAS-AL00 |
hardwareModel | string | Yes | No | Hardware model. Example: TASA00CVN1 |
hardwareProfile(deprecated) | string | Yes | No | Hardware profile. NOTE This API is supported since API version 6 and deprecated since API version 9. Example: default |
serial | string | Yes | No | Device SN. NOTE The device SN can be used as the unique identifier of a device. Required permissions: ohos.permission.sec.ACCESS_UDID Example: The SN varies with the device. |
bootloaderVersion | string | Yes | No | Bootloader version. Example: bootloader |
abiList | string | Yes | No | Application binary interface (Abi) list. Example: arm64-v8a |
securityPatchTag | string | Yes | No | Security patch tag. Example: 2021/01/01 |
displayVersion | string | Yes | No | Product version. Example: XXX X.X.X.X |
incrementalVersion | string | Yes | No | Incremental version. Example: default |
osReleaseType | string | Yes | No | OS release type. The options are as follows: - Canary: Preliminary release open only to specific developers. This release does not promise API stability and may require tolerance of instability. - Beta: Release open to all developers. This release does not promise API stability and may require tolerance of instability. - Release: Official release open to all developers. This release promises that all APIs are stable. Example: Canary/Beta/Release |
osFullName | string | Yes | No | System version. The version number is in the format of OpenHarmony-x.x.x.x, where x is a digit. Atomic service API: This API can be used in atomic services since API version 11. Example: Openharmony-5.0.0.1 |
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, facilitating efficiency improvement. Example: 5 |
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, facilitating efficiency improvement. Example: 0 |
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, facilitating efficiency improvement. Example: 0 |
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, facilitating efficiency improvement. Example: 1 |
sdkApiVersion | number | Yes | No | SDK API version. Atomic service API: This API can be used in atomic services since API version 14. Example: 12 |
firstApiVersion | number | Yes | No | First API version. Example: 3 |
versionId | string | Yes | No | Version ID. It consists of the following fields: deviceType, manufacture, brand, productSeries, osFullName, productModel, softwareModel, sdkApiVersion, incrementalVersion, and buildType. Example: wearable/HUAWEI/HUAWEI/TAS/OpenHarmony-5.0.0.1/TAS-AL00/TAS-AL00/12/default/release:nolog |
buildType | string | Yes | No | Build type. Example: default |
buildUser | string | Yes | No | Build user. Example: default |
buildHost | string | Yes | No | Build host. Example: default |
buildTime | string | Yes | No | Build time. Example: default |
buildRootHash | string | Yes | No | Build root hash. Example: default |
udid7+ | string | Yes | No | Device UDID. NOTE The data length is 65 bytes. The UDID can be used as the unique identifier of a device. Required permissions: ohos.permission.sec.ACCESS_UDID Example: 9D6AABD147XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXE5536412 |
distributionOSName10+ | string | Yes | No | Distribution OS name. It is defined by the issuer.. Example: OpenHarmony |
distributionOSVersion10+ | string | Yes | No | Distribution OS version. It is defined by the issuer.. Example: 5.0.0 |
distributionOSApiVersion10+ | number | Yes | No | Distribution OS API version. It is defined by the issuer.. Example: 50001 |
distributionOSApiName13+ | string | Yes | No | Distribution OS API name. It is defined by the issuer.. |
distributionOSReleaseType10+ | string | Yes | No | Distribution OS release type. It is defined by the issuer.. Example: Release |
ODID12+ | string | Yes | No | Open device identifier. An ODID will be regenerated in the following scenarios: Restore a phone to its factory settings. Uninstall and reinstall all applications with the same developerId on one device. An ODID is generated based on the following rules: 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. Applications with the same developerId use the same ODID on one device. Applications with different developerIds use different ODIDs on one device. Applications with the same developerId use different ODIDs on different devices. Applications with different developerIds use different ODIDs on different devices. NOTE The data length is 37 bytes. Example: 1234a567-XXXX-XXXX-XXXX-XXXXXXXXXXXX |
diskSN15+ | string | Yes | No | Disk SN. NOTE This field can be queried only on the 2-in-1 device. For other devices, the query result is empty. Required permissions: ohos.permission.ACCESS_DISK_PHY_INFO Example: 2502EM400567 |
Example
import { deviceInfo } from '@kit.BasicServicesKit';
let deviceTypeInfo: string = deviceInfo.deviceType;
// Output: the value of the deviceType is: wearable
console.info('the value of the deviceType is :' + deviceTypeInfo);
let manufactureInfo: string = deviceInfo.manufacture;
// Output: the value of the manufactureInfo is: HUAWEI
console.info('the value of the manufactureInfo is :' + manufactureInfo);
let brandInfo: string = deviceInfo.brand;
// Output: the value of the device brand is: HUAWEI
console.info('the value of the device brand is :' + brandInfo);
let marketNameInfo: string = deviceInfo.marketName;
// Output: the value of the deviceInfo marketName is: Mate XX
console.info('the value of the deviceInfo marketName is :' + marketNameInfo);
let productSeriesInfo: string = deviceInfo.productSeries;
// Output: the value of the deviceInfo productSeries is: TAS
console.info('the value of the deviceInfo productSeries is :' + productSeriesInfo);
let productModelInfo: string = deviceInfo.productModel;
// Output: the value of the deviceInfo productModel is: TAS-AL00
console.info('the value of the deviceInfo productModel is :' + productModelInfo);
let productModelAliasInfo: string = deviceInfo.productModelAlias;
console.info('the value of the deviceInfo productModelAlias is :' + productModelAliasInfo);
let softwareModelInfo: string = deviceInfo.softwareModel;
// Output result: the value of the deviceInfo softwareModel is: TAS-AL00
console.info('the value of the deviceInfo softwareModel is :' + softwareModelInfo);
let hardwareModelInfo: string = deviceInfo.hardwareModel;
// Output: the value of the deviceInfo hardwareModel is: TASA00CVN1
console.info('the value of the deviceInfo hardwareModel is :' + hardwareModelInfo);
let serialInfo: string = deviceInfo.serial;
// Output: the value of the deviceInfo serial is: The serial number varies depending on the device.
console.info('the value of the deviceInfo serial is :' + serialInfo);
let bootloaderVersionInfo: string = deviceInfo.bootloaderVersion;
// Output: the value of the deviceInfo bootloaderVersion is: bootloader
console.info('the value of the deviceInfo bootloaderVersion is :' + bootloaderVersionInfo);
let abiListInfo: string = deviceInfo.abiList;
// Output: the value of the deviceInfo abiList is: arm64-v8a
console.info('the value of the deviceInfo abiList is :' + abiListInfo);
let securityPatchTagInfo: string = deviceInfo.securityPatchTag;
// Output: the value of the deviceInfo securityPatchTag is: 2021/01/01
console.info('the value of the deviceInfo securityPatchTag is :' + securityPatchTagInfo);
let displayVersionInfo: string = deviceInfo.displayVersion;
// Output: the value of the deviceInfo displayVersion is: XXX X.X.X.X
console.info('the value of the deviceInfo displayVersion is :' + displayVersionInfo);
let incrementalVersionInfo: string = deviceInfo.incrementalVersion;
// Output: the value of the deviceInfo incrementalVersion is: default
console.info('the value of the deviceInfo incrementalVersion is :' + incrementalVersionInfo);
let osReleaseTypeInfo: string = deviceInfo.osReleaseType;
// Output: the value of the deviceInfo osReleaseType is: Release
console.info('the value of the deviceInfo osReleaseType is :' + osReleaseTypeInfo);
let osFullNameInfo: string = deviceInfo.osFullName;
// Output: the value of the osFullName is: OpenHarmony-5.0.0.1
console.info('the value of the deviceInfo osFullName is :' + osFullNameInfo);
let majorVersionInfo: number = deviceInfo.majorVersion;
// Output: the value of the deviceInfo majorVersion is: 5
console.info('the value of the deviceInfo majorVersion is :' + majorVersionInfo);
let seniorVersionInfo: number = deviceInfo.seniorVersion;
// Output: the value of the deviceInfo seniorVersion is: 0
console.info('the value of the deviceInfo seniorVersion is :' + seniorVersionInfo);
let featureVersionInfo: number = deviceInfo.featureVersion;
// Output: the value of the deviceInfo featureVersion is: 0
console.info('the value of the deviceInfo featureVersion is :' + featureVersionInfo);
let buildVersionInfo: number = deviceInfo.buildVersion;
// Output: the value of the deviceInfo buildVersion is: 1
console.info('the value of the deviceInfo buildVersion is :' + buildVersionInfo);
let sdkApiVersionInfo: number = deviceInfo.sdkApiVersion;
// Output: the value of the deviceInfo sdkApiVersion is: 12
console.info('the value of the deviceInfo sdkApiVersion is :' + sdkApiVersionInfo);
let firstApiVersionInfo: number = deviceInfo.firstApiVersion;
// Output: the value of the deviceInfo firstApiVersion is: 3
console.info('the value of the deviceInfo firstApiVersion is :' + firstApiVersionInfo);
let versionIdInfo: string = deviceInfo.versionId;
// Output result: the value of the deviceInfo versionId is: wearable/HUAWEI/HUAWEI/TAS/OpenHarmony-5.0.0.1/TAS-AL00/TAS-AL00/12/default/release:nolog
console.info('the value of the deviceInfo versionId is :' + versionIdInfo);
let buildTypeInfo: string = deviceInfo.buildType;
// Output: the value of the deviceInfo buildUser is: default
console.info('the value of the deviceInfo buildType is :' + buildTypeInfo);
let buildUserInfo: string = deviceInfo.buildUser;
// Output: the value of the deviceInfo buildUser is: default
console.info('the value of the deviceInfo buildUser is :' + buildUserInfo);
let buildHostInfo: string = deviceInfo.buildHost;
// Output: the value of the deviceInfo buildHost is: default
console.info('the value of the deviceInfo buildHost is :' + buildHostInfo);
let buildTimeInfo: string = deviceInfo.buildTime;
// Output result: the value of the deviceInfo buildTime is: default
console.info('the value of the deviceInfo buildTime is :' + buildTimeInfo);
let buildRootHashInfo: string = deviceInfo.buildRootHash;
// Output result: the value of the deviceInfo buildRootHash is: default
console.info('the value of the deviceInfo buildRootHash is :' + buildRootHashInfo);
let udid: string = deviceInfo.udid;
// Output: the value of the deviceInfo udid is: 9D6AABD147XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXE5536412
console.info('the value of the deviceInfo udid is :' + udid);
let distributionOSName: string = deviceInfo.distributionOSName
// Output: the value of the deviceInfo distributionOSName is: OpenHarmony
console.info('the value of the deviceInfo distributionOSName is :' + distributionOSName);
let distributionOSVersion: string = deviceInfo.distributionOSVersion
// Output: the value of the deviceInfo distributionOSVersion is: 5.0.0
console.info('the value of the deviceInfo distributionOSVersion is :' + distributionOSVersion);
let distributionOSApiVersion: number = deviceInfo.distributionOSApiVersion
// Output: the value of the deviceInfo distributionOSApiVersion is: 500001
console.info('the value of the deviceInfo distributionOSApiVersion is :' + distributionOSApiVersion);
let distributionOSApiName: string = deviceInfo.distributionOSApiName
console.info('the value of the deviceInfo distributionOSApiName is :' + distributionOSApiName);
let distributionOSReleaseType: string = deviceInfo.distributionOSReleaseType
// Output: the value of the deviceInfo distributionOSReleaseType is: Release
console.info('the value of the deviceInfo distributionOSReleaseType is :' + distributionOSReleaseType);
let odid: string = deviceInfo.ODID;
// Output: the value of the deviceInfo odid is: 1234a567-XXXX-XXXX-XXXX-XXXXXXXXXXXX
console.info('the value of the deviceInfo odid is :' + odid);
let diskSN: string = deviceInfo.diskSN;
// Output: the value of the deviceInfo diskSN is: 2502EM400567
console.info('the value of the deviceInfo diskSN is :' + diskSN);
你可能感兴趣的鸿蒙文章
0
赞
- 所属分类: 后端技术
- 本文标签:
热门推荐
-
2、 - 优质文章
-
3、 gate.io
-
8、 golang
-
9、 openharmony
-
10、 Vue中input框自动聚焦