提交 d149dcf5 编写于 作者: A Annie_wang

update docs

Signed-off-by: NAnnie_wang <annie.wangli@huawei.com>
上级 e07927e1
...@@ -100,6 +100,182 @@ Checks whether an application is the default application of the specified servic ...@@ -100,6 +100,182 @@ Checks whether an application is the default application of the specified servic
| ------- | ------------------------------------ | | ------- | ------------------------------------ |
| boolean | Returns **true** if the application is the default payment application; returns **false** otherwise.| | boolean | Returns **true** if the application is the default payment application; returns **false** otherwise.|
## HceService<sup>8+</sup>
Implements HCE, including receiving Application Protocol Data Units (APDUs) from the peer card reader and sending a response. Before using HCE-related APIs, check whether the device supports HCE. This API is used only for declaration and cannot be used currently.
### startHCE<sup>8+</sup>
startHCE(aidList: string[]): boolean
Starts HCE, including setting the application to be foreground preferred and dynamically registering the application identifier (AID) list. This API is used only for declaration and cannot be used currently.
> **NOTE**
> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [start](#start9).
**Required permissions**: ohos.permission.NFC_CARD_EMULATION
**System capability**: SystemCapability.Communication.NFC.CardEmulation
**Parameters**
| Name | Type | Mandatory| Description |
| ------- | -------- | ---- | ----------------------- |
| aidList | string[] | Yes | AID list to register.|
### start<sup>9+</sup>
start(elementName: ElementName, aidList: string[]): void
Starts HCE, including setting the application to be foreground preferred and dynamically registering the application identifier (AID) list. This API is used only for declaration and cannot be used currently.
**Required permissions**: ohos.permission.NFC_CARD_EMULATION
**System capability**: SystemCapability.Communication.NFC.CardEmulation
**Parameters**
| Name | Type | Mandatory| Description |
| ------- | -------- | ---- | ----------------------- |
| elementName | ElementName | Yes | Element name of a service capability.|
| aidList | string[] | Yes | AID list to register.|
**Error codes**
For details about the error codes, see [NFC Error Codes](../errorcodes/errorcode-nfc.md).
| ID| Error Message |
| ------- | -------|
| 3100301 | Card emulation running state is abnormal in service. |
### stopHCE<sup>8+</sup>
stopHCE(): boolean
Stops HCE, including removing the foreground preferred attribute and releasing the dynamically registered AID list. This API is used only for declaration and cannot be used currently.
> **NOTE**
> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [stop](#stop).
**Required permissions**: ohos.permission.NFC_CARD_EMULATION
**System capability**: SystemCapability.Communication.NFC.CardEmulation
### stop<sup>9+</sup>
stop(elementName: ElementName): void;
Stops HCE, including removing the foreground preferred attribute and releasing the dynamically registered AID list. This API is used only for declaration and cannot be used currently.
**Required permissions**: ohos.permission.NFC_CARD_EMULATION
**System capability**: SystemCapability.Communication.NFC.CardEmulation
**Parameters**
| Name | Type | Mandatory| Description |
| ------- | -------- | ---- | ----------------------- |
| elementName | ElementName | Yes | Element name of a service capability.|
**Error codes**
For details about the error codes, see [NFC Error Codes](../errorcodes/errorcode-nfc.md).
| ID| Error Message |
| ------- | -------|
| 3100301 | Card emulation running state is abnormal in service. |
### on<sup>8+</sup>
on(type: "hceCmd", callback: AsyncCallback<number[]>): void;
Registers a callback to receive APDUs from the peer card reader. This API is used only for declaration and cannot be used currently.
**Required permissions**: ohos.permission.NFC_CARD_EMULATION
**System capability**: SystemCapability.Communication.NFC.CardEmulation
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ----------------------- | ---- | -------------------------------------------- |
| type | string | Yes | Event type to subscribe to. The value is **hceCmd**. |
| callback | AsyncCallback<number[]> | Yes | Callback invoked to return the APDU, which consists of hexadecimal numbers ranging from **0x00** to **0xFF**.|
### sendResponse<sup>8+</sup>
sendResponse(responseApdu: number[]): void;
Sends a response to the peer card reader. This API is used only for declaration and cannot be used currently.
> **NOTE**
> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [transmit](#transmit9).
**Required permissions**: ohos.permission.NFC_CARD_EMULATION
**System capability**: SystemCapability.Communication.NFC.CardEmulation
**Parameters**
| Name | Type | Mandatory| Description |
| ------------ | -------- | ---- | -------------------------------------------------- |
| responseApdu | number[] | Yes | Response APDU sent to the peer card reader. The value consists of hexadecimal numbers ranging from **0x00** to **0xFF**.|
### transmit<sup>9+</sup>
transmit(response: number[]): Promise\<void>;
Sends a response to the peer card reader. This API is used only for declaration and cannot be used currently.
**Required permissions**: ohos.permission.NFC_CARD_EMULATION
**System capability**: SystemCapability.Communication.NFC.CardEmulation
**Parameters**
| Name | Type | Mandatory| Description |
| ------------ | -------- | ---- | -------------------------------------------------- |
| responseApdu | number[] | Yes | Response APDU sent to the peer card reader. The value consists of hexadecimal numbers ranging from **0x00** to **0xFF**.|
**Return value**
| **Type** | **Description** |
| ------- | -------------------------------------- |
| Promise\<void> | Promise that returns no value.|
**Error codes**
For details about the error codes, see [NFC Error Codes](../errorcodes/errorcode-nfc.md).
| ID| Error Message |
| ------- | -------|
| 3100301 | Card emulation running state is abnormal in service. |
### transmit<sup>9+</sup>
transmit(response: number[], callback: AsyncCallback\<void>): void;
Sends a response to the peer card reader. This API is used only for declaration and cannot be used currently.
**Required permissions**: ohos.permission.NFC_CARD_EMULATION
**System capability**: SystemCapability.Communication.NFC.CardEmulation
**Parameters**
| Name | Type | Mandatory| Description |
| ------- | -------- | ---- | ----------------------- |
| responseApdu | number[] | Yes | Response APDU sent to the peer card reader. The value consists of hexadecimal numbers ranging from **0x00** to **0xFF**.|
| callback | AsyncCallback\<void> | Yes | Callback that returns no value.|
**Error codes**
For details about the error codes, see [NFC Error Codes](../errorcodes/errorcode-nfc.md).
| ID| Error Message |
| ------- | -------|
| 3100301 | Card emulation running state is abnormal in service. |
**Example** **Example**
```js ```js
......
...@@ -525,7 +525,7 @@ import tag from '@ohos.nfc.tag'; ...@@ -525,7 +525,7 @@ import tag from '@ohos.nfc.tag';
let elementName = null; let elementName = null;
let discTech = [tag.NFC_A, tag.NFC_B]; // replace with the tech(s) that is needed by foreground ability let discTech = [tag.NFC_A, tag.NFC_B]; // replace with the tech(s) that is needed by foreground ability
function foregroundCb(err, taginfo) { function foregroundCb(err, tagInfo) {
if (!err) { if (!err) {
console.log("foreground callback: tag found tagInfo = ", JSON.stringify(tagInfo)); console.log("foreground callback: tag found tagInfo = ", JSON.stringify(tagInfo));
} else { } else {
......
...@@ -1863,7 +1863,7 @@ The following describes the unique APIs of **MifareUltralightTag**. ...@@ -1863,7 +1863,7 @@ The following describes the unique APIs of **MifareUltralightTag**.
readMultiplePages(pageIndex: number): Promise\<number[]> readMultiplePages(pageIndex: number): Promise\<number[]>
Reads four pages (4 bytes per page) from this tag. This API uses a promise to return the result. Reads four pages of data (4 bytes per page) from this tag. This API uses a promise to return the result.
**Required permissions**: ohos.permission.NFC_TAG **Required permissions**: ohos.permission.NFC_TAG
...@@ -1921,7 +1921,7 @@ try { ...@@ -1921,7 +1921,7 @@ try {
readMultiplePages(pageIndex: number, callback: AsyncCallback\<number[]>): void readMultiplePages(pageIndex: number, callback: AsyncCallback\<number[]>): void
Reads four pages (4 bytes per page) from this tag. This API uses an asynchronous callback to return the result. Reads four pages of data (4 bytes per page) from this tag. This API uses an asynchronous callback to return the result.
**Required permissions**: ohos.permission.NFC_TAG **Required permissions**: ohos.permission.NFC_TAG
...@@ -2188,6 +2188,13 @@ Formats this tag as an NDEF tag, and writes an NDEF message to it. This API uses ...@@ -2188,6 +2188,13 @@ Formats this tag as an NDEF tag, and writes an NDEF message to it. This API uses
| ------------------ | --------------------------| | ------------------ | --------------------------|
| callback: AsyncCallback\<void> | Callback invoked to return the result.| | callback: AsyncCallback\<void> | Callback invoked to return the result.|
**Error codes**
For details about the error codes, see [NFC Error Codes](../errorcodes/errorcode-nfc.md).
| ID| Error Message|
| ------- | -------|
| 3100201 | Tag running state is abnormal in service. |
**Example** **Example**
...@@ -2297,6 +2304,13 @@ Formats this tag as an NDEF tag, writes an NDEF message to the NDEF tag, and the ...@@ -2297,6 +2304,13 @@ Formats this tag as an NDEF tag, writes an NDEF message to the NDEF tag, and the
| ------------------ | --------------------------| | ------------------ | --------------------------|
| callback: AsyncCallback\<void> | Callback invoked to return the result.| | callback: AsyncCallback\<void> | Callback invoked to return the result.|
**Error codes**
For details about the error codes, see [NFC Error Codes](../errorcodes/errorcode-nfc.md).
| ID| Error Message|
| ------- | -------|
| 3100201 | Tag running state is abnormal in service. |
**Example** **Example**
......
...@@ -261,7 +261,7 @@ For details about error codes, see [SE Error Codes](../errorcodes/errorcode-se.m ...@@ -261,7 +261,7 @@ For details about error codes, see [SE Error Codes](../errorcodes/errorcode-se.m
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------- | | -------- | -------------------------------- |
| 3300101 | Illegal service state exception. | | 3300101 | IllegalStateError, service state exception. |
**Example** **Example**
...@@ -302,8 +302,8 @@ For details about error codes, see [SE Error Codes](../errorcodes/errorcode-se.m ...@@ -302,8 +302,8 @@ For details about error codes, see [SE Error Codes](../errorcodes/errorcode-se.m
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------- | | -------- | -------------------------------- |
| 3300101 | Illegal service state exception. | | 3300101 | IllegalStateError, service state exception. |
| 3300104 | Secure element IO exception. | | 3300104 | IOError, there is a communication problem to the reader or the SE. |
**Example** **Example**
...@@ -340,7 +340,7 @@ For details about error codes, see [SE Error Codes](../errorcodes/errorcode-se.m ...@@ -340,7 +340,7 @@ For details about error codes, see [SE Error Codes](../errorcodes/errorcode-se.m
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------- | | -------- | -------------------------------- |
| 3300101 | Illegal service state exception. | | 3300101 | IllegalStateError, service state exception. |
**Example** **Example**
...@@ -413,7 +413,7 @@ For details about error codes, see [SE Error Codes](../errorcodes/errorcode-se.m ...@@ -413,7 +413,7 @@ For details about error codes, see [SE Error Codes](../errorcodes/errorcode-se.m
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------- | | -------- | -------------------------------- |
| 3300101 | Illegal service state exception. | | 3300101 | IllegalStateError, service state exception. |
**Example** **Example**
...@@ -456,7 +456,7 @@ For details about error codes, see [SE Error Codes](../errorcodes/errorcode-se.m ...@@ -456,7 +456,7 @@ For details about error codes, see [SE Error Codes](../errorcodes/errorcode-se.m
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------- | | -------- | -------------------------------- |
| 3300101 | Illegal service state exception. | | 3300101 | IllegalStateError, service state exception. |
**Example** **Example**
...@@ -526,7 +526,7 @@ For details about error codes, see [SE Error Codes](../errorcodes/errorcode-se.m ...@@ -526,7 +526,7 @@ For details about error codes, see [SE Error Codes](../errorcodes/errorcode-se.m
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------- | | -------- | -------------------------------- |
| 3300101 | Illegal service state exception. | | 3300101 | IllegalStateError, service state exception. |
**Example** **Example**
...@@ -570,10 +570,10 @@ For details about error codes, see [SE Error Codes](../errorcodes/errorcode-se.m ...@@ -570,10 +570,10 @@ For details about error codes, see [SE Error Codes](../errorcodes/errorcode-se.m
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------- | | -------- | -------------------------------- |
| 3300101 | Illegal service state exception. | | 3300101 | IllegalStateError, an attempt is made to use an SE session that has been closed. |
| 3300102 | No such element exception. | | 3300102 | NoSuchElementError, the AID on the SE is not available or cannot be selected. |
| 3300103 | Illegal access rule exception. | | 3300103 | SecurityError, the calling application cannot be granted access to this AID or the default applet on this session. |
| 3300104 | Secure element IO exception. | | 3300104 | IOError, there is a communication problem to the reader or the SE. |
**Example** **Example**
...@@ -619,10 +619,10 @@ For details about error codes, see [SE Error Codes](../errorcodes/errorcode-se.m ...@@ -619,10 +619,10 @@ For details about error codes, see [SE Error Codes](../errorcodes/errorcode-se.m
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------- | | -------- | -------------------------------- |
| 3300101 | Illegal service state exception. | | 3300101 | IllegalStateError, an attempt is made to use an SE session that has been closed. |
| 3300102 | No such element exception. | | 3300102 | NoSuchElementError, the AID on the SE is not available or cannot be selected. |
| 3300103 | Illegal access rule exception. | | 3300103 | SecurityError, the calling application cannot be granted access to this AID or the default applet on this session. |
| 3300104 | Secure element IO exception. | | 3300104 | IOError, there is a communication problem to the reader or the SE. |
**Example** **Example**
...@@ -675,10 +675,10 @@ For details about error codes, see [SE Error Codes](../errorcodes/errorcode-se.m ...@@ -675,10 +675,10 @@ For details about error codes, see [SE Error Codes](../errorcodes/errorcode-se.m
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------- | | -------- | -------------------------------- |
| 3300101 | Illegal service state exception. | | 3300101 | IllegalStateError, an attempt is made to use an SE session that has been closed. |
| 3300102 | No such element exception. | | 3300102 | NoSuchElementError, the AID on the SE is not available or cannot be selected. |
| 3300103 | Illegal access rule exception. | | 3300103 | SecurityError, the calling application cannot be granted access to this AID or the default applet on this session. |
| 3300104 | Secure element IO exception. | | 3300104 | IOError, there is a communication problem to the reader or the SE. |
**Example** **Example**
...@@ -726,10 +726,10 @@ For details about error codes, see [SE Error Codes](../errorcodes/errorcode-se.m ...@@ -726,10 +726,10 @@ For details about error codes, see [SE Error Codes](../errorcodes/errorcode-se.m
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------- | | -------- | -------------------------------- |
| 3300101 | Illegal service state exception. | | 3300101 | IllegalStateError, an attempt is made to use an SE session that has been closed. |
| 3300102 | No such element exception. | | 3300102 | NoSuchElementError, the AID on the SE is not available or cannot be selected. |
| 3300103 | Illegal access rule exception. | | 3300103 | SecurityError, the calling application cannot be granted access to this AID or the default applet on this session. |
| 3300104 | Secure element IO exception. | | 3300104 | IOError, there is a communication problem to the reader or the SE. |
**Example** **Example**
...@@ -782,10 +782,10 @@ For details about error codes, see [SE Error Codes](../errorcodes/errorcode-se.m ...@@ -782,10 +782,10 @@ For details about error codes, see [SE Error Codes](../errorcodes/errorcode-se.m
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------- | | -------- | -------------------------------- |
| 3300101 | Illegal service state exception. | | 3300101 | IllegalStateError, an attempt is made to use an SE session that has been closed. |
| 3300102 | No such element exception. | | 3300102 | NoSuchElementError, the AID on the SE is not available or cannot be selected. |
| 3300103 | Illegal access rule exception. | | 3300103 | SecurityError, the calling application cannot be granted access to this AID or the default applet on this session. |
| 3300104 | Secure element IO exception. | | 3300104 | IOError, there is a communication problem to the reader or the SE. |
**Example** **Example**
...@@ -831,10 +831,10 @@ For details about error codes, see [SE Error Codes](../errorcodes/errorcode-se.m ...@@ -831,10 +831,10 @@ For details about error codes, see [SE Error Codes](../errorcodes/errorcode-se.m
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------- | | -------- | -------------------------------- |
| 3300101 | Illegal service state exception. | | 3300101 | IllegalStateError, an attempt is made to use an SE session that has been closed. |
| 3300102 | No such element exception. | | 3300102 | NoSuchElementError, the AID on the SE is not available or cannot be selected. |
| 3300103 | Illegal access rule exception. | | 3300103 | SecurityError, the calling application cannot be granted access to this AID or the default applet on this session. |
| 3300104 | Secure element IO exception. | | 3300104 | IOError, there is a communication problem to the reader or the SE. |
**Example** **Example**
...@@ -887,10 +887,10 @@ For details about error codes, see [SE Error Codes](../errorcodes/errorcode-se.m ...@@ -887,10 +887,10 @@ For details about error codes, see [SE Error Codes](../errorcodes/errorcode-se.m
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------- | | -------- | -------------------------------- |
| 3300101 | Illegal service state exception. | | 3300101 | IllegalStateError, an attempt is made to use an SE session that has been closed. |
| 3300102 | No such element exception. | | 3300102 | NoSuchElementError, the AID on the SE is not available or cannot be selected. |
| 3300103 | Illegal access rule exception. | | 3300103 | SecurityError, the calling application cannot be granted access to this AID or the default applet on this session. |
| 3300104 | Secure element IO exception. | | 3300104 | IOError, there is a communication problem to the reader or the SE. |
**Example** **Example**
...@@ -947,10 +947,10 @@ For details about error codes, see [SE Error Codes](../errorcodes/errorcode-se.m ...@@ -947,10 +947,10 @@ For details about error codes, see [SE Error Codes](../errorcodes/errorcode-se.m
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------- | | -------- | -------------------------------- |
| 3300101 | Illegal service state exception. | | 3300101 | IllegalStateError, an attempt is made to use an SE session that has been closed. |
| 3300102 | No such element exception. | | 3300102 | NoSuchElementError, the AID on the SE is not available or cannot be selected. |
| 3300103 | Illegal access rule exception. | | 3300103 | SecurityError, the calling application cannot be granted access to this AID or the default applet on this session. |
| 3300104 | Secure element IO exception. | | 3300104 | IOError, there is a communication problem to the reader or the SE. |
**Example** **Example**
...@@ -1176,9 +1176,9 @@ For details about error codes, see [SE Error Codes](../errorcodes/errorcode-se.m ...@@ -1176,9 +1176,9 @@ For details about error codes, see [SE Error Codes](../errorcodes/errorcode-se.m
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------- | | -------- | -------------------------------- |
| 3300101 | Illegal service state exception. | | 3300101 | IllegalStateError, an attempt is made to use an SE session or channel that has been closed. |
| 3300103 | Illegal access rule exception. | | 3300103 | SecurityError, the command is filtered by the security policy. |
| 3300104 | Secure element IO exception. | | 3300104 | IOError, there is a communication problem to the reader or the SE. |
**Example** **Example**
...@@ -1228,9 +1228,9 @@ For details about error codes, see [SE Error Codes](../errorcodes/errorcode-se.m ...@@ -1228,9 +1228,9 @@ For details about error codes, see [SE Error Codes](../errorcodes/errorcode-se.m
| ID| Error Message | | ID| Error Message |
| -------- | -------------------------------- | | -------- | -------------------------------- |
| 3300101 | Illegal service state exception. | | 3300101 | IllegalStateError, an attempt is made to use an SE session or channel that has been closed. |
| 3300103 | Illegal access rule exception. | | 3300103 | SecurityError, the command is filtered by the security policy. |
| 3300104 | Secure element IO exception. | | 3300104 | IOError, there is a communication problem to the reader or the SE. |
**Example** **Example**
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
**Error Message** **Error Message**
Illegal service state exception. IllegalStateError, an attempt is made to use an SE session that has been closed.
**Description** **Description**
...@@ -28,7 +28,7 @@ The SecureElement (SE) service is abnormal. ...@@ -28,7 +28,7 @@ The SecureElement (SE) service is abnormal.
**Error Message** **Error Message**
No such element exception. NoSuchElementError, the AID on the SE is not available or cannot be selected.
**Description** **Description**
...@@ -48,7 +48,7 @@ The SE is unavailable. ...@@ -48,7 +48,7 @@ The SE is unavailable.
**Error Message** **Error Message**
Illegal access rule exception. SecurityError, the calling application cannot be granted access to this AID or the default applet on this session.
**Description** **Description**
...@@ -67,7 +67,7 @@ The access rule cannot be obtained. ...@@ -67,7 +67,7 @@ The access rule cannot be obtained.
**Error Message** **Error Message**
Secure element IO exception. IOError, there is a communication problem to the reader or the SE.
**Description** **Description**
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册