提交 0aac27e4 编写于 作者: IT_newip's avatar IT_newip

Merge branch 'master' of https://gitee.com/openharmony/docs

......@@ -59,8 +59,8 @@ Enumerates the error codes.
| HUKS_ERROR_NEW_ROOT_KEY_MATERIAL_EXIST | -36 |New root key material exists.|
| HUKS_ERROR_UPDATE_ROOT_KEY_MATERIAL_FAIL | -37 |Failed to update the root key material.|
| HUKS_ERROR_VERIFICATION_FAILED | -38 |Failed to verify the certificate chain.|
| HUKS_ERROR_GET_USERIAM_SECINFO_FAILED<sup>9+</sup> | -40 |Failed to obtain the security attribute information of the current user.|
| HUKS_ERROR_GET_USERIAM_AUTHINFO_FAILED<sup>9+</sup> | -41 |Failed to obtain the authentication information of the current user.|
| HUKS_ERROR_GET_USERIAM_SECINFO_FAILED<sup>9+</sup> | -40 |Failed to obtain the security attribute information of the user.|
| HUKS_ERROR_GET_USERIAM_AUTHINFO_FAILED<sup>9+</sup> | -41 |Failed to obtain the authentication information of the user.|
| HUKS_ERROR_USER_AUTH_TYPE_NOT_SUPPORT<sup>9+</sup> | -42 |The access control of the current authentication type is not supported.|
| HUKS_ERROR_KEY_AUTH_FAILED<sup>9+</sup> | -43 |The access control authentication has failed.|
| HUKS_ERROR_DEVICE_NO_CREDENTIAL<sup>9+</sup> | -44 |No credential has been enrolled for the device.|
......@@ -154,7 +154,7 @@ Enumerates the cipher modes.
| Name | Value | Description |
| ------------- | ---- | --------------------- |
| HUKS_MODE_ECB | 1 | Electronic Code bLock (ECB) mode|
| HUKS_MODE_ECB | 1 | Electronic Code BLock (ECB) mode|
| HUKS_MODE_CBC | 2 | Cipher Block Chaining (CBC) mode|
| HUKS_MODE_CTR | 3 | Counter (CTR) mode|
| HUKS_MODE_OFB | 4 | Output Feedback (OFB) mode|
......@@ -297,7 +297,7 @@ Enumerates the user authentication types.
## HuksAuthAccessType<sup>9+</sup>
Enumerates access control types.
Enumerates the access control types.
**System capability**: SystemCapability.Security.Huks
......@@ -320,7 +320,7 @@ Enumerates the types of the challenges generated when a key is used.
## HuksChallengePosition<sup>9+</sup>
Enumerates the positions of the 8-byte custom challenges.
Enumerates the positions of the 8-byte valid value in a custom challenge generated.
**System capability**: SystemCapability.Security.Huks
......@@ -364,7 +364,7 @@ Enumerates the tags used to invoke parameters.
**System capability**: SystemCapability.Security.Huks
| Name | Value | Description |
| -------------------------------------------- | ---------------------------------------- | ------------------------------------------------------------ |
| -------------------------------------------- | ---------------------------------------- | -------------------------------------- |
| HUKS_TAG_INVALID | HuksTagType.HUKS_TAG_TYPE_INVALID \| 0 | Invalid tag. |
| HUKS_TAG_ALGORITHM | HUKS_TAG_TYPE_UINT \| 1 | Algorithm. |
| HUKS_TAG_PURPOSE | HuksTagType.HUKS_TAG_TYPE_UINT \| 2 | Purpose of a key. |
......@@ -399,13 +399,13 @@ Enumerates the tags used to invoke parameters.
| HUKS_TAG_ALL_USERS | ksTagType.HUKS_TAG_TYPE_BOOL \| 301 | Reserved. |
| HUKS_TAG_USER_ID | HuksTagType.HUKS_TAG_TYPE_UINT \| 302 | Reserved. |
| HUKS_TAG_NO_AUTH_REQUIRED | HuksTagType.HUKS_TAG_TYPE_BOOL \| 303 | Reserved. |
| HUKS_TAG_USER_AUTH_TYPE | HuksTagType.HUKS_TAG_TYPE_UINT \| 304 | User authentication type. For details, see [HuksUserAuthType](#huksuserauthtype9). This parameter must be set together with [HuksAuthAccessType](#huksauthaccesstype9). You can set a maximum of two user authentication types at a time. For example, if **HuksAuthAccessType** is **HKS_SECURE_ACCESS_INVALID_NEW_BIO_ENROLL**, you can set two of **HKS_USER_AUTH_TYPE_FACE**, **HKS_USER_AUTH_TYPE_FINGERPRINT**, and **HKS_USER_AUTH_TYPE_FACE**. |
| HUKS_TAG_USER_AUTH_TYPE | HuksTagType.HUKS_TAG_TYPE_UINT \| 304 | User authentication type. For details, see [HuksUserAuthType](#huksuserauthtype9). This parameter must be set together with [HuksAuthAccessType](#huksauthaccesstype9). You can set a maximum of two user authentication types at a time. For example, if **HuksAuthAccessType** is **HKS_SECURE_ACCESS_INVALID_NEW_BIO_ENROLL**, you can set the authentication type to **HKS_USER_AUTH_TYPE_FACE**, **HKS_USER_AUTH_TYPE_FINGERPRINT**, or their combination.|
| HUKS_TAG_AUTH_TIMEOUT | HuksTagType.HUKS_TAG_TYPE_UINT \| 305 | Reserved. |
| HUKS_TAG_AUTH_TOKEN | HuksTagType.HUKS_TAG_TYPE_BYTES \| 306 | Reserved. |
| HUKS_TAG_KEY_AUTH_ACCESS_TYPE<sup>9+</sup> | HuksTagType.HUKS_TAG_TYPE_UINT \| 307 | Access control type. For details, see [HuksAuthAccessType](#huksauthaccesstype9). This parameter must be set together with [HuksUserAuthType](#huksuserauthtype9). |
| HUKS_TAG_KEY_SECURE_SIGN_TYPE<sup>9+</sup> | HuksTagType.HUKS_TAG_TYPE_UINT \| 308 | Signature type of the key generated or imported. |
| HUKS_TAG_CHALLENGE_TYPE<sup>9+</sup> | HuksTagType.HUKS_TAG_TYPE_UINT \| 309 | Type of the challenge generated for a key. For details, see [HuksChallengeType](#hukschallengetype9). |
| HUKS_TAG_CHALLENGE_POS<sup>9+</sup> | HuksTagType.HUKS_TAG_TYPE_UINT \| 310 | Position of the 8-bypte custom challenge. For details, see [HuksChallengePosition](#hukschallengeposition9). |
| HUKS_TAG_KEY_AUTH_ACCESS_TYPE<sup>9+</sup> | HuksTagType.HUKS_TAG_TYPE_UINT \| 307 | Access control type. For details, see [HuksAuthAccessType](#huksauthaccesstype9). This parameter must be set together with [HuksUserAuthType](#huksuserauthtype9).|
| HUKS_TAG_KEY_SECURE_SIGN_TYPE<sup>9+</sup> | HuksTagType.HUKS_TAG_TYPE_UINT \| 308 | Signature type of the key generated or imported.|
| HUKS_TAG_CHALLENGE_TYPE<sup>9+</sup> | HuksTagType.HUKS_TAG_TYPE_UINT \| 309 | Type of the challenge generated for a key. For details, see [HuksChallengeType](#hukschallengetype9).|
| HUKS_TAG_CHALLENGE_POS<sup>9+</sup> | HuksTagType.HUKS_TAG_TYPE_UINT \| 310 | Position of the 8-byte valid value in a custom challenge. For details, see [HuksChallengePosition](#hukschallengeposition9).|
| HUKS_TAG_ATTESTATION_CHALLENGE | HuksTagType.HUKS_TAG_TYPE_BYTES \| 501 | Challenge value used in the attestation. |
| HUKS_TAG_ATTESTATION_APPLICATION_ID | HuksTagType.HUKS_TAG_TYPE_BYTES \| 502 | Application ID used in the attestation. |
| HUKS_TAG_ATTESTATION_ID_BRAND | HuksTagType.HUKS_TAG_TYPE_BYTES \| 503 | Brand of the device. |
......@@ -421,7 +421,7 @@ Enumerates the tags used to invoke parameters.
| HUKS_TAG_ATTESTATION_ID_UDID | HuksTagType.HUKS_TAG_TYPE_BYTES \| 513 | Device UDID. |
| HUKS_TAG_ATTESTATION_ID_SEC_LEVEL_INFO | HuksTagType.HUKS_TAG_TYPE_BYTES \| 514 | Security credential used in the attestation. |
| HUKS_TAG_ATTESTATION_ID_VERSION_INFO | HuksTagType.HUKS_TAG_TYPE_BYTES \| 515 | Version information used in the attestation. |
| HUKS_TAG_IS_KEY_ALIAS | HuksTagType.HUKS_TAG_TYPE_BOOL \| 1001 | Whether to use the alias passed in during key generation. |
| HUKS_TAG_IS_KEY_ALIAS | HuksTagType.HUKS_TAG_TYPE_BOOL \| 1001 | Whether to use the alias passed in during key generation.|
| HUKS_TAG_KEY_STORAGE_FLAG | HuksTagType.HUKS_TAG_TYPE_UINT \| 1002 | Key storage mode. |
| HUKS_TAG_IS_ALLOWED_WRAP | HuksTagType.HUKS_TAG_TYPE_BOOL \| 1003 | Reserved. |
| HUKS_TAG_KEY_WRAP_TYPE | HuksTagType.HUKS_TAG_TYPE_UINT \| 1004 | Reserved. |
......@@ -502,7 +502,7 @@ huks.generateKey(keyAlias, options, function (err, data){});
generateKey(keyAlias: string, options: HuksOptions) : Promise\<HuksResult>
Generates a key. This API uses a promise to return the result asynchronously.
Generates a key. This API uses a promise to return the result.
**System capability**: SystemCapability.Security.Huks
......@@ -580,7 +580,7 @@ huks.deleteKey(keyAlias, emptyOptions, function (err, data) {});
deleteKey(keyAlias: string, options: HuksOptions) : Promise\<HuksResult>
Deletes a key. This API uses a promise to return the result asynchronously.
Deletes a key. This API uses a promise to return the result.
**System capability**: SystemCapability.Security.Huks
......@@ -700,7 +700,7 @@ huks.importKey(keyAlias, options, function (err, data){});
importKey(keyAlias: string, options: HuksOptions) : Promise\<HuksResult>
Imports a key in plaintext. This API uses a promise to return the result asynchronously.
Imports a key in plaintext. This API uses a promise to return the result.
**System capability**: SystemCapability.Security.Huks
......@@ -798,6 +798,51 @@ function printLog(...data) {
console.error(data.toString());
}
async function generateKey(alias) {
let properties = new Array();
properties[0] = {
tag: huks.HuksTag.HUKS_TAG_ALGORITHM,
value: huks.HuksKeyAlg.HUKS_ALG_RSA
};
properties[1] = {
tag: huks.HuksTag.HUKS_TAG_KEY_STORAGE_FLAG,
value: huks.HuksKeyStorageType.HUKS_STORAGE_PERSISTENT
};
properties[2] = {
tag: huks.HuksTag.HUKS_TAG_KEY_SIZE,
value: huks.HuksKeySize.HUKS_RSA_KEY_SIZE_2048
};
properties[3] = {
tag: huks.HuksTag.HUKS_TAG_PURPOSE,
value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_VERIFY
};
properties[4] = {
tag: huks.HuksTag.HUKS_TAG_DIGEST,
value: huks.HuksKeyDigest.HUKS_DIGEST_SHA256
};
properties[5] = {
tag: huks.HuksTag.HUKS_TAG_PADDING,
value: huks.HuksKeyPadding.HUKS_PADDING_PSS
};
properties[6] = {
tag: huks.HuksTag.HUKS_TAG_KEY_GENERATE_TYPE,
value: huks.HuksKeyGenerateType.HUKS_KEY_GENERATE_TYPE_DEFAULT
};
properties[7] = {
tag: huks.HuksTag.HUKS_TAG_BLOCK_MODE,
value: huks.HuksCipherMode.HUKS_MODE_ECB
};
let options = {
properties: properties
};
await huks.generateKey(alias, options).then(async (data) => {
console.error(`generateKey data ${JSON.stringify(data)}`);
}).catch((err) => {
console.error(`generateKey err: " + ${JSON.stringify(err)}`);
});;
}
async function attestKey() {
let aliasString = keyAliasString;
let aliasUint8 = stringToUint8Array(aliasString);
......@@ -821,7 +866,7 @@ async function attestKey() {
let options = {
properties: properties
};
generateKey(aliasString);
await generateKey(aliasString);
huks.attestKey(aliasString, options, function (err, data) {
printLog(`key attest result : ${JSON.stringify(data)}`);
});
......@@ -870,6 +915,51 @@ function printLog(...data) {
console.error(data.toString());
}
async function generateKey(alias) {
let properties = new Array();
properties[0] = {
tag: huks.HuksTag.HUKS_TAG_ALGORITHM,
value: huks.HuksKeyAlg.HUKS_ALG_RSA
};
properties[1] = {
tag: huks.HuksTag.HUKS_TAG_KEY_STORAGE_FLAG,
value: huks.HuksKeyStorageType.HUKS_STORAGE_PERSISTENT
};
properties[2] = {
tag: huks.HuksTag.HUKS_TAG_KEY_SIZE,
value: huks.HuksKeySize.HUKS_RSA_KEY_SIZE_2048
};
properties[3] = {
tag: huks.HuksTag.HUKS_TAG_PURPOSE,
value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_VERIFY
};
properties[4] = {
tag: huks.HuksTag.HUKS_TAG_DIGEST,
value: huks.HuksKeyDigest.HUKS_DIGEST_SHA256
};
properties[5] = {
tag: huks.HuksTag.HUKS_TAG_PADDING,
value: huks.HuksKeyPadding.HUKS_PADDING_PSS
};
properties[6] = {
tag: huks.HuksTag.HUKS_TAG_KEY_GENERATE_TYPE,
value: huks.HuksKeyGenerateType.HUKS_KEY_GENERATE_TYPE_DEFAULT
};
properties[7] = {
tag: huks.HuksTag.HUKS_TAG_BLOCK_MODE,
value: huks.HuksCipherMode.HUKS_MODE_ECB
};
let options = {
properties: properties
};
await huks.generateKey(alias, options).then(async (data) => {
console.error(`generateKey data ${JSON.stringify(data)}`);
}).catch((err) => {
console.error(`generateKey err: " + ${JSON.stringify(err)}`);
});;
}
async function attestKey() {
let aliasString = keyAliasString;
let aliasUint8 = stringToUint8Array(aliasString);
......@@ -893,7 +983,7 @@ async function attestKey() {
let options = {
properties: properties
};
generateKey(aliasString);
await generateKey(aliasString);
huks.attestKey(aliasString, options)
.then((data) => {
console.log(`test attestKey data: ${JSON.stringify(data)}`);
......@@ -1096,7 +1186,7 @@ function huksImportWrappedKey() {
importWrappedKey(keyAlias: string, wrappingKeyAlias: string, options: HuksOptions) : Promise\<HuksResult>
Imports a wrapped key. This API uses a promise to return the result asynchronously.
Imports a wrapped key. This API uses a promise to return the result.
**System capability**: SystemCapability.Security.Huks
......@@ -1159,7 +1249,7 @@ huks.exportKey(keyAlias, emptyOptions, function (err, data){});
exportKey(keyAlias: string, options: HuksOptions) : Promise\<HuksResult>
Exports a key. This API uses a promise to return the result asynchronously.
Exports a key. This API uses a promise to return the result.
**System capability**: SystemCapability.Security.Huks
......@@ -1218,7 +1308,7 @@ huks.getKeyProperties(keyAlias, emptyOptions, function (err, data){});
getKeyProperties(keyAlias: string, options: HuksOptions) : Promise\<HuksResult>
Obtains key properties. This API uses a promise to return the result asynchronously.
Obtains key properties. This API uses a promise to return the result.
**System capability**: SystemCapability.Security.Huks
......@@ -1277,7 +1367,7 @@ huks.isKeyExist(keyAlias, emptyOptions, function (err, data){});
isKeyExist(keyAlias: string, options: HuksOptions) : Promise\<boolean>
Checks whether a key exists. This API uses a promise to return the result asynchronously.
Checks whether a key exists. This API uses a promise to return the result.
**System capability**: SystemCapability.Security.Huks
......@@ -1311,7 +1401,7 @@ var result = huks.isKeyExist(keyAlias, emptyOptions);
init(keyAlias: string, options: HuksOptions, callback: AsyncCallback\<HuksHandle>) : void
Initializes a key. This API uses an asynchronous callback to return the result.
Initializes the data for a key operation. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Security.Huks
......@@ -1328,7 +1418,7 @@ Initializes a key. This API uses an asynchronous callback to return the result.
init(keyAlias: string, options: HuksOptions) : Promise\<HuksHandle>
Initializes a key. This API uses a promise to return the result asynchronously.
Initializes the data for a key operation. This API uses a promise to return the result.
**System capability**: SystemCapability.Security.Huks
......@@ -1345,9 +1435,9 @@ Initializes a key. This API uses a promise to return the result asynchronously.
update(handle: number, token?: Uint8Array, options: HuksOptions, callback: AsyncCallback\<HuksResult>) : void
Updates a key. This API uses an asynchronous callback to return the result.
Updates the key operation data by segment. This API uses an asynchronous callback to return the result.
> **NOTE**<br>This API is discarded since API version 9. You are advised to use [huks.update<sup>9+</sup>].
> **NOTE**<br>This API is deprecated since API version 9. You are advised to use [huks.update<sup>9+</sup>](#huksupdate9-1).
**System capability**: SystemCapability.Security.Huks
......@@ -1364,9 +1454,9 @@ Updates a key. This API uses an asynchronous callback to return the result.
update(handle: number, token?: Uint8Array, options: HuksOptions) : Promise\<HuksResult>
Updates a key. This API uses a promise to return the result asynchronously.
Updates the key operation data by segment. This API uses a promise to return the result.
> **NOTE**<br>This API is discarded since API version 9. You are advised to use [huks.update<sup>9+</sup>](#huksupdate9).
> **NOTE**<br>This API is discarded since API version 9. You are advised to use [huks.update<sup>9+</sup>](#huksupdate9-2).
**System capability**: SystemCapability.Security.Huks
......@@ -1383,7 +1473,7 @@ Updates a key. This API uses a promise to return the result asynchronously.
update(handle: number, options: HuksOptions, callback: AsyncCallback\<HuksResult>) : void
Updates a key. This API uses an asynchronous callback to return the result.
Updates the key operation by segment. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Security.Huks
......@@ -1400,7 +1490,7 @@ Updates a key. This API uses an asynchronous callback to return the result.
update(handle: number, options: HuksOptions, token: Uint8Array, callback: AsyncCallback\<HuksResult>) : void
Updates a key. This API uses an asynchronous callback to return the result.
Updates the key operation by segment. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Security.Huks
......@@ -1417,7 +1507,7 @@ Updates a key. This API uses an asynchronous callback to return the result.
update(handle: number, options: HuksOptions, token?: Uint8Array) : Promise\<HuksResult>
Updates a key. This API uses a promise to return the result asynchronously.
Updates the key operation by segment. This API uses a promise to return the result.
**System capability**: SystemCapability.Security.Huks
......@@ -1451,7 +1541,7 @@ Completes the key operation and releases resources. This API uses an asynchronou
finish(handle: number, options: HuksOptions) : Promise\<HuksResult>
Completes the key operation and releases resources. This API uses a promise to return the result asynchronously.
Completes the key operation and releases resources. This API uses a promise to return the result.
**System capability**: SystemCapability.Security.Huks
......@@ -1485,7 +1575,7 @@ Completes the key operation and releases resources. This API uses an asynchronou
finish(handle: number, options: HuksOptions, token?: Uint8Array) : Promise\<HuksResult>
Completes the key operation and releases resources. This API uses a promise to return the result asynchronously.
Completes the key operation and releases resources. This API uses a promise to return the result.
**System capability**: SystemCapability.Security.Huks
......@@ -1722,7 +1812,7 @@ struct Index {
abort(handle: number, options: HuksOptions) : Promise\<HuksResult>;
Aborts the use of the key. This API uses a promise to return the result asynchronously.
Aborts the use of the key. This API uses a promise to return the result.
**System capability**: SystemCapability.Security.Huks
......@@ -1976,7 +2066,7 @@ Defines the HUKS handle structure.
| ---------- | ---------------- | ---- | -------- |
| errorCode | number | Yes | Error code.|
| handle | number | Yes| Value of the handle.|
| token | Uint8Array | No| Challenge information obtained after the [init](#huksinit) operation.|
| token | Uint8Array | No| Challenge obtained after the [init](#huksinit) operation.|
## HuksResult
......
# Standard NFC Tag
# NFC Tags
The **nfcTag** module provides methods for managing Near-Field Communication (NFC) tags.
......
# Standard NFC Tag Technologies
# NFC Tag Technologies
The **nfctech** module provides methods for reading and writing tags that use different Near-Field Communication (NFC) technologies.
The **nfctech** module provides APIs for reading and writing tags that use different Near-Field Communication (NFC) technologies.
> **NOTE**
>
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## **Modules to Import**
......@@ -14,7 +13,7 @@ import tag from '@ohos.nfc.tag';
## NfcATag
Provides access to NFC-A (ISO 14443-3A) properties and I/O operations. **NfcATag** inherits from **TagSession**.
Provides access to NFC-A (ISO 14443-3A) properties and I/O operations. This class inherits from **TagSession**.
**TagSession** is the base class of all NFC tag technologies. It provides common interfaces for establishing connections and transferring data. For more details, see [TagSession](js-apis-tagSession.md).
......@@ -74,7 +73,7 @@ console.log("atqa:" +atqa);
## NfcBTag
Provides access to NFC-B (ISO 14443-3B) properties and I/O operations. **NfcBTag** inherits from **TagSession**.
Provides access to NFC-B (ISO 14443-3B) properties and I/O operations. This class inherits from **TagSession**.
**TagSession** is the base class of all NFC tag technologies. It provides common interfaces for establishing connections and transferring data. For more details, see [TagSession](js-apis-tagSession.md).
......@@ -110,7 +109,7 @@ console.log("appData:" +appData);
getRespProtocol(): number[]
Obtains protocol information of this NFC-B tag.
Obtains the protocol information of this NFC-B tag.
**Required permissions**: ohos.permission.NFC_TAG
......@@ -134,7 +133,7 @@ console.log("appData:" +protocol);
## NfcFTag
Provides access to NFC-F(JIS 6319-4) properties and I/O operations. **NfcFTag** inherits from **TagSession**.
Provides access to NFC-F (JIS 6319-4) properties and I/O operations. This class inherits from **TagSession**.
**TagSession** is the base class of all NFC tag technologies. It provides common interfaces for establishing connections and transferring data. For more details, see [TagSession](js-apis-tagSession.md).
......@@ -144,7 +143,7 @@ The following describes the unique interfaces of **NfcFTag**.
getSystemCode(): number[]
Obtains the system code from the tag instance.
Obtains the system code from this NFC-F tag.
**Required permissions**: ohos.permission.NFC_TAG
......@@ -170,7 +169,7 @@ console.log("systemCode:" +systemCode);
getPmm(): number[]
Obtains the PMm (consisting of the IC code and manufacturer parameters) information from the tag instance.
Obtains the PMm (consisting of the IC code and manufacturer parameters) information from this NFC-F tag.
**Required permissions**: ohos.permission.NFC_TAG
......@@ -194,7 +193,7 @@ console.log("pmm:" +pmm);
## NfcVTag
Provides access to NFC-V (ISO 15693) properties and I/O operations. **NfcVTag** inherits from **TagSession**.
Provides access to NFC-V (ISO 15693) properties and I/O operations. This class inherits from **TagSession**.
**TagSession** is the base class of all NFC tag technologies. It provides common interfaces for establishing connections and transferring data. For more details, see [TagSession](js-apis-tagSession.md).
......@@ -204,7 +203,7 @@ The following describes the unique interfaces of **NfcVTag**.
getResponseFlags(): number
Obtains the response flags from the tag instance.
Obtains the response flags from this NFC-V tag.
**Required permissions**: ohos.permission.NFC_TAG
......@@ -230,7 +229,7 @@ console.log("flags:" +flags);
getDsfId(): number
Obtains the data storage format identifier (DSFID) from the tag instance.
Obtains the data storage format identifier (DSFID) from this NFC-V tag.
**Required permissions**: ohos.permission.NFC_TAG
......@@ -254,7 +253,7 @@ console.log("dsfId:" +dsfId);
## IsoDepTag<sup>9+</sup>
Provides access to ISO-DEP (ISO 14443-4) properties and I/O operations. **IsoDepTag** inherits from **TagSession**.
Provides access to ISO-DEP (ISO 14443-4) properties and I/O operations. This class inherits from **TagSession**.
**TagSession** is the base class of all NFC tag technologies. It provides common interfaces for establishing connections and transferring data. For more details, see [TagSession](js-apis-tagSession.md).
......@@ -343,7 +342,7 @@ tag.getIsoDepTag(taginfo).isExtendedApduSupported().then(function (has) {
isExtendedApduSupported(callback: AsyncCallback\<boolean>): void
Checks whether an extended application protocol data unit (APDU) is supported. This API uses an asynchronous callback to return the result.
Checks whether an extended APDU is supported. This API uses an asynchronous callback to return the result.
**Required permissions**: ohos.permission.NFC_TAG
......@@ -367,7 +366,7 @@ tag.getIsoDepTag(taginfo).isExtendedApduSupported(function (error, has) {
## NdefTag<sup>9+</sup>
Provides access to the tags in the NFC Data Exchange Format (NDEF). **NdefTag** inherits from **TagSession**.
Provides access to the tags in the NFC Data Exchange Format (NDEF). This class inherits from **TagSession**.
**TagSession** is the base class of all NFC tag technologies. It provides common interfaces for establishing connections and transferring data. For more details, see [TagSession](js-apis-tagSession.md).
......@@ -596,7 +595,7 @@ Reads the NDEF message from this tag. This API uses a promise to return the resu
| **Type**| **Description** |
| ------------------ | --------------------------|
| Promise\<[NdefMessage](#ndefmessage9)> | Promise used to return the message read.|
| Promise\<[NdefMessage](#ndefmessage9)> | Promise used to return the NDEF message read.|
**Example**
......@@ -641,7 +640,7 @@ tag.NdefTag(taginfo).readNdef(function (error, ndefMessage) {
writeNdef(msg: NdefMessage): Promise\<number>;
Write an NDEF message to this tag. This API uses a promise to return the result.
Writes an NDEF message to this tag. This API uses a promise to return the result.
**Required permissions**: ohos.permission.NFC_TAG
......@@ -674,7 +673,7 @@ NdefTag.writeNdef(msg).then(function (netHandle) {
writeNdef(msg: NdefMessage, callback: AsyncCallback\<number>): void
Write an NDEF message to this tag. This API uses an asynchronous callback to return the result.
Writes an NDEF message to this tag. This API uses an asynchronous callback to return the result.
**Required permissions**: ohos.permission.NFC_TAG
......@@ -728,7 +727,7 @@ tag.NdefTag(taginfo).canSetReadOnly().then(function (has) {
### NdefTag.canSetReadOnly<sup>9+</sup>
canSetReadOnly()(callback: AsyncCallback&lt;boolean&gt;): void;
canSetReadOnly(callback: AsyncCallback&lt;boolean&gt;): void;
Checks whether this NDEF tag can be set to read-only. This API uses an asynchronous callback to return the result.
......@@ -813,7 +812,7 @@ tag.NdefTag(taginfo).setReadOnly(function (error, errcode) {
getNdefTagTypeString(type: [NfcForumType](#nfcforumtype9)): string
Converts the NFC Forum Type to a byte array defined in the NFC Forum.
Converts an NFC Forum Type to a byte array defined in the NFC Forum.
**Required permissions**: ohos.permission.NFC_TAG
......@@ -852,7 +851,7 @@ let ndefTypeString= tag.NdefTag(taginfo).getNdefTagTypeString(type);
## MifareClassicTag <sup>9+</sup>
Provides access to MIFARE Classic properties and I/O operations. **MifareClassicTag** inherits from **TagSession**.
Provides access to MIFARE Classic properties and I/O operations. This class inherits from **TagSession**.
**TagSession** is the base class of all NFC tag technologies. It provides common interfaces for establishing connections and transferring data. For more details, see [TagSession](js-apis-tagSession.md).
......@@ -928,7 +927,7 @@ tag.MifareClassicTag(taginfo).authenticateSector(sectorIndex, key, function (err
readSingleBlock(blockIndex: number): Promise\<string>
Reads a block on the tag. The size of a block is 16 bytes. This API uses a promise to return the result.
Reads a block (16 bytes) on the tag. This API uses a promise to return the result.
**Required permissions**: ohos.permission.NFC_TAG
......@@ -962,7 +961,7 @@ tag.MifareClassicTag(taginfo).readSingleBlock(blockIndex).then(function (data){
readSingleBlock(blockIndex: number, callback: AsyncCallback\<string>): void
Reads a block on the tag. The size of a block is 16 bytes. This API uses an asynchronous callback to return the result.
Reads a block (16 bytes) on the tag. This API uses an asynchronous callback to return the result.
**Required permissions**: ohos.permission.NFC_TAG
......@@ -992,7 +991,7 @@ tag.MifareClassicTag(taginfo).readSingleBlock(blockIndex, function (error, data)
writeSingleBlock(blockIndex: number, data: string): Promise\<number>
Writes data to a block on the tag. The size of a block is 16 bytes. This API uses a promise to return the result.
Writes data to a block on the tag. This API uses a promise to return the result.
**Required permissions**: ohos.permission.NFC_TAG
......@@ -1027,7 +1026,7 @@ tag.MifareClassicTag(taginfo).writeSingleBlock(blockIndex, data).then(function (
writeSingleBlock(blockIndex: number, data: string, callback: AsyncCallback\<number>): void
Writes data to a block on the tag. The size of a block is 16 bytes. This API uses an asynchronous callback to return the result.
Writes data to a block on the tag. This API uses an asynchronous callback to return the result.
**Required permissions**: ohos.permission.NFC_TAG
......@@ -1427,10 +1426,10 @@ let size = tag.MifareClassicTag(taginfo).getTagSize();
| **Name**| **Value**| **Description**|
| -------- | -------- | -------- |
| MC_SIZE_MINI | 320 | Each tag has five sectors, and each sector has four blocks.|
| MC_SIZE_1K | 1024 | Each tag has 16 sectors, and each sector has four blocks.|
| MC_SIZE_2K | 2048 | Each tag has 32 sectors, and each sector has four blocks.|
| MC_SIZE_4K | 4096 | Each tag has 40 sectors, and each sector has four blocks.|
| MC_SIZE_MINI | 320 | Each tag has 5 sectors, and each sector has 4 blocks.|
| MC_SIZE_1K | 1024 | Each tag has 16 sectors, and each sector has 4 blocks.|
| MC_SIZE_2K | 2048 | Each tag has 32 sectors, and each sector has 4 blocks.|
| MC_SIZE_4K | 4096 | Each tag has 40 sectors, and each sector has 4 blocks.|
### MifareClassicTag.isEmulatedTag<sup>9+</sup>
......@@ -1521,7 +1520,7 @@ let index = tag.MifareClassicTag(taginfo).getSectorIndex(blockIndex);
## MifareUltralightTag<sup>9+</sup>
Provides access to MIFARE Ultralight properties and I/O operations. **MifareUltralightTag** inherits from **TagSession**.
Provides access to MIFARE Ultralight properties and I/O operations. This class inherits from **TagSession**.
**TagSession** is the base class of all NFC tag technologies. It provides common interfaces for establishing connections and transferring data. For more details, see [TagSession](js-apis-tagSession.md).
......@@ -1531,7 +1530,7 @@ The following describes the unique interfaces of **MifareUltralightTag**.
readMultiplePages(pageIndex: number): Promise\<string>
Reads multiple pages. The size of each page is 4 bytes. This API uses a promise to return the result.
Reads multiple pages (4 bytes per page). This API uses a promise to return the result.
**Required permissions**: ohos.permission.NFC_TAG
......@@ -1565,7 +1564,7 @@ tag.MifareUltralightTag(taginfo).readMultiplePages(pageIndex).then(function (dat
readMultiplePages(pageIndex: number, callback: AsyncCallback\<string>): void
Reads multiple pages. The size of each page is 4 bytes. This API uses an asynchronous callback to return the result.
Reads multiple pages (4 bytes per page). This API uses an asynchronous callback to return the result.
**Required permissions**: ohos.permission.NFC_TAG
......@@ -1594,7 +1593,7 @@ tag.MifareUltralightTag(taginfo).readMultiplePages(pageIndex, function (error, d
writeSinglePages(pageIndex: number, data: string): Promise\<number>
Writes a page of data. The size of each page is 4 bytes. This API uses a promise to return the result.
Writes a page of data. This API uses a promise to return the result.
**Required permissions**: ohos.permission.NFC_TAG
......@@ -1628,7 +1627,7 @@ tag.MifareUltralightTag(taginfo).writeSinglePages(pageIndex, data).then(function
writeSinglePages(pageIndex: number, data: string, callback: AsyncCallback\<number>): void
Writes a page of data. The size of each page is 4 bytes. This API uses an asynchronous callback to return the result.
Writes a page of data. This API uses an asynchronous callback to return the result.
**Required permissions**: ohos.permission.NFC_TAG
......@@ -1658,7 +1657,7 @@ tag.MifareUltralightTag(taginfo).writeSinglePages(pageIndex, data, function (err
getType(): MifareUltralightType
Obtains the MIFARE Ultralight tag type, in bytes. For details, see [MifareUltralightType](#mifareultralighttype9).
Obtains the MIFARE Ultralight tag type, in bytes.
**Required permissions**: ohos.permission.NFC_TAG
......@@ -1689,7 +1688,7 @@ let type = tag.MifareUltralightType(taginfo).getType();
## NdefFormatableTag<sup>9+</sup>
Provides methods for operating NDEF formattable tags. **NdefFormatableTag** inherits from **TagSession**.
Provides APIs for operating NDEF formattable tags. This class inherits from **TagSession**.
**TagSession** is the base class of all NFC tag technologies. It provides common interfaces for establishing connections and transferring data. For more details, see [TagSession](js-apis-tagSession.md).
......@@ -1709,7 +1708,7 @@ Formats this tag as an NDEF tag, and writes an NDEF message to the tag. This API
| Name | Type | Mandatory| Description |
| -------- | ----------------------- | ---- | -------------------------------------- |
| message | [NdefMessage](#ndefmessage9) | Yes | NDEF message to write when the formatting is successful. If it is **null**, the tag is formatted only and no data will be written.|
| message | [NdefMessage](#ndefmessage9) | Yes | NDEF message to write when the formatting is successful. If this parameter is **null**, the tag is formatted only (no data will be written).|
**Return value**
......@@ -1742,8 +1741,8 @@ Formats this tag as an NDEF tag, and writes an NDEF message to the tag. This API
| Name | Type | Mandatory| Description |
| -------- | ----------------------- | ---- | -------------------------------------- |
| message | [NdefMessage](#ndefmessage9) | Yes | NDEF message to write when the formatting is successful. If it is **null**, the tag is formatted only and no data will be written.|
| callback: AsyncCallback\<number> | Callback invoked to return the result.|
| message | [NdefMessage](#ndefmessage9) | Yes | NDEF message to write when the formatting is successful. If this parameter is **null**, the tag is formatted only.|
| callback | AsyncCallback\<number> |Yes|Callback invoked to return the result.|
**Example**
......@@ -1771,7 +1770,7 @@ Formats this tag as an NDEF tag, writes an NDEF message to the NDEF tag, and the
| Name | Type | Mandatory| Description |
| -------- | ----------------------- | ---- | -------------------------------------- |
| message | [NdefMessage](#ndefmessage9) | Yes | NDEF message to write when the formatting is successful. If it is **null**, the tag is formatted only and no data will be written.|
| message | [NdefMessage](#ndefmessage9) | Yes | NDEF message to write when the formatting is successful. If this parameter is **null**, the tag is formatted only (no data will be written).|
**Return value**
......@@ -1804,8 +1803,8 @@ Formats this tag as an NDEF tag, writes an NDEF message to the NDEF tag, and the
| Name | Type | Mandatory| Description |
| -------- | ----------------------- | ---- | -------------------------------------- |
| message | [NdefMessage](#ndefmessage9) | Yes | NDEF message to write when the formatting is successful. If it is **null**, the tag is formatted only and no data will be written.|
| callback: AsyncCallback\<number> | Callback invoked to return the result.|
| message | [NdefMessage](#ndefmessage9) | Yes | NDEF message to write when the formatting is successful. If this parameter is **null**, the tag is formatted only.|
| callback | AsyncCallback\<number> |Yes|Callback invoked to return the result.|
**Example**
......
# Standard NFC Tag Session
# NFC Tag Session
The **tagSession** module provides common APIs for establishing connections and transferring data.
> **NOTE**
>
> **NOTE**<br>
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## **Modules to Import**
......@@ -18,7 +17,7 @@ Provides common APIs for establishing connections and transferring data. **tagSe
A child class instance is required to access the following interfaces. You can use **get**XX**Tag()** to obtain a child class instance.
The specific method varies with the NFC tag technology in use. For details, see [nfcTag](js-apis-nfcTag.md).
The specific API varies with the NFC tag technology in use. For details, see [NFC Tags](js-apis-nfcTag.md).
### tagSession.connectTag
......@@ -26,7 +25,7 @@ connectTag(): boolean;
Connects to this tag.
Call this method to set up a connection before reading data from or writing data to a tag.
Call this API to set up a connection before reading data from or writing data to a tag.
**Required permissions**: ohos.permission.NFC_TAG
......@@ -95,7 +94,7 @@ Checks whether the tag is connected.
```js
import tag from '@ohos.nfc.tag';
// tagInfo is an Object given by nfc service when tag is dispatched.
// tagInfo is an object given by the NFC service when a tag is dispatched.
let isTagConnected = tag.getXXXTag(taginfo).isTagConnected();
console.log("isTagConnected:" +isTagConnected);
```
......
......@@ -4,33 +4,33 @@
### Function
The motion recognition module provides motion recognition and control capabilities. Currently, OpenHarmony supports recognition of pick-up, flip, shake, and rotation.
The motion module provides motion recognition and control capabilities. Currently, OpenHarmony supports recognition of pick-up, flip, shake, and rotation.
The motion recognition driver is developed based on the hardware driver foundation (HDF). It shields hardware differences and provides APIs for the Multimodal Sensor Data Platform (MSDP) to implement capabilities such as enabling or disabling motion recognition, and subscribing to or unsubscribing from motion recognition data.
The motion driver is developed based on the hardware driver foundation (HDF). It shields hardware differences and provides APIs for the Multimodal Sensor Data Platform (MSDP) to implement capabilities such as enabling or disabling motion recognition, and subscribing to or unsubscribing from motion recognition data.
The figure below shows the motion recognition driver architecture. The framework layer provides MSDP services, and interacts with the Motion Stub through the Motion Proxy in the User Hardware Driver Foundation (UHDF). The Motion Stub calls the Motion HDI Impl APIs to provide motion recognition capabilities for upper-layer services.
The figure below shows the motion driver architecture. The framework layer provides MSDP services, and interacts with the Motion Stub through the Motion Proxy in the User Hardware Driver Foundation (UHDF). The Motion Stub calls the Motion HDI Impl APIs to provide motion recognition capabilities for upper-layer services.
**Figure 1** Motion recognition driver architecture
**Figure 1** Motion driver architecture
![](figures/motion_recognition_driver_architecture.png)
![](figures/motion_driver_architecture.png)
### Working Principles
The figure below illustrates how a motion recognition driver works.
The figure below illustrates how a motion driver works.
**Figure 2** How a motion recognition driver works
**Figure 2** How a motion driver works
![](figures/motion_recognition_driver_work.png)
![](figures/motion_driver_work.png)
1. MSDP: The MSDP service obtains a Motion HDI service instance from the Motion Proxy and calls the Motion HDI API.
2. IDL: The IService Manager allocates a Motion HDI instance requested by the MSDP service, and the Motion Proxy forwards the instance to the MSDP service. After the MSDP service calls the HDI API provided by the Motion Proxy, Motion Stub is called through Inter-Process Communication (IPC) to invoke the Motion Service API. The code is automatically generated by a tool and does not need to be developed by the component vendor.
3. HDI Service: HDI Service consists of Motion Interface Driver, Motion Service, and Motion Impl. Motion Interface Driver provides the motion recognition driver code. A **HdfDriverEntry** structure is defined to implement the **Init**, **Bind**, and **Release** functions. The **HDF_INIT** macro is used to load the driver in the functions. Motion Service provides the motion recognition service interface class. The specific implementation is described in Motion Impl. The code of HDI Service must be developed by the component vendor.
3. HDI Service: HDI Service consists of Motion Interface Driver, Motion Service, and Motion Impl. Motion Interface Driver provides the motion driver code. A **HdfDriverEntry** structure is defined to implement the **Init**, **Bind**, and **Release** functions. The **HDF_INIT** macro is used to load the driver in the functions. Motion Service provides the motion recognition service interface class. The specific implementation is described in Motion Impl. The code of HDI Service must be developed by the component vendor.
## Development Guidelines
### When to Use
The motion recognition driver provides capabilities for the MSDP service to enable or disable motion recognition and subscribe to or unsubscribe from motion recognition data. It can be used for motion recognition when a user picks up, flips, shakes, and rotates a device.
The motion driver provides capabilities for the MSDP service to enable or disable motion recognition and subscribe to or unsubscribe from motion recognition data. It can be used for motion recognition when a user picks up, flips, shakes, and rotates a device.
### Available APIs
......@@ -59,7 +59,7 @@ The motion recognition directory structure is as follows:
│ └── unittest\hdi # HDI unit test code for the motion recognition module.
```
The following describes how to develop a user-mode motion recognition driver based on the HDF. For details, see [motion_interface_driver.cpp](https://gitee.com/openharmony/drivers_peripheral/blob/master/motion/hdi_service/motion_interface_driver.cpp).
The following describes how to develop a user-mode motion driver based on the HDF. For details, see [motion_interface_driver.cpp](https://gitee.com/openharmony/drivers_peripheral/blob/master/motion/hdi_service/motion_interface_driver.cpp).
To develop the user-mode driver for motion recognition, implement the **Bind**, **Init**, **Release**, and **Dispatch** functions. The **Bind** function provides service capabilities. The **Init** function initializes the driver before the driver is loaded. The **Release** function releases resources when the **Init** function fails.
......@@ -99,7 +99,7 @@ int HdfMotionInterfaceDriverInit(struct HdfDeviceObject *deviceObject)
return HDF_SUCCESS;
}
// Bind the services provided by the motion recognition driver to the HDF.
// Bind the services provided by the motion driver to the HDF.
int HdfMotionInterfaceDriverBind(struct HdfDeviceObject *deviceObject)
{
HDF_LOGI("HdfMotionInterfaceDriverBind enter");
......@@ -131,7 +131,7 @@ int HdfMotionInterfaceDriverBind(struct HdfDeviceObject *deviceObject)
return HDF_SUCCESS;
}
// Release the resources used by the motion recognition driver.
// Release the resources used by the motion driver.
void HdfMotionInterfaceDriverRelease(struct HdfDeviceObject *deviceObject)
{
HDF_LOGI("HdfMotionInterfaceDriverRelease enter");
......
......@@ -4,6 +4,20 @@
- [Compilation and Building Guide](subsys-build-all.md)
- [Build System Coding Specifications and Best Practices](subsys-build-gn-coding-style-and-best-practice.md)
- [Building the Kconfig Visual Configuration](subsys-build-gn-kconfig-visual-config-guide.md)
- Related Operations
- [Building a Product](subsys-build-product.md)
- [Building a Subsystem](subsys-build-subsystem.md)
- [Building a Component](subsys-build-component.md)
- [Building a Module](subsys-build-module.md)
- [Building a Chipset Solution](subsys-build-chip_solution.md)
- [Configuring Features](subsys-build-feature.md)
- [Configuring System Capabilities](subsys-build-syscap.md)
- [Setting deps and external_deps](subsys-build-reference.md#deps-and-external_deps)
- [Information Collected by the Open Source Software Notice](subsys-build-reference.md#information-collected-by-the-open-source-software-notice)
- [Configuring Parameters for Accelerating Local Build](subsys-build-reference.md#parameters-for-accelerating-local-build)
- [Viewing Ninja Build Information](subsys-build-reference.md#viewing-ninja-build-information)
- [HAP Build Guide](subsys-build-gn-hap-compilation-guide.md)
- [FAQs](subsys-build-FAQ.md)
- [Distributed Remote Startup](subsys-remote-start.md)
- Graphics
- [Graphics Overview](subsys-graphics-overview.md)
......@@ -70,6 +84,7 @@
- [Development on Application Permission Management](subsys-security-rightmanagement.md)
- [Development on IPC Authentication](subsys-security-communicationverify.md)
- [Development on Device Security Level Management](subsys-security-devicesecuritylevel.md)
- [Development on HUKS](subsys-security-huks-guide.md)
- Startup
- [Startup](subsys-boot-overview.md)
- init Module
......
此差异已折叠。
......@@ -4,17 +4,14 @@
HUAWEI DevEco Studio For OpenHarmony(以下简称DevEco Studio)是基于IntelliJ IDEA Community开源版本打造,面向OpenHarmony全场景多设备的一站式集成开发环境(IDE),为开发者提供工程模板创建、开发、编译、调试、发布等E2E的OpenHarmony应用/服务开发。
[DevEco Studio 3.0 Beta3](https://developer.harmonyos.com/cn/develop/deveco-studio#download_beta_openharmony) 作为支撑OpenHarmony应用和服务开发的IDE,具有以下能力特点:
[DevEco Studio](https://developer.harmonyos.com/cn/develop/deveco-studio/) 作为支撑OpenHarmony应用和服务开发的IDE,具有以下能力特点:
- 支持一站式的信息获取平台
- 提供多设备工程模板
- 高效的代码编辑
- 支持可视化的界面UI开发
- 双向、极速的界面UI预览
- 全新的编译工具Hvigor
- 支持基于设备系统能力集Syscap进行应用开发
- 支持全自动化的应用签名机制
- 丰富的代码调试调优能力
- **高效智能代码编辑**:支持eTS、JavaScript、C/C++等语言的代码高亮、代码智能补齐、代码错误检查、代码自动跳转、代码格式化、代码查找等功能,提升代码编写效率。更多详细信息,请参考[编辑器使用技巧](https://developer.harmonyos.com/cn/docs/documentation/doc-guides/ohos-editor-usage-tips-0000001263360493)
- **低代码可视化开发**:丰富的UI界面编辑能力,支持自由拖拽组件和可视化数据绑定,可快速预览效果,所见即所得;同时支持卡片的零代码开发,降低开发门槛和提升界面开发效率。更多详细信息,请参考使用[低代码开发应用/服务](https://developer.harmonyos.com/cn/docs/documentation/doc-guides/ohos-low-code-development-0000001218440652)
- **多端双向实时预览**:支持UI界面代码的双向预览、实时预览、动态预览、组件预览以及多端设备预览,便于快速查看代码运行效果。更多详细信息,请参考[使用预览器预览应用/服务界面效果](https://developer.harmonyos.com/cn/docs/documentation/doc-guides/ohos-previewing-app-service-0000001218760596)
- **全新构建体系**:通过Hvigor编译构建工具,一键完成应用及服务的编译和打包,更好地支持eTS/JS开发。
- **一站式信息获取**:基于开发者了解、学习、开发、求助的用户旅程,在DevEco Studio中提供一站式的信息获取平台,高效支撑开发者活动。
- **高效代码调试**:提供TS、JS 、C/C++代码的断点设置,单步执行、变量查看等调试能力,提升应用及服务的问题分析效率。
更多工具体验和使用指导请见:[DevEco Studio (OpenHarmony) 使用指南](https://developer.harmonyos.com/cn/docs/documentation/doc-guides/ohos-deveco-studio-overview-0000001263280421)
......@@ -8,6 +8,8 @@
应用中存在用户能够直观感受到的且需要一直在后台运行的业务时(如,后台播放音乐),可以使用长时任务机制。
对于系统特权应用,提供独立的能效资源申请接口。系统特权应用如果需要使用特定的系统资源,例如在被挂起期间仍然能够收到系统公共事件,可以使用能效资源申请接口。
> **说明:**
> 本模块首批接口从API version 7开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
......@@ -201,7 +203,7 @@ startBackgroundRunning(context: Context, bgMode: BackgroundMode, wantAgent: Want
| bgMode | [BackgroundMode](#backgroundmode8) | 是 | 向系统申请的后台模式。 |
| wantAgent | [WantAgent](js-apis-wantAgent.md) | 是 | 通知参数,用于指定长时任务通知点击跳转的界面。 |
**返回值**
**返回值**
| 类型 | 说明 |
| -------------- | ---------------- |
| Promise\<void> | 使用Promise形式返回结果。 |
......@@ -279,7 +281,7 @@ stopBackgroundRunning(context: Context): Promise&lt;void&gt;
| ------- | ------- | ---- | ---------------------------------------- |
| context | Context | 是 | 应用运行的上下文。<br>FA模型的应用Context定义见[Context](js-apis-Context.md)<br>Stage模型的应用Context定义见[Context](js-apis-ability-context.md)。 |
**返回值**
**返回值**
| 类型 | 说明 |
| -------------- | ---------------- |
| Promise\<void> | 使用Promise形式返回结果。 |
......@@ -297,6 +299,64 @@ backgroundTaskManager.stopBackgroundRunning(featureAbility.getContext()).then(()
```
## backgroundTaskManager.applyEfficiencyResources<sup>9+</sup>
applyEfficiencyResources(request: [EfficiencyResourcesRequest](#efficiencyresourcesrequest9)): boolean
向系统申请能效资源,使用boolean形式返回结果。
进程和它所属的应用可以同时申请某一类资源,例如CPU资源,但是应用释放资源的时候会将进程的资源一起释放。
**系统能力**: SystemCapability.ResourceSchedule.BackgroundTaskManager.EfficiencyResourcesApply
**系统API**: 此接口为系统接口。
**参数**
| 参数名 | 类型 | 必填 | 说明 |
| ------- | ------- | ---- | ---------------------------------------- |
| request | [EfficiencyResourcesRequest](#efficiencyresourcesrequest9) | 是 | 请求的必要信息。包括资源类型,超时时间等信息。详见[EfficiencyResourcesRequest](#efficiencyresourcesrequest9)。 |
**返回值**
| 类型 | 说明 |
| -------------- | ---------------- |
| boolean | true代表申请成功,false代表申请失败。 |
**示例**
```js
import backgroundTaskManager from '@ohos.backgroundTaskManager';
let request = {
resourceTypes: backgroundTaskManager.ResourceType.CPU,
isApply: true,
timeOut: 0,
reason: "apply",
isPersist: true,
isProcess: false,
};
let res = backgroundTaskManager.applyEfficiencyResources(request);
console.info("result of applyEfficiencyResources is: " + res)
```
## backgroundTaskManager.resetAllEfficiencyResources<sup>9+</sup>
resetAllEfficiencyResources(): void
释放所有已经申请的资源。
**系统能力:** SystemCapability.ResourceSchedule.BackgroundTaskManager.EfficiencyResourcesApply
**系统API**: 此接口为系统接口。
**示例**
```js
import backgroundTaskManager from '@ohos.backgroundTaskManager';
backgroundTaskManager.backgroundTaskManager.resetAllEfficiencyResources();
```
## DelaySuspendInfo
延迟挂起信息。
......@@ -315,12 +375,47 @@ backgroundTaskManager.stopBackgroundRunning(featureAbility.getContext()).then(()
| 参数名 | 参数值 | 描述 |
| ----------------------- | ---- | --------------------- |
| DATA_TRANSFER | 1 | 数据传输 |
| AUDIO_PLAYBACK | 2 | 音频播放 |
| AUDIO_RECORDING | 3 | 录音 |
| LOCATION | 4 | 定位导航 |
| BLUETOOTH_INTERACTION | 5 | 蓝牙相关 |
| MULTI_DEVICE_CONNECTION | 6 | 多设备互联 |
| DATA_TRANSFER | 1 | 数据传输 |
| AUDIO_PLAYBACK | 2 | 音频播放 |
| AUDIO_RECORDING | 3 | 录音 |
| LOCATION | 4 | 定位导航 |
| BLUETOOTH_INTERACTION | 5 | 蓝牙相关 |
| MULTI_DEVICE_CONNECTION | 6 | 多设备互联 |
| WIFI_INTERACTION | 7 | WLAN相关<br />此接口为系统接口。 |
| VOIP | 8 | 音视频通话<br />此接口为系统接口。 |
| TASK_KEEPING | 9 | 计算任务(仅在特定设备生效) |
\ No newline at end of file
| TASK_KEEPING | 9 | 计算任务(仅在特定设备生效)。 |
## EfficiencyResourcesRequest<sup>9+</sup>
能效资源申请参数。
**系统能力:** SystemCapability.ResourceSchedule.BackgroundTaskManager.EfficiencyResourcesApply
**系统API**: 此接口为系统接口。
| 参数名 | 类型 | 必填 | 说明 |
| --------------- | ------ | ---- | ---------------------------------------- |
| resourceTypes | number | 是 | 申请的资源类型。 |
| isApply | boolean | 是 | 申请资源或者是释放资源。 |
| timeOut | number | 是 | 资源的使用时间,以毫秒为单位。 |
| isPersist | boolean | 否 | 是否永久持有资源,如果是true,那么timeOut就无效。 |
| isProcess | boolean | 否 | 应用申请或者是进程申请。 |
| reason | string | 是 | 申请资源的原因。 |
## ResourceType<sup>9+</sup>
能效资源类型。
**系统能力:** SystemCapability.ResourceSchedule.BackgroundTaskManager.EfficiencyResourcesApply
**系统API**: 此接口为系统接口。
| 参数名 | 参数值 | 描述 |
| ----------------------- | ---- | --------------------- |
| CPU | 1 | CPU资源,申请后不被挂起。 |
| COMMON_EVENT | 2 | 公共事件,申请后挂起状态下不被代理掉。 |
| TIMER | 4 | 计时器,申请后挂起状态下不被代理掉。 |
| WORK_SCHEDULER | 8 | 延迟任务,申请后有更长的执行时间。 |
| BLUETOOTH | 16 | 蓝牙相关,申请后挂起状态下不被代理掉。 |
| GPS | 32 | GPS相关,申请后挂起状态下不被代理掉。 |
| AUDIO | 64 | 音频资源,申请后挂起状态下不被代理掉。 |
\ No newline at end of file
......@@ -7,19 +7,19 @@
LauncherAbilityInfo信息
LauncherAbilityInfo信息,通过接口[innerBundleManager.getLauncherAbilityInfos](js-apis-Bundle-InnerBundleManager.md)获取。
## LauncherAbilityInfo
**系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework
**系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework。
**系统API:**此接口为系统接口,三方应用不支持调用
**系统API:** 此接口为系统接口,三方应用不支持调用。
| 名称 | 类型 | 可读 | 可写 | 说明 |
| --------------- | ---------------------------------------------------- | ---- | ---- | ------------------------------------ |
| applicationInfo | [ApplicationInfo](js-apis-bundle-ApplicationInfo.md) | 是 | 否 | launcher ability的应用程序的配置信息 |
| elementName | [ElementName](js-apis-bundle-ElementName.md) | 是 | 否 | launcher ability的ElementName信息 |
| labelId | number | 是 | 否 | launcher ability的标签ID |
| iconId | number | 是 | 否 | launcher ability的图标ID |
| userId | number | 是 | 否 | launcher ability的用户ID |
| installTime | number | 是 | 否 | launcher ability的安装时间 |
\ No newline at end of file
| --------------- | ---------------------------------------------------- | ---- | ---- | -------------------------------------- |
| applicationInfo | [ApplicationInfo](js-apis-bundle-ApplicationInfo.md) | 是 | 否 | launcher ability的应用程序的配置信息。 |
| elementName | [ElementName](js-apis-bundle-ElementName.md) | 是 | 否 | launcher ability的ElementName信息。 |
| labelId | number | 是 | 否 | launcher ability的标签ID。 |
| iconId | number | 是 | 否 | launcher ability的图标ID。 |
| userId | number | 是 | 否 | launcher ability的用户ID。 |
| installTime | number | 是 | 否 | launcher ability的安装时间。 |
\ No newline at end of file
......@@ -433,7 +433,7 @@ ws.off('open', callback1);
on\(type: 'message', callback: AsyncCallback<string | ArrayBuffer\>\): void
订阅WebSocket的接收到服务器消息事件,使用callback方式作为异步方法。
订阅WebSocket的接收到服务器消息事件,使用callback方式作为异步方法。每个消息最大长度为4K,超过4K自动分片。
>![](public_sys-resources/icon-note.gif) **说明:**
>AsyncCallback中的数据可以是字符串\(API 6\)或ArrayBuffer\(API 8\)。
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册