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

!13878 [翻译完成】#I6661B

Merge pull request !13878 from Annie_wang/PR12492
...@@ -108,7 +108,7 @@ ...@@ -108,7 +108,7 @@
- [MissionListener](js-apis-inner-application-missionListener.md) - [MissionListener](js-apis-inner-application-missionListener.md)
- [MissionParameter](js-apis-inner-application-missionParameter.md) - [MissionParameter](js-apis-inner-application-missionParameter.md)
- [MissionSnapshot](js-apis-inner-application-missionSnapshot.md) - [MissionSnapshot](js-apis-inner-application-missionSnapshot.md)
- [PermissionRequestResult](js-apis-inner-application-permissionRequestResult.md) - [PermissionRequestResult](js-apis-permissionrequestresult.md)
- [ProcessData](js-apis-inner-application-processData.md) - [ProcessData](js-apis-inner-application-processData.md)
- [ProcessRunningInfo](js-apis-inner-application-processRunningInfo.md) - [ProcessRunningInfo](js-apis-inner-application-processRunningInfo.md)
- [ProcessRunningInformation](js-apis-inner-application-processRunningInformation.md) - [ProcessRunningInformation](js-apis-inner-application-processRunningInformation.md)
...@@ -242,19 +242,19 @@ ...@@ -242,19 +242,19 @@
- [@ohos.net.webSocket](js-apis-webSocket.md) - [@ohos.net.webSocket](js-apis-webSocket.md)
- [@ohos.request](js-apis-request.md) - [@ohos.request](js-apis-request.md)
- Connectivity - Connectivity
- [@ohos.bluetooth](js-apis-bluetooth.md) - [@ohos.bluetooth (Bluetooth)](js-apis-bluetooth.md)
- [@ohos.connectedTag](js-apis-connectedTag.md) - [@ohos.connectedTag (Active Tags)](js-apis-connectedTag.md)
- [@ohos.nfc.cardEmulation](js-apis-cardEmulation.md) - [@ohos.nfc.cardEmulation (Standard NFC Card Emulation)](js-apis-cardEmulation.md)
- [@ohos.nfc.controller](js-apis-nfcController.md) - [@ohos.nfc.controller (Standard NFC)](js-apis-nfcController.md)
- [@ohos.nfc.tag](js-apis-nfcTag.md) - [@ohos.nfc.tag (Standard NFC Tags)](js-apis-nfcTag.md)
- [@ohos.rpc](js-apis-rpc.md) - [@ohos.rpc (RPC)](js-apis-rpc.md)
- [@ohos.wifiManager (WLAN)](js-apis-wifiManager.md) - [@ohos.wifiManager (WLAN)](js-apis-wifiManager.md)
- [@ohos.wifiManagerExt](js-apis-wifiManagerExt.md) - [@ohos.wifiManagerExt (WLAN Extension)](js-apis-wifiManagerExt.md)
- [@ohos.wifi](js-apis-wifi.md) - [@ohos.wifi (To Be Deprecated)](js-apis-wifi.md)
- [@ohos.wifiext](js-apis-wifiext.md) - [@ohos.wifiext (To Be Deprecated)](js-apis-wifiext.md)
- tag - tag
- [nfctech](js-apis-nfctech.md) - [nfctech (Standard NFC Technologies)](js-apis-nfctech.md)
- [tagSession](js-apis-tagSession.md) - [tagSession (Standard NFC Tag Session)](js-apis-tagSession.md)
- Basic Features - Basic Features
- [@ohos.accessibility](js-apis-accessibility.md) - [@ohos.accessibility](js-apis-accessibility.md)
- [@ohos.accessibility.config](js-apis-accessibility-config.md) - [@ohos.accessibility.config](js-apis-accessibility-config.md)
...@@ -314,9 +314,9 @@ ...@@ -314,9 +314,9 @@
- [@ohos.usb](js-apis-usb.md) - [@ohos.usb](js-apis-usb.md)
- [@ohos.vibrator](js-apis-vibrator.md) - [@ohos.vibrator](js-apis-vibrator.md)
- Account Management - Account Management
- [@ohos.account.appAccount](js-apis-appAccount.md) - [@ohos.account.appAccount (App Account Management)](js-apis-appAccount.md)
- [@ohos.account.distributedAccount](js-apis-distributed-account.md) - [@ohos.account.distributedAccount (Distributed Account Management)](js-apis-distributed-account.md)
- [@ohos.account.osAccount](js-apis-osAccount.md) - [@ohos.account.osAccount (OS Account Management)](js-apis-osAccount.md)
- Custom Management - Custom Management
- [@ohos.configPolicy](js-apis-configPolicy.md) - [@ohos.configPolicy](js-apis-configPolicy.md)
- [@ohos.enterprise.deviceInfo](js-apis-enterprise-deviceInfo.md) - [@ohos.enterprise.deviceInfo](js-apis-enterprise-deviceInfo.md)
......
# @ohos.account.appAccount # @ohos.account.appAccount (App Account Management)
The **appAccount** module provides APIs for adding, deleting, modifying, and querying app account information, and supports inter-app authentication and distributed data synchronization. The **appAccount** module provides APIs for adding, deleting, modifying, and querying app account information, and supports inter-app authentication and distributed data synchronization.
...@@ -4883,7 +4883,7 @@ Creates an app account implicitly based on the specified account owner. This API ...@@ -4883,7 +4883,7 @@ Creates an app account implicitly based on the specified account owner. This API
| options | [CreateAccountImplicitlyOptions](#createaccountimplicitlyoptions9) | Yes | Options for implicitly creating the account. | | options | [CreateAccountImplicitlyOptions](#createaccountimplicitlyoptions9) | Yes | Options for implicitly creating the account. |
| callback | [AuthCallback](#authcallback9) | Yes | Authenticator callback invoked to return the result.| | callback | [AuthCallback](#authcallback9) | Yes | Authenticator callback invoked to return the result.|
### addAccountImplicitly<sup>deprecated</sup> ### addAccountImplicitly<sup>(deprecated)</sup>
addAccountImplicitly(authType: string, callerBundleName: string, options: {[key: string]: any}, callback: AuthenticatorCallback): void addAccountImplicitly(authType: string, callerBundleName: string, options: {[key: string]: any}, callback: AuthenticatorCallback): void
...@@ -4922,7 +4922,7 @@ Authenticates an app account to obtain the authorization token. This API uses an ...@@ -4922,7 +4922,7 @@ Authenticates an app account to obtain the authorization token. This API uses an
| options | {[key: string]: Object} | Yes | Options for the authentication. | | options | {[key: string]: Object} | Yes | Options for the authentication. |
| callback | [AuthCallback](#authcallback9) | Yes | Callback invoked to return the result.| | callback | [AuthCallback](#authcallback9) | Yes | Callback invoked to return the result.|
### authenticate<sup>deprecated</sup> ### authenticate<sup>(deprecated)</sup>
authenticate(name: string, authType: string, callerBundleName: string, options: {[key: string]: any}, callback: AuthenticatorCallback): void authenticate(name: string, authType: string, callerBundleName: string, options: {[key: string]: any}, callback: AuthenticatorCallback): void
......
# @ohos.bluetooth # @ohos.bluetooth (Bluetooth)
The **Bluetooth** module provides classic Bluetooth capabilities and Bluetooth Low Energy (BLE) scan and advertising. The **Bluetooth** module provides classic Bluetooth capabilities and Bluetooth Low Energy (BLE) scan and advertising.
......
# @ohos.nfc.cardEmulation # @ohos.nfc.cardEmulation (Standard NFC Card Emulation)
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). 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).
...@@ -16,21 +16,40 @@ import cardEmulation from '@ohos.nfc.cardEmulation'; ...@@ -16,21 +16,40 @@ import cardEmulation from '@ohos.nfc.cardEmulation';
Enumerates the NFC card emulation types. Enumerates the NFC card emulation types.
**System capability**: SystemCapability.Communication.NFC.Core > **NOTE**
>
> This parameter is supported since API version 6 and deprecated since API version 9. You are advised to use [hasHceCapability](#hashcecapability9).
**System capability**: SystemCapability.Communication.NFC.CardEmulation
| Name| Value| Description| | Name| Value| Description|
| -------- | -------- | -------- | | -------- | -------- | -------- |
| HCE | 0 | HCE.| | HCE | 0 | HCE.|
| UICC | 1 | Subscriber identity module (SIM) card emulation.| | UICC | 1 | Subscriber identity module (SIM) card emulation.|
| ESE | 2 | embedded Secure Element (eSE) emulation.| | ESE | 2 | embedded Secure Element (eSE) emulation.|
## CardType<sup>9+</sup>
Enumerates the types of services used by the card emulation application.
## cardEmulation.isSupported **System capability**: SystemCapability.Communication.NFC.CardEmulation
| Name| Value| Description|
| -------- | -------- | -------- |
| PAYMENT | "payment" | Payment type.|
| OTHER | "other" | Other types.|
## isSupported
isSupported(feature: number): boolean isSupported(feature: number): boolean
Checks whether a certain type of card emulation is supported. Checks whether a certain type of card emulation is supported.
**System capability**: SystemCapability.Communication.NFC.Core > **NOTE**
>
> This parameter is supported since API version 6 and deprecated since API version 9. You are advised to use [hasHceCapability](#hashcecapability9).
**System capability**: SystemCapability.Communication.NFC.CardEmulation
**Parameters** **Parameters**
...@@ -44,68 +63,44 @@ Checks whether a certain type of card emulation is supported. ...@@ -44,68 +63,44 @@ Checks whether a certain type of card emulation is supported.
| -------- | -------- | | -------- | -------- |
| boolean | Returns **true** if the card emulation type is supported; returns **false** otherwise.| | boolean | Returns **true** if the card emulation type is supported; returns **false** otherwise.|
## HceService<sup>8+</sup> ## hasHceCapability<sup>9+</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.
### startHCE<sup>8+</sup> hasHceCapability(): boolean
startHCE(aidList: string[]): boolean Checks whether HCE is supported.
Starts HCE, including setting the application to be foreground preferred and dynamically registering the application identifier (AID) list. **System capability**: SystemCapability.Communication.NFC.CardEmulation
**Required permissions**: ohos.permission.NFC_CARD_EMULATION **Required permissions**: ohos.permission.NFC_CARD_EMULATION
**System capability**: SystemCapability.Communication.NFC.Core **Return value**
**Parameters**
| Name | Type | Mandatory| Description |
| ------- | -------- | ---- | ----------------------- |
| aidList | string[] | Yes | AID list to register.|
### stopHCE<sup>8+</sup>
stopHCE(): boolean
Stops HCE, including removing the foreground preferred attribute and releasing the dynamically registered AID list.
**Required permissions**: ohos.permission.NFC_CARD_EMULATION | **Type**| **Description**|
| -------- | -------- |
| boolean | Returns **true** if HCE is supported; returns **false** otherwise.|
**System capability**: SystemCapability.Communication.NFC.Core ## isDefaultService<sup>9+</sup>
### on<sup>8+</sup> isDefaultService(elementName: ElementName, type: CardType): boolean
on(type: "hceCmd", callback: AsyncCallback<number[]>): void; Checks whether an application is the default application of the specified service type.
Registers a callback to receive APDUs from the peer card reader. **System capability**: SystemCapability.Communication.NFC.CardEmulation
**Required permissions**: ohos.permission.NFC_CARD_EMULATION **Required permissions**: ohos.permission.NFC_CARD_EMULATION
**System capability**: SystemCapability.Communication.NFC.Core
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ----------------------- | ---- | -------------------------------------------- | | ------- | -------- | ---- | ----------------------- |
| type | string | Yes | Event type to subscribe to. The value is **hceCmd**. | | elementName | [ElementName](js-apis-bundleManager-elementName.md#elementname) | Yes| Application description, which consists of the bundle name and component name.|
| callback | AsyncCallback<number[]> | Yes | Callback invoked to return the APDU. Each number in the callback is a hexadecimal number ranging from **0x00** to **0xFF**.| | type | [CardType](#cardtype9) | Yes| Card emulation service type.|
### sendResponse<sup>8+</sup>
sendResponse(responseApdu: number[]): void;
Sends a response to the peer card reader.
**Required permissions**: ohos.permission.NFC_CARD_EMULATION
**System capability**: SystemCapability.Communication.NFC.Core
**Parameters** **Return value**
| Name | Type | Mandatory| Description | | **Type**| **Description**|
| ------------ | -------- | ---- | -------------------------------------------------- | | -------- | -------- |
| responseApdu | number[] | Yes | Response APDU sent to the peer card reader. Each number of the APDU is a hexadecimal number ranging from **0x00** to **0xFF**.| | boolean | Returns **true** if the application is the default payment application; returns **false** otherwise.|
**Example** **Example**
...@@ -118,23 +113,16 @@ if (!isHceSupported) { ...@@ -118,23 +113,16 @@ if (!isHceSupported) {
return; return;
} }
// The device supports HCE and transimits APDUs with the remote NFC reader. var hasHceCap = cardEmulation.hasHceCapability();
var hceService = new cardEmulation.HceService(); if (!hasHceCap) {
hceService.startHCE([ console.log('this device hasHceCapability false, ignore it.');
"F0010203040506", "A0000000041010" return;
]); }
hceService.on("hceCmd", (err, res) => { var elementName = {
if(err.data === 0) { "bundleName": "com.example.myapplication",
console.log('callback => Operation hceCmd succeeded. Data: ' + JSON.stringify(res)); "abilityName": "EntryAbility",
hceService.sendResponse([0x00,0xa4,0x04,0x00, };
0x0e,0x32,0x50,0x41,0x59,0x2e,0x53,0x59,0x53,0x2e,0x44,0x44, var isDefaultService = cardEmulation.isDefaultService(elementName, cardEmulation.CardType.PAYMENT);
0x46,0x30,0x31,0x00]); console.log('is the app is default service for this card type: ' + isDefaultService);
} else {
console.log('callback => Operation hceCmd failed. Cause: ' + err.data);
}
})
// Stop HCE when the application exits the NFC card emulation.
hceService.stopHCE();
``` ```
# @ohos.connectedTag # @ohos.connectedTag (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. 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.
...@@ -129,7 +129,7 @@ Writes data to this active tag. This API uses a promise to return the result. ...@@ -129,7 +129,7 @@ Writes data to this active tag. This API uses a promise to return the result.
```js ```js
import connectedTag from '@ohos.connectedTag'; import connectedTag from '@ohos.connectedTag';
var rawData = "010203"; // change it tobe correct. var rawData = "010203"; // Set it as required.
connectedTag.writeNdefTag(rawData).then(() => { connectedTag.writeNdefTag(rawData).then(() => {
console.log("connectedTag writeNdefTag Promise success."); console.log("connectedTag writeNdefTag Promise success.");
}).catch((err)=> { }).catch((err)=> {
...@@ -159,7 +159,7 @@ Writes data to this active tag. This API uses an asynchronous callback to return ...@@ -159,7 +159,7 @@ Writes data to this active tag. This API uses an asynchronous callback to return
```js ```js
import connectedTag from '@ohos.connectedTag'; import connectedTag from '@ohos.connectedTag';
var rawData = "010203"; // change it tobe correct. var rawData = "010203"; // Set it as required.
connectedTag.writeNdefTag(rawData, (err)=> { connectedTag.writeNdefTag(rawData, (err)=> {
if (err) { if (err) {
console.log("connectedTag writeNdefTag AsyncCallback err: " + err); console.log("connectedTag writeNdefTag AsyncCallback err: " + err);
...@@ -220,7 +220,7 @@ connectedTag.on("notify", (err, rfState)=> { ...@@ -220,7 +220,7 @@ connectedTag.on("notify", (err, rfState)=> {
var initStatus = connectedTag.init(); var initStatus = connectedTag.init();
console.log("connectedTag init status: " + initStatus); console.log("connectedTag init status: " + initStatus);
// Add nfc connecected tag business oprations here... // Add NFC connected tag business operations here.
// connectedTag.writeNdefTag(rawData) // connectedTag.writeNdefTag(rawData)
// connectedTag.readNdefTag() // connectedTag.readNdefTag()
......
# @ohos.account.distributedAccount # @ohos.account.distributedAccount (Distributed Account Management)
The **distributedAccount** module provides APIs for managing distributed accounts, including querying and updating account login states. The **distributedAccount** module provides APIs for managing distributed accounts, including querying and updating account login states.
...@@ -252,7 +252,7 @@ Sets the distributed account information. This API uses a promise to return the ...@@ -252,7 +252,7 @@ Sets the distributed account information. This API uses a promise to return the
updateOsAccountDistributedInfo(accountInfo: DistributedInfo, callback: AsyncCallback&lt;void&gt;): void updateOsAccountDistributedInfo(accountInfo: DistributedInfo, callback: AsyncCallback&lt;void&gt;): void
Updates distributed account information. This API uses an asynchronous callback to return the result. Updates the distributed account information. This API uses an asynchronous callback to return the result.
> **NOTE** > **NOTE**
> >
......
# Standard NFC # @ohos.nfc.controller (Standard NFC)
The **nfcController** module provides APIs for opening and closing Near-Field Communication (NFC) and reading the NFC state. The **nfcController** module provides APIs for opening and closing Near-Field Communication (NFC) and reading the NFC state.
> **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. > 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** ## **Modules to Import**
``` ```js
import controller from '@ohos.nfc.controller'; import controller from '@ohos.nfc.controller';
``` ```
...@@ -18,7 +18,7 @@ Enumerates the NFC states. ...@@ -18,7 +18,7 @@ Enumerates the NFC states.
**System capability**: SystemCapability.Communication.NFC.Core **System capability**: SystemCapability.Communication.NFC.Core
| Name| Default Value| Description| | Name| Value| Description|
| -------- | -------- | -------- | | -------- | -------- | -------- |
| STATE_OFF | 1 | NFC is closed (OFF).| | STATE_OFF | 1 | NFC is closed (OFF).|
| STATE_TURNING_ON | 2 | NFC is turning on.| | STATE_TURNING_ON | 2 | NFC is turning on.|
...@@ -31,6 +31,10 @@ isNfcAvailable(): boolean ...@@ -31,6 +31,10 @@ isNfcAvailable(): boolean
Checks whether the device supports NFC. Checks whether the device supports NFC.
> **NOTE**
>
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use canIUse("SystemCapability.Communication.NFC.Core").
**System capability**: SystemCapability.Communication.NFC.Core **System capability**: SystemCapability.Communication.NFC.Core
**Return value** **Return value**
...@@ -46,6 +50,10 @@ openNfc(): boolean ...@@ -46,6 +50,10 @@ openNfc(): boolean
Opens NFC. Opens NFC.
> **NOTE**
>
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [enableNfc](#controllerenablenfc9).
**Required permissions**: ohos.permission.MANAGE_SECURE_SETTINGS **Required permissions**: ohos.permission.MANAGE_SECURE_SETTINGS
**System capability**: SystemCapability.Communication.NFC.Core **System capability**: SystemCapability.Communication.NFC.Core
...@@ -56,12 +64,34 @@ Opens NFC. ...@@ -56,12 +64,34 @@ Opens NFC.
| -------- | -------- | | -------- | -------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.| | boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
## controller.enableNfc<sup>9+</sup>
enableNfc(): boolean
Enables NFC.
**Required permissions**: ohos.permission.MANAGE_SECURE_SETTINGS
**System capability**: SystemCapability.Communication.NFC.Core
**Error codes**
For details about the error codes, see [NFC Error Codes](../errorcodes/errorcode-nfc.md).
| ID| Error Message|
| ------- | -------|
| 3100101 | NFC state is abnormal in service. |
## controller.closeNfc ## controller.closeNfc
closeNfc(): boolean closeNfc(): boolean
Closes NFC. Closes NFC.
> **NOTE**
>
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [disableNfc](#controllerdisablenfc9).
**Required permissions**: ohos.permission.MANAGE_SECURE_SETTINGS **Required permissions**: ohos.permission.MANAGE_SECURE_SETTINGS
**System capability**: SystemCapability.Communication.NFC.Core **System capability**: SystemCapability.Communication.NFC.Core
...@@ -72,6 +102,24 @@ Closes NFC. ...@@ -72,6 +102,24 @@ Closes NFC.
| -------- | ------------------------------------------- | | -------- | ------------------------------------------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.| | boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
## controller.disableNfc<sup>9+</sup>
disableNfc(): boolean
Disables NFC.
**Required permissions**: ohos.permission.MANAGE_SECURE_SETTINGS
**System capability**: SystemCapability.Communication.NFC.Core
**Error codes**
For details about the error codes, see [NFC Error Codes](../errorcodes/errorcode-nfc.md).
| ID| Error Message|
| ------- | -------|
| 3100101 | NFC state is abnormal in service. |
## controller.isNfcOpen ## controller.isNfcOpen
isNfcOpen(): boolean isNfcOpen(): boolean
...@@ -108,14 +156,12 @@ Subscribes to NFC state changes. A callback will be invoked to return the NFC st ...@@ -108,14 +156,12 @@ Subscribes to NFC state changes. A callback will be invoked to return the NFC st
**System capability**: SystemCapability.Communication.NFC.Core **System capability**: SystemCapability.Communication.NFC.Core
**Parameter** **Parameters**
| **Name**| **Type**| **Mandatory**| **Description**| | **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| type | string | Yes| Event type to subscribe to. The value is **nfcStateChange**.| | type | string | Yes| Event type to subscribe to. The value is **nfcStateChange**.|
| callback | Callback&lt;[NfcState](#nfcstate)&gt; | Yes| Callback invoked to return the NFC state.| | callback | Callback&lt;[NfcState](#nfcstate)&gt; | Yes| Callback invoked to return the NFC state.|
## controller.off('nfcStateChange') ## controller.off('nfcStateChange')
...@@ -125,42 +171,55 @@ Unsubscribes from the NFC state changes. The subscriber will not receive NFC sta ...@@ -125,42 +171,55 @@ Unsubscribes from the NFC state changes. The subscriber will not receive NFC sta
**System capability**: SystemCapability.Communication.NFC.Core **System capability**: SystemCapability.Communication.NFC.Core
**Parameter** **Parameters**
| **Name**| **Type**| **Mandatory**| **Description**| | **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| type | string | Yes| Event type to unsubscribe from. The value is **nfcStateChange**.| | type | string | Yes| Event type to unsubscribe from. The value is **nfcStateChange**.|
| callback | Callback&lt;[NfcState](#nfcstate)&gt; | No| Callback for the NFC state changes. This parameter can be left blank.| | callback | Callback&lt;[NfcState](#nfcstate)&gt; | No| Callback for the NFC state changes. This parameter can be left blank.|
**Example** **Example**
```js ```js
import controller from '@ohos.nfc.controller'; import controller from '@ohos.nfc.controller';
// Define a callback key.
var NFC_STATE_CALLBACK_KEY = "nfcStateChange";
// Register the callback to receive NFC state change notifications.
controller.on(NFC_STATE_CALLBACK_KEY, (err, nfcState)=> {
if (err) {
console.log("controller on callback err: " + err);
} else {
console.log("controller on callback nfcState: " + nfcState);
}
});
// Open NFC. Require permission: ohos.permission.MANAGE_SECURE_SETTINGS.
if (!controller.isNfcOpen()) {
var ret = controller.openNfc();
console.log("controller openNfc ret: " + ret);
}
// Close NFC. Require permission: ohos.permission.MANAGE_SECURE_SETTINGS. // Register a callback to receive the NFC state change notification.
if (controller.isNfcOpen()) { controller.on("nfcStateChange", (err, nfcState)=> {
var ret = controller.closeNfc(); if (err) {
console.log("controller closeNfc ret: " + ret); console.log("controller on callback err: " + err);
} else {
console.log("controller on callback nfcState: " + nfcState);
} }
});
// Unregister the callback.
controller.off(NFC_STATE_CALLBACK_KEY); // Open NFC. The ohos.permission.MANAGE_SECURE_SETTINGS permission is required.
``` if (!controller.isNfcOpen()) {
var ret = controller.openNfc();
console.log("controller openNfc ret: " + ret);
}
// Use 'enableNfc' to enable NFC from API version 9.
try {
controller.enableNfc();
console.log("controller enableNfc success");
} catch (busiError) {
console.log("controller enableNfc busiError: " + busiError);
}
// Close NFC. The ohos.permission.MANAGE_SECURE_SETTINGS permission is required.
if (controller.isNfcOpen()) {
var ret = controller.closeNfc();
console.log("controller closeNfc ret: " + ret);
}
// Use 'disableNfc' to disable NFC from API version 9.
try {
controller.disableNfc();
console.log("controller disableNfc success");
} catch (busiError) {
console.log("controller disableNfc busiError: " + busiError);
}
// Unregister the callback.
controller.off("nfcStateChange");
```
# @ohos.nfc.tag # @ohos.nfc.tag (Standard NFC Tags)
The **nfcTag** module provides APIs for managing Near-Field Communication (NFC) tags. The **nfcTag** module provides APIs for managing Near-Field Communication (NFC) tags.
...@@ -48,11 +48,11 @@ Before developing applications related to tag read and write, you must declare N ...@@ -48,11 +48,11 @@ Before developing applications related to tag read and write, you must declare N
} }
``` ```
> **CAUTION**<br> > **CAUTION**<br>
1. The **actions** field is mandatory. It must be **ohos.nfc.tag.action.TAG_FOUND** and cannot be changed. >
2. The **name** field under **metadata** is mandatory. It must be **tag-tech** and cannot be changed. > - The **actions** field is mandatory. It must be **ohos.nfc.tag.action.TAG_FOUND** and cannot be changed.
3. The **value** field under **metadata** is mandatory. It can be **NfcA**, **NfcB**, **NfcF**, **NfcV**, **IsoDep**, **Ndef**, **MifareClassic**, **MifareUL**, **NdefFormatable** or any of their combinations. Incorrect settings of this field will cause a parsing failure. > - The **name** field under **metadata** is mandatory. It must be **tag-tech** and cannot be changed.
4. The **name** field under **requestPermissions** is mandatory. It must be **ohos.permission.NFC_TAG** and cannot be changed. > - The **value** field under **metadata** is mandatory. It can be **NfcA**, **NfcB**, **NfcF**, **NfcV**, **IsoDep**, **Ndef**, **MifareClassic**, **MifareUL**, **NdefFormatable** or any of their combinations. Incorrect settings of this field will cause a parsing failure.
> - The **name** field under **requestPermissions** is mandatory. It must be **ohos.permission.NFC_TAG** and cannot be changed.
## **Modules to Import** ## **Modules to Import**
```js ```js
...@@ -73,7 +73,7 @@ onCreate(want, launchParam) { ...@@ -73,7 +73,7 @@ onCreate(want, launchParam) {
try { try {
tagInfo = tag.getTagInfo(want); tagInfo = tag.getTagInfo(want);
} catch (error) { } catch (error) {
console.log("tag.getTagInfo catched error: " + error); console.log("tag.getTagInfo caught error: " + error);
} }
if (tagInfo == null || tagInfo == undefined) { if (tagInfo == null || tagInfo == undefined) {
console.log("no TagInfo to be created, ignore it."); console.log("no TagInfo to be created, ignore it.");
...@@ -100,7 +100,7 @@ onCreate(want, launchParam) { ...@@ -100,7 +100,7 @@ onCreate(want, launchParam) {
try { try {
nfcA = tag.getNfcATag(taginfo); nfcA = tag.getNfcATag(taginfo);
} catch (error) { } catch (error) {
console.log("tag.getNfcATag catched error: " + error); console.log("tag.getNfcATag caught error: " + error);
} }
// Other code to read or write this tag. // Other code to read or write this tag.
} }
...@@ -111,7 +111,7 @@ onCreate(want, launchParam) { ...@@ -111,7 +111,7 @@ onCreate(want, launchParam) {
try { try {
isoDep = tag.getIsoDep(taginfo); isoDep = tag.getIsoDep(taginfo);
} catch (error) { } catch (error) {
console.log("tag.getIsoDep catched error: " + error); console.log("tag.getIsoDep caught error: " + error);
} }
// Other code to read or write this tag. // Other code to read or write this tag.
} }
...@@ -126,9 +126,16 @@ getNfcATag(tagInfo: [TagInfo](#taginfo)): [NfcATag](js-apis-nfctech.md#nfcatag) ...@@ -126,9 +126,16 @@ getNfcATag(tagInfo: [TagInfo](#taginfo)): [NfcATag](js-apis-nfctech.md#nfcatag)
Obtains an **NfcATag** object, which allows access to the tags that use the NFC-A technology. Obtains an **NfcATag** object, which allows access to the tags that use the NFC-A technology.
**Required permissions**: ohos.permission.NFC_TAG > **NOTE**
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [tag.getNfcA](#taggetnfca9).
**System capability**: SystemCapability.Communication.NFC.Tag
**System capability**: SystemCapability.Communication.NFC.Core **Parameters**
| Name | Type | Mandatory | Description |
| --------- | ------------------------- | ---- | ---------------------------------------- |
| taginfo | [TagInfo](#taginfo) | Yes| Tag information including the technology type and related parameters, which are obtained from **tag.getTagInfo(want: Want)**.
**Return value** **Return value**
...@@ -136,15 +143,70 @@ Obtains an **NfcATag** object, which allows access to the tags that use the NFC- ...@@ -136,15 +143,70 @@ Obtains an **NfcATag** object, which allows access to the tags that use the NFC-
| -------- | -------- | | -------- | -------- |
| [NfcATag](js-apis-nfctech.md#nfcatag) | **NfcATag** object obtained.| | [NfcATag](js-apis-nfctech.md#nfcatag) | **NfcATag** object obtained.|
## tag.getNfcA<sup>9+</sup>
getNfcA(tagInfo: [TagInfo](#taginfo)): [NfcATag](js-apis-nfctech.md#nfcatag)
Obtains an **NfcATag** object, which allows access to the tags that use the NFC-A technology.
**System capability**: SystemCapability.Communication.NFC.Tag
**Parameters**
| Name | Type | Mandatory | Description |
| --------- | ------------------------- | ---- | ---------------------------------------- |
| taginfo | [TagInfo](#taginfo) | Yes| Tag information including the technology type and related parameters, which are obtained from **tag.getTagInfo(want: Want)**.
**Return value**
| **Type**| **Description**|
| -------- | -------- |
| [NfcATag](js-apis-nfctech.md#nfcatag) | **NfcATag** object obtained.|
**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. |
## tag.getNfcBTag ## tag.getNfcBTag
getNfcBTag(tagInfo: [TagInfo](#taginfo)): [NfcBTag](js-apis-nfctech.md#nfcbtag) getNfcBTag(tagInfo: [TagInfo](#taginfo)): [NfcBTag](js-apis-nfctech.md#nfcbtag)
Obtains an **NfcBTag** object, which allows access to the tags that use the NFC-B technology. Obtains an **NfcBTag** object, which allows access to the tags that use the NFC-B technology.
**Required permissions**: ohos.permission.NFC_TAG > **NOTE**
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [tag.getNfcB](#taggetnfcb9).
**System capability**: SystemCapability.Communication.NFC.Tag
**Parameters**
| Name | Type | Mandatory | Description |
| --------- | ------------------------- | ---- | ---------------------------------------- |
| taginfo | [TagInfo](#taginfo) | Yes| Tag information including the technology type and related parameters, which are obtained from **tag.getTagInfo(want: Want)**.
**Return value**
| **Type**| **Description** |
| -------- | ---------------- |
| [NfcBTag](js-apis-nfctech.md#nfcbtag) | **NfcBTag** object obtained.|
## tag.getNfcB<sup>9+</sup>
getNfcB(tagInfo: [TagInfo](#taginfo)): [NfcBTag](js-apis-nfctech.md#nfcbtag)
**System capability**: SystemCapability.Communication.NFC.Core Obtains an **NfcBTag** object, which allows access to the tags that use the NFC-B technology.
**System capability**: SystemCapability.Communication.NFC.Tag
**Parameters**
| Name | Type | Mandatory | Description |
| --------- | ------------------------- | ---- | ---------------------------------------- |
| taginfo | [TagInfo](#taginfo) | Yes| Tag information including the technology type and related parameters, which are obtained from **tag.getTagInfo(want: Want)**.
**Return value** **Return value**
...@@ -152,15 +214,30 @@ Obtains an **NfcBTag** object, which allows access to the tags that use the NFC- ...@@ -152,15 +214,30 @@ Obtains an **NfcBTag** object, which allows access to the tags that use the NFC-
| -------- | ---------------- | | -------- | ---------------- |
| [NfcBTag](js-apis-nfctech.md#nfcbtag) | **NfcBTag** object obtained.| | [NfcBTag](js-apis-nfctech.md#nfcbtag) | **NfcBTag** object obtained.|
**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. |
## tag.getNfcFTag ## tag.getNfcFTag
getNfcFTag(tagInfo: [TagInfo](#taginfo)): [NfcFTag](js-apis-nfctech.md#nfcftag) getNfcFTag(tagInfo: [TagInfo](#taginfo)): [NfcFTag](js-apis-nfctech.md#nfcftag)
Obtains an **NfcFTag** object, which allows access to the tags that use the NFC-F technology. Obtains an **NfcFTag** object, which allows access to the tags that use the NFC-F technology.
**Required permissions**: ohos.permission.NFC_TAG > **NOTE**
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [tag.getNfcF](#taggetnfcf9).
**System capability**: SystemCapability.Communication.NFC.Tag
**System capability**: SystemCapability.Communication.NFC.Core **Parameters**
| Name | Type | Mandatory | Description |
| --------- | ------------------------- | ---- | ---------------------------------------- |
| taginfo | [TagInfo](#taginfo) | Yes| Tag information including the technology type and related parameters, which are obtained from **tag.getTagInfo(want: Want)**.
**Return value** **Return value**
...@@ -168,15 +245,70 @@ Obtains an **NfcFTag** object, which allows access to the tags that use the NFC- ...@@ -168,15 +245,70 @@ Obtains an **NfcFTag** object, which allows access to the tags that use the NFC-
| -------- | ---------------- | | -------- | ---------------- |
| [NfcFTag](js-apis-nfctech.md#nfcftag) | **NfcFTag** object obtained.| | [NfcFTag](js-apis-nfctech.md#nfcftag) | **NfcFTag** object obtained.|
## tag.getNfcF<sup>9+</sup>
getNfcF(tagInfo: [TagInfo](#taginfo)): [NfcFTag](js-apis-nfctech.md#nfcftag)
Obtains an **NfcFTag** object, which allows access to the tags that use the NFC-F technology.
**System capability**: SystemCapability.Communication.NFC.Tag
**Parameters**
| Name | Type | Mandatory | Description |
| --------- | ------------------------- | ---- | ---------------------------------------- |
| taginfo | [TagInfo](#taginfo) | Yes| Tag information including the technology type and related parameters, which are obtained from **tag.getTagInfo(want: Want)**.
**Return value**
| **Type**| **Description** |
| -------- | ---------------- |
| [NfcFTag](js-apis-nfctech.md#nfcftag) | **NfcFTag** object obtained.|
**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. |
## tag.getNfcVTag ## tag.getNfcVTag
getNfcVTag(tagInfo: [TagInfo](#taginfo)): [NfcVTag](js-apis-nfctech.md#nfcvtag) getNfcVTag(tagInfo: [TagInfo](#taginfo)): [NfcVTag](js-apis-nfctech.md#nfcvtag)
Obtains an **NfcVTag** object, which allows access to the tags that use the NFC-V technology. Obtains an **NfcVTag** object, which allows access to the tags that use the NFC-V technology.
**Required permissions**: ohos.permission.NFC_TAG > **NOTE**
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [tag.getNfcV](#taggetnfcv9).
**System capability**: SystemCapability.Communication.NFC.Core **System capability**: SystemCapability.Communication.NFC.Tag
**Parameters**
| Name | Type | Mandatory | Description |
| --------- | ------------------------- | ---- | ---------------------------------------- |
| taginfo | [TagInfo](#taginfo) | Yes| Tag information including the technology type and related parameters, which are obtained from **tag.getTagInfo(want: Want)**.
**Return value**
| **Type**| **Description** |
| -------- | ---------------- |
| [NfcVTag](js-apis-nfctech.md#nfcvtag) | **NfcVTag** object obtained.|
## tag.getNfcV<sup>9+</sup>
getNfcV(tagInfo: [TagInfo](#taginfo)): [NfcVTag](js-apis-nfctech.md#nfcvtag)
Obtains an **NfcVTag** object, which allows access to the tags that use the NFC-V technology.
**System capability**: SystemCapability.Communication.NFC.Tag
**Parameters**
| Name | Type | Mandatory | Description |
| --------- | ------------------------- | ---- | ---------------------------------------- |
| taginfo | [TagInfo](#taginfo) | Yes| Tag information including the technology type and related parameters, which are obtained from **tag.getTagInfo(want: Want)**.
**Return value** **Return value**
...@@ -184,19 +316,27 @@ Obtains an **NfcVTag** object, which allows access to the tags that use the NFC- ...@@ -184,19 +316,27 @@ Obtains an **NfcVTag** object, which allows access to the tags that use the NFC-
| -------- | ---------------- | | -------- | ---------------- |
| [NfcVTag](js-apis-nfctech.md#nfcvtag) | **NfcVTag** object obtained.| | [NfcVTag](js-apis-nfctech.md#nfcvtag) | **NfcVTag** object obtained.|
**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. |
## tag.getIsoDep<sup>9+</sup> ## tag.getIsoDep<sup>9+</sup>
getIsoDep(tagInfo: [TagInfo](#taginfo)): [IsoDepTag](js-apis-nfctech.md#isoDepTag9 ) getIsoDep(tagInfo: [TagInfo](#taginfo)): [IsoDepTag](js-apis-nfctech.md#isoDepTag9 )
Obtains an **IsoDepTag** object, which allows access to the tags that use the ISO-DEP technology. Obtains an **IsoDepTag** object, which allows access to the tags that use the ISO-DEP technology.
**System capability**: SystemCapability.Communication.NFC.Core **System capability**: SystemCapability.Communication.NFC.Tag
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| --------- | ------------------------- | ---- | ---------------------------------------- | | --------- | ------------------------- | ---- | ---------------------------------------- |
| taginfo | [TagInfo](#taginfo) | Yes| Tag information including the technology type and related parameters, which are obtained from **tag.getTagInfo(want: Want)**. | | taginfo | [TagInfo](#taginfo) | Yes| Tag information including the technology type and related parameters, which are obtained from **tag.getTagInfo(want: Want)**. |
**Return value** **Return value**
...@@ -218,13 +358,13 @@ getNdef(tagInfo: [TagInfo](#taginfo)): [NdefTag](js-apis-nfctech.md#ndeftag9) ...@@ -218,13 +358,13 @@ getNdef(tagInfo: [TagInfo](#taginfo)): [NdefTag](js-apis-nfctech.md#ndeftag9)
Obtains an **NdefTag** object, which allows access to the tags in the NFC Data Exchange Format (NDEF). Obtains an **NdefTag** object, which allows access to the tags in the NFC Data Exchange Format (NDEF).
**System capability**: SystemCapability.Communication.NFC.Core **System capability**: SystemCapability.Communication.NFC.Tag
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| --------- | ------------------------- | ---- | ---------------------------------------- | | --------- | ------------------------- | ---- | ---------------------------------------- |
| taginfo | [TagInfo](#taginfo) | Yes | Tag information including the technology type and related parameters, which are obtained from **tag.getTagInfo(want: Want)**. | | taginfo | [TagInfo](#taginfo) | Yes | Tag information including the technology type and related parameters, which are obtained from **tag.getTagInfo(want: Want)**. |
**Return value** **Return value**
...@@ -242,11 +382,11 @@ For details about the error codes, see [NFC Error Codes](../errorcodes/errorcode ...@@ -242,11 +382,11 @@ For details about the error codes, see [NFC Error Codes](../errorcodes/errorcode
## tag.getMifareClassic<sup>9+</sup> ## tag.getMifareClassic<sup>9+</sup>
getMifareClassic(tagInfo: [TagInfo](#taginfo)): [MifareClassicTag](js-apis-nfctech.md#mifareclassictag9) getMifareClassic(tagInfo: [TagInfo](#taginfo)): [MifareClassicTag](js-apis-nfctech.md#mifareclassictag-9)
Obtains a **MifareClassicTag** object, which allows access to the tags that use MIFARE Classic. Obtains a **MifareClassicTag** object, which allows access to the tags that use MIFARE Classic.
**System capability**: SystemCapability.Communication.NFC.Core **System capability**: SystemCapability.Communication.NFC.Tag
**Parameters** **Parameters**
...@@ -258,7 +398,7 @@ Obtains a **MifareClassicTag** object, which allows access to the tags that use ...@@ -258,7 +398,7 @@ Obtains a **MifareClassicTag** object, which allows access to the tags that use
| **Type**| **Description** | | **Type**| **Description** |
| ----------------- | ------------------------| | ----------------- | ------------------------|
| [MifareClassicTag](js-apis-nfctech.md#mifareclassictag9) | **MifareClassicTag** object obtained.| | [MifareClassicTag](js-apis-nfctech.md#mifareclassictag-9) | **MifareClassicTag** object obtained.|
**Error codes** **Error codes**
...@@ -274,12 +414,12 @@ getMifareUltralight(tagInfo: [TagInfo](#taginfo)): [MifareUltralightTag](js-apis ...@@ -274,12 +414,12 @@ getMifareUltralight(tagInfo: [TagInfo](#taginfo)): [MifareUltralightTag](js-apis
Obtains a **MifareUltralightTag** object, which allows access to the tags that use MIFARE Ultralight. Obtains a **MifareUltralightTag** object, which allows access to the tags that use MIFARE Ultralight.
**System capability**: SystemCapability.Communication.NFC.Core **System capability**: SystemCapability.Communication.NFC.Tag
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| --------- | ------------------------- | ---- | ---------------------------------------- | | --------- | ------------------------- | ---- | ---------------------------------------- |
| taginfo | [TagInfo](#taginfo) | Yes | Tag information including the technology type and related parameters, which are obtained from **tag.getTagInfo(want: Want)**. | | taginfo | [TagInfo](#taginfo) | Yes | Tag information including the technology type and related parameters, which are obtained from **tag.getTagInfo(want: Want)**. |
**Return value** **Return value**
...@@ -301,7 +441,7 @@ getNdefFormatable(tagInfo: [TagInfo](#taginfo)): [NdefFormatableTag](js-apis-nfc ...@@ -301,7 +441,7 @@ getNdefFormatable(tagInfo: [TagInfo](#taginfo)): [NdefFormatableTag](js-apis-nfc
Obtains an **NdefFormatableTag** object, which allows access to the tags that are NDEF formattable. Obtains an **NdefFormatableTag** object, which allows access to the tags that are NDEF formattable.
**System capability**: SystemCapability.Communication.NFC.Core **System capability**: SystemCapability.Communication.NFC.Tag
**Return value** **Return value**
...@@ -323,7 +463,7 @@ getTagInfo(want: [Want](js-apis-app-ability-want.md#Want)): [TagInfo](#taginfo) ...@@ -323,7 +463,7 @@ getTagInfo(want: [Want](js-apis-app-ability-want.md#Want)): [TagInfo](#taginfo)
Obtains **TagInfo** from **Want**, which is initialized by the NFC service and contains the attributes required by **TagInfo**. Obtains **TagInfo** from **Want**, which is initialized by the NFC service and contains the attributes required by **TagInfo**.
**System capability**: SystemCapability.Communication.NFC.Core **System capability**: SystemCapability.Communication.NFC.Tag
**Parameters** **Parameters**
...@@ -344,7 +484,7 @@ makeUriRecord(uri: string): [NdefRecord](#ndefrecord9); ...@@ -344,7 +484,7 @@ makeUriRecord(uri: string): [NdefRecord](#ndefrecord9);
Creates an NDEF record based on the specified URI. Creates an NDEF record based on the specified URI.
**System capability**: SystemCapability.Communication.NFC.Core **System capability**: SystemCapability.Communication.NFC.Tag
**Parameters** **Parameters**
...@@ -373,7 +513,7 @@ try { ...@@ -373,7 +513,7 @@ try {
console.log("ndefMessage makeUriRecord ndefRecord: " + ndefRecord); console.log("ndefMessage makeUriRecord ndefRecord: " + ndefRecord);
} }
} catch (busiError) { } catch (busiError) {
console.log("ndefMessage makeUriRecord catched busiError: " + busiError); console.log("ndefMessage makeUriRecord caught busiError: " + busiError);
} }
``` ```
...@@ -383,7 +523,7 @@ makeTextRecord(text: string, locale: string): [NdefRecord](#ndefrecord9); ...@@ -383,7 +523,7 @@ makeTextRecord(text: string, locale: string): [NdefRecord](#ndefrecord9);
Creates an NDEF record based on the specified text data and encoding type. Creates an NDEF record based on the specified text data and encoding type.
**System capability**: SystemCapability.Communication.NFC.Core **System capability**: SystemCapability.Communication.NFC.Tag
**Parameters** **Parameters**
...@@ -414,7 +554,7 @@ try { ...@@ -414,7 +554,7 @@ try {
console.log("ndefMessage makeTextRecord ndefRecord: " + ndefRecord); console.log("ndefMessage makeTextRecord ndefRecord: " + ndefRecord);
} }
} catch (busiError) { } catch (busiError) {
console.log("ndefMessage makeTextRecord catched busiError: " + busiError); console.log("ndefMessage makeTextRecord caught busiError: " + busiError);
} }
``` ```
...@@ -425,7 +565,7 @@ makeMimeRecord(mimeType: string, mimeData: number[]): [NdefRecord](#ndefrecord9) ...@@ -425,7 +565,7 @@ makeMimeRecord(mimeType: string, mimeData: number[]): [NdefRecord](#ndefrecord9)
Creates an NDEF record based on the specified MIME data and type. Creates an NDEF record based on the specified MIME data and type.
**System capability**: SystemCapability.Communication.NFC.Core **System capability**: SystemCapability.Communication.NFC.Tag
**Parameters** **Parameters**
...@@ -456,7 +596,7 @@ try { ...@@ -456,7 +596,7 @@ try {
console.log("ndefMessage makeMimeRecord ndefRecord: " + ndefRecord); console.log("ndefMessage makeMimeRecord ndefRecord: " + ndefRecord);
} }
} catch (busiError) { } catch (busiError) {
console.log("ndefMessage makeMimeRecord catched busiError: " + busiError); console.log("ndefMessage makeMimeRecord caught busiError: " + busiError);
} }
``` ```
## tag.ndef.makeExternalRecord<sup>9+</sup> ## tag.ndef.makeExternalRecord<sup>9+</sup>
...@@ -465,7 +605,7 @@ makeExternalRecord(domainName: string, type: string, externalData: number[]): [N ...@@ -465,7 +605,7 @@ makeExternalRecord(domainName: string, type: string, externalData: number[]): [N
Creates an NDEF record based on application-specific data. Creates an NDEF record based on application-specific data.
**System capability**: SystemCapability.Communication.NFC.Core **System capability**: SystemCapability.Communication.NFC.Tag
**Parameters** **Parameters**
...@@ -498,7 +638,7 @@ try { ...@@ -498,7 +638,7 @@ try {
console.log("ndefMessage makeExternalRecord ndefRecord: " + ndefRecord); console.log("ndefMessage makeExternalRecord ndefRecord: " + ndefRecord);
} }
} catch (busiError) { } catch (busiError) {
console.log("ndefMessage makeExternalRecord catched busiError: " + busiError); console.log("ndefMessage makeExternalRecord caught busiError: " + busiError);
} }
``` ```
...@@ -508,7 +648,7 @@ messageToBytes(ndefMessage: [NdefMessage](js-apis-nfctech.md#ndefmessage9)): num ...@@ -508,7 +648,7 @@ messageToBytes(ndefMessage: [NdefMessage](js-apis-nfctech.md#ndefmessage9)): num
Converts an NDEF message to bytes. Converts an NDEF message to bytes.
**System capability**: SystemCapability.Communication.NFC.Core **System capability**: SystemCapability.Communication.NFC.Tag
**Parameters** **Parameters**
...@@ -540,7 +680,7 @@ try { ...@@ -540,7 +680,7 @@ try {
let rawData2 = tag.ndef.messageToBytes(ndefMessage); let rawData2 = tag.ndef.messageToBytes(ndefMessage);
console.log("ndefMessage messageToBytes rawData2: " + rawData2); console.log("ndefMessage messageToBytes rawData2: " + rawData2);
} catch (busiError) { } catch (busiError) {
console.log("ndefMessage messageToBytes catched busiError: " + busiError); console.log("ndefMessage messageToBytes caught busiError: " + busiError);
} }
``` ```
## tag.ndef.createNdefMessage<sup>9+</sup> ## tag.ndef.createNdefMessage<sup>9+</sup>
...@@ -549,7 +689,7 @@ createNdefMessage(data: number[]): [NdefMessage](js-apis-nfctech.md#ndefmessage9 ...@@ -549,7 +689,7 @@ createNdefMessage(data: number[]): [NdefMessage](js-apis-nfctech.md#ndefmessage9
Creates an NDEF message from raw byte data. The data must comply with the NDEF record format. Otherwise, the NDE record list contained in the **NdefMessage** object will be empty. Creates an NDEF message from raw byte data. The data must comply with the NDEF record format. Otherwise, the NDE record list contained in the **NdefMessage** object will be empty.
**System capability**: SystemCapability.Communication.NFC.Core **System capability**: SystemCapability.Communication.NFC.Tag
**Parameters** **Parameters**
...@@ -583,7 +723,7 @@ createNdefMessage(ndefRecords: NdefRecord[]): [NdefMessage](js-apis-nfctech.md#n ...@@ -583,7 +723,7 @@ createNdefMessage(ndefRecords: NdefRecord[]): [NdefMessage](js-apis-nfctech.md#n
Creates an NDEF message from the NDEF records list. Creates an NDEF message from the NDEF records list.
**System capability**: SystemCapability.Communication.NFC.Core **System capability**: SystemCapability.Communication.NFC.Tag
**Parameters** **Parameters**
...@@ -618,7 +758,7 @@ try { ...@@ -618,7 +758,7 @@ try {
Defines the **TagInfo** object, which provides information about the tag technologies supported by a card. Defines the **TagInfo** object, which provides information about the tag technologies supported by a card.
**System capability**: SystemCapability.Communication.NFC.Core **System capability**: SystemCapability.Communication.NFC.Tag
**Required permissions**: ohos.permission.NFC_TAG **Required permissions**: ohos.permission.NFC_TAG
...@@ -626,14 +766,15 @@ Defines the **TagInfo** object, which provides information about the tag technol ...@@ -626,14 +766,15 @@ Defines the **TagInfo** object, which provides information about the tag technol
| -------- | -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- | -------- |
| uid<sup>9+</sup> | number[] | Yes| No| Tag unique identifier (UID), which consists of hexadecimal numbers ranging from **0x00** to **0xFF**.| | uid<sup>9+</sup> | number[] | Yes| No| Tag unique identifier (UID), which consists of hexadecimal numbers ranging from **0x00** to **0xFF**.|
| technology<sup>9+</sup> | number[] | Yes| No| Supported technologies. Each number is a constant indicating the supported technology.| | technology<sup>9+</sup> | number[] | Yes| No| Supported technologies. Each number is a constant indicating the supported technology.|
| supportedProfiles | number[] | Yes| No| Supported profiles. This parameter is not supported since API version 9. Use [tag.TagInfo#technology](#taginfo) instead.| | supportedProfiles | number[] | Yes| No| Supported profiles. This parameter is not supported since API version 9. Use [technology](#taginfo).|
| extrasData<sup>9+</sup> | [PacMap](js-apis-inner-ability-dataAbilityHelper.md#pacmap)[] | Yes| No| Extended attribute value of the tag technology.<br>**System API**: This is a system API.| | extrasData<sup>9+</sup> | [PacMap](js-apis-inner-ability-dataAbilityHelper.md#pacmap)[] | Yes| No| Extended attribute value of the tag technology.<br>**System API**: This is a system API.|
| tagRfDiscId<sup>9+</sup> | number | Yes| No| ID allocated when the tag is discovered.<br>**System API**: This is a system API.| | tagRfDiscId<sup>9+</sup> | number | Yes| No| ID allocated when the tag is discovered.<br>**System API**: This is a system API.|
| remoteTagService<sup>9+</sup> | [rpc.RemoteObject](js-apis-rpc.md#remoteobject) | Yes| No| Remote object of the NFC service process used for interface communication between the client and the service.<br>**System API**: This is a system API.| | remoteTagService<sup>9+</sup> | [rpc.RemoteObject](js-apis-rpc.md#remoteobject) | Yes| No| Remote object of the NFC service process used for interface communication between the client and the service.<br>**System API**: This is a system API.|
## NdefRecord<sup>9+</sup> ## NdefRecord<sup>9+</sup>
Defines an NDEF record. For details, see *NFCForum-TS-NDEF_1.0*. Defines an NDEF record. For details, see *NFCForum-TS-NDEF_1.0*.
**System capability**: SystemCapability.Communication.NFC.Core **System capability**: SystemCapability.Communication.NFC.Tag
| **Name**| **Type**| **Readable**| **Writable**| **Description**| | **Name**| **Type**| **Readable**| **Writable**| **Description**|
| -------- | -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- | -------- |
...@@ -645,7 +786,7 @@ Defines an NDEF record. For details, see *NFCForum-TS-NDEF_1.0*. ...@@ -645,7 +786,7 @@ Defines an NDEF record. For details, see *NFCForum-TS-NDEF_1.0*.
## Technology Type Definition ## Technology Type Definition
Enumerates the tag technology types. Enumerates the tag technology types.
**System capability**: SystemCapability.Communication.NFC.Core **System capability**: SystemCapability.Communication.NFC.Tag
| **Name**| **Value**| **Description**| | **Name**| **Value**| **Description**|
| -------- | -------- | -------- | | -------- | -------- | -------- |
...@@ -662,7 +803,7 @@ Enumerates the tag technology types. ...@@ -662,7 +803,7 @@ Enumerates the tag technology types.
## TnfType<sup>9+</sup> ## TnfType<sup>9+</sup>
Enumerates the TNF types. For details, see *NFCForum-TS-NDEF_1.0*. Enumerates the TNF types. For details, see *NFCForum-TS-NDEF_1.0*.
**System capability**: SystemCapability.Communication.NFC.Core **System capability**: SystemCapability.Communication.NFC.Tag
| **Name**| **Value**| **Description**| | **Name**| **Value**| **Description**|
| -------- | -------- | -------- | | -------- | -------- | -------- |
...@@ -677,7 +818,7 @@ Enumerates the TNF types. For details, see *NFCForum-TS-NDEF_1.0*. ...@@ -677,7 +818,7 @@ Enumerates the TNF types. For details, see *NFCForum-TS-NDEF_1.0*.
## NDEF Record RTD ## NDEF Record RTD
Enumerates the NDEF record types. For details about the RTD, see *NFCForum-TS-NDEF_1.0*. Enumerates the NDEF record types. For details about the RTD, see *NFCForum-TS-NDEF_1.0*.
**System capability**: SystemCapability.Communication.NFC.Core **System capability**: SystemCapability.Communication.NFC.Tag
| **Name**| **Value**| **Description**| | **Name**| **Value**| **Description**|
| -------- | -------- | -------- | | -------- | -------- | -------- |
...@@ -687,7 +828,7 @@ Enumerates the NDEF record types. For details about the RTD, see *NFCForum-TS-ND ...@@ -687,7 +828,7 @@ Enumerates the NDEF record types. For details about the RTD, see *NFCForum-TS-ND
## NfcForumType<sup>9+</sup> ## NfcForumType<sup>9+</sup>
Enumerates the NFC Forum tag types. Enumerates the NFC Forum tag types.
**System capability**: SystemCapability.Communication.NFC.Core **System capability**: SystemCapability.Communication.NFC.Tag
| **Name**| **Value**| **Description**| | **Name**| **Value**| **Description**|
| -------- | -------- | -------- | | -------- | -------- | -------- |
...@@ -700,7 +841,7 @@ Enumerates the NFC Forum tag types. ...@@ -700,7 +841,7 @@ Enumerates the NFC Forum tag types.
## MifareClassicType<sup>9+</sup> ## MifareClassicType<sup>9+</sup>
Enumerates the MIFARE Classic tag types. Enumerates the MIFARE Classic tag types.
**System capability**: SystemCapability.Communication.NFC.Core **System capability**: SystemCapability.Communication.NFC.Tag
| **Name**| **Value**| **Description**| | **Name**| **Value**| **Description**|
| -------- | -------- | -------- | | -------- | -------- | -------- |
...@@ -710,9 +851,9 @@ Enumerates the MIFARE Classic tag types. ...@@ -710,9 +851,9 @@ Enumerates the MIFARE Classic tag types.
| TYPE_PRO | 3 | MIFARE Pro.| | TYPE_PRO | 3 | MIFARE Pro.|
## MifareClassicSize<sup>9+</sup> ## MifareClassicSize<sup>9+</sup>
Enumerates the sizes of MIFARE Classic tags. Enumerates the sizes of a MIFARE Classic tag.
**System capability**: SystemCapability.Communication.NFC.Core **System capability**: SystemCapability.Communication.NFC.Tag
| **Name**| **Value**| **Description**| | **Name**| **Value**| **Description**|
| -------- | -------- | -------- | | -------- | -------- | -------- |
...@@ -724,11 +865,11 @@ Enumerates the sizes of MIFARE Classic tags. ...@@ -724,11 +865,11 @@ Enumerates the sizes of MIFARE Classic tags.
## MifareUltralightType<sup>9+</sup> ## MifareUltralightType<sup>9+</sup>
Enumerates the MIFARE Ultralight tag types. Enumerates the MIFARE Ultralight tag types.
**System capability**: SystemCapability.Communication.NFC.Core **System capability**: SystemCapability.Communication.NFC.Tag
| **Name**| **Value**| **Description**| | **Name**| **Value**| **Description**|
| -------- | -------- | -------- | | -------- | -------- | -------- |
| TYPE_UNKNOWN | 0 | Unknown type.| | TYPE_UNKNOWN | 0 | Unknown type.|
| TYPE_ULTRALIGHT | 1 | MIFARE Ultralight.| | TYPE_ULTRALIGHT | 1 | MIFARE Ultralight.|
| TYPE_ULTRALIGHT_C | 2 | MIFARE Ultralight C.| | TYPE_ULTRALIGHT_C | 2 | MIFARE Ultralight C.|
<!--no_check-->
# nfctech # nfctech (Standard NFC Technologies)
The **nfctech** module provides APIs 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.
...@@ -26,9 +26,7 @@ getSak(): number ...@@ -26,9 +26,7 @@ getSak(): number
Obtains the SAK value of this NFC-A tag. Obtains the SAK value of this NFC-A tag.
**Required permissions**: ohos.permission.NFC_TAG **System capability**: SystemCapability.Communication.NFC.Tag
**System capability**: SystemCapability.Communication.NFC.Core
**Return value** **Return value**
...@@ -52,9 +50,7 @@ getAtqa(): number[] ...@@ -52,9 +50,7 @@ getAtqa(): number[]
Obtains the ATQA value of this NFC-A tag. Obtains the ATQA value of this NFC-A tag.
**Required permissions**: ohos.permission.NFC_TAG **System capability**: SystemCapability.Communication.NFC.Tag
**System capability**: SystemCapability.Communication.NFC.Core
**Return value** **Return value**
...@@ -86,9 +82,7 @@ getRespAppData(): number[] ...@@ -86,9 +82,7 @@ getRespAppData(): number[]
Obtains the application data of this NFC-B tag. Obtains the application data of this NFC-B tag.
**Required permissions**: ohos.permission.NFC_TAG **System capability**: SystemCapability.Communication.NFC.Tag
**System capability**: SystemCapability.Communication.NFC.Core
**Return value** **Return value**
...@@ -112,9 +106,7 @@ getRespProtocol(): number[] ...@@ -112,9 +106,7 @@ getRespProtocol(): number[]
Obtains the protocol information of this NFC-B tag. Obtains the protocol information of this NFC-B tag.
**Required permissions**: ohos.permission.NFC_TAG **System capability**: SystemCapability.Communication.NFC.Tag
**System capability**: SystemCapability.Communication.NFC.Core
**Return value** **Return value**
...@@ -146,9 +138,7 @@ getSystemCode(): number[] ...@@ -146,9 +138,7 @@ getSystemCode(): number[]
Obtains the system code from this NFC-F tag. Obtains the system code from this NFC-F tag.
**Required permissions**: ohos.permission.NFC_TAG **System capability**: SystemCapability.Communication.NFC.Tag
**System capability**: SystemCapability.Communication.NFC.Core
**Return value** **Return value**
...@@ -172,9 +162,7 @@ getPmm(): number[] ...@@ -172,9 +162,7 @@ getPmm(): number[]
Obtains the PMm (consisting of the IC code and manufacturer parameters) information from this NFC-F tag. Obtains the PMm (consisting of the IC code and manufacturer parameters) information from this NFC-F tag.
**Required permissions**: ohos.permission.NFC_TAG **System capability**: SystemCapability.Communication.NFC.Tag
**System capability**: SystemCapability.Communication.NFC.Core
**Return value** **Return value**
...@@ -206,9 +194,7 @@ getResponseFlags(): number ...@@ -206,9 +194,7 @@ getResponseFlags(): number
Obtains the response flags from this NFC-V tag. Obtains the response flags from this NFC-V tag.
**Required permissions**: ohos.permission.NFC_TAG **System capability**: SystemCapability.Communication.NFC.Tag
**System capability**: SystemCapability.Communication.NFC.Core
**Return value** **Return value**
...@@ -232,9 +218,7 @@ getDsfId(): number ...@@ -232,9 +218,7 @@ getDsfId(): number
Obtains the data storage format identifier (DSFID) from this NFC-V tag. Obtains the data storage format identifier (DSFID) from this NFC-V tag.
**Required permissions**: ohos.permission.NFC_TAG **System capability**: SystemCapability.Communication.NFC.Tag
**System capability**: SystemCapability.Communication.NFC.Core
**Return value** **Return value**
...@@ -266,7 +250,7 @@ getHistoricalBytes(): number[] ...@@ -266,7 +250,7 @@ getHistoricalBytes(): number[]
Obtains the historical bytes for the given tag. This API applies only to the IsoDep cards that use the NFC-A technology. Obtains the historical bytes for the given tag. This API applies only to the IsoDep cards that use the NFC-A technology.
**System capability**: SystemCapability.Communication.NFC.Core **System capability**: SystemCapability.Communication.NFC.Tag
**Return value** **Return value**
...@@ -290,7 +274,7 @@ getHiLayerResponse(): number[] ...@@ -290,7 +274,7 @@ getHiLayerResponse(): number[]
Obtains the higher-layer response bytes for the given tag. This API applies only to the IsoDep cards that use the NFC-B technology. Obtains the higher-layer response bytes for the given tag. This API applies only to the IsoDep cards that use the NFC-B technology.
**System capability**: SystemCapability.Communication.NFC.Core **System capability**: SystemCapability.Communication.NFC.Tag
**Return value** **Return value**
...@@ -316,7 +300,7 @@ Checks whether an extended application protocol data unit (APDU) is supported. T ...@@ -316,7 +300,7 @@ Checks whether an extended application protocol data unit (APDU) is supported. T
**Required permissions**: ohos.permission.NFC_TAG **Required permissions**: ohos.permission.NFC_TAG
**System capability**: SystemCapability.Communication.NFC.Core **System capability**: SystemCapability.Communication.NFC.Tag
**Return value** **Return value**
...@@ -367,7 +351,7 @@ Checks whether an extended APDU is supported. This API uses an asynchronous call ...@@ -367,7 +351,7 @@ Checks whether an extended APDU is supported. This API uses an asynchronous call
**Required permissions**: ohos.permission.NFC_TAG **Required permissions**: ohos.permission.NFC_TAG
**System capability**: SystemCapability.Communication.NFC.Core **System capability**: SystemCapability.Communication.NFC.Tag
**Parameters** **Parameters**
...@@ -419,7 +403,7 @@ getNdefRecords(): [tag.NdefRecord](js-apis-nfcTag.md#ndefrecord9)[] ...@@ -419,7 +403,7 @@ getNdefRecords(): [tag.NdefRecord](js-apis-nfcTag.md#ndefrecord9)[]
Obtains all NDEF records. Obtains all NDEF records.
**System capability**: SystemCapability.Communication.NFC.Core **System capability**: SystemCapability.Communication.NFC.Tag
**Return value** **Return value**
...@@ -454,7 +438,7 @@ getNdefTagType(): [tag.NfcForumType](js-apis-nfcTag.md#nfcforumtype9) ...@@ -454,7 +438,7 @@ getNdefTagType(): [tag.NfcForumType](js-apis-nfcTag.md#nfcforumtype9)
Obtains the NDEF tag type. Obtains the NDEF tag type.
**System capability**: SystemCapability.Communication.NFC.Core **System capability**: SystemCapability.Communication.NFC.Tag
**Return value** **Return value**
...@@ -478,7 +462,7 @@ getNdefMessage(): [NdefMessage](#ndefmessage9) ...@@ -478,7 +462,7 @@ getNdefMessage(): [NdefMessage](#ndefmessage9)
Obtains the NDEF message from this NDEF tag. Obtains the NDEF message from this NDEF tag.
**System capability**: SystemCapability.Communication.NFC.Core **System capability**: SystemCapability.Communication.NFC.Tag
**Return value** **Return value**
...@@ -501,7 +485,7 @@ isNdefWritable(): boolean; ...@@ -501,7 +485,7 @@ isNdefWritable(): boolean;
Check whether this NDEF tag is writable. Before calling the data write API, check whether the write operation is supported. Check whether this NDEF tag is writable. Before calling the data write API, check whether the write operation is supported.
**System capability**: SystemCapability.Communication.NFC.Core **System capability**: SystemCapability.Communication.NFC.Tag
**Return value** **Return value**
...@@ -527,7 +511,7 @@ Reads the NDEF message from this tag. This API uses a promise to return the resu ...@@ -527,7 +511,7 @@ Reads the NDEF message from this tag. This API uses a promise to return the resu
**Required permissions**: ohos.permission.NFC_TAG **Required permissions**: ohos.permission.NFC_TAG
**System capability**: SystemCapability.Communication.NFC.Core **System capability**: SystemCapability.Communication.NFC.Tag
**Return value** **Return value**
...@@ -577,7 +561,7 @@ Reads the NDEF message from this tag. This API uses an asynchronous callback to ...@@ -577,7 +561,7 @@ Reads the NDEF message from this tag. This API uses an asynchronous callback to
**Required permissions**: ohos.permission.NFC_TAG **Required permissions**: ohos.permission.NFC_TAG
**System capability**: SystemCapability.Communication.NFC.Core **System capability**: SystemCapability.Communication.NFC.Tag
**Parameters** **Parameters**
...@@ -629,7 +613,7 @@ Writes an NDEF message to this tag. This API uses a promise to return the result ...@@ -629,7 +613,7 @@ Writes an NDEF message to this tag. This API uses a promise to return the result
**Required permissions**: ohos.permission.NFC_TAG **Required permissions**: ohos.permission.NFC_TAG
**System capability**: SystemCapability.Communication.NFC.Core **System capability**: SystemCapability.Communication.NFC.Tag
**Parameters** **Parameters**
...@@ -682,7 +666,7 @@ Writes an NDEF message to this tag. This API uses an asynchronous callback to re ...@@ -682,7 +666,7 @@ Writes an NDEF message to this tag. This API uses an asynchronous callback to re
**Required permissions**: ohos.permission.NFC_TAG **Required permissions**: ohos.permission.NFC_TAG
**System capability**: SystemCapability.Communication.NFC.Core **System capability**: SystemCapability.Communication.NFC.Tag
**Parameters** **Parameters**
...@@ -738,7 +722,7 @@ Checks whether this NDEF tag can be set to read-only. ...@@ -738,7 +722,7 @@ Checks whether this NDEF tag can be set to read-only.
**Required permissions**: ohos.permission.NFC_TAG **Required permissions**: ohos.permission.NFC_TAG
**System capability**: SystemCapability.Communication.NFC.Core **System capability**: SystemCapability.Communication.NFC.Tag
**Return value** **Return value**
...@@ -772,7 +756,7 @@ Sets this NDEF tag to read-only. This API uses a promise to return the result. ...@@ -772,7 +756,7 @@ Sets this NDEF tag to read-only. This API uses a promise to return the result.
**Required permissions**: ohos.permission.NFC_TAG **Required permissions**: ohos.permission.NFC_TAG
**System capability**: SystemCapability.Communication.NFC.Core **System capability**: SystemCapability.Communication.NFC.Tag
**Error codes** **Error codes**
...@@ -816,7 +800,7 @@ Sets this NDEF tag to read-only. This API uses an asynchronous callback to retur ...@@ -816,7 +800,7 @@ Sets this NDEF tag to read-only. This API uses an asynchronous callback to retur
**Required permissions**: ohos.permission.NFC_TAG **Required permissions**: ohos.permission.NFC_TAG
**System capability**: SystemCapability.Communication.NFC.Core **System capability**: SystemCapability.Communication.NFC.Tag
**Parameters** **Parameters**
...@@ -866,7 +850,7 @@ getNdefTagTypeString(type: [tag.NfcForumType](js-apis-nfcTag.md#nfcforumtype9)): ...@@ -866,7 +850,7 @@ getNdefTagTypeString(type: [tag.NfcForumType](js-apis-nfcTag.md#nfcforumtype9)):
Converts an NFC Forum Type tag to a string defined in the NFC Forum. Converts an NFC Forum Type tag to a string defined in the NFC Forum.
**System capability**: SystemCapability.Communication.NFC.Core **System capability**: SystemCapability.Communication.NFC.Tag
**Parameters** **Parameters**
...@@ -911,7 +895,7 @@ Authenticates a sector using a key. The sector can be accessed only after the au ...@@ -911,7 +895,7 @@ Authenticates a sector using a key. The sector can be accessed only after the au
**Required permissions**: ohos.permission.NFC_TAG **Required permissions**: ohos.permission.NFC_TAG
**System capability**: SystemCapability.Communication.NFC.Core **System capability**: SystemCapability.Communication.NFC.Tag
**Parameters** **Parameters**
...@@ -965,7 +949,7 @@ Authenticates a sector using a key. The sector can be accessed only after the au ...@@ -965,7 +949,7 @@ Authenticates a sector using a key. The sector can be accessed only after the au
**Required permissions**: ohos.permission.NFC_TAG **Required permissions**: ohos.permission.NFC_TAG
**System capability**: SystemCapability.Communication.NFC.Core **System capability**: SystemCapability.Communication.NFC.Tag
**Parameters** **Parameters**
...@@ -1021,7 +1005,7 @@ Reads a block (16 bytes) on this tag. This API uses a promise to return the resu ...@@ -1021,7 +1005,7 @@ Reads a block (16 bytes) on this tag. This API uses a promise to return the resu
**Required permissions**: ohos.permission.NFC_TAG **Required permissions**: ohos.permission.NFC_TAG
**System capability**: SystemCapability.Communication.NFC.Core **System capability**: SystemCapability.Communication.NFC.Tag
**Parameters** **Parameters**
...@@ -1078,14 +1062,14 @@ Reads a block (16 bytes) on this tag. This API uses an asynchronous callback to ...@@ -1078,14 +1062,14 @@ Reads a block (16 bytes) on this tag. This API uses an asynchronous callback to
**Required permissions**: ohos.permission.NFC_TAG **Required permissions**: ohos.permission.NFC_TAG
**System capability**: SystemCapability.Communication.NFC.Core **System capability**: SystemCapability.Communication.NFC.Tag
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ----------------------- | ---- | -------------------------------------- | | -------- | ----------------------- | ---- | -------------------------------------- |
| blockIndex | number | Yes | Index of the block to read. The block indexes start from **0**.| | blockIndex | number | Yes | Index of the block to read. The block indexes start from **0**.|
| callback | AsyncCallback\<number[]> | Yes | Callback invoked to return the block read.| | callback | AsyncCallback\<number[]> | Yes | Callback invoked to return the data read.|
**Error codes** **Error codes**
...@@ -1132,7 +1116,7 @@ Writes data to a block on this tag. This API uses a promise to return the result ...@@ -1132,7 +1116,7 @@ Writes data to a block on this tag. This API uses a promise to return the result
**Required permissions**: ohos.permission.NFC_TAG **Required permissions**: ohos.permission.NFC_TAG
**System capability**: SystemCapability.Communication.NFC.Core **System capability**: SystemCapability.Communication.NFC.Tag
**Parameters** **Parameters**
...@@ -1186,7 +1170,7 @@ Writes data to a block on this tag. This API uses an asynchronous callback to re ...@@ -1186,7 +1170,7 @@ Writes data to a block on this tag. This API uses an asynchronous callback to re
**Required permissions**: ohos.permission.NFC_TAG **Required permissions**: ohos.permission.NFC_TAG
**System capability**: SystemCapability.Communication.NFC.Core **System capability**: SystemCapability.Communication.NFC.Tag
**Parameters** **Parameters**
...@@ -1243,7 +1227,7 @@ Increments a block with data. This API uses a promise to return the result. ...@@ -1243,7 +1227,7 @@ Increments a block with data. This API uses a promise to return the result.
**Required permissions**: ohos.permission.NFC_TAG **Required permissions**: ohos.permission.NFC_TAG
**System capability**: SystemCapability.Communication.NFC.Core **System capability**: SystemCapability.Communication.NFC.Tag
**Parameters** **Parameters**
...@@ -1296,7 +1280,7 @@ Increments a block with data. This API uses an asynchronous callback to return t ...@@ -1296,7 +1280,7 @@ Increments a block with data. This API uses an asynchronous callback to return t
**Required permissions**: ohos.permission.NFC_TAG **Required permissions**: ohos.permission.NFC_TAG
**System capability**: SystemCapability.Communication.NFC.Core **System capability**: SystemCapability.Communication.NFC.Tag
**Parameters** **Parameters**
...@@ -1352,7 +1336,7 @@ Decrements a block. This API uses a promise to return the result. ...@@ -1352,7 +1336,7 @@ Decrements a block. This API uses a promise to return the result.
**Required permissions**: ohos.permission.NFC_TAG **Required permissions**: ohos.permission.NFC_TAG
**System capability**: SystemCapability.Communication.NFC.Core **System capability**: SystemCapability.Communication.NFC.Tag
**Parameters** **Parameters**
...@@ -1405,7 +1389,7 @@ Decrements a block. This API uses an asynchronous callback to return the result. ...@@ -1405,7 +1389,7 @@ Decrements a block. This API uses an asynchronous callback to return the result.
**Required permissions**: ohos.permission.NFC_TAG **Required permissions**: ohos.permission.NFC_TAG
**System capability**: SystemCapability.Communication.NFC.Core **System capability**: SystemCapability.Communication.NFC.Tag
**Parameters** **Parameters**
...@@ -1461,7 +1445,7 @@ Transfers data from the temporary register to a block. This API uses a promise t ...@@ -1461,7 +1445,7 @@ Transfers data from the temporary register to a block. This API uses a promise t
**Required permissions**: ohos.permission.NFC_TAG **Required permissions**: ohos.permission.NFC_TAG
**System capability**: SystemCapability.Communication.NFC.Core **System capability**: SystemCapability.Communication.NFC.Tag
**Parameters** **Parameters**
...@@ -1512,7 +1496,7 @@ Transfers data from the temporary register to a block. This API uses an asynchro ...@@ -1512,7 +1496,7 @@ Transfers data from the temporary register to a block. This API uses an asynchro
**Required permissions**: ohos.permission.NFC_TAG **Required permissions**: ohos.permission.NFC_TAG
**System capability**: SystemCapability.Communication.NFC.Core **System capability**: SystemCapability.Communication.NFC.Tag
**Parameters** **Parameters**
...@@ -1566,7 +1550,7 @@ Restores data in the temporary register from a block. This API uses a promise to ...@@ -1566,7 +1550,7 @@ Restores data in the temporary register from a block. This API uses a promise to
**Required permissions**: ohos.permission.NFC_TAG **Required permissions**: ohos.permission.NFC_TAG
**System capability**: SystemCapability.Communication.NFC.Core **System capability**: SystemCapability.Communication.NFC.Tag
**Parameters** **Parameters**
...@@ -1617,7 +1601,7 @@ Restores data in the temporary register from a block. This API uses an asynchron ...@@ -1617,7 +1601,7 @@ Restores data in the temporary register from a block. This API uses an asynchron
**Required permissions**: ohos.permission.NFC_TAG **Required permissions**: ohos.permission.NFC_TAG
**System capability**: SystemCapability.Communication.NFC.Core **System capability**: SystemCapability.Communication.NFC.Tag
**Parameters** **Parameters**
...@@ -1669,7 +1653,7 @@ getSectorCount(): number ...@@ -1669,7 +1653,7 @@ getSectorCount(): number
Obtains the number of sectors in this MIFARE Classic tag. Obtains the number of sectors in this MIFARE Classic tag.
**System capability**: SystemCapability.Communication.NFC.Core **System capability**: SystemCapability.Communication.NFC.Tag
**Return value** **Return value**
...@@ -1693,7 +1677,7 @@ getBlockCountInSector(sectorIndex: number): number ...@@ -1693,7 +1677,7 @@ getBlockCountInSector(sectorIndex: number): number
Obtains the number of blocks in a sector. Obtains the number of blocks in a sector.
**System capability**: SystemCapability.Communication.NFC.Core **System capability**: SystemCapability.Communication.NFC.Tag
**Parameters** **Parameters**
...@@ -1729,7 +1713,7 @@ getType(): [tag.MifareClassicType](js-apis-nfcTag.md#mifareclassictype9) ...@@ -1729,7 +1713,7 @@ getType(): [tag.MifareClassicType](js-apis-nfcTag.md#mifareclassictype9)
Obtains the type of this MIFARE Classic tag. Obtains the type of this MIFARE Classic tag.
**System capability**: SystemCapability.Communication.NFC.Core **System capability**: SystemCapability.Communication.NFC.Tag
**Return value** **Return value**
...@@ -1753,7 +1737,7 @@ getTagSize(): number ...@@ -1753,7 +1737,7 @@ getTagSize(): number
Obtains the size of this tag. For details, see [MifareClassicSize](js-apis-nfcTag.md#mifareclassicsize9). Obtains the size of this tag. For details, see [MifareClassicSize](js-apis-nfcTag.md#mifareclassicsize9).
**System capability**: SystemCapability.Communication.NFC.Core **System capability**: SystemCapability.Communication.NFC.Tag
**Return value** **Return value**
...@@ -1777,7 +1761,7 @@ isEmulatedTag(): boolean ...@@ -1777,7 +1761,7 @@ isEmulatedTag(): boolean
Checks whether it is an emulated tag. Checks whether it is an emulated tag.
**System capability**: SystemCapability.Communication.NFC.Core **System capability**: SystemCapability.Communication.NFC.Tag
**Return value** **Return value**
...@@ -1801,7 +1785,7 @@ getBlockIndex(sectorIndex: number): number ...@@ -1801,7 +1785,7 @@ getBlockIndex(sectorIndex: number): number
Obtains the index of the first block in a sector. Obtains the index of the first block in a sector.
**System capability**: SystemCapability.Communication.NFC.Core **System capability**: SystemCapability.Communication.NFC.Tag
**Parameters** **Parameters**
...@@ -1835,9 +1819,9 @@ try { ...@@ -1835,9 +1819,9 @@ try {
getSectorIndex(blockIndex: number): number getSectorIndex(blockIndex: number): number
Obtains the index of a sector that holds the specified block. Obtains the index of the sector that holds the specified block.
**System capability**: SystemCapability.Communication.NFC.Core **System capability**: SystemCapability.Communication.NFC.Tag
**Parameters** **Parameters**
...@@ -1883,7 +1867,7 @@ Reads four pages (4 bytes per page) from this tag. This API uses a promise to re ...@@ -1883,7 +1867,7 @@ Reads four pages (4 bytes per page) from this tag. This API uses a promise to re
**Required permissions**: ohos.permission.NFC_TAG **Required permissions**: ohos.permission.NFC_TAG
**System capability**: SystemCapability.Communication.NFC.Core **System capability**: SystemCapability.Communication.NFC.Tag
**Parameters** **Parameters**
...@@ -1941,7 +1925,7 @@ Reads four pages (4 bytes per page) from this tag. This API uses an asynchronous ...@@ -1941,7 +1925,7 @@ Reads four pages (4 bytes per page) from this tag. This API uses an asynchronous
**Required permissions**: ohos.permission.NFC_TAG **Required permissions**: ohos.permission.NFC_TAG
**System capability**: SystemCapability.Communication.NFC.Core **System capability**: SystemCapability.Communication.NFC.Tag
**Parameters** **Parameters**
...@@ -1995,7 +1979,7 @@ Writes one page (4 bytes) of data to this tag. This API uses a promise to return ...@@ -1995,7 +1979,7 @@ Writes one page (4 bytes) of data to this tag. This API uses a promise to return
**Required permissions**: ohos.permission.NFC_TAG **Required permissions**: ohos.permission.NFC_TAG
**System capability**: SystemCapability.Communication.NFC.Core **System capability**: SystemCapability.Communication.NFC.Tag
**Parameters** **Parameters**
...@@ -2048,7 +2032,7 @@ Writes one page (4 bytes) of data to this tag. This API uses an asynchronous cal ...@@ -2048,7 +2032,7 @@ Writes one page (4 bytes) of data to this tag. This API uses an asynchronous cal
**Required permissions**: ohos.permission.NFC_TAG **Required permissions**: ohos.permission.NFC_TAG
**System capability**: SystemCapability.Communication.NFC.Core **System capability**: SystemCapability.Communication.NFC.Tag
**Parameters** **Parameters**
...@@ -2102,7 +2086,7 @@ getType(): [tag.MifareUltralightType](js-apis-nfcTag.md#mifareultralighttype9) ...@@ -2102,7 +2086,7 @@ getType(): [tag.MifareUltralightType](js-apis-nfcTag.md#mifareultralighttype9)
Obtains the type of this MIFARE Ultralight tag. Obtains the type of this MIFARE Ultralight tag.
**System capability**: SystemCapability.Communication.NFC.Core **System capability**: SystemCapability.Communication.NFC.Tag
**Return value** **Return value**
...@@ -2136,7 +2120,7 @@ Formats this tag as an NDEF tag, and writes an NDEF message to it. This API uses ...@@ -2136,7 +2120,7 @@ Formats this tag as an NDEF tag, and writes an NDEF message to it. This API uses
**Required permissions**: ohos.permission.NFC_TAG **Required permissions**: ohos.permission.NFC_TAG
**System capability**: SystemCapability.Communication.NFC.Core **System capability**: SystemCapability.Communication.NFC.Tag
**Parameters** **Parameters**
...@@ -2190,7 +2174,7 @@ Formats this tag as an NDEF tag, and writes an NDEF message to it. This API uses ...@@ -2190,7 +2174,7 @@ Formats this tag as an NDEF tag, and writes an NDEF message to it. This API uses
**Required permissions**: ohos.permission.NFC_TAG **Required permissions**: ohos.permission.NFC_TAG
**System capability**: SystemCapability.Communication.NFC.Core **System capability**: SystemCapability.Communication.NFC.Tag
**Parameters** **Parameters**
...@@ -2245,7 +2229,7 @@ Formats this tag as an NDEF tag, writes an NDEF message to it, and then sets the ...@@ -2245,7 +2229,7 @@ Formats this tag as an NDEF tag, writes an NDEF message to it, and then sets the
**Required permissions**: ohos.permission.NFC_TAG **Required permissions**: ohos.permission.NFC_TAG
**System capability**: SystemCapability.Communication.NFC.Core **System capability**: SystemCapability.Communication.NFC.Tag
**Parameters** **Parameters**
...@@ -2299,7 +2283,7 @@ Formats this tag as an NDEF tag, writes an NDEF message to the NDEF tag, and the ...@@ -2299,7 +2283,7 @@ Formats this tag as an NDEF tag, writes an NDEF message to the NDEF tag, and the
**Required permissions**: ohos.permission.NFC_TAG **Required permissions**: ohos.permission.NFC_TAG
**System capability**: SystemCapability.Communication.NFC.Core **System capability**: SystemCapability.Communication.NFC.Tag
**Parameters** **Parameters**
......
# @ohos.account.osAccount # @ohos.account.osAccount (OS Account Management)
The **osAccount** module provides basic capabilities for managing OS accounts, including adding, deleting, querying, setting, subscribing to, and enabling an OS account. The **osAccount** module provides basic capabilities for managing OS accounts, including adding, deleting, querying, setting, subscribing to, and enabling an OS account.
...@@ -155,7 +155,7 @@ Checks whether multiple OS accounts are supported. This API uses an asynchronous ...@@ -155,7 +155,7 @@ Checks whether multiple OS accounts are supported. This API uses an asynchronous
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ---------------------------- | ---- | ------------------------------------------------------ | | -------- | ---------------------------- | ---- | ------------------------------------------------------ |
| callback | AsyncCallback&lt;boolean&gt; | Yes | Callback invoked to return the result. The value **true** means multiple OS accounts are supported; the value false means the opposite.| | callback | AsyncCallback&lt;boolean&gt; | Yes | Callback invoked to return the result. The value **true** means multiple OS accounts are supported; the value **false** means the opposite.|
**Error codes** **Error codes**
...@@ -192,7 +192,7 @@ Checks whether multiple OS accounts are supported. This API uses a promise to re ...@@ -192,7 +192,7 @@ Checks whether multiple OS accounts are supported. This API uses a promise to re
| Type | Description | | Type | Description |
| :--------------------- | :--------------------------------------------------------- | | :--------------------- | :--------------------------------------------------------- |
| Promise&lt;boolean&gt; | Promise used to return the result. The value **true** means multiple OS accounts are supported; the value false means the opposite.| | Promise&lt;boolean&gt; | Promise used to return the result. The value **true** means multiple OS accounts are supported; the value **false** means the opposite.|
**Error codes** **Error codes**
...@@ -483,7 +483,7 @@ Checks whether this OS account has been verified. This API uses an asynchronous ...@@ -483,7 +483,7 @@ Checks whether this OS account has been verified. This API uses an asynchronous
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ---------------------------- | ---- | ------------------------------------------------------------- | | -------- | ---------------------------- | ---- | ------------------------------------------------------------- |
| callback | AsyncCallback&lt;boolean&gt; | Yes | Callback invoked to return the result. If true is returned, the current account has been verified. If false is returned, the current account has not been verified.| | callback | AsyncCallback&lt;boolean&gt; | Yes | Callback invoked to return the result. The value **true** means the OS account has been verified; the value **false** means the opposite.|
**Error codes** **Error codes**
...@@ -1690,7 +1690,7 @@ Creates an OS account and associates it with the specified domain account. This ...@@ -1690,7 +1690,7 @@ Creates an OS account and associates it with the specified domain account. This
| Type | Description | | Type | Description |
| ---------------------------------------------- | -------------------------------------- | | ---------------------------------------------- | -------------------------------------- |
| Promise&lt;[OsAccountInfo](#osaccountinfo)&gt; | Promise used to return the OS account created.| | Promise&lt;[OsAccountInfo](#osaccountinfo)&gt; | Promise used to return the information about the created OS account.|
**Error codes** **Error codes**
...@@ -2709,6 +2709,7 @@ Obtains the constraint source information of an OS account. This API uses a prom ...@@ -2709,6 +2709,7 @@ Obtains the constraint source information of an OS account. This API uses a prom
console.info('queryOsAccountConstraintSourceType exception:' + JSON.stringify(e)); console.info('queryOsAccountConstraintSourceType exception:' + JSON.stringify(e));
} }
``` ```
### isMultiOsAccountEnable<sup>(deprecated)</sup> ### isMultiOsAccountEnable<sup>(deprecated)</sup>
isMultiOsAccountEnable(callback: AsyncCallback&lt;boolean&gt;): void isMultiOsAccountEnable(callback: AsyncCallback&lt;boolean&gt;): void
...@@ -2725,7 +2726,7 @@ Checks whether multiple OS accounts are supported. This API uses an asynchronous ...@@ -2725,7 +2726,7 @@ Checks whether multiple OS accounts are supported. This API uses an asynchronous
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ---------------------------- | ---- | ------------------------------------------------------ | | -------- | ---------------------------- | ---- | ------------------------------------------------------ |
| callback | AsyncCallback&lt;boolean&gt; | Yes | Callback invoked to return the result. The value **true** means multiple OS accounts are supported; the value false means the opposite.| | callback | AsyncCallback&lt;boolean&gt; | Yes | Callback invoked to return the result. The value **true** means multiple OS accounts are supported; the value **false** means the opposite.|
**Example** **Example**
...@@ -2756,7 +2757,7 @@ Checks whether multiple OS accounts are supported. This API uses a promise to re ...@@ -2756,7 +2757,7 @@ Checks whether multiple OS accounts are supported. This API uses a promise to re
| Type | Description | | Type | Description |
| :--------------------- | :--------------------------------------------------------- | | :--------------------- | :--------------------------------------------------------- |
| Promise&lt;boolean&gt; | Promise used to return the result. The value **true** means multiple OS accounts are supported; the value false means the opposite.| | Promise&lt;boolean&gt; | Promise used to return the result. The value **true** means multiple OS accounts are supported; the value **false** means the opposite.|
**Example** **Example**
...@@ -3694,7 +3695,7 @@ Obtains the OS account ID based on the SN. This API uses an asynchronous callbac ...@@ -3694,7 +3695,7 @@ Obtains the OS account ID based on the SN. This API uses an asynchronous callbac
getOsAccountLocalIdBySerialNumber(serialNumber: number): Promise&lt;number&gt; getOsAccountLocalIdBySerialNumber(serialNumber: number): Promise&lt;number&gt;
Obtains the OS account ID based on the SN. This API uses a promise to return the result. Obtains the OS account ID based on the serial number. This API uses a promise to return the result.
> **NOTE** > **NOTE**
> >
...@@ -4360,7 +4361,7 @@ Register a credential inputer. ...@@ -4360,7 +4361,7 @@ Register a credential inputer.
let authType = account_osAccount.AuthType.DOMAIN; let authType = account_osAccount.AuthType.DOMAIN;
let password = new Uint8Array([0, 0, 0, 0, 0]); let password = new Uint8Array([0, 0, 0, 0, 0]);
try { try {
InputerMgr.registerInputer(authType, { inputerMgr.registerInputer(authType, {
onGetData: (authSubType, callback) => { onGetData: (authSubType, callback) => {
callback.onSetData(authSubType, password); callback.onSetData(authSubType, password);
} }
......
# @ohos.rpc (RPC) # @ohos.rpc (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. 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** > **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. > - 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. > - This module supports return of error codes since API version 9.
## Modules to Import ## Modules to Import
...@@ -15,7 +14,6 @@ The **rpc** module implements communication between processes, including inter-p ...@@ -15,7 +14,6 @@ The **rpc** module implements communication between processes, including inter-p
import rpc from '@ohos.rpc'; import rpc from '@ohos.rpc';
``` ```
## ErrorCode<sup>9+</sup> ## ErrorCode<sup>9+</sup>
The APIs of this module return exceptions since API version 9. The following table lists the error codes. The APIs of this module return exceptions since API version 9. The following table lists the error codes.
...@@ -42,11 +40,11 @@ The APIs of this module return exceptions since API version 9. The following tab ...@@ -42,11 +40,11 @@ The APIs of this module return exceptions since API version 9. The following tab
## MessageSequence<sup>9+</sup> ## MessageSequence<sup>9+</sup>
Provides APIs for reading and writing data in specific format. During RPC, the sender can use the **write()** method provided by **MessageSequence** to write data in specific format to a **MessageSequence** object. The receiver can use the **read()** method provided by **MessageSequence** to read data in specific format from a **MessageSequence** object. The data formats include basic data types and arrays, IPC objects, interface tokens, and custom sequenceable objects. Provides APIs for reading and writing data in specific format. During RPC or IPC, the sender can use the **write()** method provided by **MessageSequence** to write data in specific format to a **MessageSequence** object. The receiver can use the **read()** method provided by **MessageSequence** to read data in specific format from a **MessageSequence** object. The data formats include basic data types and arrays, IPC objects, interface tokens, and custom sequenceable objects.
### create ### create
create(): MessageSequence static create(): MessageSequence
Creates a **MessageSequence** object. This API is a static method. Creates a **MessageSequence** object. This API is a static method.
...@@ -60,7 +58,7 @@ The APIs of this module return exceptions since API version 9. The following tab ...@@ -60,7 +58,7 @@ The APIs of this module return exceptions since API version 9. The following tab
**Example** **Example**
``` ```ts
let data = rpc.MessageSequence.create(); let data = rpc.MessageSequence.create();
console.log("RpcClient: data is " + data); console.log("RpcClient: data is " + data);
``` ```
...@@ -75,7 +73,7 @@ Reclaims the **MessageSequence** object that is no longer used. ...@@ -75,7 +73,7 @@ Reclaims the **MessageSequence** object that is no longer used.
**Example** **Example**
``` ```ts
let reply = rpc.MessageSequence.create(); let reply = rpc.MessageSequence.create();
reply.reclaim(); reply.reclaim();
``` ```
...@@ -105,7 +103,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode ...@@ -105,7 +103,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example** **Example**
``` ```ts
class TestRemoteObject extends rpc.RemoteObject { class TestRemoteObject extends rpc.RemoteObject {
constructor(descriptor) { constructor(descriptor) {
super(descriptor); super(descriptor);
...@@ -146,7 +144,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode ...@@ -146,7 +144,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example** **Example**
``` ```ts
class TestRemoteObject extends rpc.RemoteObject { class TestRemoteObject extends rpc.RemoteObject {
constructor(descriptor) { constructor(descriptor) {
super(descriptor); super(descriptor);
...@@ -187,7 +185,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode ...@@ -187,7 +185,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example** **Example**
``` ```ts
let data = rpc.MessageSequence.create(); let data = rpc.MessageSequence.create();
try { try {
data.writeInterfaceToken("aaa"); data.writeInterfaceToken("aaa");
...@@ -219,23 +217,22 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode ...@@ -219,23 +217,22 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
| ------- | ----- | | ------- | ----- |
| 1900010 | read data from message sequence failed | | 1900010 | read data from message sequence failed |
**Example** **Example**
``` ```ts
class Stub extends rpc.RemoteObject { class Stub extends rpc.RemoteObject {
onRemoteRequest(code, data, reply, option) { onRemoteRequest(code, data, reply, option) {
try { try {
let interfaceToken = data.readInterfaceToken(); let interfaceToken = data.readInterfaceToken();
console.log("RpcServer: interfaceToken is " + interfaceToken); console.log("RpcServer: interfaceToken is " + interfaceToken);
} catch(error) { } catch(error) {
console.info("RpcServer: read interfaceToken failed, errorCode " + error.code); console.info("RpcServer: read interfaceToken failed, errorCode " + error.code);
console.info("RpcServer: read interfaceToken failed, errorMessage " + error.message); console.info("RpcServer: read interfaceToken failed, errorMessage " + error.message);
} }
return true; return true;
} }
} }
``` ```
### getSize ### getSize
...@@ -253,7 +250,7 @@ Obtains the data size of this **MessageSequence** object. ...@@ -253,7 +250,7 @@ Obtains the data size of this **MessageSequence** object.
**Example** **Example**
``` ```ts
let data = rpc.MessageSequence.create(); let data = rpc.MessageSequence.create();
let size = data.getSize(); let size = data.getSize();
console.log("RpcClient: size is " + size); console.log("RpcClient: size is " + size);
...@@ -275,7 +272,7 @@ Obtains the capacity of this **MessageSequence** object. ...@@ -275,7 +272,7 @@ Obtains the capacity of this **MessageSequence** object.
**Example** **Example**
``` ```ts
let data = rpc.MessageSequence.create(); let data = rpc.MessageSequence.create();
let result = data.getCapacity(); let result = data.getCapacity();
console.log("RpcClient: capacity is " + result); console.log("RpcClient: capacity is " + result);
...@@ -285,7 +282,7 @@ Obtains the capacity of this **MessageSequence** object. ...@@ -285,7 +282,7 @@ Obtains the capacity of this **MessageSequence** object.
setSize(size: number): void setSize(size: number): void
Sets the size of data contained in this **MessageSequence** object. Sets the size of the data contained in this **MessageSequence** object.
**System capability**: SystemCapability.Communication.IPC.Core **System capability**: SystemCapability.Communication.IPC.Core
...@@ -293,11 +290,11 @@ Sets the size of data contained in this **MessageSequence** object. ...@@ -293,11 +290,11 @@ Sets the size of data contained in this **MessageSequence** object.
| Name| Type | Mandatory| Description| | Name| Type | Mandatory| Description|
| ------ | ------ | ---- | ------ | | ------ | ------ | ---- | ------ |
| size | number | Yes| Data size to set, in bytes.| | size | number | Yes | Data size to set, in bytes.|
**Example** **Example**
``` ```ts
let data = rpc.MessageSequence.create(); let data = rpc.MessageSequence.create();
try { try {
data.setSize(16); data.setSize(16);
...@@ -332,7 +329,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode ...@@ -332,7 +329,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example** **Example**
``` ```ts
let data = rpc.MessageSequence.create(); let data = rpc.MessageSequence.create();
try { try {
data.setCapacity(100); data.setCapacity(100);
...@@ -347,7 +344,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode ...@@ -347,7 +344,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
getWritableBytes(): number getWritableBytes(): number
Obtains the writable capacity of this **MessageSequence** object. Obtains the writable capacity (in bytes) of this **MessageSequence** object.
**System capability**: SystemCapability.Communication.IPC.Core **System capability**: SystemCapability.Communication.IPC.Core
...@@ -355,19 +352,19 @@ Obtains the writable capacity of this **MessageSequence** object. ...@@ -355,19 +352,19 @@ Obtains the writable capacity of this **MessageSequence** object.
| Type| Description| | Type| Description|
| ------ | ------ | | ------ | ------ |
| number | **MessageSequence** writable capacity obtained, in bytes.| | number | Writable capacity of the **MessageSequence** instance, in bytes.|
**Example** **Example**
``` ```ts
class Stub extends rpc.RemoteObject { class Stub extends rpc.RemoteObject {
onRemoteRequest(code, data, reply, option) { onRemoteRequest(code, data, reply, option) {
let getWritableBytes = data.getWritableBytes(); let getWritableBytes = data.getWritableBytes();
console.log("RpcServer: getWritableBytes is " + getWritableBytes); console.log("RpcServer: getWritableBytes is " + getWritableBytes);
return true; return true;
} }
} }
``` ```
### getReadableBytes ### getReadableBytes
...@@ -381,18 +378,18 @@ Obtains the readable capacity of this **MessageSequence** object. ...@@ -381,18 +378,18 @@ Obtains the readable capacity of this **MessageSequence** object.
| Type| Description| | Type| Description|
| ------ | ------- | | ------ | ------- |
| number | **MessageSequence** readable capacity obtained, in bytes.| | number | Readable capacity of the **MessageSequence** instance, in bytes.|
**Example** **Example**
``` ```ts
class Stub extends rpc.RemoteObject { class Stub extends rpc.RemoteObject {
onRemoteRequest(code, data, reply, option) { onRemoteRequest(code, data, reply, option) {
let result = data.getReadableBytes(); let result = data.getReadableBytes();
console.log("RpcServer: getReadableBytes is " + result); console.log("RpcServer: getReadableBytes is " + result);
return true; return true;
} }
} }
``` ```
### getReadPosition ### getReadPosition
...@@ -411,7 +408,7 @@ Obtains the read position of this **MessageSequence** object. ...@@ -411,7 +408,7 @@ Obtains the read position of this **MessageSequence** object.
**Example** **Example**
``` ```ts
let data = rpc.MessageSequence.create(); let data = rpc.MessageSequence.create();
let readPos = data.getReadPosition(); let readPos = data.getReadPosition();
console.log("RpcClient: readPos is " + readPos); console.log("RpcClient: readPos is " + readPos);
...@@ -433,7 +430,7 @@ Obtains the write position of this **MessageSequence** object. ...@@ -433,7 +430,7 @@ Obtains the write position of this **MessageSequence** object.
**Example** **Example**
``` ```ts
let data = rpc.MessageSequence.create(); let data = rpc.MessageSequence.create();
data.writeInt(10); data.writeInt(10);
let bwPos = data.getWritePosition(); let bwPos = data.getWritePosition();
...@@ -456,7 +453,7 @@ Moves the read pointer to the specified position. ...@@ -456,7 +453,7 @@ Moves the read pointer to the specified position.
**Example** **Example**
``` ```ts
let data = rpc.MessageSequence.create(); let data = rpc.MessageSequence.create();
data.writeInt(12); data.writeInt(12);
data.writeString("sequence"); data.writeString("sequence");
...@@ -488,7 +485,7 @@ Moves the write pointer to the specified position. ...@@ -488,7 +485,7 @@ Moves the write pointer to the specified position.
**Example** **Example**
``` ```ts
let data = rpc.MessageSequence.create(); let data = rpc.MessageSequence.create();
data.writeInt(4); data.writeInt(4);
try { try {
...@@ -526,7 +523,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode ...@@ -526,7 +523,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example** **Example**
``` ```ts
let data = rpc.MessageSequence.create(); let data = rpc.MessageSequence.create();
try { try {
data.writeByte(2); data.writeByte(2);
...@@ -560,7 +557,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode ...@@ -560,7 +557,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example** **Example**
``` ```ts
let data = rpc.MessageSequence.create(); let data = rpc.MessageSequence.create();
try { try {
data.writeByte(2); data.writeByte(2);
...@@ -601,7 +598,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode ...@@ -601,7 +598,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example** **Example**
``` ```ts
let data = rpc.MessageSequence.create(); let data = rpc.MessageSequence.create();
try { try {
data.writeShort(8); data.writeShort(8);
...@@ -635,7 +632,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode ...@@ -635,7 +632,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example** **Example**
``` ```ts
let data = rpc.MessageSequence.create(); let data = rpc.MessageSequence.create();
try { try {
data.writeShort(8); data.writeShort(8);
...@@ -676,7 +673,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode ...@@ -676,7 +673,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example** **Example**
``` ```ts
let data = rpc.MessageSequence.create(); let data = rpc.MessageSequence.create();
try { try {
data.writeInt(10); data.writeInt(10);
...@@ -710,7 +707,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode ...@@ -710,7 +707,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example** **Example**
``` ```ts
let data = rpc.MessageSequence.create(); let data = rpc.MessageSequence.create();
try { try {
data.writeInt(10); data.writeInt(10);
...@@ -751,7 +748,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode ...@@ -751,7 +748,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example** **Example**
``` ```ts
let data = rpc.MessageSequence.create(); let data = rpc.MessageSequence.create();
try { try {
data.writeLong(10000); data.writeLong(10000);
...@@ -785,7 +782,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode ...@@ -785,7 +782,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example** **Example**
``` ```ts
let data = rpc.MessageSequence.create(); let data = rpc.MessageSequence.create();
try { try {
data.writeLong(10000); data.writeLong(10000);
...@@ -826,7 +823,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode ...@@ -826,7 +823,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example** **Example**
``` ```ts
let data = rpc.MessageSequence.create(); let data = rpc.MessageSequence.create();
try { try {
data.writeFloat(1.2); data.writeFloat(1.2);
...@@ -860,7 +857,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode ...@@ -860,7 +857,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example** **Example**
``` ```ts
let data = rpc.MessageSequence.create(); let data = rpc.MessageSequence.create();
try { try {
data.writeFloat(1.2); data.writeFloat(1.2);
...@@ -901,7 +898,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode ...@@ -901,7 +898,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example** **Example**
``` ```ts
let data = rpc.MessageSequence.create(); let data = rpc.MessageSequence.create();
try { try {
data.writeDouble(10.2); data.writeDouble(10.2);
...@@ -935,7 +932,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode ...@@ -935,7 +932,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example** **Example**
``` ```ts
let data = rpc.MessageSequence.create(); let data = rpc.MessageSequence.create();
try { try {
data.writeDouble(10.2); data.writeDouble(10.2);
...@@ -976,7 +973,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode ...@@ -976,7 +973,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example** **Example**
``` ```ts
let data = rpc.MessageSequence.create(); let data = rpc.MessageSequence.create();
try { try {
data.writeBoolean(false); data.writeBoolean(false);
...@@ -1010,7 +1007,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode ...@@ -1010,7 +1007,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example** **Example**
``` ```ts
let data = rpc.MessageSequence.create(); let data = rpc.MessageSequence.create();
try { try {
data.writeBoolean(false); data.writeBoolean(false);
...@@ -1051,7 +1048,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode ...@@ -1051,7 +1048,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example** **Example**
``` ```ts
let data = rpc.MessageSequence.create(); let data = rpc.MessageSequence.create();
try { try {
data.writeChar(97); data.writeChar(97);
...@@ -1085,7 +1082,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode ...@@ -1085,7 +1082,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example** **Example**
``` ```ts
let data = rpc.MessageSequence.create(); let data = rpc.MessageSequence.create();
try { try {
data.writeChar(97); data.writeChar(97);
...@@ -1126,7 +1123,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode ...@@ -1126,7 +1123,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example** **Example**
``` ```ts
let data = rpc.MessageSequence.create(); let data = rpc.MessageSequence.create();
try { try {
data.writeString('abc'); data.writeString('abc');
...@@ -1160,7 +1157,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode ...@@ -1160,7 +1157,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example** **Example**
``` ```ts
let data = rpc.MessageSequence.create(); let data = rpc.MessageSequence.create();
try { try {
data.writeString('abc'); data.writeString('abc');
...@@ -1201,7 +1198,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode ...@@ -1201,7 +1198,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example** **Example**
``` ```ts
class MySequenceable { class MySequenceable {
num: number; num: number;
str: string; str: string;
...@@ -1255,7 +1252,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode ...@@ -1255,7 +1252,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example** **Example**
``` ```ts
class MySequenceable { class MySequenceable {
num: number; num: number;
str: string; str: string;
...@@ -1310,7 +1307,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode ...@@ -1310,7 +1307,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example** **Example**
``` ```ts
let data = rpc.MessageSequence.create(); let data = rpc.MessageSequence.create();
let ByteArrayVar = [1, 2, 3, 4, 5]; let ByteArrayVar = [1, 2, 3, 4, 5];
try { try {
...@@ -1345,7 +1342,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode ...@@ -1345,7 +1342,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example** **Example**
``` ```ts
let data = rpc.MessageSequence.create(); let data = rpc.MessageSequence.create();
let ByteArrayVar = [1, 2, 3, 4, 5]; let ByteArrayVar = [1, 2, 3, 4, 5];
try { try {
...@@ -1387,7 +1384,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode ...@@ -1387,7 +1384,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example** **Example**
``` ```ts
let data = rpc.MessageSequence.create(); let data = rpc.MessageSequence.create();
let byteArrayVar = [1, 2, 3, 4, 5]; let byteArrayVar = [1, 2, 3, 4, 5];
try { try {
...@@ -1429,7 +1426,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode ...@@ -1429,7 +1426,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example** **Example**
``` ```ts
let data = rpc.MessageSequence.create(); let data = rpc.MessageSequence.create();
try { try {
data.writeShortArray([11, 12, 13]); data.writeShortArray([11, 12, 13]);
...@@ -1463,7 +1460,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode ...@@ -1463,7 +1460,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example** **Example**
``` ```ts
let data = rpc.MessageSequence.create(); let data = rpc.MessageSequence.create();
try { try {
data.writeShortArray([11, 12, 13]); data.writeShortArray([11, 12, 13]);
...@@ -1504,7 +1501,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode ...@@ -1504,7 +1501,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example** **Example**
``` ```ts
let data = rpc.MessageSequence.create(); let data = rpc.MessageSequence.create();
try { try {
data.writeShortArray([11, 12, 13]); data.writeShortArray([11, 12, 13]);
...@@ -1545,7 +1542,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode ...@@ -1545,7 +1542,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example** **Example**
``` ```ts
let data = rpc.MessageSequence.create(); let data = rpc.MessageSequence.create();
try { try {
data.writeIntArray([100, 111, 112]); data.writeIntArray([100, 111, 112]);
...@@ -1579,7 +1576,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode ...@@ -1579,7 +1576,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example** **Example**
``` ```ts
let data = rpc.MessageSequence.create(); let data = rpc.MessageSequence.create();
try { try {
data.writeIntArray([100, 111, 112]); data.writeIntArray([100, 111, 112]);
...@@ -1620,7 +1617,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode ...@@ -1620,7 +1617,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example** **Example**
``` ```ts
let data = rpc.MessageSequence.create(); let data = rpc.MessageSequence.create();
try { try {
data.writeIntArray([100, 111, 112]); data.writeIntArray([100, 111, 112]);
...@@ -1661,7 +1658,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode ...@@ -1661,7 +1658,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example** **Example**
``` ```ts
let data = rpc.MessageSequence.create(); let data = rpc.MessageSequence.create();
try { try {
data.writeLongArray([1111, 1112, 1113]); data.writeLongArray([1111, 1112, 1113]);
...@@ -1695,7 +1692,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode ...@@ -1695,7 +1692,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example** **Example**
``` ```ts
let data = rpc.MessageSequence.create(); let data = rpc.MessageSequence.create();
try { try {
data.writeLongArray([1111, 1112, 1113]); data.writeLongArray([1111, 1112, 1113]);
...@@ -1736,7 +1733,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode ...@@ -1736,7 +1733,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example** **Example**
``` ```ts
let data = rpc.MessageSequence.create(); let data = rpc.MessageSequence.create();
try { try {
data.writeLongArray([1111, 1112, 1113]); data.writeLongArray([1111, 1112, 1113]);
...@@ -1777,7 +1774,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode ...@@ -1777,7 +1774,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example** **Example**
``` ```ts
let data = rpc.MessageSequence.create(); let data = rpc.MessageSequence.create();
try { try {
data.writeFloatArray([1.2, 1.3, 1.4]); data.writeFloatArray([1.2, 1.3, 1.4]);
...@@ -1811,7 +1808,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode ...@@ -1811,7 +1808,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example** **Example**
``` ```ts
let data = rpc.MessageSequence.create(); let data = rpc.MessageSequence.create();
try { try {
data.writeFloatArray([1.2, 1.3, 1.4]); data.writeFloatArray([1.2, 1.3, 1.4]);
...@@ -1852,7 +1849,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode ...@@ -1852,7 +1849,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example** **Example**
``` ```ts
let data = rpc.MessageSequence.create(); let data = rpc.MessageSequence.create();
try { try {
data.writeFloatArray([1.2, 1.3, 1.4]); data.writeFloatArray([1.2, 1.3, 1.4]);
...@@ -1893,7 +1890,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode ...@@ -1893,7 +1890,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example** **Example**
``` ```ts
let data = rpc.MessageSequence.create(); let data = rpc.MessageSequence.create();
try { try {
data.writeDoubleArray([11.1, 12.2, 13.3]); data.writeDoubleArray([11.1, 12.2, 13.3]);
...@@ -1927,7 +1924,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode ...@@ -1927,7 +1924,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example** **Example**
``` ```ts
let data = rpc.MessageSequence.create(); let data = rpc.MessageSequence.create();
try { try {
data.writeDoubleArray([11.1, 12.2, 13.3]); data.writeDoubleArray([11.1, 12.2, 13.3]);
...@@ -1968,7 +1965,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode ...@@ -1968,7 +1965,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example** **Example**
``` ```ts
let data = rpc.MessageSequence.create(); let data = rpc.MessageSequence.create();
try { try {
data.writeDoubleArray([11.1, 12.2, 13.3]); data.writeDoubleArray([11.1, 12.2, 13.3]);
...@@ -2009,7 +2006,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode ...@@ -2009,7 +2006,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example** **Example**
``` ```ts
let data = rpc.MessageSequence.create(); let data = rpc.MessageSequence.create();
try { try {
data.writeBooleanArray([false, true, false]); data.writeBooleanArray([false, true, false]);
...@@ -2043,7 +2040,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode ...@@ -2043,7 +2040,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example** **Example**
``` ```ts
let data = rpc.MessageSequence.create(); let data = rpc.MessageSequence.create();
try { try {
data.writeBooleanArray([false, true, false]); data.writeBooleanArray([false, true, false]);
...@@ -2084,7 +2081,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode ...@@ -2084,7 +2081,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example** **Example**
``` ```ts
let data = rpc.MessageSequence.create(); let data = rpc.MessageSequence.create();
try { try {
data.writeBooleanArray([false, true, false]); data.writeBooleanArray([false, true, false]);
...@@ -2125,7 +2122,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode ...@@ -2125,7 +2122,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example** **Example**
``` ```ts
let data = rpc.MessageSequence.create(); let data = rpc.MessageSequence.create();
try { try {
data.writeCharArray([97, 98, 88]); data.writeCharArray([97, 98, 88]);
...@@ -2159,7 +2156,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode ...@@ -2159,7 +2156,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example** **Example**
``` ```ts
let data = rpc.MessageSequence.create(); let data = rpc.MessageSequence.create();
try { try {
data.writeCharArray([97, 98, 88]); data.writeCharArray([97, 98, 88]);
...@@ -2200,7 +2197,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode ...@@ -2200,7 +2197,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example** **Example**
``` ```ts
let data = rpc.MessageSequence.create(); let data = rpc.MessageSequence.create();
try { try {
data.writeCharArray([97, 98, 88]); data.writeCharArray([97, 98, 88]);
...@@ -2242,7 +2239,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode ...@@ -2242,7 +2239,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example** **Example**
``` ```ts
let data = rpc.MessageSequence.create(); let data = rpc.MessageSequence.create();
try { try {
data.writeStringArray(["abc", "def"]); data.writeStringArray(["abc", "def"]);
...@@ -2276,7 +2273,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode ...@@ -2276,7 +2273,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example** **Example**
``` ```ts
let data = rpc.MessageSequence.create(); let data = rpc.MessageSequence.create();
try { try {
data.writeStringArray(["abc", "def"]); data.writeStringArray(["abc", "def"]);
...@@ -2317,7 +2314,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode ...@@ -2317,7 +2314,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example** **Example**
``` ```ts
let data = rpc.MessageSequence.create(); let data = rpc.MessageSequence.create();
try { try {
data.writeStringArray(["abc", "def"]); data.writeStringArray(["abc", "def"]);
...@@ -2352,7 +2349,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode ...@@ -2352,7 +2349,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example** **Example**
``` ```ts
class TestRemoteObject extends rpc.RemoteObject { class TestRemoteObject extends rpc.RemoteObject {
constructor(descriptor) { constructor(descriptor) {
super(descriptor); super(descriptor);
...@@ -2394,7 +2391,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode ...@@ -2394,7 +2391,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example** **Example**
``` ```ts
import FA from "@ohos.ability.featureAbility"; import FA from "@ohos.ability.featureAbility";
let proxy; let proxy;
let connect = { let connect = {
...@@ -2411,7 +2408,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode ...@@ -2411,7 +2408,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
}; };
let want = { let want = {
"bundleName": "com.ohos.server", "bundleName": "com.ohos.server",
"abilityName": "com.ohos.server.MainAbility", "abilityName": "com.ohos.server.EntryAbility",
}; };
FA.connectAbility(want, connect); FA.connectAbility(want, connect);
let option = new rpc.MessageOption(); let option = new rpc.MessageOption();
...@@ -2467,7 +2464,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode ...@@ -2467,7 +2464,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example** **Example**
``` ```ts
class MyParcelable { class MyParcelable {
num: number; num: number;
str: string; str: string;
...@@ -2524,7 +2521,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode ...@@ -2524,7 +2521,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example** **Example**
``` ```ts
class MyParcelable { class MyParcelable {
num: number; num: number;
str: string; str: string;
...@@ -2584,7 +2581,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode ...@@ -2584,7 +2581,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example** **Example**
``` ```ts
class TestRemoteObject extends rpc.RemoteObject { class TestRemoteObject extends rpc.RemoteObject {
constructor(descriptor) { constructor(descriptor) {
super(descriptor); super(descriptor);
...@@ -2631,7 +2628,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode ...@@ -2631,7 +2628,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example** **Example**
``` ```ts
class MyDeathRecipient { class MyDeathRecipient {
onRemoteDied() { onRemoteDied() {
console.log("server died"); console.log("server died");
...@@ -2684,7 +2681,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode ...@@ -2684,7 +2681,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example** **Example**
``` ```ts
class TestRemoteObject extends rpc.RemoteObject { class TestRemoteObject extends rpc.RemoteObject {
constructor(descriptor) { constructor(descriptor) {
super(descriptor); super(descriptor);
...@@ -2712,7 +2709,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode ...@@ -2712,7 +2709,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
static closeFileDescriptor(fd: number): void static closeFileDescriptor(fd: number): void
Closes a file descriptor. Closes a file descriptor. This API is a static method.
**System capability**: SystemCapability.Communication.IPC.Core **System capability**: SystemCapability.Communication.IPC.Core
...@@ -2724,7 +2721,7 @@ Closes a file descriptor. ...@@ -2724,7 +2721,7 @@ Closes a file descriptor.
**Example** **Example**
``` ```ts
import fileio from '@ohos.fileio'; import fileio from '@ohos.fileio';
let filePath = "path/to/file"; let filePath = "path/to/file";
let fd = fileio.openSync(filePath, 0o2| 0o100, 0o666); let fd = fileio.openSync(filePath, 0o2| 0o100, 0o666);
...@@ -2740,7 +2737,7 @@ Closes a file descriptor. ...@@ -2740,7 +2737,7 @@ Closes a file descriptor.
static dupFileDescriptor(fd: number) :number static dupFileDescriptor(fd: number) :number
Duplicates a file descriptor. Duplicates a file descriptor. This API is a static method.
**System capability**: SystemCapability.Communication.IPC.Core **System capability**: SystemCapability.Communication.IPC.Core
...@@ -2766,7 +2763,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode ...@@ -2766,7 +2763,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example** **Example**
``` ```ts
import fileio from '@ohos.fileio'; import fileio from '@ohos.fileio';
let filePath = "path/to/file"; let filePath = "path/to/file";
let fd = fileio.openSync(filePath, 0o2| 0o100, 0o666); let fd = fileio.openSync(filePath, 0o2| 0o100, 0o666);
...@@ -2795,7 +2792,7 @@ Checks whether this **MessageSequence** object contains file descriptors. ...@@ -2795,7 +2792,7 @@ Checks whether this **MessageSequence** object contains file descriptors.
**Example** **Example**
``` ```ts
import fileio from '@ohos.fileio'; import fileio from '@ohos.fileio';
let sequence = new rpc.MessageSequence(); let sequence = new rpc.MessageSequence();
let filePath = "path/to/file"; let filePath = "path/to/file";
...@@ -2840,7 +2837,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode ...@@ -2840,7 +2837,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example** **Example**
``` ```ts
import fileio from '@ohos.fileio'; import fileio from '@ohos.fileio';
let sequence = new rpc.MessageSequence(); let sequence = new rpc.MessageSequence();
let filePath = "path/to/file"; let filePath = "path/to/file";
...@@ -2853,7 +2850,6 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode ...@@ -2853,7 +2850,6 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
} }
``` ```
### readFileDescriptor ### readFileDescriptor
readFileDescriptor(): number readFileDescriptor(): number
...@@ -2878,7 +2874,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode ...@@ -2878,7 +2874,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example** **Example**
``` ```ts
import fileio from '@ohos.fileio'; import fileio from '@ohos.fileio';
let sequence = new rpc.MessageSequence(); let sequence = new rpc.MessageSequence();
let filePath = "path/to/file"; let filePath = "path/to/file";
...@@ -2897,7 +2893,6 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode ...@@ -2897,7 +2893,6 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
} }
``` ```
### writeAshmem ### writeAshmem
writeAshmem(ashmem: Ashmem): void writeAshmem(ashmem: Ashmem): void
...@@ -2922,7 +2917,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode ...@@ -2922,7 +2917,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example** **Example**
``` ```ts
let sequence = new rpc.MessageSequence(); let sequence = new rpc.MessageSequence();
let ashmem; let ashmem;
try { try {
...@@ -2964,7 +2959,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode ...@@ -2964,7 +2959,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example** **Example**
``` ```ts
let sequence = new rpc.MessageSequence(); let sequence = new rpc.MessageSequence();
let ashmem; let ashmem;
try { try {
...@@ -2988,7 +2983,6 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode ...@@ -2988,7 +2983,6 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
} }
``` ```
### getRawDataCapacity ### getRawDataCapacity
getRawDataCapacity(): number getRawDataCapacity(): number
...@@ -3005,13 +2999,12 @@ Obtains the maximum amount of raw data that can be held by this **MessageSequenc ...@@ -3005,13 +2999,12 @@ Obtains the maximum amount of raw data that can be held by this **MessageSequenc
**Example** **Example**
``` ```ts
let sequence = new rpc.MessageSequence(); let sequence = new rpc.MessageSequence();
let result = sequence.getRawDataCapacity(); let result = sequence.getRawDataCapacity();
console.log("RpcTest: sequence get RawDataCapacity result is : " + result); console.log("RpcTest: sequence get RawDataCapacity result is : " + result);
``` ```
### writeRawData ### writeRawData
writeRawData(rawData: number[], size: number): void writeRawData(rawData: number[], size: number): void
...@@ -3037,7 +3030,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode ...@@ -3037,7 +3030,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example** **Example**
``` ```ts
let sequence = new rpc.MessageSequence(); let sequence = new rpc.MessageSequence();
let arr = [1, 2, 3, 4, 5]; let arr = [1, 2, 3, 4, 5];
try { try {
...@@ -3048,7 +3041,6 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode ...@@ -3048,7 +3041,6 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
} }
``` ```
### readRawData ### readRawData
readRawData(size: number): number[] readRawData(size: number): number[]
...@@ -3079,7 +3071,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode ...@@ -3079,7 +3071,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example** **Example**
``` ```ts
let sequence = new rpc.MessageSequence(); let sequence = new rpc.MessageSequence();
let arr = [1, 2, 3, 4, 5]; let arr = [1, 2, 3, 4, 5];
try { try {
...@@ -3105,7 +3097,7 @@ Provides APIs for reading and writing data in specific format. During RPC, the s ...@@ -3105,7 +3097,7 @@ Provides APIs for reading and writing data in specific format. During RPC, the s
### create ### create
create(): MessageParcel static create(): MessageParcel
Creates a **MessageParcel** object. This method is a static method. Creates a **MessageParcel** object. This method is a static method.
...@@ -3119,7 +3111,7 @@ Creates a **MessageParcel** object. This method is a static method. ...@@ -3119,7 +3111,7 @@ Creates a **MessageParcel** object. This method is a static method.
**Example** **Example**
``` ```ts
let data = rpc.MessageParcel.create(); let data = rpc.MessageParcel.create();
console.log("RpcClient: data is " + data); console.log("RpcClient: data is " + data);
``` ```
...@@ -3134,7 +3126,7 @@ Reclaims the **MessageParcel** object that is no longer used. ...@@ -3134,7 +3126,7 @@ Reclaims the **MessageParcel** object that is no longer used.
**Example** **Example**
``` ```ts
let reply = rpc.MessageParcel.create(); let reply = rpc.MessageParcel.create();
reply.reclaim(); reply.reclaim();
``` ```
...@@ -3161,7 +3153,7 @@ Serializes a remote object and writes it to this **MessageParcel** object. ...@@ -3161,7 +3153,7 @@ Serializes a remote object and writes it to this **MessageParcel** object.
**Example** **Example**
``` ```ts
class MyDeathRecipient { class MyDeathRecipient {
onRemoteDied() { onRemoteDied() {
console.log("server died"); console.log("server died");
...@@ -3202,7 +3194,7 @@ Reads the remote object from this **MessageParcel** object. You can use this met ...@@ -3202,7 +3194,7 @@ Reads the remote object from this **MessageParcel** object. You can use this met
**Example** **Example**
``` ```ts
class MyDeathRecipient { class MyDeathRecipient {
onRemoteDied() { onRemoteDied() {
console.log("server died"); console.log("server died");
...@@ -3250,7 +3242,7 @@ Writes an interface token to this **MessageParcel** object. The remote object ca ...@@ -3250,7 +3242,7 @@ Writes an interface token to this **MessageParcel** object. The remote object ca
**Example** **Example**
``` ```ts
let data = rpc.MessageParcel.create(); let data = rpc.MessageParcel.create();
let result = data.writeInterfaceToken("aaa"); let result = data.writeInterfaceToken("aaa");
console.log("RpcServer: writeInterfaceToken is " + result); console.log("RpcServer: writeInterfaceToken is " + result);
...@@ -3273,7 +3265,7 @@ Reads the interface token from this **MessageParcel** object. The interface toke ...@@ -3273,7 +3265,7 @@ Reads the interface token from this **MessageParcel** object. The interface toke
**Example** **Example**
``` ```ts
class Stub extends rpc.RemoteObject { class Stub extends rpc.RemoteObject {
onRemoteMessageRequest(code, data, reply, option) { onRemoteMessageRequest(code, data, reply, option) {
let interfaceToken = data.readInterfaceToken(); let interfaceToken = data.readInterfaceToken();
...@@ -3283,7 +3275,6 @@ Reads the interface token from this **MessageParcel** object. The interface toke ...@@ -3283,7 +3275,6 @@ Reads the interface token from this **MessageParcel** object. The interface toke
} }
``` ```
### getSize ### getSize
getSize(): number getSize(): number
...@@ -3300,13 +3291,12 @@ Obtains the data size of this **MessageParcel** object. ...@@ -3300,13 +3291,12 @@ Obtains the data size of this **MessageParcel** object.
**Example** **Example**
``` ```ts
let data = rpc.MessageParcel.create(); let data = rpc.MessageParcel.create();
let size = data.getSize(); let size = data.getSize();
console.log("RpcClient: size is " + size); console.log("RpcClient: size is " + size);
``` ```
### getCapacity ### getCapacity
getCapacity(): number getCapacity(): number
...@@ -3323,13 +3313,12 @@ Obtains the capacity of this **MessageParcel** object. ...@@ -3323,13 +3313,12 @@ Obtains the capacity of this **MessageParcel** object.
**Example** **Example**
``` ```ts
let data = rpc.MessageParcel.create(); let data = rpc.MessageParcel.create();
let result = data.getCapacity(); let result = data.getCapacity();
console.log("RpcClient: capacity is " + result); console.log("RpcClient: capacity is " + result);
``` ```
### setSize ### setSize
setSize(size: number): boolean setSize(size: number): boolean
...@@ -3352,13 +3341,12 @@ Sets the size of data contained in this **MessageParcel** object. ...@@ -3352,13 +3341,12 @@ Sets the size of data contained in this **MessageParcel** object.
**Example** **Example**
``` ```ts
let data = rpc.MessageParcel.create(); let data = rpc.MessageParcel.create();
let setSize = data.setSize(16); let setSize = data.setSize(16);
console.log("RpcClient: setSize is " + setSize); console.log("RpcClient: setSize is " + setSize);
``` ```
### setCapacity ### setCapacity
setCapacity(size: number): boolean setCapacity(size: number): boolean
...@@ -3381,13 +3369,12 @@ Sets the storage capacity of this **MessageParcel** object. ...@@ -3381,13 +3369,12 @@ Sets the storage capacity of this **MessageParcel** object.
**Example** **Example**
``` ```ts
let data = rpc.MessageParcel.create(); let data = rpc.MessageParcel.create();
let result = data.setCapacity(100); let result = data.setCapacity(100);
console.log("RpcClient: setCapacity is " + result); console.log("RpcClient: setCapacity is " + result);
``` ```
### getWritableBytes ### getWritableBytes
getWritableBytes(): number getWritableBytes(): number
...@@ -3404,7 +3391,7 @@ Obtains the writable capacity of this **MessageParcel** object. ...@@ -3404,7 +3391,7 @@ Obtains the writable capacity of this **MessageParcel** object.
**Example** **Example**
``` ```ts
class Stub extends rpc.RemoteObject { class Stub extends rpc.RemoteObject {
onRemoteMessageRequest(code, data, reply, option) { onRemoteMessageRequest(code, data, reply, option) {
let getWritableBytes = data.getWritableBytes(); let getWritableBytes = data.getWritableBytes();
...@@ -3414,7 +3401,6 @@ Obtains the writable capacity of this **MessageParcel** object. ...@@ -3414,7 +3401,6 @@ Obtains the writable capacity of this **MessageParcel** object.
} }
``` ```
### getReadableBytes ### getReadableBytes
getReadableBytes(): number getReadableBytes(): number
...@@ -3431,7 +3417,7 @@ Obtains the readable capacity of this **MessageParcel** object. ...@@ -3431,7 +3417,7 @@ Obtains the readable capacity of this **MessageParcel** object.
**Example** **Example**
``` ```ts
class Stub extends rpc.RemoteObject { class Stub extends rpc.RemoteObject {
onRemoteRequest(code, data, reply, option) { onRemoteRequest(code, data, reply, option) {
let result = data.getReadableBytes(); let result = data.getReadableBytes();
...@@ -3441,7 +3427,6 @@ Obtains the readable capacity of this **MessageParcel** object. ...@@ -3441,7 +3427,6 @@ Obtains the readable capacity of this **MessageParcel** object.
} }
``` ```
### getReadPosition ### getReadPosition
getReadPosition(): number getReadPosition(): number
...@@ -3458,13 +3443,12 @@ Obtains the read position of this **MessageParcel** object. ...@@ -3458,13 +3443,12 @@ Obtains the read position of this **MessageParcel** object.
**Example** **Example**
``` ```ts
let data = rpc.MessageParcel.create(); let data = rpc.MessageParcel.create();
let readPos = data.getReadPosition(); let readPos = data.getReadPosition();
console.log("RpcClient: readPos is " + readPos); console.log("RpcClient: readPos is " + readPos);
``` ```
### getWritePosition ### getWritePosition
getWritePosition(): number getWritePosition(): number
...@@ -3481,14 +3465,13 @@ Obtains the write position of this **MessageParcel** object. ...@@ -3481,14 +3465,13 @@ Obtains the write position of this **MessageParcel** object.
**Example** **Example**
``` ```ts
let data = rpc.MessageParcel.create(); let data = rpc.MessageParcel.create();
data.writeInt(10); data.writeInt(10);
let bwPos = data.getWritePosition(); let bwPos = data.getWritePosition();
console.log("RpcClient: bwPos is " + bwPos); console.log("RpcClient: bwPos is " + bwPos);
``` ```
### rewindRead ### rewindRead
rewindRead(pos: number): boolean rewindRead(pos: number): boolean
...@@ -3511,7 +3494,7 @@ Moves the read pointer to the specified position. ...@@ -3511,7 +3494,7 @@ Moves the read pointer to the specified position.
**Example** **Example**
``` ```ts
let data = rpc.MessageParcel.create(); let data = rpc.MessageParcel.create();
data.writeInt(12); data.writeInt(12);
data.writeString("parcel"); data.writeString("parcel");
...@@ -3522,7 +3505,6 @@ Moves the read pointer to the specified position. ...@@ -3522,7 +3505,6 @@ Moves the read pointer to the specified position.
console.log("RpcClient: rewindRead is " + number2); console.log("RpcClient: rewindRead is " + number2);
``` ```
### rewindWrite ### rewindWrite
rewindWrite(pos: number): boolean rewindWrite(pos: number): boolean
...@@ -3545,7 +3527,7 @@ Moves the write pointer to the specified position. ...@@ -3545,7 +3527,7 @@ Moves the write pointer to the specified position.
**Example** **Example**
``` ```ts
let data = rpc.MessageParcel.create(); let data = rpc.MessageParcel.create();
data.writeInt(4); data.writeInt(4);
data.rewindWrite(0); data.rewindWrite(0);
...@@ -3554,7 +3536,6 @@ Moves the write pointer to the specified position. ...@@ -3554,7 +3536,6 @@ Moves the write pointer to the specified position.
console.log("RpcClient: rewindWrite is: " + number); console.log("RpcClient: rewindWrite is: " + number);
``` ```
### writeByte ### writeByte
writeByte(val: number): boolean writeByte(val: number): boolean
...@@ -3577,13 +3558,12 @@ Writes a Byte value to this **MessageParcel** object. ...@@ -3577,13 +3558,12 @@ Writes a Byte value to this **MessageParcel** object.
**Example** **Example**
``` ```ts
let data = rpc.MessageParcel.create(); let data = rpc.MessageParcel.create();
let result = data.writeByte(2); let result = data.writeByte(2);
console.log("RpcClient: writeByte is: " + result); console.log("RpcClient: writeByte is: " + result);
``` ```
### readByte ### readByte
readByte(): number readByte(): number
...@@ -3600,7 +3580,7 @@ Reads the Byte value from this **MessageParcel** object. ...@@ -3600,7 +3580,7 @@ Reads the Byte value from this **MessageParcel** object.
**Example** **Example**
``` ```ts
let data = rpc.MessageParcel.create(); let data = rpc.MessageParcel.create();
let result = data.writeByte(2); let result = data.writeByte(2);
console.log("RpcClient: writeByte is: " + result); console.log("RpcClient: writeByte is: " + result);
...@@ -3608,7 +3588,6 @@ Reads the Byte value from this **MessageParcel** object. ...@@ -3608,7 +3588,6 @@ Reads the Byte value from this **MessageParcel** object.
console.log("RpcClient: readByte is: " + ret); console.log("RpcClient: readByte is: " + ret);
``` ```
### writeShort ### writeShort
writeShort(val: number): boolean writeShort(val: number): boolean
...@@ -3627,17 +3606,16 @@ Writes a Short int value to this **MessageParcel** object. ...@@ -3627,17 +3606,16 @@ Writes a Short int value to this **MessageParcel** object.
| Type | Description | | Type | Description |
| ------- | ----------------------------- | | ------- | ----------------------------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.| | boolean | Returns **true** if the data is written successfully; returns **false** otherwise.|
**Example** **Example**
``` ```ts
let data = rpc.MessageParcel.create(); let data = rpc.MessageParcel.create();
let result = data.writeShort(8); let result = data.writeShort(8);
console.log("RpcClient: writeShort is: " + result); console.log("RpcClient: writeShort is: " + result);
``` ```
### readShort ### readShort
readShort(): number readShort(): number
...@@ -3654,7 +3632,7 @@ Reads the Short int value from this **MessageParcel** object. ...@@ -3654,7 +3632,7 @@ Reads the Short int value from this **MessageParcel** object.
**Example** **Example**
``` ```ts
let data = rpc.MessageParcel.create(); let data = rpc.MessageParcel.create();
let result = data.writeShort(8); let result = data.writeShort(8);
console.log("RpcClient: writeShort is: " + result); console.log("RpcClient: writeShort is: " + result);
...@@ -3662,7 +3640,6 @@ Reads the Short int value from this **MessageParcel** object. ...@@ -3662,7 +3640,6 @@ Reads the Short int value from this **MessageParcel** object.
console.log("RpcClient: readShort is: " + ret); console.log("RpcClient: readShort is: " + ret);
``` ```
### writeInt ### writeInt
writeInt(val: number): boolean writeInt(val: number): boolean
...@@ -3685,13 +3662,12 @@ Writes an Int value to this **MessageParcel** object. ...@@ -3685,13 +3662,12 @@ Writes an Int value to this **MessageParcel** object.
**Example** **Example**
``` ```ts
let data = rpc.MessageParcel.create(); let data = rpc.MessageParcel.create();
let result = data.writeInt(10); let result = data.writeInt(10);
console.log("RpcClient: writeInt is " + result); console.log("RpcClient: writeInt is " + result);
``` ```
### readInt ### readInt
readInt(): number readInt(): number
...@@ -3708,7 +3684,7 @@ Reads the Int value from this **MessageParcel** object. ...@@ -3708,7 +3684,7 @@ Reads the Int value from this **MessageParcel** object.
**Example** **Example**
``` ```ts
let data = rpc.MessageParcel.create(); let data = rpc.MessageParcel.create();
let result = data.writeInt(10); let result = data.writeInt(10);
console.log("RpcClient: writeInt is " + result); console.log("RpcClient: writeInt is " + result);
...@@ -3716,7 +3692,6 @@ Reads the Int value from this **MessageParcel** object. ...@@ -3716,7 +3692,6 @@ Reads the Int value from this **MessageParcel** object.
console.log("RpcClient: readInt is " + ret); console.log("RpcClient: readInt is " + ret);
``` ```
### writeLong ### writeLong
writeLong(val: number): boolean writeLong(val: number): boolean
...@@ -3735,17 +3710,16 @@ Writes a Long int value to this **MessageParcel** object. ...@@ -3735,17 +3710,16 @@ Writes a Long int value to this **MessageParcel** object.
| Type | Description | | Type | Description |
| ------- | --------------------------------- | | ------- | --------------------------------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.| | boolean | Returns **true** if the data is written successfully; returns **false** otherwise.|
**Example** **Example**
``` ```ts
let data = rpc.MessageParcel.create(); let data = rpc.MessageParcel.create();
let result = data.writeLong(10000); let result = data.writeLong(10000);
console.log("RpcClient: writeLong is " + result); console.log("RpcClient: writeLong is " + result);
``` ```
### readLong ### readLong
readLong(): number readLong(): number
...@@ -3762,7 +3736,7 @@ Reads the Long int value from this **MessageParcel** object. ...@@ -3762,7 +3736,7 @@ Reads the Long int value from this **MessageParcel** object.
**Example** **Example**
``` ```ts
let data = rpc.MessageParcel.create(); let data = rpc.MessageParcel.create();
let result = data.writeLong(10000); let result = data.writeLong(10000);
console.log("RpcClient: writeLong is " + result); console.log("RpcClient: writeLong is " + result);
...@@ -3770,7 +3744,6 @@ Reads the Long int value from this **MessageParcel** object. ...@@ -3770,7 +3744,6 @@ Reads the Long int value from this **MessageParcel** object.
console.log("RpcClient: readLong is " + ret); console.log("RpcClient: readLong is " + ret);
``` ```
### writeFloat ### writeFloat
writeFloat(val: number): boolean writeFloat(val: number): boolean
...@@ -3789,17 +3762,16 @@ Writes a Float value to this **MessageParcel** object. ...@@ -3789,17 +3762,16 @@ Writes a Float value to this **MessageParcel** object.
| Type | Description | | Type | Description |
| ------- | --------------------------------- | | ------- | --------------------------------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.| | boolean | Returns **true** if the data is written successfully; returns **false** otherwise.|
**Example** **Example**
``` ```ts
let data = rpc.MessageParcel.create(); let data = rpc.MessageParcel.create();
let result = data.writeFloat(1.2); let result = data.writeFloat(1.2);
console.log("RpcClient: writeFloat is " + result); console.log("RpcClient: writeFloat is " + result);
``` ```
### readFloat ### readFloat
readFloat(): number readFloat(): number
...@@ -3816,7 +3788,7 @@ Reads the Float value from this **MessageParcel** object. ...@@ -3816,7 +3788,7 @@ Reads the Float value from this **MessageParcel** object.
**Example** **Example**
``` ```ts
let data = rpc.MessageParcel.create(); let data = rpc.MessageParcel.create();
let result = data.writeFloat(1.2); let result = data.writeFloat(1.2);
console.log("RpcClient: writeFloat is " + result); console.log("RpcClient: writeFloat is " + result);
...@@ -3824,7 +3796,6 @@ Reads the Float value from this **MessageParcel** object. ...@@ -3824,7 +3796,6 @@ Reads the Float value from this **MessageParcel** object.
console.log("RpcClient: readFloat is " + ret); console.log("RpcClient: readFloat is " + ret);
``` ```
### writeDouble ### writeDouble
writeDouble(val: number): boolean writeDouble(val: number): boolean
...@@ -3843,17 +3814,16 @@ Writes a Double value to this **MessageParcel** object. ...@@ -3843,17 +3814,16 @@ Writes a Double value to this **MessageParcel** object.
| Type | Description | | Type | Description |
| ------- | --------------------------------- | | ------- | --------------------------------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.| | boolean | Returns **true** if the data is written successfully; returns **false** otherwise.|
**Example** **Example**
``` ```ts
let data = rpc.MessageParcel.create(); let data = rpc.MessageParcel.create();
let result = data.writeDouble(10.2); let result = data.writeDouble(10.2);
console.log("RpcClient: writeDouble is " + result); console.log("RpcClient: writeDouble is " + result);
``` ```
### readDouble ### readDouble
readDouble(): number readDouble(): number
...@@ -3870,7 +3840,7 @@ Reads the Double value from this **MessageParcel** object. ...@@ -3870,7 +3840,7 @@ Reads the Double value from this **MessageParcel** object.
**Example** **Example**
``` ```ts
let data = rpc.MessageParcel.create(); let data = rpc.MessageParcel.create();
let result = data.writeDouble(10.2); let result = data.writeDouble(10.2);
console.log("RpcClient: writeDouble is " + result); console.log("RpcClient: writeDouble is " + result);
...@@ -3896,17 +3866,16 @@ Writes a Boolean value to this **MessageParcel** object. ...@@ -3896,17 +3866,16 @@ Writes a Boolean value to this **MessageParcel** object.
| Type | Description | | Type | Description |
| ------- | --------------------------------- | | ------- | --------------------------------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.| | boolean | Returns **true** if the data is written successfully; returns **false** otherwise.|
**Example** **Example**
``` ```ts
let data = rpc.MessageParcel.create(); let data = rpc.MessageParcel.create();
let result = data.writeBoolean(false); let result = data.writeBoolean(false);
console.log("RpcClient: writeBoolean is " + result); console.log("RpcClient: writeBoolean is " + result);
``` ```
### readBoolean ### readBoolean
readBoolean(): boolean readBoolean(): boolean
...@@ -3923,7 +3892,7 @@ Reads the Boolean value from this **MessageParcel** object. ...@@ -3923,7 +3892,7 @@ Reads the Boolean value from this **MessageParcel** object.
**Example** **Example**
``` ```ts
let data = rpc.MessageParcel.create(); let data = rpc.MessageParcel.create();
let result = data.writeBoolean(false); let result = data.writeBoolean(false);
console.log("RpcClient: writeBoolean is " + result); console.log("RpcClient: writeBoolean is " + result);
...@@ -3931,7 +3900,6 @@ Reads the Boolean value from this **MessageParcel** object. ...@@ -3931,7 +3900,6 @@ Reads the Boolean value from this **MessageParcel** object.
console.log("RpcClient: readBoolean is " + ret); console.log("RpcClient: readBoolean is " + ret);
``` ```
### writeChar ### writeChar
writeChar(val: number): boolean writeChar(val: number): boolean
...@@ -3950,17 +3918,16 @@ Writes a Char value to this **MessageParcel** object. ...@@ -3950,17 +3918,16 @@ Writes a Char value to this **MessageParcel** object.
| Type | Description | | Type | Description |
| ------- | ----------------------------- | | ------- | ----------------------------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.| | boolean | Returns **true** if the data is written successfully; returns **false** otherwise.|
**Example** **Example**
``` ```ts
let data = rpc.MessageParcel.create(); let data = rpc.MessageParcel.create();
let result = data.writeChar(97); let result = data.writeChar(97);
console.log("RpcClient: writeChar is " + result); console.log("RpcClient: writeChar is " + result);
``` ```
### readChar ### readChar
readChar(): number readChar(): number
...@@ -3977,7 +3944,7 @@ Reads the Char value from this **MessageParcel** object. ...@@ -3977,7 +3944,7 @@ Reads the Char value from this **MessageParcel** object.
**Example** **Example**
``` ```ts
let data = rpc.MessageParcel.create(); let data = rpc.MessageParcel.create();
let result = data.writeChar(97); let result = data.writeChar(97);
console.log("RpcClient: writeChar is " + result); console.log("RpcClient: writeChar is " + result);
...@@ -3985,7 +3952,6 @@ Reads the Char value from this **MessageParcel** object. ...@@ -3985,7 +3952,6 @@ Reads the Char value from this **MessageParcel** object.
console.log("RpcClient: readChar is " + ret); console.log("RpcClient: readChar is " + ret);
``` ```
### writeString ### writeString
writeString(val: string): boolean writeString(val: string): boolean
...@@ -4004,17 +3970,16 @@ Writes a string to this **MessageParcel** object. ...@@ -4004,17 +3970,16 @@ Writes a string to this **MessageParcel** object.
| Type | Description | | Type | Description |
| ------- | --------------------------------- | | ------- | --------------------------------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.| | boolean | Returns **true** if the data is written successfully; returns **false** otherwise.|
**Example** **Example**
``` ```ts
let data = rpc.MessageParcel.create(); let data = rpc.MessageParcel.create();
let result = data.writeString('abc'); let result = data.writeString('abc');
console.log("RpcClient: writeString is " + result); console.log("RpcClient: writeString is " + result);
``` ```
### readString ### readString
readString(): string readString(): string
...@@ -4031,7 +3996,7 @@ Reads the string from this **MessageParcel** object. ...@@ -4031,7 +3996,7 @@ Reads the string from this **MessageParcel** object.
**Example** **Example**
``` ```ts
let data = rpc.MessageParcel.create(); let data = rpc.MessageParcel.create();
let result = data.writeString('abc'); let result = data.writeString('abc');
console.log("RpcClient: writeString is " + result); console.log("RpcClient: writeString is " + result);
...@@ -4039,7 +4004,6 @@ Reads the string from this **MessageParcel** object. ...@@ -4039,7 +4004,6 @@ Reads the string from this **MessageParcel** object.
console.log("RpcClient: readString is " + ret); console.log("RpcClient: readString is " + ret);
``` ```
### writeSequenceable ### writeSequenceable
writeSequenceable(val: Sequenceable): boolean writeSequenceable(val: Sequenceable): boolean
...@@ -4058,11 +4022,11 @@ Writes a sequenceable object to this **MessageParcel** object. ...@@ -4058,11 +4022,11 @@ Writes a sequenceable object to this **MessageParcel** object.
| Type | Description | | Type | Description |
| ------- | --------------------------------- | | ------- | --------------------------------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.| | boolean | Returns **true** if the data is written successfully; returns **false** otherwise.|
**Example** **Example**
``` ```ts
class MySequenceable { class MySequenceable {
num: number; num: number;
str: string; str: string;
...@@ -4087,7 +4051,6 @@ Writes a sequenceable object to this **MessageParcel** object. ...@@ -4087,7 +4051,6 @@ Writes a sequenceable object to this **MessageParcel** object.
console.log("RpcClient: writeSequenceable is " + result); console.log("RpcClient: writeSequenceable is " + result);
``` ```
### readSequenceable ### readSequenceable
readSequenceable(dataIn: Sequenceable): boolean readSequenceable(dataIn: Sequenceable): boolean
...@@ -4110,7 +4073,7 @@ Reads member variables from this **MessageParcel** object. ...@@ -4110,7 +4073,7 @@ Reads member variables from this **MessageParcel** object.
**Example** **Example**
``` ```ts
class MySequenceable { class MySequenceable {
num: number; num: number;
str: string; str: string;
...@@ -4138,7 +4101,6 @@ Reads member variables from this **MessageParcel** object. ...@@ -4138,7 +4101,6 @@ Reads member variables from this **MessageParcel** object.
console.log("RpcClient: writeSequenceable is " + result2); console.log("RpcClient: writeSequenceable is " + result2);
``` ```
### writeByteArray ### writeByteArray
writeByteArray(byteArray: number[]): boolean writeByteArray(byteArray: number[]): boolean
...@@ -4157,18 +4119,17 @@ Writes a byte array to this **MessageParcel** object. ...@@ -4157,18 +4119,17 @@ Writes a byte array to this **MessageParcel** object.
| Type | Description | | Type | Description |
| ------- | --------------------------------- | | ------- | --------------------------------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.| | boolean | Returns **true** if the data is written successfully; returns **false** otherwise.|
**Example** **Example**
``` ```ts
let data = rpc.MessageParcel.create(); let data = rpc.MessageParcel.create();
let ByteArrayVar = [1, 2, 3, 4, 5]; let ByteArrayVar = [1, 2, 3, 4, 5];
let result = data.writeByteArray(ByteArrayVar); let result = data.writeByteArray(ByteArrayVar);
console.log("RpcClient: writeByteArray is " + result); console.log("RpcClient: writeByteArray is " + result);
``` ```
### readByteArray ### readByteArray
readByteArray(dataIn: number[]): void readByteArray(dataIn: number[]): void
...@@ -4185,7 +4146,7 @@ Reads a byte array from this **MessageParcel** object. ...@@ -4185,7 +4146,7 @@ Reads a byte array from this **MessageParcel** object.
**Example** **Example**
``` ```ts
let data = rpc.MessageParcel.create(); let data = rpc.MessageParcel.create();
let ByteArrayVar = [1, 2, 3, 4, 5]; let ByteArrayVar = [1, 2, 3, 4, 5];
let result = data.writeByteArray(ByteArrayVar); let result = data.writeByteArray(ByteArrayVar);
...@@ -4194,7 +4155,6 @@ Reads a byte array from this **MessageParcel** object. ...@@ -4194,7 +4155,6 @@ Reads a byte array from this **MessageParcel** object.
data.readByteArray(array); data.readByteArray(array);
``` ```
### readByteArray ### readByteArray
readByteArray(): number[] readByteArray(): number[]
...@@ -4211,7 +4171,7 @@ Reads the byte array from this **MessageParcel** object. ...@@ -4211,7 +4171,7 @@ Reads the byte array from this **MessageParcel** object.
**Example** **Example**
``` ```ts
let data = rpc.MessageParcel.create(); let data = rpc.MessageParcel.create();
let ByteArrayVar = [1, 2, 3, 4, 5]; let ByteArrayVar = [1, 2, 3, 4, 5];
let result = data.writeByteArray(ByteArrayVar); let result = data.writeByteArray(ByteArrayVar);
...@@ -4220,7 +4180,6 @@ Reads the byte array from this **MessageParcel** object. ...@@ -4220,7 +4180,6 @@ Reads the byte array from this **MessageParcel** object.
console.log("RpcClient: readByteArray is " + array); console.log("RpcClient: readByteArray is " + array);
``` ```
### writeShortArray ### writeShortArray
writeShortArray(shortArray: number[]): boolean writeShortArray(shortArray: number[]): boolean
...@@ -4239,17 +4198,16 @@ Writes a short array to this **MessageParcel** object. ...@@ -4239,17 +4198,16 @@ Writes a short array to this **MessageParcel** object.
| Type | Description | | Type | Description |
| ------- | ----------------------------- | | ------- | ----------------------------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.| | boolean | Returns **true** if the data is written successfully; returns **false** otherwise.|
**Example** **Example**
``` ```ts
let data = rpc.MessageParcel.create(); let data = rpc.MessageParcel.create();
let result = data.writeShortArray([11, 12, 13]); let result = data.writeShortArray([11, 12, 13]);
console.log("RpcClient: writeShortArray is " + result); console.log("RpcClient: writeShortArray is " + result);
``` ```
### readShortArray ### readShortArray
readShortArray(dataIn: number[]): void readShortArray(dataIn: number[]): void
...@@ -4266,7 +4224,7 @@ Reads a short array from this **MessageParcel** object. ...@@ -4266,7 +4224,7 @@ Reads a short array from this **MessageParcel** object.
**Example** **Example**
``` ```ts
let data = rpc.MessageParcel.create(); let data = rpc.MessageParcel.create();
let result = data.writeShortArray([11, 12, 13]); let result = data.writeShortArray([11, 12, 13]);
console.log("RpcClient: writeShortArray is " + result); console.log("RpcClient: writeShortArray is " + result);
...@@ -4274,7 +4232,6 @@ Reads a short array from this **MessageParcel** object. ...@@ -4274,7 +4232,6 @@ Reads a short array from this **MessageParcel** object.
data.readShortArray(array); data.readShortArray(array);
``` ```
### readShortArray ### readShortArray
readShortArray(): number[] readShortArray(): number[]
...@@ -4291,7 +4248,7 @@ Reads the short array from this **MessageParcel** object. ...@@ -4291,7 +4248,7 @@ Reads the short array from this **MessageParcel** object.
**Example** **Example**
``` ```ts
let data = rpc.MessageParcel.create(); let data = rpc.MessageParcel.create();
let result = data.writeShortArray([11, 12, 13]); let result = data.writeShortArray([11, 12, 13]);
console.log("RpcClient: writeShortArray is " + result); console.log("RpcClient: writeShortArray is " + result);
...@@ -4299,7 +4256,6 @@ Reads the short array from this **MessageParcel** object. ...@@ -4299,7 +4256,6 @@ Reads the short array from this **MessageParcel** object.
console.log("RpcClient: readShortArray is " + array); console.log("RpcClient: readShortArray is " + array);
``` ```
### writeIntArray ### writeIntArray
writeIntArray(intArray: number[]): boolean writeIntArray(intArray: number[]): boolean
...@@ -4318,17 +4274,16 @@ Writes an integer array to this **MessageParcel** object. ...@@ -4318,17 +4274,16 @@ Writes an integer array to this **MessageParcel** object.
| Type | Description | | Type | Description |
| ------- | ----------------------------- | | ------- | ----------------------------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.| | boolean | Returns **true** if the data is written successfully; returns **false** otherwise.|
**Example** **Example**
``` ```ts
let data = rpc.MessageParcel.create(); let data = rpc.MessageParcel.create();
let result = data.writeIntArray([100, 111, 112]); let result = data.writeIntArray([100, 111, 112]);
console.log("RpcClient: writeIntArray is " + result); console.log("RpcClient: writeIntArray is " + result);
``` ```
### readIntArray ### readIntArray
readIntArray(dataIn: number[]): void readIntArray(dataIn: number[]): void
...@@ -4345,7 +4300,7 @@ Reads an integer array from this **MessageParcel** object. ...@@ -4345,7 +4300,7 @@ Reads an integer array from this **MessageParcel** object.
**Example** **Example**
``` ```ts
let data = rpc.MessageParcel.create(); let data = rpc.MessageParcel.create();
let result = data.writeIntArray([100, 111, 112]); let result = data.writeIntArray([100, 111, 112]);
console.log("RpcClient: writeIntArray is " + result); console.log("RpcClient: writeIntArray is " + result);
...@@ -4353,7 +4308,6 @@ Reads an integer array from this **MessageParcel** object. ...@@ -4353,7 +4308,6 @@ Reads an integer array from this **MessageParcel** object.
data.readIntArray(array); data.readIntArray(array);
``` ```
### readIntArray ### readIntArray
readIntArray(): number[] readIntArray(): number[]
...@@ -4370,7 +4324,7 @@ Reads the integer array from this **MessageParcel** object. ...@@ -4370,7 +4324,7 @@ Reads the integer array from this **MessageParcel** object.
**Example** **Example**
``` ```ts
let data = rpc.MessageParcel.create(); let data = rpc.MessageParcel.create();
let result = data.writeIntArray([100, 111, 112]); let result = data.writeIntArray([100, 111, 112]);
console.log("RpcClient: writeIntArray is " + result); console.log("RpcClient: writeIntArray is " + result);
...@@ -4378,7 +4332,6 @@ Reads the integer array from this **MessageParcel** object. ...@@ -4378,7 +4332,6 @@ Reads the integer array from this **MessageParcel** object.
console.log("RpcClient: readIntArray is " + array); console.log("RpcClient: readIntArray is " + array);
``` ```
### writeLongArray ### writeLongArray
writeLongArray(longArray: number[]): boolean writeLongArray(longArray: number[]): boolean
...@@ -4397,17 +4350,16 @@ Writes a long array to this **MessageParcel** object. ...@@ -4397,17 +4350,16 @@ Writes a long array to this **MessageParcel** object.
| Type | Description | | Type | Description |
| ------- | ----------------------------- | | ------- | ----------------------------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.| | boolean | Returns **true** if the data is written successfully; returns **false** otherwise.|
**Example** **Example**
``` ```ts
let data = rpc.MessageParcel.create(); let data = rpc.MessageParcel.create();
let result = data.writeLongArray([1111, 1112, 1113]); let result = data.writeLongArray([1111, 1112, 1113]);
console.log("RpcClient: writeLongArray is " + result); console.log("RpcClient: writeLongArray is " + result);
``` ```
### readLongArray ### readLongArray
readLongArray(dataIn: number[]): void readLongArray(dataIn: number[]): void
...@@ -4424,7 +4376,7 @@ Reads a long array from this **MessageParcel** object. ...@@ -4424,7 +4376,7 @@ Reads a long array from this **MessageParcel** object.
**Example** **Example**
``` ```ts
let data = rpc.MessageParcel.create(); let data = rpc.MessageParcel.create();
let result = data.writeLongArray([1111, 1112, 1113]); let result = data.writeLongArray([1111, 1112, 1113]);
console.log("RpcClient: writeLongArray is " + result); console.log("RpcClient: writeLongArray is " + result);
...@@ -4432,7 +4384,6 @@ Reads a long array from this **MessageParcel** object. ...@@ -4432,7 +4384,6 @@ Reads a long array from this **MessageParcel** object.
data.readLongArray(array); data.readLongArray(array);
``` ```
### readLongArray ### readLongArray
readLongArray(): number[] readLongArray(): number[]
...@@ -4449,7 +4400,7 @@ Reads the long array from this **MessageParcel** object. ...@@ -4449,7 +4400,7 @@ Reads the long array from this **MessageParcel** object.
**Example** **Example**
``` ```ts
let data = rpc.MessageParcel.create(); let data = rpc.MessageParcel.create();
let result = data.writeLongArray([1111, 1112, 1113]); let result = data.writeLongArray([1111, 1112, 1113]);
console.log("RpcClient: writeLongArray is " + result); console.log("RpcClient: writeLongArray is " + result);
...@@ -4457,7 +4408,6 @@ Reads the long array from this **MessageParcel** object. ...@@ -4457,7 +4408,6 @@ Reads the long array from this **MessageParcel** object.
console.log("RpcClient: readLongArray is " + array); console.log("RpcClient: readLongArray is " + array);
``` ```
### writeFloatArray ### writeFloatArray
writeFloatArray(floatArray: number[]): boolean writeFloatArray(floatArray: number[]): boolean
...@@ -4476,17 +4426,16 @@ Writes a FloatArray to this **MessageParcel** object. ...@@ -4476,17 +4426,16 @@ Writes a FloatArray to this **MessageParcel** object.
| Type | Description | | Type | Description |
| ------- | ----------------------------- | | ------- | ----------------------------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.| | boolean | Returns **true** if the data is written successfully; returns **false** otherwise.|
**Example** **Example**
``` ```ts
let data = rpc.MessageParcel.create(); let data = rpc.MessageParcel.create();
let result = data.writeFloatArray([1.2, 1.3, 1.4]); let result = data.writeFloatArray([1.2, 1.3, 1.4]);
console.log("RpcClient: writeFloatArray is " + result); console.log("RpcClient: writeFloatArray is " + result);
``` ```
### readFloatArray ### readFloatArray
readFloatArray(dataIn: number[]): void readFloatArray(dataIn: number[]): void
...@@ -4503,7 +4452,7 @@ Reads a FloatArray from this **MessageParcel** object. ...@@ -4503,7 +4452,7 @@ Reads a FloatArray from this **MessageParcel** object.
**Example** **Example**
``` ```ts
let data = rpc.MessageParcel.create(); let data = rpc.MessageParcel.create();
let result = data.writeFloatArray([1.2, 1.3, 1.4]); let result = data.writeFloatArray([1.2, 1.3, 1.4]);
console.log("RpcClient: writeFloatArray is " + result); console.log("RpcClient: writeFloatArray is " + result);
...@@ -4511,7 +4460,6 @@ Reads a FloatArray from this **MessageParcel** object. ...@@ -4511,7 +4460,6 @@ Reads a FloatArray from this **MessageParcel** object.
data.readFloatArray(array); data.readFloatArray(array);
``` ```
### readFloatArray ### readFloatArray
readFloatArray(): number[] readFloatArray(): number[]
...@@ -4528,7 +4476,7 @@ Reads the FloatArray from this **MessageParcel** object. ...@@ -4528,7 +4476,7 @@ Reads the FloatArray from this **MessageParcel** object.
**Example** **Example**
``` ```ts
let data = rpc.MessageParcel.create(); let data = rpc.MessageParcel.create();
let result = data.writeFloatArray([1.2, 1.3, 1.4]); let result = data.writeFloatArray([1.2, 1.3, 1.4]);
console.log("RpcClient: writeFloatArray is " + result); console.log("RpcClient: writeFloatArray is " + result);
...@@ -4536,7 +4484,6 @@ Reads the FloatArray from this **MessageParcel** object. ...@@ -4536,7 +4484,6 @@ Reads the FloatArray from this **MessageParcel** object.
console.log("RpcClient: readFloatArray is " + array); console.log("RpcClient: readFloatArray is " + array);
``` ```
### writeDoubleArray ### writeDoubleArray
writeDoubleArray(doubleArray: number[]): boolean writeDoubleArray(doubleArray: number[]): boolean
...@@ -4555,17 +4502,16 @@ Writes a DoubleArray to this **MessageParcel** object. ...@@ -4555,17 +4502,16 @@ Writes a DoubleArray to this **MessageParcel** object.
| Type | Description | | Type | Description |
| ------- | ----------------------------- | | ------- | ----------------------------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.| | boolean | Returns **true** if the data is written successfully; returns **false** otherwise.|
**Example** **Example**
``` ```ts
let data = rpc.MessageParcel.create(); let data = rpc.MessageParcel.create();
let result = data.writeDoubleArray([11.1, 12.2, 13.3]); let result = data.writeDoubleArray([11.1, 12.2, 13.3]);
console.log("RpcClient: writeDoubleArray is " + result); console.log("RpcClient: writeDoubleArray is " + result);
``` ```
### readDoubleArray ### readDoubleArray
readDoubleArray(dataIn: number[]): void readDoubleArray(dataIn: number[]): void
...@@ -4582,7 +4528,7 @@ Reads a DoubleArray from this **MessageParcel** object. ...@@ -4582,7 +4528,7 @@ Reads a DoubleArray from this **MessageParcel** object.
**Example** **Example**
``` ```ts
let data = rpc.MessageParcel.create(); let data = rpc.MessageParcel.create();
let result = data.writeDoubleArray([11.1, 12.2, 13.3]); let result = data.writeDoubleArray([11.1, 12.2, 13.3]);
console.log("RpcClient: writeDoubleArray is " + result); console.log("RpcClient: writeDoubleArray is " + result);
...@@ -4590,7 +4536,6 @@ Reads a DoubleArray from this **MessageParcel** object. ...@@ -4590,7 +4536,6 @@ Reads a DoubleArray from this **MessageParcel** object.
data.readDoubleArray(array); data.readDoubleArray(array);
``` ```
### readDoubleArray ### readDoubleArray
readDoubleArray(): number[] readDoubleArray(): number[]
...@@ -4607,7 +4552,7 @@ Reads the DoubleArray from this **MessageParcel** object. ...@@ -4607,7 +4552,7 @@ Reads the DoubleArray from this **MessageParcel** object.
**Example** **Example**
``` ```ts
let data = rpc.MessageParcel.create(); let data = rpc.MessageParcel.create();
let result = data.writeDoubleArray([11.1, 12.2, 13.3]); let result = data.writeDoubleArray([11.1, 12.2, 13.3]);
console.log("RpcClient: writeDoubleArray is " + result); console.log("RpcClient: writeDoubleArray is " + result);
...@@ -4615,7 +4560,6 @@ Reads the DoubleArray from this **MessageParcel** object. ...@@ -4615,7 +4560,6 @@ Reads the DoubleArray from this **MessageParcel** object.
console.log("RpcClient: readDoubleArray is " + array); console.log("RpcClient: readDoubleArray is " + array);
``` ```
### writeBooleanArray ### writeBooleanArray
writeBooleanArray(booleanArray: boolean[]): boolean writeBooleanArray(booleanArray: boolean[]): boolean
...@@ -4634,17 +4578,16 @@ Writes a Boolean array to this **MessageParcel** object. ...@@ -4634,17 +4578,16 @@ Writes a Boolean array to this **MessageParcel** object.
| Type | Description | | Type | Description |
| ------- | --------------------------------- | | ------- | --------------------------------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.| | boolean | Returns **true** if the data is written successfully; returns **false** otherwise.|
**Example** **Example**
``` ```ts
let data = rpc.MessageParcel.create(); let data = rpc.MessageParcel.create();
let result = data.writeBooleanArray([false, true, false]); let result = data.writeBooleanArray([false, true, false]);
console.log("RpcClient: writeBooleanArray is " + result); console.log("RpcClient: writeBooleanArray is " + result);
``` ```
### readBooleanArray ### readBooleanArray
readBooleanArray(dataIn: boolean[]): void readBooleanArray(dataIn: boolean[]): void
...@@ -4661,7 +4604,7 @@ Reads a Boolean array from this **MessageParcel** object. ...@@ -4661,7 +4604,7 @@ Reads a Boolean array from this **MessageParcel** object.
**Example** **Example**
``` ```ts
let data = rpc.MessageParcel.create(); let data = rpc.MessageParcel.create();
let result = data.writeBooleanArray([false, true, false]); let result = data.writeBooleanArray([false, true, false]);
console.log("RpcClient: writeBooleanArray is " + result); console.log("RpcClient: writeBooleanArray is " + result);
...@@ -4669,7 +4612,6 @@ Reads a Boolean array from this **MessageParcel** object. ...@@ -4669,7 +4612,6 @@ Reads a Boolean array from this **MessageParcel** object.
data.readBooleanArray(array); data.readBooleanArray(array);
``` ```
### readBooleanArray ### readBooleanArray
readBooleanArray(): boolean[] readBooleanArray(): boolean[]
...@@ -4686,7 +4628,7 @@ Reads the Boolean array from this **MessageParcel** object. ...@@ -4686,7 +4628,7 @@ Reads the Boolean array from this **MessageParcel** object.
**Example** **Example**
``` ```ts
let data = rpc.MessageParcel.create(); let data = rpc.MessageParcel.create();
let result = data.writeBooleanArray([false, true, false]); let result = data.writeBooleanArray([false, true, false]);
console.log("RpcClient: writeBooleanArray is " + result); console.log("RpcClient: writeBooleanArray is " + result);
...@@ -4694,7 +4636,6 @@ Reads the Boolean array from this **MessageParcel** object. ...@@ -4694,7 +4636,6 @@ Reads the Boolean array from this **MessageParcel** object.
console.log("RpcClient: readBooleanArray is " + array); console.log("RpcClient: readBooleanArray is " + array);
``` ```
### writeCharArray ### writeCharArray
writeCharArray(charArray: number[]): boolean writeCharArray(charArray: number[]): boolean
...@@ -4713,17 +4654,16 @@ Writes a character array to this **MessageParcel** object. ...@@ -4713,17 +4654,16 @@ Writes a character array to this **MessageParcel** object.
| Type | Description | | Type | Description |
| ------- | --------------------------------- | | ------- | --------------------------------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.| | boolean | Returns **true** if the data is written successfully; returns **false** otherwise.|
**Example** **Example**
``` ```ts
let data = rpc.MessageParcel.create(); let data = rpc.MessageParcel.create();
let result = data.writeCharArray([97, 98, 88]); let result = data.writeCharArray([97, 98, 88]);
console.log("RpcClient: writeCharArray is " + result); console.log("RpcClient: writeCharArray is " + result);
``` ```
### readCharArray ### readCharArray
readCharArray(dataIn: number[]): void readCharArray(dataIn: number[]): void
...@@ -4740,7 +4680,7 @@ Reads a character array from this **MessageParcel** object. ...@@ -4740,7 +4680,7 @@ Reads a character array from this **MessageParcel** object.
**Example** **Example**
``` ```ts
let data = rpc.MessageParcel.create(); let data = rpc.MessageParcel.create();
let result = data.writeCharArray([97, 98, 99]); let result = data.writeCharArray([97, 98, 99]);
console.log("RpcClient: writeCharArray is " + result); console.log("RpcClient: writeCharArray is " + result);
...@@ -4748,7 +4688,6 @@ Reads a character array from this **MessageParcel** object. ...@@ -4748,7 +4688,6 @@ Reads a character array from this **MessageParcel** object.
data.readCharArray(array); data.readCharArray(array);
``` ```
### readCharArray ### readCharArray
readCharArray(): number[] readCharArray(): number[]
...@@ -4765,7 +4704,7 @@ Reads the character array from this **MessageParcel** object. ...@@ -4765,7 +4704,7 @@ Reads the character array from this **MessageParcel** object.
**Example** **Example**
``` ```ts
let data = rpc.MessageParcel.create(); let data = rpc.MessageParcel.create();
let result = data.writeCharArray([97, 98, 99]); let result = data.writeCharArray([97, 98, 99]);
console.log("RpcClient: writeCharArray is " + result); console.log("RpcClient: writeCharArray is " + result);
...@@ -4773,7 +4712,6 @@ Reads the character array from this **MessageParcel** object. ...@@ -4773,7 +4712,6 @@ Reads the character array from this **MessageParcel** object.
console.log("RpcClient: readCharArray is " + array); console.log("RpcClient: readCharArray is " + array);
``` ```
### writeStringArray ### writeStringArray
writeStringArray(stringArray: string[]): boolean writeStringArray(stringArray: string[]): boolean
...@@ -4792,17 +4730,16 @@ Writes a string array to this **MessageParcel** object. ...@@ -4792,17 +4730,16 @@ Writes a string array to this **MessageParcel** object.
| Type | Description| | Type | Description|
| ------- | --------------------------------- | | ------- | --------------------------------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.| | boolean | Returns **true** if the data is written successfully; returns **false** otherwise.|
**Example** **Example**
``` ```ts
let data = rpc.MessageParcel.create(); let data = rpc.MessageParcel.create();
let result = data.writeStringArray(["abc", "def"]); let result = data.writeStringArray(["abc", "def"]);
console.log("RpcClient: writeStringArray is " + result); console.log("RpcClient: writeStringArray is " + result);
``` ```
### readStringArray ### readStringArray
readStringArray(dataIn: string[]): void readStringArray(dataIn: string[]): void
...@@ -4819,7 +4756,7 @@ Reads a string array from this **MessageParcel** object. ...@@ -4819,7 +4756,7 @@ Reads a string array from this **MessageParcel** object.
**Example** **Example**
``` ```ts
let data = rpc.MessageParcel.create(); let data = rpc.MessageParcel.create();
let result = data.writeStringArray(["abc", "def"]); let result = data.writeStringArray(["abc", "def"]);
console.log("RpcClient: writeStringArray is " + result); console.log("RpcClient: writeStringArray is " + result);
...@@ -4827,7 +4764,6 @@ Reads a string array from this **MessageParcel** object. ...@@ -4827,7 +4764,6 @@ Reads a string array from this **MessageParcel** object.
data.readStringArray(array); data.readStringArray(array);
``` ```
### readStringArray ### readStringArray
readStringArray(): string[] readStringArray(): string[]
...@@ -4844,7 +4780,7 @@ Reads the string array from this **MessageParcel** object. ...@@ -4844,7 +4780,7 @@ Reads the string array from this **MessageParcel** object.
**Example** **Example**
``` ```ts
let data = rpc.MessageParcel.create(); let data = rpc.MessageParcel.create();
let result = data.writeStringArray(["abc", "def"]); let result = data.writeStringArray(["abc", "def"]);
console.log("RpcClient: writeStringArray is " + result); console.log("RpcClient: writeStringArray is " + result);
...@@ -4852,7 +4788,6 @@ Reads the string array from this **MessageParcel** object. ...@@ -4852,7 +4788,6 @@ Reads the string array from this **MessageParcel** object.
console.log("RpcClient: readStringArray is " + array); console.log("RpcClient: readStringArray is " + array);
``` ```
### writeNoException<sup>8+</sup> ### writeNoException<sup>8+</sup>
writeNoException(): void writeNoException(): void
...@@ -4863,7 +4798,7 @@ Writes information to this **MessageParcel** object indicating that no exception ...@@ -4863,7 +4798,7 @@ Writes information to this **MessageParcel** object indicating that no exception
**Example** **Example**
``` ```ts
class MyDeathRecipient { class MyDeathRecipient {
onRemoteDied() { onRemoteDied() {
console.log("server died"); console.log("server died");
...@@ -4905,7 +4840,7 @@ Reads the exception information from this **MessageParcel** object. ...@@ -4905,7 +4840,7 @@ Reads the exception information from this **MessageParcel** object.
**Example** **Example**
``` ```ts
import FA from "@ohos.ability.featureAbility"; import FA from "@ohos.ability.featureAbility";
let proxy; let proxy;
let connect = { let connect = {
...@@ -4922,7 +4857,7 @@ Reads the exception information from this **MessageParcel** object. ...@@ -4922,7 +4857,7 @@ Reads the exception information from this **MessageParcel** object.
}; };
let want = { let want = {
"bundleName": "com.ohos.server", "bundleName": "com.ohos.server",
"abilityName": "com.ohos.server.MainAbility", "abilityName": "com.ohos.server.EntryAbility",
}; };
FA.connectAbility(want, connect); FA.connectAbility(want, connect);
let option = new rpc.MessageOption(); let option = new rpc.MessageOption();
...@@ -4967,11 +4902,11 @@ Writes a sequenceable array to this **MessageParcel** object. ...@@ -4967,11 +4902,11 @@ Writes a sequenceable array to this **MessageParcel** object.
| Type | Description | | Type | Description |
| ------- | --------------------------------- | | ------- | --------------------------------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.| | boolean | Returns **true** if the data is written successfully; returns **false** otherwise.|
**Example** **Example**
``` ```ts
class MySequenceable { class MySequenceable {
num: number; num: number;
str: string; str: string;
...@@ -4999,7 +4934,6 @@ Writes a sequenceable array to this **MessageParcel** object. ...@@ -4999,7 +4934,6 @@ Writes a sequenceable array to this **MessageParcel** object.
console.log("RpcClient: writeSequenceableArray is " + result); console.log("RpcClient: writeSequenceableArray is " + result);
``` ```
### readSequenceableArray<sup>8+</sup> ### readSequenceableArray<sup>8+</sup>
readSequenceableArray(sequenceableArray: Sequenceable[]): void readSequenceableArray(sequenceableArray: Sequenceable[]): void
...@@ -5016,7 +4950,7 @@ Reads a sequenceable array from this **MessageParcel** object. ...@@ -5016,7 +4950,7 @@ Reads a sequenceable array from this **MessageParcel** object.
**Example** **Example**
``` ```ts
class MySequenceable { class MySequenceable {
num: number; num: number;
str: string; str: string;
...@@ -5046,7 +4980,6 @@ Reads a sequenceable array from this **MessageParcel** object. ...@@ -5046,7 +4980,6 @@ Reads a sequenceable array from this **MessageParcel** object.
data.readSequenceableArray(b); data.readSequenceableArray(b);
``` ```
### writeRemoteObjectArray<sup>8+</sup> ### writeRemoteObjectArray<sup>8+</sup>
writeRemoteObjectArray(objectArray: IRemoteObject[]): boolean writeRemoteObjectArray(objectArray: IRemoteObject[]): boolean
...@@ -5065,11 +4998,11 @@ Writes an array of **IRemoteObject** objects to this **MessageParcel** object. ...@@ -5065,11 +4998,11 @@ Writes an array of **IRemoteObject** objects to this **MessageParcel** object.
| Type | Description | | Type | Description |
| ------- | -------------------------------------------------------------------------------------------------------------------- | | ------- | -------------------------------------------------------------------------------------------------------------------- |
| boolean | Returns **true** if the operation is successful; returns **false** if the operation fails or if the **IRemoteObject** array is null.| | boolean | Returns **true** if the data is written successfully; returns **false** otherwise.|
**Example** **Example**
``` ```ts
class MyDeathRecipient { class MyDeathRecipient {
onRemoteDied() { onRemoteDied() {
console.log("server died"); console.log("server died");
...@@ -5099,7 +5032,6 @@ Writes an array of **IRemoteObject** objects to this **MessageParcel** object. ...@@ -5099,7 +5032,6 @@ Writes an array of **IRemoteObject** objects to this **MessageParcel** object.
console.log("RpcClient: writeRemoteObjectArray is " + result); console.log("RpcClient: writeRemoteObjectArray is " + result);
``` ```
### readRemoteObjectArray<sup>8+</sup> ### readRemoteObjectArray<sup>8+</sup>
readRemoteObjectArray(objects: IRemoteObject[]): void readRemoteObjectArray(objects: IRemoteObject[]): void
...@@ -5116,7 +5048,7 @@ Reads an **IRemoteObject** array from this **MessageParcel** object. ...@@ -5116,7 +5048,7 @@ Reads an **IRemoteObject** array from this **MessageParcel** object.
**Example** **Example**
``` ```ts
class MyDeathRecipient { class MyDeathRecipient {
onRemoteDied() { onRemoteDied() {
console.log("server died"); console.log("server died");
...@@ -5147,7 +5079,6 @@ Reads an **IRemoteObject** array from this **MessageParcel** object. ...@@ -5147,7 +5079,6 @@ Reads an **IRemoteObject** array from this **MessageParcel** object.
data.readRemoteObjectArray(b); data.readRemoteObjectArray(b);
``` ```
### readRemoteObjectArray<sup>8+</sup> ### readRemoteObjectArray<sup>8+</sup>
readRemoteObjectArray(): IRemoteObject[] readRemoteObjectArray(): IRemoteObject[]
...@@ -5164,7 +5095,7 @@ Reads the **IRemoteObject** array from this **MessageParcel** object. ...@@ -5164,7 +5095,7 @@ Reads the **IRemoteObject** array from this **MessageParcel** object.
**Example** **Example**
``` ```ts
class MyDeathRecipient { class MyDeathRecipient {
onRemoteDied() { onRemoteDied() {
console.log("server died"); console.log("server died");
...@@ -5196,12 +5127,11 @@ Reads the **IRemoteObject** array from this **MessageParcel** object. ...@@ -5196,12 +5127,11 @@ Reads the **IRemoteObject** array from this **MessageParcel** object.
console.log("RpcClient: readRemoteObjectArray is " + b); console.log("RpcClient: readRemoteObjectArray is " + b);
``` ```
### closeFileDescriptor<sup>8+</sup> ### closeFileDescriptor<sup>8+</sup>
static closeFileDescriptor(fd: number): void static closeFileDescriptor(fd: number): void
Closes a file descriptor. Closes a file descriptor. This API is a static method.
**System capability**: SystemCapability.Communication.IPC.Core **System capability**: SystemCapability.Communication.IPC.Core
...@@ -5213,19 +5143,18 @@ Closes a file descriptor. ...@@ -5213,19 +5143,18 @@ Closes a file descriptor.
**Example** **Example**
``` ```ts
import fileio from '@ohos.fileio'; import fileio from '@ohos.fileio';
let filePath = "path/to/file"; let filePath = "path/to/file";
let fd = fileio.openSync(filePath, 0o2| 0o100, 0o666); let fd = fileio.openSync(filePath, 0o2| 0o100, 0o666);
rpc.MessageParcel.closeFileDescriptor(fd); rpc.MessageParcel.closeFileDescriptor(fd);
``` ```
### dupFileDescriptor<sup>8+</sup> ### dupFileDescriptor<sup>8+</sup>
static dupFileDescriptor(fd: number) :number static dupFileDescriptor(fd: number) :number
Duplicates a file descriptor. Duplicates a file descriptor. This API is a static method.
**System capability**: SystemCapability.Communication.IPC.Core **System capability**: SystemCapability.Communication.IPC.Core
...@@ -5243,14 +5172,13 @@ Duplicates a file descriptor. ...@@ -5243,14 +5172,13 @@ Duplicates a file descriptor.
**Example** **Example**
``` ```ts
import fileio from '@ohos.fileio'; import fileio from '@ohos.fileio';
let filePath = "path/to/file"; let filePath = "path/to/file";
let fd = fileio.openSync(filePath, 0o2| 0o100, 0o666); let fd = fileio.openSync(filePath, 0o2| 0o100, 0o666);
let newFd = rpc.MessageParcel.dupFileDescriptor(fd); let newFd = rpc.MessageParcel.dupFileDescriptor(fd);
``` ```
### containFileDescriptors<sup>8+</sup> ### containFileDescriptors<sup>8+</sup>
containFileDescriptors(): boolean containFileDescriptors(): boolean
...@@ -5263,11 +5191,11 @@ Checks whether this **MessageParcel** object contains a file descriptor. ...@@ -5263,11 +5191,11 @@ Checks whether this **MessageParcel** object contains a file descriptor.
| Type | Description | | Type | Description |
| ------- | ------------------------------------------------------------------ | | ------- | ------------------------------------------------------------------ |
| boolean | Returns **true** if the **MessageParcel** object contains a file descriptor; returns **false** otherwise.| | boolean |Returns **true** if the **MessageSequence** object contains a file descriptor; returns **false** otherwise.|
**Example** **Example**
``` ```ts
import fileio from '@ohos.fileio'; import fileio from '@ohos.fileio';
let parcel = new rpc.MessageParcel(); let parcel = new rpc.MessageParcel();
let filePath = "path/to/file"; let filePath = "path/to/file";
...@@ -5279,7 +5207,6 @@ Checks whether this **MessageParcel** object contains a file descriptor. ...@@ -5279,7 +5207,6 @@ Checks whether this **MessageParcel** object contains a file descriptor.
console.log("RpcTest: parcel after write fd containFd result is : " + containFD); console.log("RpcTest: parcel after write fd containFd result is : " + containFD);
``` ```
### writeFileDescriptor<sup>8+</sup> ### writeFileDescriptor<sup>8+</sup>
writeFileDescriptor(fd: number): boolean writeFileDescriptor(fd: number): boolean
...@@ -5302,7 +5229,7 @@ Writes a file descriptor to this **MessageParcel** object. ...@@ -5302,7 +5229,7 @@ Writes a file descriptor to this **MessageParcel** object.
**Example** **Example**
``` ```ts
import fileio from '@ohos.fileio'; import fileio from '@ohos.fileio';
let parcel = new rpc.MessageParcel(); let parcel = new rpc.MessageParcel();
let filePath = "path/to/file"; let filePath = "path/to/file";
...@@ -5311,7 +5238,6 @@ Writes a file descriptor to this **MessageParcel** object. ...@@ -5311,7 +5238,6 @@ Writes a file descriptor to this **MessageParcel** object.
console.log("RpcTest: parcel writeFd result is : " + writeResult); console.log("RpcTest: parcel writeFd result is : " + writeResult);
``` ```
### readFileDescriptor<sup>8+</sup> ### readFileDescriptor<sup>8+</sup>
readFileDescriptor(): number readFileDescriptor(): number
...@@ -5328,7 +5254,7 @@ Reads the file descriptor from this **MessageParcel** object. ...@@ -5328,7 +5254,7 @@ Reads the file descriptor from this **MessageParcel** object.
**Example** **Example**
``` ```ts
import fileio from '@ohos.fileio'; import fileio from '@ohos.fileio';
let parcel = new rpc.MessageParcel(); let parcel = new rpc.MessageParcel();
let filePath = "path/to/file"; let filePath = "path/to/file";
...@@ -5338,7 +5264,6 @@ Reads the file descriptor from this **MessageParcel** object. ...@@ -5338,7 +5264,6 @@ Reads the file descriptor from this **MessageParcel** object.
console.log("RpcTest: parcel read fd is : " + readFD); console.log("RpcTest: parcel read fd is : " + readFD);
``` ```
### writeAshmem<sup>8+</sup> ### writeAshmem<sup>8+</sup>
writeAshmem(ashmem: Ashmem): boolean writeAshmem(ashmem: Ashmem): boolean
...@@ -5357,18 +5282,17 @@ Writes an anonymous shared object to this **MessageParcel** object. ...@@ -5357,18 +5282,17 @@ Writes an anonymous shared object to this **MessageParcel** object.
| Type | Description | | Type | Description |
| ------- | -------------------------------------------------------------------- | | ------- | -------------------------------------------------------------------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.| | boolean | Returns **true** if the data is written successfully; returns **false** otherwise.|
**Example** **Example**
``` ```ts
let parcel = new rpc.MessageParcel(); let parcel = new rpc.MessageParcel();
let ashmem = rpc.Ashmem.createAshmem("ashmem", 1024); let ashmem = rpc.Ashmem.createAshmem("ashmem", 1024);
let isWriteSuccess = parcel.writeAshmem(ashmem); let isWriteSuccess = parcel.writeAshmem(ashmem);
console.log("RpcTest: write ashmem to result is : " + isWriteSuccess); console.log("RpcTest: write ashmem to result is : " + isWriteSuccess);
``` ```
### readAshmem<sup>8+</sup> ### readAshmem<sup>8+</sup>
readAshmem(): Ashmem readAshmem(): Ashmem
...@@ -5385,7 +5309,7 @@ Reads the anonymous shared object from this **MessageParcel** object. ...@@ -5385,7 +5309,7 @@ Reads the anonymous shared object from this **MessageParcel** object.
**Example** **Example**
``` ```ts
let parcel = new rpc.MessageParcel(); let parcel = new rpc.MessageParcel();
let ashmem = rpc.Ashmem.createAshmem("ashmem", 1024); let ashmem = rpc.Ashmem.createAshmem("ashmem", 1024);
let isWriteSuccess = parcel.writeAshmem(ashmem); let isWriteSuccess = parcel.writeAshmem(ashmem);
...@@ -5394,7 +5318,6 @@ Reads the anonymous shared object from this **MessageParcel** object. ...@@ -5394,7 +5318,6 @@ Reads the anonymous shared object from this **MessageParcel** object.
console.log("RpcTest: read ashmem to result is : " + readAshmem); console.log("RpcTest: read ashmem to result is : " + readAshmem);
``` ```
### getRawDataCapacity<sup>8+</sup> ### getRawDataCapacity<sup>8+</sup>
getRawDataCapacity(): number getRawDataCapacity(): number
...@@ -5411,13 +5334,12 @@ Obtains the maximum amount of raw data that can be held by this **MessageParcel* ...@@ -5411,13 +5334,12 @@ Obtains the maximum amount of raw data that can be held by this **MessageParcel*
**Example** **Example**
``` ```ts
let parcel = new rpc.MessageParcel(); let parcel = new rpc.MessageParcel();
let result = parcel.getRawDataCapacity(); let result = parcel.getRawDataCapacity();
console.log("RpcTest: parcel get RawDataCapacity result is : " + result); console.log("RpcTest: parcel get RawDataCapacity result is : " + result);
``` ```
### writeRawData<sup>8+</sup> ### writeRawData<sup>8+</sup>
writeRawData(rawData: number[], size: number): boolean writeRawData(rawData: number[], size: number): boolean
...@@ -5437,18 +5359,17 @@ Writes raw data to this **MessageParcel** object. ...@@ -5437,18 +5359,17 @@ Writes raw data to this **MessageParcel** object.
| Type | Description | | Type | Description |
| ------- | ----------------------------------------- | | ------- | ----------------------------------------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.| | boolean | Returns **true** if the data is written successfully; returns **false** otherwise.|
**Example** **Example**
``` ```ts
let parcel = new rpc.MessageParcel(); let parcel = new rpc.MessageParcel();
let arr = [1, 2, 3, 4, 5]; let arr = [1, 2, 3, 4, 5];
let isWriteSuccess = parcel.writeRawData(arr, arr.length); let isWriteSuccess = parcel.writeRawData(arr, arr.length);
console.log("RpcTest: parcel write raw data result is : " + isWriteSuccess); console.log("RpcTest: parcel write raw data result is : " + isWriteSuccess);
``` ```
### readRawData<sup>8+</sup> ### readRawData<sup>8+</sup>
readRawData(size: number): number[] readRawData(size: number): number[]
...@@ -5471,7 +5392,7 @@ Reads raw data from this **MessageParcel** object. ...@@ -5471,7 +5392,7 @@ Reads raw data from this **MessageParcel** object.
**Example** **Example**
``` ```ts
let parcel = new rpc.MessageParcel(); let parcel = new rpc.MessageParcel();
let arr = [1, 2, 3, 4, 5]; let arr = [1, 2, 3, 4, 5];
let isWriteSuccess = parcel.writeRawData(arr, arr.length); let isWriteSuccess = parcel.writeRawData(arr, arr.length);
...@@ -5480,7 +5401,6 @@ Reads raw data from this **MessageParcel** object. ...@@ -5480,7 +5401,6 @@ Reads raw data from this **MessageParcel** object.
console.log("RpcTest: parcel read raw data result is : " + result); console.log("RpcTest: parcel read raw data result is : " + result);
``` ```
## Parcelable<sup>9+</sup> ## Parcelable<sup>9+</sup>
Writes an object to a **MessageSequence** and reads it from the **MessageSequence** during IPC. Writes an object to a **MessageSequence** and reads it from the **MessageSequence** during IPC.
...@@ -5504,10 +5424,9 @@ Marshals this **Parcelable** object into a **MessageSequence** object. ...@@ -5504,10 +5424,9 @@ Marshals this **Parcelable** object into a **MessageSequence** object.
| Type | Description | | Type | Description |
| ------- | ----------------------------------------- | | ------- | ----------------------------------------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.| | boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
**Example** **Example**
``` ```ts
class MyParcelable { class MyParcelable {
num: number; num: number;
str: string; str: string;
...@@ -5535,7 +5454,6 @@ Marshals this **Parcelable** object into a **MessageSequence** object. ...@@ -5535,7 +5454,6 @@ Marshals this **Parcelable** object into a **MessageSequence** object.
console.log("RpcClient: readParcelable is " + result2); console.log("RpcClient: readParcelable is " + result2);
``` ```
### unmarshalling ### unmarshalling
unmarshalling(dataIn: MessageSequence): boolean unmarshalling(dataIn: MessageSequence): boolean
...@@ -5558,7 +5476,7 @@ Unmarshals this **Parcelable** object from a **MessageSequence** object. ...@@ -5558,7 +5476,7 @@ Unmarshals this **Parcelable** object from a **MessageSequence** object.
**Example** **Example**
``` ```ts
class MyParcelable { class MyParcelable {
num: number; num: number;
str: string; str: string;
...@@ -5586,7 +5504,6 @@ Unmarshals this **Parcelable** object from a **MessageSequence** object. ...@@ -5586,7 +5504,6 @@ Unmarshals this **Parcelable** object from a **MessageSequence** object.
console.log("RpcClient: readParcelable is " + result2); console.log("RpcClient: readParcelable is " + result2);
``` ```
## Sequenceable<sup>(deprecated)</sup> ## Sequenceable<sup>(deprecated)</sup>
>This class is no longer maintained since API version 9. You are advised to use the [Parcelable](#parcelable9). >This class is no longer maintained since API version 9. You are advised to use the [Parcelable](#parcelable9).
...@@ -5612,10 +5529,9 @@ Marshals the sequenceable object into a **MessageParcel** object. ...@@ -5612,10 +5529,9 @@ Marshals the sequenceable object into a **MessageParcel** object.
| Type | Description | | Type | Description |
| ------- | ----------------------------------------- | | ------- | ----------------------------------------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.| | boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
**Example** **Example**
``` ```ts
class MySequenceable { class MySequenceable {
num: number; num: number;
str: string; str: string;
...@@ -5643,7 +5559,6 @@ Marshals the sequenceable object into a **MessageParcel** object. ...@@ -5643,7 +5559,6 @@ Marshals the sequenceable object into a **MessageParcel** object.
console.log("RpcClient: readSequenceable is " + result2); console.log("RpcClient: readSequenceable is " + result2);
``` ```
### unmarshalling ### unmarshalling
unmarshalling(dataIn: MessageParcel): boolean unmarshalling(dataIn: MessageParcel): boolean
...@@ -5666,7 +5581,7 @@ Unmarshals this sequenceable object from a **MessageParcel** object. ...@@ -5666,7 +5581,7 @@ Unmarshals this sequenceable object from a **MessageParcel** object.
**Example** **Example**
``` ```ts
class MySequenceable { class MySequenceable {
num: number; num: number;
str: string; str: string;
...@@ -5694,7 +5609,6 @@ Unmarshals this sequenceable object from a **MessageParcel** object. ...@@ -5694,7 +5609,6 @@ Unmarshals this sequenceable object from a **MessageParcel** object.
console.log("RpcClient: readSequenceable is " + result2); console.log("RpcClient: readSequenceable is " + result2);
``` ```
## IRemoteBroker ## IRemoteBroker
Provides the holder of a remote proxy object. Provides the holder of a remote proxy object.
...@@ -5715,17 +5629,38 @@ Obtains a proxy or remote object. This API must be implemented by its derived cl ...@@ -5715,17 +5629,38 @@ Obtains a proxy or remote object. This API must be implemented by its derived cl
**Example** **Example**
``` ```ts
class TestAbility extends rpc.RemoteObject { class TestAbility extends rpc.RemoteObject {
asObject() { asObject() {
return this; return this;
} }
} }
let remoteObject = new TestAbility().asObject();
``` ```
**Example** **Example**
``` ```ts
import FA from "@ohos.ability.featureAbility";
let proxy;
let connect = {
onConnect: function (elementName, remoteProxy) {
console.log("RpcClient: js onConnect called.");
proxy = remoteProxy;
},
onDisconnect: function (elementName) {
console.log("RpcClient: onDisconnect");
},
onFailed: function () {
console.log("RpcClient: onFailed");
}
};
let want = {
"bundleName": "com.ohos.server",
"abilityName": "com.ohos.server.EntryAbility",
};
FA.connectAbility(want, connect);
class TestProxy { class TestProxy {
remote: rpc.RemoteObject; remote: rpc.RemoteObject;
constructor(remote) { constructor(remote) {
...@@ -5735,6 +5670,8 @@ Obtains a proxy or remote object. This API must be implemented by its derived cl ...@@ -5735,6 +5670,8 @@ Obtains a proxy or remote object. This API must be implemented by its derived cl
return this.remote; return this.remote;
} }
} }
let iRemoteObject = new TestProxy(proxy).asObject();
``` ```
## DeathRecipient ## DeathRecipient
...@@ -5751,7 +5688,7 @@ Called to perform subsequent operations when a death notification of the remote ...@@ -5751,7 +5688,7 @@ Called to perform subsequent operations when a death notification of the remote
**Example** **Example**
``` ```ts
class MyDeathRecipient { class MyDeathRecipient {
onRemoteDied() { onRemoteDied() {
console.log("server died"); console.log("server died");
...@@ -5795,7 +5732,7 @@ Provides methods to query of obtain interface descriptors, add or delete death n ...@@ -5795,7 +5732,7 @@ Provides methods to query of obtain interface descriptors, add or delete death n
getLocalInterface(descriptor: string): IRemoteBroker getLocalInterface(descriptor: string): IRemoteBroker
Obtains the interface. Obtains the interface descriptor.
**System capability**: SystemCapability.Communication.IPC.Core **System capability**: SystemCapability.Communication.IPC.Core
...@@ -5817,7 +5754,7 @@ Obtains the interface. ...@@ -5817,7 +5754,7 @@ Obtains the interface.
queryLocalInterface(descriptor: string): IRemoteBroker queryLocalInterface(descriptor: string): IRemoteBroker
Obtains the interface. Queries the interface descriptor.
**System capability**: SystemCapability.Communication.IPC.Core **System capability**: SystemCapability.Communication.IPC.Core
...@@ -5833,7 +5770,6 @@ Obtains the interface. ...@@ -5833,7 +5770,6 @@ Obtains the interface.
| ------------- | --------------------------------------------- | | ------------- | --------------------------------------------- |
| IRemoteBroker | **IRemoteBroker** object bound to the specified interface token.| | IRemoteBroker | **IRemoteBroker** object bound to the specified interface token.|
### sendRequest<sup>(deprecated)</sup> ### sendRequest<sup>(deprecated)</sup>
>This API is no longer maintained since API version 9. You are advised to use [sendMessageRequest](#sendmessagerequest9). >This API is no longer maintained since API version 9. You are advised to use [sendMessageRequest](#sendmessagerequest9).
...@@ -5857,7 +5793,7 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch ...@@ -5857,7 +5793,7 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch
| Type | Description | | Type | Description |
| ------- | --------------------------------------------- | | ------- | --------------------------------------------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.| | boolean | Returns **true** if the message is sent successfully; returns **false** otherwise.|
### sendRequest<sup>8+(deprecated)</sup> ### sendRequest<sup>8+(deprecated)</sup>
...@@ -5928,7 +5864,6 @@ Sends a **MessageSequence** message to the remote process in synchronous or asyn ...@@ -5928,7 +5864,6 @@ Sends a **MessageSequence** message to the remote process in synchronous or asyn
| options | [MessageOption](#messageoption) | Yes | Request sending mode, which can be synchronous (default) or asynchronous. | | options | [MessageOption](#messageoption) | Yes | Request sending mode, which can be synchronous (default) or asynchronous. |
| callback | AsyncCallback&lt;RequestResult&gt; | Yes | Callback for receiving the sending result. | | callback | AsyncCallback&lt;RequestResult&gt; | Yes | Callback for receiving the sending result. |
### sendRequest<sup>8+(deprecated)</sup> ### sendRequest<sup>8+(deprecated)</sup>
>This API is no longer maintained since API version 9. You are advised to use [sendMessageRequest](#sendmessagerequest9). >This API is no longer maintained since API version 9. You are advised to use [sendMessageRequest](#sendmessagerequest9).
...@@ -5949,12 +5884,11 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch ...@@ -5949,12 +5884,11 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch
| options | [MessageOption](#messageoption) | Yes | Request sending mode, which can be synchronous (default) or asynchronous. | | options | [MessageOption](#messageoption) | Yes | Request sending mode, which can be synchronous (default) or asynchronous. |
| callback | AsyncCallback&lt;SendRequestResult&gt; | Yes | Callback for receiving the sending result. | | callback | AsyncCallback&lt;SendRequestResult&gt; | Yes | Callback for receiving the sending result. |
### registerDeathRecipient<sup>9+</sup> ### registerDeathRecipient<sup>9+</sup>
registerDeathRecipient(recipient: DeathRecipient, flags: number): void registerDeathRecipient(recipient: DeathRecipient, flags: number): void
Adds a callback for receiving death notifications of the remote object. This method is called if the remote object process matching the **RemoteProxy** object is killed. Registers a callback for receiving death notifications of the remote object. This method is called if the remote object process matching the **RemoteProxy** object is killed.
**System capability**: SystemCapability.Communication.IPC.Core **System capability**: SystemCapability.Communication.IPC.Core
...@@ -5962,7 +5896,7 @@ Adds a callback for receiving death notifications of the remote object. This met ...@@ -5962,7 +5896,7 @@ Adds a callback for receiving death notifications of the remote object. This met
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| --------- | --------------------------------- | ---- | -------------- | | --------- | --------------------------------- | ---- | -------------- |
| recipient | [DeathRecipient](#deathrecipient) | Yes | Callback to add.| | recipient | [DeathRecipient](#deathrecipient) | Yes | Callback to register.|
| flags | number | Yes | Flag of the death notification.| | flags | number | Yes | Flag of the death notification.|
**Error Code** **Error Code**
...@@ -5973,7 +5907,6 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode ...@@ -5973,7 +5907,6 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
| ------- | -------- | | ------- | -------- |
| 1900008 | proxy or remote object is invalid | | 1900008 | proxy or remote object is invalid |
### addDeathrecipient<sup>(deprecated)</sup> ### addDeathrecipient<sup>(deprecated)</sup>
>This API is no longer maintained since API version 9. You are advised to use [registerDeathRecipient](#registerdeathrecipient9). >This API is no longer maintained since API version 9. You are advised to use [registerDeathRecipient](#registerdeathrecipient9).
...@@ -5995,14 +5928,14 @@ Adds a callback for receiving death notifications of the remote object. This met ...@@ -5995,14 +5928,14 @@ Adds a callback for receiving death notifications of the remote object. This met
| Type | Description | | Type | Description |
| ------- | --------------------------------------------- | | ------- | --------------------------------------------- |
| boolean | Returns **true** if the callback is added successfully; returns **false** otherwise.| | boolean | Returns **true** if the callback is added successfully; return **false** otherwise.|
### unregisterDeathRecipient<sup>9+</sup> ### unregisterDeathRecipient<sup>9+</sup>
unregisterDeathRecipient(recipient: DeathRecipient, flags: number): void unregisterDeathRecipient(recipient: DeathRecipient, flags: number): void
Removes the callback used to receive death notifications of the remote object. Unregisters the callback used to receive death notifications of the remote object.
**System capability**: SystemCapability.Communication.IPC.Core **System capability**: SystemCapability.Communication.IPC.Core
...@@ -6010,7 +5943,7 @@ Removes the callback used to receive death notifications of the remote object. ...@@ -6010,7 +5943,7 @@ Removes the callback used to receive death notifications of the remote object.
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| --------- | --------------------------------- | ---- | -------------- | | --------- | --------------------------------- | ---- | -------------- |
| recipient | [DeathRecipient](#deathrecipient) | Yes | Callback to remove.| | recipient | [DeathRecipient](#deathrecipient) | Yes | Callback to unregister.|
| flags | number | Yes | Flag of the death notification.| | flags | number | Yes | Flag of the death notification.|
**Error Code** **Error Code**
...@@ -6021,7 +5954,6 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode ...@@ -6021,7 +5954,6 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
| ------- | -------- | | ------- | -------- |
| 1900008 | proxy or remote object is invalid | | 1900008 | proxy or remote object is invalid |
### removeDeathRecipient<sup>(deprecated)</sup> ### removeDeathRecipient<sup>(deprecated)</sup>
>This API is no longer maintained since API version 9. You are advised to use [unregisterDeathRecipient](#unregisterdeathrecipient9). >This API is no longer maintained since API version 9. You are advised to use [unregisterDeathRecipient](#unregisterdeathrecipient9).
...@@ -6043,8 +5975,7 @@ Removes the callback used to receive death notifications of the remote object. ...@@ -6043,8 +5975,7 @@ Removes the callback used to receive death notifications of the remote object.
| Type | Description | | Type | Description |
| ------- | --------------------------------------------- | | ------- | --------------------------------------------- |
| boolean | Returns **true** if the callback is removed successfully; returns **false** otherwise.| | boolean | Returns **true** if the callback is removed; returns **false** otherwise.|
### getDescriptor<sup>9+</sup> ### getDescriptor<sup>9+</sup>
...@@ -6115,7 +6046,6 @@ Provides APIs to implement **IRemoteObject**. ...@@ -6115,7 +6046,6 @@ Provides APIs to implement **IRemoteObject**.
| MIN_TRANSACTION_ID | 1 (0x00000001) | Minimum valid instruction code. | | MIN_TRANSACTION_ID | 1 (0x00000001) | Minimum valid instruction code. |
| MAX_TRANSACTION_ID | 16777215 (0x00FFFFFF) | Maximum valid instruction code. | | MAX_TRANSACTION_ID | 16777215 (0x00FFFFFF) | Maximum valid instruction code. |
### sendRequest<sup>(deprecated)</sup> ### sendRequest<sup>(deprecated)</sup>
>This API is no longer maintained since API version 9. You are advised to use [sendMessageRequest](#sendmessagerequest9). >This API is no longer maintained since API version 9. You are advised to use [sendMessageRequest](#sendmessagerequest9).
...@@ -6139,11 +6069,11 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch ...@@ -6139,11 +6069,11 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch
| Type | Description | | Type | Description |
| ------- | --------------------------------------------- | | ------- | --------------------------------------------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.| | boolean | Returns **true** if the message is sent successfully; returns **false** otherwise.|
**Example** **Example**
``` ```ts
import FA from "@ohos.ability.featureAbility"; import FA from "@ohos.ability.featureAbility";
let proxy; let proxy;
let connect = { let connect = {
...@@ -6160,7 +6090,7 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch ...@@ -6160,7 +6090,7 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch
}; };
let want = { let want = {
"bundleName": "com.ohos.server", "bundleName": "com.ohos.server",
"abilityName": "com.ohos.server.MainAbility", "abilityName": "com.ohos.server.EntryAbility",
}; };
FA.connectAbility(want, connect); FA.connectAbility(want, connect);
let option = new rpc.MessageOption(); let option = new rpc.MessageOption();
...@@ -6181,7 +6111,6 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch ...@@ -6181,7 +6111,6 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch
reply.reclaim(); reply.reclaim();
``` ```
### sendMessageRequest<sup>9+</sup> ### sendMessageRequest<sup>9+</sup>
sendMessageRequest(code: number, data: MessageSequence, reply: MessageSequence, options: MessageOption): Promise&lt;RequestResult&gt; sendMessageRequest(code: number, data: MessageSequence, reply: MessageSequence, options: MessageOption): Promise&lt;RequestResult&gt;
...@@ -6207,7 +6136,7 @@ Sends a **MessageSequence** message to the remote process in synchronous or asyn ...@@ -6207,7 +6136,7 @@ Sends a **MessageSequence** message to the remote process in synchronous or asyn
**Example** **Example**
``` ```ts
import FA from "@ohos.ability.featureAbility"; import FA from "@ohos.ability.featureAbility";
let proxy; let proxy;
let connect = { let connect = {
...@@ -6224,7 +6153,7 @@ Sends a **MessageSequence** message to the remote process in synchronous or asyn ...@@ -6224,7 +6153,7 @@ Sends a **MessageSequence** message to the remote process in synchronous or asyn
}; };
let want = { let want = {
"bundleName": "com.ohos.server", "bundleName": "com.ohos.server",
"abilityName": "com.ohos.server.MainAbility", "abilityName": "com.ohos.server.EntryAbility",
}; };
FA.connectAbility(want, connect); FA.connectAbility(want, connect);
let option = new rpc.MessageOption(); let option = new rpc.MessageOption();
...@@ -6251,7 +6180,6 @@ Sends a **MessageSequence** message to the remote process in synchronous or asyn ...@@ -6251,7 +6180,6 @@ Sends a **MessageSequence** message to the remote process in synchronous or asyn
}); });
``` ```
### sendRequest<sup>8+(deprecated)</sup> ### sendRequest<sup>8+(deprecated)</sup>
>This API is no longer maintained since API version 9. You are advised to use [sendMessageRequest](#sendmessagerequest9). >This API is no longer maintained since API version 9. You are advised to use [sendMessageRequest](#sendmessagerequest9).
...@@ -6279,7 +6207,7 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch ...@@ -6279,7 +6207,7 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch
**Example** **Example**
``` ```ts
import FA from "@ohos.ability.featureAbility"; import FA from "@ohos.ability.featureAbility";
let proxy; let proxy;
let connect = { let connect = {
...@@ -6296,7 +6224,7 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch ...@@ -6296,7 +6224,7 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch
}; };
let want = { let want = {
"bundleName": "com.ohos.server", "bundleName": "com.ohos.server",
"abilityName": "com.ohos.server.MainAbility", "abilityName": "com.ohos.server.EntryAbility",
}; };
FA.connectAbility(want, connect); FA.connectAbility(want, connect);
let option = new rpc.MessageOption(); let option = new rpc.MessageOption();
...@@ -6341,10 +6269,9 @@ Sends a **MessageSequence** message to the remote process in synchronous or asyn ...@@ -6341,10 +6269,9 @@ Sends a **MessageSequence** message to the remote process in synchronous or asyn
| options | [MessageOption](#messageoption) | Yes | Request sending mode, which can be synchronous (default) or asynchronous. | | options | [MessageOption](#messageoption) | Yes | Request sending mode, which can be synchronous (default) or asynchronous. |
| callback | AsyncCallback&lt;RequestResult&gt; | Yes | Callback for receiving the sending result. | | callback | AsyncCallback&lt;RequestResult&gt; | Yes | Callback for receiving the sending result. |
**Example** **Example**
``` ```ts
import FA from "@ohos.ability.featureAbility"; import FA from "@ohos.ability.featureAbility";
let proxy; let proxy;
let connect = { let connect = {
...@@ -6361,7 +6288,7 @@ Sends a **MessageSequence** message to the remote process in synchronous or asyn ...@@ -6361,7 +6288,7 @@ Sends a **MessageSequence** message to the remote process in synchronous or asyn
}; };
let want = { let want = {
"bundleName": "com.ohos.server", "bundleName": "com.ohos.server",
"abilityName": "com.ohos.server.MainAbility", "abilityName": "com.ohos.server.EntryAbility",
}; };
function sendRequestCallback(result) { function sendRequestCallback(result) {
if (result.errCode === 0) { if (result.errCode === 0) {
...@@ -6390,7 +6317,6 @@ Sends a **MessageSequence** message to the remote process in synchronous or asyn ...@@ -6390,7 +6317,6 @@ Sends a **MessageSequence** message to the remote process in synchronous or asyn
} }
``` ```
### sendRequest<sup>8+(deprecated)</sup> ### sendRequest<sup>8+(deprecated)</sup>
>This API is no longer maintained since API version 9. You are advised to use [sendMessageRequest](#sendmessagerequest9). >This API is no longer maintained since API version 9. You are advised to use [sendMessageRequest](#sendmessagerequest9).
...@@ -6413,7 +6339,7 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch ...@@ -6413,7 +6339,7 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch
**Example** **Example**
``` ```ts
import FA from "@ohos.ability.featureAbility"; import FA from "@ohos.ability.featureAbility";
let proxy; let proxy;
let connect = { let connect = {
...@@ -6430,7 +6356,7 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch ...@@ -6430,7 +6356,7 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch
}; };
let want = { let want = {
"bundleName": "com.ohos.server", "bundleName": "com.ohos.server",
"abilityName": "com.ohos.server.MainAbility", "abilityName": "com.ohos.server.EntryAbility",
}; };
function sendRequestCallback(result) { function sendRequestCallback(result) {
if (result.errCode === 0) { if (result.errCode === 0) {
...@@ -6454,7 +6380,6 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch ...@@ -6454,7 +6380,6 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch
proxy.sendRequest(1, data, reply, option, sendRequestCallback); proxy.sendRequest(1, data, reply, option, sendRequestCallback);
``` ```
### getLocalInterface<sup>9+</sup> ### getLocalInterface<sup>9+</sup>
getLocalInterface(interface: string): IRemoteBroker getLocalInterface(interface: string): IRemoteBroker
...@@ -6485,7 +6410,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode ...@@ -6485,7 +6410,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example** **Example**
``` ```ts
import FA from "@ohos.ability.featureAbility"; import FA from "@ohos.ability.featureAbility";
let proxy; let proxy;
let connect = { let connect = {
...@@ -6502,7 +6427,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode ...@@ -6502,7 +6427,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
}; };
let want = { let want = {
"bundleName":"com.ohos.server", "bundleName":"com.ohos.server",
"abilityName":"com.ohos.server.MainAbility", "abilityName":"com.ohos.server.EntryAbility",
}; };
FA.connectAbility(want, connect); FA.connectAbility(want, connect);
try { try {
...@@ -6514,7 +6439,6 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode ...@@ -6514,7 +6439,6 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
} }
``` ```
### queryLocalInterface<sup>(deprecated)</sup> ### queryLocalInterface<sup>(deprecated)</sup>
>This API is no longer maintained since API version 9. You are advised to use [getLocalInterface](#getlocalinterface9). >This API is no longer maintained since API version 9. You are advised to use [getLocalInterface](#getlocalinterface9).
...@@ -6539,7 +6463,7 @@ Obtains the **LocalInterface** object of an interface token. ...@@ -6539,7 +6463,7 @@ Obtains the **LocalInterface** object of an interface token.
**Example** **Example**
``` ```ts
import FA from "@ohos.ability.featureAbility"; import FA from "@ohos.ability.featureAbility";
let proxy; let proxy;
let connect = { let connect = {
...@@ -6556,19 +6480,18 @@ Obtains the **LocalInterface** object of an interface token. ...@@ -6556,19 +6480,18 @@ Obtains the **LocalInterface** object of an interface token.
}; };
let want = { let want = {
"bundleName":"com.ohos.server", "bundleName":"com.ohos.server",
"abilityName":"com.ohos.server.MainAbility", "abilityName":"com.ohos.server.EntryAbility",
}; };
FA.connectAbility(want, connect); FA.connectAbility(want, connect);
let broker = proxy.queryLocalInterface("testObject"); let broker = proxy.queryLocalInterface("testObject");
console.log("RpcClient: queryLocalInterface is " + broker); console.log("RpcClient: queryLocalInterface is " + broker);
``` ```
### registerDeathRecipient<sup>9+</sup> ### registerDeathRecipient<sup>9+</sup>
registerDeathRecipient(recipient: DeathRecipient, flags: number): void registerDeathRecipient(recipient: DeathRecipient, flags: number): void
Adds a callback for receiving death notifications of the remote object. This method is called if the remote object process matching the **RemoteProxy** object is killed. Registers a callback for receiving death notifications of the remote object. This method is called if the remote object process matching the **RemoteProxy** object is killed.
**System capability**: SystemCapability.Communication.IPC.Core **System capability**: SystemCapability.Communication.IPC.Core
...@@ -6576,7 +6499,7 @@ Adds a callback for receiving death notifications of the remote object. This met ...@@ -6576,7 +6499,7 @@ Adds a callback for receiving death notifications of the remote object. This met
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| --------- | --------------------------------- | ---- | -------------- | | --------- | --------------------------------- | ---- | -------------- |
| recipient | [DeathRecipient](#deathrecipient) | Yes | Callback to add.| | recipient | [DeathRecipient](#deathrecipient) | Yes | Callback to register.|
| flags | number | Yes | Flag of the death notification.| | flags | number | Yes | Flag of the death notification.|
**Error Code** **Error Code**
...@@ -6589,7 +6512,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode ...@@ -6589,7 +6512,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example** **Example**
``` ```ts
import FA from "@ohos.ability.featureAbility"; import FA from "@ohos.ability.featureAbility";
let proxy; let proxy;
let connect = { let connect = {
...@@ -6606,7 +6529,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode ...@@ -6606,7 +6529,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
}; };
let want = { let want = {
"bundleName": "com.ohos.server", "bundleName": "com.ohos.server",
"abilityName": "com.ohos.server.MainAbility", "abilityName": "com.ohos.server.EntryAbility",
}; };
FA.connectAbility(want, connect); FA.connectAbility(want, connect);
class MyDeathRecipient { class MyDeathRecipient {
...@@ -6623,7 +6546,6 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode ...@@ -6623,7 +6546,6 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
} }
``` ```
### addDeathRecippient<sup>(deprecated)</sup> ### addDeathRecippient<sup>(deprecated)</sup>
>This API is no longer maintained since API version 9. You are advised to use [registerDeathRecipient](#registerdeathrecipient9). >This API is no longer maintained since API version 9. You are advised to use [registerDeathRecipient](#registerdeathrecipient9).
...@@ -6645,11 +6567,11 @@ Adds a callback for receiving the death notifications of the remote object, incl ...@@ -6645,11 +6567,11 @@ Adds a callback for receiving the death notifications of the remote object, incl
| Type | Description | | Type | Description |
| ------- | --------------------------------------------- | | ------- | --------------------------------------------- |
| boolean | Returns **true** if the callback is added successfully; returns **false** otherwise.| | boolean | Returns **true** if the callback is added successfully; return **false** otherwise.|
**Example** **Example**
``` ```ts
import FA from "@ohos.ability.featureAbility"; import FA from "@ohos.ability.featureAbility";
let proxy; let proxy;
let connect = { let connect = {
...@@ -6666,7 +6588,7 @@ Adds a callback for receiving the death notifications of the remote object, incl ...@@ -6666,7 +6588,7 @@ Adds a callback for receiving the death notifications of the remote object, incl
}; };
let want = { let want = {
"bundleName": "com.ohos.server", "bundleName": "com.ohos.server",
"abilityName": "com.ohos.server.MainAbility", "abilityName": "com.ohos.server.EntryAbility",
}; };
FA.connectAbility(want, connect); FA.connectAbility(want, connect);
class MyDeathRecipient { class MyDeathRecipient {
...@@ -6682,7 +6604,7 @@ Adds a callback for receiving the death notifications of the remote object, incl ...@@ -6682,7 +6604,7 @@ Adds a callback for receiving the death notifications of the remote object, incl
unregisterDeathRecipient(recipient: DeathRecipient, flags: number): boolean unregisterDeathRecipient(recipient: DeathRecipient, flags: number): boolean
Removes the callback used to receive death notifications of the remote object. Unregisters the callback used to receive death notifications of the remote object.
**System capability**: SystemCapability.Communication.IPC.Core **System capability**: SystemCapability.Communication.IPC.Core
...@@ -6690,7 +6612,7 @@ Removes the callback used to receive death notifications of the remote object. ...@@ -6690,7 +6612,7 @@ Removes the callback used to receive death notifications of the remote object.
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| --------- | --------------------------------- | ---- | -------------- | | --------- | --------------------------------- | ---- | -------------- |
| recipient | [DeathRecipient](#deathrecipient) | Yes | Callback to remove.| | recipient | [DeathRecipient](#deathrecipient) | Yes | Callback to unregister.|
| flags | number | Yes | Flag of the death notification.| | flags | number | Yes | Flag of the death notification.|
**Error Code** **Error Code**
...@@ -6703,7 +6625,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode ...@@ -6703,7 +6625,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example** **Example**
``` ```ts
import FA from "@ohos.ability.featureAbility"; import FA from "@ohos.ability.featureAbility";
let proxy; let proxy;
let connect = { let connect = {
...@@ -6720,7 +6642,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode ...@@ -6720,7 +6642,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
}; };
let want = { let want = {
"bundleName": "com.ohos.server", "bundleName": "com.ohos.server",
"abilityName": "com.ohos.server.MainAbility", "abilityName": "com.ohos.server.EntryAbility",
}; };
FA.connectAbility(want, connect); FA.connectAbility(want, connect);
class MyDeathRecipient { class MyDeathRecipient {
...@@ -6738,7 +6660,6 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode ...@@ -6738,7 +6660,6 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
} }
``` ```
### removeDeathRecipient<sup>(deprecated)</sup> ### removeDeathRecipient<sup>(deprecated)</sup>
>This API is no longer maintained since API version 9. You are advised to use [unregisterDeathRecipient](#unregisterdeathrecipient9). >This API is no longer maintained since API version 9. You are advised to use [unregisterDeathRecipient](#unregisterdeathrecipient9).
...@@ -6760,11 +6681,11 @@ Removes the callback used to receive death notifications of the remote object. ...@@ -6760,11 +6681,11 @@ Removes the callback used to receive death notifications of the remote object.
| Type | Description | | Type | Description |
| ------- | --------------------------------------------- | | ------- | --------------------------------------------- |
| boolean | Returns **true** if the callback is removed successfully; returns **false** otherwise.| | boolean | Returns **true** if the callback is removed; returns **false** otherwise.|
**Example** **Example**
``` ```ts
import FA from "@ohos.ability.featureAbility"; import FA from "@ohos.ability.featureAbility";
let proxy; let proxy;
let connect = { let connect = {
...@@ -6781,7 +6702,7 @@ Removes the callback used to receive death notifications of the remote object. ...@@ -6781,7 +6702,7 @@ Removes the callback used to receive death notifications of the remote object.
}; };
let want = { let want = {
"bundleName": "com.ohos.server", "bundleName": "com.ohos.server",
"abilityName": "com.ohos.server.MainAbility", "abilityName": "com.ohos.server.EntryAbility",
}; };
FA.connectAbility(want, connect); FA.connectAbility(want, connect);
class MyDeathRecipient { class MyDeathRecipient {
...@@ -6794,7 +6715,6 @@ Removes the callback used to receive death notifications of the remote object. ...@@ -6794,7 +6715,6 @@ Removes the callback used to receive death notifications of the remote object.
proxy.removeDeathRecipient(deathRecipient, 0); proxy.removeDeathRecipient(deathRecipient, 0);
``` ```
### getDescriptor<sup>9+</sup> ### getDescriptor<sup>9+</sup>
getDescriptor(): string getDescriptor(): string
...@@ -6820,7 +6740,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode ...@@ -6820,7 +6740,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example** **Example**
``` ```ts
import FA from "@ohos.ability.featureAbility"; import FA from "@ohos.ability.featureAbility";
let proxy; let proxy;
let connect = { let connect = {
...@@ -6837,7 +6757,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode ...@@ -6837,7 +6757,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
}; };
let want = { let want = {
"bundleName": "com.ohos.server", "bundleName": "com.ohos.server",
"abilityName": "com.ohos.server.MainAbility", "abilityName": "com.ohos.server.EntryAbility",
}; };
FA.connectAbility(want, connect); FA.connectAbility(want, connect);
try { try {
...@@ -6849,7 +6769,6 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode ...@@ -6849,7 +6769,6 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
} }
``` ```
### getInterfaceDescriptor<sup>(deprecated)</sup> ### getInterfaceDescriptor<sup>(deprecated)</sup>
>This API is no longer maintained since API version 9. You are advised to use [getDescriptor](#getdescriptor9). >This API is no longer maintained since API version 9. You are advised to use [getDescriptor](#getdescriptor9).
...@@ -6868,7 +6787,7 @@ Obtains the interface descriptor of this proxy object. ...@@ -6868,7 +6787,7 @@ Obtains the interface descriptor of this proxy object.
**Example** **Example**
``` ```ts
import FA from "@ohos.ability.featureAbility"; import FA from "@ohos.ability.featureAbility";
let proxy; let proxy;
let connect = { let connect = {
...@@ -6885,14 +6804,13 @@ Obtains the interface descriptor of this proxy object. ...@@ -6885,14 +6804,13 @@ Obtains the interface descriptor of this proxy object.
}; };
let want = { let want = {
"bundleName": "com.ohos.server", "bundleName": "com.ohos.server",
"abilityName": "com.ohos.server.MainAbility", "abilityName": "com.ohos.server.EntryAbility",
}; };
FA.connectAbility(want, connect); FA.connectAbility(want, connect);
let descriptor = proxy.getInterfaceDescriptor(); let descriptor = proxy.getInterfaceDescriptor();
console.log("RpcClient: descriptor is " + descriptor); console.log("RpcClient: descriptor is " + descriptor);
``` ```
### isObjectDead ### isObjectDead
isObjectDead(): boolean isObjectDead(): boolean
...@@ -6909,7 +6827,7 @@ Checks whether the **RemoteObject** is dead. ...@@ -6909,7 +6827,7 @@ Checks whether the **RemoteObject** is dead.
**Example** **Example**
``` ```ts
import FA from "@ohos.ability.featureAbility"; import FA from "@ohos.ability.featureAbility";
let proxy; let proxy;
let connect = { let connect = {
...@@ -6926,14 +6844,13 @@ Checks whether the **RemoteObject** is dead. ...@@ -6926,14 +6844,13 @@ Checks whether the **RemoteObject** is dead.
}; };
let want = { let want = {
"bundleName": "com.ohos.server", "bundleName": "com.ohos.server",
"abilityName": "com.ohos.server.MainAbility", "abilityName": "com.ohos.server.EntryAbility",
}; };
FA.connectAbility(want, connect); FA.connectAbility(want, connect);
let isDead = proxy.isObjectDead(); let isDead = proxy.isObjectDead();
console.log("RpcClient: isObjectDead is " + isDead); console.log("RpcClient: isObjectDead is " + isDead);
``` ```
## MessageOption ## MessageOption
Provides common message options (flag and wait time). Use the specified flag to construct the **MessageOption** object. Provides common message options (flag and wait time). Use the specified flag to construct the **MessageOption** object.
...@@ -6963,6 +6880,16 @@ A constructor used to create a **MessageOption** object. ...@@ -6963,6 +6880,16 @@ A constructor used to create a **MessageOption** object.
| syncFlags | number | No | Call flag, which can be synchronous or asynchronous. The default value is **synchronous**.| | syncFlags | number | No | Call flag, which can be synchronous or asynchronous. The default value is **synchronous**.|
**Example**
```ts
class TestRemoteObject extends rpc.MessageOption {
constructor(async) {
super(async);
}
}
```
### constructor ### constructor
constructor(syncFlags?: number, waitTime?: number) constructor(syncFlags?: number, waitTime?: number)
...@@ -6978,7 +6905,15 @@ A constructor used to create a **MessageOption** object. ...@@ -6978,7 +6905,15 @@ A constructor used to create a **MessageOption** object.
| syncFlags | number | No | Call flag, which can be synchronous or asynchronous. The default value is **synchronous**. | | syncFlags | number | No | Call flag, which can be synchronous or asynchronous. The default value is **synchronous**. |
| waitTime | number | No | Maximum wait time for an RPC call. The default value is **TF_WAIT_TIME**.| | waitTime | number | No | Maximum wait time for an RPC call. The default value is **TF_WAIT_TIME**.|
**Example**
```ts
class TestRemoteObject extends rpc.MessageOption {
constructor(syncFlags,waitTime) {
super(syncFlags,waitTime);
}
}
```
### isAsync<sup>9+</sup> ### isAsync<sup>9+</sup>
isAsync(): boolean; isAsync(): boolean;
...@@ -6991,8 +6926,14 @@ Checks whether **SendMessageRequest** is called synchronously or asynchronously. ...@@ -6991,8 +6926,14 @@ Checks whether **SendMessageRequest** is called synchronously or asynchronously.
| Type | Description | | Type | Description |
| ------- | ------------------------------------ | | ------- | ------------------------------------ |
| boolean | Call mode obtained.| | boolean | Returns **true** if **SendMessageRequest** is called synchronously; returns **false** if **SendMessageRequest** is called asynchronously.|
**Example**
```ts
let option = new rpc.MessageOption();
let isAsync = option.isAsync();
```
### setAsync<sup>9+</sup> ### setAsync<sup>9+</sup>
...@@ -7002,6 +6943,13 @@ Sets whether **SendMessageRequest** is called synchronously or asynchronously. ...@@ -7002,6 +6943,13 @@ Sets whether **SendMessageRequest** is called synchronously or asynchronously.
**System capability**: SystemCapability.Communication.IPC.Core **System capability**: SystemCapability.Communication.IPC.Core
**Example**
```ts
let option = new rpc.MessageOption();
let setAsync = option.setAsync(true);
console.log("Set synchronization flag");
```
### getFlags ### getFlags
...@@ -7017,6 +6965,22 @@ Obtains the call flag, which can be synchronous or asynchronous. ...@@ -7017,6 +6965,22 @@ Obtains the call flag, which can be synchronous or asynchronous.
| ------ | ------------------------------------ | | ------ | ------------------------------------ |
| number | Call mode obtained.| | number | Call mode obtained.|
**Example**
```ts
try {
let option = new rpc.MessageOption();
console.info("create object successfully.");
let flog = option.getFlags();
console.info("run getFlags success, flog is " + flog);
option.setFlags(1)
console.info("run setFlags success");
let flog2 = option.getFlags();
console.info("run getFlags success, flog2 is " + flog2);
} catch (error) {
console.info("error " + error);
}
```
### setFlags ### setFlags
...@@ -7032,6 +6996,19 @@ Sets the call flag, which can be synchronous or asynchronous. ...@@ -7032,6 +6996,19 @@ Sets the call flag, which can be synchronous or asynchronous.
| ------ | ------ | ---- | ------------------------ | | ------ | ------ | ---- | ------------------------ |
| flags | number | Yes | Call flag to set.| | flags | number | Yes | Call flag to set.|
**Example**
```ts
try {
let option = new rpc.MessageOption();
option.setFlags(1)
console.info("run setFlags success");
let flog = option.getFlags();
console.info("run getFlags success, flog is " + flog);
} catch (error) {
console.info("error " + error);
}
```
### getWaitTime ### getWaitTime
...@@ -7047,6 +7024,20 @@ Obtains the maximum wait time for this RPC call. ...@@ -7047,6 +7024,20 @@ Obtains the maximum wait time for this RPC call.
| ------ | ----------------- | | ------ | ----------------- |
| number | Maximum wait time obtained.| | number | Maximum wait time obtained.|
**Example**
```ts
try {
let option = new rpc.MessageOption();
let time = option.getWaitTime();
console.info("run getWaitTime success");
option.setWaitTime(16);
let time2 = option.getWaitTime();
console.info("run getWaitTime success, time is " + time);
} catch (error) {
console.info("error " + error);
}
```
### setWaitTime ### setWaitTime
...@@ -7062,6 +7053,18 @@ Sets the maximum wait time for this RPC call. ...@@ -7062,6 +7053,18 @@ Sets the maximum wait time for this RPC call.
| -------- | ------ | ---- | --------------------- | | -------- | ------ | ---- | --------------------- |
| waitTime | number | Yes | Maximum wait time to set.| | waitTime | number | Yes | Maximum wait time to set.|
**Example**
```ts
try {
let option = new rpc.MessageOption();
option.setWaitTime(16);
let time = option.getWaitTime();
console.info("run getWaitTime success, time is " + time);
} catch (error) {
console.info("error " + error);
}
```
## IPCSkeleton ## IPCSkeleton
...@@ -7071,7 +7074,7 @@ Obtains IPC context information, including the UID and PID, local and remote dev ...@@ -7071,7 +7074,7 @@ Obtains IPC context information, including the UID and PID, local and remote dev
static getContextObject(): IRemoteObject static getContextObject(): IRemoteObject
Obtains the system capability manager. Obtains the system capability manager. This API is a static method.
**System capability**: SystemCapability.Communication.IPC.Core **System capability**: SystemCapability.Communication.IPC.Core
...@@ -7083,17 +7086,16 @@ Obtains the system capability manager. ...@@ -7083,17 +7086,16 @@ Obtains the system capability manager.
**Example** **Example**
``` ```ts
let samgr = rpc.IPCSkeleton.getContextObject(); let samgr = rpc.IPCSkeleton.getContextObject();
console.log("RpcServer: getContextObject result: " + samgr); console.log("RpcServer: getContextObject result: " + samgr);
``` ```
### getCallingPid ### getCallingPid
static getCallingPid(): number static getCallingPid(): number
Obtains the PID of the caller. This method is invoked by the **RemoteObject** object in the **onRemoteRequest** method. If this method is not invoked in the IPC context (**onRemoteRequest**), the PID of the process will be returned. Obtains the PID of the caller. This API is a static method, which is invoked by the **RemoteObject** object in the **onRemoteRequest** method. If this method is not invoked in the IPC context (**onRemoteRequest**), the PID of the process will be returned.
**System capability**: SystemCapability.Communication.IPC.Core **System capability**: SystemCapability.Communication.IPC.Core
...@@ -7105,7 +7107,7 @@ Obtains the PID of the caller. This method is invoked by the **RemoteObject** ob ...@@ -7105,7 +7107,7 @@ Obtains the PID of the caller. This method is invoked by the **RemoteObject** ob
**Example** **Example**
``` ```ts
class Stub extends rpc.RemoteObject { class Stub extends rpc.RemoteObject {
onRemoteMessageRequest(code, data, reply, option) { onRemoteMessageRequest(code, data, reply, option) {
let callerPid = rpc.IPCSkeleton.getCallingPid(); let callerPid = rpc.IPCSkeleton.getCallingPid();
...@@ -7115,12 +7117,11 @@ Obtains the PID of the caller. This method is invoked by the **RemoteObject** ob ...@@ -7115,12 +7117,11 @@ Obtains the PID of the caller. This method is invoked by the **RemoteObject** ob
} }
``` ```
### getCallingUid ### getCallingUid
static getCallingUid(): number static getCallingUid(): number
Obtains the UID of the caller. This method is invoked by the **RemoteObject** object in the **onRemoteRequest** method. If this method is not invoked in the IPC context (**onRemoteRequest**), the UID of the process will be returned. Obtains the UID of the caller. This API is a static method, which is invoked by the **RemoteObject** object in the **onRemoteRequest** method. If this method is not invoked in the IPC context (**onRemoteRequest**), the UID of the process will be returned.
**System capability**: SystemCapability.Communication.IPC.Core **System capability**: SystemCapability.Communication.IPC.Core
...@@ -7132,7 +7133,7 @@ Obtains the UID of the caller. This method is invoked by the **RemoteObject** ob ...@@ -7132,7 +7133,7 @@ Obtains the UID of the caller. This method is invoked by the **RemoteObject** ob
**Example** **Example**
``` ```ts
class Stub extends rpc.RemoteObject { class Stub extends rpc.RemoteObject {
onRemoteMessageRequest(code, data, reply, option) { onRemoteMessageRequest(code, data, reply, option) {
let callerUid = rpc.IPCSkeleton.getCallingUid(); let callerUid = rpc.IPCSkeleton.getCallingUid();
...@@ -7142,7 +7143,6 @@ Obtains the UID of the caller. This method is invoked by the **RemoteObject** ob ...@@ -7142,7 +7143,6 @@ Obtains the UID of the caller. This method is invoked by the **RemoteObject** ob
} }
``` ```
### getCallingTokenId<sup>8+</sup> ### getCallingTokenId<sup>8+</sup>
static getCallingTokenId(): number; static getCallingTokenId(): number;
...@@ -7151,16 +7151,15 @@ Obtains the caller's token ID, which is used to verify the caller identity. ...@@ -7151,16 +7151,15 @@ Obtains the caller's token ID, which is used to verify the caller identity.
**System capability**: SystemCapability.Communication.IPC.Core **System capability**: SystemCapability.Communication.IPC.Core
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------ | --------------------- | | ------ | --------------------- |
| number | Token ID of the caller obtained.| | number | Token ID of the caller obtained.|
**Example** **Example**
``` ```ts
class Stub extends rpc.RemoteObject { class Stub extends rpc.RemoteObject {
onRemoteMessageRequest(code, data, reply, option) { onRemoteMessageRequest(code, data, reply, option) {
let callerTokenId = rpc.IPCSkeleton.getCallingTokenId(); let callerTokenId = rpc.IPCSkeleton.getCallingTokenId();
...@@ -7187,7 +7186,7 @@ Obtains the ID of the device hosting the caller's process. ...@@ -7187,7 +7186,7 @@ Obtains the ID of the device hosting the caller's process.
**Example** **Example**
``` ```ts
class Stub extends rpc.RemoteObject { class Stub extends rpc.RemoteObject {
onRemoteMessageRequest(code, data, reply, option) { onRemoteMessageRequest(code, data, reply, option) {
let callerDeviceID = rpc.IPCSkeleton.getCallingDeviceID(); let callerDeviceID = rpc.IPCSkeleton.getCallingDeviceID();
...@@ -7197,12 +7196,11 @@ Obtains the ID of the device hosting the caller's process. ...@@ -7197,12 +7196,11 @@ Obtains the ID of the device hosting the caller's process.
} }
``` ```
### getLocalDeviceID ### getLocalDeviceID
static getLocalDeviceID(): string static getLocalDeviceID(): string
Obtains the local device ID. Obtains the local device ID. This API is a static method.
**System capability**: SystemCapability.Communication.IPC.Core **System capability**: SystemCapability.Communication.IPC.Core
...@@ -7214,7 +7212,7 @@ Obtains the local device ID. ...@@ -7214,7 +7212,7 @@ Obtains the local device ID.
**Example** **Example**
``` ```ts
class Stub extends rpc.RemoteObject { class Stub extends rpc.RemoteObject {
onRemoteMessageRequest(code, data, reply, option) { onRemoteMessageRequest(code, data, reply, option) {
let localDeviceID = rpc.IPCSkeleton.getLocalDeviceID(); let localDeviceID = rpc.IPCSkeleton.getLocalDeviceID();
...@@ -7224,12 +7222,11 @@ Obtains the local device ID. ...@@ -7224,12 +7222,11 @@ Obtains the local device ID.
} }
``` ```
### isLocalCalling ### isLocalCalling
static isLocalCalling(): boolean static isLocalCalling(): boolean
Checks whether the remote process is a process of the local device. Checks whether the remote process is a process of the local device. This API is a static method.
**System capability**: SystemCapability.Communication.IPC.Core **System capability**: SystemCapability.Communication.IPC.Core
...@@ -7241,7 +7238,7 @@ Checks whether the remote process is a process of the local device. ...@@ -7241,7 +7238,7 @@ Checks whether the remote process is a process of the local device.
**Example** **Example**
``` ```ts
class Stub extends rpc.RemoteObject { class Stub extends rpc.RemoteObject {
onRemoteMessageRequest(code, data, reply, option) { onRemoteMessageRequest(code, data, reply, option) {
let isLocalCalling = rpc.IPCSkeleton.isLocalCalling(); let isLocalCalling = rpc.IPCSkeleton.isLocalCalling();
...@@ -7251,12 +7248,11 @@ Checks whether the remote process is a process of the local device. ...@@ -7251,12 +7248,11 @@ Checks whether the remote process is a process of the local device.
} }
``` ```
### flushCmdBuffer<sup>9+</sup> ### flushCmdBuffer<sup>9+</sup>
static flushCmdBuffer(object: IRemoteObject): void static flushCmdBuffer(object: IRemoteObject): void
Flushes all suspended commands from the specified **RemoteProxy** to the corresponding **RemoteObject**. It is recommended that this method be called before any time-sensitive operation is performed. Flushes all suspended commands from the specified **RemoteProxy** to the corresponding **RemoteObject**. This API is a static method. It is recommended that this method be called before any time-sensitive operation is performed.
**System capability**: SystemCapability.Communication.IPC.Core **System capability**: SystemCapability.Communication.IPC.Core
...@@ -7269,7 +7265,7 @@ Flushes all suspended commands from the specified **RemoteProxy** to the corresp ...@@ -7269,7 +7265,7 @@ Flushes all suspended commands from the specified **RemoteProxy** to the corresp
**Example** **Example**
``` ```ts
class TestRemoteObject extends rpc.RemoteObject { class TestRemoteObject extends rpc.RemoteObject {
constructor(descriptor) { constructor(descriptor) {
super(descriptor); super(descriptor);
...@@ -7284,14 +7280,13 @@ Flushes all suspended commands from the specified **RemoteProxy** to the corresp ...@@ -7284,14 +7280,13 @@ Flushes all suspended commands from the specified **RemoteProxy** to the corresp
} }
``` ```
### flushCommands<sup>(deprecated)</sup> ### flushCommands<sup>(deprecated)</sup>
>This API is no longer maintained since API version 9. You are advised to use [flushCmdBuffer](#flushcmdbuffer9). >This API is no longer maintained since API version 9. You are advised to use [flushCmdBuffer](#flushcmdbuffer9).
static flushCommands(object: IRemoteObject): number static flushCommands(object: IRemoteObject): number
Flushes all suspended commands from the specified **RemoteProxy** to the corresponding **RemoteObject**. It is recommended that this method be called before any time-sensitive operation is performed. Flushes all suspended commands from the specified **RemoteProxy** to the corresponding **RemoteObject**. This API is a static method. It is recommended that this method be called before any time-sensitive operation is performed.
**System capability**: SystemCapability.Communication.IPC.Core **System capability**: SystemCapability.Communication.IPC.Core
...@@ -7309,7 +7304,7 @@ Flushes all suspended commands from the specified **RemoteProxy** to the corresp ...@@ -7309,7 +7304,7 @@ Flushes all suspended commands from the specified **RemoteProxy** to the corresp
**Example** **Example**
``` ```ts
class MyDeathRecipient { class MyDeathRecipient {
onRemoteDied() { onRemoteDied() {
console.log("server died"); console.log("server died");
...@@ -7338,7 +7333,7 @@ Flushes all suspended commands from the specified **RemoteProxy** to the corresp ...@@ -7338,7 +7333,7 @@ Flushes all suspended commands from the specified **RemoteProxy** to the corresp
static resetCallingIdentity(): string static resetCallingIdentity(): string
Changes the UID and PID of the remote user to the UID and PID of the local user. This method is used in scenarios such as identity authentication. Changes the UID and PID of the remote user to the UID and PID of the local user. This API is a static method. You can use it in scenarios such as identity authentication.
**System capability**: SystemCapability.Communication.IPC.Core **System capability**: SystemCapability.Communication.IPC.Core
...@@ -7350,7 +7345,7 @@ Changes the UID and PID of the remote user to the UID and PID of the local user. ...@@ -7350,7 +7345,7 @@ Changes the UID and PID of the remote user to the UID and PID of the local user.
**Example** **Example**
``` ```ts
class Stub extends rpc.RemoteObject { class Stub extends rpc.RemoteObject {
onRemoteMessageRequest(code, data, reply, option) { onRemoteMessageRequest(code, data, reply, option) {
let callingIdentity = rpc.IPCSkeleton.resetCallingIdentity(); let callingIdentity = rpc.IPCSkeleton.resetCallingIdentity();
...@@ -7365,7 +7360,7 @@ Changes the UID and PID of the remote user to the UID and PID of the local user. ...@@ -7365,7 +7360,7 @@ Changes the UID and PID of the remote user to the UID and PID of the local user.
static restoreCallingIdentity(identity: string): void static restoreCallingIdentity(identity: string): void
Changes the UID and PID of the remote user to the UID and PID of the local user. This method is used in scenarios such as identity authentication. Changes the UID and PID of the remote user to the UID and PID of the local user. This API is a static method. You can use it in scenarios such as identity authentication.
**System capability**: SystemCapability.Communication.IPC.Core **System capability**: SystemCapability.Communication.IPC.Core
...@@ -7377,7 +7372,7 @@ Changes the UID and PID of the remote user to the UID and PID of the local user. ...@@ -7377,7 +7372,7 @@ Changes the UID and PID of the remote user to the UID and PID of the local user.
**Example** **Example**
``` ```ts
class Stub extends rpc.RemoteObject { class Stub extends rpc.RemoteObject {
onRemoteMessageRequest(code, data, reply, option) { onRemoteMessageRequest(code, data, reply, option) {
let callingIdentity = null; let callingIdentity = null;
...@@ -7392,14 +7387,13 @@ Changes the UID and PID of the remote user to the UID and PID of the local user. ...@@ -7392,14 +7387,13 @@ Changes the UID and PID of the remote user to the UID and PID of the local user.
} }
``` ```
### setCallingIdentity<sup>(deprecated)</sup> ### setCallingIdentity<sup>(deprecated)</sup>
>This API is no longer maintained since API version 9. You are advised to use [restoreCallingIdentity](#restorecallingidentity9). >This API is no longer maintained since API version 9. You are advised to use [restoreCallingIdentity](#restorecallingidentity9).
static setCallingIdentity(identity: string): boolean static setCallingIdentity(identity: string): boolean
Restores the UID and PID of the remote user. It is usually called when the UID and PID of the remote user are required. The UID and PID of the remote user are returned by **resetCallingIdentity**. Restores the UID and PID of the remote user. This API is a static method. It is usually called when the UID and PID of the remote user are required. The UID and PID of the remote user are returned by **resetCallingIdentity**.
**System capability**: SystemCapability.Communication.IPC.Core **System capability**: SystemCapability.Communication.IPC.Core
...@@ -7417,7 +7411,7 @@ Restores the UID and PID of the remote user. It is usually called when the UID a ...@@ -7417,7 +7411,7 @@ Restores the UID and PID of the remote user. It is usually called when the UID a
**Example** **Example**
``` ```ts
class Stub extends rpc.RemoteObject { class Stub extends rpc.RemoteObject {
onRemoteMessageRequest(code, data, reply, option) { onRemoteMessageRequest(code, data, reply, option) {
let callingIdentity = null; let callingIdentity = null;
...@@ -7433,7 +7427,6 @@ Restores the UID and PID of the remote user. It is usually called when the UID a ...@@ -7433,7 +7427,6 @@ Restores the UID and PID of the remote user. It is usually called when the UID a
} }
``` ```
## RemoteObject ## RemoteObject
Provides methods to implement **RemoteObject**. The service provider must inherit from this class. Provides methods to implement **RemoteObject**. The service provider must inherit from this class.
...@@ -7476,11 +7469,11 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch ...@@ -7476,11 +7469,11 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch
| Type | Description | | Type | Description |
| ------- | --------------------------------------------- | | ------- | --------------------------------------------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.| | boolean | Returns **true** if the message is sent successfully; returns **false** otherwise.|
**Example** **Example**
``` ```ts
class MyDeathRecipient { class MyDeathRecipient {
onRemoteDied() { onRemoteDied() {
console.log("server died"); console.log("server died");
...@@ -7519,7 +7512,6 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch ...@@ -7519,7 +7512,6 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch
reply.reclaim(); reply.reclaim();
``` ```
### sendRequest<sup>8+(deprecated)</sup> ### sendRequest<sup>8+(deprecated)</sup>
>This API is no longer maintained since API version 9. You are advised to use [sendMessageRequest](#sendmessagerequest9). >This API is no longer maintained since API version 9. You are advised to use [sendMessageRequest](#sendmessagerequest9).
...@@ -7547,7 +7539,7 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch ...@@ -7547,7 +7539,7 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch
**Example** **Example**
``` ```ts
class MyDeathRecipient { class MyDeathRecipient {
onRemoteDied() { onRemoteDied() {
console.log("server died"); console.log("server died");
...@@ -7617,7 +7609,7 @@ Sends a **MessageSequence** message to the remote process in synchronous or asyn ...@@ -7617,7 +7609,7 @@ Sends a **MessageSequence** message to the remote process in synchronous or asyn
**Example** **Example**
``` ```ts
class TestRemoteObject extends rpc.RemoteObject { class TestRemoteObject extends rpc.RemoteObject {
constructor(descriptor) { constructor(descriptor) {
super(descriptor); super(descriptor);
...@@ -7648,7 +7640,6 @@ Sends a **MessageSequence** message to the remote process in synchronous or asyn ...@@ -7648,7 +7640,6 @@ Sends a **MessageSequence** message to the remote process in synchronous or asyn
}); });
``` ```
### sendMessageRequest<sup>9+</sup> ### sendMessageRequest<sup>9+</sup>
sendMessageRequest(code: number, data: MessageSequence, reply: MessageSequence, options: MessageOption, callback: AsyncCallback&lt;RequestResult&gt;): void sendMessageRequest(code: number, data: MessageSequence, reply: MessageSequence, options: MessageOption, callback: AsyncCallback&lt;RequestResult&gt;): void
...@@ -7669,7 +7660,7 @@ Sends a **MessageSequence** message to the remote process in synchronous or asyn ...@@ -7669,7 +7660,7 @@ Sends a **MessageSequence** message to the remote process in synchronous or asyn
**Example** **Example**
``` ```ts
class TestRemoteObject extends rpc.RemoteObject { class TestRemoteObject extends rpc.RemoteObject {
constructor(descriptor) { constructor(descriptor) {
super(descriptor); super(descriptor);
...@@ -7697,7 +7688,6 @@ Sends a **MessageSequence** message to the remote process in synchronous or asyn ...@@ -7697,7 +7688,6 @@ Sends a **MessageSequence** message to the remote process in synchronous or asyn
testRemoteObject.sendMessageRequest(1, data, reply, option, sendRequestCallback); testRemoteObject.sendMessageRequest(1, data, reply, option, sendRequestCallback);
``` ```
### sendRequest<sup>8+(deprecated)</sup> ### sendRequest<sup>8+(deprecated)</sup>
>This API is no longer maintained since API version 9. You are advised to use [sendMessageRequest](#sendmessagerequest9). >This API is no longer maintained since API version 9. You are advised to use [sendMessageRequest](#sendmessagerequest9).
...@@ -7720,7 +7710,7 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch ...@@ -7720,7 +7710,7 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch
**Example** **Example**
``` ```ts
class MyDeathRecipient { class MyDeathRecipient {
onRemoteDied() { onRemoteDied() {
console.log("server died"); console.log("server died");
...@@ -7762,7 +7752,6 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch ...@@ -7762,7 +7752,6 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch
testRemoteObject.sendRequest(1, data, reply, option, sendRequestCallback); testRemoteObject.sendRequest(1, data, reply, option, sendRequestCallback);
``` ```
### onRemoteRequest<sup>8+(deprecated)</sup> ### onRemoteRequest<sup>8+(deprecated)</sup>
>This API is no longer maintained since API version 9. You are advised to use [onRemoteMessageRequest](#onremotemessagerequest9). >This API is no longer maintained since API version 9. You are advised to use [onRemoteMessageRequest](#onremotemessagerequest9).
...@@ -7790,7 +7779,7 @@ Provides a response to **sendMessageRequest()**. The server processes the reques ...@@ -7790,7 +7779,7 @@ Provides a response to **sendMessageRequest()**. The server processes the reques
**Example** **Example**
```ets ```ts
class MyDeathRecipient { class MyDeathRecipient {
onRemoteDied() { onRemoteDied() {
console.log("server died"); console.log("server died");
...@@ -7847,12 +7836,12 @@ Provides a response to **sendMessageRequest()**. The server processes the reques ...@@ -7847,12 +7836,12 @@ Provides a response to **sendMessageRequest()**. The server processes the reques
| Type | Description | | Type | Description |
| ----------------- | ---------------------------------------------------------------------------------------------- | | ----------------- | ---------------------------------------------------------------------------------------------- |
| boolean | Returns a Boolean value if the request is processed synchronously in **onRemoteMessageRequest**. If the operation is successful, **true** is returned. Otherwise, **false** is returned.| | boolean | Returns a Boolean value if the request is processed synchronously in **onRemoteMessageRequest**. The value **true** means the operation is successful; the value **false** means the opposite.|
| Promise\<boolean> | Returns a promise object if the request is processed asynchronously in **onRemoteMessageRequest**. | | Promise\<boolean> | Returns a promise object if the request is processed asynchronously in **onRemoteMessageRequest**. |
**Example**: Overload **onRemoteMessageRequest** to process requests synchronously. **Example**: Overload **onRemoteMessageRequest** to process requests synchronously.
```ets ```ts
class TestRemoteObject extends rpc.RemoteObject { class TestRemoteObject extends rpc.RemoteObject {
constructor(descriptor) { constructor(descriptor) {
super(descriptor); super(descriptor);
...@@ -7872,7 +7861,7 @@ Provides a response to **sendMessageRequest()**. The server processes the reques ...@@ -7872,7 +7861,7 @@ Provides a response to **sendMessageRequest()**. The server processes the reques
**Example**: Overload **onRemoteMessageRequest** to process requests asynchronously. **Example**: Overload **onRemoteMessageRequest** to process requests asynchronously.
```ets ```ts
class TestRemoteObject extends rpc.RemoteObject { class TestRemoteObject extends rpc.RemoteObject {
constructor(descriptor) { constructor(descriptor) {
super(descriptor); super(descriptor);
...@@ -7895,7 +7884,7 @@ Provides a response to **sendMessageRequest()**. The server processes the reques ...@@ -7895,7 +7884,7 @@ Provides a response to **sendMessageRequest()**. The server processes the reques
**Example**: Overload **onRemoteMessageRequest** and **onRemoteRequest** to process requests synchronously. **Example**: Overload **onRemoteMessageRequest** and **onRemoteRequest** to process requests synchronously.
```ets ```ts
class TestRemoteObject extends rpc.RemoteObject { class TestRemoteObject extends rpc.RemoteObject {
constructor(descriptor) { constructor(descriptor) {
super(descriptor); super(descriptor);
...@@ -7926,7 +7915,7 @@ Provides a response to **sendMessageRequest()**. The server processes the reques ...@@ -7926,7 +7915,7 @@ Provides a response to **sendMessageRequest()**. The server processes the reques
**Example**: Overload **onRemoteMessageRequest** and **onRemoteRequest** to process requests asynchronously. **Example**: Overload **onRemoteMessageRequest** and **onRemoteRequest** to process requests asynchronously.
```ets ```ts
class TestRemoteObject extends rpc.RemoteObject { class TestRemoteObject extends rpc.RemoteObject {
constructor(descriptor) { constructor(descriptor) {
super(descriptor); super(descriptor);
...@@ -7957,7 +7946,6 @@ Provides a response to **sendMessageRequest()**. The server processes the reques ...@@ -7957,7 +7946,6 @@ Provides a response to **sendMessageRequest()**. The server processes the reques
} }
``` ```
### getCallingUid ### getCallingUid
getCallingUid(): number getCallingUid(): number
...@@ -7973,7 +7961,7 @@ Obtains the UID of the remote process. ...@@ -7973,7 +7961,7 @@ Obtains the UID of the remote process.
**Example** **Example**
``` ```ts
class TestRemoteObject extends rpc.RemoteObject { class TestRemoteObject extends rpc.RemoteObject {
constructor(descriptor) { constructor(descriptor) {
super(descriptor); super(descriptor);
...@@ -7999,7 +7987,7 @@ Obtains the PID of the remote process. ...@@ -7999,7 +7987,7 @@ Obtains the PID of the remote process.
**Example** **Example**
``` ```ts
class TestRemoteObject extends rpc.RemoteObject { class TestRemoteObject extends rpc.RemoteObject {
constructor(descriptor) { constructor(descriptor) {
super(descriptor); super(descriptor);
...@@ -8013,7 +8001,7 @@ Obtains the PID of the remote process. ...@@ -8013,7 +8001,7 @@ Obtains the PID of the remote process.
getLocalInterface(descriptor: string): IRemoteBroker getLocalInterface(descriptor: string): IRemoteBroker
Obtains the interface. Obtains the interface descriptor.
**System capability**: SystemCapability.Communication.IPC.Core **System capability**: SystemCapability.Communication.IPC.Core
...@@ -8032,7 +8020,7 @@ Obtains the interface. ...@@ -8032,7 +8020,7 @@ Obtains the interface.
**Example** **Example**
``` ```ts
class MyDeathRecipient { class MyDeathRecipient {
onRemoteDied() { onRemoteDied() {
console.log("server died"); console.log("server died");
...@@ -8057,7 +8045,6 @@ Obtains the interface. ...@@ -8057,7 +8045,6 @@ Obtains the interface.
} }
``` ```
### queryLocalInterface<sup>(deprecated)</sup> ### queryLocalInterface<sup>(deprecated)</sup>
>This API is no longer maintained since API version 9. You are advised to use [getLocalInterface](#getlocalinterface9). >This API is no longer maintained since API version 9. You are advised to use [getLocalInterface](#getlocalinterface9).
...@@ -8082,7 +8069,7 @@ Checks whether the remote object corresponding to the specified interface token ...@@ -8082,7 +8069,7 @@ Checks whether the remote object corresponding to the specified interface token
**Example** **Example**
``` ```ts
class MyDeathRecipient { class MyDeathRecipient {
onRemoteDied() { onRemoteDied() {
console.log("server died"); console.log("server died");
...@@ -8106,7 +8093,6 @@ Checks whether the remote object corresponding to the specified interface token ...@@ -8106,7 +8093,6 @@ Checks whether the remote object corresponding to the specified interface token
let broker = testRemoteObject.queryLocalInterface("testObject"); let broker = testRemoteObject.queryLocalInterface("testObject");
``` ```
### getDescriptor<sup>9+</sup> ### getDescriptor<sup>9+</sup>
getDescriptor(): string getDescriptor(): string
...@@ -8131,7 +8117,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode ...@@ -8131,7 +8117,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example** **Example**
``` ```ts
class MyDeathRecipient { class MyDeathRecipient {
onRemoteDied() { onRemoteDied() {
console.log("server died"); console.log("server died");
...@@ -8157,7 +8143,6 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode ...@@ -8157,7 +8143,6 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
console.log("RpcServer: descriptor is: " + descriptor); console.log("RpcServer: descriptor is: " + descriptor);
``` ```
### getInterfaceDescriptor<sup>(deprecated)</sup> ### getInterfaceDescriptor<sup>(deprecated)</sup>
>This API is no longer maintained since API version 9. You are advised to use [getDescriptor](#getdescriptor9). >This API is no longer maintained since API version 9. You are advised to use [getDescriptor](#getdescriptor9).
...@@ -8176,7 +8161,7 @@ Obtains the interface descriptor. ...@@ -8176,7 +8161,7 @@ Obtains the interface descriptor.
**Example** **Example**
``` ```ts
class MyDeathRecipient { class MyDeathRecipient {
onRemoteDied() { onRemoteDied() {
console.log("server died"); console.log("server died");
...@@ -8201,7 +8186,6 @@ Obtains the interface descriptor. ...@@ -8201,7 +8186,6 @@ Obtains the interface descriptor.
console.log("RpcServer: descriptor is: " + descriptor); console.log("RpcServer: descriptor is: " + descriptor);
``` ```
### modifyLocalInterface<sup>9+</sup> ### modifyLocalInterface<sup>9+</sup>
modifyLocalInterface(localInterface: IRemoteBroker, descriptor: string): void modifyLocalInterface(localInterface: IRemoteBroker, descriptor: string): void
...@@ -8217,10 +8201,9 @@ Binds an interface descriptor to an **IRemoteBroker** object. ...@@ -8217,10 +8201,9 @@ Binds an interface descriptor to an **IRemoteBroker** object.
| localInterface | IRemoteBroker | Yes | **IRemoteBroker** object. | | localInterface | IRemoteBroker | Yes | **IRemoteBroker** object. |
| descriptor | string | Yes | Interface descriptor.| | descriptor | string | Yes | Interface descriptor.|
**Example** **Example**
``` ```ts
class MyDeathRecipient { class MyDeathRecipient {
onRemoteDied() { onRemoteDied() {
console.log("server died"); console.log("server died");
...@@ -8267,7 +8250,7 @@ Binds an interface descriptor to an **IRemoteBroker** object. ...@@ -8267,7 +8250,7 @@ Binds an interface descriptor to an **IRemoteBroker** object.
**Example** **Example**
``` ```ts
class MyDeathRecipient { class MyDeathRecipient {
onRemoteDied() { onRemoteDied() {
console.log("server died"); console.log("server died");
...@@ -8294,15 +8277,14 @@ Binds an interface descriptor to an **IRemoteBroker** object. ...@@ -8294,15 +8277,14 @@ Binds an interface descriptor to an **IRemoteBroker** object.
let testRemoteObject = new TestRemoteObject("testObject"); let testRemoteObject = new TestRemoteObject("testObject");
``` ```
## Ashmem<sup>8+</sup> ## Ashmem<sup>8+</sup>
Provides methods related to anonymous shared memory objects, including creating, closing, mapping, and unmapping an **Ashmem** object, reading data from and writing data to an **Ashmem** object, obtaining the **Ashmem** size, and setting **Ashmem** protection. Provides methods related to anonymous shared memory objects, including creating, closing, mapping, and unmapping an **Ashmem** object, reading data from and writing data to an **Ashmem** object, obtaining the **Ashmem** size, and setting **Ashmem** protection.
The table below describes the protection types of the mapped memory.
**System capability**: SystemCapability.Communication.IPC.Core **System capability**: SystemCapability.Communication.IPC.Core
The table below describes the protection types of the mapped memory.
| Name | Value | Description | | Name | Value | Description |
| ---------- | --- | ------------------ | | ---------- | --- | ------------------ |
| PROT_EXEC | 4 | The mapped memory is executable. | | PROT_EXEC | 4 | The mapped memory is executable. |
...@@ -8310,12 +8292,11 @@ The table below describes the protection types of the mapped memory. ...@@ -8310,12 +8292,11 @@ The table below describes the protection types of the mapped memory.
| PROT_READ | 1 | The mapped memory is readable. | | PROT_READ | 1 | The mapped memory is readable. |
| PROT_WRITE | 2 | The mapped memory is writeable. | | PROT_WRITE | 2 | The mapped memory is writeable. |
### create<sup>9+</sup> ### create<sup>9+</sup>
static create(name: string, size: number): Ashmem static create(name: string, size: number): Ashmem
Creates an **Ashmem** object with the specified name and size. Creates an **Ashmem** object with the specified name and size. This API is a static method.
**System capability**: SystemCapability.Communication.IPC.Core **System capability**: SystemCapability.Communication.IPC.Core
...@@ -8332,10 +8313,9 @@ Creates an **Ashmem** object with the specified name and size. ...@@ -8332,10 +8313,9 @@ Creates an **Ashmem** object with the specified name and size.
| ------ | ---------------------------------------------- | | ------ | ---------------------------------------------- |
| Ashmem | Returns the **Ashmem** object if it is created successfully; returns null otherwise.| | Ashmem | Returns the **Ashmem** object if it is created successfully; returns null otherwise.|
**Example** **Example**
``` ```ts
let ashmem; let ashmem;
try { try {
ashmem = rpc.Ashmem.create("ashmem", 1024*1024); ashmem = rpc.Ashmem.create("ashmem", 1024*1024);
...@@ -8347,14 +8327,13 @@ Creates an **Ashmem** object with the specified name and size. ...@@ -8347,14 +8327,13 @@ Creates an **Ashmem** object with the specified name and size.
console.log("RpcTest: get ashemm by create : " + ashmem + " size is : " + size); console.log("RpcTest: get ashemm by create : " + ashmem + " size is : " + size);
``` ```
### createAshmem<sup>8+(deprecated)</sup> ### createAshmem<sup>8+(deprecated)</sup>
>This API is no longer maintained since API version 9. You are advised to use [create](#create9). >This API is no longer maintained since API version 9. You are advised to use [create](#create9).
static createAshmem(name: string, size: number): Ashmem static createAshmem(name: string, size: number): Ashmem
Creates an **Ashmem** object with the specified name and size. Creates an **Ashmem** object with the specified name and size. This API is a static method.
**System capability**: SystemCapability.Communication.IPC.Core **System capability**: SystemCapability.Communication.IPC.Core
...@@ -8373,18 +8352,17 @@ Creates an **Ashmem** object with the specified name and size. ...@@ -8373,18 +8352,17 @@ Creates an **Ashmem** object with the specified name and size.
**Example** **Example**
``` ```ts
let ashmem = rpc.Ashmem.createAshmem("ashmem", 1024*1024); let ashmem = rpc.Ashmem.createAshmem("ashmem", 1024*1024);
let size = ashmem.getAshmemSize(); let size = ashmem.getAshmemSize();
console.log("RpcTest: get ashemm by createAshmem : " + ashmem + " size is : " + size); console.log("RpcTest: get ashemm by createAshmem : " + ashmem + " size is : " + size);
``` ```
### create<sup>9+</sup> ### create<sup>9+</sup>
static create(ashmem: Ashmem): Ashmem static create(ashmem: Ashmem): Ashmem
Creates an **Ashmem** object by copying the file descriptor (FD) of an existing Ashmem object. The two **Ashmem** objects point to the same shared memory region. Creates an **Ashmem** object by copying the file descriptor of an existing **Ashmem** object. The two **Ashmem** objects point to the same shared memory region.
**System capability**: SystemCapability.Communication.IPC.Core **System capability**: SystemCapability.Communication.IPC.Core
...@@ -8403,7 +8381,7 @@ Creates an **Ashmem** object by copying the file descriptor (FD) of an existing ...@@ -8403,7 +8381,7 @@ Creates an **Ashmem** object by copying the file descriptor (FD) of an existing
**Example** **Example**
``` ```ts
let ashmem2; let ashmem2;
try { try {
let ashmem = rpc.Ashmem.create("ashmem", 1024*1024); let ashmem = rpc.Ashmem.create("ashmem", 1024*1024);
...@@ -8416,14 +8394,13 @@ Creates an **Ashmem** object by copying the file descriptor (FD) of an existing ...@@ -8416,14 +8394,13 @@ Creates an **Ashmem** object by copying the file descriptor (FD) of an existing
console.log("RpcTest: get ashemm by create : " + ashmem2 + " size is : " + size); console.log("RpcTest: get ashemm by create : " + ashmem2 + " size is : " + size);
``` ```
### createAshmemFromExisting<sup>8+(deprecated)</sup> ### createAshmemFromExisting<sup>8+(deprecated)</sup>
>This API is no longer maintained since API version 9. You are advised to use [create](#create9). >This API is no longer maintained since API version 9. You are advised to use [create](#create9).
static createAshmemFromExisting(ashmem: Ashmem): Ashmem static createAshmemFromExisting(ashmem: Ashmem): Ashmem
Creates an **Ashmem** object by copying the file descriptor (FD) of an existing Ashmem object. The two **Ashmem** objects point to the same shared memory region. Creates an **Ashmem** object by copying the file descriptor of an existing **Ashmem** object. The two **Ashmem** objects point to the same shared memory region.
**System capability**: SystemCapability.Communication.IPC.Core **System capability**: SystemCapability.Communication.IPC.Core
...@@ -8441,14 +8418,13 @@ Creates an **Ashmem** object by copying the file descriptor (FD) of an existing ...@@ -8441,14 +8418,13 @@ Creates an **Ashmem** object by copying the file descriptor (FD) of an existing
**Example** **Example**
``` ```ts
let ashmem = rpc.Ashmem.createAshmem("ashmem", 1024*1024); let ashmem = rpc.Ashmem.createAshmem("ashmem", 1024*1024);
let ashmem2 = rpc.Ashmem.createAshmemFromExisting(ashmem); let ashmem2 = rpc.Ashmem.createAshmemFromExisting(ashmem);
let size = ashmem2.getAshmemSize(); let size = ashmem2.getAshmemSize();
console.log("RpcTest: get ashemm by createAshmemFromExisting : " + ashmem2 + " size is : " + size); console.log("RpcTest: get ashemm by createAshmemFromExisting : " + ashmem2 + " size is : " + size);
``` ```
### closeAshmem<sup>8+</sup> ### closeAshmem<sup>8+</sup>
closeAshmem(): void closeAshmem(): void
...@@ -8459,12 +8435,11 @@ Closes this **Ashmem** object. ...@@ -8459,12 +8435,11 @@ Closes this **Ashmem** object.
**Example** **Example**
``` ```ts
let ashmem = rpc.Ashmem.create("ashmem", 1024*1024); let ashmem = rpc.Ashmem.create("ashmem", 1024*1024);
ashmem.closeAshmem(); ashmem.closeAshmem();
``` ```
### unmapAshmem<sup>8+</sup> ### unmapAshmem<sup>8+</sup>
unmapAshmem(): void unmapAshmem(): void
...@@ -8475,12 +8450,11 @@ Deletes the mappings for the specified address range of this **Ashmem** object. ...@@ -8475,12 +8450,11 @@ Deletes the mappings for the specified address range of this **Ashmem** object.
**Example** **Example**
``` ```ts
let ashmem = rpc.Ashmem.create("ashmem", 1024*1024); let ashmem = rpc.Ashmem.create("ashmem", 1024*1024);
ashmem.unmapAshmem(); ashmem.unmapAshmem();
``` ```
### getAshmemSize<sup>8+</sup> ### getAshmemSize<sup>8+</sup>
getAshmemSize(): number getAshmemSize(): number
...@@ -8497,13 +8471,12 @@ Obtains the memory size of this **Ashmem** object. ...@@ -8497,13 +8471,12 @@ Obtains the memory size of this **Ashmem** object.
**Example** **Example**
``` ```ts
let ashmem = rpc.Ashmem.createAshmem("ashmem", 1024*1024); let ashmem = rpc.Ashmem.createAshmem("ashmem", 1024*1024);
let size = ashmem.getAshmemSize(); let size = ashmem.getAshmemSize();
console.log("RpcTest: get ashmem is " + ashmem + " size is : " + size); console.log("RpcTest: get ashmem is " + ashmem + " size is : " + size);
``` ```
### mapTypedAshmem<sup>9+</sup> ### mapTypedAshmem<sup>9+</sup>
mapTypedAshmem(mapType: number): void mapTypedAshmem(mapType: number): void
...@@ -8528,7 +8501,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode ...@@ -8528,7 +8501,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example** **Example**
``` ```ts
let ashmem = rpc.Ashmem.create("ashmem", 1024*1024); let ashmem = rpc.Ashmem.create("ashmem", 1024*1024);
try { try {
ashmem.mapTypedAshmem(ashmem.PROT_READ | ashmem.PROT_WRITE); ashmem.mapTypedAshmem(ashmem.PROT_READ | ashmem.PROT_WRITE);
...@@ -8538,7 +8511,6 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode ...@@ -8538,7 +8511,6 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
} }
``` ```
### mapAshmem<sup>8+(deprecated)</sup> ### mapAshmem<sup>8+(deprecated)</sup>
>This API is no longer maintained since API version 9. You are advised to use [mapTypedAshmem](#maptypedashmem9). >This API is no longer maintained since API version 9. You are advised to use [mapTypedAshmem](#maptypedashmem9).
...@@ -8559,17 +8531,16 @@ Creates the shared file mapping on the virtual address space of this process. Th ...@@ -8559,17 +8531,16 @@ Creates the shared file mapping on the virtual address space of this process. Th
| Type | Description | | Type | Description |
| ------- | ----------------------------------------- | | ------- | ----------------------------------------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.| | boolean | Returns **true** if the mapping is created; returns **false** otherwise.|
**Example** **Example**
``` ```ts
let ashmem = rpc.Ashmem.createAshmem("ashmem", 1024*1024); let ashmem = rpc.Ashmem.createAshmem("ashmem", 1024*1024);
let mapReadAndWrite = ashmem.mapAshmem(ashmem.PROT_READ | ashmem.PROT_WRITE); let mapReadAndWrite = ashmem.mapAshmem(ashmem.PROT_READ | ashmem.PROT_WRITE);
console.log("RpcTest: map ashmem result is : " + mapReadAndWrite); console.log("RpcTest: map ashmem result is : " + mapReadAndWrite);
``` ```
### mapReadWriteAshmem<sup>9+</sup> ### mapReadWriteAshmem<sup>9+</sup>
mapReadWriteAshmem(): void mapReadWriteAshmem(): void
...@@ -8588,7 +8559,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode ...@@ -8588,7 +8559,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example** **Example**
``` ```ts
let ashmem = rpc.Ashmem.create("ashmem", 1024*1024); let ashmem = rpc.Ashmem.create("ashmem", 1024*1024);
try { try {
ashmem.mapReadWriteAshmem(); ashmem.mapReadWriteAshmem();
...@@ -8598,7 +8569,6 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode ...@@ -8598,7 +8569,6 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
} }
``` ```
### mapReadAndWriteAshmem<sup>8+(deprecated)</sup> ### mapReadAndWriteAshmem<sup>8+(deprecated)</sup>
>This API is no longer maintained since API version 9. You are advised to use [mapReadWriteAshmem](#mapreadwriteashmem9). >This API is no longer maintained since API version 9. You are advised to use [mapReadWriteAshmem](#mapreadwriteashmem9).
...@@ -8613,17 +8583,16 @@ Maps the shared file to the readable and writable virtual address space of the p ...@@ -8613,17 +8583,16 @@ Maps the shared file to the readable and writable virtual address space of the p
| Type | Description | | Type | Description |
| ------- | ----------------------------------------- | | ------- | ----------------------------------------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.| | boolean | Returns **true** if the mapping is created; returns **false** otherwise.|
**Example** **Example**
``` ```ts
let ashmem = rpc.Ashmem.createAshmem("ashmem", 1024*1024); let ashmem = rpc.Ashmem.createAshmem("ashmem", 1024*1024);
let mapResult = ashmem.mapReadAndWriteAshmem(); let mapResult = ashmem.mapReadAndWriteAshmem();
console.log("RpcTest: map ashmem result is : " + mapResult); console.log("RpcTest: map ashmem result is : " + mapResult);
``` ```
### mapReadonlyAshmem<sup>9+</sup> ### mapReadonlyAshmem<sup>9+</sup>
mapReadonlyAshmem(): void mapReadonlyAshmem(): void
...@@ -8642,7 +8611,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode ...@@ -8642,7 +8611,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example** **Example**
``` ```ts
let ashmem = rpc.Ashmem.create("ashmem", 1024*1024); let ashmem = rpc.Ashmem.create("ashmem", 1024*1024);
try { try {
ashmem.mapReadonlyAshmem(); ashmem.mapReadonlyAshmem();
...@@ -8652,7 +8621,6 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode ...@@ -8652,7 +8621,6 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
} }
``` ```
### mapReadOnlyAshmem<sup>8+(deprecated)</sup> ### mapReadOnlyAshmem<sup>8+(deprecated)</sup>
>This API is no longer maintained since API version 9. You are advised to use [mapReadonlyAshmem](#mapreadonlyashmem9). >This API is no longer maintained since API version 9. You are advised to use [mapReadonlyAshmem](#mapreadonlyashmem9).
...@@ -8667,17 +8635,16 @@ Maps the shared file to the read-only virtual address space of the process. ...@@ -8667,17 +8635,16 @@ Maps the shared file to the read-only virtual address space of the process.
| Type | Description | | Type | Description |
| ------- | ----------------------------------------- | | ------- | ----------------------------------------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.| | boolean | Returns **true** if the mapping is created; returns **false** otherwise.|
**Example** **Example**
``` ```ts
let ashmem = rpc.Ashmem.createAshmem("ashmem", 1024*1024); let ashmem = rpc.Ashmem.createAshmem("ashmem", 1024*1024);
let mapResult = ashmem.mapReadOnlyAshmem(); let mapResult = ashmem.mapReadOnlyAshmem();
console.log("RpcTest: Ashmem mapReadOnlyAshmem result is : " + mapResult); console.log("RpcTest: Ashmem mapReadOnlyAshmem result is : " + mapResult);
``` ```
### setProtectionType<sup>9+</sup> ### setProtectionType<sup>9+</sup>
setProtectionType(protectionType: number): void setProtectionType(protectionType: number): void
...@@ -8702,7 +8669,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode ...@@ -8702,7 +8669,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example** **Example**
``` ```ts
let ashmem = rpc.Ashmem.create("ashmem", 1024*1024); let ashmem = rpc.Ashmem.create("ashmem", 1024*1024);
try { try {
ashmem.setProtection(ashmem.PROT_READ); ashmem.setProtection(ashmem.PROT_READ);
...@@ -8712,7 +8679,6 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode ...@@ -8712,7 +8679,6 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
} }
``` ```
### setProtection<sup>8+(deprecated)</sup> ### setProtection<sup>8+(deprecated)</sup>
>This API is no longer maintained since API version 9. You are advised to use [setProtectionType](#setprotectiontype9). >This API is no longer maintained since API version 9. You are advised to use [setProtectionType](#setprotectiontype9).
...@@ -8737,13 +8703,12 @@ Sets the protection level of the memory region to which the shared file is mappe ...@@ -8737,13 +8703,12 @@ Sets the protection level of the memory region to which the shared file is mappe
**Example** **Example**
``` ```ts
let ashmem = rpc.Ashmem.createAshmem("ashmem", 1024*1024); let ashmem = rpc.Ashmem.createAshmem("ashmem", 1024*1024);
let result = ashmem.setProtection(ashmem.PROT_READ); let result = ashmem.setProtection(ashmem.PROT_READ);
console.log("RpcTest: Ashmem setProtection result is : " + result); console.log("RpcTest: Ashmem setProtection result is : " + result);
``` ```
### writeAshmem<sup>9+</sup> ### writeAshmem<sup>9+</sup>
writeAshmem(buf: number[], size: number, offset: number): void writeAshmem(buf: number[], size: number, offset: number): void
...@@ -8770,7 +8735,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode ...@@ -8770,7 +8735,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example** **Example**
``` ```ts
let ashmem = rpc.Ashmem.create("ashmem", 1024*1024); let ashmem = rpc.Ashmem.create("ashmem", 1024*1024);
ashmem.mapReadWriteAshmem(); ashmem.mapReadWriteAshmem();
var ByteArrayVar = [1, 2, 3, 4, 5]; var ByteArrayVar = [1, 2, 3, 4, 5];
...@@ -8782,7 +8747,6 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode ...@@ -8782,7 +8747,6 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
} }
``` ```
### writeToAshmem<sup>8+(deprecated)</sup> ### writeToAshmem<sup>8+(deprecated)</sup>
>This API is no longer maintained since API version 9. You are advised to use [writeAshmem](#writeashmem9). >This API is no longer maintained since API version 9. You are advised to use [writeAshmem](#writeashmem9).
...@@ -8805,11 +8769,11 @@ Writes data to the shared file associated with this **Ashmem** object. ...@@ -8805,11 +8769,11 @@ Writes data to the shared file associated with this **Ashmem** object.
| Type | Description | | Type | Description |
| ------- | ----------------------------------------------------------------------------------------- | | ------- | ----------------------------------------------------------------------------------------- |
| boolean | Returns **true** is the data is written successfully; returns **false** otherwise.| | boolean | Returns **true** if the data is written successfully; returns **false** otherwise.|
**Example** **Example**
``` ```ts
let ashmem = rpc.Ashmem.createAshmem("ashmem", 1024*1024); let ashmem = rpc.Ashmem.createAshmem("ashmem", 1024*1024);
let mapResult = ashmem.mapReadAndWriteAshmem(); let mapResult = ashmem.mapReadAndWriteAshmem();
console.info("RpcTest map ashmem result is " + mapResult); console.info("RpcTest map ashmem result is " + mapResult);
...@@ -8818,7 +8782,6 @@ Writes data to the shared file associated with this **Ashmem** object. ...@@ -8818,7 +8782,6 @@ Writes data to the shared file associated with this **Ashmem** object.
console.log("RpcTest: write to Ashmem result is : " + writeResult); console.log("RpcTest: write to Ashmem result is : " + writeResult);
``` ```
### readAshmem<sup>9+</sup> ### readAshmem<sup>9+</sup>
readAshmem(size: number, offset: number): number[] readAshmem(size: number, offset: number): number[]
...@@ -8850,7 +8813,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode ...@@ -8850,7 +8813,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example** **Example**
``` ```ts
let ashmem = rpc.Ashmem.create("ashmem", 1024*1024); let ashmem = rpc.Ashmem.create("ashmem", 1024*1024);
ashmem.mapReadWriteAshmem(); ashmem.mapReadWriteAshmem();
var ByteArrayVar = [1, 2, 3, 4, 5]; var ByteArrayVar = [1, 2, 3, 4, 5];
...@@ -8864,7 +8827,6 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode ...@@ -8864,7 +8827,6 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
} }
``` ```
### readFromAshmem<sup>8+(deprecated)</sup> ### readFromAshmem<sup>8+(deprecated)</sup>
>This API is no longer maintained since API version 9. You are advised to use [readAshmem](#readashmem9). >This API is no longer maintained since API version 9. You are advised to use [readAshmem](#readashmem9).
...@@ -8890,7 +8852,7 @@ Reads data from the shared file associated with this **Ashmem** object. ...@@ -8890,7 +8852,7 @@ Reads data from the shared file associated with this **Ashmem** object.
**Example** **Example**
``` ```ts
let ashmem = rpc.Ashmem.createAshmem("ashmem", 1024*1024); let ashmem = rpc.Ashmem.createAshmem("ashmem", 1024*1024);
let mapResult = ashmem.mapReadAndWriteAshmem(); let mapResult = ashmem.mapReadAndWriteAshmem();
console.info("RpcTest map ashmem result is " + mapResult); console.info("RpcTest map ashmem result is " + mapResult);
...@@ -8899,4 +8861,5 @@ Reads data from the shared file associated with this **Ashmem** object. ...@@ -8899,4 +8861,5 @@ Reads data from the shared file associated with this **Ashmem** object.
console.log("RpcTest: write to Ashmem result is : " + writeResult); console.log("RpcTest: write to Ashmem result is : " + writeResult);
let readResult = ashmem.readFromAshmem(5, 0); let readResult = ashmem.readFromAshmem(5, 0);
console.log("RpcTest: read to Ashmem result is : " + readResult); console.log("RpcTest: read to Ashmem result is : " + readResult);
``` ```
# tagSession # tagSession (Standard NFC Tag Session)
The **tagSession** module provides common APIs for establishing connections and transferring data. The **tagSession** module provides common APIs for establishing connections and transferring data.
...@@ -26,9 +26,12 @@ getTagInfo(): tag.TagInfo ...@@ -26,9 +26,12 @@ getTagInfo(): tag.TagInfo
Obtains the **tagInfo** object provided by the NFC service when the tag is dispatched. Obtains the **tagInfo** object provided by the NFC service when the tag is dispatched.
> **NOTE**
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [tag.getTagInfo](js-apis-nfcTag.md#taggettaginfo9).
**Required permissions**: ohos.permission.NFC_TAG **Required permissions**: ohos.permission.NFC_TAG
**System capability**: SystemCapability.Communication.NFC.Core **System capability**: SystemCapability.Communication.NFC.Tag
**Return value** **Return value**
...@@ -54,9 +57,12 @@ connectTag(): boolean; ...@@ -54,9 +57,12 @@ connectTag(): boolean;
Connects to this tag. Call this API to set up a connection before reading data from or writing data to a tag. Connects to this tag. Call this API to set up a connection before reading data from or writing data to a tag.
> **NOTE**
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [tagSession.connect](#tagsessionconnect9).
**Required permissions**: ohos.permission.NFC_TAG **Required permissions**: ohos.permission.NFC_TAG
**System capability**: SystemCapability.Communication.NFC.Core **System capability**: SystemCapability.Communication.NFC.Tag
**Return value** **Return value**
...@@ -76,15 +82,52 @@ let connectStatus = tag.getIsoDep(tagInfo).connectTag(); ...@@ -76,15 +82,52 @@ let connectStatus = tag.getIsoDep(tagInfo).connectTag();
console.log("connectStatus: " + connectStatus); console.log("connectStatus: " + connectStatus);
``` ```
### tagSession.connect<sup>9+</sup>
connect(): void;
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
**System capability**: SystemCapability.Communication.NFC.Tag
**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**
```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.
try {
tag.getIsoDep(tagInfo).connect();
console.log("tag connect success");
} catch (busiError) {
console.log("tag connect busiError: " + busiError);
}
```
### tagSession.reset() ### tagSession.reset()
reset(): void reset(): void
Resets the connection to this tag. Resets the connection to this tag.
> **NOTE**
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [tagSession.resetConnection](#tagsessionresetconnection9).
**Required permissions**: ohos.permission.NFC_TAG **Required permissions**: ohos.permission.NFC_TAG
**System capability**: SystemCapability.Communication.NFC.Core **System capability**: SystemCapability.Communication.NFC.Tag
**Example** **Example**
...@@ -97,15 +140,52 @@ import tag from '@ohos.nfc.tag'; ...@@ -97,15 +140,52 @@ import tag from '@ohos.nfc.tag';
tag.getIsoDep(tagInfo).reset(); tag.getIsoDep(tagInfo).reset();
``` ```
### tagSession.resetConnection()<sup>9+</sup>
resetConnection(): void
Resets the connection to this tag.
**Required permissions**: ohos.permission.NFC_TAG
**System capability**: SystemCapability.Communication.NFC.Tag
**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**
```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.
try {
tag.getIsoDep(tagInfo).resetConnection();
console.log("tag resetConnection success");
} catch (busiError) {
console.log("tag resetConnection busiError: " + busiError);
}
```
### tagSession.isTagConnected ### tagSession.isTagConnected
isTagConnected(): boolean isTagConnected(): boolean
Checks whether the tag is connected. Checks whether the tag is connected.
> **NOTE**
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [tagSession.isConnected](#tagsessionisconnected9).
**Required permissions**: ohos.permission.NFC_TAG **Required permissions**: ohos.permission.NFC_TAG
**System capability**: SystemCapability.Communication.NFC.Core **System capability**: SystemCapability.Communication.NFC.Tag
**Return value** **Return value**
...@@ -125,15 +205,50 @@ let isTagConnected = tag.getIsoDep(tagInfo).isTagConnected(); ...@@ -125,15 +205,50 @@ let isTagConnected = tag.getIsoDep(tagInfo).isTagConnected();
console.log("isTagConnected: " + isTagConnected); console.log("isTagConnected: " + isTagConnected);
``` ```
### tagSession.isConnected<sup>9+</sup>
isConnected(): boolean
Checks whether the tag is connected.
**Required permissions**: ohos.permission.NFC_TAG
**System capability**: SystemCapability.Communication.NFC.Tag
**Return value**
| **Type**| **Description** |
| ------------------ | --------------------------|
| boolean | Returns **true** if the tag is connected; 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.
try {
var isConnected = tag.getIsoDep(tagInfo).isConnected();
console.log("tag isConnected = " + isConnected);
} catch (busiError) {
console.log("tag isConnected busiError: " + busiError);
}
```
### tagSession.getMaxSendLength ### tagSession.getMaxSendLength
getMaxSendLength(): number getMaxSendLength(): number
Obtains the maximum length of the data that can be sent to this tag. Obtains the maximum length of the data that can be sent to this tag.
> **NOTE**
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [tagSession.getMaxTransmitSize](#tagsessiongetmaxtransmitsize9).
**Required permissions**: ohos.permission.NFC_TAG **Required permissions**: ohos.permission.NFC_TAG
**System capability**: SystemCapability.Communication.NFC.Core **System capability**: SystemCapability.Communication.NFC.Tag
**Return value** **Return value**
...@@ -152,15 +267,57 @@ let maxSendLen = tag.getIsoDep(tagInfo).getMaxSendLength(); ...@@ -152,15 +267,57 @@ let maxSendLen = tag.getIsoDep(tagInfo).getMaxSendLength();
console.log("tag maxSendLen: " + maxSendLen); console.log("tag maxSendLen: " + maxSendLen);
``` ```
### tagSession.getMaxTransmitSize<sup>9+</sup>
getMaxTransmitSize(): number
Obtains the maximum length of the data that can be sent to this tag.
**Required permissions**: ohos.permission.NFC_TAG
**System capability**: SystemCapability.Communication.NFC.Tag
**Return value**
| **Type**| **Description** |
| ------------------ | --------------------------|
| number | Maximum data length obtained. The value cannot be a negative number.|
**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**
```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.
try {
var maxTransmitSize = tag.getIsoDep(tagInfo).getMaxTransmitSize();
console.log("tag maxTransmitSize = " + maxTransmitSize);
} catch (busiError) {
console.log("tag getMaxTransmitSize busiError: " + busiError);
}
```
### tagSession.getSendDataTimeout ### tagSession.getSendDataTimeout
getSendDataTimeout(): number getSendDataTimeout(): number
Obtains the timeout period for sending data to this tag, in milliseconds. Obtains the timeout period for sending data to this tag, in milliseconds.
> **NOTE**
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [tagSession.getTimeout](#tagsessiongettimeout9).
**Required permissions**: ohos.permission.NFC_TAG **Required permissions**: ohos.permission.NFC_TAG
**System capability**: SystemCapability.Communication.NFC.Core **System capability**: SystemCapability.Communication.NFC.Tag
**Return value** **Return value**
...@@ -180,15 +337,58 @@ let sendDataTimeout = tag.getIsoDep(tagInfo).getSendDataTimeout(); ...@@ -180,15 +337,58 @@ let sendDataTimeout = tag.getIsoDep(tagInfo).getSendDataTimeout();
console.log("tag sendDataTimeout: " + sendDataTimeout); console.log("tag sendDataTimeout: " + sendDataTimeout);
``` ```
### tagSession.getTimeout<sup>9+</sup>
getTimeout(): number
Obtains the timeout period for sending data to this tag, in milliseconds.
**Required permissions**: ohos.permission.NFC_TAG
**System capability**: SystemCapability.Communication.NFC.Tag
**Return value**
| **Type**| **Description** |
| ------------------ | --------------------------|
| number | Timeout period obtained, in milliseconds. The value cannot be a negative number.|
**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**
```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.
try {
var timeout = tag.getIsoDep(tagInfo).getTimeout();
console.log("tag timeout = " + timeout);
} catch (busiError) {
console.log("tag getTimeout busiError: " + busiError);
}
```
### tagSession.setSendDataTimeout ### tagSession.setSendDataTimeout
setSendDataTimeout(timeout: number): boolean setSendDataTimeout(timeout: number): boolean
Sets the timeout period for sending data to this tag, in milliseconds. Sets the timeout period for sending data to this tag, in milliseconds.
> **NOTE**
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [tagSession.setTimeout](#tagsessionsettimeout9).
**Required permissions**: ohos.permission.NFC_TAG **Required permissions**: ohos.permission.NFC_TAG
**System capability**: SystemCapability.Communication.NFC.Core **System capability**: SystemCapability.Communication.NFC.Tag
**Parameters** **Parameters**
...@@ -215,15 +415,59 @@ let setStatus = tag.getIsoDep(tagInfo).setSendDataTimeout(timeoutMs); ...@@ -215,15 +415,59 @@ let setStatus = tag.getIsoDep(tagInfo).setSendDataTimeout(timeoutMs);
console.log("tag setSendDataTimeout setStatus: " + setStatus); console.log("tag setSendDataTimeout setStatus: " + setStatus);
``` ```
### tagSession.setTimeout<sup>9+</sup>
setTimeout(timeout: number): void
Sets the timeout period for sending data to this tag, in milliseconds.
**Required permissions**: ohos.permission.NFC_TAG
**System capability**: SystemCapability.Communication.NFC.Tag
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ----------------------- | ---- | -------------------------------------- |
| timeout | number | Yes| Timeout period to set, in milliseconds. The value cannot be a negative number.|
**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**
```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.
try {
tag.getIsoDep(tagInfo).setTimeout(timeoutMs);
console.log("tag setTimeout success");
} catch (busiError) {
console.log("tag setTimeout busiError: " + busiError);
}
```
### tagSession.sendData ### tagSession.sendData
sendData(data: number[]): Promise<number[]> sendData(data: number[]): Promise<number[]>
Sends data to this tag. This API uses a promise to return the result. Sends data to this tag. This API uses a promise to return the result.
> **NOTE**
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [tagSession.transmit](#tagsessiontransmit9).
**Required permissions**: ohos.permission.NFC_TAG **Required permissions**: ohos.permission.NFC_TAG
**System capability**: SystemCapability.Communication.NFC.Core **System capability**: SystemCapability.Communication.NFC.Tag
**Parameters** **Parameters**
...@@ -267,9 +511,12 @@ sendData(data: number[], callback: AsyncCallback<number[]>): void ...@@ -267,9 +511,12 @@ sendData(data: number[], callback: AsyncCallback<number[]>): void
Sends data to this tag. This API uses an asynchronous callback to return the result. Sends data to this tag. This API uses an asynchronous callback to return the result.
> **NOTE**
> This parameter is supported since API version 7 and discarded since API version 9. You are advised to use [tagSession.transmit](#tagsessiontransmit9-1).
**Required permissions**: ohos.permission.NFC_TAG **Required permissions**: ohos.permission.NFC_TAG
**System capability**: SystemCapability.Communication.NFC.Core **System capability**: SystemCapability.Communication.NFC.Tag
**Parameters** **Parameters**
...@@ -303,3 +550,123 @@ tag.getIsoDep(tagInfo).sendData(cmdData, (err, response)=> { ...@@ -303,3 +550,123 @@ tag.getIsoDep(tagInfo).sendData(cmdData, (err, response)=> {
} }
}); });
``` ```
### tagSession.transmit<sup>9+</sup>
transmit(data: number[]): Promise<number[]>
Transmits data to this tag. This API uses a promise to return the result.
**Required permissions**: ohos.permission.NFC_TAG
**System capability**: SystemCapability.Communication.NFC.Tag
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ----------------------- | ---- | -------------------------------------- |
| data | number[] | Yes| Data to transmit. 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**.|
**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**
```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.
try {
if (!tag.getIsoDep(tagInfo).isConnected()) {
tag.getIsoDep(tagInfo).connect();
}
} catch (busiError) {
console.log("tag connect busiError: " + busiError);
return;
}
let cmdData = [0x01, 0x02, 0x03, 0x04]; // Change it as required.
try {
tag.getIsoDep(tagInfo).transmit(cmdData).then((response) => {
console.log("tagSession transmit Promise response: " + response);
}).catch((err)=> {
console.log("tagSession transmit Promise err: " + err);
});
} catch (busiError) {
console.log("tag transmit busiError: " + busiError);
return;
}
```
### tagSession.transmit<sup>9+</sup>
transmit(data: number[], callback: AsyncCallback<number[]>): void
Transmits 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.Tag
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ----------------------- | ---- | -------------------------------------- |
| data | number[] | Yes| Data to transmit. 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**.|
**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**
```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.
try {
if (!tag.getIsoDep(tagInfo).isConnected()) {
tag.getIsoDep(tagInfo).connect();
}
} catch (busiError) {
console.log("tag connect busiError: " + busiError);
return;
}
let cmdData = [0x01, 0x02, 0x03, 0x04]; // Change it as required.
try {
tag.getIsoDep(tagInfo).transmit(cmdData, (err, response)=> {
if (err) {
console.log("tagSession transmit AsyncCallback err: " + err);
} else {
console.log("tagSession transmit AsyncCallback response: " + response);
}
});
} catch (busiError) {
console.log("tag transmit busiError: " + busiError);
return;
}
```
...@@ -263,7 +263,7 @@ Represents the WLAN configuration. ...@@ -263,7 +263,7 @@ Represents the WLAN configuration.
## IpType<sup>7+</sup> ## IpType<sup>7+</sup>
Enumerate the IP address types. Enumerates the IP address types.
**System API**: This is a system API. **System API**: This is a system API.
......
# WLAN # WLAN
The **WLAN** module provides basic wireless local area network (WLAN) functions, peer-to-peer (P2P) functions, and WLAN message notification services. It allows applications to communicate with other devices over WLAN. The **WLAN** module provides basic wireless local area network (WLAN) functions, peer-to-peer (P2P) functions, and WLAN message notification services. It allows applications to communicate with other devices over WLAN.
> **NOTE** > **NOTE**
...@@ -1038,7 +1037,7 @@ Removes the specified network configuration. ...@@ -1038,7 +1037,7 @@ Removes the specified network configuration.
| **Name**| **Type**| **Mandatory**| **Description**| | **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| id | number | Yes| ID of the network configuration to remove.| | id | number | Yes| ID of the network configuration to remove.|
**Return value** **Return value**
...@@ -1788,7 +1787,7 @@ Unregisters the WLAN state change events. ...@@ -1788,7 +1787,7 @@ Unregisters the WLAN state change events.
``` ```
## wifi.on('wifiConnectionChange')<sup>7+</sup> ## wifi.on('wifiConnectionChange')<sup>9+</sup>
on(type: "wifiConnectionChange", callback: Callback&lt;number&gt;): void on(type: "wifiConnectionChange", callback: Callback&lt;number&gt;): void
......
# WLAN Extension Interface # WLAN Extension Interface
This **wifiext** module provides WLAN extension interfaces for non-universal products. This **wifiext** module provides WLAN extension interfaces for non-universal products.
> **NOTE** > **NOTE**
...@@ -26,9 +25,9 @@ Enables the WLAN hotspot. ...@@ -26,9 +25,9 @@ Enables the WLAN hotspot.
**Return value** **Return value**
| **Type**| **Description**| | **Type**| **Description**|
| -------- | -------- | | -------- | -------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.| | boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
## wifiext.disableHotspot ## wifiext.disableHotspot
...@@ -43,9 +42,9 @@ Disables the WLAN hotspot. ...@@ -43,9 +42,9 @@ Disables the WLAN hotspot.
**Return value** **Return value**
| **Type**| **Description**| | **Type**| **Description**|
| -------- | -------- | | -------- | -------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.| | boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
## wifiext.getSupportedPowerModel ## wifiext.getSupportedPowerModel
...@@ -60,9 +59,9 @@ Obtains the supported power models. This API uses a promise to return the result ...@@ -60,9 +59,9 @@ Obtains the supported power models. This API uses a promise to return the result
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;Array&lt;[PowerModel](#powermodel)&gt;&gt; | Promise used to return the power models obtained.| | Promise&lt;Array&lt;[PowerModel](#powermodel)&gt;&gt; | Promise used to return the power models obtained.|
## PowerModel ## PowerModel
...@@ -90,9 +89,9 @@ Obtains the supported power models. This API uses an asynchronous callback to re ...@@ -90,9 +89,9 @@ Obtains the supported power models. This API uses an asynchronous callback to re
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | 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.| | 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 ## wifiext.getPowerModel
...@@ -107,9 +106,9 @@ Obtains the power model. This API uses a promise to return the result. ...@@ -107,9 +106,9 @@ Obtains the power model. This API uses a promise to return the result.
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;[PowerModel](#powermodel)&gt; | Promise used to return the power model obtained.| | Promise&lt;[PowerModel](#powermodel)&gt; | Promise used to return the power model obtained.|
## wifiext.getPowerModel ## wifiext.getPowerModel
...@@ -124,16 +123,16 @@ Obtains the power model. This API uses an asynchronous callback to return the re ...@@ -124,16 +123,16 @@ Obtains the power model. This API uses an asynchronous callback to return the re
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | 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.| | 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 ## wifiext.setPowerModel
setPowerModel(model: PowerModel) : boolean; setPowerModel(model: PowerModel) : boolean;
Sets the power model. Sets the power model.
**Required permissions**: ohos.permission.MANAGE_WIFI_HOTSPOT_EXT **Required permissions**: ohos.permission.MANAGE_WIFI_HOTSPOT_EXT
...@@ -141,12 +140,12 @@ setPowerModel(model: PowerModel) : boolean; ...@@ -141,12 +140,12 @@ setPowerModel(model: PowerModel) : boolean;
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| model | [PowerModel](#powermodel) | Yes| Power model to set.| | model | [PowerModel](#powermodel) | Yes| Power model to set.|
**Return value** **Return value**
| **Type**| **Description**| | **Type**| **Description**|
| -------- | -------- | | -------- | -------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.| | boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
# @ohos.wifiext # @ohos.wifiext (WLAN Extension)
This **wifiext** module provides WLAN extension interfaces for non-universal products. This **wifiext** module provides WLAN extension interfaces for non-universal products.
...@@ -26,9 +26,9 @@ Enables the WLAN hotspot. ...@@ -26,9 +26,9 @@ Enables the WLAN hotspot.
**Return value** **Return value**
| **Type**| **Description**| | **Type**| **Description**|
| -------- | -------- | | -------- | -------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.| | boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
## wifiext.disableHotspot ## wifiext.disableHotspot
...@@ -43,9 +43,9 @@ Disables the WLAN hotspot. ...@@ -43,9 +43,9 @@ Disables the WLAN hotspot.
**Return value** **Return value**
| **Type**| **Description**| | **Type**| **Description**|
| -------- | -------- | | -------- | -------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.| | boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
## wifiext.getSupportedPowerModel ## wifiext.getSupportedPowerModel
...@@ -60,9 +60,9 @@ Obtains the supported power models. This API uses a promise to return the result ...@@ -60,9 +60,9 @@ Obtains the supported power models. This API uses a promise to return the result
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;Array&lt;[PowerModel](#powermodel)&gt;&gt; | Promise used to return the power models obtained.| | Promise&lt;Array&lt;[PowerModel](#powermodel)&gt;&gt; | Promise used to return the power models obtained.|
## PowerModel ## PowerModel
...@@ -90,9 +90,9 @@ Obtains the supported power models. This API uses an asynchronous callback to re ...@@ -90,9 +90,9 @@ Obtains the supported power models. This API uses an asynchronous callback to re
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | 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.| | 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 ## wifiext.getPowerModel
...@@ -107,9 +107,9 @@ Obtains the power model. This API uses a promise to return the result. ...@@ -107,9 +107,9 @@ Obtains the power model. This API uses a promise to return the result.
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;[PowerModel](#powermodel)&gt; | Promise used to return the power model obtained.| | Promise&lt;[PowerModel](#powermodel)&gt; | Promise used to return the power model obtained.|
## wifiext.getPowerModel ## wifiext.getPowerModel
...@@ -124,16 +124,16 @@ Obtains the power model. This API uses an asynchronous callback to return the re ...@@ -124,16 +124,16 @@ Obtains the power model. This API uses an asynchronous callback to return the re
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | 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.| | 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 ## wifiext.setPowerModel
setPowerModel(model: PowerModel) : boolean; setPowerModel(model: PowerModel) : boolean;
Sets the power model. Sets the power model.
**Required permissions**: ohos.permission.MANAGE_WIFI_HOTSPOT_EXT **Required permissions**: ohos.permission.MANAGE_WIFI_HOTSPOT_EXT
...@@ -141,12 +141,12 @@ setPowerModel(model: PowerModel) : boolean; ...@@ -141,12 +141,12 @@ setPowerModel(model: PowerModel) : boolean;
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| model | [PowerModel](#powermodel) | Yes| Power model to set.| | model | [PowerModel](#powermodel) | Yes| Power model to set.|
**Return value** **Return value**
| **Type**| **Description**| | **Type**| **Description**|
| -------- | -------- | | -------- | -------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.| | 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.
先完成此消息的编辑!
想要评论请 注册