未验证 提交 e9a844e5 编写于 作者: O openharmony_ci 提交者: Gitee

!12777 [翻译完成】#I662OM

Merge pull request !12777 from Annie_wang/PR12476
......@@ -203,15 +203,16 @@
- [@ohos.data.distributedKVStore](js-apis-distributedKVStore.md)
- [@ohos.data.preferences](js-apis-data-preferences.md)
- [@ohos.data.rdb](js-apis-data-rdb.md)
- [@ohos.data.ValuesBucket](js-apis-data-ValuesBucket.md)
- data/rdb/[resultSet](js-apis-data-resultset.md)
- [@ohos.data.ValuesBucket](js-apis-data-valuesBucket.md)
- data/rdb
- [resultSet](js-apis-data-resultset.md)
- File Management
- [@ohos.document](js-apis-document.md)
- [@ohos.environment](js-apis-environment.md)
- [@ohos.data.fileAccess](js-apis-fileAccess.md)
- [@ohos.fileExtensionInfo](js-apis-fileExtensionInfo.md)
- [@ohos.fileio](js-apis-fileio.md)
- [@ohos.filemanagement.userfile_manager](js-apis-userfilemanager.md)
- [@ohos.filemanagement.userFileManager](js-apis-userfilemanager.md)
- [@ohos.multimedia.medialibrary](js-apis-medialibrary.md)
- [@ohos.securityLabel](js-apis-securityLabel.md)
- [@ohos.statfs](js-apis-statfs.md)
......@@ -240,10 +241,13 @@
- [@ohos.nfc.controller](js-apis-nfcController.md)
- [@ohos.nfc.tag](js-apis-nfcTag.md)
- [@ohos.rpc](js-apis-rpc.md)
- [@ohos.wifiManager (WLAN)](js-apis-wifiManager.md)
- [@ohos.wifiManagerExt](js-apis-wifiManagerExt.md)
- [@ohos.wifi](js-apis-wifi.md)
- [@ohos.wifiext](js-apis-wifiext.md)
- tag/[nfctech](js-apis-nfctech.md)
- tag/[tagSession](js-apis-tagSession.md)
- tag
- [nfctech](js-apis-nfctech.md)
- [tagSession](js-apis-tagSession.md)
- Basic Features
- [@ohos.accessibility](js-apis-accessibility.md)
- [@ohos.accessibility.config](js-apis-accessibility-config.md)
......
# App Account Management
# @ohos.account.appAccount
The **appAccount** module provides APIs for adding, deleting, modifying, and querying app account information, and supports inter-app authentication and distributed data synchronization.
......@@ -3173,7 +3173,7 @@ Set credentials for an app account. This API uses an asynchronous callback to re
| Name | Type | Mandatory | Description |
| -------------- | ------------------------- | ---- | ------------- |
| name | string | Yes | Name of the target app account. |
| credentialType | string | Yes | Type of the credential to delete. |
| credentialType | string | Yes | Type of the credential to set. |
| credential | string | Yes | Credential value. |
| callback | AsyncCallback<void> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object.|
......@@ -3203,7 +3203,7 @@ Set credentials for an app account. This API uses a promise to return the result
| Name | Type | Mandatory | Description |
| -------------- | ------ | ---- | ---------- |
| name | string | Yes | Name of the target app account. |
| credentialType | string | Yes | Type of the credential to delete.|
| credentialType | string | Yes | Type of the credential to set.|
| credential | string | Yes | Credential value.|
**Return value**
......@@ -3576,7 +3576,7 @@ Obtains the credential of an app account. This API uses an asynchronous callback
| Name | Type | Mandatory | Description |
| -------------- | --------------------------- | ---- | -------------- |
| name | string | Yes | Name of the target app account. |
| credentialType | string | Yes | Type of the credential to delete.|
| credentialType | string | Yes | Type of the credential to obtain.|
| callback | AsyncCallback<string> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **null** and **data** is the credential obtained. Otherwise, **err** is an error object.|
**Example**
......@@ -3606,7 +3606,7 @@ Obtains the credential of an app account. This API uses a promise to return the
| Name | Type | Mandatory | Description |
| -------------- | ------ | ---- | ---------- |
| name | string | Yes | Name of the target app account. |
| credentialType | string | Yes | Type of the credential to delete.|
| credentialType | string | Yes | Type of the credential to obtain.|
**Return value**
......
# Bluetooth
# @ohos.bluetooth
The **Bluetooth** module provides classic Bluetooth capabilities and Bluetooth Low Energy (BLE) scan and advertising.
> **NOTE**<br>
> **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.
......@@ -202,7 +203,7 @@ Obtains the connection state of a profile.
| Name | Type | Mandatory | Description |
| --------- | --------- | ---- | ------------------------------------- |
| ProfileId | profileId | Yes | ID of the target profile, for example, **PROFILE_A2DP_SOURCE**.|
| ProfileId | profileId | Yes | ID of the profile to obtain, for example, **PROFILE_A2DP_SOURCE**.|
**Return value**
......@@ -1280,10 +1281,6 @@ Obtains the connected devices.
**System capability**: SystemCapability.Communication.Bluetooth.Core
**Parameters**
No value is returned.
**Return value**
| Type | Description |
......@@ -2695,8 +2692,6 @@ Obtains all services of the remote BLE device. This API uses a promise to return
**System capability**: SystemCapability.Communication.Bluetooth.Core
**Parameters**
**Return value**
| Type | Description |
......@@ -2830,7 +2825,7 @@ Reads the descriptor contained in the specific characteristic of the remote BLE
| Name | Type | Mandatory | Description |
| ---------- | ---------------------------------------- | ---- | ----------------------- |
| descriptor | [BLEDescriptor](#bledescriptor) | Yes | Descriptor to read. |
| callback | AsyncCallback&lt;[BLECharacteristic](#blecharacteristic)&gt; | Yes | Callback invoked to return the descriptor read.|
| callback | AsyncCallback&lt;[BLEDescriptor](#bledescriptor)&gt; | Yes | Callback invoked to return the descriptor read.|
**Return value**
......@@ -3309,7 +3304,7 @@ Enumerates the scan modes.
**System capability**: SystemCapability.Communication.Bluetooth.Core
| Name | Default Value | Description |
| Name | Value | Description |
| ---------------------------------------- | ---- | --------------- |
| SCAN_MODE_NONE | 0 | No scan mode. |
| SCAN_MODE_CONNECTABLE | 1 | Connectable mode. |
......@@ -3324,7 +3319,7 @@ Enumerates the pairing states.
**System capability**: SystemCapability.Communication.Bluetooth.Core
| Name | Default Value | Description |
| Name | Value | Description |
| ------------------ | ---- | ------ |
| BOND_STATE_INVALID | 0 | Invalid pairing.|
| BOND_STATE_BONDING | 1 | Pairing. |
......@@ -3350,7 +3345,7 @@ Enumerates the SPP link types.
**System capability**: SystemCapability.Communication.Bluetooth.Core
| Name | Default Value | Description |
| Name | Value | Description |
| ---------- | ---- | ------------- |
| SPP_RFCOMM | 0 | Radio frequency communication (RFCOMM) link type.|
......@@ -3510,7 +3505,7 @@ Enumerates the profile connection states.
**System capability**: SystemCapability.Communication.Bluetooth.Core
| Name | Default Value | Description |
| Name | Value | Description |
| ------------------- | ---- | -------------- |
| STATE_DISCONNECTED | 0 | Disconnected. |
| STATE_CONNECTING | 1 | Connecting.|
......@@ -3558,7 +3553,7 @@ Enumerates the scan duty options.
**System capability**: SystemCapability.Communication.Bluetooth.Core
| Name | Default Value | Description |
| Name | Value | Description |
| --------------------- | ---- | ------------ |
| SCAN_MODE_LOW_POWER | 0 | Low-power mode, which is the default value.|
| SCAN_MODE_BALANCED | 1 | Balanced mode. |
......@@ -3571,7 +3566,7 @@ Enumerates the hardware match modes of BLE scan filters.
**System capability**: SystemCapability.Communication.Bluetooth.Core
| Name | Default Value | Description |
| Name | Value | Description |
| --------------------- | ---- | ---------------------------------------- |
| MATCH_MODE_AGGRESSIVE | 1 | Hardware reports the scan result with a lower threshold of signal strength and few number of matches in a duration. This is the default value.|
| MATCH_MODE_STICKY | 2 | Hardware reports the scan result with a higher threshold of signal strength and sightings. |
......@@ -3596,7 +3591,7 @@ Enumerates the Bluetooth states.
**System capability**: SystemCapability.Communication.Bluetooth.Core
| Name | Default Value | Description |
| Name | Value | Description |
| --------------------- | ---- | ------------------ |
| STATE_OFF | 0 | Bluetooth is turned off. |
| STATE_TURNING_ON | 1 | Bluetooth is being turned on. |
......@@ -3641,7 +3636,7 @@ Defines the content of a BLE advertisement packet.
| Name | Type | Readable | Writable | Description |
| ---------------- | ------------------- | ---- | ---- | ------------------ |
| manufactureId | Array&lt;string&gt; | Yes | Yes | Manufacturer ID allocated by the Bluetooth SIG.|
| manufactureId | number | Yes | Yes | Manufacturer ID allocated by the Bluetooth SIG.|
| manufactureValue | ArrayBuffer | Yes | Yes | Manufacturer data. |
......@@ -3713,7 +3708,7 @@ Enumerates the major classes of Bluetooth devices.
**System capability**: SystemCapability.Communication.Bluetooth.Core
| Name | Default Value | Description |
| Name | Value | Description |
| ------------------- | ------ | ---------- |
| MAJOR_MISC | 0x0000 | Miscellaneous device. |
| MAJOR_COMPUTER | 0x0100 | Computer. |
......@@ -3734,7 +3729,7 @@ Enumerates the major and minor classes of Bluetooth devices.
**System capability**: SystemCapability.Communication.Bluetooth.Core
| Name | Default Value | Description |
| Name | Value | Description |
| ---------------------------------------- | ------ | --------------- |
| COMPUTER_UNCATEGORIZED | 0x0100 | Unclassified computer. |
| COMPUTER_DESKTOP | 0x0104 | Desktop computer. |
......@@ -3830,7 +3825,7 @@ Enumerates the A2DP playing states.
**System capability**: SystemCapability.Communication.Bluetooth.Core
| Name | Default Value | Description |
| Name | Value | Description |
| ----------------- | ------ | ------- |
| STATE_NOT_PLAYING | 0x0000 | Not playing. |
| STATE_PLAYING | 0x0001 | Playing.|
......@@ -3842,9 +3837,9 @@ Enumerates the Bluetooth profiles. API version 9 is added with **PROFILE_HID_HOS
**System capability**: SystemCapability.Communication.Bluetooth.Core
| Name | Default Value | Description |
| Name | Value | Description |
| -------------------------------- | ------ | --------------- |
| PROFILE_A2DP_SOURCE | 0x0001 | A2DP profile.|
| PROFILE_HANDS_FREE_AUDIO_GATEWAY | 0x0004 | HFP profile. |
| PROFILE_HID_HOST<sup>9+</sup> | 0x0006 | Human Interface Device (HID) profile. |
| PROFILE_PAN_NETWORK<sup>9+</sup> | 0x0007 | PAN profile. |
| PROFILE_A2DP_SOURCE | 1 | A2DP profile.|
| PROFILE_HANDS_FREE_AUDIO_GATEWAY | 4 | HFP profile. |
| PROFILE_HID_HOST<sup>9+</sup> | 6 | Human Interface Device (HID) profile. |
| PROFILE_PAN_NETWORK<sup>9+</sup> | 7 | PAN profile. |
# Standard NFC Card Emulation
# @ohos.nfc.cardEmulation
The **cardEmulation** module implements Near-Field Communication (NFC) card emulation. You can use the APIs provided by this module to determine the card emulation type supported and implement Host-based Card Emulation (HCE).
> **NOTE**<br>
> **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.
## Modules to Import
```
......@@ -18,7 +18,7 @@ Enumerates the NFC card emulation types.
**System capability**: SystemCapability.Communication.NFC.Core
| Name| Default Value| Description|
| Name| Value| Description|
| -------- | -------- | -------- |
| HCE | 0 | HCE.|
| UICC | 1 | Subscriber identity module (SIM) card emulation.|
......@@ -30,8 +30,6 @@ isSupported(feature: number): boolean
Checks whether a certain type of card emulation is supported.
**Required permissions**: ohos.permission.NFC_CARD_EMULATION
**System capability**: SystemCapability.Communication.NFC.Core
**Parameters**
......@@ -42,9 +40,9 @@ Checks whether a certain type of card emulation is supported.
**Return value**
| **Type**| **Description**|
| -------- | -------- |
| boolean | Returns **true** if the card emulation type is supported; returns **false** otherwise.|
| **Type**| **Description**|
| -------- | -------- |
| boolean | Returns **true** if the card emulation type is supported; returns **false** otherwise.|
## HceService<sup>8+</sup>
......
# Active Tag
# @ohos.connectedTag
The **connectedTag** module provides methods for using active tags. You can use the APIs provided by this module to initialize the active tag chip and read and write active tags.
The **connectedTag** module provides APIs for using active tags. You can use the APIs to initialize the active tag chip and read and write active tags.
> **NOTE**<br>
> **NOTE**
>
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import
```
```js
import connectedTag from '@ohos.connectedTag';
```
## connectedTag.init
init(): boolean
......@@ -23,11 +22,11 @@ Initializes the active tag chip.
**System capability**: SystemCapability.Communication.ConnectedTag
- Return value
| **Type**| **Description**|
| -------- | -------- |
| boolean | Returns **true** if the initialization is successful; returns **false** otherwise.|
**Return value**
| **Type**| **Description**|
| -------- | -------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
## connectedTag.uninit
......@@ -39,125 +38,136 @@ Uninitializes the active tag resources.
**System capability**: SystemCapability.Communication.ConnectedTag
- Return value
| **Type**| **Description**|
| -------- | -------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
**Return value**
| **Type**| **Description**|
| -------- | -------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
## connectedTag.readNdefTag
readNdefTag(): Promise&lt;string&gt;
Reads the content of this active tag. This method uses a promise to return the result.
Reads the content of this active tag. This API uses a promise to return the result.
**Required permissions**: ohos.permission.NFC_TAG
**System capability**: SystemCapability.Communication.ConnectedTag
- Return value
| **Type**| **Description**|
| -------- | -------- |
| Promise&lt;string&gt; | Promise used to return the content of the active tag.|
**Return value**
- Example
```
import connectedTag from '@ohos.connectedTag';
| **Type**| **Description**|
| -------- | -------- |
| Promise&lt;string&gt; | Promise used to return the content of the active tag.|
connectedTag.readNdefTag().then(result => {
console.log("promise recv ndef response: " + result);
});
```
**Example**
```js
import connectedTag from '@ohos.connectedTag';
connectedTag.readNdefTag().then((data) => {
console.log("connectedTag readNdefTag Promise data = " + data);
}).catch((err)=> {
console.log("connectedTag readNdefTag Promise err: " + err);
});
```
## connectedTag.readNdefTag
readNdefTag(callback: AsyncCallback&lt;string&gt;): void
Reads the content of this active tag. This method uses an asynchronous callback to return the result.
Reads the content of this active tag. This API uses an asynchronous callback to return the result.
**Required permissions**: ohos.permission.NFC_TAG
**System capability**: SystemCapability.Communication.ConnectedTag
- Parameters
| **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;string&gt; | Yes| Callback invoked to return the active tag content obtained.|
**Parameters**
- Example
```
import connectedTag from '@ohos.connectedTag';
connectedTag.readNdefTag(result => {
console.log("callback recv ndef response: " + result);
});
```
| **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;string&gt; | Yes| Callback invoked to return the active tag content obtained.|
**Example**
```js
import connectedTag from '@ohos.connectedTag';
connectedTag.readNdefTag((err, data)=> {
if (err) {
console.log("connectedTag readNdefTag AsyncCallback err: " + err);
} else {
console.log("connectedTag readNdefTag AsyncCallback data: " + data);
}
});
```
## connectedTag.writeNdefTag
writeNdefTag(data: string): Promise&lt;void&gt;
Writes data to this active tag. This method uses a promise to return the result.
Writes data to this active tag. This API uses a promise to return the result.
**Required permissions**: ohos.permission.NFC_TAG
**System capability**: SystemCapability.Communication.ConnectedTag
- Parameters
| **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- |
| data | string | Yes| Data to write. The maximum length is 1024 bytes.|
- Return value
| **Type**| **Description**|
| -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the result. This method returns no value.|
- Example
```
import connectedTag from '@ohos.connectedTag';
writeNdefTag.write("010203")
.then((value) => {
// Data is written to the tag.
console.log(`success to write event: ${value}`);
}).catch((err) => {
// Failed to write data to the tag.
console.error(`failed to write event because ${err.code}`);
});
```
**Parameters**
| **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- |
| data | string | Yes| Data to write. The maximum length is 1024 bytes.|
**Return value**
| **Type**| **Description**|
| -------- | -------- |
| Promise&lt;void&gt; | Promise that returns no value.|
**Example**
```js
import connectedTag from '@ohos.connectedTag';
var rawData = "010203"; // change it tobe correct.
connectedTag.writeNdefTag(rawData).then(() => {
console.log("connectedTag writeNdefTag Promise success.");
}).catch((err)=> {
console.log("connectedTag writeNdefTag Promise err: " + err);
});
```
## connectedTag.writeNdefTag
writeNdefTag(data: string, callback: AsyncCallback&lt;void&gt;): void
Writes data to this active tag. This method uses an asynchronous callback to return the result.
Writes data to this active tag. This API uses an asynchronous callback to return the result.
**Required permissions**: ohos.permission.NFC_TAG
**System capability**: SystemCapability.Communication.ConnectedTag
- Parameters
| **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- |
| data | string | Yes| Data to write. The maximum length is 1024 bytes.|
| callback | AsyncCallback&lt;string&gt; | Yes| Callback invoked to return the active tag content obtained.|
- Example
```
import connectedTag from '@ohos.connectedTag';
connectedTag.writeNdefTag("010203", (err, value) => {
if (err) {
// Failed to write data to the tag.
console.error(`failed to write event because ${err.code}`);
return;
}
// Data is written to the tag.
console.log(`success to write event: ${value}`);
});
```
**Parameters**
| **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- |
| data | string | Yes| Data to write. The maximum length is 1024 bytes.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback invoked to return the active tag content obtained.|
**Example**
```js
import connectedTag from '@ohos.connectedTag';
var rawData = "010203"; // change it tobe correct.
connectedTag.writeNdefTag(rawData, (err)=> {
if (err) {
console.log("connectedTag writeNdefTag AsyncCallback err: " + err);
} else {
console.log("connectedTag writeNdefTag AsyncCallback success.");
}
});
```
## connectedTag.on('notify')
......@@ -169,18 +179,12 @@ Registers the NFC field strength state events.
**System capability**: SystemCapability.Communication.ConnectedTag
- Parameters
| **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Event type. The value is **notify**.|
| callback | Callback&lt;number&gt; | Yes| Callback invoked to return the field strength state.|
- Enumerates the field strength states.
| **Value**| **Description**|
| -------- | -------- |
| 0 | Field off.|
| 1 | Field on.|
**Parameters**
| **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Event type. The value is **notify**.|
| callback | Callback&lt;number&gt; | Yes| Callback used to return the [NfcRfType](#nfcrftype).|
## connectedTag.off('notify')
......@@ -192,36 +196,54 @@ Unregisters the NFC field strength state events.
**System capability**: SystemCapability.Communication.ConnectedTag
- Parameters
| **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Event type. The value is **notify**.|
| callback | Callback&lt;number&gt; | No| Callback used to return the field strength state. If this parameter is not specified, all callbacks associated with the specified event will be unregistered.|
- Example
```
import connectedTag from '@ohos.connectedTag';
var NFC_RF_NOTIFY = "notify";
var recvNfcRfNotifyFunc = result => {
console.info("nfc rf receive state: " + result);
}
// Register event notification.
connectedTag.on(NFC_RF_NOTIFY, recvNfcRfNotifyFunc);
// Unregister event notification.
connectedTag.off(NFC_RF_NOTIFY, recvNfcRfNotifyFunc);
```
**Parameters**
| **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Event type. The value is **notify**.|
| callback | Callback&lt;number&gt; | No| Callback used to return the field strength state. If this parameter is not specified, all callbacks associated with the specified event will be unregistered.|
**Example**
```js
import connectedTag from '@ohos.connectedTag';
// Register the event.
connectedTag.on("notify", (err, rfState)=> {
if (err) {
console.log("connectedTag on Callback err: " + err);
} else {
console.log("connectedTag on Callback rfState: " + rfState);
}
});
var initStatus = connectedTag.init();
console.log("connectedTag init status: " + initStatus);
// Add nfc connecected tag business oprations here...
// connectedTag.writeNdefTag(rawData)
// connectedTag.readNdefTag()
var uninitStatus = connectedTag.uninit();
console.log("connectedTag uninit status: " + uninitStatus);
// Unregister the event.
connectedTag.off("notify", (err, rfState)=> {
if (err) {
console.log("connectedTag off Callback err: " + err);
} else {
console.log("connectedTag off Callback rfState: " + rfState);
}
});
```
## NfcRfType
Enumerates the NFC states.
Enumerates the NFC field strength states.
**System capability**: SystemCapability.Communication.ConnectedTag
| Name| Default Value| Description|
| Name| Value| Description|
| -------- | -------- | -------- |
| NFC_RF_LEAVE | 0 | Field on.|
| NFC_RF_LEAVE | 0 | Field off.|
| NFC_RF_ENTER | 1 | Field on.|
# Value Bucket
# @ohos.data.ValuesBucket
The **ValueBucket** module holds data in key-value (KV) pairs. You can use it to insert data into a database.
......
# Distributed Account Management
# @ohos.account.distributedAccount
The **distributedAccount** module provides APIs for managing distributed accounts, including querying and updating account login status.
The **distributedAccount** module provides APIs for managing distributed accounts, including querying and updating account login states.
> **NOTE**<br>
> **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.
......@@ -49,7 +49,7 @@ Obtains distributed account information. This API uses an asynchronous callback
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;[DistributedInfo](#distributedinfo)&gt; | Yes| Callback invoked to return the result. If the operation is successful, **err** is **undefined** and data is the distributed account information obtained. Otherwise, **err** is an error object.|
| callback | AsyncCallback&lt;[DistributedInfo](#distributedinfo)&gt; | Yes| Callback invoked to return the result. If the operation is successful, **err** is **undefined** and **data** is the distributed account information obtained. Otherwise, **err** is an error object.|
**Error codes**
......@@ -124,7 +124,7 @@ Obtains distributed account information. This API uses an asynchronous callback
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;[DistributedInfo](#distributedinfo)&gt; | Yes| Callback invoked to return the result. If the operation is successful, **err** is **undefined** and data is the distributed account information obtained. Otherwise, **err** is an error object.|
| callback | AsyncCallback&lt;[DistributedInfo](#distributedinfo)&gt; | Yes| Callback invoked to return the result. If the operation is successful, **err** is **undefined** and **data** is the distributed account information obtained. Otherwise, **err** is an error object.|
**Example**
```js
......@@ -181,7 +181,7 @@ Sets the distributed account information. This API uses an asynchronous callback
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| accountInfo | [DistributedInfo](#distributedinfo) | Yes| New distributed account information.|
| accountInfo | [DistributedInfo](#distributedinfo) | Yes| Distributed account information to set.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback invoked to return the result. If the distributed account information is set successfully, **err** is **undefined**. Otherwise, **err** is an error object.|
**Error codes**
......@@ -219,7 +219,7 @@ Sets the distributed account information. This API uses a promise to return the
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| accountInfo | [DistributedInfo](#distributedinfo) | Yes| New distributed account information.|
| accountInfo | [DistributedInfo](#distributedinfo) | Yes| Distributed account information to set.|
**Return value**
......@@ -322,7 +322,7 @@ Defines distributed OS account information.
| -------- | -------- | -------- | -------- |
| name | string | Yes| Name of the distributed account. It must be a non-null string.|
| id | string | Yes| UID of the distributed account. It must be a non-null string.|
| event | string | Yes| Login state of a distributed account. The state can be login, logout, token invalid, or logoff, which correspond to the following strings respectively:<br>-&nbsp;Ohos.account.event.LOGIN<br>-&nbsp;Ohos.account.event.LOGOUT<br>-&nbsp;Ohos.account.event.TOKEN_INVALID<br>-&nbsp;Ohos.account.event.LOGOFF |
| event | string | Yes| Login state of the distributed account. The state can be login, logout, token invalid, or logoff, which correspond to the following strings respectively:<br>-&nbsp;Ohos.account.event.LOGIN<br>-&nbsp;Ohos.account.event.LOGOUT<br>-&nbsp;Ohos.account.event.TOKEN_INVALID<br>-&nbsp;Ohos.account.event.LOGOFF |
| nickname<sup>9+</sup> | string | No| Nickname of the distributed account. It must be a non-null string.|
| avatar<sup>9+</sup> | string | No| Avatar of the distributed account. It must be a non-null string.|
| scalableData | object | No| Extended information about the distributed account, passed in key-value (KV) pairs.<br>**NOTE**<br>This parameter is reserved and not used in query and update methods.|
| scalableData | object | No| Extended information about the distributed account, passed in key-value (KV) pairs.<br>**NOTE**<br>This parameter is reserved and not used in the setters and getters.|
# OS Account Management
# @ohos.account.osAccount
The **osAccount** module provides basic capabilities for managing OS accounts, including adding, deleting, querying, setting, subscribing to, and enabling an OS account.
> **NOTE**<br>
> **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.
......@@ -2708,7 +2709,6 @@ Obtains the constraint source information of an OS account. This API uses a prom
console.info('queryOsAccountConstraintSourceType exception:' + JSON.stringify(e));
}
```
### isMultiOsAccountEnable<sup>(deprecated)</sup>
isMultiOsAccountEnable(callback: AsyncCallback&lt;boolean&gt;): void
......@@ -4280,17 +4280,12 @@ Register a PIN inputer.
| ----------| ----------------------- | --- | -------------------------- |
| inputer | [IInputer](#iinputer8) | Yes | PIN inputer, which is used to obtain the PIN.|
**Return value**
| Type | Description |
| :------ | :-------------------------------------------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
**Error codes**
| ID| Error Message |
| -------- | --------------------------- |
| 12300001 | System service exception. |
| 12300102 | Invalid inputer. |
| 12300103 | Inputer already registered. |
**Example**
......@@ -4299,8 +4294,8 @@ Register a PIN inputer.
let password = new Uint8Array([0, 0, 0, 0, 0]);
try {
let result = pinAuth.registerInputer({
onGetData: (pinSubType, callback) => {
callback.onSetData(pinSubType, password);
onGetData: (authSubType, callback) => {
callback.onSetData(authSubType, password);
}
});
console.log('registerInputer result = ' + result);
......@@ -4327,6 +4322,91 @@ Unregisters this PIN inputer.
pinAuth.unregisterInputer();
```
### InputerManager <sup>10+</sup>
Provides APIs for managing credential inputers.
### registerInputer<sup>10+</sup>
registerInputer(authType: AuthType, inputer: IInputer): void;
Register a credential inputer.
**System API**: This is a system API.
**System capability**: SystemCapability.Account.OsAccount
**Required permissions**: ohos.permission.ACCESS_USER_AUTH_INTERNAL or ohos.permission.MANAGE_USER_IDM
**Parameters**
| Name | Type | Mandatory| Description |
| ----------| ----------------------- | --- | -------------------------- |
| authType | [AuthType](#authtype8) | Yes | Authentication credential type.|
| inputer | [IInputer](#iinputer8) | Yes | Credential inputer to register.|
**Error codes**
| ID| Error Message |
| -------- | --------------------------- |
| 12300001 | System service exception. |
| 12300102 | Invalid authType or inputer. |
| 12300103 | The credential inputer has been registered. |
| 12300106 | Unsupported authType. |
**Example**
```js
let inputerMgr = new account_osAccount.InputerManager();
let authType = account_osAccount.AuthType.DOMAIN;
let password = new Uint8Array([0, 0, 0, 0, 0]);
try {
InputerMgr.registerInputer(authType, {
onGetData: (authSubType, callback) => {
callback.onSetData(authSubType, password);
}
});
console.log('registerInputer success.');
} catch (e) {
console.log('registerInputer exception = ' + JSON.stringify(e));
}
```
### unregisterInputer<sup>10+</sup>
unregisterInputer(authType: AuthType): void;
Unregisters this credential inputer.
**System API**: This is a system API.
**System capability**: SystemCapability.Account.OsAccount
**Required permissions**: ohos.permission.ACCESS_USER_AUTH_INTERNAL or ohos.permission.MANAGE_USER_IDM
**Parameters**
| Name | Type | Mandatory| Description |
| ----------| ----------------------- | --- | -------------------------- |
| authType | [AuthType](#authtype8) | Yes | Authentication credential type.|
**Error codes**
| ID| Error Message |
| -------- | --------------------------- |
| 12300002 | Invalid authType. |
**Example**
```js
let inputerMgr = new account_osAccount.InputerManager();
let authType = account_osAccount.AuthType.DOMAIN;
try {
inputerMgr.unregisterInputer(authType);
console.log('unregisterInputer success.');
} catch(err) {
console.log("unregisterInputer err:" + JSON.stringify(err));
}
```
## UserIdentityManager<sup>8+</sup>
Provides APIs for user identity management (IDM).
......@@ -4456,8 +4536,8 @@ Adds credential information, including the credential type, subtype, and token (
let password = new Uint8Array([0, 0, 0, 0, 0, 0]);
let pinAuth = new account_osAccount.PINAuth();
pinAuth.registerInputer({
onGetData: (pinSubType, callback) => {
callback.onSetData(pinSubType, password);
onGetData: (authSubType, callback) => {
callback.onSetData(authSubType, password);
}
});
let credentialInfo = {
......@@ -4470,12 +4550,12 @@ Adds credential information, including the credential type, subtype, and token (
try {
userIDM.addCredential(credentialInfo, {
onResult: (result, extraInfo) => {
console.log('updateCredential result = ' + result);
console.log('updateCredential extraInfo = ' + extraInfo);
console.log('addCredential result = ' + result);
console.log('addCredential extraInfo = ' + extraInfo);
}
});
} catch (e) {
console.log('updateCredential exception = ' + JSON.stringify(e));
console.log('addCredential exception = ' + JSON.stringify(e));
}
});
```
......@@ -4520,8 +4600,8 @@ Updates credential information. This API uses a callback to return the result.
token: null
};
pinAuth.registerInputer({
onGetData: (pinSubType, callback) => {
callback.onSetData(pinSubType, password);
onGetData: (authSubType, callback) => {
callback.onSetData(authSubType, password);
}
});
userIDM.openSession((err, challenge) => {
......@@ -4820,7 +4900,7 @@ Provides callbacks for PIN operations.
### onSetData<sup>8+</sup>
onSetData: (pinSubType: AuthSubType, data: Uint8Array) => void;
onSetData: (authSubType: AuthSubType, data: Uint8Array) => void;
**System API**: This is a system API.
......@@ -4832,7 +4912,7 @@ Called to set data in a PIN operation.
| Name | Type | Mandatory| Description |
| ---------- | ---------------------------------------- | ---- | ----------------------------------------------- |
| pinSubType | [AuthSubType](#authsubtype8) | Yes | Credential subtype. |
| authSubType | [AuthSubType](#authsubtype8) | Yes | Credential subtype. |
| data | Uint8Array | Yes | Data (credential) to set. The data is used for authentication and operations for adding and modifying credentials.|
**Example**
......@@ -4840,11 +4920,11 @@ Called to set data in a PIN operation.
let password = new Uint8Array([0, 0, 0, 0, 0, 0]);
let passwordNumber = new Uint8Array([1, 2, 3, 4]);
let inputer = {
onGetData: (pinSubType, callback) => {
if (pinSubType == account_osAccount.AuthSubType.PIN_NUMBER) {
callback.onSetData(pinSubType, passwordNumber);
onGetData: (authSubType, callback) => {
if (authSubType == account_osAccount.AuthSubType.PIN_NUMBER) {
callback.onSetData(authSubType, passwordNumber);
} else {
callback.onSetData(pinSubType, password);
callback.onSetData(authSubType, password);
}
}
};
......@@ -4852,13 +4932,13 @@ Called to set data in a PIN operation.
## IInputer<sup>8+</sup>
Provides callbacks for the PIN input box.
Provides callbacks for credential inputers.
**System API**: This is a system API.
### onGetData<sup>8+</sup>
onGetData: (pinSubType: AuthSubType, callback: IInputData) => void;
onGetData: (authSubType: AuthSubType, callback: IInputData) => void;
Called to obtain data.
......@@ -4877,11 +4957,11 @@ Called to obtain data.
let password = new Uint8Array([0, 0, 0, 0, 0, 0]);
let passwordNumber = new Uint8Array([1, 2, 3, 4]);
let inputer = {
onGetData: (pinSubType, callback) => {
if (pinSubType == account_osAccount.AuthSubType.PIN_NUMBER) {
callback.onSetData(pinSubType, passwordNumber);
onGetData: (authSubType, callback) => {
if (authSubType == account_osAccount.AuthSubType.PIN_NUMBER) {
callback.onSetData(authSubType, passwordNumber);
} else {
callback.onSetData(pinSubType, password);
callback.onSetData(authSubType, password);
}
}
};
......@@ -5157,6 +5237,8 @@ Enumerates the authentication credential types.
| ----- | ----- | ---------------- |
| PIN | 1 | PIN authentication.|
| FACE | 2 | Facial authentication.|
| FINGERPRINT<sup>10+</sup> | 4 | Fingerprint authentication.|
| DOMAIN<sup>10+</sup> | 1024 | Domain authentication.|
## AuthSubType<sup>8+</sup>
......@@ -5170,9 +5252,10 @@ Enumerates the authentication credential subtypes.
| ---------- | ----- | ------------------ |
| PIN_SIX | 10000 | Six-digit PIN. |
| PIN_NUMBER | 10001 | Custom PIN.|
| PIN_MIXED | 10002 | Custom mixed credential.|
| PIN_MIXED | 10002 | Custom mixed credentials.|
| FACE_2D | 20000 | 2D face credential. |
| FACE_3D | 20001 | 3D face credential. |
| DOMAIN_MIXED<sup>10+</sup> | 10240001 | Mixed domain authentication credentials. |
## AuthTrustLevel<sup>8+</sup>
......
# RPC
# @ohos.rpc
The **RPC** module implements communication between processes, including inter-process communication (IPC) on a single device and remote procedure call (RPC) between processes on difference devices. IPC is implemented based on the Binder driver, and RPC is based on the DSoftBus driver.
> **NOTE**<br>
> **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.
>
> This module supports return of error codes since API version 9.
......@@ -24,7 +26,7 @@ The APIs of this module return exceptions since API version 9. The following tab
| ------------------------------------- | ------- | --------------------------------------------- |
| CHECK_PARAM_ERROR | 401 | Parameter check failed. |
| OS_MMAP_ERROR | 1900001 | Failed to call mmap. |
| OS_IOCTL_ERROR | 1900002 | Failed to execute **ioctl** with the shared memory file descriptor.|
| OS_IOCTL_ERROR | 1900002 | Failed to call **ioctl** with the shared memory file descriptor.|
| WRITE_TO_ASHMEM_ERROR | 1900003 | Failed to write data to the shared memory. |
| READ_FROM_ASHMEM_ERROR | 1900004 | Failed to read data from the shared memory. |
| ONLY_PROXY_OBJECT_PERMITTED_ERROR | 1900005 | This operation is allowed only on the proxy object. |
......@@ -123,7 +125,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
readRemoteObject(): IRemoteObject
Reads a remote object from **MessageSequence**. You can use this API to deserialize the **MessageSequence** object to generate an **IRemoteObject**. The remote object is read in the order in which it is written to this **MessageSequence** object.
Reads the remote object from **MessageSequence**. You can use this API to deserialize the **MessageSequence** object to generate an **IRemoteObject**. The remote object is read in the order in which it is written to this **MessageSequence** object.
**System capability**: SystemCapability.Communication.IPC.Core
......@@ -405,7 +407,7 @@ Obtains the read position of this **MessageSequence** object.
| Type| Description|
| ------ | ------ |
| number | Current read position of the **MessageSequence** object.|
| number | Read position obtained.|
**Example**
......@@ -427,7 +429,7 @@ Obtains the write position of this **MessageSequence** object.
| Type| Description|
| ------ | ----- |
| number | Current write position of the **MessageSequence** object.|
| number | Write position obtained.|
**Example**
......@@ -504,7 +506,7 @@ Moves the write pointer to the specified position.
writeByte(val: number): void
Writes a Byte value to this **MessageSequence** object.
Writes a byte value to this **MessageSequence** object.
**System capability**: SystemCapability.Communication.IPC.Core
......@@ -538,7 +540,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
readByte(): number
Reads the Byte value from this **MessageSequence** object.
Reads the byte value from this **MessageSequence** object.
**System capability**: SystemCapability.Communication.IPC.Core
......@@ -2856,7 +2858,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
readFileDescriptor(): number
Reads a file descriptor from this **MessageSequence** object.
Reads the file descriptor from this **MessageSequence** object.
**System capability**: SystemCapability.Communication.IPC.Core
......@@ -4017,7 +4019,7 @@ Writes a string to this **MessageParcel** object.
readString(): string
Reads a string from this **MessageParcel** object.
Reads the string from this **MessageParcel** object.
**System capability**: SystemCapability.Communication.IPC.Core
......
# NFC Tag Session
# tagSession
The **tagSession** module provides common APIs for establishing connections and transferring data.
> **NOTE**<br>
> **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**
......@@ -15,17 +16,15 @@ import tag from '@ohos.nfc.tag';
Provides common APIs for establishing connections and transferring data. **tagSession** is the base class of all [NFC tag technologies](js-apis-nfctech.md).
A child class instance is required to access the following interfaces. You can use **get**XX**Tag()** to obtain a child class instance.
A child class instance is required to access the following interfaces. You can use **get**XXX() to obtain a child class instance.
The specific API varies with the NFC tag technology in use. For details, see [NFC Tags](js-apis-nfcTag.md).
### tagSession.connectTag
connectTag(): boolean;
### tagSession.getTagInfo
Connects to this tag.
getTagInfo(): tag.TagInfo
Call this API to set up a connection before reading data from or writing data to a tag.
Obtains the **tagInfo** object provided by the NFC service when the tag is dispatched.
**Required permissions**: ohos.permission.NFC_TAG
......@@ -35,23 +34,25 @@ Call this API to set up a connection before reading data from or writing data to
| **Type**| **Description** |
| ------------------ | --------------------------|
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
| TagInfo | **Taginfo** object obtained.|
**Example**
```js
import tag from '@ohos.nfc.tag';
// tagInfo is an object given by the NFC service when a tag is dispatched.
let isNfcConnected = tag.getXXXTag(taginfo).connectTag();
console.log("isNfcConnected:" +isNfcConnected);
// tagInfo is an object provided by the NFC service when a tag is dispatched.
// getXXX can be getIsoDep, getNdef, getMifareClassic, or any other getter for NFC tags.
let tagInfo = tag.getIsoDep(tagInfo).getTagInfo();
console.log("tag tagInfo: " + tagInfo);
```
### tagSession.reset()
### tagSession.connectTag
reset(): void
connectTag(): boolean;
Resets the connection to this tag and restores the default timeout duration for writing data to the tag.
Connects to this 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
......@@ -68,9 +69,32 @@ Resets the connection to this tag and restores the default timeout duration for
```js
import tag from '@ohos.nfc.tag';
// tagInfo is an object given by the NFC service when a tag is dispatched.
let reset = tag.getXXXTag(taginfo).reset();
console.log("reset:" +reset);
// tagInfo is an object provided by the NFC service when a tag is dispatched.
// getXXX can be getIsoDep, getNdef, getMifareClassic, or any other getter for NFC tags.
let connectStatus = tag.getIsoDep(tagInfo).connectTag();
console.log("connectStatus: " + connectStatus);
```
### tagSession.reset()
reset(): void
Resets the connection to this tag.
**Required permissions**: ohos.permission.NFC_TAG
**System capability**: SystemCapability.Communication.NFC.Core
**Example**
```js
import tag from '@ohos.nfc.tag';
// tagInfo is an object provided by the NFC service when a tag is dispatched.
// getXXX can be getIsoDep, getNdef, getMifareClassic, or any other getter for NFC tags.
tag.getIsoDep(tagInfo).reset();
```
### tagSession.isTagConnected
......@@ -94,16 +118,18 @@ Checks whether the tag is connected.
```js
import tag from '@ohos.nfc.tag';
// tagInfo is an object given by the NFC service when a tag is dispatched.
let isTagConnected = tag.getXXXTag(taginfo).isTagConnected();
console.log("isTagConnected:" +isTagConnected);
// tagInfo is an object provided by the NFC service when a tag is dispatched.
// getXXX can be getIsoDep, getNdef, getMifareClassic, or any other getter for NFC tags.
let isTagConnected = tag.getIsoDep(tagInfo).isTagConnected();
console.log("isTagConnected: " + isTagConnected);
```
### tagSession.getMaxSendLength
getMaxSendLength(): number
Obtains the maximum length of the data that can be sent to the tag.
Obtains the maximum length of the data that can be sent to this tag.
**Required permissions**: ohos.permission.NFC_TAG
......@@ -113,14 +139,167 @@ Obtains the maximum length of the data that can be sent to the tag.
| **Type**| **Description** |
| ------------------ | --------------------------|
| number | Maximum data length obtained.|
| number | Maximum data length obtained. The value cannot be a negative number.|
**Example**
```js
import tag from '@ohos.nfc.tag';
// tagInfo is an object provided by the NFC service when a tag is dispatched.
// getXXX can be getIsoDep, getNdef, getMifareClassic, or any other getter for NFC tags.
let maxSendLen = tag.getIsoDep(tagInfo).getMaxSendLength();
console.log("tag maxSendLen: " + maxSendLen);
```
### tagSession.getSendDataTimeout
getSendDataTimeout(): number
Obtains the timeout period for sending data to this tag, in milliseconds.
**Required permissions**: ohos.permission.NFC_TAG
**System capability**: SystemCapability.Communication.NFC.Core
**Return value**
| **Type**| **Description** |
| ------------------ | --------------------------|
| number | Timeout period obtained, in milliseconds. The value cannot be a negative number.|
**Example**
```js
import tag from '@ohos.nfc.tag';
// tagInfo is an object provided by the NFC service when a tag is dispatched.
// getXXX can be getIsoDep, getNdef, getMifareClassic, or any other getter for NFC tags.
let sendDataTimeout = tag.getIsoDep(tagInfo).getSendDataTimeout();
console.log("tag sendDataTimeout: " + sendDataTimeout);
```
### tagSession.setSendDataTimeout
setSendDataTimeout(timeout: number): boolean
Sets the timeout period for sending data to this tag, in milliseconds.
**Required permissions**: ohos.permission.NFC_TAG
**System capability**: SystemCapability.Communication.NFC.Core
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ----------------------- | ---- | -------------------------------------- |
| timeout | number | Yes| Timeout period to set, in milliseconds. The value cannot be a negative number.|
**Return value**
| **Type**| **Description** |
| ------------------ | --------------------------|
| boolean | Returns **true** if the timeout period is set successfully; returns **false** otherwise.|
**Example**
```js
import tag from '@ohos.nfc.tag';
// tagInfo is an object provided by the NFC service when a tag is dispatched.
// getXXX can be getIsoDep, getNdef, getMifareClassic, or any other getter for NFC tags.
let timeoutMs = 700; // Change it as required.
let setStatus = tag.getIsoDep(tagInfo).setSendDataTimeout(timeoutMs);
console.log("tag setSendDataTimeout setStatus: " + setStatus);
```
### tagSession.sendData
sendData(data: number[]): Promise<number[]>
Sends data to this tag. This API uses a promise to return the result.
**Required permissions**: ohos.permission.NFC_TAG
**System capability**: SystemCapability.Communication.NFC.Core
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ----------------------- | ---- | -------------------------------------- |
| data | number[] | Yes| Data to send. The data consists of hexadecimal numbers ranging from **0x00** to **0xFF**.|
**Return value**
| **Type**| **Description** |
| ------------------ | --------------------------|
| Promise<number[]> | Promise used to return the response from the tag. The response consists of hexadecimal numbers ranging from **0x00** to **0xFF**.|
**Example**
```js
import tag from '@ohos.nfc.tag';
// tagInfo is an object provided by the NFC service when a tag is dispatched.
// getXXX can be getIsoDep, getNdef, getMifareClassic, or any other getter for NFC tags.
// Connect to the tag if it is not connected.
if (!tag.getIsoDep(tagInfo).isTagConnected()) {
if (!tag.getIsoDep(tagInfo).connectTag()) {
console.log("tagSession connectTag failed.");
return;
}
}
let cmdData = [0x01, 0x02, 0x03, 0x04]; // Change it as required.
tag.getIsoDep(tagInfo).sendData(cmdData).then((response) => {
console.log("tagSession sendData Promise response: " + response);
}).catch((err)=> {
console.log("tagSession sendData Promise err: " + err);
});
```
### tagSession.sendData
sendData(data: number[], callback: AsyncCallback<number[]>): void
Sends data to this tag. This API uses an asynchronous callback to return the result.
**Required permissions**: ohos.permission.NFC_TAG
**System capability**: SystemCapability.Communication.NFC.Core
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ----------------------- | ---- | -------------------------------------- |
| data | number[] | Yes| Data to send. The data consists of hexadecimal numbers ranging from **0x00** to **0xFF**.|
| callback | AsyncCallback<number[]> | Yes| Callback invoked to return the response from the tag. The response consists of hexadecimal numbers ranging from **0x00** to **0xFF**.|
**Example**
```js
import tag from '@ohos.nfc.tag';
// tagInfo is an object given by the NFC service when a tag is dispatched.
let mazSendLen = tag.getXXXTag(taginfo).getMaxSendLength();
console.log("mazSendLen:" +mazSendLen);
// tagInfo is an object provided by the NFC service when a tag is dispatched.
// getXXX can be getIsoDep, getNdef, getMifareClassic, or any other getter for NFC tags.
// Connect to the tag if it is not connected.
if (!tag.getIsoDep(tagInfo).isTagConnected()) {
if (!tag.getIsoDep(tagInfo).connectTag()) {
console.log("tagSession connectTag failed.");
return;
}
}
let cmdData = [0x01, 0x02, 0x03, 0x04]; // Change it as required.
tag.getIsoDep(tagInfo).sendData(cmdData, (err, response)=> {
if (err) {
console.log("tagSession sendData AsyncCallback err: " + err);
} else {
console.log("tagSession sendData AsyncCallback response: " + response);
}
});
```
# WLAN Extension Interface
This **wifiext** module provides WLAN extension interfaces for non-universal products.
> **NOTE**
>
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
The APIs described in this document are used only for non-universal products, such as routers.
## Modules to Import
```js
import wifiManagerExt from '@ohos.wifiManagerExt';
```
## wifiext.enableHotspot
enableHotspot(): boolean;
Enables the WLAN hotspot.
**Required permissions**: ohos.permission.MANAGE_WIFI_HOTSPOT_EXT
**System capability**: SystemCapability.Communication.WiFi.AP.Extension
**Return value**
| **Type**| **Description**|
| -------- | -------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
## wifiext.disableHotspot
disableHotspot(): boolean;
Disables the WLAN hotspot.
**Required permissions**: ohos.permission.MANAGE_WIFI_HOTSPOT_EXT
**System capability**: SystemCapability.Communication.WiFi.AP.Extension
**Return value**
| **Type**| **Description**|
| -------- | -------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
## wifiext.getSupportedPowerModel
getSupportedPowerModel(): Promise&lt;Array&lt;PowerModel&gt;&gt;
Obtains the supported power models. This API uses a promise to return the result.
**Required permissions**: ohos.permission.GET_WIFI_INFO
**System capability**: SystemCapability.Communication.WiFi.AP.Extension
**Return value**
| Type| Description|
| -------- | -------- |
| Promise&lt;Array&lt;[PowerModel](#powermodel)&gt;&gt; | Promise used to return the power models obtained.|
## PowerModel
Enumerates the power models.
**System capability**: SystemCapability.Communication.WiFi.AP.Extension
| Name| Value| Description|
| -------- | -------- | -------- |
| SLEEPING | 0 | Sleeping|
| GENERAL | 1 | General|
| THROUGH_WALL | 2 | Through_wall|
## wifiext.getSupportedPowerModel
getSupportedPowerModel(callback: AsyncCallback&lt;Array&lt;PowerModel&gt;&gt;): void
Obtains the supported power models. This API uses an asynchronous callback to return the result.
**Required permissions**: ohos.permission.GET_WIFI_INFO
**System capability**: SystemCapability.Communication.WiFi.AP.Extension
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;Array&lt;[PowerModel](#powermodel)&gt;&gt; | Yes| Callback invoked to return the result. If the operation is successful, **err** is 0 and **data** is the power models obtained. If **err** is not **0**, an error has occurred.|
## wifiext.getPowerModel
getPowerModel(): Promise&lt;PowerModel&gt;
Obtains the power model. This API uses a promise to return the result.
**Required permissions**: ohos.permission.GET_WIFI_INFO
**System capability**: SystemCapability.Communication.WiFi.AP.Extension
**Return value**
| Type| Description|
| -------- | -------- |
| Promise&lt;[PowerModel](#powermodel)&gt; | Promise used to return the power model obtained.|
## wifiext.getPowerModel
getPowerModel(callback: AsyncCallback&lt;PowerModel&gt;): void
Obtains the power model. This API uses an asynchronous callback to return the result.
**Required permissions**: ohos.permission.GET_WIFI_INFO
**System capability**: SystemCapability.Communication.WiFi.AP.Extension
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;[PowerModel](#powermodel)&gt; | Yes| Callback invoked to return the result. If the operation is successful, **err** is **0** and **data** is the power model obtained. If **err** is not **0**, an error has occurred.|
## wifiext.setPowerModel
setPowerModel(model: PowerModel) : boolean;
Sets the power model.
**Required permissions**: ohos.permission.MANAGE_WIFI_HOTSPOT_EXT
**System capability**: SystemCapability.Communication.WiFi.AP.Extension
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| model | [PowerModel](#powermodel) | Yes| Power model to set.|
**Return value**
| **Type**| **Description**|
| -------- | -------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册