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

!13878 [翻译完成】#I6661B

Merge pull request !13878 from Annie_wang/PR12492
......@@ -108,7 +108,7 @@
- [MissionListener](js-apis-inner-application-missionListener.md)
- [MissionParameter](js-apis-inner-application-missionParameter.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)
- [ProcessRunningInfo](js-apis-inner-application-processRunningInfo.md)
- [ProcessRunningInformation](js-apis-inner-application-processRunningInformation.md)
......@@ -242,19 +242,19 @@
- [@ohos.net.webSocket](js-apis-webSocket.md)
- [@ohos.request](js-apis-request.md)
- Connectivity
- [@ohos.bluetooth](js-apis-bluetooth.md)
- [@ohos.connectedTag](js-apis-connectedTag.md)
- [@ohos.nfc.cardEmulation](js-apis-cardEmulation.md)
- [@ohos.nfc.controller](js-apis-nfcController.md)
- [@ohos.nfc.tag](js-apis-nfcTag.md)
- [@ohos.rpc](js-apis-rpc.md)
- [@ohos.bluetooth (Bluetooth)](js-apis-bluetooth.md)
- [@ohos.connectedTag (Active Tags)](js-apis-connectedTag.md)
- [@ohos.nfc.cardEmulation (Standard NFC Card Emulation)](js-apis-cardEmulation.md)
- [@ohos.nfc.controller (Standard NFC)](js-apis-nfcController.md)
- [@ohos.nfc.tag (Standard NFC Tags)](js-apis-nfcTag.md)
- [@ohos.rpc (RPC)](js-apis-rpc.md)
- [@ohos.wifiManager (WLAN)](js-apis-wifiManager.md)
- [@ohos.wifiManagerExt](js-apis-wifiManagerExt.md)
- [@ohos.wifi](js-apis-wifi.md)
- [@ohos.wifiext](js-apis-wifiext.md)
- [@ohos.wifiManagerExt (WLAN Extension)](js-apis-wifiManagerExt.md)
- [@ohos.wifi (To Be Deprecated)](js-apis-wifi.md)
- [@ohos.wifiext (To Be Deprecated)](js-apis-wifiext.md)
- tag
- [nfctech](js-apis-nfctech.md)
- [tagSession](js-apis-tagSession.md)
- [nfctech (Standard NFC Technologies)](js-apis-nfctech.md)
- [tagSession (Standard NFC Tag Session)](js-apis-tagSession.md)
- Basic Features
- [@ohos.accessibility](js-apis-accessibility.md)
- [@ohos.accessibility.config](js-apis-accessibility-config.md)
......@@ -314,9 +314,9 @@
- [@ohos.usb](js-apis-usb.md)
- [@ohos.vibrator](js-apis-vibrator.md)
- Account Management
- [@ohos.account.appAccount](js-apis-appAccount.md)
- [@ohos.account.distributedAccount](js-apis-distributed-account.md)
- [@ohos.account.osAccount](js-apis-osAccount.md)
- [@ohos.account.appAccount (App Account Management)](js-apis-appAccount.md)
- [@ohos.account.distributedAccount (Distributed Account Management)](js-apis-distributed-account.md)
- [@ohos.account.osAccount (OS Account Management)](js-apis-osAccount.md)
- Custom Management
- [@ohos.configPolicy](js-apis-configPolicy.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.
......@@ -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. |
| 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
......@@ -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. |
| 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
......
# @ohos.bluetooth
# @ohos.bluetooth (Bluetooth)
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).
......@@ -16,7 +16,11 @@ import cardEmulation from '@ohos.nfc.cardEmulation';
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|
| -------- | -------- | -------- |
......@@ -24,13 +28,28 @@ Enumerates the NFC card emulation types.
| UICC | 1 | Subscriber identity module (SIM) card emulation.|
| ESE | 2 | embedded Secure Element (eSE) emulation.|
## cardEmulation.isSupported
## CardType<sup>9+</sup>
Enumerates the types of services used by the card emulation application.
**System capability**: SystemCapability.Communication.NFC.CardEmulation
| Name| Value| Description|
| -------- | -------- | -------- |
| PAYMENT | "payment" | Payment type.|
| OTHER | "other" | Other types.|
## isSupported
isSupported(feature: number): boolean
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**
......@@ -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.|
## HceService<sup>8+</sup>
Implements HCE, including receiving Application Protocol Data Units (APDUs) from the peer card reader and sending a response. Before using HCE-related APIs, check whether the device supports HCE.
## hasHceCapability<sup>9+</sup>
### 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
**System capability**: SystemCapability.Communication.NFC.Core
**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.
**Return value**
**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
**System capability**: SystemCapability.Communication.NFC.Core
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ----------------------- | ---- | -------------------------------------------- |
| type | string | Yes | Event type to subscribe to. The value is **hceCmd**. |
| callback | AsyncCallback<number[]> | Yes | Callback invoked to return the APDU. Each number in the callback is a hexadecimal number ranging from **0x00** to **0xFF**.|
### 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
| ------- | -------- | ---- | ----------------------- |
| elementName | [ElementName](js-apis-bundleManager-elementName.md#elementname) | Yes| Application description, which consists of the bundle name and component name.|
| type | [CardType](#cardtype9) | Yes| Card emulation service type.|
**Parameters**
**Return value**
| Name | Type | Mandatory| 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**.|
| **Type**| **Description**|
| -------- | -------- |
| boolean | Returns **true** if the application is the default payment application; returns **false** otherwise.|
**Example**
......@@ -118,23 +113,16 @@ if (!isHceSupported) {
return;
}
// The device supports HCE and transimits APDUs with the remote NFC reader.
var hceService = new cardEmulation.HceService();
hceService.startHCE([
"F0010203040506", "A0000000041010"
]);
hceService.on("hceCmd", (err, res) => {
if(err.data === 0) {
console.log('callback => Operation hceCmd succeeded. Data: ' + JSON.stringify(res));
hceService.sendResponse([0x00,0xa4,0x04,0x00,
0x0e,0x32,0x50,0x41,0x59,0x2e,0x53,0x59,0x53,0x2e,0x44,0x44,
0x46,0x30,0x31,0x00]);
} else {
console.log('callback => Operation hceCmd failed. Cause: ' + err.data);
}
})
// Stop HCE when the application exits the NFC card emulation.
hceService.stopHCE();
var hasHceCap = cardEmulation.hasHceCapability();
if (!hasHceCap) {
console.log('this device hasHceCapability false, ignore it.');
return;
}
var elementName = {
"bundleName": "com.example.myapplication",
"abilityName": "EntryAbility",
};
var isDefaultService = cardEmulation.isDefaultService(elementName, cardEmulation.CardType.PAYMENT);
console.log('is the app is default service for this card type: ' + isDefaultService);
```
# @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.
......@@ -129,7 +129,7 @@ Writes data to this active tag. This API uses a promise to return the result.
```js
import connectedTag from '@ohos.connectedTag';
var rawData = "010203"; // change it tobe correct.
var rawData = "010203"; // Set it as required.
connectedTag.writeNdefTag(rawData).then(() => {
console.log("connectedTag writeNdefTag Promise success.");
}).catch((err)=> {
......@@ -159,7 +159,7 @@ Writes data to this active tag. This API uses an asynchronous callback to return
```js
import connectedTag from '@ohos.connectedTag';
var rawData = "010203"; // change it tobe correct.
var rawData = "010203"; // Set it as required.
connectedTag.writeNdefTag(rawData, (err)=> {
if (err) {
console.log("connectedTag writeNdefTag AsyncCallback err: " + err);
......@@ -220,7 +220,7 @@ connectedTag.on("notify", (err, rfState)=> {
var initStatus = connectedTag.init();
console.log("connectedTag init status: " + initStatus);
// Add nfc connecected tag business oprations here...
// Add NFC connected tag business operations here.
// connectedTag.writeNdefTag(rawData)
// 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.
......@@ -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
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**
>
......
# 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.
> **NOTE**<br>
> **NOTE**
>
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## **Modules to Import**
```
```js
import controller from '@ohos.nfc.controller';
```
......@@ -18,7 +18,7 @@ Enumerates the NFC states.
**System capability**: SystemCapability.Communication.NFC.Core
| Name| Default Value| Description|
| Name| Value| Description|
| -------- | -------- | -------- |
| STATE_OFF | 1 | NFC is closed (OFF).|
| STATE_TURNING_ON | 2 | NFC is turning on.|
......@@ -31,6 +31,10 @@ isNfcAvailable(): boolean
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
**Return value**
......@@ -46,6 +50,10 @@ openNfc(): boolean
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
**System capability**: SystemCapability.Communication.NFC.Core
......@@ -56,12 +64,34 @@ Opens NFC.
| -------- | -------- |
| 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
closeNfc(): boolean
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
**System capability**: SystemCapability.Communication.NFC.Core
......@@ -72,6 +102,24 @@ Closes NFC.
| -------- | ------------------------------------------- |
| 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
isNfcOpen(): boolean
......@@ -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
**Parameter**
| **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- |
| 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.|
**Parameters**
| **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- |
| 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.|
## controller.off('nfcStateChange')
......@@ -125,42 +171,55 @@ Unsubscribes from the NFC state changes. The subscriber will not receive NFC sta
**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**.|
| callback | Callback&lt;[NfcState](#nfcstate)&gt; | No| Callback for the NFC state changes. This parameter can be left blank.|
**Example**
```js
import controller from '@ohos.nfc.controller';
// Define a callback key.
var NFC_STATE_CALLBACK_KEY = "nfcStateChange";
```js
import controller from '@ohos.nfc.controller';
// Register the callback to receive NFC state change notifications.
controller.on(NFC_STATE_CALLBACK_KEY, (err, nfcState)=> {
// Register a callback to receive the NFC state change notification.
controller.on("nfcStateChange", (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()) {
// Open NFC. The ohos.permission.MANAGE_SECURE_SETTINGS permission is required.
if (!controller.isNfcOpen()) {
var ret = controller.openNfc();
console.log("controller openNfc ret: " + ret);
}
// Close NFC. Require permission: ohos.permission.MANAGE_SECURE_SETTINGS.
if (controller.isNfcOpen()) {
}
// 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);
}
// Unregister the callback.
controller.off(NFC_STATE_CALLBACK_KEY);
```
}
// 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.
......@@ -48,11 +48,11 @@ Before developing applications related to tag read and write, you must declare N
}
```
> **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.
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.
4. The **name** field under **requestPermissions** is mandatory. It must be **ohos.permission.NFC_TAG** and cannot be changed.
>
> - The **actions** field is mandatory. It must be **ohos.nfc.tag.action.TAG_FOUND** and cannot be changed.
> - The **name** field under **metadata** is mandatory. It must be **tag-tech** 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**
```js
......@@ -73,7 +73,7 @@ onCreate(want, launchParam) {
try {
tagInfo = tag.getTagInfo(want);
} catch (error) {
console.log("tag.getTagInfo catched error: " + error);
console.log("tag.getTagInfo caught error: " + error);
}
if (tagInfo == null || tagInfo == undefined) {
console.log("no TagInfo to be created, ignore it.");
......@@ -100,7 +100,7 @@ onCreate(want, launchParam) {
try {
nfcA = tag.getNfcATag(taginfo);
} catch (error) {
console.log("tag.getNfcATag catched error: " + error);
console.log("tag.getNfcATag caught error: " + error);
}
// Other code to read or write this tag.
}
......@@ -111,7 +111,7 @@ onCreate(want, launchParam) {
try {
isoDep = tag.getIsoDep(taginfo);
} catch (error) {
console.log("tag.getIsoDep catched error: " + error);
console.log("tag.getIsoDep caught error: " + error);
}
// Other code to read or write this tag.
}
......@@ -126,9 +126,36 @@ 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.
**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
**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.|
**System capability**: SystemCapability.Communication.NFC.Core
## 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**
......@@ -136,15 +163,50 @@ Obtains an **NfcATag** object, which allows access to the tags that use the NFC-
| -------- | -------- |
| [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
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.
**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>
**System capability**: SystemCapability.Communication.NFC.Core
getNfcB(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.
**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**
......@@ -152,15 +214,50 @@ Obtains an **NfcBTag** object, which allows access to the tags that use the NFC-
| -------- | ---------------- |
| [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
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.
**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
**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.|
## tag.getNfcF<sup>9+</sup>
getNfcF(tagInfo: [TagInfo](#taginfo)): [NfcFTag](js-apis-nfctech.md#nfcftag)
**System capability**: SystemCapability.Communication.NFC.Core
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**
......@@ -168,15 +265,50 @@ Obtains an **NfcFTag** object, which allows access to the tags that use the NFC-
| -------- | ---------------- |
| [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
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.
**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.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**
**System capability**: SystemCapability.Communication.NFC.Core
| 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**
......@@ -184,13 +316,21 @@ Obtains an **NfcVTag** object, which allows access to the tags that use the NFC-
| -------- | ---------------- |
| [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>
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.
**System capability**: SystemCapability.Communication.NFC.Core
**System capability**: SystemCapability.Communication.NFC.Tag
**Parameters**
......@@ -218,7 +358,7 @@ 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).
**System capability**: SystemCapability.Communication.NFC.Core
**System capability**: SystemCapability.Communication.NFC.Tag
**Parameters**
......@@ -242,11 +382,11 @@ For details about the error codes, see [NFC Error Codes](../errorcodes/errorcode
## 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.
**System capability**: SystemCapability.Communication.NFC.Core
**System capability**: SystemCapability.Communication.NFC.Tag
**Parameters**
......@@ -258,7 +398,7 @@ Obtains a **MifareClassicTag** object, which allows access to the tags that use
| **Type**| **Description** |
| ----------------- | ------------------------|
| [MifareClassicTag](js-apis-nfctech.md#mifareclassictag9) | **MifareClassicTag** object obtained.|
| [MifareClassicTag](js-apis-nfctech.md#mifareclassictag-9) | **MifareClassicTag** object obtained.|
**Error codes**
......@@ -274,7 +414,7 @@ getMifareUltralight(tagInfo: [TagInfo](#taginfo)): [MifareUltralightTag](js-apis
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**
| Name | Type | Mandatory | Description |
......@@ -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.
**System capability**: SystemCapability.Communication.NFC.Core
**System capability**: SystemCapability.Communication.NFC.Tag
**Return value**
......@@ -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**.
**System capability**: SystemCapability.Communication.NFC.Core
**System capability**: SystemCapability.Communication.NFC.Tag
**Parameters**
......@@ -344,7 +484,7 @@ makeUriRecord(uri: string): [NdefRecord](#ndefrecord9);
Creates an NDEF record based on the specified URI.
**System capability**: SystemCapability.Communication.NFC.Core
**System capability**: SystemCapability.Communication.NFC.Tag
**Parameters**
......@@ -373,7 +513,7 @@ try {
console.log("ndefMessage makeUriRecord ndefRecord: " + ndefRecord);
}
} 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);
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**
......@@ -414,7 +554,7 @@ try {
console.log("ndefMessage makeTextRecord ndefRecord: " + ndefRecord);
}
} 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)
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**
......@@ -456,7 +596,7 @@ try {
console.log("ndefMessage makeMimeRecord ndefRecord: " + ndefRecord);
}
} catch (busiError) {
console.log("ndefMessage makeMimeRecord catched busiError: " + busiError);
console.log("ndefMessage makeMimeRecord caught busiError: " + busiError);
}
```
## tag.ndef.makeExternalRecord<sup>9+</sup>
......@@ -465,7 +605,7 @@ makeExternalRecord(domainName: string, type: string, externalData: number[]): [N
Creates an NDEF record based on application-specific data.
**System capability**: SystemCapability.Communication.NFC.Core
**System capability**: SystemCapability.Communication.NFC.Tag
**Parameters**
......@@ -498,7 +638,7 @@ try {
console.log("ndefMessage makeExternalRecord ndefRecord: " + ndefRecord);
}
} 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
Converts an NDEF message to bytes.
**System capability**: SystemCapability.Communication.NFC.Core
**System capability**: SystemCapability.Communication.NFC.Tag
**Parameters**
......@@ -540,7 +680,7 @@ try {
let rawData2 = tag.ndef.messageToBytes(ndefMessage);
console.log("ndefMessage messageToBytes rawData2: " + rawData2);
} catch (busiError) {
console.log("ndefMessage messageToBytes catched busiError: " + busiError);
console.log("ndefMessage messageToBytes caught busiError: " + busiError);
}
```
## tag.ndef.createNdefMessage<sup>9+</sup>
......@@ -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.
**System capability**: SystemCapability.Communication.NFC.Core
**System capability**: SystemCapability.Communication.NFC.Tag
**Parameters**
......@@ -583,7 +723,7 @@ createNdefMessage(ndefRecords: NdefRecord[]): [NdefMessage](js-apis-nfctech.md#n
Creates an NDEF message from the NDEF records list.
**System capability**: SystemCapability.Communication.NFC.Core
**System capability**: SystemCapability.Communication.NFC.Tag
**Parameters**
......@@ -618,7 +758,7 @@ try {
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
......@@ -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**.|
| 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.|
| 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.|
## NdefRecord<sup>9+</sup>
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**|
| -------- | -------- | -------- | -------- | -------- |
......@@ -645,7 +786,7 @@ Defines an NDEF record. For details, see *NFCForum-TS-NDEF_1.0*.
## Technology Type Definition
Enumerates the tag technology types.
**System capability**: SystemCapability.Communication.NFC.Core
**System capability**: SystemCapability.Communication.NFC.Tag
| **Name**| **Value**| **Description**|
| -------- | -------- | -------- |
......@@ -662,7 +803,7 @@ Enumerates the tag technology types.
## TnfType<sup>9+</sup>
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**|
| -------- | -------- | -------- |
......@@ -677,7 +818,7 @@ Enumerates the TNF types. For details, see *NFCForum-TS-NDEF_1.0*.
## NDEF Record RTD
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**|
| -------- | -------- | -------- |
......@@ -687,7 +828,7 @@ Enumerates the NDEF record types. For details about the RTD, see *NFCForum-TS-ND
## NfcForumType<sup>9+</sup>
Enumerates the NFC Forum tag types.
**System capability**: SystemCapability.Communication.NFC.Core
**System capability**: SystemCapability.Communication.NFC.Tag
| **Name**| **Value**| **Description**|
| -------- | -------- | -------- |
......@@ -700,7 +841,7 @@ Enumerates the NFC Forum tag types.
## MifareClassicType<sup>9+</sup>
Enumerates the MIFARE Classic tag types.
**System capability**: SystemCapability.Communication.NFC.Core
**System capability**: SystemCapability.Communication.NFC.Tag
| **Name**| **Value**| **Description**|
| -------- | -------- | -------- |
......@@ -710,9 +851,9 @@ Enumerates the MIFARE Classic tag types.
| TYPE_PRO | 3 | MIFARE Pro.|
## 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**|
| -------- | -------- | -------- |
......@@ -724,11 +865,11 @@ Enumerates the sizes of MIFARE Classic tags.
## MifareUltralightType<sup>9+</sup>
Enumerates the MIFARE Ultralight tag types.
**System capability**: SystemCapability.Communication.NFC.Core
**System capability**: SystemCapability.Communication.NFC.Tag
| **Name**| **Value**| **Description**|
| -------- | -------- | -------- |
| TYPE_UNKNOWN | 0 | Unknown type.|
| TYPE_ULTRALIGHT | 1 | MIFARE Ultralight.|
| 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.
......@@ -26,9 +26,7 @@ getSak(): number
Obtains the SAK value of this NFC-A tag.
**Required permissions**: ohos.permission.NFC_TAG
**System capability**: SystemCapability.Communication.NFC.Core
**System capability**: SystemCapability.Communication.NFC.Tag
**Return value**
......@@ -52,9 +50,7 @@ getAtqa(): number[]
Obtains the ATQA value of this NFC-A tag.
**Required permissions**: ohos.permission.NFC_TAG
**System capability**: SystemCapability.Communication.NFC.Core
**System capability**: SystemCapability.Communication.NFC.Tag
**Return value**
......@@ -86,9 +82,7 @@ getRespAppData(): number[]
Obtains the application data of this NFC-B tag.
**Required permissions**: ohos.permission.NFC_TAG
**System capability**: SystemCapability.Communication.NFC.Core
**System capability**: SystemCapability.Communication.NFC.Tag
**Return value**
......@@ -112,9 +106,7 @@ getRespProtocol(): number[]
Obtains the protocol information of this NFC-B tag.
**Required permissions**: ohos.permission.NFC_TAG
**System capability**: SystemCapability.Communication.NFC.Core
**System capability**: SystemCapability.Communication.NFC.Tag
**Return value**
......@@ -146,9 +138,7 @@ getSystemCode(): number[]
Obtains the system code from this NFC-F tag.
**Required permissions**: ohos.permission.NFC_TAG
**System capability**: SystemCapability.Communication.NFC.Core
**System capability**: SystemCapability.Communication.NFC.Tag
**Return value**
......@@ -172,9 +162,7 @@ getPmm(): number[]
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.Core
**System capability**: SystemCapability.Communication.NFC.Tag
**Return value**
......@@ -206,9 +194,7 @@ getResponseFlags(): number
Obtains the response flags from this NFC-V tag.
**Required permissions**: ohos.permission.NFC_TAG
**System capability**: SystemCapability.Communication.NFC.Core
**System capability**: SystemCapability.Communication.NFC.Tag
**Return value**
......@@ -232,9 +218,7 @@ getDsfId(): number
Obtains the data storage format identifier (DSFID) from this NFC-V tag.
**Required permissions**: ohos.permission.NFC_TAG
**System capability**: SystemCapability.Communication.NFC.Core
**System capability**: SystemCapability.Communication.NFC.Tag
**Return value**
......@@ -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.
**System capability**: SystemCapability.Communication.NFC.Core
**System capability**: SystemCapability.Communication.NFC.Tag
**Return value**
......@@ -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.
**System capability**: SystemCapability.Communication.NFC.Core
**System capability**: SystemCapability.Communication.NFC.Tag
**Return value**
......@@ -316,7 +300,7 @@ Checks whether an extended application protocol data unit (APDU) is supported. T
**Required permissions**: ohos.permission.NFC_TAG
**System capability**: SystemCapability.Communication.NFC.Core
**System capability**: SystemCapability.Communication.NFC.Tag
**Return value**
......@@ -367,7 +351,7 @@ Checks whether an extended APDU is supported. This API uses an asynchronous call
**Required permissions**: ohos.permission.NFC_TAG
**System capability**: SystemCapability.Communication.NFC.Core
**System capability**: SystemCapability.Communication.NFC.Tag
**Parameters**
......@@ -419,7 +403,7 @@ getNdefRecords(): [tag.NdefRecord](js-apis-nfcTag.md#ndefrecord9)[]
Obtains all NDEF records.
**System capability**: SystemCapability.Communication.NFC.Core
**System capability**: SystemCapability.Communication.NFC.Tag
**Return value**
......@@ -454,7 +438,7 @@ getNdefTagType(): [tag.NfcForumType](js-apis-nfcTag.md#nfcforumtype9)
Obtains the NDEF tag type.
**System capability**: SystemCapability.Communication.NFC.Core
**System capability**: SystemCapability.Communication.NFC.Tag
**Return value**
......@@ -478,7 +462,7 @@ getNdefMessage(): [NdefMessage](#ndefmessage9)
Obtains the NDEF message from this NDEF tag.
**System capability**: SystemCapability.Communication.NFC.Core
**System capability**: SystemCapability.Communication.NFC.Tag
**Return value**
......@@ -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.
**System capability**: SystemCapability.Communication.NFC.Core
**System capability**: SystemCapability.Communication.NFC.Tag
**Return value**
......@@ -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
**System capability**: SystemCapability.Communication.NFC.Core
**System capability**: SystemCapability.Communication.NFC.Tag
**Return value**
......@@ -577,7 +561,7 @@ Reads the NDEF message from this tag. This API uses an asynchronous callback to
**Required permissions**: ohos.permission.NFC_TAG
**System capability**: SystemCapability.Communication.NFC.Core
**System capability**: SystemCapability.Communication.NFC.Tag
**Parameters**
......@@ -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
**System capability**: SystemCapability.Communication.NFC.Core
**System capability**: SystemCapability.Communication.NFC.Tag
**Parameters**
......@@ -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
**System capability**: SystemCapability.Communication.NFC.Core
**System capability**: SystemCapability.Communication.NFC.Tag
**Parameters**
......@@ -738,7 +722,7 @@ Checks whether this NDEF tag can be set to read-only.
**Required permissions**: ohos.permission.NFC_TAG
**System capability**: SystemCapability.Communication.NFC.Core
**System capability**: SystemCapability.Communication.NFC.Tag
**Return value**
......@@ -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
**System capability**: SystemCapability.Communication.NFC.Core
**System capability**: SystemCapability.Communication.NFC.Tag
**Error codes**
......@@ -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
**System capability**: SystemCapability.Communication.NFC.Core
**System capability**: SystemCapability.Communication.NFC.Tag
**Parameters**
......@@ -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.
**System capability**: SystemCapability.Communication.NFC.Core
**System capability**: SystemCapability.Communication.NFC.Tag
**Parameters**
......@@ -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
**System capability**: SystemCapability.Communication.NFC.Core
**System capability**: SystemCapability.Communication.NFC.Tag
**Parameters**
......@@ -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
**System capability**: SystemCapability.Communication.NFC.Core
**System capability**: SystemCapability.Communication.NFC.Tag
**Parameters**
......@@ -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
**System capability**: SystemCapability.Communication.NFC.Core
**System capability**: SystemCapability.Communication.NFC.Tag
**Parameters**
......@@ -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
**System capability**: SystemCapability.Communication.NFC.Core
**System capability**: SystemCapability.Communication.NFC.Tag
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ----------------------- | ---- | -------------------------------------- |
| 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**
......@@ -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
**System capability**: SystemCapability.Communication.NFC.Core
**System capability**: SystemCapability.Communication.NFC.Tag
**Parameters**
......@@ -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
**System capability**: SystemCapability.Communication.NFC.Core
**System capability**: SystemCapability.Communication.NFC.Tag
**Parameters**
......@@ -1243,7 +1227,7 @@ Increments a block with data. This API uses a promise to return the result.
**Required permissions**: ohos.permission.NFC_TAG
**System capability**: SystemCapability.Communication.NFC.Core
**System capability**: SystemCapability.Communication.NFC.Tag
**Parameters**
......@@ -1296,7 +1280,7 @@ Increments a block with data. This API uses an asynchronous callback to return t
**Required permissions**: ohos.permission.NFC_TAG
**System capability**: SystemCapability.Communication.NFC.Core
**System capability**: SystemCapability.Communication.NFC.Tag
**Parameters**
......@@ -1352,7 +1336,7 @@ Decrements a block. This API uses a promise to return the result.
**Required permissions**: ohos.permission.NFC_TAG
**System capability**: SystemCapability.Communication.NFC.Core
**System capability**: SystemCapability.Communication.NFC.Tag
**Parameters**
......@@ -1405,7 +1389,7 @@ Decrements a block. This API uses an asynchronous callback to return the result.
**Required permissions**: ohos.permission.NFC_TAG
**System capability**: SystemCapability.Communication.NFC.Core
**System capability**: SystemCapability.Communication.NFC.Tag
**Parameters**
......@@ -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
**System capability**: SystemCapability.Communication.NFC.Core
**System capability**: SystemCapability.Communication.NFC.Tag
**Parameters**
......@@ -1512,7 +1496,7 @@ Transfers data from the temporary register to a block. This API uses an asynchro
**Required permissions**: ohos.permission.NFC_TAG
**System capability**: SystemCapability.Communication.NFC.Core
**System capability**: SystemCapability.Communication.NFC.Tag
**Parameters**
......@@ -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
**System capability**: SystemCapability.Communication.NFC.Core
**System capability**: SystemCapability.Communication.NFC.Tag
**Parameters**
......@@ -1617,7 +1601,7 @@ Restores data in the temporary register from a block. This API uses an asynchron
**Required permissions**: ohos.permission.NFC_TAG
**System capability**: SystemCapability.Communication.NFC.Core
**System capability**: SystemCapability.Communication.NFC.Tag
**Parameters**
......@@ -1669,7 +1653,7 @@ getSectorCount(): number
Obtains the number of sectors in this MIFARE Classic tag.
**System capability**: SystemCapability.Communication.NFC.Core
**System capability**: SystemCapability.Communication.NFC.Tag
**Return value**
......@@ -1693,7 +1677,7 @@ getBlockCountInSector(sectorIndex: number): number
Obtains the number of blocks in a sector.
**System capability**: SystemCapability.Communication.NFC.Core
**System capability**: SystemCapability.Communication.NFC.Tag
**Parameters**
......@@ -1729,7 +1713,7 @@ getType(): [tag.MifareClassicType](js-apis-nfcTag.md#mifareclassictype9)
Obtains the type of this MIFARE Classic tag.
**System capability**: SystemCapability.Communication.NFC.Core
**System capability**: SystemCapability.Communication.NFC.Tag
**Return value**
......@@ -1753,7 +1737,7 @@ getTagSize(): number
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**
......@@ -1777,7 +1761,7 @@ isEmulatedTag(): boolean
Checks whether it is an emulated tag.
**System capability**: SystemCapability.Communication.NFC.Core
**System capability**: SystemCapability.Communication.NFC.Tag
**Return value**
......@@ -1801,7 +1785,7 @@ getBlockIndex(sectorIndex: number): number
Obtains the index of the first block in a sector.
**System capability**: SystemCapability.Communication.NFC.Core
**System capability**: SystemCapability.Communication.NFC.Tag
**Parameters**
......@@ -1835,9 +1819,9 @@ try {
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**
......@@ -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
**System capability**: SystemCapability.Communication.NFC.Core
**System capability**: SystemCapability.Communication.NFC.Tag
**Parameters**
......@@ -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
**System capability**: SystemCapability.Communication.NFC.Core
**System capability**: SystemCapability.Communication.NFC.Tag
**Parameters**
......@@ -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
**System capability**: SystemCapability.Communication.NFC.Core
**System capability**: SystemCapability.Communication.NFC.Tag
**Parameters**
......@@ -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
**System capability**: SystemCapability.Communication.NFC.Core
**System capability**: SystemCapability.Communication.NFC.Tag
**Parameters**
......@@ -2102,7 +2086,7 @@ getType(): [tag.MifareUltralightType](js-apis-nfcTag.md#mifareultralighttype9)
Obtains the type of this MIFARE Ultralight tag.
**System capability**: SystemCapability.Communication.NFC.Core
**System capability**: SystemCapability.Communication.NFC.Tag
**Return value**
......@@ -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
**System capability**: SystemCapability.Communication.NFC.Core
**System capability**: SystemCapability.Communication.NFC.Tag
**Parameters**
......@@ -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
**System capability**: SystemCapability.Communication.NFC.Core
**System capability**: SystemCapability.Communication.NFC.Tag
**Parameters**
......@@ -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
**System capability**: SystemCapability.Communication.NFC.Core
**System capability**: SystemCapability.Communication.NFC.Tag
**Parameters**
......@@ -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
**System capability**: SystemCapability.Communication.NFC.Core
**System capability**: SystemCapability.Communication.NFC.Tag
**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.
......@@ -155,7 +155,7 @@ Checks whether multiple OS accounts are supported. This API uses an asynchronous
| 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**
......@@ -192,7 +192,7 @@ Checks whether multiple OS accounts are supported. This API uses a promise to re
| 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**
......@@ -483,7 +483,7 @@ Checks whether this OS account has been verified. This API uses an asynchronous
| 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**
......@@ -1690,7 +1690,7 @@ Creates an OS account and associates it with the specified domain account. This
| 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**
......@@ -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));
}
```
### isMultiOsAccountEnable<sup>(deprecated)</sup>
isMultiOsAccountEnable(callback: AsyncCallback&lt;boolean&gt;): void
......@@ -2725,7 +2726,7 @@ Checks whether multiple OS accounts are supported. This API uses an asynchronous
| 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**
......@@ -2756,7 +2757,7 @@ Checks whether multiple OS accounts are supported. This API uses a promise to re
| 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**
......@@ -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;
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**
>
......@@ -4360,7 +4361,7 @@ Register a credential inputer.
let authType = account_osAccount.AuthType.DOMAIN;
let password = new Uint8Array([0, 0, 0, 0, 0]);
try {
InputerMgr.registerInputer(authType, {
inputerMgr.registerInputer(authType, {
onGetData: (authSubType, callback) => {
callback.onSetData(authSubType, password);
}
......
# @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**
>
> 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
......@@ -15,7 +14,6 @@ The **rpc** module implements communication between processes, including inter-p
import rpc from '@ohos.rpc';
```
## ErrorCode<sup>9+</sup>
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
## 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(): MessageSequence
static create(): MessageSequence
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
**Example**
```
```ts
let data = rpc.MessageSequence.create();
console.log("RpcClient: data is " + data);
```
......@@ -75,7 +73,7 @@ Reclaims the **MessageSequence** object that is no longer used.
**Example**
```
```ts
let reply = rpc.MessageSequence.create();
reply.reclaim();
```
......@@ -105,7 +103,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example**
```
```ts
class TestRemoteObject extends rpc.RemoteObject {
constructor(descriptor) {
super(descriptor);
......@@ -146,7 +144,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example**
```
```ts
class TestRemoteObject extends rpc.RemoteObject {
constructor(descriptor) {
super(descriptor);
......@@ -187,7 +185,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example**
```
```ts
let data = rpc.MessageSequence.create();
try {
data.writeInterfaceToken("aaa");
......@@ -219,11 +217,10 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
| ------- | ----- |
| 1900010 | read data from message sequence failed |
**Example**
```
class Stub extends rpc.RemoteObject {
```ts
class Stub extends rpc.RemoteObject {
onRemoteRequest(code, data, reply, option) {
try {
let interfaceToken = data.readInterfaceToken();
......@@ -234,8 +231,8 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
}
return true;
}
}
```
}
```
### getSize
......@@ -253,7 +250,7 @@ Obtains the data size of this **MessageSequence** object.
**Example**
```
```ts
let data = rpc.MessageSequence.create();
let size = data.getSize();
console.log("RpcClient: size is " + size);
......@@ -275,7 +272,7 @@ Obtains the capacity of this **MessageSequence** object.
**Example**
```
```ts
let data = rpc.MessageSequence.create();
let result = data.getCapacity();
console.log("RpcClient: capacity is " + result);
......@@ -285,7 +282,7 @@ Obtains the capacity of this **MessageSequence** object.
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
......@@ -293,11 +290,11 @@ Sets the size of data contained in this **MessageSequence** object.
| Name| Type | Mandatory| Description|
| ------ | ------ | ---- | ------ |
| size | number | Yes| Data size to set, in bytes.|
| size | number | Yes | Data size to set, in bytes.|
**Example**
```
```ts
let data = rpc.MessageSequence.create();
try {
data.setSize(16);
......@@ -332,7 +329,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example**
```
```ts
let data = rpc.MessageSequence.create();
try {
data.setCapacity(100);
......@@ -347,7 +344,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
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
......@@ -355,19 +352,19 @@ Obtains the writable capacity of this **MessageSequence** object.
| Type| Description|
| ------ | ------ |
| number | **MessageSequence** writable capacity obtained, in bytes.|
| number | Writable capacity of the **MessageSequence** instance, in bytes.|
**Example**
```
class Stub extends rpc.RemoteObject {
```ts
class Stub extends rpc.RemoteObject {
onRemoteRequest(code, data, reply, option) {
let getWritableBytes = data.getWritableBytes();
console.log("RpcServer: getWritableBytes is " + getWritableBytes);
return true;
}
}
```
}
```
### getReadableBytes
......@@ -381,18 +378,18 @@ Obtains the readable capacity of this **MessageSequence** object.
| Type| Description|
| ------ | ------- |
| number | **MessageSequence** readable capacity obtained, in bytes.|
| number | Readable capacity of the **MessageSequence** instance, in bytes.|
**Example**
```
class Stub extends rpc.RemoteObject {
```ts
class Stub extends rpc.RemoteObject {
onRemoteRequest(code, data, reply, option) {
let result = data.getReadableBytes();
console.log("RpcServer: getReadableBytes is " + result);
return true;
}
}
}
```
### getReadPosition
......@@ -411,7 +408,7 @@ Obtains the read position of this **MessageSequence** object.
**Example**
```
```ts
let data = rpc.MessageSequence.create();
let readPos = data.getReadPosition();
console.log("RpcClient: readPos is " + readPos);
......@@ -433,7 +430,7 @@ Obtains the write position of this **MessageSequence** object.
**Example**
```
```ts
let data = rpc.MessageSequence.create();
data.writeInt(10);
let bwPos = data.getWritePosition();
......@@ -456,7 +453,7 @@ Moves the read pointer to the specified position.
**Example**
```
```ts
let data = rpc.MessageSequence.create();
data.writeInt(12);
data.writeString("sequence");
......@@ -488,7 +485,7 @@ Moves the write pointer to the specified position.
**Example**
```
```ts
let data = rpc.MessageSequence.create();
data.writeInt(4);
try {
......@@ -526,7 +523,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example**
```
```ts
let data = rpc.MessageSequence.create();
try {
data.writeByte(2);
......@@ -560,7 +557,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example**
```
```ts
let data = rpc.MessageSequence.create();
try {
data.writeByte(2);
......@@ -601,7 +598,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example**
```
```ts
let data = rpc.MessageSequence.create();
try {
data.writeShort(8);
......@@ -635,7 +632,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example**
```
```ts
let data = rpc.MessageSequence.create();
try {
data.writeShort(8);
......@@ -676,7 +673,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example**
```
```ts
let data = rpc.MessageSequence.create();
try {
data.writeInt(10);
......@@ -710,7 +707,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example**
```
```ts
let data = rpc.MessageSequence.create();
try {
data.writeInt(10);
......@@ -751,7 +748,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example**
```
```ts
let data = rpc.MessageSequence.create();
try {
data.writeLong(10000);
......@@ -785,7 +782,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example**
```
```ts
let data = rpc.MessageSequence.create();
try {
data.writeLong(10000);
......@@ -826,7 +823,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example**
```
```ts
let data = rpc.MessageSequence.create();
try {
data.writeFloat(1.2);
......@@ -860,7 +857,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example**
```
```ts
let data = rpc.MessageSequence.create();
try {
data.writeFloat(1.2);
......@@ -901,7 +898,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example**
```
```ts
let data = rpc.MessageSequence.create();
try {
data.writeDouble(10.2);
......@@ -935,7 +932,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example**
```
```ts
let data = rpc.MessageSequence.create();
try {
data.writeDouble(10.2);
......@@ -976,7 +973,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example**
```
```ts
let data = rpc.MessageSequence.create();
try {
data.writeBoolean(false);
......@@ -1010,7 +1007,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example**
```
```ts
let data = rpc.MessageSequence.create();
try {
data.writeBoolean(false);
......@@ -1051,7 +1048,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example**
```
```ts
let data = rpc.MessageSequence.create();
try {
data.writeChar(97);
......@@ -1085,7 +1082,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example**
```
```ts
let data = rpc.MessageSequence.create();
try {
data.writeChar(97);
......@@ -1126,7 +1123,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example**
```
```ts
let data = rpc.MessageSequence.create();
try {
data.writeString('abc');
......@@ -1160,7 +1157,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example**
```
```ts
let data = rpc.MessageSequence.create();
try {
data.writeString('abc');
......@@ -1201,7 +1198,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example**
```
```ts
class MySequenceable {
num: number;
str: string;
......@@ -1255,7 +1252,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example**
```
```ts
class MySequenceable {
num: number;
str: string;
......@@ -1310,7 +1307,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example**
```
```ts
let data = rpc.MessageSequence.create();
let ByteArrayVar = [1, 2, 3, 4, 5];
try {
......@@ -1345,7 +1342,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example**
```
```ts
let data = rpc.MessageSequence.create();
let ByteArrayVar = [1, 2, 3, 4, 5];
try {
......@@ -1387,7 +1384,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example**
```
```ts
let data = rpc.MessageSequence.create();
let byteArrayVar = [1, 2, 3, 4, 5];
try {
......@@ -1429,7 +1426,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example**
```
```ts
let data = rpc.MessageSequence.create();
try {
data.writeShortArray([11, 12, 13]);
......@@ -1463,7 +1460,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example**
```
```ts
let data = rpc.MessageSequence.create();
try {
data.writeShortArray([11, 12, 13]);
......@@ -1504,7 +1501,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example**
```
```ts
let data = rpc.MessageSequence.create();
try {
data.writeShortArray([11, 12, 13]);
......@@ -1545,7 +1542,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example**
```
```ts
let data = rpc.MessageSequence.create();
try {
data.writeIntArray([100, 111, 112]);
......@@ -1579,7 +1576,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example**
```
```ts
let data = rpc.MessageSequence.create();
try {
data.writeIntArray([100, 111, 112]);
......@@ -1620,7 +1617,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example**
```
```ts
let data = rpc.MessageSequence.create();
try {
data.writeIntArray([100, 111, 112]);
......@@ -1661,7 +1658,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example**
```
```ts
let data = rpc.MessageSequence.create();
try {
data.writeLongArray([1111, 1112, 1113]);
......@@ -1695,7 +1692,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example**
```
```ts
let data = rpc.MessageSequence.create();
try {
data.writeLongArray([1111, 1112, 1113]);
......@@ -1736,7 +1733,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example**
```
```ts
let data = rpc.MessageSequence.create();
try {
data.writeLongArray([1111, 1112, 1113]);
......@@ -1777,7 +1774,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example**
```
```ts
let data = rpc.MessageSequence.create();
try {
data.writeFloatArray([1.2, 1.3, 1.4]);
......@@ -1811,7 +1808,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example**
```
```ts
let data = rpc.MessageSequence.create();
try {
data.writeFloatArray([1.2, 1.3, 1.4]);
......@@ -1852,7 +1849,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example**
```
```ts
let data = rpc.MessageSequence.create();
try {
data.writeFloatArray([1.2, 1.3, 1.4]);
......@@ -1893,7 +1890,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example**
```
```ts
let data = rpc.MessageSequence.create();
try {
data.writeDoubleArray([11.1, 12.2, 13.3]);
......@@ -1927,7 +1924,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example**
```
```ts
let data = rpc.MessageSequence.create();
try {
data.writeDoubleArray([11.1, 12.2, 13.3]);
......@@ -1968,7 +1965,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example**
```
```ts
let data = rpc.MessageSequence.create();
try {
data.writeDoubleArray([11.1, 12.2, 13.3]);
......@@ -2009,7 +2006,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example**
```
```ts
let data = rpc.MessageSequence.create();
try {
data.writeBooleanArray([false, true, false]);
......@@ -2043,7 +2040,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example**
```
```ts
let data = rpc.MessageSequence.create();
try {
data.writeBooleanArray([false, true, false]);
......@@ -2084,7 +2081,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example**
```
```ts
let data = rpc.MessageSequence.create();
try {
data.writeBooleanArray([false, true, false]);
......@@ -2125,7 +2122,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example**
```
```ts
let data = rpc.MessageSequence.create();
try {
data.writeCharArray([97, 98, 88]);
......@@ -2159,7 +2156,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example**
```
```ts
let data = rpc.MessageSequence.create();
try {
data.writeCharArray([97, 98, 88]);
......@@ -2200,7 +2197,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example**
```
```ts
let data = rpc.MessageSequence.create();
try {
data.writeCharArray([97, 98, 88]);
......@@ -2242,7 +2239,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example**
```
```ts
let data = rpc.MessageSequence.create();
try {
data.writeStringArray(["abc", "def"]);
......@@ -2276,7 +2273,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example**
```
```ts
let data = rpc.MessageSequence.create();
try {
data.writeStringArray(["abc", "def"]);
......@@ -2317,7 +2314,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example**
```
```ts
let data = rpc.MessageSequence.create();
try {
data.writeStringArray(["abc", "def"]);
......@@ -2352,7 +2349,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example**
```
```ts
class TestRemoteObject extends rpc.RemoteObject {
constructor(descriptor) {
super(descriptor);
......@@ -2394,7 +2391,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example**
```
```ts
import FA from "@ohos.ability.featureAbility";
let proxy;
let connect = {
......@@ -2411,7 +2408,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
};
let want = {
"bundleName": "com.ohos.server",
"abilityName": "com.ohos.server.MainAbility",
"abilityName": "com.ohos.server.EntryAbility",
};
FA.connectAbility(want, connect);
let option = new rpc.MessageOption();
......@@ -2467,7 +2464,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example**
```
```ts
class MyParcelable {
num: number;
str: string;
......@@ -2524,7 +2521,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example**
```
```ts
class MyParcelable {
num: number;
str: string;
......@@ -2584,7 +2581,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example**
```
```ts
class TestRemoteObject extends rpc.RemoteObject {
constructor(descriptor) {
super(descriptor);
......@@ -2631,7 +2628,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example**
```
```ts
class MyDeathRecipient {
onRemoteDied() {
console.log("server died");
......@@ -2684,7 +2681,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example**
```
```ts
class TestRemoteObject extends rpc.RemoteObject {
constructor(descriptor) {
super(descriptor);
......@@ -2712,7 +2709,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
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
......@@ -2724,7 +2721,7 @@ Closes a file descriptor.
**Example**
```
```ts
import fileio from '@ohos.fileio';
let filePath = "path/to/file";
let fd = fileio.openSync(filePath, 0o2| 0o100, 0o666);
......@@ -2740,7 +2737,7 @@ Closes a file descriptor.
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
......@@ -2766,7 +2763,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example**
```
```ts
import fileio from '@ohos.fileio';
let filePath = "path/to/file";
let fd = fileio.openSync(filePath, 0o2| 0o100, 0o666);
......@@ -2795,7 +2792,7 @@ Checks whether this **MessageSequence** object contains file descriptors.
**Example**
```
```ts
import fileio from '@ohos.fileio';
let sequence = new rpc.MessageSequence();
let filePath = "path/to/file";
......@@ -2840,7 +2837,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example**
```
```ts
import fileio from '@ohos.fileio';
let sequence = new rpc.MessageSequence();
let filePath = "path/to/file";
......@@ -2853,7 +2850,6 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
}
```
### readFileDescriptor
readFileDescriptor(): number
......@@ -2878,7 +2874,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example**
```
```ts
import fileio from '@ohos.fileio';
let sequence = new rpc.MessageSequence();
let filePath = "path/to/file";
......@@ -2897,7 +2893,6 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
}
```
### writeAshmem
writeAshmem(ashmem: Ashmem): void
......@@ -2922,7 +2917,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example**
```
```ts
let sequence = new rpc.MessageSequence();
let ashmem;
try {
......@@ -2964,7 +2959,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example**
```
```ts
let sequence = new rpc.MessageSequence();
let ashmem;
try {
......@@ -2988,7 +2983,6 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
}
```
### getRawDataCapacity
getRawDataCapacity(): number
......@@ -3005,13 +2999,12 @@ Obtains the maximum amount of raw data that can be held by this **MessageSequenc
**Example**
```
```ts
let sequence = new rpc.MessageSequence();
let result = sequence.getRawDataCapacity();
console.log("RpcTest: sequence get RawDataCapacity result is : " + result);
```
### writeRawData
writeRawData(rawData: number[], size: number): void
......@@ -3037,7 +3030,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example**
```
```ts
let sequence = new rpc.MessageSequence();
let arr = [1, 2, 3, 4, 5];
try {
......@@ -3048,7 +3041,6 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
}
```
### readRawData
readRawData(size: number): number[]
......@@ -3079,7 +3071,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example**
```
```ts
let sequence = new rpc.MessageSequence();
let arr = [1, 2, 3, 4, 5];
try {
......@@ -3105,7 +3097,7 @@ Provides APIs for reading and writing data in specific format. During RPC, the s
### create
create(): MessageParcel
static create(): MessageParcel
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**
```
```ts
let data = rpc.MessageParcel.create();
console.log("RpcClient: data is " + data);
```
......@@ -3134,7 +3126,7 @@ Reclaims the **MessageParcel** object that is no longer used.
**Example**
```
```ts
let reply = rpc.MessageParcel.create();
reply.reclaim();
```
......@@ -3161,7 +3153,7 @@ Serializes a remote object and writes it to this **MessageParcel** object.
**Example**
```
```ts
class MyDeathRecipient {
onRemoteDied() {
console.log("server died");
......@@ -3202,7 +3194,7 @@ Reads the remote object from this **MessageParcel** object. You can use this met
**Example**
```
```ts
class MyDeathRecipient {
onRemoteDied() {
console.log("server died");
......@@ -3250,7 +3242,7 @@ Writes an interface token to this **MessageParcel** object. The remote object ca
**Example**
```
```ts
let data = rpc.MessageParcel.create();
let result = data.writeInterfaceToken("aaa");
console.log("RpcServer: writeInterfaceToken is " + result);
......@@ -3273,7 +3265,7 @@ Reads the interface token from this **MessageParcel** object. The interface toke
**Example**
```
```ts
class Stub extends rpc.RemoteObject {
onRemoteMessageRequest(code, data, reply, option) {
let interfaceToken = data.readInterfaceToken();
......@@ -3283,7 +3275,6 @@ Reads the interface token from this **MessageParcel** object. The interface toke
}
```
### getSize
getSize(): number
......@@ -3300,13 +3291,12 @@ Obtains the data size of this **MessageParcel** object.
**Example**
```
```ts
let data = rpc.MessageParcel.create();
let size = data.getSize();
console.log("RpcClient: size is " + size);
```
### getCapacity
getCapacity(): number
......@@ -3323,13 +3313,12 @@ Obtains the capacity of this **MessageParcel** object.
**Example**
```
```ts
let data = rpc.MessageParcel.create();
let result = data.getCapacity();
console.log("RpcClient: capacity is " + result);
```
### setSize
setSize(size: number): boolean
......@@ -3352,13 +3341,12 @@ Sets the size of data contained in this **MessageParcel** object.
**Example**
```
```ts
let data = rpc.MessageParcel.create();
let setSize = data.setSize(16);
console.log("RpcClient: setSize is " + setSize);
```
### setCapacity
setCapacity(size: number): boolean
......@@ -3381,13 +3369,12 @@ Sets the storage capacity of this **MessageParcel** object.
**Example**
```
```ts
let data = rpc.MessageParcel.create();
let result = data.setCapacity(100);
console.log("RpcClient: setCapacity is " + result);
```
### getWritableBytes
getWritableBytes(): number
......@@ -3404,7 +3391,7 @@ Obtains the writable capacity of this **MessageParcel** object.
**Example**
```
```ts
class Stub extends rpc.RemoteObject {
onRemoteMessageRequest(code, data, reply, option) {
let getWritableBytes = data.getWritableBytes();
......@@ -3414,7 +3401,6 @@ Obtains the writable capacity of this **MessageParcel** object.
}
```
### getReadableBytes
getReadableBytes(): number
......@@ -3431,7 +3417,7 @@ Obtains the readable capacity of this **MessageParcel** object.
**Example**
```
```ts
class Stub extends rpc.RemoteObject {
onRemoteRequest(code, data, reply, option) {
let result = data.getReadableBytes();
......@@ -3441,7 +3427,6 @@ Obtains the readable capacity of this **MessageParcel** object.
}
```
### getReadPosition
getReadPosition(): number
......@@ -3458,13 +3443,12 @@ Obtains the read position of this **MessageParcel** object.
**Example**
```
```ts
let data = rpc.MessageParcel.create();
let readPos = data.getReadPosition();
console.log("RpcClient: readPos is " + readPos);
```
### getWritePosition
getWritePosition(): number
......@@ -3481,14 +3465,13 @@ Obtains the write position of this **MessageParcel** object.
**Example**
```
```ts
let data = rpc.MessageParcel.create();
data.writeInt(10);
let bwPos = data.getWritePosition();
console.log("RpcClient: bwPos is " + bwPos);
```
### rewindRead
rewindRead(pos: number): boolean
......@@ -3511,7 +3494,7 @@ Moves the read pointer to the specified position.
**Example**
```
```ts
let data = rpc.MessageParcel.create();
data.writeInt(12);
data.writeString("parcel");
......@@ -3522,7 +3505,6 @@ Moves the read pointer to the specified position.
console.log("RpcClient: rewindRead is " + number2);
```
### rewindWrite
rewindWrite(pos: number): boolean
......@@ -3545,7 +3527,7 @@ Moves the write pointer to the specified position.
**Example**
```
```ts
let data = rpc.MessageParcel.create();
data.writeInt(4);
data.rewindWrite(0);
......@@ -3554,7 +3536,6 @@ Moves the write pointer to the specified position.
console.log("RpcClient: rewindWrite is: " + number);
```
### writeByte
writeByte(val: number): boolean
......@@ -3577,13 +3558,12 @@ Writes a Byte value to this **MessageParcel** object.
**Example**
```
```ts
let data = rpc.MessageParcel.create();
let result = data.writeByte(2);
console.log("RpcClient: writeByte is: " + result);
```
### readByte
readByte(): number
......@@ -3600,7 +3580,7 @@ Reads the Byte value from this **MessageParcel** object.
**Example**
```
```ts
let data = rpc.MessageParcel.create();
let result = data.writeByte(2);
console.log("RpcClient: writeByte is: " + result);
......@@ -3608,7 +3588,6 @@ Reads the Byte value from this **MessageParcel** object.
console.log("RpcClient: readByte is: " + ret);
```
### writeShort
writeShort(val: number): boolean
......@@ -3627,17 +3606,16 @@ Writes a Short int value to this **MessageParcel** object.
| 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**
```
```ts
let data = rpc.MessageParcel.create();
let result = data.writeShort(8);
console.log("RpcClient: writeShort is: " + result);
```
### readShort
readShort(): number
......@@ -3654,7 +3632,7 @@ Reads the Short int value from this **MessageParcel** object.
**Example**
```
```ts
let data = rpc.MessageParcel.create();
let result = data.writeShort(8);
console.log("RpcClient: writeShort is: " + result);
......@@ -3662,7 +3640,6 @@ Reads the Short int value from this **MessageParcel** object.
console.log("RpcClient: readShort is: " + ret);
```
### writeInt
writeInt(val: number): boolean
......@@ -3685,13 +3662,12 @@ Writes an Int value to this **MessageParcel** object.
**Example**
```
```ts
let data = rpc.MessageParcel.create();
let result = data.writeInt(10);
console.log("RpcClient: writeInt is " + result);
```
### readInt
readInt(): number
......@@ -3708,7 +3684,7 @@ Reads the Int value from this **MessageParcel** object.
**Example**
```
```ts
let data = rpc.MessageParcel.create();
let result = data.writeInt(10);
console.log("RpcClient: writeInt is " + result);
......@@ -3716,7 +3692,6 @@ Reads the Int value from this **MessageParcel** object.
console.log("RpcClient: readInt is " + ret);
```
### writeLong
writeLong(val: number): boolean
......@@ -3735,17 +3710,16 @@ Writes a Long int value to this **MessageParcel** object.
| 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**
```
```ts
let data = rpc.MessageParcel.create();
let result = data.writeLong(10000);
console.log("RpcClient: writeLong is " + result);
```
### readLong
readLong(): number
......@@ -3762,7 +3736,7 @@ Reads the Long int value from this **MessageParcel** object.
**Example**
```
```ts
let data = rpc.MessageParcel.create();
let result = data.writeLong(10000);
console.log("RpcClient: writeLong is " + result);
......@@ -3770,7 +3744,6 @@ Reads the Long int value from this **MessageParcel** object.
console.log("RpcClient: readLong is " + ret);
```
### writeFloat
writeFloat(val: number): boolean
......@@ -3789,17 +3762,16 @@ Writes a Float value to this **MessageParcel** object.
| 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**
```
```ts
let data = rpc.MessageParcel.create();
let result = data.writeFloat(1.2);
console.log("RpcClient: writeFloat is " + result);
```
### readFloat
readFloat(): number
......@@ -3816,7 +3788,7 @@ Reads the Float value from this **MessageParcel** object.
**Example**
```
```ts
let data = rpc.MessageParcel.create();
let result = data.writeFloat(1.2);
console.log("RpcClient: writeFloat is " + result);
......@@ -3824,7 +3796,6 @@ Reads the Float value from this **MessageParcel** object.
console.log("RpcClient: readFloat is " + ret);
```
### writeDouble
writeDouble(val: number): boolean
......@@ -3843,17 +3814,16 @@ Writes a Double value to this **MessageParcel** object.
| 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**
```
```ts
let data = rpc.MessageParcel.create();
let result = data.writeDouble(10.2);
console.log("RpcClient: writeDouble is " + result);
```
### readDouble
readDouble(): number
......@@ -3870,7 +3840,7 @@ Reads the Double value from this **MessageParcel** object.
**Example**
```
```ts
let data = rpc.MessageParcel.create();
let result = data.writeDouble(10.2);
console.log("RpcClient: writeDouble is " + result);
......@@ -3896,17 +3866,16 @@ Writes a Boolean value to this **MessageParcel** object.
| 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**
```
```ts
let data = rpc.MessageParcel.create();
let result = data.writeBoolean(false);
console.log("RpcClient: writeBoolean is " + result);
```
### readBoolean
readBoolean(): boolean
......@@ -3923,7 +3892,7 @@ Reads the Boolean value from this **MessageParcel** object.
**Example**
```
```ts
let data = rpc.MessageParcel.create();
let result = data.writeBoolean(false);
console.log("RpcClient: writeBoolean is " + result);
......@@ -3931,7 +3900,6 @@ Reads the Boolean value from this **MessageParcel** object.
console.log("RpcClient: readBoolean is " + ret);
```
### writeChar
writeChar(val: number): boolean
......@@ -3950,17 +3918,16 @@ Writes a Char value to this **MessageParcel** object.
| 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**
```
```ts
let data = rpc.MessageParcel.create();
let result = data.writeChar(97);
console.log("RpcClient: writeChar is " + result);
```
### readChar
readChar(): number
......@@ -3977,7 +3944,7 @@ Reads the Char value from this **MessageParcel** object.
**Example**
```
```ts
let data = rpc.MessageParcel.create();
let result = data.writeChar(97);
console.log("RpcClient: writeChar is " + result);
......@@ -3985,7 +3952,6 @@ Reads the Char value from this **MessageParcel** object.
console.log("RpcClient: readChar is " + ret);
```
### writeString
writeString(val: string): boolean
......@@ -4004,17 +3970,16 @@ Writes a string to this **MessageParcel** object.
| 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**
```
```ts
let data = rpc.MessageParcel.create();
let result = data.writeString('abc');
console.log("RpcClient: writeString is " + result);
```
### readString
readString(): string
......@@ -4031,7 +3996,7 @@ Reads the string from this **MessageParcel** object.
**Example**
```
```ts
let data = rpc.MessageParcel.create();
let result = data.writeString('abc');
console.log("RpcClient: writeString is " + result);
......@@ -4039,7 +4004,6 @@ Reads the string from this **MessageParcel** object.
console.log("RpcClient: readString is " + ret);
```
### writeSequenceable
writeSequenceable(val: Sequenceable): boolean
......@@ -4058,11 +4022,11 @@ Writes a sequenceable object to this **MessageParcel** object.
| 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**
```
```ts
class MySequenceable {
num: number;
str: string;
......@@ -4087,7 +4051,6 @@ Writes a sequenceable object to this **MessageParcel** object.
console.log("RpcClient: writeSequenceable is " + result);
```
### readSequenceable
readSequenceable(dataIn: Sequenceable): boolean
......@@ -4110,7 +4073,7 @@ Reads member variables from this **MessageParcel** object.
**Example**
```
```ts
class MySequenceable {
num: number;
str: string;
......@@ -4138,7 +4101,6 @@ Reads member variables from this **MessageParcel** object.
console.log("RpcClient: writeSequenceable is " + result2);
```
### writeByteArray
writeByteArray(byteArray: number[]): boolean
......@@ -4157,18 +4119,17 @@ Writes a byte array to this **MessageParcel** object.
| 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**
```
```ts
let data = rpc.MessageParcel.create();
let ByteArrayVar = [1, 2, 3, 4, 5];
let result = data.writeByteArray(ByteArrayVar);
console.log("RpcClient: writeByteArray is " + result);
```
### readByteArray
readByteArray(dataIn: number[]): void
......@@ -4185,7 +4146,7 @@ Reads a byte array from this **MessageParcel** object.
**Example**
```
```ts
let data = rpc.MessageParcel.create();
let ByteArrayVar = [1, 2, 3, 4, 5];
let result = data.writeByteArray(ByteArrayVar);
......@@ -4194,7 +4155,6 @@ Reads a byte array from this **MessageParcel** object.
data.readByteArray(array);
```
### readByteArray
readByteArray(): number[]
......@@ -4211,7 +4171,7 @@ Reads the byte array from this **MessageParcel** object.
**Example**
```
```ts
let data = rpc.MessageParcel.create();
let ByteArrayVar = [1, 2, 3, 4, 5];
let result = data.writeByteArray(ByteArrayVar);
......@@ -4220,7 +4180,6 @@ Reads the byte array from this **MessageParcel** object.
console.log("RpcClient: readByteArray is " + array);
```
### writeShortArray
writeShortArray(shortArray: number[]): boolean
......@@ -4239,17 +4198,16 @@ Writes a short array to this **MessageParcel** object.
| 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**
```
```ts
let data = rpc.MessageParcel.create();
let result = data.writeShortArray([11, 12, 13]);
console.log("RpcClient: writeShortArray is " + result);
```
### readShortArray
readShortArray(dataIn: number[]): void
......@@ -4266,7 +4224,7 @@ Reads a short array from this **MessageParcel** object.
**Example**
```
```ts
let data = rpc.MessageParcel.create();
let result = data.writeShortArray([11, 12, 13]);
console.log("RpcClient: writeShortArray is " + result);
......@@ -4274,7 +4232,6 @@ Reads a short array from this **MessageParcel** object.
data.readShortArray(array);
```
### readShortArray
readShortArray(): number[]
......@@ -4291,7 +4248,7 @@ Reads the short array from this **MessageParcel** object.
**Example**
```
```ts
let data = rpc.MessageParcel.create();
let result = data.writeShortArray([11, 12, 13]);
console.log("RpcClient: writeShortArray is " + result);
......@@ -4299,7 +4256,6 @@ Reads the short array from this **MessageParcel** object.
console.log("RpcClient: readShortArray is " + array);
```
### writeIntArray
writeIntArray(intArray: number[]): boolean
......@@ -4318,17 +4274,16 @@ Writes an integer array to this **MessageParcel** object.
| 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**
```
```ts
let data = rpc.MessageParcel.create();
let result = data.writeIntArray([100, 111, 112]);
console.log("RpcClient: writeIntArray is " + result);
```
### readIntArray
readIntArray(dataIn: number[]): void
......@@ -4345,7 +4300,7 @@ Reads an integer array from this **MessageParcel** object.
**Example**
```
```ts
let data = rpc.MessageParcel.create();
let result = data.writeIntArray([100, 111, 112]);
console.log("RpcClient: writeIntArray is " + result);
......@@ -4353,7 +4308,6 @@ Reads an integer array from this **MessageParcel** object.
data.readIntArray(array);
```
### readIntArray
readIntArray(): number[]
......@@ -4370,7 +4324,7 @@ Reads the integer array from this **MessageParcel** object.
**Example**
```
```ts
let data = rpc.MessageParcel.create();
let result = data.writeIntArray([100, 111, 112]);
console.log("RpcClient: writeIntArray is " + result);
......@@ -4378,7 +4332,6 @@ Reads the integer array from this **MessageParcel** object.
console.log("RpcClient: readIntArray is " + array);
```
### writeLongArray
writeLongArray(longArray: number[]): boolean
......@@ -4397,17 +4350,16 @@ Writes a long array to this **MessageParcel** object.
| 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**
```
```ts
let data = rpc.MessageParcel.create();
let result = data.writeLongArray([1111, 1112, 1113]);
console.log("RpcClient: writeLongArray is " + result);
```
### readLongArray
readLongArray(dataIn: number[]): void
......@@ -4424,7 +4376,7 @@ Reads a long array from this **MessageParcel** object.
**Example**
```
```ts
let data = rpc.MessageParcel.create();
let result = data.writeLongArray([1111, 1112, 1113]);
console.log("RpcClient: writeLongArray is " + result);
......@@ -4432,7 +4384,6 @@ Reads a long array from this **MessageParcel** object.
data.readLongArray(array);
```
### readLongArray
readLongArray(): number[]
......@@ -4449,7 +4400,7 @@ Reads the long array from this **MessageParcel** object.
**Example**
```
```ts
let data = rpc.MessageParcel.create();
let result = data.writeLongArray([1111, 1112, 1113]);
console.log("RpcClient: writeLongArray is " + result);
......@@ -4457,7 +4408,6 @@ Reads the long array from this **MessageParcel** object.
console.log("RpcClient: readLongArray is " + array);
```
### writeFloatArray
writeFloatArray(floatArray: number[]): boolean
......@@ -4476,17 +4426,16 @@ Writes a FloatArray to this **MessageParcel** object.
| 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**
```
```ts
let data = rpc.MessageParcel.create();
let result = data.writeFloatArray([1.2, 1.3, 1.4]);
console.log("RpcClient: writeFloatArray is " + result);
```
### readFloatArray
readFloatArray(dataIn: number[]): void
......@@ -4503,7 +4452,7 @@ Reads a FloatArray from this **MessageParcel** object.
**Example**
```
```ts
let data = rpc.MessageParcel.create();
let result = data.writeFloatArray([1.2, 1.3, 1.4]);
console.log("RpcClient: writeFloatArray is " + result);
......@@ -4511,7 +4460,6 @@ Reads a FloatArray from this **MessageParcel** object.
data.readFloatArray(array);
```
### readFloatArray
readFloatArray(): number[]
......@@ -4528,7 +4476,7 @@ Reads the FloatArray from this **MessageParcel** object.
**Example**
```
```ts
let data = rpc.MessageParcel.create();
let result = data.writeFloatArray([1.2, 1.3, 1.4]);
console.log("RpcClient: writeFloatArray is " + result);
......@@ -4536,7 +4484,6 @@ Reads the FloatArray from this **MessageParcel** object.
console.log("RpcClient: readFloatArray is " + array);
```
### writeDoubleArray
writeDoubleArray(doubleArray: number[]): boolean
......@@ -4555,17 +4502,16 @@ Writes a DoubleArray to this **MessageParcel** object.
| 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**
```
```ts
let data = rpc.MessageParcel.create();
let result = data.writeDoubleArray([11.1, 12.2, 13.3]);
console.log("RpcClient: writeDoubleArray is " + result);
```
### readDoubleArray
readDoubleArray(dataIn: number[]): void
......@@ -4582,7 +4528,7 @@ Reads a DoubleArray from this **MessageParcel** object.
**Example**
```
```ts
let data = rpc.MessageParcel.create();
let result = data.writeDoubleArray([11.1, 12.2, 13.3]);
console.log("RpcClient: writeDoubleArray is " + result);
......@@ -4590,7 +4536,6 @@ Reads a DoubleArray from this **MessageParcel** object.
data.readDoubleArray(array);
```
### readDoubleArray
readDoubleArray(): number[]
......@@ -4607,7 +4552,7 @@ Reads the DoubleArray from this **MessageParcel** object.
**Example**
```
```ts
let data = rpc.MessageParcel.create();
let result = data.writeDoubleArray([11.1, 12.2, 13.3]);
console.log("RpcClient: writeDoubleArray is " + result);
......@@ -4615,7 +4560,6 @@ Reads the DoubleArray from this **MessageParcel** object.
console.log("RpcClient: readDoubleArray is " + array);
```
### writeBooleanArray
writeBooleanArray(booleanArray: boolean[]): boolean
......@@ -4634,17 +4578,16 @@ Writes a Boolean array to this **MessageParcel** object.
| 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**
```
```ts
let data = rpc.MessageParcel.create();
let result = data.writeBooleanArray([false, true, false]);
console.log("RpcClient: writeBooleanArray is " + result);
```
### readBooleanArray
readBooleanArray(dataIn: boolean[]): void
......@@ -4661,7 +4604,7 @@ Reads a Boolean array from this **MessageParcel** object.
**Example**
```
```ts
let data = rpc.MessageParcel.create();
let result = data.writeBooleanArray([false, true, false]);
console.log("RpcClient: writeBooleanArray is " + result);
......@@ -4669,7 +4612,6 @@ Reads a Boolean array from this **MessageParcel** object.
data.readBooleanArray(array);
```
### readBooleanArray
readBooleanArray(): boolean[]
......@@ -4686,7 +4628,7 @@ Reads the Boolean array from this **MessageParcel** object.
**Example**
```
```ts
let data = rpc.MessageParcel.create();
let result = data.writeBooleanArray([false, true, false]);
console.log("RpcClient: writeBooleanArray is " + result);
......@@ -4694,7 +4636,6 @@ Reads the Boolean array from this **MessageParcel** object.
console.log("RpcClient: readBooleanArray is " + array);
```
### writeCharArray
writeCharArray(charArray: number[]): boolean
......@@ -4713,17 +4654,16 @@ Writes a character array to this **MessageParcel** object.
| 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**
```
```ts
let data = rpc.MessageParcel.create();
let result = data.writeCharArray([97, 98, 88]);
console.log("RpcClient: writeCharArray is " + result);
```
### readCharArray
readCharArray(dataIn: number[]): void
......@@ -4740,7 +4680,7 @@ Reads a character array from this **MessageParcel** object.
**Example**
```
```ts
let data = rpc.MessageParcel.create();
let result = data.writeCharArray([97, 98, 99]);
console.log("RpcClient: writeCharArray is " + result);
......@@ -4748,7 +4688,6 @@ Reads a character array from this **MessageParcel** object.
data.readCharArray(array);
```
### readCharArray
readCharArray(): number[]
......@@ -4765,7 +4704,7 @@ Reads the character array from this **MessageParcel** object.
**Example**
```
```ts
let data = rpc.MessageParcel.create();
let result = data.writeCharArray([97, 98, 99]);
console.log("RpcClient: writeCharArray is " + result);
......@@ -4773,7 +4712,6 @@ Reads the character array from this **MessageParcel** object.
console.log("RpcClient: readCharArray is " + array);
```
### writeStringArray
writeStringArray(stringArray: string[]): boolean
......@@ -4792,17 +4730,16 @@ Writes a string array to this **MessageParcel** object.
| 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**
```
```ts
let data = rpc.MessageParcel.create();
let result = data.writeStringArray(["abc", "def"]);
console.log("RpcClient: writeStringArray is " + result);
```
### readStringArray
readStringArray(dataIn: string[]): void
......@@ -4819,7 +4756,7 @@ Reads a string array from this **MessageParcel** object.
**Example**
```
```ts
let data = rpc.MessageParcel.create();
let result = data.writeStringArray(["abc", "def"]);
console.log("RpcClient: writeStringArray is " + result);
......@@ -4827,7 +4764,6 @@ Reads a string array from this **MessageParcel** object.
data.readStringArray(array);
```
### readStringArray
readStringArray(): string[]
......@@ -4844,7 +4780,7 @@ Reads the string array from this **MessageParcel** object.
**Example**
```
```ts
let data = rpc.MessageParcel.create();
let result = data.writeStringArray(["abc", "def"]);
console.log("RpcClient: writeStringArray is " + result);
......@@ -4852,7 +4788,6 @@ Reads the string array from this **MessageParcel** object.
console.log("RpcClient: readStringArray is " + array);
```
### writeNoException<sup>8+</sup>
writeNoException(): void
......@@ -4863,7 +4798,7 @@ Writes information to this **MessageParcel** object indicating that no exception
**Example**
```
```ts
class MyDeathRecipient {
onRemoteDied() {
console.log("server died");
......@@ -4905,7 +4840,7 @@ Reads the exception information from this **MessageParcel** object.
**Example**
```
```ts
import FA from "@ohos.ability.featureAbility";
let proxy;
let connect = {
......@@ -4922,7 +4857,7 @@ Reads the exception information from this **MessageParcel** object.
};
let want = {
"bundleName": "com.ohos.server",
"abilityName": "com.ohos.server.MainAbility",
"abilityName": "com.ohos.server.EntryAbility",
};
FA.connectAbility(want, connect);
let option = new rpc.MessageOption();
......@@ -4967,11 +4902,11 @@ Writes a sequenceable array to this **MessageParcel** object.
| 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**
```
```ts
class MySequenceable {
num: number;
str: string;
......@@ -4999,7 +4934,6 @@ Writes a sequenceable array to this **MessageParcel** object.
console.log("RpcClient: writeSequenceableArray is " + result);
```
### readSequenceableArray<sup>8+</sup>
readSequenceableArray(sequenceableArray: Sequenceable[]): void
......@@ -5016,7 +4950,7 @@ Reads a sequenceable array from this **MessageParcel** object.
**Example**
```
```ts
class MySequenceable {
num: number;
str: string;
......@@ -5046,7 +4980,6 @@ Reads a sequenceable array from this **MessageParcel** object.
data.readSequenceableArray(b);
```
### writeRemoteObjectArray<sup>8+</sup>
writeRemoteObjectArray(objectArray: IRemoteObject[]): boolean
......@@ -5065,11 +4998,11 @@ Writes an array of **IRemoteObject** objects to this **MessageParcel** object.
| 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**
```
```ts
class MyDeathRecipient {
onRemoteDied() {
console.log("server died");
......@@ -5099,7 +5032,6 @@ Writes an array of **IRemoteObject** objects to this **MessageParcel** object.
console.log("RpcClient: writeRemoteObjectArray is " + result);
```
### readRemoteObjectArray<sup>8+</sup>
readRemoteObjectArray(objects: IRemoteObject[]): void
......@@ -5116,7 +5048,7 @@ Reads an **IRemoteObject** array from this **MessageParcel** object.
**Example**
```
```ts
class MyDeathRecipient {
onRemoteDied() {
console.log("server died");
......@@ -5147,7 +5079,6 @@ Reads an **IRemoteObject** array from this **MessageParcel** object.
data.readRemoteObjectArray(b);
```
### readRemoteObjectArray<sup>8+</sup>
readRemoteObjectArray(): IRemoteObject[]
......@@ -5164,7 +5095,7 @@ Reads the **IRemoteObject** array from this **MessageParcel** object.
**Example**
```
```ts
class MyDeathRecipient {
onRemoteDied() {
console.log("server died");
......@@ -5196,12 +5127,11 @@ Reads the **IRemoteObject** array from this **MessageParcel** object.
console.log("RpcClient: readRemoteObjectArray is " + b);
```
### closeFileDescriptor<sup>8+</sup>
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
......@@ -5213,19 +5143,18 @@ Closes a file descriptor.
**Example**
```
```ts
import fileio from '@ohos.fileio';
let filePath = "path/to/file";
let fd = fileio.openSync(filePath, 0o2| 0o100, 0o666);
rpc.MessageParcel.closeFileDescriptor(fd);
```
### dupFileDescriptor<sup>8+</sup>
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
......@@ -5243,14 +5172,13 @@ Duplicates a file descriptor.
**Example**
```
```ts
import fileio from '@ohos.fileio';
let filePath = "path/to/file";
let fd = fileio.openSync(filePath, 0o2| 0o100, 0o666);
let newFd = rpc.MessageParcel.dupFileDescriptor(fd);
```
### containFileDescriptors<sup>8+</sup>
containFileDescriptors(): boolean
......@@ -5263,11 +5191,11 @@ Checks whether this **MessageParcel** object contains a file descriptor.
| 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**
```
```ts
import fileio from '@ohos.fileio';
let parcel = new rpc.MessageParcel();
let filePath = "path/to/file";
......@@ -5279,7 +5207,6 @@ Checks whether this **MessageParcel** object contains a file descriptor.
console.log("RpcTest: parcel after write fd containFd result is : " + containFD);
```
### writeFileDescriptor<sup>8+</sup>
writeFileDescriptor(fd: number): boolean
......@@ -5302,7 +5229,7 @@ Writes a file descriptor to this **MessageParcel** object.
**Example**
```
```ts
import fileio from '@ohos.fileio';
let parcel = new rpc.MessageParcel();
let filePath = "path/to/file";
......@@ -5311,7 +5238,6 @@ Writes a file descriptor to this **MessageParcel** object.
console.log("RpcTest: parcel writeFd result is : " + writeResult);
```
### readFileDescriptor<sup>8+</sup>
readFileDescriptor(): number
......@@ -5328,7 +5254,7 @@ Reads the file descriptor from this **MessageParcel** object.
**Example**
```
```ts
import fileio from '@ohos.fileio';
let parcel = new rpc.MessageParcel();
let filePath = "path/to/file";
......@@ -5338,7 +5264,6 @@ Reads the file descriptor from this **MessageParcel** object.
console.log("RpcTest: parcel read fd is : " + readFD);
```
### writeAshmem<sup>8+</sup>
writeAshmem(ashmem: Ashmem): boolean
......@@ -5357,18 +5282,17 @@ Writes an anonymous shared object to this **MessageParcel** object.
| 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**
```
```ts
let parcel = new rpc.MessageParcel();
let ashmem = rpc.Ashmem.createAshmem("ashmem", 1024);
let isWriteSuccess = parcel.writeAshmem(ashmem);
console.log("RpcTest: write ashmem to result is : " + isWriteSuccess);
```
### readAshmem<sup>8+</sup>
readAshmem(): Ashmem
......@@ -5385,7 +5309,7 @@ Reads the anonymous shared object from this **MessageParcel** object.
**Example**
```
```ts
let parcel = new rpc.MessageParcel();
let ashmem = rpc.Ashmem.createAshmem("ashmem", 1024);
let isWriteSuccess = parcel.writeAshmem(ashmem);
......@@ -5394,7 +5318,6 @@ Reads the anonymous shared object from this **MessageParcel** object.
console.log("RpcTest: read ashmem to result is : " + readAshmem);
```
### getRawDataCapacity<sup>8+</sup>
getRawDataCapacity(): number
......@@ -5411,13 +5334,12 @@ Obtains the maximum amount of raw data that can be held by this **MessageParcel*
**Example**
```
```ts
let parcel = new rpc.MessageParcel();
let result = parcel.getRawDataCapacity();
console.log("RpcTest: parcel get RawDataCapacity result is : " + result);
```
### writeRawData<sup>8+</sup>
writeRawData(rawData: number[], size: number): boolean
......@@ -5437,18 +5359,17 @@ Writes raw data to this **MessageParcel** object.
| 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**
```
```ts
let parcel = new rpc.MessageParcel();
let arr = [1, 2, 3, 4, 5];
let isWriteSuccess = parcel.writeRawData(arr, arr.length);
console.log("RpcTest: parcel write raw data result is : " + isWriteSuccess);
```
### readRawData<sup>8+</sup>
readRawData(size: number): number[]
......@@ -5471,7 +5392,7 @@ Reads raw data from this **MessageParcel** object.
**Example**
```
```ts
let parcel = new rpc.MessageParcel();
let arr = [1, 2, 3, 4, 5];
let isWriteSuccess = parcel.writeRawData(arr, arr.length);
......@@ -5480,7 +5401,6 @@ Reads raw data from this **MessageParcel** object.
console.log("RpcTest: parcel read raw data result is : " + result);
```
## Parcelable<sup>9+</sup>
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.
| Type | Description |
| ------- | ----------------------------------------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
**Example**
```
```ts
class MyParcelable {
num: number;
str: string;
......@@ -5535,7 +5454,6 @@ Marshals this **Parcelable** object into a **MessageSequence** object.
console.log("RpcClient: readParcelable is " + result2);
```
### unmarshalling
unmarshalling(dataIn: MessageSequence): boolean
......@@ -5558,7 +5476,7 @@ Unmarshals this **Parcelable** object from a **MessageSequence** object.
**Example**
```
```ts
class MyParcelable {
num: number;
str: string;
......@@ -5586,7 +5504,6 @@ Unmarshals this **Parcelable** object from a **MessageSequence** object.
console.log("RpcClient: readParcelable is " + result2);
```
## Sequenceable<sup>(deprecated)</sup>
>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.
| Type | Description |
| ------- | ----------------------------------------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
**Example**
```
```ts
class MySequenceable {
num: number;
str: string;
......@@ -5643,7 +5559,6 @@ Marshals the sequenceable object into a **MessageParcel** object.
console.log("RpcClient: readSequenceable is " + result2);
```
### unmarshalling
unmarshalling(dataIn: MessageParcel): boolean
......@@ -5666,7 +5581,7 @@ Unmarshals this sequenceable object from a **MessageParcel** object.
**Example**
```
```ts
class MySequenceable {
num: number;
str: string;
......@@ -5694,7 +5609,6 @@ Unmarshals this sequenceable object from a **MessageParcel** object.
console.log("RpcClient: readSequenceable is " + result2);
```
## IRemoteBroker
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
**Example**
```
```ts
class TestAbility extends rpc.RemoteObject {
asObject() {
return this;
}
}
let remoteObject = new TestAbility().asObject();
```
**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 {
remote: rpc.RemoteObject;
constructor(remote) {
......@@ -5735,6 +5670,8 @@ Obtains a proxy or remote object. This API must be implemented by its derived cl
return this.remote;
}
}
let iRemoteObject = new TestProxy(proxy).asObject();
```
## DeathRecipient
......@@ -5751,7 +5688,7 @@ Called to perform subsequent operations when a death notification of the remote
**Example**
```
```ts
class MyDeathRecipient {
onRemoteDied() {
console.log("server died");
......@@ -5795,7 +5732,7 @@ Provides methods to query of obtain interface descriptors, add or delete death n
getLocalInterface(descriptor: string): IRemoteBroker
Obtains the interface.
Obtains the interface descriptor.
**System capability**: SystemCapability.Communication.IPC.Core
......@@ -5817,7 +5754,7 @@ Obtains the interface.
queryLocalInterface(descriptor: string): IRemoteBroker
Obtains the interface.
Queries the interface descriptor.
**System capability**: SystemCapability.Communication.IPC.Core
......@@ -5833,7 +5770,6 @@ Obtains the interface.
| ------------- | --------------------------------------------- |
| IRemoteBroker | **IRemoteBroker** object bound to the specified interface token.|
### sendRequest<sup>(deprecated)</sup>
>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
| 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>
......@@ -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. |
| callback | AsyncCallback&lt;RequestResult&gt; | Yes | Callback for receiving the sending result. |
### sendRequest<sup>8+(deprecated)</sup>
>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
| 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. |
### registerDeathRecipient<sup>9+</sup>
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
......@@ -5962,7 +5896,7 @@ Adds a callback for receiving death notifications of the remote object. This met
| 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.|
**Error Code**
......@@ -5973,7 +5907,6 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
| ------- | -------- |
| 1900008 | proxy or remote object is invalid |
### addDeathrecipient<sup>(deprecated)</sup>
>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
| 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(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
......@@ -6010,7 +5943,7 @@ Removes the callback used to receive death notifications of the remote object.
| 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.|
**Error Code**
......@@ -6021,7 +5954,6 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
| ------- | -------- |
| 1900008 | proxy or remote object is invalid |
### removeDeathRecipient<sup>(deprecated)</sup>
>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.
| 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>
......@@ -6115,7 +6046,6 @@ Provides APIs to implement **IRemoteObject**.
| MIN_TRANSACTION_ID | 1 (0x00000001) | Minimum valid instruction code. |
| MAX_TRANSACTION_ID | 16777215 (0x00FFFFFF) | Maximum valid instruction code. |
### sendRequest<sup>(deprecated)</sup>
>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
| 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**
```
```ts
import FA from "@ohos.ability.featureAbility";
let proxy;
let connect = {
......@@ -6160,7 +6090,7 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch
};
let want = {
"bundleName": "com.ohos.server",
"abilityName": "com.ohos.server.MainAbility",
"abilityName": "com.ohos.server.EntryAbility",
};
FA.connectAbility(want, connect);
let option = new rpc.MessageOption();
......@@ -6181,7 +6111,6 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch
reply.reclaim();
```
### sendMessageRequest<sup>9+</sup>
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
**Example**
```
```ts
import FA from "@ohos.ability.featureAbility";
let proxy;
let connect = {
......@@ -6224,7 +6153,7 @@ Sends a **MessageSequence** message to the remote process in synchronous or asyn
};
let want = {
"bundleName": "com.ohos.server",
"abilityName": "com.ohos.server.MainAbility",
"abilityName": "com.ohos.server.EntryAbility",
};
FA.connectAbility(want, connect);
let option = new rpc.MessageOption();
......@@ -6251,7 +6180,6 @@ Sends a **MessageSequence** message to the remote process in synchronous or asyn
});
```
### sendRequest<sup>8+(deprecated)</sup>
>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
**Example**
```
```ts
import FA from "@ohos.ability.featureAbility";
let proxy;
let connect = {
......@@ -6296,7 +6224,7 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch
};
let want = {
"bundleName": "com.ohos.server",
"abilityName": "com.ohos.server.MainAbility",
"abilityName": "com.ohos.server.EntryAbility",
};
FA.connectAbility(want, connect);
let option = new rpc.MessageOption();
......@@ -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. |
| callback | AsyncCallback&lt;RequestResult&gt; | Yes | Callback for receiving the sending result. |
**Example**
```
```ts
import FA from "@ohos.ability.featureAbility";
let proxy;
let connect = {
......@@ -6361,7 +6288,7 @@ Sends a **MessageSequence** message to the remote process in synchronous or asyn
};
let want = {
"bundleName": "com.ohos.server",
"abilityName": "com.ohos.server.MainAbility",
"abilityName": "com.ohos.server.EntryAbility",
};
function sendRequestCallback(result) {
if (result.errCode === 0) {
......@@ -6390,7 +6317,6 @@ Sends a **MessageSequence** message to the remote process in synchronous or asyn
}
```
### sendRequest<sup>8+(deprecated)</sup>
>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
**Example**
```
```ts
import FA from "@ohos.ability.featureAbility";
let proxy;
let connect = {
......@@ -6430,7 +6356,7 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch
};
let want = {
"bundleName": "com.ohos.server",
"abilityName": "com.ohos.server.MainAbility",
"abilityName": "com.ohos.server.EntryAbility",
};
function sendRequestCallback(result) {
if (result.errCode === 0) {
......@@ -6454,7 +6380,6 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch
proxy.sendRequest(1, data, reply, option, sendRequestCallback);
```
### getLocalInterface<sup>9+</sup>
getLocalInterface(interface: string): IRemoteBroker
......@@ -6485,7 +6410,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example**
```
```ts
import FA from "@ohos.ability.featureAbility";
let proxy;
let connect = {
......@@ -6502,7 +6427,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
};
let want = {
"bundleName":"com.ohos.server",
"abilityName":"com.ohos.server.MainAbility",
"abilityName":"com.ohos.server.EntryAbility",
};
FA.connectAbility(want, connect);
try {
......@@ -6514,7 +6439,6 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
}
```
### queryLocalInterface<sup>(deprecated)</sup>
>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.
**Example**
```
```ts
import FA from "@ohos.ability.featureAbility";
let proxy;
let connect = {
......@@ -6556,19 +6480,18 @@ Obtains the **LocalInterface** object of an interface token.
};
let want = {
"bundleName":"com.ohos.server",
"abilityName":"com.ohos.server.MainAbility",
"abilityName":"com.ohos.server.EntryAbility",
};
FA.connectAbility(want, connect);
let broker = proxy.queryLocalInterface("testObject");
console.log("RpcClient: queryLocalInterface is " + broker);
```
### registerDeathRecipient<sup>9+</sup>
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
......@@ -6576,7 +6499,7 @@ Adds a callback for receiving death notifications of the remote object. This met
| 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.|
**Error Code**
......@@ -6589,7 +6512,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example**
```
```ts
import FA from "@ohos.ability.featureAbility";
let proxy;
let connect = {
......@@ -6606,7 +6529,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
};
let want = {
"bundleName": "com.ohos.server",
"abilityName": "com.ohos.server.MainAbility",
"abilityName": "com.ohos.server.EntryAbility",
};
FA.connectAbility(want, connect);
class MyDeathRecipient {
......@@ -6623,7 +6546,6 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
}
```
### addDeathRecippient<sup>(deprecated)</sup>
>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
| 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**
```
```ts
import FA from "@ohos.ability.featureAbility";
let proxy;
let connect = {
......@@ -6666,7 +6588,7 @@ Adds a callback for receiving the death notifications of the remote object, incl
};
let want = {
"bundleName": "com.ohos.server",
"abilityName": "com.ohos.server.MainAbility",
"abilityName": "com.ohos.server.EntryAbility",
};
FA.connectAbility(want, connect);
class MyDeathRecipient {
......@@ -6682,7 +6604,7 @@ Adds a callback for receiving the death notifications of the remote object, incl
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
......@@ -6690,7 +6612,7 @@ Removes the callback used to receive death notifications of the remote object.
| 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.|
**Error Code**
......@@ -6703,7 +6625,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example**
```
```ts
import FA from "@ohos.ability.featureAbility";
let proxy;
let connect = {
......@@ -6720,7 +6642,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
};
let want = {
"bundleName": "com.ohos.server",
"abilityName": "com.ohos.server.MainAbility",
"abilityName": "com.ohos.server.EntryAbility",
};
FA.connectAbility(want, connect);
class MyDeathRecipient {
......@@ -6738,7 +6660,6 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
}
```
### removeDeathRecipient<sup>(deprecated)</sup>
>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.
| 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**
```
```ts
import FA from "@ohos.ability.featureAbility";
let proxy;
let connect = {
......@@ -6781,7 +6702,7 @@ Removes the callback used to receive death notifications of the remote object.
};
let want = {
"bundleName": "com.ohos.server",
"abilityName": "com.ohos.server.MainAbility",
"abilityName": "com.ohos.server.EntryAbility",
};
FA.connectAbility(want, connect);
class MyDeathRecipient {
......@@ -6794,7 +6715,6 @@ Removes the callback used to receive death notifications of the remote object.
proxy.removeDeathRecipient(deathRecipient, 0);
```
### getDescriptor<sup>9+</sup>
getDescriptor(): string
......@@ -6820,7 +6740,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example**
```
```ts
import FA from "@ohos.ability.featureAbility";
let proxy;
let connect = {
......@@ -6837,7 +6757,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
};
let want = {
"bundleName": "com.ohos.server",
"abilityName": "com.ohos.server.MainAbility",
"abilityName": "com.ohos.server.EntryAbility",
};
FA.connectAbility(want, connect);
try {
......@@ -6849,7 +6769,6 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
}
```
### getInterfaceDescriptor<sup>(deprecated)</sup>
>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.
**Example**
```
```ts
import FA from "@ohos.ability.featureAbility";
let proxy;
let connect = {
......@@ -6885,14 +6804,13 @@ Obtains the interface descriptor of this proxy object.
};
let want = {
"bundleName": "com.ohos.server",
"abilityName": "com.ohos.server.MainAbility",
"abilityName": "com.ohos.server.EntryAbility",
};
FA.connectAbility(want, connect);
let descriptor = proxy.getInterfaceDescriptor();
console.log("RpcClient: descriptor is " + descriptor);
```
### isObjectDead
isObjectDead(): boolean
......@@ -6909,7 +6827,7 @@ Checks whether the **RemoteObject** is dead.
**Example**
```
```ts
import FA from "@ohos.ability.featureAbility";
let proxy;
let connect = {
......@@ -6926,14 +6844,13 @@ Checks whether the **RemoteObject** is dead.
};
let want = {
"bundleName": "com.ohos.server",
"abilityName": "com.ohos.server.MainAbility",
"abilityName": "com.ohos.server.EntryAbility",
};
FA.connectAbility(want, connect);
let isDead = proxy.isObjectDead();
console.log("RpcClient: isObjectDead is " + isDead);
```
## MessageOption
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.
| 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(syncFlags?: number, waitTime?: number)
......@@ -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**. |
| 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(): boolean;
......@@ -6991,8 +6926,14 @@ Checks whether **SendMessageRequest** is called synchronously or asynchronously.
| 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>
......@@ -7002,6 +6943,13 @@ Sets whether **SendMessageRequest** is called synchronously or asynchronously.
**System capability**: SystemCapability.Communication.IPC.Core
**Example**
```ts
let option = new rpc.MessageOption();
let setAsync = option.setAsync(true);
console.log("Set synchronization flag");
```
### getFlags
......@@ -7017,6 +6965,22 @@ Obtains the call flag, which can be synchronous or asynchronous.
| ------ | ------------------------------------ |
| 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
......@@ -7032,6 +6996,19 @@ Sets the call flag, which can be synchronous or asynchronous.
| ------ | ------ | ---- | ------------------------ |
| 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
......@@ -7047,6 +7024,20 @@ Obtains the maximum wait time for this RPC call.
| ------ | ----------------- |
| 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
......@@ -7062,6 +7053,18 @@ Sets the maximum wait time for this RPC call.
| -------- | ------ | ---- | --------------------- |
| 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
......@@ -7071,7 +7074,7 @@ Obtains IPC context information, including the UID and PID, local and remote dev
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
......@@ -7083,17 +7086,16 @@ Obtains the system capability manager.
**Example**
```
```ts
let samgr = rpc.IPCSkeleton.getContextObject();
console.log("RpcServer: getContextObject result: " + samgr);
```
### getCallingPid
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
......@@ -7105,7 +7107,7 @@ Obtains the PID of the caller. This method is invoked by the **RemoteObject** ob
**Example**
```
```ts
class Stub extends rpc.RemoteObject {
onRemoteMessageRequest(code, data, reply, option) {
let callerPid = rpc.IPCSkeleton.getCallingPid();
......@@ -7115,12 +7117,11 @@ Obtains the PID of the caller. This method is invoked by the **RemoteObject** ob
}
```
### getCallingUid
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
......@@ -7132,7 +7133,7 @@ Obtains the UID of the caller. This method is invoked by the **RemoteObject** ob
**Example**
```
```ts
class Stub extends rpc.RemoteObject {
onRemoteMessageRequest(code, data, reply, option) {
let callerUid = rpc.IPCSkeleton.getCallingUid();
......@@ -7142,7 +7143,6 @@ Obtains the UID of the caller. This method is invoked by the **RemoteObject** ob
}
```
### getCallingTokenId<sup>8+</sup>
static getCallingTokenId(): number;
......@@ -7151,7 +7151,6 @@ Obtains the caller's token ID, which is used to verify the caller identity.
**System capability**: SystemCapability.Communication.IPC.Core
**Return value**
| Type | Description |
......@@ -7160,7 +7159,7 @@ Obtains the caller's token ID, which is used to verify the caller identity.
**Example**
```
```ts
class Stub extends rpc.RemoteObject {
onRemoteMessageRequest(code, data, reply, option) {
let callerTokenId = rpc.IPCSkeleton.getCallingTokenId();
......@@ -7187,7 +7186,7 @@ Obtains the ID of the device hosting the caller's process.
**Example**
```
```ts
class Stub extends rpc.RemoteObject {
onRemoteMessageRequest(code, data, reply, option) {
let callerDeviceID = rpc.IPCSkeleton.getCallingDeviceID();
......@@ -7197,12 +7196,11 @@ Obtains the ID of the device hosting the caller's process.
}
```
### getLocalDeviceID
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
......@@ -7214,7 +7212,7 @@ Obtains the local device ID.
**Example**
```
```ts
class Stub extends rpc.RemoteObject {
onRemoteMessageRequest(code, data, reply, option) {
let localDeviceID = rpc.IPCSkeleton.getLocalDeviceID();
......@@ -7224,12 +7222,11 @@ Obtains the local device ID.
}
```
### isLocalCalling
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
......@@ -7241,7 +7238,7 @@ Checks whether the remote process is a process of the local device.
**Example**
```
```ts
class Stub extends rpc.RemoteObject {
onRemoteMessageRequest(code, data, reply, option) {
let isLocalCalling = rpc.IPCSkeleton.isLocalCalling();
......@@ -7251,12 +7248,11 @@ Checks whether the remote process is a process of the local device.
}
```
### flushCmdBuffer<sup>9+</sup>
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
......@@ -7269,7 +7265,7 @@ Flushes all suspended commands from the specified **RemoteProxy** to the corresp
**Example**
```
```ts
class TestRemoteObject extends rpc.RemoteObject {
constructor(descriptor) {
super(descriptor);
......@@ -7284,14 +7280,13 @@ Flushes all suspended commands from the specified **RemoteProxy** to the corresp
}
```
### flushCommands<sup>(deprecated)</sup>
>This API is no longer maintained since API version 9. You are advised to use [flushCmdBuffer](#flushcmdbuffer9).
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
......@@ -7309,7 +7304,7 @@ Flushes all suspended commands from the specified **RemoteProxy** to the corresp
**Example**
```
```ts
class MyDeathRecipient {
onRemoteDied() {
console.log("server died");
......@@ -7338,7 +7333,7 @@ Flushes all suspended commands from the specified **RemoteProxy** to the corresp
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
......@@ -7350,7 +7345,7 @@ Changes the UID and PID of the remote user to the UID and PID of the local user.
**Example**
```
```ts
class Stub extends rpc.RemoteObject {
onRemoteMessageRequest(code, data, reply, option) {
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.
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
......@@ -7377,7 +7372,7 @@ Changes the UID and PID of the remote user to the UID and PID of the local user.
**Example**
```
```ts
class Stub extends rpc.RemoteObject {
onRemoteMessageRequest(code, data, reply, option) {
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.
}
```
### setCallingIdentity<sup>(deprecated)</sup>
>This API is no longer maintained since API version 9. You are advised to use [restoreCallingIdentity](#restorecallingidentity9).
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
......@@ -7417,7 +7411,7 @@ Restores the UID and PID of the remote user. It is usually called when the UID a
**Example**
```
```ts
class Stub extends rpc.RemoteObject {
onRemoteMessageRequest(code, data, reply, option) {
let callingIdentity = null;
......@@ -7433,7 +7427,6 @@ Restores the UID and PID of the remote user. It is usually called when the UID a
}
```
## RemoteObject
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
| 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**
```
```ts
class MyDeathRecipient {
onRemoteDied() {
console.log("server died");
......@@ -7519,7 +7512,6 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch
reply.reclaim();
```
### sendRequest<sup>8+(deprecated)</sup>
>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
**Example**
```
```ts
class MyDeathRecipient {
onRemoteDied() {
console.log("server died");
......@@ -7617,7 +7609,7 @@ Sends a **MessageSequence** message to the remote process in synchronous or asyn
**Example**
```
```ts
class TestRemoteObject extends rpc.RemoteObject {
constructor(descriptor) {
super(descriptor);
......@@ -7648,7 +7640,6 @@ Sends a **MessageSequence** message to the remote process in synchronous or asyn
});
```
### sendMessageRequest<sup>9+</sup>
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
**Example**
```
```ts
class TestRemoteObject extends rpc.RemoteObject {
constructor(descriptor) {
super(descriptor);
......@@ -7697,7 +7688,6 @@ Sends a **MessageSequence** message to the remote process in synchronous or asyn
testRemoteObject.sendMessageRequest(1, data, reply, option, sendRequestCallback);
```
### sendRequest<sup>8+(deprecated)</sup>
>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
**Example**
```
```ts
class MyDeathRecipient {
onRemoteDied() {
console.log("server died");
......@@ -7762,7 +7752,6 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch
testRemoteObject.sendRequest(1, data, reply, option, sendRequestCallback);
```
### onRemoteRequest<sup>8+(deprecated)</sup>
>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
**Example**
```ets
```ts
class MyDeathRecipient {
onRemoteDied() {
console.log("server died");
......@@ -7847,12 +7836,12 @@ Provides a response to **sendMessageRequest()**. The server processes the reques
| 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**. |
**Example**: Overload **onRemoteMessageRequest** to process requests synchronously.
```ets
```ts
class TestRemoteObject extends rpc.RemoteObject {
constructor(descriptor) {
super(descriptor);
......@@ -7872,7 +7861,7 @@ Provides a response to **sendMessageRequest()**. The server processes the reques
**Example**: Overload **onRemoteMessageRequest** to process requests asynchronously.
```ets
```ts
class TestRemoteObject extends rpc.RemoteObject {
constructor(descriptor) {
super(descriptor);
......@@ -7895,7 +7884,7 @@ Provides a response to **sendMessageRequest()**. The server processes the reques
**Example**: Overload **onRemoteMessageRequest** and **onRemoteRequest** to process requests synchronously.
```ets
```ts
class TestRemoteObject extends rpc.RemoteObject {
constructor(descriptor) {
super(descriptor);
......@@ -7926,7 +7915,7 @@ Provides a response to **sendMessageRequest()**. The server processes the reques
**Example**: Overload **onRemoteMessageRequest** and **onRemoteRequest** to process requests asynchronously.
```ets
```ts
class TestRemoteObject extends rpc.RemoteObject {
constructor(descriptor) {
super(descriptor);
......@@ -7957,7 +7946,6 @@ Provides a response to **sendMessageRequest()**. The server processes the reques
}
```
### getCallingUid
getCallingUid(): number
......@@ -7973,7 +7961,7 @@ Obtains the UID of the remote process.
**Example**
```
```ts
class TestRemoteObject extends rpc.RemoteObject {
constructor(descriptor) {
super(descriptor);
......@@ -7999,7 +7987,7 @@ Obtains the PID of the remote process.
**Example**
```
```ts
class TestRemoteObject extends rpc.RemoteObject {
constructor(descriptor) {
super(descriptor);
......@@ -8013,7 +8001,7 @@ Obtains the PID of the remote process.
getLocalInterface(descriptor: string): IRemoteBroker
Obtains the interface.
Obtains the interface descriptor.
**System capability**: SystemCapability.Communication.IPC.Core
......@@ -8032,7 +8020,7 @@ Obtains the interface.
**Example**
```
```ts
class MyDeathRecipient {
onRemoteDied() {
console.log("server died");
......@@ -8057,7 +8045,6 @@ Obtains the interface.
}
```
### queryLocalInterface<sup>(deprecated)</sup>
>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
**Example**
```
```ts
class MyDeathRecipient {
onRemoteDied() {
console.log("server died");
......@@ -8106,7 +8093,6 @@ Checks whether the remote object corresponding to the specified interface token
let broker = testRemoteObject.queryLocalInterface("testObject");
```
### getDescriptor<sup>9+</sup>
getDescriptor(): string
......@@ -8131,7 +8117,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example**
```
```ts
class MyDeathRecipient {
onRemoteDied() {
console.log("server died");
......@@ -8157,7 +8143,6 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
console.log("RpcServer: descriptor is: " + descriptor);
```
### getInterfaceDescriptor<sup>(deprecated)</sup>
>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.
**Example**
```
```ts
class MyDeathRecipient {
onRemoteDied() {
console.log("server died");
......@@ -8201,7 +8186,6 @@ Obtains the interface descriptor.
console.log("RpcServer: descriptor is: " + descriptor);
```
### modifyLocalInterface<sup>9+</sup>
modifyLocalInterface(localInterface: IRemoteBroker, descriptor: string): void
......@@ -8217,10 +8201,9 @@ Binds an interface descriptor to an **IRemoteBroker** object.
| localInterface | IRemoteBroker | Yes | **IRemoteBroker** object. |
| descriptor | string | Yes | Interface descriptor.|
**Example**
```
```ts
class MyDeathRecipient {
onRemoteDied() {
console.log("server died");
......@@ -8267,7 +8250,7 @@ Binds an interface descriptor to an **IRemoteBroker** object.
**Example**
```
```ts
class MyDeathRecipient {
onRemoteDied() {
console.log("server died");
......@@ -8294,15 +8277,14 @@ Binds an interface descriptor to an **IRemoteBroker** object.
let testRemoteObject = new TestRemoteObject("testObject");
```
## 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.
The table below describes the protection types of the mapped memory.
**System capability**: SystemCapability.Communication.IPC.Core
The table below describes the protection types of the mapped memory.
| Name | Value | Description |
| ---------- | --- | ------------------ |
| PROT_EXEC | 4 | The mapped memory is executable. |
......@@ -8310,12 +8292,11 @@ The table below describes the protection types of the mapped memory.
| PROT_READ | 1 | The mapped memory is readable. |
| PROT_WRITE | 2 | The mapped memory is writeable. |
### create<sup>9+</sup>
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
......@@ -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.|
**Example**
```
```ts
let ashmem;
try {
ashmem = rpc.Ashmem.create("ashmem", 1024*1024);
......@@ -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);
```
### createAshmem<sup>8+(deprecated)</sup>
>This API is no longer maintained since API version 9. You are advised to use [create](#create9).
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
......@@ -8373,18 +8352,17 @@ Creates an **Ashmem** object with the specified name and size.
**Example**
```
```ts
let ashmem = rpc.Ashmem.createAshmem("ashmem", 1024*1024);
let size = ashmem.getAshmemSize();
console.log("RpcTest: get ashemm by createAshmem : " + ashmem + " size is : " + size);
```
### create<sup>9+</sup>
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
......@@ -8403,7 +8381,7 @@ Creates an **Ashmem** object by copying the file descriptor (FD) of an existing
**Example**
```
```ts
let ashmem2;
try {
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
console.log("RpcTest: get ashemm by create : " + ashmem2 + " size is : " + size);
```
### createAshmemFromExisting<sup>8+(deprecated)</sup>
>This API is no longer maintained since API version 9. You are advised to use [create](#create9).
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
......@@ -8441,14 +8418,13 @@ Creates an **Ashmem** object by copying the file descriptor (FD) of an existing
**Example**
```
```ts
let ashmem = rpc.Ashmem.createAshmem("ashmem", 1024*1024);
let ashmem2 = rpc.Ashmem.createAshmemFromExisting(ashmem);
let size = ashmem2.getAshmemSize();
console.log("RpcTest: get ashemm by createAshmemFromExisting : " + ashmem2 + " size is : " + size);
```
### closeAshmem<sup>8+</sup>
closeAshmem(): void
......@@ -8459,12 +8435,11 @@ Closes this **Ashmem** object.
**Example**
```
```ts
let ashmem = rpc.Ashmem.create("ashmem", 1024*1024);
ashmem.closeAshmem();
```
### unmapAshmem<sup>8+</sup>
unmapAshmem(): void
......@@ -8475,12 +8450,11 @@ Deletes the mappings for the specified address range of this **Ashmem** object.
**Example**
```
```ts
let ashmem = rpc.Ashmem.create("ashmem", 1024*1024);
ashmem.unmapAshmem();
```
### getAshmemSize<sup>8+</sup>
getAshmemSize(): number
......@@ -8497,13 +8471,12 @@ Obtains the memory size of this **Ashmem** object.
**Example**
```
```ts
let ashmem = rpc.Ashmem.createAshmem("ashmem", 1024*1024);
let size = ashmem.getAshmemSize();
console.log("RpcTest: get ashmem is " + ashmem + " size is : " + size);
```
### mapTypedAshmem<sup>9+</sup>
mapTypedAshmem(mapType: number): void
......@@ -8528,7 +8501,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example**
```
```ts
let ashmem = rpc.Ashmem.create("ashmem", 1024*1024);
try {
ashmem.mapTypedAshmem(ashmem.PROT_READ | ashmem.PROT_WRITE);
......@@ -8538,7 +8511,6 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
}
```
### mapAshmem<sup>8+(deprecated)</sup>
>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
| 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**
```
```ts
let ashmem = rpc.Ashmem.createAshmem("ashmem", 1024*1024);
let mapReadAndWrite = ashmem.mapAshmem(ashmem.PROT_READ | ashmem.PROT_WRITE);
console.log("RpcTest: map ashmem result is : " + mapReadAndWrite);
```
### mapReadWriteAshmem<sup>9+</sup>
mapReadWriteAshmem(): void
......@@ -8588,7 +8559,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example**
```
```ts
let ashmem = rpc.Ashmem.create("ashmem", 1024*1024);
try {
ashmem.mapReadWriteAshmem();
......@@ -8598,7 +8569,6 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
}
```
### mapReadAndWriteAshmem<sup>8+(deprecated)</sup>
>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
| 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**
```
```ts
let ashmem = rpc.Ashmem.createAshmem("ashmem", 1024*1024);
let mapResult = ashmem.mapReadAndWriteAshmem();
console.log("RpcTest: map ashmem result is : " + mapResult);
```
### mapReadonlyAshmem<sup>9+</sup>
mapReadonlyAshmem(): void
......@@ -8642,7 +8611,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example**
```
```ts
let ashmem = rpc.Ashmem.create("ashmem", 1024*1024);
try {
ashmem.mapReadonlyAshmem();
......@@ -8652,7 +8621,6 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
}
```
### mapReadOnlyAshmem<sup>8+(deprecated)</sup>
>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.
| 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**
```
```ts
let ashmem = rpc.Ashmem.createAshmem("ashmem", 1024*1024);
let mapResult = ashmem.mapReadOnlyAshmem();
console.log("RpcTest: Ashmem mapReadOnlyAshmem result is : " + mapResult);
```
### setProtectionType<sup>9+</sup>
setProtectionType(protectionType: number): void
......@@ -8702,7 +8669,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example**
```
```ts
let ashmem = rpc.Ashmem.create("ashmem", 1024*1024);
try {
ashmem.setProtection(ashmem.PROT_READ);
......@@ -8712,7 +8679,6 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
}
```
### setProtection<sup>8+(deprecated)</sup>
>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
**Example**
```
```ts
let ashmem = rpc.Ashmem.createAshmem("ashmem", 1024*1024);
let result = ashmem.setProtection(ashmem.PROT_READ);
console.log("RpcTest: Ashmem setProtection result is : " + result);
```
### writeAshmem<sup>9+</sup>
writeAshmem(buf: number[], size: number, offset: number): void
......@@ -8770,7 +8735,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example**
```
```ts
let ashmem = rpc.Ashmem.create("ashmem", 1024*1024);
ashmem.mapReadWriteAshmem();
var ByteArrayVar = [1, 2, 3, 4, 5];
......@@ -8782,7 +8747,6 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
}
```
### writeToAshmem<sup>8+(deprecated)</sup>
>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.
| 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**
```
```ts
let ashmem = rpc.Ashmem.createAshmem("ashmem", 1024*1024);
let mapResult = ashmem.mapReadAndWriteAshmem();
console.info("RpcTest map ashmem result is " + mapResult);
......@@ -8818,7 +8782,6 @@ Writes data to the shared file associated with this **Ashmem** object.
console.log("RpcTest: write to Ashmem result is : " + writeResult);
```
### readAshmem<sup>9+</sup>
readAshmem(size: number, offset: number): number[]
......@@ -8850,7 +8813,7 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
**Example**
```
```ts
let ashmem = rpc.Ashmem.create("ashmem", 1024*1024);
ashmem.mapReadWriteAshmem();
var ByteArrayVar = [1, 2, 3, 4, 5];
......@@ -8864,7 +8827,6 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
}
```
### readFromAshmem<sup>8+(deprecated)</sup>
>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.
**Example**
```
```ts
let ashmem = rpc.Ashmem.createAshmem("ashmem", 1024*1024);
let mapResult = ashmem.mapReadAndWriteAshmem();
console.info("RpcTest map ashmem result is " + mapResult);
......@@ -8900,3 +8862,4 @@ Reads data from the shared file associated with this **Ashmem** object.
let readResult = ashmem.readFromAshmem(5, 0);
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.
......@@ -26,9 +26,12 @@ getTagInfo(): tag.TagInfo
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
**System capability**: SystemCapability.Communication.NFC.Core
**System capability**: SystemCapability.Communication.NFC.Tag
**Return value**
......@@ -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.
> **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
**System capability**: SystemCapability.Communication.NFC.Core
**System capability**: SystemCapability.Communication.NFC.Tag
**Return value**
......@@ -76,15 +82,52 @@ let connectStatus = tag.getIsoDep(tagInfo).connectTag();
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()
reset(): void
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
**System capability**: SystemCapability.Communication.NFC.Core
**System capability**: SystemCapability.Communication.NFC.Tag
**Example**
......@@ -97,15 +140,52 @@ import tag from '@ohos.nfc.tag';
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
isTagConnected(): boolean
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
**System capability**: SystemCapability.Communication.NFC.Core
**System capability**: SystemCapability.Communication.NFC.Tag
**Return value**
......@@ -125,15 +205,50 @@ let isTagConnected = tag.getIsoDep(tagInfo).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
getMaxSendLength(): number
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
**System capability**: SystemCapability.Communication.NFC.Core
**System capability**: SystemCapability.Communication.NFC.Tag
**Return value**
......@@ -152,15 +267,57 @@ let maxSendLen = tag.getIsoDep(tagInfo).getMaxSendLength();
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
getSendDataTimeout(): number
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
**System capability**: SystemCapability.Communication.NFC.Core
**System capability**: SystemCapability.Communication.NFC.Tag
**Return value**
......@@ -180,15 +337,58 @@ let sendDataTimeout = tag.getIsoDep(tagInfo).getSendDataTimeout();
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
setSendDataTimeout(timeout: number): boolean
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
**System capability**: SystemCapability.Communication.NFC.Core
**System capability**: SystemCapability.Communication.NFC.Tag
**Parameters**
......@@ -215,15 +415,59 @@ let setStatus = tag.getIsoDep(tagInfo).setSendDataTimeout(timeoutMs);
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
sendData(data: number[]): Promise<number[]>
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
**System capability**: SystemCapability.Communication.NFC.Core
**System capability**: SystemCapability.Communication.NFC.Tag
**Parameters**
......@@ -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.
> **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
**System capability**: SystemCapability.Communication.NFC.Core
**System capability**: SystemCapability.Communication.NFC.Tag
**Parameters**
......@@ -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.
## IpType<sup>7+</sup>
Enumerate the IP address types.
Enumerates the IP address types.
**System API**: This is a system API.
......
# 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**
......@@ -1038,7 +1037,7 @@ Removes the specified network configuration.
| **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**
......@@ -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
......
# WLAN Extension Interface
This **wifiext** module provides WLAN extension interfaces for non-universal products.
> **NOTE**
......@@ -26,9 +25,9 @@ Enables the WLAN hotspot.
**Return value**
| **Type**| **Description**|
| -------- | -------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
| **Type**| **Description**|
| -------- | -------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
## wifiext.disableHotspot
......@@ -43,9 +42,9 @@ Disables the WLAN hotspot.
**Return value**
| **Type**| **Description**|
| -------- | -------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
| **Type**| **Description**|
| -------- | -------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
## wifiext.getSupportedPowerModel
......@@ -60,9 +59,9 @@ Obtains the supported power models. This API uses a promise to return the result
**Return value**
| Type| Description|
| -------- | -------- |
| Promise&lt;Array&lt;[PowerModel](#powermodel)&gt;&gt; | Promise used to return the power models obtained.|
| Type| Description|
| -------- | -------- |
| Promise&lt;Array&lt;[PowerModel](#powermodel)&gt;&gt; | Promise used to return the power models obtained.|
## PowerModel
......@@ -90,9 +89,9 @@ Obtains the supported power models. This API uses an asynchronous callback to re
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;Array&lt;[PowerModel](#powermodel)&gt;&gt; | Yes| Callback invoked to return the result. If the operation is successful, **err** is 0 and **data** is the power models obtained. If **err** is not **0**, an error has occurred.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;Array&lt;[PowerModel](#powermodel)&gt;&gt; | Yes| Callback invoked to return the result. If the operation is successful, **err** is 0 and **data** is the power models obtained. If **err** is not **0**, an error has occurred.|
## wifiext.getPowerModel
......@@ -107,9 +106,9 @@ Obtains the power model. This API uses a promise to return the result.
**Return value**
| Type| Description|
| -------- | -------- |
| Promise&lt;[PowerModel](#powermodel)&gt; | Promise used to return the power model obtained.|
| Type| Description|
| -------- | -------- |
| Promise&lt;[PowerModel](#powermodel)&gt; | Promise used to return the power model obtained.|
## wifiext.getPowerModel
......@@ -124,16 +123,16 @@ Obtains the power model. This API uses an asynchronous callback to return the re
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;[PowerModel](#powermodel)&gt; | Yes| Callback invoked to return the result. If the operation is successful, **err** is **0** and **data** is the power model obtained. If **err** is not **0**, an error has occurred.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;[PowerModel](#powermodel)&gt; | Yes| Callback invoked to return the result. If the operation is successful, **err** is **0** and **data** is the power model obtained. If **err** is not **0**, an error has occurred.|
## wifiext.setPowerModel
setPowerModel(model: PowerModel) : boolean;
Sets the power model.
Sets the power model.
**Required permissions**: ohos.permission.MANAGE_WIFI_HOTSPOT_EXT
......@@ -141,12 +140,12 @@ setPowerModel(model: PowerModel) : boolean;
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| model | [PowerModel](#powermodel) | Yes| Power model to set.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| model | [PowerModel](#powermodel) | Yes| Power model to set.|
**Return value**
| **Type**| **Description**|
| -------- | -------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
| **Type**| **Description**|
| -------- | -------- |
| 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.
......@@ -26,9 +26,9 @@ Enables the WLAN hotspot.
**Return value**
| **Type**| **Description**|
| -------- | -------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
| **Type**| **Description**|
| -------- | -------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
## wifiext.disableHotspot
......@@ -43,9 +43,9 @@ Disables the WLAN hotspot.
**Return value**
| **Type**| **Description**|
| -------- | -------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
| **Type**| **Description**|
| -------- | -------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
## wifiext.getSupportedPowerModel
......@@ -60,9 +60,9 @@ Obtains the supported power models. This API uses a promise to return the result
**Return value**
| Type| Description|
| -------- | -------- |
| Promise&lt;Array&lt;[PowerModel](#powermodel)&gt;&gt; | Promise used to return the power models obtained.|
| Type| Description|
| -------- | -------- |
| Promise&lt;Array&lt;[PowerModel](#powermodel)&gt;&gt; | Promise used to return the power models obtained.|
## PowerModel
......@@ -90,9 +90,9 @@ Obtains the supported power models. This API uses an asynchronous callback to re
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;Array&lt;[PowerModel](#powermodel)&gt;&gt; | Yes| Callback invoked to return the result. If the operation is successful, **err** is 0 and **data** is the power models obtained. If **err** is not **0**, an error has occurred.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;Array&lt;[PowerModel](#powermodel)&gt;&gt; | Yes| Callback invoked to return the result. If the operation is successful, **err** is 0 and **data** is the power models obtained. If **err** is not **0**, an error has occurred.|
## wifiext.getPowerModel
......@@ -107,9 +107,9 @@ Obtains the power model. This API uses a promise to return the result.
**Return value**
| Type| Description|
| -------- | -------- |
| Promise&lt;[PowerModel](#powermodel)&gt; | Promise used to return the power model obtained.|
| Type| Description|
| -------- | -------- |
| Promise&lt;[PowerModel](#powermodel)&gt; | Promise used to return the power model obtained.|
## wifiext.getPowerModel
......@@ -124,16 +124,16 @@ Obtains the power model. This API uses an asynchronous callback to return the re
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;[PowerModel](#powermodel)&gt; | Yes| Callback invoked to return the result. If the operation is successful, **err** is **0** and **data** is the power model obtained. If **err** is not **0**, an error has occurred.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;[PowerModel](#powermodel)&gt; | Yes| Callback invoked to return the result. If the operation is successful, **err** is **0** and **data** is the power model obtained. If **err** is not **0**, an error has occurred.|
## wifiext.setPowerModel
setPowerModel(model: PowerModel) : boolean;
Sets the power model.
Sets the power model.
**Required permissions**: ohos.permission.MANAGE_WIFI_HOTSPOT_EXT
......@@ -141,12 +141,12 @@ setPowerModel(model: PowerModel) : boolean;
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| model | [PowerModel](#powermodel) | Yes| Power model to set.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| model | [PowerModel](#powermodel) | Yes| Power model to set.|
**Return value**
| **Type**| **Description**|
| -------- | -------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
| **Type**| **Description**|
| -------- | -------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册