提交 f61b6a68 编写于 作者: A annie_wangli

update docs

Signed-off-by: Nannie_wangli <annie.wangli@huawei.com>
上级 03de8509
# RPC Communication # RPC
> ![icon-note.gif](public_sys-resources/icon-note.gif) **Note:** > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br/>
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. > 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.
...@@ -13,11 +13,6 @@ import rpc from '@ohos.rpc'; ...@@ -13,11 +13,6 @@ import rpc from '@ohos.rpc';
``` ```
## Required Permissions
None
## MessageParcel ## MessageParcel
Provides methods for reading and writing basic data types and arrays, inter-process communication (IPC) objects, interface tokens, and sequenceable objects. Provides methods for reading and writing basic data types and arrays, inter-process communication (IPC) objects, interface tokens, and sequenceable objects.
...@@ -29,11 +24,12 @@ create(): MessageParcel ...@@ -29,11 +24,12 @@ create(): MessageParcel
Creates a **MessageParcel** object. This method is a static method. Creates a **MessageParcel** object. This method is a static method.
**System capability**: SystemCapability.Communication.IPC.Core
- Return values - Return value
| Type | Description | | Type| Description|
| -------- | -------- | | -------- | -------- |
| MessageParcel | **MessageParcel**&nbsp;object&nbsp;created. | | MessageParcel | **MessageParcel** object created.|
- Example - Example
...@@ -47,8 +43,9 @@ Creates a **MessageParcel** object. This method is a static method. ...@@ -47,8 +43,9 @@ Creates a **MessageParcel** object. This method is a static method.
reclaim(): void reclaim(): void
Reclaims the **MessageParcel** instance that is no longer used. Reclaims the **MessageParcel** object that is no longer used.
**System capability**: SystemCapability.Communication.IPC.Core
- Example - Example
...@@ -63,15 +60,18 @@ Reclaims the **MessageParcel** instance that is no longer used. ...@@ -63,15 +60,18 @@ Reclaims the **MessageParcel** instance that is no longer used.
writeRemoteObject(object: [IRemoteObject](#iremoteobject)): boolean writeRemoteObject(object: [IRemoteObject](#iremoteobject)): boolean
Serializes a remote object and writes it to this **MessageParcel** object. Serializes a remote object and writes it to this **MessageParcel** object.
**System capability**: SystemCapability.Communication.IPC.Core
- Parameters - Parameters
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| object | [IRemoteObject](#iremoteobject) | Yes | Remote&nbsp;object&nbsp;to&nbsp;serialize&nbsp;and&nbsp;write&nbsp;to&nbsp;the&nbsp;**MessageParcel**&nbsp;object. | | object | [IRemoteObject](#iremoteobject) | Yes| Remote object to serialize and write to the **MessageParcel** object.|
- Return values - Return value
| Type | Description | | Type| Description|
| -------- | -------- | | -------- | -------- |
| boolean | Returns&nbsp;**true**&nbsp;if&nbsp;the&nbsp;operation&nbsp;is&nbsp;successful;&nbsp;returns&nbsp;**false**&nbsp;otherwise. | | boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
- Example - Example
...@@ -93,11 +93,12 @@ readRemoteObject(): IRemoteObject ...@@ -93,11 +93,12 @@ readRemoteObject(): IRemoteObject
Reads the remote object from this **MessageParcel** object. You can use this method to deserialize the **MessageParcel** object to generate an **IRemoteObject**. The remote objects are read in the order in which they are written to this **MessageParcel** object. Reads the remote object from this **MessageParcel** object. You can use this method to deserialize the **MessageParcel** object to generate an **IRemoteObject**. The remote objects are read in the order in which they are written to this **MessageParcel** object.
**System capability**: SystemCapability.Communication.IPC.Core
- Return values - Return value
| Type | Description | | Type| Description|
| -------- | -------- | | -------- | -------- |
| [IRemoteObject](#iremoteobject) | Remote&nbsp;object&nbsp;obtained. | | [IRemoteObject](#iremoteobject) | Remote object obtained.|
- Example - Example
...@@ -120,16 +121,17 @@ writeInterfaceToken(token: string): boolean ...@@ -120,16 +121,17 @@ writeInterfaceToken(token: string): boolean
Writes an interface token to this **MessageParcel** object. Writes an interface token to this **MessageParcel** object.
**System capability**: SystemCapability.Communication.IPC.Core
- Parameters - Parameters
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| token | string | Yes | Interface&nbsp;token&nbsp;to&nbsp;write. | | token | string | Yes| Interface token to write.|
- Return values - Return value
| Type | Description | | Type| Description|
| -------- | -------- | | -------- | -------- |
| boolean | Returns&nbsp;**true**&nbsp;if&nbsp;the&nbsp;operation&nbsp;is&nbsp;successful;&nbsp;returns&nbsp;**false**&nbsp;otherwise. | | boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
- Example - Example
...@@ -146,11 +148,12 @@ readInterfaceToken(): string ...@@ -146,11 +148,12 @@ readInterfaceToken(): string
Reads the interface token from this **MessageParcel** object. The interface tokens are read in the order in which they are written into the **MessageParcel** object. Reads the interface token from this **MessageParcel** object. The interface tokens are read in the order in which they are written into the **MessageParcel** object.
**System capability**: SystemCapability.Communication.IPC.Core
- Return values - Return value
| Type | Description | | Type| Description|
| -------- | -------- | | -------- | -------- |
| string | Interface&nbsp;token&nbsp;obtained. | | string | Interface token obtained.|
- Example - Example
...@@ -171,11 +174,12 @@ getSize(): number ...@@ -171,11 +174,12 @@ getSize(): number
Obtains the data size of this **MessageParcel** object. Obtains the data size of this **MessageParcel** object.
**System capability**: SystemCapability.Communication.IPC.Core
- Return values - Return value
| Type | Description | | Type| Description|
| -------- | -------- | | -------- | -------- |
| number | Data&nbsp;size&nbsp;obtained,&nbsp;in&nbsp;bytes. | | number | Size of the **MessageParcel** object obtained, in bytes.|
- Example - Example
...@@ -192,11 +196,12 @@ getCapacity(): number ...@@ -192,11 +196,12 @@ getCapacity(): number
Obtains the capacity of this **MessageParcel** object. Obtains the capacity of this **MessageParcel** object.
**System capability**: SystemCapability.Communication.IPC.Core
- Return values - Return value
| Type | Description | | Type| Description|
| -------- | -------- | | -------- | -------- |
| number | **MessageParcel**&nbsp;capacity&nbsp;obtained,&nbsp;in&nbsp;bytes. | | number | **MessageParcel** capacity obtained, in bytes.|
- Example - Example
...@@ -213,16 +218,17 @@ setSize(size: number): boolean ...@@ -213,16 +218,17 @@ setSize(size: number): boolean
Sets the size of data contained in this **MessageParcel** object. Sets the size of data contained in this **MessageParcel** object.
**System capability**: SystemCapability.Communication.IPC.Core
- Parameters - Parameters
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| size | number | Yes | Data&nbsp;size&nbsp;to&nbsp;set,&nbsp;in&nbsp;bytes. | | size | number | Yes| Data size to set, in bytes.|
- Return values - Return value
| Type | Description | | Type| Description|
| -------- | -------- | | -------- | -------- |
| boolean | Returns&nbsp;**true**&nbsp;if&nbsp;the&nbsp;operation&nbsp;is&nbsp;successful;&nbsp;returns&nbsp;**false**&nbsp;otherwise. | | boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
- Example - Example
...@@ -239,16 +245,17 @@ setCapacity(size: number): boolean ...@@ -239,16 +245,17 @@ setCapacity(size: number): boolean
Sets the storage capacity of this **MessageParcel** object. Sets the storage capacity of this **MessageParcel** object.
**System capability**: SystemCapability.Communication.IPC.Core
- Parameters - Parameters
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| size | number | Yes | Storage&nbsp;capacity&nbsp;to&nbsp;set,&nbsp;in&nbsp;bytes. | | size | number | Yes| Storage capacity to set, in bytes.|
- Return values - Return value
| Type | Description | | Type| Description|
| -------- | -------- | | -------- | -------- |
| boolean | Returns&nbsp;**true**&nbsp;if&nbsp;the&nbsp;operation&nbsp;is&nbsp;successful;&nbsp;returns&nbsp;**false**&nbsp;otherwise. | | boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
- Example - Example
...@@ -265,11 +272,12 @@ getWritableBytes(): number ...@@ -265,11 +272,12 @@ getWritableBytes(): number
Obtains the writable capacity of this **MessageParcel** object. Obtains the writable capacity of this **MessageParcel** object.
**System capability**: SystemCapability.Communication.IPC.Core
- Return values - Return value
| Type | Description | | Type| Description|
| -------- | -------- | | -------- | -------- |
| number | **MessageParcel**&nbsp;writable&nbsp;capacity&nbsp;obtained,&nbsp;in&nbsp;bytes. | | number | **MessageParcel** writable capacity obtained, in bytes.|
- Example - Example
...@@ -290,11 +298,12 @@ getReadableBytes(): number ...@@ -290,11 +298,12 @@ getReadableBytes(): number
Obtains the readable capacity of this **MessageParcel** object. Obtains the readable capacity of this **MessageParcel** object.
**System capability**: SystemCapability.Communication.IPC.Core
- Return values - Return value
| Type | Description | | Type| Description|
| -------- | -------- | | -------- | -------- |
| number | **MessageParcel**&nbsp;readable&nbsp;capacity&nbsp;obtained,&nbsp;in&nbsp;bytes. | | number | **MessageParcel** object readable capacity, in bytes.|
- Example - Example
...@@ -315,11 +324,12 @@ getReadPosition(): number ...@@ -315,11 +324,12 @@ getReadPosition(): number
Obtains the read position of this **MessageParcel** object. Obtains the read position of this **MessageParcel** object.
**System capability**: SystemCapability.Communication.IPC.Core
- Return values - Return value
| Type | Description | | Type| Description|
| -------- | -------- | | -------- | -------- |
| number | Current&nbsp;read&nbsp;position&nbsp;of&nbsp;the&nbsp;**MessageParcel**&nbsp;object. | | number | Current read position of the **MessageParcel** object.|
- Example - Example
...@@ -336,11 +346,12 @@ getWritePosition(): number ...@@ -336,11 +346,12 @@ getWritePosition(): number
Obtains the write position of this **MessageParcel** object. Obtains the write position of this **MessageParcel** object.
**System capability**: SystemCapability.Communication.IPC.Core
- Return values - Return value
| Type | Description | | Type| Description|
| -------- | -------- | | -------- | -------- |
| number | Current&nbsp;write&nbsp;position&nbsp;of&nbsp;the&nbsp;**MessageParcel**&nbsp;object. | | number | Current write position of the **MessageParcel** object.|
- Example - Example
...@@ -358,16 +369,17 @@ rewindRead(pos: number): boolean ...@@ -358,16 +369,17 @@ rewindRead(pos: number): boolean
Moves the read pointer to the specified position. Moves the read pointer to the specified position.
**System capability**: SystemCapability.Communication.IPC.Core
- Parameters - Parameters
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| pos | number | Yes | Position&nbsp;from&nbsp;which&nbsp;data&nbsp;is&nbsp;to&nbsp;read. | | pos | number | Yes| Position from which data is to read.|
- Return values - Return value
| Type | Description | | Type| Description|
| -------- | -------- | | -------- | -------- |
| boolean | Returns&nbsp;**true**&nbsp;if&nbsp;the&nbsp;read&nbsp;position&nbsp;changes;&nbsp;returns&nbsp;**false**&nbsp;otherwise. | | boolean | Returns **true** if the read position changes; returns **false** otherwise.|
- Example - Example
...@@ -389,16 +401,17 @@ rewindWrite(pos: number): boolean ...@@ -389,16 +401,17 @@ rewindWrite(pos: number): boolean
Moves the write pointer to the specified position. Moves the write pointer to the specified position.
**System capability**: SystemCapability.Communication.IPC.Core
- Parameters - Parameters
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| pos | number | Yes | Position&nbsp;from&nbsp;which&nbsp;data&nbsp;is&nbsp;to&nbsp;write. | | pos | number | Yes| Position from which data is to write.|
- Return values - Return value
| Type | Description | | Type| Description|
| -------- | -------- | | -------- | -------- |
| boolean | Returns&nbsp;**true**&nbsp;if&nbsp;the&nbsp;write&nbsp;position&nbsp;changes;&nbsp;returns&nbsp;**false**&nbsp;otherwise. | | boolean | Returns **true** if the write position changes; returns **false** otherwise.|
- Example - Example
...@@ -416,18 +429,19 @@ Moves the write pointer to the specified position. ...@@ -416,18 +429,19 @@ Moves the write pointer to the specified position.
writeByte(val: number): boolean writeByte(val: number): boolean
Writes a **Byte** value to this **MessageParcel** object. Writes a Byte value to this **MessageParcel** object.
**System capability**: SystemCapability.Communication.IPC.Core
- Parameters - Parameters
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| val | number | Yes | **Byte**&nbsp;value&nbsp;to&nbsp;write. | | val | number | Yes| Byte value to write.|
- Return values - Return value
| Type | Description | | Type| Description|
| -------- | -------- | | -------- | -------- |
| boolean | Returns&nbsp;**true**&nbsp;if&nbsp;the&nbsp;operation&nbsp;is&nbsp;successful;&nbsp;returns&nbsp;**false**&nbsp;otherwise. | | boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
- Example - Example
...@@ -442,13 +456,14 @@ Writes a **Byte** value to this **MessageParcel** object. ...@@ -442,13 +456,14 @@ Writes a **Byte** value to this **MessageParcel** object.
readByte(): number readByte(): number
Reads the **Byte** value from this **MessageParcel** object. Reads the Byte value from this **MessageParcel** object.
**System capability**: SystemCapability.Communication.IPC.Core
- Return values - Return value
| Type | Description | | Type| Description|
| -------- | -------- | | -------- | -------- |
| number | **Byte**&nbsp;value&nbsp;read. | | number | Byte value read.|
- Example - Example
...@@ -465,18 +480,19 @@ Reads the **Byte** value from this **MessageParcel** object. ...@@ -465,18 +480,19 @@ Reads the **Byte** value from this **MessageParcel** object.
writeShort(val: number): boolean writeShort(val: number): boolean
Writes a **Short int** value to this **MessageParcel** object. Writes a Short int value to this **MessageParcel** object.
**System capability**: SystemCapability.Communication.IPC.Core
- Parameters - Parameters
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| val | number | Yes | **Short&nbsp;int**&nbsp;value&nbsp;to&nbsp;write. | | val | number | Yes| Short int value to write.|
- Return values - Return value
| Type | Description | | Type| Description|
| -------- | -------- | | -------- | -------- |
| boolean | Returns&nbsp;**true**&nbsp;if&nbsp;the&nbsp;operation&nbsp;is&nbsp;successful;&nbsp;returns&nbsp;**false**&nbsp;otherwise. | | boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
- Example - Example
...@@ -491,13 +507,14 @@ Writes a **Short int** value to this **MessageParcel** object. ...@@ -491,13 +507,14 @@ Writes a **Short int** value to this **MessageParcel** object.
readShort(): number readShort(): number
Reads the **Short int** value from this **MessageParcel** object. Reads the Short int value from this **MessageParcel** object.
**System capability**: SystemCapability.Communication.IPC.Core
- Return values - Return value
| Type | Description | | Type| Description|
| -------- | -------- | | -------- | -------- |
| number | **Short&nbsp;int**&nbsp;value&nbsp;read. | | number | Short int value read.|
- Example - Example
...@@ -514,18 +531,19 @@ Reads the **Short int** value from this **MessageParcel** object. ...@@ -514,18 +531,19 @@ Reads the **Short int** value from this **MessageParcel** object.
writeInt(val: number): boolean writeInt(val: number): boolean
Writes an **Int** value to this **MessageParcel** object. Writes an Int value to this **MessageParcel** object.
**System capability**: SystemCapability.Communication.IPC.Core
- Parameters - Parameters
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| val | number | Yes | **Int**&nbsp;value&nbsp;to&nbsp;write. | | val | number | Yes| Int value to write.|
- Return values - Return value
| Type | Description | | Type| Description|
| -------- | -------- | | -------- | -------- |
| boolean | Returns&nbsp;**true**&nbsp;if&nbsp;the&nbsp;operation&nbsp;is&nbsp;successful;&nbsp;returns&nbsp;**false**&nbsp;otherwise. | | boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
- Example - Example
...@@ -540,13 +558,14 @@ Writes an **Int** value to this **MessageParcel** object. ...@@ -540,13 +558,14 @@ Writes an **Int** value to this **MessageParcel** object.
readInt(): number readInt(): number
Reads the **Int** value from this **MessageParcel** object. Reads the Int value from this **MessageParcel** object.
**System capability**: SystemCapability.Communication.IPC.Core
- Return values - Return value
| Type | Description | | Type| Description|
| -------- | -------- | | -------- | -------- |
| number | **Int**&nbsp;value&nbsp;read. | | number | Int value read.|
- Example - Example
...@@ -563,18 +582,19 @@ Reads the **Int** value from this **MessageParcel** object. ...@@ -563,18 +582,19 @@ Reads the **Int** value from this **MessageParcel** object.
writeLong(val: number): boolean writeLong(val: number): boolean
Writes a **Long int** value to this **MessageParcel** object. Writes a Long int value to this **MessageParcel** object.
**System capability**: SystemCapability.Communication.IPC.Core
- Parameters - Parameters
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| val | number | Yes | **Long&nbsp;int**&nbsp;value&nbsp;to&nbsp;write. | | val | number | Yes| Long int value to write.|
- Return values - Return value
| Type | Description | | Type| Description|
| -------- | -------- | | -------- | -------- |
| boolean | Returns&nbsp;**true**&nbsp;if&nbsp;the&nbsp;operation&nbsp;is&nbsp;successful;&nbsp;returns&nbsp;**false**&nbsp;otherwise. | | boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
- Example - Example
...@@ -589,13 +609,14 @@ Writes a **Long int** value to this **MessageParcel** object. ...@@ -589,13 +609,14 @@ Writes a **Long int** value to this **MessageParcel** object.
readLong(): number readLong(): number
Reads the **Long int** value from this **MessageParcel** object. Reads the Long int value from this **MessageParcel** object.
**System capability**: SystemCapability.Communication.IPC.Core
- Return values - Return value
| Type | Description | | Type| Description|
| -------- | -------- | | -------- | -------- |
| number | **Long&nbsp;int**&nbsp;value&nbsp;read. | | number | Long int value read.|
- Example - Example
...@@ -612,18 +633,19 @@ Reads the **Long int** value from this **MessageParcel** object. ...@@ -612,18 +633,19 @@ Reads the **Long int** value from this **MessageParcel** object.
writeFloat(val: number): boolean writeFloat(val: number): boolean
Writes a **Float** value to this **MessageParcel** object. Writes a Float value to this **MessageParcel** object.
**System capability**: SystemCapability.Communication.IPC.Core
- Parameters - Parameters
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| val | number | Yes | **Float**&nbsp;value&nbsp;to&nbsp;write. | | val | number | Yes| Float value to write.|
- Return values - Return value
| Type | Description | | Type| Description|
| -------- | -------- | | -------- | -------- |
| boolean | Returns&nbsp;**true**&nbsp;if&nbsp;the&nbsp;operation&nbsp;is&nbsp;successful;&nbsp;returns&nbsp;**false**&nbsp;otherwise. | | boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
- Example - Example
...@@ -638,13 +660,14 @@ Writes a **Float** value to this **MessageParcel** object. ...@@ -638,13 +660,14 @@ Writes a **Float** value to this **MessageParcel** object.
readFloat(): number readFloat(): number
Reads the **Float** value from this **MessageParcel** object. Reads the Float value from this **MessageParcel** object.
**System capability**: SystemCapability.Communication.IPC.Core
- Return values - Return value
| Type | Description | | Type| Description|
| -------- | -------- | | -------- | -------- |
| number | **Float**&nbsp;value&nbsp;read. | | number | Float value read.|
- Example - Example
...@@ -661,18 +684,19 @@ Reads the **Float** value from this **MessageParcel** object. ...@@ -661,18 +684,19 @@ Reads the **Float** value from this **MessageParcel** object.
writeDouble(val: number): boolean writeDouble(val: number): boolean
Writes a **Double** value to this **MessageParcel** object. Writes a Double value to this **MessageParcel** object.
**System capability**: SystemCapability.Communication.IPC.Core
- Parameters - Parameters
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| val | number | Yes | **Double**&nbsp;value&nbsp;to&nbsp;write. | | val | number | Yes| Double value to write.|
- Return values - Return value
| Type | Description | | Type| Description|
| -------- | -------- | | -------- | -------- |
| boolean | Returns&nbsp;**true**&nbsp;if&nbsp;the&nbsp;operation&nbsp;is&nbsp;successful;&nbsp;returns&nbsp;**false**&nbsp;otherwise. | | boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
- Example - Example
...@@ -687,13 +711,14 @@ Writes a **Double** value to this **MessageParcel** object. ...@@ -687,13 +711,14 @@ Writes a **Double** value to this **MessageParcel** object.
readDouble(): number readDouble(): number
Reads the **Double** value from this **MessageParcel** object. Reads the Double value from this **MessageParcel** object.
**System capability**: SystemCapability.Communication.IPC.Core
- Return values - Return value
| Type | Description | | Type| Description|
| -------- | -------- | | -------- | -------- |
| number | **Double**&nbsp;value&nbsp;read. | | number | Double value read.|
- Example - Example
...@@ -710,18 +735,19 @@ Reads the **Double** value from this **MessageParcel** object. ...@@ -710,18 +735,19 @@ Reads the **Double** value from this **MessageParcel** object.
writeBoolean(val: boolean): boolean writeBoolean(val: boolean): boolean
Writes a **Boolean** value to this **MessageParcel** object. Writes a Boolean value to this **MessageParcel** object.
**System capability**: SystemCapability.Communication.IPC.Core
- Parameters - Parameters
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| val | boolean | Yes | **Boolean**&nbsp;value&nbsp;to&nbsp;write. | | val | boolean | Yes| Boolean value to write.|
- Return values - Return value
| Type | Description | | Type| Description|
| -------- | -------- | | -------- | -------- |
| boolean | Returns&nbsp;**true**&nbsp;if&nbsp;the&nbsp;operation&nbsp;is&nbsp;successful;&nbsp;returns&nbsp;**false**&nbsp;otherwise. | | boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
- Example - Example
...@@ -736,13 +762,14 @@ Writes a **Boolean** value to this **MessageParcel** object. ...@@ -736,13 +762,14 @@ Writes a **Boolean** value to this **MessageParcel** object.
readBoolean(): boolean readBoolean(): boolean
Reads the **Boolean** value from this **MessageParcel** object. Reads the Boolean value from this **MessageParcel** object.
**System capability**: SystemCapability.Communication.IPC.Core
- Return values - Return value
| Type | Description | | Type| Description|
| -------- | -------- | | -------- | -------- |
| boolean | **Boolean**&nbsp;value&nbsp;read. | | boolean | Boolean value read.|
- Example - Example
...@@ -759,18 +786,19 @@ Reads the **Boolean** value from this **MessageParcel** object. ...@@ -759,18 +786,19 @@ Reads the **Boolean** value from this **MessageParcel** object.
writeChar(val: number): boolean writeChar(val: number): boolean
Writes a **Char** value to this **MessageParcel** object. Writes a Char value to this **MessageParcel** object.
**System capability**: SystemCapability.Communication.IPC.Core
- Parameters - Parameters
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| val | number | Yes | **Char**&nbsp;value&nbsp;to&nbsp;write. | | val | number | Yes| Char value to write.|
- Return values - Return value
| Type | Description | | Type| Description|
| -------- | -------- | | -------- | -------- |
| boolean | Returns&nbsp;**true**&nbsp;if&nbsp;the&nbsp;operation&nbsp;is&nbsp;successful;&nbsp;returns&nbsp;**false**&nbsp;otherwise. | | boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
- Example - Example
...@@ -785,13 +813,14 @@ Writes a **Char** value to this **MessageParcel** object. ...@@ -785,13 +813,14 @@ Writes a **Char** value to this **MessageParcel** object.
readChar(): number readChar(): number
Reads the **Char** value from this **MessageParcel** object. Reads the Char value from this **MessageParcel** object.
**System capability**: SystemCapability.Communication.IPC.Core
- Return values - Return value
| Type | Description | | Type| Description|
| -------- | -------- | | -------- | -------- |
| number | **Char**&nbsp;value&nbsp;read. | | number | Char value read.|
- Example - Example
...@@ -808,18 +837,19 @@ Reads the **Char** value from this **MessageParcel** object. ...@@ -808,18 +837,19 @@ Reads the **Char** value from this **MessageParcel** object.
writeString(val: string): boolean writeString(val: string): boolean
Writes a **String** value to this **MessageParcel** object. Writes a String value to this **MessageParcel** object.
**System capability**: SystemCapability.Communication.IPC.Core
- Parameters - Parameters
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| val | string | Yes | **String**&nbsp;value&nbsp;to&nbsp;write. | | val | string | Yes| String value to write.|
- Return values - Return value
| Type | Description | | Type| Description|
| -------- | -------- | | -------- | -------- |
| boolean | Returns&nbsp;**true**&nbsp;if&nbsp;the&nbsp;operation&nbsp;is&nbsp;successful;&nbsp;returns&nbsp;**false**&nbsp;otherwise. | | boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
- Example - Example
...@@ -834,13 +864,14 @@ Writes a **String** value to this **MessageParcel** object. ...@@ -834,13 +864,14 @@ Writes a **String** value to this **MessageParcel** object.
readString(): string readString(): string
Reads the **String** value from this **MessageParcel** object. Reads the String value from this **MessageParcel** object.
**System capability**: SystemCapability.Communication.IPC.Core
- Return values - Return value
| Type | Description | | Type| Description|
| -------- | -------- | | -------- | -------- |
| string | **String**&nbsp;value&nbsp;read. | | string | String value read.|
- Example - Example
...@@ -859,16 +890,17 @@ writeSequenceable(val: Sequenceable): boolean ...@@ -859,16 +890,17 @@ writeSequenceable(val: Sequenceable): boolean
Writes a sequenceable object to this **MessageParcel** object. Writes a sequenceable object to this **MessageParcel** object.
**System capability**: SystemCapability.Communication.IPC.Core
- Parameters - Parameters
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| val | [Sequenceable](#sequenceable) | Yes | Sequenceable&nbsp;object&nbsp;to&nbsp;write. | | val | [Sequenceable](#sequenceable) | Yes| Sequenceable object to write.|
- Return values - Return value
| Type | Description | | Type| Description|
| -------- | -------- | | -------- | -------- |
| boolean | Returns&nbsp;**true**&nbsp;if&nbsp;the&nbsp;operation&nbsp;is&nbsp;successful;&nbsp;returns&nbsp;**false**&nbsp;otherwise. | | boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
- Example - Example
...@@ -900,18 +932,19 @@ Writes a sequenceable object to this **MessageParcel** object. ...@@ -900,18 +932,19 @@ Writes a sequenceable object to this **MessageParcel** object.
readSequenceable(dataIn: Sequenceable) : boolean readSequenceable(dataIn: Sequenceable) : boolean
Reads member variables from the **MessageParcel** instance. Reads member variables from this **MessageParcel** object.
**System capability**: SystemCapability.Communication.IPC.Core
- Parameters - Parameters
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| dataIn | [Sequenceable](#sequenceable) | Yes | Object&nbsp;that&nbsp;reads&nbsp;member&nbsp;variables&nbsp;from&nbsp;the&nbsp;**MessageParcel**&nbsp;instance. | | dataIn | [Sequenceable](#sequenceable) | Yes| Object that reads member variables from the **MessageParcel** object.|
- Return values - Return value
| Type | Description | | Type| Description|
| -------- | -------- | | -------- | -------- |
| boolean | Returns&nbsp;**true**&nbsp;if&nbsp;the&nbsp;operation&nbsp;is&nbsp;successful;&nbsp;returns&nbsp;**false**&nbsp;otherwise. | | boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
- Example - Example
...@@ -946,18 +979,19 @@ Reads member variables from the **MessageParcel** instance. ...@@ -946,18 +979,19 @@ Reads member variables from the **MessageParcel** instance.
writeByteArray(byteArray: number[]): boolean writeByteArray(byteArray: number[]): boolean
Writes a **ByteArray** to this **MessageParcel** object. Writes a ByteArray to this **MessageParcel** object.
**System capability**: SystemCapability.Communication.IPC.Core
- Parameters - Parameters
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| byteArray | number[] | Yes | **ByteArray**&nbsp;to&nbsp;write. | | byteArray | number[] | Yes| ByteArray to write.|
- Return values - Return value
| Type | Description | | Type| Description|
| -------- | -------- | | -------- | -------- |
| boolean | Returns&nbsp;**true**&nbsp;if&nbsp;the&nbsp;operation&nbsp;is&nbsp;successful;&nbsp;returns&nbsp;**false**&nbsp;otherwise. | | boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
- Example - Example
...@@ -973,13 +1007,14 @@ Writes a **ByteArray** to this **MessageParcel** object. ...@@ -973,13 +1007,14 @@ Writes a **ByteArray** to this **MessageParcel** object.
readByteArray(dataIn: number[]) : void readByteArray(dataIn: number[]) : void
Reads the **ByteArray** from this **MessageParcel** object. Reads the ByteArray from this **MessageParcel** object.
**System capability**: SystemCapability.Communication.IPC.Core
- Parameters - Parameters
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| dataIn | number[] | Yes | **ByteArray**&nbsp;to&nbsp;read. | | dataIn | number[] | Yes| ByteArray to read.|
- Example - Example
...@@ -997,13 +1032,14 @@ Reads the **ByteArray** from this **MessageParcel** object. ...@@ -997,13 +1032,14 @@ Reads the **ByteArray** from this **MessageParcel** object.
readByteArray(): number[] readByteArray(): number[]
Reads the **ByteArray** from this **MessageParcel** object. Reads the ByteArray from this **MessageParcel** object.
**System capability**: SystemCapability.Communication.IPC.Core
- Return values - Return value
| Type | Description | | Type| Description|
| -------- | -------- | | -------- | -------- |
| number[] | **ByteArray**&nbsp;read. | | number[] | ByteArray read.|
- Example - Example
...@@ -1021,18 +1057,19 @@ Reads the **ByteArray** from this **MessageParcel** object. ...@@ -1021,18 +1057,19 @@ Reads the **ByteArray** from this **MessageParcel** object.
writeShortArray(shortArray: number[]): boolean writeShortArray(shortArray: number[]): boolean
Writes a **ShortArray** to this **MessageParcel** object. Writes a ShortArray to this **MessageParcel** object.
**System capability**: SystemCapability.Communication.IPC.Core
- Parameters - Parameters
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| shortArray | number[] | Yes | **ShortArray**&nbsp;to&nbsp;write. | | shortArray | number[] | Yes| ShortArray to write.|
- Return values - Return value
| Type | Description | | Type| Description|
| -------- | -------- | | -------- | -------- |
| boolean | Returns&nbsp;**true**&nbsp;if&nbsp;the&nbsp;operation&nbsp;is&nbsp;successful;&nbsp;returns&nbsp;**false**&nbsp;otherwise. | | boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
- Example - Example
...@@ -1047,13 +1084,14 @@ Writes a **ShortArray** to this **MessageParcel** object. ...@@ -1047,13 +1084,14 @@ Writes a **ShortArray** to this **MessageParcel** object.
readShortArray(dataIn: number[]) : void readShortArray(dataIn: number[]) : void
Reads the **ShortArray** from this **MessageParcel** object. Reads a ShortArray from this **MessageParcel** object.
**System capability**: SystemCapability.Communication.IPC.Core
- Parameters - Parameters
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| dataIn | number[] | Yes | **ShortArray**&nbsp;to&nbsp;read. | | dataIn | number[] | Yes| ShortArray to read.|
- Example - Example
...@@ -1070,13 +1108,14 @@ Reads the **ShortArray** from this **MessageParcel** object. ...@@ -1070,13 +1108,14 @@ Reads the **ShortArray** from this **MessageParcel** object.
readShortArray(): number[] readShortArray(): number[]
Reads the **ShortArray** from this **MessageParcel** object. Reads the ShortArray from this **MessageParcel** object.
**System capability**: SystemCapability.Communication.IPC.Core
- Return values - Return value
| Type | Description | | Type| Description|
| -------- | -------- | | -------- | -------- |
| number[] | **ShortArray**&nbsp;read. | | number[] | ShortArray read.|
- Example - Example
...@@ -1093,18 +1132,19 @@ Reads the **ShortArray** from this **MessageParcel** object. ...@@ -1093,18 +1132,19 @@ Reads the **ShortArray** from this **MessageParcel** object.
writeIntArray(intArray: number[]): boolean writeIntArray(intArray: number[]): boolean
Writes an **IntArray** to this **MessageParcel** object. Writes an IntArray to this **MessageParcel** object.
**System capability**: SystemCapability.Communication.IPC.Core
- Parameters - Parameters
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| intArray | number[] | Yes | **IntArray**&nbsp;to&nbsp;write. | | intArray | number[] | Yes| IntArray to write.|
- Return values - Return value
| Type | Description | | Type| Description|
| -------- | -------- | | -------- | -------- |
| boolean | Returns&nbsp;**true**&nbsp;if&nbsp;the&nbsp;operation&nbsp;is&nbsp;successful;&nbsp;returns&nbsp;**false**&nbsp;otherwise. | | boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
- Example - Example
...@@ -1119,13 +1159,14 @@ Writes an **IntArray** to this **MessageParcel** object. ...@@ -1119,13 +1159,14 @@ Writes an **IntArray** to this **MessageParcel** object.
readIntArray(dataIn: number[]) : void readIntArray(dataIn: number[]) : void
Reads the **IntArray** from this **MessageParcel** object. Reads an IntArray from this **MessageParcel** object.
**System capability**: SystemCapability.Communication.IPC.Core
- Parameters - Parameters
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| dataIn | number[] | Yes | **IntArray**&nbsp;to&nbsp;read. | | dataIn | number[] | Yes| IntArray to read.|
- Example - Example
...@@ -1142,13 +1183,14 @@ Reads the **IntArray** from this **MessageParcel** object. ...@@ -1142,13 +1183,14 @@ Reads the **IntArray** from this **MessageParcel** object.
readIntArray(): number[] readIntArray(): number[]
Reads the **IntArray** from this **MessageParcel** object. Reads the IntArray from this **MessageParcel** object.
**System capability**: SystemCapability.Communication.IPC.Core
- Return values - Return value
| Type | Description | | Type| Description|
| -------- | -------- | | -------- | -------- |
| number[] | **IntArray**&nbsp;read. | | number[] | IntArray read.|
- Example - Example
...@@ -1165,18 +1207,19 @@ Reads the **IntArray** from this **MessageParcel** object. ...@@ -1165,18 +1207,19 @@ Reads the **IntArray** from this **MessageParcel** object.
writeLongArray(longArray: number[]): boolean writeLongArray(longArray: number[]): boolean
Writes a **LongArray** to this **MessageParcel** object. Writes a LongArray to this **MessageParcel** object.
**System capability**: SystemCapability.Communication.IPC.Core
- Parameters - Parameters
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| longArray | number[] | Yes | **LongArray**&nbsp;to&nbsp;write. | | longArray | number[] | Yes| LongArray to write.|
- Return values - Return value
| Type | Description | | Type| Description|
| -------- | -------- | | -------- | -------- |
| boolean | Returns&nbsp;**true**&nbsp;if&nbsp;the&nbsp;operation&nbsp;is&nbsp;successful;&nbsp;returns&nbsp;**false**&nbsp;otherwise. | | boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
- Example - Example
...@@ -1191,13 +1234,14 @@ Writes a **LongArray** to this **MessageParcel** object. ...@@ -1191,13 +1234,14 @@ Writes a **LongArray** to this **MessageParcel** object.
readLongArray(dataIn: number[]) : void readLongArray(dataIn: number[]) : void
Reads the **LongArray** from this **MessageParcel** object. Reads a LongArray from this **MessageParcel** object.
**System capability**: SystemCapability.Communication.IPC.Core
- Parameters - Parameters
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| dataIn | number[] | Yes | **LongArray**&nbsp;to&nbsp;read. | | dataIn | number[] | Yes| LongArray to read.|
- Example - Example
...@@ -1214,13 +1258,14 @@ Reads the **LongArray** from this **MessageParcel** object. ...@@ -1214,13 +1258,14 @@ Reads the **LongArray** from this **MessageParcel** object.
readLongArray(): number[] readLongArray(): number[]
Reads the **LongArray** from this **MessageParcel** object. Reads the LongArray from this **MessageParcel** object.
**System capability**: SystemCapability.Communication.IPC.Core
- Return values - Return value
| Type | Description | | Type| Description|
| -------- | -------- | | -------- | -------- |
| number[] | **LongArray**&nbsp;read. | | number[] | LongArray read.|
- Example - Example
...@@ -1237,18 +1282,19 @@ Reads the **LongArray** from this **MessageParcel** object. ...@@ -1237,18 +1282,19 @@ Reads the **LongArray** from this **MessageParcel** object.
writeFloatArray(floatArray: number[]): boolean writeFloatArray(floatArray: number[]): boolean
Writes a **FloatArray** to this **MessageParcel** object. Writes a FloatArray to this **MessageParcel** object.
**System capability**: SystemCapability.Communication.IPC.Core
- Parameters - Parameters
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| floatArray | number[] | Yes | **FloatArray**&nbsp;to&nbsp;write. | | floatArray | number[] | Yes| FloatArray to write.|
- Return values - Return value
| Type | Description | | Type| Description|
| -------- | -------- | | -------- | -------- |
| boolean | Returns&nbsp;**true**&nbsp;if&nbsp;the&nbsp;operation&nbsp;is&nbsp;successful;&nbsp;returns&nbsp;**false**&nbsp;otherwise. | | boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
- Example - Example
...@@ -1263,12 +1309,14 @@ Writes a **FloatArray** to this **MessageParcel** object. ...@@ -1263,12 +1309,14 @@ Writes a **FloatArray** to this **MessageParcel** object.
readFloatArray(dataIn: number[]) : void readFloatArray(dataIn: number[]) : void
Reads the **FloatArray** from this **MessageParcel** object. Reads a FloatArray from this **MessageParcel** object.
**System capability**: SystemCapability.Communication.IPC.Core
- Parameters - Parameters
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| dataIn | number[] | Yes | **FloatArray**&nbsp;to&nbsp;read. | | dataIn | number[] | Yes| FloatArray to read.|
- Example - Example
...@@ -1286,13 +1334,14 @@ Reads the **FloatArray** from this **MessageParcel** object. ...@@ -1286,13 +1334,14 @@ Reads the **FloatArray** from this **MessageParcel** object.
readFloatArray(): number[] readFloatArray(): number[]
Reads the **FloatArray** from this **MessageParcel** object. Reads the FloatArray from this **MessageParcel** object.
**System capability**: SystemCapability.Communication.IPC.Core
- Return values - Return value
| Type | Description | | Type| Description|
| -------- | -------- | | -------- | -------- |
| number[] | **FloatArray**&nbsp;read. | | number[] | FloatArray read.|
- Example - Example
...@@ -1309,18 +1358,19 @@ Reads the **FloatArray** from this **MessageParcel** object. ...@@ -1309,18 +1358,19 @@ Reads the **FloatArray** from this **MessageParcel** object.
writeDoubleArray(doubleArray: number[]): boolean writeDoubleArray(doubleArray: number[]): boolean
Writes a **DoubleArray** to this **MessageParcel** object. Writes a DoubleArray to this **MessageParcel** object.
**System capability**: SystemCapability.Communication.IPC.Core
- Parameters - Parameters
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| doubleArray | number[] | Yes | **DoubleArray**&nbsp;to&nbsp;write. | | doubleArray | number[] | Yes| DoubleArray to write.|
- Return values - Return value
| Type | Description | | Type| Description|
| -------- | -------- | | -------- | -------- |
| boolean | Returns&nbsp;**true**&nbsp;if&nbsp;the&nbsp;operation&nbsp;is&nbsp;successful;&nbsp;returns&nbsp;**false**&nbsp;otherwise. | | boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
- Example - Example
...@@ -1335,13 +1385,14 @@ Writes a **DoubleArray** to this **MessageParcel** object. ...@@ -1335,13 +1385,14 @@ Writes a **DoubleArray** to this **MessageParcel** object.
readDoubleArray(dataIn: number[]) : void readDoubleArray(dataIn: number[]) : void
Reads the **DoubleArray** from this **MessageParcel** object. Reads a DoubleArray from this **MessageParcel** object.
**System capability**: SystemCapability.Communication.IPC.Core
- Parameters - Parameters
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| dataIn | number[] | Yes | **DoubleArray**&nbsp;to&nbsp;read. | | dataIn | number[] | Yes| DoubleArray to read.|
- Example - Example
...@@ -1358,13 +1409,14 @@ Reads the **DoubleArray** from this **MessageParcel** object. ...@@ -1358,13 +1409,14 @@ Reads the **DoubleArray** from this **MessageParcel** object.
readDoubleArray(): number[] readDoubleArray(): number[]
Reads the **DoubleArray** from this **MessageParcel** object. Reads the DoubleArray from this **MessageParcel** object.
**System capability**: SystemCapability.Communication.IPC.Core
- Return values - Return value
| Type | Description | | Type| Description|
| -------- | -------- | | -------- | -------- |
| number[] | **DoubleArray**&nbsp;read. | | number[] | DoubleArray read.|
- Example - Example
...@@ -1381,18 +1433,19 @@ Reads the **DoubleArray** from this **MessageParcel** object. ...@@ -1381,18 +1433,19 @@ Reads the **DoubleArray** from this **MessageParcel** object.
writeBooleanArray(booleanArray: boolean[]): boolean writeBooleanArray(booleanArray: boolean[]): boolean
Writes a **BooleanArray** to this **MessageParcel** object. Writes a BooleanArray to this **MessageParcel** object.
**System capability**: SystemCapability.Communication.IPC.Core
- Parameters - Parameters
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| booleanArray | boolean[] | Yes | **BooleanArray**&nbsp;to&nbsp;write. | | booleanArray | boolean[] | Yes| BooleanArray to write.|
- Return values - Return value
| Type | Description | | Type| Description|
| -------- | -------- | | -------- | -------- |
| boolean | Returns&nbsp;**true**&nbsp;if&nbsp;the&nbsp;operation&nbsp;is&nbsp;successful;&nbsp;returns&nbsp;**false**&nbsp;otherwise. | | boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
- Example - Example
...@@ -1407,13 +1460,14 @@ Writes a **BooleanArray** to this **MessageParcel** object. ...@@ -1407,13 +1460,14 @@ Writes a **BooleanArray** to this **MessageParcel** object.
readBooleanArray(dataIn: boolean[]) : void readBooleanArray(dataIn: boolean[]) : void
Reads the **BooleanArray** from this **MessageParcel** object. Reads a BooleanArray from this **MessageParcel** object.
**System capability**: SystemCapability.Communication.IPC.Core
- Parameters - Parameters
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| dataIn | boolean[] | Yes | **BooleanArray**&nbsp;to&nbsp;read. | | dataIn | boolean[] | Yes| BooleanArray to read.|
- Example - Example
...@@ -1430,13 +1484,14 @@ Reads the **BooleanArray** from this **MessageParcel** object. ...@@ -1430,13 +1484,14 @@ Reads the **BooleanArray** from this **MessageParcel** object.
readBooleanArray(): boolean[] readBooleanArray(): boolean[]
Reads the **BooleanArray** from this **MessageParcel** object. Reads the BooleanArray from this **MessageParcel** object.
**System capability**: SystemCapability.Communication.IPC.Core
- Return values - Return value
| Type | Description | | Type| Description|
| -------- | -------- | | -------- | -------- |
| boolean[] | **BooleanArray**&nbsp;read. | | boolean[] | BooleanArray read.|
``` ```
...@@ -1452,18 +1507,19 @@ Reads the **BooleanArray** from this **MessageParcel** object. ...@@ -1452,18 +1507,19 @@ Reads the **BooleanArray** from this **MessageParcel** object.
writeCharArray(charArray: number[]): boolean writeCharArray(charArray: number[]): boolean
Writes a **CharArray** to this **MessageParcel** object. Writes a CharArray to this **MessageParcel** object.
**System capability**: SystemCapability.Communication.IPC.Core
- Parameters - Parameters
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| charArray | number[] | Yes | **CharArray**&nbsp;to&nbsp;write. | | charArray | number[] | Yes| CharArray to write.|
- Return values - Return value
| Type | Description | | Type| Description|
| -------- | -------- | | -------- | -------- |
| boolean | Returns&nbsp;**true**&nbsp;if&nbsp;the&nbsp;operation&nbsp;is&nbsp;successful;&nbsp;returns&nbsp;**false**&nbsp;otherwise. | | boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
- Example - Example
...@@ -1476,15 +1532,16 @@ Writes a **CharArray** to this **MessageParcel** object. ...@@ -1476,15 +1532,16 @@ Writes a **CharArray** to this **MessageParcel** object.
### readCharArray ### readCharArray
readCharArray(dataIn: boolean[]) : void readCharArray(dataIn: number[]) : void
Reads the **CharArray** from this **MessageParcel** object. Reads a CharArray from this **MessageParcel** object.
**System capability**: SystemCapability.Communication.IPC.Core
- Parameters - Parameters
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| dataIn | boolean[] | Yes | **CharArray**&nbsp;to&nbsp;read. | | dataIn | number[] | Yes| CharArray to read.|
- Example - Example
...@@ -1499,15 +1556,16 @@ Reads the **CharArray** from this **MessageParcel** object. ...@@ -1499,15 +1556,16 @@ Reads the **CharArray** from this **MessageParcel** object.
### readCharArray ### readCharArray
readCharArray(): boolean[] readCharArray(): number[]
Reads the **CharArray** from this **MessageParcel** object. Reads the CharArray from this **MessageParcel** object.
**System capability**: SystemCapability.Communication.IPC.Core
- Return values - Return value
| Type | Description | | Type| Description|
| -------- | -------- | | -------- | -------- |
| boolean[] | **CharArray**&nbsp;read. | | number[] | CharArray read.|
- Example - Example
...@@ -1524,18 +1582,19 @@ Reads the **CharArray** from this **MessageParcel** object. ...@@ -1524,18 +1582,19 @@ Reads the **CharArray** from this **MessageParcel** object.
writeStringArray(stringArray: string[]): boolean writeStringArray(stringArray: string[]): boolean
Writes a **StringArray** to this **MessageParcel** object. Writes a StringArray to this **MessageParcel** object.
**System capability**: SystemCapability.Communication.IPC.Core
- Parameters - Parameters
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| stringArray | string[] | Yes | **StringArray**&nbsp;to&nbsp;write. | | stringArray | string[] | Yes| StringArray to write.|
- Return values - Return value
| Type | Description | | Type| Description|
| -------- | -------- | | -------- | -------- |
| boolean | Returns&nbsp;**true**&nbsp;if&nbsp;the&nbsp;operation&nbsp;is&nbsp;successful;&nbsp;returns&nbsp;**false**&nbsp;otherwise. | | boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
- Example - Example
...@@ -1550,13 +1609,14 @@ Writes a **StringArray** to this **MessageParcel** object. ...@@ -1550,13 +1609,14 @@ Writes a **StringArray** to this **MessageParcel** object.
readStringArray(dataIn: string[]) : void readStringArray(dataIn: string[]) : void
Reads the **StringArray** from this **MessageParcel** object. Reads a StringArray from this **MessageParcel** object.
**System capability**: SystemCapability.Communication.IPC.Core
- Parameters - Parameters
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| dataIn | string[] | Yes | **StringArray**&nbsp;to&nbsp;read. | | dataIn | string[] | Yes| StringArray to read.|
- Example - Example
...@@ -1573,13 +1633,14 @@ Reads the **StringArray** from this **MessageParcel** object. ...@@ -1573,13 +1633,14 @@ Reads the **StringArray** from this **MessageParcel** object.
readStringArray(): string[] readStringArray(): string[]
Reads the **StringArray** from this **MessageParcel** object. Reads the StringArray from this **MessageParcel** object.
**System capability**: SystemCapability.Communication.IPC.Core
- Return values - Return value
| Type | Description | | Type| Description|
| -------- | -------- | | -------- | -------- |
| string[] | **StringArray**&nbsp;read. | | string[] | StringArray read.|
- Example - Example
...@@ -1598,6 +1659,7 @@ writeNoException(): void ...@@ -1598,6 +1659,7 @@ writeNoException(): void
Writes information to this **MessageParcel** object indicating that no exception occurred. Writes information to this **MessageParcel** object indicating that no exception occurred.
**System capability**: SystemCapability.Communication.IPC.Core
- Example - Example
...@@ -1626,6 +1688,7 @@ readException(): void ...@@ -1626,6 +1688,7 @@ readException(): void
Reads the exception information from this **MessageParcel** object. Reads the exception information from this **MessageParcel** object.
**System capability**: SystemCapability.Communication.IPC.Core
- Example - Example
...@@ -1645,8 +1708,8 @@ Reads the exception information from this **MessageParcel** object. ...@@ -1645,8 +1708,8 @@ Reads the exception information from this **MessageParcel** object.
} }
}; };
let want = { let want = {
"bundleName": "com.huawei.server", "bundleName": "com.ohos.server",
"abilityName": "com.huawei.server.MainAbility", "abilityName": "com.ohos.server.MainAbility",
}; };
FA.connectAbility(want, connect); FA.connectAbility(want, connect);
let option = new rpc.MessageOption(); let option = new rpc.MessageOption();
...@@ -1678,18 +1741,19 @@ Reads the exception information from this **MessageParcel** object. ...@@ -1678,18 +1741,19 @@ Reads the exception information from this **MessageParcel** object.
writeSequenceableArray(sequenceableArray: Sequenceable[]): boolean writeSequenceableArray(sequenceableArray: Sequenceable[]): boolean
Writes a **SequenceableArray** to this **MessageParcel** object. Writes a SequenceableArray to this **MessageParcel** object.
**System capability**: SystemCapability.Communication.IPC.Core
- Parameters - Parameters
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| sequenceableArray | Sequenceable[] | Yes | **SequenceableArray**&nbsp;to&nbsp;write. | | sequenceableArray | Sequenceable[] | Yes| SequenceableArray to write.|
- Return values - Return value
| Type | Description | | Type| Description|
| -------- | -------- | | -------- | -------- |
| boolean | Returns&nbsp;**true**&nbsp;if&nbsp;the&nbsp;operation&nbsp;is&nbsp;successful;&nbsp;returns&nbsp;**false**&nbsp;otherwise. | | boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
- Example - Example
...@@ -1724,13 +1788,14 @@ Writes a **SequenceableArray** to this **MessageParcel** object. ...@@ -1724,13 +1788,14 @@ Writes a **SequenceableArray** to this **MessageParcel** object.
readSequenceableArray(sequenceableArray: Sequenceable[]): void readSequenceableArray(sequenceableArray: Sequenceable[]): void
Reads the specified **SequenceableArray** from this **MessageParcel** object. Reads a SequenceableArray from this **MessageParcel** object.
**System capability**: SystemCapability.Communication.IPC.Core
- Parameters - Parameters
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| sequenceableArray | Sequenceable[] | Yes | **SequenceableArray**&nbsp;to&nbsp;read. | | sequenceableArray | Sequenceable[] | Yes| SequenceableArray to read.|
- Example - Example
...@@ -1769,16 +1834,17 @@ writeRemoteObjectArray(objectArray: IRemoteObject[]): boolean ...@@ -1769,16 +1834,17 @@ writeRemoteObjectArray(objectArray: IRemoteObject[]): boolean
Writes an array of **IRemoteObject** objects to this **MessageParcel** object. Writes an array of **IRemoteObject** objects to this **MessageParcel** object.
**System capability**: SystemCapability.Communication.IPC.Core
- Parameters - Parameters
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| objectArray | IRemoteObject[] | Yes | Array&nbsp;of&nbsp;**IRemoteObject**&nbsp;objects&nbsp;to&nbsp;write. | | objectArray | IRemoteObject[] | Yes| Array of **IRemoteObject** objects to write.|
- Return values - Return value
| Type | Description | | Type| Description|
| -------- | -------- | | -------- | -------- |
| boolean | Returns&nbsp;**true**&nbsp;if&nbsp;the&nbsp;**IRemoteObject**&nbsp;array&nbsp;is&nbsp;successfully&nbsp;written&nbsp;to&nbsp;the&nbsp;**MessageParcel**;&nbsp;returns&nbsp;**false**&nbsp;if&nbsp;the&nbsp;**IRemoteObject**&nbsp;array&nbsp;is&nbsp;null&nbsp;or&nbsp;fails&nbsp;to&nbsp;be&nbsp;written&nbsp;to&nbsp;the&nbsp;**MessageParcel**. | | boolean | Returns **true** if the operation is successful; returns **false** if the operation fails or if the **IRemoteObject** array is null.|
- Example - Example
...@@ -1800,13 +1866,14 @@ Writes an array of **IRemoteObject** objects to this **MessageParcel** object. ...@@ -1800,13 +1866,14 @@ Writes an array of **IRemoteObject** objects to this **MessageParcel** object.
readRemoteObjectArray(objects: IRemoteObject[]): void readRemoteObjectArray(objects: IRemoteObject[]): void
Reads the specified **IRemoteObject** array from this **MessageParcel** object. Reads an **IRemoteObject** array from this **MessageParcel** object.
**System capability**: SystemCapability.Communication.IPC.Core
- Parameters - Parameters
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| objects | IRemoteObject[] | Yes | **IRemoteObject**&nbsp;array&nbsp;to&nbsp;read. | | objects | IRemoteObject[] | Yes| **IRemoteObject** array to read.|
- Example - Example
...@@ -1829,13 +1896,14 @@ Reads the specified **IRemoteObject** array from this **MessageParcel** object. ...@@ -1829,13 +1896,14 @@ Reads the specified **IRemoteObject** array from this **MessageParcel** object.
readRemoteObjectArray(): IRemoteObject[] readRemoteObjectArray(): IRemoteObject[]
Reads **IRemoteObject** objects from this **MessageParcel** object. Reads the **IRemoteObject** array from this **MessageParcel** object.
**System capability**: SystemCapability.Communication.IPC.Core
- Return values - Return value
| Type | Description | | Type| Description|
| -------- | -------- | | -------- | -------- |
| IRemoteObject[] | An&nbsp;array&nbsp;of&nbsp;**IRemoteObject**&nbsp;objects&nbsp;obtained. | | IRemoteObject[] | **IRemoteObject** object array obtained.|
- Example - Example
...@@ -1859,13 +1927,14 @@ Reads **IRemoteObject** objects from this **MessageParcel** object. ...@@ -1859,13 +1927,14 @@ Reads **IRemoteObject** objects from this **MessageParcel** object.
static closeFileDescriptor(fd: number): void static closeFileDescriptor(fd: number): void
Closes the specified file descriptor. Closes a file descriptor.
**System capability**: SystemCapability.Communication.IPC.Core
- Parameters - Parameters
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| fd | number | Yes | File&nbsp;descriptor&nbsp;to&nbsp;close. | | fd | number | Yes| File descriptor to close.|
- Example - Example
...@@ -1881,18 +1950,19 @@ Closes the specified file descriptor. ...@@ -1881,18 +1950,19 @@ Closes the specified file descriptor.
static dupFileDescriptor(fd: number) :number static dupFileDescriptor(fd: number) :number
Duplicates the specified file descriptor. Duplicates a file descriptor.
**System capability**: SystemCapability.Communication.IPC.Core
- Parameters - Parameters
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| fd | number | Yes | File&nbsp;descriptor&nbsp;to&nbsp;duplicate. | | fd | number | Yes| File descriptor to duplicate.|
- Return values - Return value
| Type | Description | | Type| Description|
| -------- | -------- | | -------- | -------- |
| number | New&nbsp;file&nbsp;descriptor. | | number | New file descriptor.|
- Example - Example
...@@ -1910,11 +1980,12 @@ containFileDescriptors(): boolean ...@@ -1910,11 +1980,12 @@ containFileDescriptors(): boolean
Checks whether this **MessageParcel** object contains a file descriptor. Checks whether this **MessageParcel** object contains a file descriptor.
**System capability**: SystemCapability.Communication.IPC.Core
- Return values - Return value
| Type | Description | | Type| Description|
| -------- | -------- | | -------- | -------- |
| boolean | Returns&nbsp;**true**&nbsp;if&nbsp;the&nbsp;**MessageParcel**&nbsp;object&nbsp;contains&nbsp;a&nbsp;file&nbsp;descriptor;&nbsp;returns&nbsp;**false**&nbsp;otherwise. | | boolean | Returns **true** if the **MessageParcel** object contains a file descriptor; returns **false** otherwise.|
- Example - Example
...@@ -1937,16 +2008,17 @@ writeFileDescriptor(fd: number): boolean ...@@ -1937,16 +2008,17 @@ writeFileDescriptor(fd: number): boolean
Writes a file descriptor to this **MessageParcel** object. Writes a file descriptor to this **MessageParcel** object.
**System capability**: SystemCapability.Communication.IPC.Core
- Parameters - Parameters
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| fd | number | Yes | File&nbsp;descriptor&nbsp;to&nbsp;write. | | fd | number | Yes| File descriptor to write.|
- Return values - Return value
| Type | Description | | Type| Description|
| -------- | -------- | | -------- | -------- |
| boolean | Returns&nbsp;**true**&nbsp;if&nbsp;the&nbsp;operation&nbsp;is&nbsp;successful;&nbsp;returns&nbsp;**false**&nbsp;otherwise. | | boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
- Example - Example
...@@ -1964,13 +2036,14 @@ Writes a file descriptor to this **MessageParcel** object. ...@@ -1964,13 +2036,14 @@ Writes a file descriptor to this **MessageParcel** object.
readFileDescriptor(): number readFileDescriptor(): number
Reads a file descriptor from this **MessageParcel** object. Reads the file descriptor from this **MessageParcel** object.
**System capability**: SystemCapability.Communication.IPC.Core
- Return values - Return value
| Type | Description | | Type| Description|
| -------- | -------- | | -------- | -------- |
| number | File&nbsp;descriptor&nbsp;obtained. | | number | File descriptor read.|
- Example - Example
...@@ -1991,16 +2064,17 @@ writeAshmem(ashmem: Ashmem): boolean ...@@ -1991,16 +2064,17 @@ writeAshmem(ashmem: Ashmem): boolean
Writes an anonymous shared object to this **MessageParcel** object. Writes an anonymous shared object to this **MessageParcel** object.
**System capability**: SystemCapability.Communication.IPC.Core
- Parameters - Parameters
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| ashmem | Ashmem | Yes | Anonymous&nbsp;shared&nbsp;object&nbsp;to&nbsp;write. | | ashmem | Ashmem | Yes| Anonymous shared object to write.|
- Return values - Return value
| Type | Description | | Type| Description|
| -------- | -------- | | -------- | -------- |
| boolean | Returns&nbsp;**true**&nbsp;if&nbsp;the&nbsp;operation&nbsp;is&nbsp;successful;&nbsp;returns&nbsp;**false**&nbsp;otherwise. | | boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
- Example - Example
...@@ -2018,11 +2092,12 @@ readAshmem(): Ashmem ...@@ -2018,11 +2092,12 @@ readAshmem(): Ashmem
Reads the anonymous shared object from this **MessageParcel** object. Reads the anonymous shared object from this **MessageParcel** object.
**System capability**: SystemCapability.Communication.IPC.Core
- Return values - Return value
| Type | Description | | Type| Description|
| -------- | -------- | | -------- | -------- |
| Ashmem | Anonymous&nbsp;share&nbsp;object&nbsp;obtained. | | Ashmem | Anonymous share object obtained.|
- Example - Example
...@@ -2042,11 +2117,12 @@ getRawDataCapacity(): number ...@@ -2042,11 +2117,12 @@ getRawDataCapacity(): number
Obtains the maximum amount of raw data that can be held by this **MessageParcel** object. Obtains the maximum amount of raw data that can be held by this **MessageParcel** object.
**System capability**: SystemCapability.Communication.IPC.Core
- Return values - Return value
| Type | Description | | Type| Description|
| -------- | -------- | | -------- | -------- |
| number | 128&nbsp;MB,&nbsp;which&nbsp;is&nbsp;the&nbsp;maximum&nbsp;amount&nbsp;of&nbsp;raw&nbsp;data&nbsp;that&nbsp;can&nbsp;be&nbsp;held&nbsp;by&nbsp;this&nbsp;**MessageParcel**&nbsp;object. | | number | 128 MB, which is the maximum amount of raw data that can be held by this **MessageParcel** object.|
- Example - Example
...@@ -2063,17 +2139,18 @@ writeRawData(rawData: number[], size: number): boolean ...@@ -2063,17 +2139,18 @@ writeRawData(rawData: number[], size: number): boolean
Writes raw data to this **MessageParcel** object. Writes raw data to this **MessageParcel** object.
**System capability**: SystemCapability.Communication.IPC.Core
- Parameters - Parameters
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| rawData | number[] | Yes | Raw&nbsp;data&nbsp;to&nbsp;write. | | rawData | number[] | Yes| Raw data to write.|
| size | number | Yes | Size&nbsp;of&nbsp;the&nbsp;raw&nbsp;data,&nbsp;in&nbsp;bytes. | | size | number | Yes| Size of the raw data, in bytes.|
- Return values - Return value
| Type | Description | | Type| Description|
| -------- | -------- | | -------- | -------- |
| boolean | Returns&nbsp;**true**&nbsp;if&nbsp;the&nbsp;operation&nbsp;is&nbsp;successful;&nbsp;returns&nbsp;**false**&nbsp;otherwise. | | boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
- Example - Example
...@@ -2091,16 +2168,17 @@ readRawData(size: number): number[] ...@@ -2091,16 +2168,17 @@ readRawData(size: number): number[]
Reads raw data from this **MessageParcel** object. Reads raw data from this **MessageParcel** object.
**System capability**: SystemCapability.Communication.IPC.Core
- Parameters - Parameters
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| size | number | Yes | Size&nbsp;of&nbsp;the&nbsp;raw&nbsp;data&nbsp;to&nbsp;read. | | size | number | Yes| Size of the raw data to read.|
- Return values - Return value
| Type | Description | | Type| Description|
| -------- | -------- | | -------- | -------- |
| number[] | Raw&nbsp;data&nbsp;obtained,&nbsp;in&nbsp;bytes. | | number[] | Raw data obtained, in bytes.|
- Example - Example
...@@ -2113,87 +2191,28 @@ Reads raw data from this **MessageParcel** object. ...@@ -2113,87 +2191,28 @@ Reads raw data from this **MessageParcel** object.
console.log("RpcTest: parcel read raw data result is : " + result); console.log("RpcTest: parcel read raw data result is : " + result);
``` ```
### getDataVersion<sup>8+</sup>
getDataVersion(): number
Obtains the data format version from this **MessageParcel** object.
- Return values
| Type | Description |
| -------- | -------- |
| number | Data&nbsp;format&nbsp;version&nbsp;obtained. |
- Example
```
let parcel = new rpc.MessageParcel();
let version = parcel.getDataVersion();
console.log("RpcTest: parcel get data version is : " + version);
```
### updateDataVersion<sup>8+</sup>
updateDataVersion(proxy: IRemoteObject): void
Updates the data format version of the **IRemoteObject** to this **MessageParcel** object.
- Parameters
| Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
| proxy | IRemoteObject | Yes | Remote&nbsp;object&nbsp;that&nbsp;uses&nbsp;this&nbsp;**MessageParcel**&nbsp;object&nbsp;to&nbsp;send&nbsp;the&nbsp;request. |
- Example
```
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.huawei.server",
"abilityName": "com.huawei.server.MainAbility",
};
FA.connectAbility(want, connect);
let parcel = new rpc.MessageParcel();
parcel.updateDataVersion(proxy);
```
## Sequenceable ## Sequenceable
Writes objects of classes to a **MessageParcel** and reads them from the **MessageParcel** during inter-process communication (IPC). Writes objects of classes to a **MessageParcel** and reads them from the **MessageParcel** during IPC.
### marshalling ### marshalling
marshalling(dataOut: MessageParcel): boolean marshalling(dataOut: MessageParcel): boolean
Marshals this sequenceable object into a **MessageParcel** object. Marshals the sequenceable object into a **MessageParcel** object.
**System capability**: SystemCapability.Communication.IPC.Core
- Parameters - Parameters
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| dataOut | [MessageParcel](#messageparcel) | Yes | **MessageParcel**&nbsp;object&nbsp;to&nbsp;which&nbsp;the&nbsp;sequenceable&nbsp;object&nbsp;is&nbsp;to&nbsp;be&nbsp;marshaled. | | dataOut | [MessageParcel](#messageparcel) | Yes| **MessageParcel** object to which the sequenceable object is to be marshaled.|
- Return values - Return value
| Type | Description | | Type| Description|
| -------- | -------- | | -------- | -------- |
| boolean | Returns&nbsp;**true**&nbsp;if&nbsp;the&nbsp;operation&nbsp;is&nbsp;successful;&nbsp;returns&nbsp;**false**&nbsp;otherwise. | | boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
- Example - Example
...@@ -2230,15 +2249,17 @@ unmarshalling(dataIn: MessageParcel) : boolean ...@@ -2230,15 +2249,17 @@ unmarshalling(dataIn: MessageParcel) : boolean
Unmarshals this sequenceable object from a **MessageParcel** object. Unmarshals this sequenceable object from a **MessageParcel** object.
**System capability**: SystemCapability.Communication.IPC.Core
- Parameters - Parameters
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| dataIn | [MessageParcel](#messageparcel) | Yes | **MessageParcel**&nbsp;object&nbsp;in&nbsp;which&nbsp;the&nbsp;sequenceable&nbsp;object&nbsp;has&nbsp;been&nbsp;marshaled. | | dataIn | [MessageParcel](#messageparcel) | Yes| **MessageParcel** object in which the sequenceable object is to be unmarshaled.|
- Return values - Return value
| Type | Description | | Type| Description|
| -------- | -------- | | -------- | -------- |
| boolean | Returns&nbsp;**true**&nbsp;if&nbsp;the&nbsp;operation&nbsp;is&nbsp;successful;&nbsp;returns&nbsp;**false**&nbsp;otherwise. | | boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
- Example - Example
...@@ -2280,10 +2301,12 @@ asObject(): IRemoteObject ...@@ -2280,10 +2301,12 @@ asObject(): IRemoteObject
Obtains a proxy or remote object. This method must be implemented by its derived classes. Obtains a proxy or remote object. This method must be implemented by its derived classes.
- Return values **System capability**: SystemCapability.Communication.IPC.Core
| Type | Description |
- Return value
| Type| Description|
| -------- | -------- | | -------- | -------- |
| [IRemoteObject](#iremoteobject) | Returns&nbsp;the&nbsp;[RemoteObject](#ashmem8)&nbsp;if&nbsp;the&nbsp;caller&nbsp;is&nbsp;a&nbsp;[RemoteObject](#ashmem8);&nbsp;returns&nbsp;the&nbsp;[IRemoteObject](#iremoteobject),&nbsp;that&nbsp;is,&nbsp;the&nbsp;holder&nbsp;of&nbsp;this&nbsp;**RemoteProxy**&nbsp;object,&nbsp;if&nbsp;the&nbsp;caller&nbsp;is&nbsp;a&nbsp;[RemoteProxy](#remoteproxy)&nbsp;object. | | [IRemoteObject](#iremoteobject) | Returns the [RemoteObject](#ashmem8) if it is the caller; returns the [IRemoteObject](#iremoteobject), the holder of this **RemoteProxy** object, if the caller is a [RemoteProxy](#remoteproxy) object.|
- Example - Example
...@@ -2311,7 +2334,7 @@ Obtains a proxy or remote object. This method must be implemented by its derived ...@@ -2311,7 +2334,7 @@ Obtains a proxy or remote object. This method must be implemented by its derived
## DeathRecipient ## DeathRecipient
Subscribes to death notifications of a remote object. When the remote object is dead, the local end will receive a notification and [onRemoteDied](#onremotedied) will be called. A remote object is dead when the process holding the object is terminated or the device of the remote object is shut down or restarted. If the local and remote objects belong to different devices, the remote object is dead when the device holding the remote object is detached from the network. Subscribes to death notifications of a remote object. When the remote object is dead, the local end will receive a notification and **[onRemoteDied](#onremotedied)** will be called. A remote object is dead when the process holding the object is terminated or the device of the remote object is shut down or restarted. If the local and remote objects belong to different devices, the remote object is dead when the device holding the remote object is detached from the network.
### onRemoteDied ### onRemoteDied
...@@ -2320,6 +2343,8 @@ onRemoteDied(): void ...@@ -2320,6 +2343,8 @@ onRemoteDied(): void
Called to perform subsequent operations when a death notification of the remote object is received. Called to perform subsequent operations when a death notification of the remote object is received.
**System capability**: SystemCapability.Communication.IPC.Core
- Example - Example
``` ```
...@@ -2335,17 +2360,19 @@ Called to perform subsequent operations when a death notification of the remote ...@@ -2335,17 +2360,19 @@ Called to perform subsequent operations when a death notification of the remote
Defines the response to the request. Defines the response to the request.
| Parameters | Value | Description | **System capability**: SystemCapability.Communication.IPC.Core
| Parameter| Value| Description|
| -------- | -------- | -------- | | -------- | -------- | -------- |
| errCode | number | Error&nbsp;code. | | errCode | number | Error Code|
| code | number | Message&nbsp;code. | | code | number | Message code.|
| data | MessageParcel | **MessageParcel**&nbsp;object&nbsp;sent&nbsp;to&nbsp;the&nbsp;peer&nbsp;process. | | data | MessageParcel | **MessageParcel** object sent to the remote process.|
| reply | MessageParcel | **MessageParcel**&nbsp;object&nbsp;returned&nbsp;by&nbsp;the&nbsp;peer&nbsp;process. | | reply | MessageParcel | **MessageParcel** object returned by the remote process.|
## IRemoteObject ## IRemoteObject
Provides methods to query or obtain interface descriptors, add or delete death notifications, dump object status to specific files, and send messages. Provides methods to query of obtain interface descriptors, add or delete death notifications, dump object status to specific files, and send messages.
### queryLocalInterface ### queryLocalInterface
...@@ -2354,53 +2381,59 @@ queryLocalInterface(descriptor: string): IRemoteBroker ...@@ -2354,53 +2381,59 @@ queryLocalInterface(descriptor: string): IRemoteBroker
Obtains the interface. Obtains the interface.
**System capability**: SystemCapability.Communication.IPC.Core
- Parameters - Parameters
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| descriptor | string | Yes | Interface&nbsp;descriptor. | | descriptor | string | Yes| Interface descriptor.|
- Return values - Return value
| Type | Description | | Type| Description|
| -------- | -------- | | -------- | -------- |
| IRemoteBroker | **IRemoteBroker**&nbsp;object&nbsp;bound&nbsp;to&nbsp;the&nbsp;specified&nbsp;interface&nbsp;descriptor. | | IRemoteBroker | **IRemoteBroker** object bound to the specified interface descriptor.|
### sendRequest ### sendRequest
sendRequest(code : number, data : MessageParcel, reply : MessageParcel, options : MessageOption): Promise&lt;number&gt;<sup>7</sup> sendRequest(code : number, data : MessageParcel, reply : MessageParcel, options : MessageOption): boolean;<sup>7</sup>
sendRequest(code : number, data : MessageParcel, reply : MessageParcel, options : MessageOption): Promise&lt;SendRequestResult&gt;<sup>8+</sup> sendRequest(code : number, data : MessageParcel, reply : MessageParcel, options : MessageOption): Promise&lt;SendRequestResult&gt;<sup>8+</sup>
Sends a **MessageParcel** message to the peer process in synchronous or asynchronous mode. If **options** indicates the asynchronous mode, a promise will be fulfilled immediately and the **reply** message does not contain any content. If **options** indicates the synchronous mode, a promise will be fulfilled when the response to **sendRequest** is returned, and the reply message contains the returned information. Sends a **MessageParcel** message to the remote process in synchronous or asynchronous mode. If **options** is the asynchronous mode, a promise will be fulfilled immediately and the reply message does not contain any content. If **options** is the synchronous mode, a promise will be fulfilled when the response to **sendRequest** is returned, and the reply message contains the returned information.
**System capability**: SystemCapability.Communication.IPC.Core
- Parameters - Parameters
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| code | number | Yes | Message&nbsp;code&nbsp;called&nbsp;by&nbsp;the&nbsp;request,&nbsp;which&nbsp;is&nbsp;determined&nbsp;by&nbsp;the&nbsp;client&nbsp;and&nbsp;server.&nbsp;If&nbsp;the&nbsp;method&nbsp;is&nbsp;generated&nbsp;by&nbsp;an&nbsp;IDL&nbsp;tool,&nbsp;the&nbsp;message&nbsp;code&nbsp;is&nbsp;automatically&nbsp;generated&nbsp;by&nbsp;the&nbsp;IDL&nbsp;tool. | | code | number | Yes| Message code called by the request, which is determined by the client and server. If the method is generated by an IDL tool, the message code is automatically generated by the IDL tool.|
| data | [MessageParcel](#messageparcel) | Yes | **MessageParcel**&nbsp;object&nbsp;holding&nbsp;the&nbsp;data&nbsp;to&nbsp;send. | | data | [MessageParcel](#messageparcel) | Yes| **MessageParcel** object holding the data to send.|
| reply | [MessageParcel](#messageparcel) | Yes | **MessageParcel**&nbsp;object&nbsp;that&nbsp;receives&nbsp;the&nbsp;response. | | reply | [MessageParcel](#messageparcel) | Yes| **MessageParcel** object that receives the response.|
| options | [MessageOption](#messageoption) | Yes | Request&nbsp;sending&nbsp;mode,&nbsp;which&nbsp;can&nbsp;be&nbsp;synchronous&nbsp;(default)&nbsp;or&nbsp;asynchronous. | | options | [MessageOption](#messageoption) | Yes| Request sending mode, which can be synchronous (default) or asynchronous.|
- Return values - Return value
| Type | Description | | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;number&gt;<sup>7</sup><br/>Promise&lt;SendRequestResult&gt;<sup>8+</sup> | Promise&nbsp;used&nbsp;to&nbsp;return&nbsp;the&nbsp;result.&nbsp;The&nbsp;value&nbsp;**0**&nbsp;will&nbsp;be&nbsp;returned&nbsp;if&nbsp;the&nbsp;request&nbsp;is&nbsp;sent&nbsp;successfully.&nbsp;Otherwise,&nbsp;an&nbsp;error&nbsp;code&nbsp;will&nbsp;be&nbsp;returned.&nbsp;<sup>7</sup><br/>Promise&nbsp;used&nbsp;to&nbsp;return&nbsp;the&nbsp;**sendRequestResult**&nbsp;instance.&nbsp;<sup>8+</sup> | | Promise&lt;number&gt;<sup>7</sup><br>Promise&lt;SendRequestResult&gt;<sup>8+</sup> | Promise used to return the result. The value **0** will be returned if the request is sent successfully. Otherwise, an error code will be returned.<sup>7</sup><br>Promise used to return the **sendRequestResult** object.<sup>8+</sup> |
### sendRequest<sup>8+</sup> ### sendRequest<sup>8+</sup>
sendRequest(code: number, data: MessageParcel, reply: MessageParcel, options: MessageOption, callback: AsyncCallback&lt;SendRequestResult&gt;): void sendRequest(code: number, data: MessageParcel, reply: MessageParcel, options: MessageOption, callback: AsyncCallback&lt;SendRequestResult&gt;): void
Sends a **MessageParcel** message to the peer process in synchronous or asynchronous mode. If **options** indicates the asynchronous mode, a callback will be invoked immediately and the **reply** message does not contain any content. If **options** indicates the synchronous mode, a callback will be invoked when the response to **sendRequest** is returned, and the **reply** message contains the returned information. Sends a **MessageParcel** message to the remote process in synchronous or asynchronous mode. If **options** is the asynchronous mode, a callback will be invoked immediately and the reply message does not contain any content. If **options** is the synchronous mode, a callback will be invoked when the response to sendRequest is returned, and the reply message contains the returned information.
**System capability**: SystemCapability.Communication.IPC.Core
- Parameters - Parameters
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| code | number | Yes | Message&nbsp;code&nbsp;called&nbsp;by&nbsp;the&nbsp;request,&nbsp;which&nbsp;is&nbsp;determined&nbsp;by&nbsp;the&nbsp;client&nbsp;and&nbsp;server.&nbsp;If&nbsp;the&nbsp;method&nbsp;is&nbsp;generated&nbsp;by&nbsp;an&nbsp;IDL&nbsp;tool,&nbsp;the&nbsp;message&nbsp;code&nbsp;is&nbsp;automatically&nbsp;generated&nbsp;by&nbsp;the&nbsp;IDL&nbsp;tool. | | code | number | Yes| Message code called by the request, which is determined by the client and server. If the method is generated by an IDL tool, the message code is automatically generated by the IDL tool.|
| data | [MessageParcel](#messageparcel) | Yes | **MessageParcel**&nbsp;object&nbsp;holding&nbsp;the&nbsp;data&nbsp;to&nbsp;send. | | data | [MessageParcel](#messageparcel) | Yes| **MessageParcel** object holding the data to send.|
| reply | [MessageParcel](#messageparcel) | Yes | **MessageParcel**&nbsp;object&nbsp;that&nbsp;receives&nbsp;the&nbsp;response. | | reply | [MessageParcel](#messageparcel) | Yes| **MessageParcel** object that receives the response.|
| options | [MessageOption](#messageoption) | Yes | Request&nbsp;sending&nbsp;mode,&nbsp;which&nbsp;can&nbsp;be&nbsp;synchronous&nbsp;(default)&nbsp;or&nbsp;asynchronous. | | options | [MessageOption](#messageoption) | Yes| Request sending mode, which can be synchronous (default) or asynchronous.|
| callback | AsyncCallback&lt;SendRequestResult&gt; | Yes | Callback&nbsp;for&nbsp;receiving&nbsp;the&nbsp;sending&nbsp;result. | | callback | AsyncCallback&lt;SendRequestResult&gt; | Yes| Callback for receiving the sending result.|
### addDeathrecipient ### addDeathrecipient
...@@ -2409,16 +2442,18 @@ addDeathRecipient(recipient: DeathRecipient, flags: number): boolean ...@@ -2409,16 +2442,18 @@ addDeathRecipient(recipient: DeathRecipient, flags: number): boolean
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. 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.
**System capability**: SystemCapability.Communication.IPC.Core
- Parameters - Parameters
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| recipient | [DeathRecipient](#deathrecipient) | Yes | Callback&nbsp;to&nbsp;add. | | recipient | [DeathRecipient](#deathrecipient) | Yes| Callback to add.|
| flags | number | Yes | Flag&nbsp;of&nbsp;the&nbsp;death&nbsp;notification. | | flags | number | Yes| Flag of the death notification.|
- Return values - Return value
| Type | Description | | Type| Description|
| -------- | -------- | | -------- | -------- |
| boolean | Returns&nbsp;**true**&nbsp;if&nbsp;the&nbsp;callback&nbsp;is&nbsp;added&nbsp;successfully;&nbsp;returns&nbsp;**false**&nbsp;otherwise. | | boolean | Returns **true** if the callback is added successfully; returns **false** otherwise.|
### removeDeathRecipient ### removeDeathRecipient
...@@ -2427,70 +2462,90 @@ removeDeathRecipient(recipient: DeathRecipient, flags: number): boolean ...@@ -2427,70 +2462,90 @@ removeDeathRecipient(recipient: DeathRecipient, flags: number): boolean
Removes the callback used to receive death notifications of the remote object. Removes the callback used to receive death notifications of the remote object.
**System capability**: SystemCapability.Communication.IPC.Core
- Parameters - Parameters
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| recipient | [DeathRecipient](#deathrecipient) | Yes | Callback&nbsp;to&nbsp;remove. | | recipient | [DeathRecipient](#deathrecipient) | Yes| Callback to remove.|
| flags | number | Yes | Flag&nbsp;of&nbsp;the&nbsp;death&nbsp;notification. | | flags | number | Yes| Flag of the death notification.|
- Return values - Return value
| Type | Description | | Type| Description|
| -------- | -------- | | -------- | -------- |
| boolean | Returns&nbsp;**true**&nbsp;if&nbsp;the&nbsp;callback&nbsp;is&nbsp;removed&nbsp;successfully;&nbsp;returns&nbsp;**false**&nbsp;otherwise. | | boolean | Returns **true** if the callback is removed successfully; returns **false** otherwise.|
### getInterfaceDescriptor ### getInterfaceDescriptor
getInterfaceDescriptor(): string getInterfaceDescriptor(): string
Obtains the interface descriptor of the object. The interface descriptor is a string. Obtains the interface descriptor of this object. The interface descriptor is a string.
- Return values **System capability**: SystemCapability.Communication.IPC.Core
| Type | Description |
- Return value
| Type| Description|
| -------- | -------- | | -------- | -------- |
| string | Interface&nbsp;descriptor&nbsp;obtained. | | string | Interface descriptor obtained.|
### isObjectDead ### isObjectDead
isObjectDead(): boolean isObjectDead(): boolean
Checks whether the current object is dead. Checks whether this object is dead.
- Return values **System capability**: SystemCapability.Communication.IPC.Core
| Type | Description |
- Return value
| Type| Description|
| -------- | -------- | | -------- | -------- |
| boolean | Returns&nbsp;**true**&nbsp;if&nbsp;the&nbsp;object&nbsp;is&nbsp;dead;&nbsp;returns&nbsp;**false**&nbsp;otherwise. | | boolean | Returns **true** if the object is dead; returns **false** otherwise.|
## RemoteProxy ## RemoteProxy
Provides methods to implement **IRemoteObject**. Provides methods to implement **IRemoteObject**.
**System capability**: SystemCapability.Communication.IPC.Core
| Parameter | Value | Description |
| --------------------- | ----------------------- | --------------------------------- |
| PING_TRANSACTION | 1599098439 (0x5f504e47) | Internal instruction code used to test whether the IPC service is normal.|
| DUMP_TRANSACTION | 1598311760 (0x5f444d50) | Internal instruction code used to obtain the internal status of the binder.|
| INTERFACE_TRANSACTION | 1598968902 (0x5f4e5446) | Internal instruction code used to obtain the remote interface descriptor. |
| MIN_TRANSACTION_ID | 1 (0x00000001) | Minimum valid instruction code. |
| MAX_TRANSACTION_ID | 16777215 (0x00FFFFFF) | Maximum valid instruction code. |
### sendRequest ### sendRequest
sendRequest(code : number, data : MessageParcel, reply : MessageParcel, options : MessageOption): Promise&lt;number&gt;<sup>7</sup> sendRequest(code : number, data : MessageParcel, reply : MessageParcel, options : MessageOption): boolean;<sup>7</sup>
sendRequest(code : number, data : MessageParcel, reply : MessageParcel, options : MessageOption): Promise&lt;SendRequestResult&gt;<sup>8+</sup> sendRequest(code : number, data : MessageParcel, reply : MessageParcel, options : MessageOption): Promise&lt;SendRequestResult&gt;<sup>8+</sup>
Sends a **MessageParcel** message to the peer process in synchronous or asynchronous mode. If **options** indicates the asynchronous mode, a promise will be fulfilled immediately and the **reply** message does not contain any content. If **options** indicates the synchronous mode, a promise will be fulfilled when the response to **sendRequest** is returned, and the reply message contains the returned information. Sends a **MessageParcel** message to the remote process in synchronous or asynchronous mode. If **options** is the asynchronous mode, a promise will be fulfilled immediately and the reply message does not contain any content. If **options** is the synchronous mode, a promise will be fulfilled when the response to **sendRequest** is returned, and the reply message contains the returned information.
**System capability**: SystemCapability.Communication.IPC.Core
- Parameters - Parameters
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| code | number | Yes | Message&nbsp;code&nbsp;called&nbsp;by&nbsp;the&nbsp;request,&nbsp;which&nbsp;is&nbsp;determined&nbsp;by&nbsp;the&nbsp;client&nbsp;and&nbsp;server.&nbsp;If&nbsp;the&nbsp;method&nbsp;is&nbsp;generated&nbsp;by&nbsp;an&nbsp;IDL&nbsp;tool,&nbsp;the&nbsp;message&nbsp;code&nbsp;is&nbsp;automatically&nbsp;generated&nbsp;by&nbsp;the&nbsp;IDL&nbsp;tool. | | code | number | Yes| Message code called by the request, which is determined by the client and server. If the method is generated by an IDL tool, the message code is automatically generated by the IDL tool.|
| data | [MessageParcel](#messageparcel) | Yes | **MessageParcel**&nbsp;object&nbsp;holding&nbsp;the&nbsp;data&nbsp;to&nbsp;send. | | data | [MessageParcel](#messageparcel) | Yes| **MessageParcel** object holding the data to send.|
| reply | [MessageParcel](#messageparcel) | Yes | **MessageParcel**&nbsp;object&nbsp;that&nbsp;receives&nbsp;the&nbsp;response. | | reply | [MessageParcel](#messageparcel) | Yes| **MessageParcel** object that receives the response.|
| options | [MessageOption](#messageoption) | Yes | Request&nbsp;sending&nbsp;mode,&nbsp;which&nbsp;can&nbsp;be&nbsp;synchronous&nbsp;(default)&nbsp;or&nbsp;asynchronous. | | options | [MessageOption](#messageoption) | Yes| Request sending mode, which can be synchronous (default) or asynchronous.|
- Return values - Return value
| Type | Description | | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;number&gt;<sup>7</sup><br/>Promise&lt;SendRequestResult&gt;<sup>8+</sup> | Promise&nbsp;used&nbsp;to&nbsp;return&nbsp;the&nbsp;result.&nbsp;The&nbsp;value&nbsp;**0**&nbsp;will&nbsp;be&nbsp;returned&nbsp;if&nbsp;the&nbsp;request&nbsp;is&nbsp;sent&nbsp;successfully.&nbsp;Otherwise,&nbsp;an&nbsp;error&nbsp;code&nbsp;will&nbsp;be&nbsp;returned.&nbsp;<sup>7</sup><br/>Promise&nbsp;used&nbsp;to&nbsp;return&nbsp;the&nbsp;**sendRequestResult**&nbsp;instance.&nbsp;<sup>8+</sup> | | Promise&lt;number&gt;<sup>7</sup><br>Promise&lt;SendRequestResult&gt;<sup>8+</sup> | Promise used to return the result. The value **0** will be returned if the request is sent successfully. Otherwise, an error code will be returned.<sup>7</sup><br>Promise used to return the **sendRequestResult** object.<sup>8+</sup> |
- Example<sup>7</sup> - Example:<sup>7</sup>
``` ```
import FA from "@ohos.ability.featureAbility"; import FA from "@ohos.ability.featureAbility";
...@@ -2508,8 +2563,8 @@ Sends a **MessageParcel** message to the peer process in synchronous or asynchro ...@@ -2508,8 +2563,8 @@ Sends a **MessageParcel** message to the peer process in synchronous or asynchro
} }
}; };
let want = { let want = {
"bundleName": "com.huawei.server", "bundleName": "com.ohos.server",
"abilityName": "com.huawei.server.MainAbility", "abilityName": "com.ohos.server.MainAbility",
}; };
FA.connectAbility(want, connect); FA.connectAbility(want, connect);
let option = new rpc.MessageOption(); let option = new rpc.MessageOption();
...@@ -2535,7 +2590,7 @@ Sends a **MessageParcel** message to the peer process in synchronous or asynchro ...@@ -2535,7 +2590,7 @@ Sends a **MessageParcel** message to the peer process in synchronous or asynchro
}); });
``` ```
- Example<sup>8+</sup> - Example:<sup>8+</sup>
``` ```
import FA from "@ohos.ability.featureAbility"; import FA from "@ohos.ability.featureAbility";
...@@ -2553,8 +2608,8 @@ Sends a **MessageParcel** message to the peer process in synchronous or asynchro ...@@ -2553,8 +2608,8 @@ Sends a **MessageParcel** message to the peer process in synchronous or asynchro
} }
}; };
let want = { let want = {
"bundleName": "com.huawei.server", "bundleName": "com.ohos.server",
"abilityName": "com.huawei.server.MainAbility", "abilityName": "com.ohos.server.MainAbility",
}; };
FA.connectAbility(want, connect); FA.connectAbility(want, connect);
let option = new rpc.MessageOption(); let option = new rpc.MessageOption();
...@@ -2586,17 +2641,18 @@ Sends a **MessageParcel** message to the peer process in synchronous or asynchro ...@@ -2586,17 +2641,18 @@ Sends a **MessageParcel** message to the peer process in synchronous or asynchro
sendRequest(code: number, data: MessageParcel, reply: MessageParcel, options: MessageOption, callback: AsyncCallback&lt;SendRequestResult&gt;): void sendRequest(code: number, data: MessageParcel, reply: MessageParcel, options: MessageOption, callback: AsyncCallback&lt;SendRequestResult&gt;): void
Sends a **MessageParcel** message to the peer process in synchronous or asynchronous mode. If **options** indicates the asynchronous mode, a callback will be invoked immediately and the **reply** message does not contain any content. If **options** indicates the synchronous mode, a callback will be invoked when the response to **sendRequest** is returned, and the **reply** message contains the returned information. Sends a **MessageParcel** message to the remote process in synchronous or asynchronous mode. If **options** is the asynchronous mode, a callback will be invoked immediately and the reply message does not contain any content. If **options** is the synchronous mode, a callback will be invoked when the response to sendRequest is returned, and the reply message contains the returned information.
**System capability**: SystemCapability.Communication.IPC.Core
- Parameters - Parameters
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| code | number | Yes | Message&nbsp;code&nbsp;called&nbsp;by&nbsp;the&nbsp;request,&nbsp;which&nbsp;is&nbsp;determined&nbsp;by&nbsp;the&nbsp;client&nbsp;and&nbsp;server.&nbsp;If&nbsp;the&nbsp;method&nbsp;is&nbsp;generated&nbsp;by&nbsp;an&nbsp;IDL&nbsp;tool,&nbsp;the&nbsp;message&nbsp;code&nbsp;is&nbsp;automatically&nbsp;generated&nbsp;by&nbsp;the&nbsp;IDL&nbsp;tool. | | code | number | Yes| Message code called by the request, which is determined by the client and server. If the method is generated by an IDL tool, the message code is automatically generated by the IDL tool.|
| data | [MessageParcel](#messageparcel) | Yes | **MessageParcel**&nbsp;object&nbsp;holding&nbsp;the&nbsp;data&nbsp;to&nbsp;send. | | data | [MessageParcel](#messageparcel) | Yes| **MessageParcel** object holding the data to send.|
| reply | [MessageParcel](#messageparcel) | Yes | **MessageParcel**&nbsp;object&nbsp;that&nbsp;receives&nbsp;the&nbsp;response. | | reply | [MessageParcel](#messageparcel) | Yes| **MessageParcel** object that receives the response.|
| options | [MessageOption](#messageoption) | Yes | Request&nbsp;sending&nbsp;mode,&nbsp;which&nbsp;can&nbsp;be&nbsp;synchronous&nbsp;(default)&nbsp;or&nbsp;asynchronous. | | options | [MessageOption](#messageoption) | Yes| Request sending mode, which can be synchronous (default) or asynchronous.|
| callback | AsyncCallback&lt;SendRequestResult&gt; | Yes | Callback&nbsp;for&nbsp;receiving&nbsp;the&nbsp;sending&nbsp;result. | | callback | AsyncCallback&lt;SendRequestResult&gt; | Yes| Callback for receiving the sending result.|
- Example - Example
...@@ -2616,8 +2672,8 @@ Sends a **MessageParcel** message to the peer process in synchronous or asynchro ...@@ -2616,8 +2672,8 @@ Sends a **MessageParcel** message to the peer process in synchronous or asynchro
} }
}; };
let want = { let want = {
"bundleName": "com.huawei.server", "bundleName": "com.ohos.server",
"abilityName": "com.huawei.server.MainAbility", "abilityName": "com.ohos.server.MainAbility",
}; };
function sendRequestCallback(result) { function sendRequestCallback(result) {
if (result.errCode === 0) { if (result.errCode === 0) {
...@@ -2648,16 +2704,17 @@ queryLocalInterface(interface: string): IRemoteBroker ...@@ -2648,16 +2704,17 @@ queryLocalInterface(interface: string): IRemoteBroker
Obtains the **LocalInterface** object of an interface descriptor. Obtains the **LocalInterface** object of an interface descriptor.
**System capability**: SystemCapability.Communication.IPC.Core
- Parameters - Parameters
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| interface | string | Yes | Interface&nbsp;descriptor. | | interface | string | Yes| Interface descriptor.|
- Return values - Return value
| Type | Description | | Type| Description|
| -------- | -------- | | -------- | -------- |
| IRemoteBroker | Returns&nbsp;**Null**&nbsp;by&nbsp;default,&nbsp;which&nbsp;indicates&nbsp;a&nbsp;proxy&nbsp;interface. | | IRemoteBroker | Returns **Null** by default, which indicates a proxy interface.|
- Example - Example
...@@ -2677,8 +2734,8 @@ Obtains the **LocalInterface** object of an interface descriptor. ...@@ -2677,8 +2734,8 @@ Obtains the **LocalInterface** object of an interface descriptor.
} }
}; };
let want = { let want = {
"bundleName":"com.huawei.server", "bundleName":"com.ohos.server",
"abilityName":"com.huawei.server.MainAbility", "abilityName":"com.ohos.server.MainAbility",
}; };
FA.connectAbility(want, connect); FA.connectAbility(want, connect);
let broker = proxy.queryLocalInterface("testObject"); let broker = proxy.queryLocalInterface("testObject");
...@@ -2692,17 +2749,18 @@ addDeathRecipient(recipient : DeathRecipient, flags : number): boolean ...@@ -2692,17 +2749,18 @@ addDeathRecipient(recipient : DeathRecipient, flags : number): boolean
Adds a callback for receiving the death notifications of the remote object, including the death notifications of the remote proxy. Adds a callback for receiving the death notifications of the remote object, including the death notifications of the remote proxy.
**System capability**: SystemCapability.Communication.IPC.Core
- Parameters - Parameters
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| recipient | [DeathRecipient](#deathrecipient) | Yes | Callback&nbsp;to&nbsp;add. | | recipient | [DeathRecipient](#deathrecipient) | Yes| Callback to add.|
| flags | number | Yes | Flag&nbsp;of&nbsp;the&nbsp;death&nbsp;notification.&nbsp;This&nbsp;parameter&nbsp;is&nbsp;reserved.&nbsp;It&nbsp;is&nbsp;set&nbsp;to&nbsp;**0**. | | flags | number | Yes| Flag of the death notification. This parameter is reserved. It is set to **0**.|
- Return values - Return value
| Type | Description | | Type| Description|
| -------- | -------- | | -------- | -------- |
| boolean | Returns&nbsp;**true**&nbsp;if&nbsp;the&nbsp;callback&nbsp;is&nbsp;added&nbsp;successfully;&nbsp;returns&nbsp;**false**&nbsp;otherwise. | | boolean | Returns **true** if the callback is added successfully; returns **false** otherwise.|
- Example - Example
...@@ -2722,8 +2780,8 @@ Adds a callback for receiving the death notifications of the remote object, incl ...@@ -2722,8 +2780,8 @@ Adds a callback for receiving the death notifications of the remote object, incl
} }
}; };
let want = { let want = {
"bundleName": "com.huawei.server", "bundleName": "com.ohos.server",
"abilityName": "com.huawei.server.MainAbility", "abilityName": "com.ohos.server.MainAbility",
}; };
FA.connectAbility(want, connect); FA.connectAbility(want, connect);
class MyDeathRecipient { class MyDeathRecipient {
...@@ -2742,17 +2800,18 @@ removeDeathRecipient(recipient : DeathRecipient, flags : number): boolean ...@@ -2742,17 +2800,18 @@ removeDeathRecipient(recipient : DeathRecipient, flags : number): boolean
Removes the callback used to receive death notifications of the remote object. Removes the callback used to receive death notifications of the remote object.
**System capability**: SystemCapability.Communication.IPC.Core
- Parameters - Parameters
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| recipient | [DeathRecipient](#deathrecipient) | Yes | Callback&nbsp;to&nbsp;remove. | | recipient | [DeathRecipient](#deathrecipient) | Yes| Callback to remove.|
| flags | number | Yes | Flag&nbsp;of&nbsp;the&nbsp;death&nbsp;notification.&nbsp;This&nbsp;parameter&nbsp;is&nbsp;reserved.&nbsp;It&nbsp;is&nbsp;set&nbsp;to&nbsp;**0**. | | flags | number | Yes| Flag of the death notification. This parameter is reserved. It is set to **0**.|
- Return values - Return value
| Type | Description | | Type| Description|
| -------- | -------- | | -------- | -------- |
| boolean | Returns&nbsp;**true**&nbsp;if&nbsp;the&nbsp;callback&nbsp;is&nbsp;removed&nbsp;successfully;&nbsp;returns&nbsp;**false**&nbsp;otherwise. | | boolean | Returns **true** if the callback is removed successfully; returns **false** otherwise.|
- Example - Example
...@@ -2772,8 +2831,8 @@ Removes the callback used to receive death notifications of the remote object. ...@@ -2772,8 +2831,8 @@ Removes the callback used to receive death notifications of the remote object.
} }
}; };
let want = { let want = {
"bundleName": "com.huawei.server", "bundleName": "com.ohos.server",
"abilityName": "com.huawei.server.MainAbility", "abilityName": "com.ohos.server.MainAbility",
}; };
FA.connectAbility(want, connect); FA.connectAbility(want, connect);
class MyDeathRecipient { class MyDeathRecipient {
...@@ -2793,11 +2852,12 @@ getInterfaceDescriptor(): string ...@@ -2793,11 +2852,12 @@ getInterfaceDescriptor(): string
Obtains the interface descriptor of this proxy object. Obtains the interface descriptor of this proxy object.
**System capability**: SystemCapability.Communication.IPC.Core
- Return values - Return value
| Type | Description | | Type| Description|
| -------- | -------- | | -------- | -------- |
| string | Interface&nbsp;descriptor&nbsp;obtained. | | string | Interface descriptor obtained.|
- Example - Example
...@@ -2817,8 +2877,8 @@ Obtains the interface descriptor of this proxy object. ...@@ -2817,8 +2877,8 @@ Obtains the interface descriptor of this proxy object.
} }
}; };
let want = { let want = {
"bundleName": "com.huawei.server", "bundleName": "com.ohos.server",
"abilityName": "com.huawei.server.MainAbility", "abilityName": "com.ohos.server.MainAbility",
}; };
FA.connectAbility(want, connect); FA.connectAbility(want, connect);
let descriptor = proxy.getInterfaceDescriptor(); let descriptor = proxy.getInterfaceDescriptor();
...@@ -2832,11 +2892,12 @@ isObjectDead(): boolean ...@@ -2832,11 +2892,12 @@ isObjectDead(): boolean
Checks whether the **RemoteObject** is dead. Checks whether the **RemoteObject** is dead.
**System capability**: SystemCapability.Communication.IPC.Core
- Return values - Return value
| Type | Description | | Type| Description|
| -------- | -------- | | -------- | -------- |
| boolean | Returns&nbsp;**true**&nbsp;if&nbsp;the&nbsp;**RemoteObject**&nbsp;is&nbsp;dead;&nbsp;returns&nbsp;**false**&nbsp;otherwise. | | boolean | Returns **true** if the **RemoteObject** is dead; returns **false** otherwise.|
- Example - Example
...@@ -2856,8 +2917,8 @@ Checks whether the **RemoteObject** is dead. ...@@ -2856,8 +2917,8 @@ Checks whether the **RemoteObject** is dead.
} }
}; };
let want = { let want = {
"bundleName": "com.huawei.server", "bundleName": "com.ohos.server",
"abilityName": "com.huawei.server.MainAbility", "abilityName": "com.ohos.server.MainAbility",
}; };
FA.connectAbility(want, connect); FA.connectAbility(want, connect);
let isDead = proxy.isObjectDead(); let isDead = proxy.isObjectDead();
...@@ -2865,99 +2926,61 @@ Checks whether the **RemoteObject** is dead. ...@@ -2865,99 +2926,61 @@ Checks whether the **RemoteObject** is dead.
``` ```
### setDataVersion<sup>8+</sup>
setDataVersion(dataVersion: number): boolean
Sets the data format version to this **RemoteProxy** object.
- Parameters
| Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
| dataVersion | number | Yes | Data&nbsp;format&nbsp;version&nbsp;to&nbsp;set. |
- Return values
| Type | Description |
| -------- | -------- |
| boolean | Returns&nbsp;**true**&nbsp;if&nbsp;the&nbsp;operation&nbsp;is&nbsp;successful;&nbsp;returns&nbsp;**false**&nbsp;otherwise. |
- Example
```
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.huawei.server",
"abilityName": "com.huawei.server.MainAbility",
};
FA.connectAbility(want, connect);
let result = proxy.setDataVersion(1);
console.log("RpcClient: set Data Version is " + result);
```
## MessageOption ## MessageOption
Provides common message options (flag and wait time). The flag is used to construct the specified **MessageOption** object. Provides common message options (flag and wait time). The flag is used to construct the specified **MessageOption** object.
**System capability**: SystemCapability.Communication.IPC.Core
| Parameters | Value | Description | | Parameter| Value| Description|
| -------- | -------- | -------- | | -------- | -------- | -------- |
| TF_SYNC | 0 | Synchronous&nbsp;call. | | TF_SYNC | 0 | Synchronous call.|
| TF_ASYNC | 1 | Asynchronous&nbsp;call. | | TF_ASYNC | 1 | Asynchronous call.|
| TF_ACCEPT_FDS | 0x10 | Indication&nbsp;to&nbsp;the&nbsp;[sendRequest](#sendrequest8)&nbsp;API&nbsp;for&nbsp;returning&nbsp;the&nbsp;file&nbsp;descriptor. | | TF_ACCEPT_FDS | 0x10 | Indication to the [sendRequest](#sendrequest8) API for returning the file descriptor.|
| TF_WAIT_TIME | 8 | Wait&nbsp;time,&nbsp;in&nbsp;seconds. | | TF_WAIT_TIME | 8 | Time to wait, in seconds.|
### constructor ### constructor
constructor(syncFlags?: number, waitTime = TF_WAIT_TIME) constructor(syncFlags?: number, waitTime = TF_WAIT_TIME)
A constructor used to create a **MessageOption** instance. A constructor used to create a **MessageOption** object.
**System capability**: SystemCapability.Communication.IPC.Core
- Parameters - Parameters
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| syncFlags | number | No | Specifies&nbsp;whether&nbsp;the&nbsp;**SendRequest**&nbsp;is&nbsp;called&nbsp;synchronously&nbsp;(default)&nbsp;or&nbsp;asynchronously. | | syncFlags | number | No| Call flag, which can be synchronous or asynchronous. The default value is **synchronous**.|
| waitTime | number | No | Maximum&nbsp;wait&nbsp;time&nbsp;for&nbsp;an&nbsp;RPC&nbsp;call.&nbsp;The&nbsp;default&nbsp;value&nbsp;is&nbsp;**TF_WAIT_TIME**. | | waitTime | number | No| Maximum wait time for an RPC call. The default value is **TF_WAIT_TIME**.|
### getFlags ### getFlags
getFlags(): number getFlags(): number
Obtains the **SendRequest** call flag, which can be synchronous or asynchronous. Obtains the call flag, which can be synchronous or asynchronous.
**System capability**: SystemCapability.Communication.IPC.Core
- Return values - Return value
| Type | Description | | Type| Description|
| -------- | -------- | | -------- | -------- |
| number | Whether&nbsp;the&nbsp;**SendRequest**&nbsp;is&nbsp;called&nbsp;synchronously&nbsp;or&nbsp;asynchronously. | | number | Call mode obtained.|
### setFlags ### setFlags
setFlags(flags: number): void setFlags(flags: number): void
Sets the **SendRequest** call flag, which can be synchronous or asynchronous. Sets the call flag, which can be synchronous or asynchronous.
**System capability**: SystemCapability.Communication.IPC.Core
- Parameters - Parameters
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| flags | number | Yes | Call&nbsp;flag,&nbsp;which&nbsp;can&nbsp;be&nbsp;synchronous&nbsp;or&nbsp;asynchronous. | | flags | number | Yes| Call flag to set.|
### getWaitTime ### getWaitTime
...@@ -2966,10 +2989,12 @@ getWaitTime(): number ...@@ -2966,10 +2989,12 @@ getWaitTime(): number
Obtains the maximum wait time for this RPC call. Obtains the maximum wait time for this RPC call.
- Return values **System capability**: SystemCapability.Communication.IPC.Core
| Type | Description |
- Return value
| Type| Description|
| -------- | -------- | | -------- | -------- |
| number | Maximum&nbsp;wait&nbsp;time&nbsp;obtained. | | number | Maximum wait time obtained.|
### setWaitTime ### setWaitTime
...@@ -2978,15 +3003,17 @@ setWaitTime(waitTime: number): void ...@@ -2978,15 +3003,17 @@ setWaitTime(waitTime: number): void
Sets the maximum wait time for this RPC call. Sets the maximum wait time for this RPC call.
**System capability**: SystemCapability.Communication.IPC.Core
- Parameters - Parameters
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| waitTime | number | Yes | Maximum&nbsp;wait&nbsp;time&nbsp;to&nbsp;set. | | waitTime | number | Yes| Maximum wait time to set.|
## IPCSkeleton ## IPCSkeleton
Obtains IPC context information, including the UID and PID, local and peer device IDs, and whether the method is invoked on the same device. Obtains IPC context information, including the UID and PID, local and remote device IDs, and whether the method is invoked on the same device.
### getContextObject ### getContextObject
...@@ -2995,11 +3022,12 @@ static getContextObject(): IRemoteObject ...@@ -2995,11 +3022,12 @@ static getContextObject(): IRemoteObject
Obtains the system capability manager. Obtains the system capability manager.
**System capability**: SystemCapability.Communication.IPC.Core
- Return values - Return value
| Type | Description | | Type| Description|
| -------- | -------- | | -------- | -------- |
| [IRemoteObject](#iremoteobject) | System&nbsp;capability&nbsp;manager. | | [IRemoteObject](#iremoteobject) | System capability manager obtained.|
- Example - Example
...@@ -3015,11 +3043,12 @@ static getCallingPid(): number ...@@ -3015,11 +3043,12 @@ 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 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.
**System capability**: SystemCapability.Communication.IPC.Core
- Return values - Return value
| Type | Description | | Type| Description|
| -------- | -------- | | -------- | -------- |
| number | PID&nbsp;of&nbsp;the&nbsp;caller. | | number | PID of the caller.|
- Example - Example
...@@ -3040,11 +3069,12 @@ static getCallingUid(): number ...@@ -3040,11 +3069,12 @@ 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 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.
**System capability**: SystemCapability.Communication.IPC.Core
- Return values - Return value
| Type | Description | | Type| Description|
| -------- | -------- | | -------- | -------- |
| number | UID&nbsp;of&nbsp;the&nbsp;caller. | | number | UID of the caller.|
- Example - Example
...@@ -3058,6 +3088,32 @@ Obtains the UID of the caller. This method is invoked by the **RemoteObject** ob ...@@ -3058,6 +3088,32 @@ Obtains the UID of the caller. This method is invoked by the **RemoteObject** ob
} }
``` ```
### getCallingTokenId
static getCallingTokenId(): number;
Obtains the caller's token ID, which is used to verify the caller identity.
**System capability**: SystemCapability.Communication.IPC.Core
Return value
| Type | Description |
| ------ | --------------------- |
| number | Token ID of the caller obtained.|
Example
```
class Stub extends rpc.RemoteObject {
onRemoteRequest(code, data, reply, option) {
let callerTokenId = rpc.IPCSkeleton.getCallingTokenId();
console.log("RpcServer: getCallingTokenId result: " + callerTokenId);
return true;
}
}
```
### getCalligDeviceID ### getCalligDeviceID
...@@ -3065,11 +3121,12 @@ static getCallingDeviceID(): string ...@@ -3065,11 +3121,12 @@ static getCallingDeviceID(): string
Obtains the ID of the device hosting the caller's process. Obtains the ID of the device hosting the caller's process.
**System capability**: SystemCapability.Communication.IPC.Core
- Return values - Return value
| Type | Description | | Type| Description|
| -------- | -------- | | -------- | -------- |
| string | Device&nbsp;ID&nbsp;obtained. | | string | Device ID obtained.|
- Example - Example
...@@ -3090,11 +3147,12 @@ static getLocalDeviceID(): string ...@@ -3090,11 +3147,12 @@ static getLocalDeviceID(): string
Obtains the local device ID. Obtains the local device ID.
**System capability**: SystemCapability.Communication.IPC.Core
- Return values - Return value
| Type | Description | | Type| Description|
| -------- | -------- | | -------- | -------- |
| string | Local&nbsp;device&nbsp;ID&nbsp;obtained. | | string | Local device ID obtained.|
- Example - Example
...@@ -3113,13 +3171,14 @@ Obtains the local device ID. ...@@ -3113,13 +3171,14 @@ Obtains the local device ID.
static isLocalCalling(): boolean static isLocalCalling(): boolean
Checks whether the peer process is a process of the local device. Checks whether the remote process is a process of the local device.
**System capability**: SystemCapability.Communication.IPC.Core
- Return values - Return value
| Type | Description | | Type| Description|
| -------- | -------- | | -------- | -------- |
| boolean | Returns&nbsp;**true**&nbsp;if&nbsp;the&nbsp;local&nbsp;and&nbsp;peer&nbsp;processes&nbsp;are&nbsp;on&nbsp;the&nbsp;same&nbsp;device;&nbsp;returns&nbsp;false&nbsp;otherwise. | | boolean | Returns **true** if the local and remote processes are on the same device; returns **false** otherwise.|
- Example - Example
...@@ -3140,16 +3199,18 @@ static flushCommands(object : IRemoteObject): number ...@@ -3140,16 +3199,18 @@ 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**. It is recommended that this method be called before any time-sensitive operation is performed.
**System capability**: SystemCapability.Communication.IPC.Core
- Parameters - Parameters
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| object | [IRemoteObject](#iremoteobject) | Yes | **RemoteProxy**. | | object | [IRemoteObject](#iremoteobject) | Yes| **RemoteProxy** specified. |
- Return values - Return value
| Type | Description | | Type| Description|
| -------- | -------- | | -------- | -------- |
| number | Returns&nbsp;**0**&nbsp;if&nbsp;the&nbsp;operation&nbsp;is&nbsp;successful;&nbsp;returns&nbsp;an&nbsp;error&nbsp;code&nbsp;if&nbsp;the&nbsp;input&nbsp;object&nbsp;is&nbsp;null&nbsp;or&nbsp;a&nbsp;**RemoteObject**,&nbsp;or&nbsp;the&nbsp;operation&nbsp;fails. | | number | Returns **0** if the operation is successful; returns an error code if the input object is null or a **RemoteObject**, or if the operation fails.|
- Example - Example
...@@ -3166,11 +3227,12 @@ static resetCallingIdentity(): string ...@@ -3166,11 +3227,12 @@ 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 method is used in scenarios such as identity authentication.
**System capability**: SystemCapability.Communication.IPC.Core
- Return values - Return value
| Type | Description | | Type| Description|
| -------- | -------- | | -------- | -------- |
| string | String&nbsp;containing&nbsp;the&nbsp;UID&nbsp;and&nbsp;PID&nbsp;of&nbsp;the&nbsp;remote&nbsp;user. | | string | String containing the UID and PID of the remote user.|
- Example - Example
...@@ -3191,15 +3253,17 @@ static setCallingIdentity(identity : string): boolean ...@@ -3191,15 +3253,17 @@ 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. 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
- Parameters - Parameters
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| identity | string | Yes | String&nbsp;containing&nbsp;the&nbsp;remote&nbsp;user&nbsp;UID&nbsp;and&nbsp;PID,&nbsp;which&nbsp;are&nbsp;returned&nbsp;by&nbsp;**resetCallingIdentity**. | | identity | string | Yes| String containing the remote user UID and PID, which are returned by **resetCallingIdentity**.|
- Return values - Return value
| Type | Description | | Type| Description|
| -------- | -------- | | -------- | -------- |
| boolean | Returns&nbsp;**true**&nbsp;if&nbsp;the&nbsp;operation&nbsp;is&nbsp;successful;&nbsp;returns&nbsp;**false**&nbsp;otherwise. | | boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
- Example - Example
...@@ -3229,34 +3293,38 @@ Provides methods to implement **RemoteObject**. The service provider must inheri ...@@ -3229,34 +3293,38 @@ Provides methods to implement **RemoteObject**. The service provider must inheri
constructor(descriptor: string) constructor(descriptor: string)
A constructor used to create a **RemoteObject** instance. A constructor used to create a **RemoteObject** object.
**System capability**: SystemCapability.Communication.IPC.Core
- Parameters - Parameters
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| descriptor | string | Yes | Interface&nbsp;descriptor. | | descriptor | string | Yes| Interface descriptor.|
### sendRequest ### sendRequest
sendRequest(code : number, data : MessageParcel, reply : MessageParcel, options : MessageOption): Promise&lt;number&gt;<sup>7</sup> sendRequest(code : number, data : MessageParcel, reply : MessageParcel, options : MessageOption): boolean;<sup>7</sup>
sendRequest(code : number, data : MessageParcel, reply : MessageParcel, options : MessageOption): Promise&lt;SendRequestResult&gt;<sup>8+</sup> sendRequest(code : number, data : MessageParcel, reply : MessageParcel, options : MessageOption): Promise&lt;SendRequestResult&gt;<sup>8+</sup>
Sends a **MessageParcel** message to the peer process in synchronous or asynchronous mode. If **options** indicates the asynchronous mode, a promise will be fulfilled immediately and the **reply** message does not contain any content. If **options** indicates the synchronous mode, a promise will be fulfilled when the response to **sendRequest** is returned, and the reply message contains the returned information. Sends a **MessageParcel** message to the remote process in synchronous or asynchronous mode. If **options** is the asynchronous mode, a promise will be fulfilled immediately and the reply message does not contain any content. If **options** is the synchronous mode, a promise will be fulfilled when the response to **sendRequest** is returned, and the reply message contains the returned information.
**System capability**: SystemCapability.Communication.IPC.Core
- Parameters - Parameters
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| code | number | Yes | Message&nbsp;code&nbsp;called&nbsp;by&nbsp;the&nbsp;request,&nbsp;which&nbsp;is&nbsp;determined&nbsp;by&nbsp;the&nbsp;client&nbsp;and&nbsp;server.&nbsp;If&nbsp;the&nbsp;method&nbsp;is&nbsp;generated&nbsp;by&nbsp;an&nbsp;IDL&nbsp;tool,&nbsp;the&nbsp;message&nbsp;code&nbsp;is&nbsp;automatically&nbsp;generated&nbsp;by&nbsp;the&nbsp;IDL&nbsp;tool. | | code | number | Yes| Message code called by the request, which is determined by the client and server. If the method is generated by an IDL tool, the message code is automatically generated by the IDL tool.|
| data | [MessageParcel](#messageparcel) | Yes | **MessageParcel**&nbsp;object&nbsp;holding&nbsp;the&nbsp;data&nbsp;to&nbsp;send. | | data | [MessageParcel](#messageparcel) | Yes| **MessageParcel** object holding the data to send.|
| reply | [MessageParcel](#messageparcel) | Yes | **MessageParcel**&nbsp;object&nbsp;that&nbsp;receives&nbsp;the&nbsp;response. | | reply | [MessageParcel](#messageparcel) | Yes| **MessageParcel** object that receives the response.|
| options | [MessageOption](#messageoption) | Yes | Request&nbsp;sending&nbsp;mode,&nbsp;which&nbsp;can&nbsp;be&nbsp;synchronous&nbsp;(default)&nbsp;or&nbsp;asynchronous. | | options | [MessageOption](#messageoption) | Yes| Request sending mode, which can be synchronous (default) or asynchronous.|
- Return values - Return value
| Type | Description | | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;number&gt;<sup>7</sup><br/>Promise&lt;SendRequestResult&gt;<sup>8+</sup> | Promise&nbsp;used&nbsp;to&nbsp;return&nbsp;the&nbsp;result.&nbsp;The&nbsp;value&nbsp;**0**&nbsp;will&nbsp;be&nbsp;returned&nbsp;if&nbsp;the&nbsp;request&nbsp;is&nbsp;sent&nbsp;successfully.&nbsp;Otherwise,&nbsp;an&nbsp;error&nbsp;code&nbsp;will&nbsp;be&nbsp;returned.&nbsp;<sup>7</sup><br/>Promise&nbsp;used&nbsp;to&nbsp;return&nbsp;the&nbsp;**sendRequestResult**&nbsp;instance.&nbsp;<sup>8+</sup> | | Promise&lt;number&gt;<sup>7</sup><br>Promise&lt;SendRequestResult&gt;<sup>8+</sup> | Promise used to return the result. The value **0** will be returned if the request is sent successfully. Otherwise, an error code will be returned.<sup>7</sup><br>Promise used to return the **sendRequestResult** object.<sup>8+</sup> |
- Example<sup>7</sup> - Example<sup>7</sup>
...@@ -3330,16 +3398,18 @@ Sends a **MessageParcel** message to the peer process in synchronous or asynchro ...@@ -3330,16 +3398,18 @@ Sends a **MessageParcel** message to the peer process in synchronous or asynchro
sendRequest(code: number, data: MessageParcel, reply: MessageParcel, options: MessageOption, callback: AsyncCallback&lt;SendRequestResult&gt;): void sendRequest(code: number, data: MessageParcel, reply: MessageParcel, options: MessageOption, callback: AsyncCallback&lt;SendRequestResult&gt;): void
Sends a **MessageParcel** message to the peer process in synchronous or asynchronous mode. If **options** indicates the asynchronous mode, a callback will be invoked immediately and the **reply** message does not contain any content. If **options** indicates the synchronous mode, a callback will be invoked when the response to **sendRequest** is returned, and the **reply** message contains the returned information. Sends a **MessageParcel** message to the remote process in synchronous or asynchronous mode. If **options** is the asynchronous mode, a callback will be invoked immediately and the reply message does not contain any content. If **options** is the synchronous mode, a callback will be invoked when the response to sendRequest is returned, and the reply message contains the returned information.
**System capability**: SystemCapability.Communication.IPC.Core
- Parameters - Parameters
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| code | number | Yes | Message&nbsp;code&nbsp;called&nbsp;by&nbsp;the&nbsp;request,&nbsp;which&nbsp;is&nbsp;determined&nbsp;by&nbsp;the&nbsp;client&nbsp;and&nbsp;server.&nbsp;If&nbsp;the&nbsp;method&nbsp;is&nbsp;generated&nbsp;by&nbsp;an&nbsp;IDL&nbsp;tool,&nbsp;the&nbsp;message&nbsp;code&nbsp;is&nbsp;automatically&nbsp;generated&nbsp;by&nbsp;the&nbsp;IDL&nbsp;tool. | | code | number | Yes| Message code called by the request, which is determined by the client and server. If the method is generated by an IDL tool, the message code is automatically generated by the IDL tool.|
| data | [MessageParcel](#messageparcel) | Yes | **MessageParcel**&nbsp;object&nbsp;holding&nbsp;the&nbsp;data&nbsp;to&nbsp;send. | | data | [MessageParcel](#messageparcel) | Yes| **MessageParcel** object holding the data to send.|
| reply | [MessageParcel](#messageparcel) | Yes | **MessageParcel**&nbsp;object&nbsp;that&nbsp;receives&nbsp;the&nbsp;response. | | reply | [MessageParcel](#messageparcel) | Yes| **MessageParcel** object that receives the response.|
| options | [MessageOption](#messageoption) | Yes | Request&nbsp;sending&nbsp;mode,&nbsp;which&nbsp;can&nbsp;be&nbsp;synchronous&nbsp;(default)&nbsp;or&nbsp;asynchronous. | | options | [MessageOption](#messageoption) | Yes| Request sending mode, which can be synchronous (default) or asynchronous.|
| AsyncCallback | AsyncCallback&lt;SendRequestResult&gt; | Yes | Callback&nbsp;for&nbsp;receiving&nbsp;the&nbsp;sending&nbsp;result. | | AsyncCallback | AsyncCallback&lt;SendRequestResult&gt; | Yes| Callback for receiving the sending result.|
- Example - Example
...@@ -3379,18 +3449,20 @@ onRemoteRequest(code : number, data : MessageParcel, reply: MessageParcel, optio ...@@ -3379,18 +3449,20 @@ onRemoteRequest(code : number, data : MessageParcel, reply: MessageParcel, optio
Provides a response to **sendRequest()**. The server processes the request and returns a response in this function. Provides a response to **sendRequest()**. The server processes the request and returns a response in this function.
**System capability**: SystemCapability.Communication.IPC.Core
- Parameters - Parameters
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| code | number | Yes | Service&nbsp;request&nbsp;code&nbsp;sent&nbsp;by&nbsp;the&nbsp;peer&nbsp;end. | | code | number | Yes| Service request code sent by the remote end.|
| data | [MessageParcel](#messageparcel) | Yes | **MessageParcel**&nbsp;object&nbsp;that&nbsp;holds&nbsp;the&nbsp;parameters&nbsp;called&nbsp;by&nbsp;the&nbsp;client. | | data | [MessageParcel](#messageparcel) | Yes| **MessageParcel** object that holds the parameters called by the client.|
| reply | [MessageParcel](#messageparcel) | Yes | **MessageParcel**&nbsp;object&nbsp;carrying&nbsp;the&nbsp;result. | | reply | [MessageParcel](#messageparcel) | Yes| **MessageParcel** object carrying the result.|
| option | [MessageOption](#messageoption) | Yes | Whether&nbsp;the&nbsp;operation&nbsp;is&nbsp;synchronous&nbsp;or&nbsp;asynchronous. | | option | [MessageOption](#messageoption) | Yes| Whether the operation is synchronous or asynchronous.|
- Return values - Return value
| Type | Description | | Type| Description|
| -------- | -------- | | -------- | -------- |
| boolean | Returns&nbsp;**true**&nbsp;if&nbsp;the&nbsp;operation&nbsp;is&nbsp;successful;&nbsp;returns&nbsp;**false**&nbsp;otherwise. | | boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
- Example - Example
...@@ -3418,12 +3490,14 @@ Provides a response to **sendRequest()**. The server processes the request and r ...@@ -3418,12 +3490,14 @@ Provides a response to **sendRequest()**. The server processes the request and r
getCallingUid(): number getCallingUid(): number
Obtains the UID of the peer process. Obtains the UID of the remote process.
- Return values **System capability**: SystemCapability.Communication.IPC.Core
| Type | Description |
- Return value
| Type| Description|
| -------- | -------- | | -------- | -------- |
| number | UID&nbsp;of&nbsp;the&nbsp;peer&nbsp;process&nbsp;obtained. | | number | UID of the remote process obtained.|
- Example - Example
...@@ -3443,12 +3517,14 @@ Obtains the UID of the peer process. ...@@ -3443,12 +3517,14 @@ Obtains the UID of the peer process.
getCallingPid(): number getCallingPid(): number
Obtains the PID of the peer process. Obtains the PID of the remote process.
- Return values **System capability**: SystemCapability.Communication.IPC.Core
| Type | Description |
- Return value
| Type| Description|
| -------- | -------- | | -------- | -------- |
| number | PID&nbsp;of&nbsp;the&nbsp;peer&nbsp;process&nbsp;obtained. | | number | PID of the remote process obtained.|
- Example - Example
...@@ -3466,19 +3542,21 @@ Obtains the PID of the peer process. ...@@ -3466,19 +3542,21 @@ Obtains the PID of the peer process.
### queryLocalInterface ### queryLocalInterface
queryLocalInterface(descriptor: descriptor): IRemoteBroker queryLocalInterface(descriptor: string): IRemoteBroker
Checks whether the remote object corresponding to the specified interface descriptor exists. Checks whether the remote object corresponding to the specified interface descriptor exists.
**System capability**: SystemCapability.Communication.IPC.Core
- Parameters - Parameters
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| descriptor | descriptor | Yes | Interface&nbsp;descriptor. | | descriptor | string | Yes| Interface descriptor.|
- Return values - Return value
| Type | Description | | Type| Description|
| -------- | -------- | | -------- | -------- |
| IRemoteBroker | Returns&nbsp;the&nbsp;remote&nbsp;object&nbsp;if&nbsp;a&nbsp;match&nbsp;is&nbsp;found;&nbsp;returns&nbsp;**Null**&nbsp;otherwise. | | IRemoteBroker | Returns the remote object if a match is found; returns **Null** otherwise.|
- Example - Example
...@@ -3500,10 +3578,12 @@ getInterfaceDescriptor(): string ...@@ -3500,10 +3578,12 @@ getInterfaceDescriptor(): string
Obtains the interface descriptor. Obtains the interface descriptor.
- Return values **System capability**: SystemCapability.Communication.IPC.Core
| Type | Description |
- Return value
| Type| Description|
| -------- | -------- | | -------- | -------- |
| string | Interface&nbsp;descriptor&nbsp;obtained. | | string | Interface descriptor obtained.|
- Example - Example
...@@ -3526,11 +3606,13 @@ attachLocalInterface(localInterface: IRemoteBroker, descriptor: string): void ...@@ -3526,11 +3606,13 @@ attachLocalInterface(localInterface: IRemoteBroker, descriptor: string): void
Binds an interface descriptor to an **IRemoteBroker** object. Binds an interface descriptor to an **IRemoteBroker** object.
**System capability**: SystemCapability.Communication.IPC.Core
- Parameters - Parameters
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| localInterface | IRemoteBroker | Yes | **IRemoteBroker**&nbsp;object. | | localInterface | IRemoteBroker | Yes| **IRemoteBroker** object.|
| descriptor | string | Yes | Interface&nbsp;descriptor. | | descriptor | string | Yes| Interface descriptor.|
- Example - Example
...@@ -3550,32 +3632,36 @@ Binds an interface descriptor to an **IRemoteBroker** object. ...@@ -3550,32 +3632,36 @@ Binds an interface descriptor to an **IRemoteBroker** object.
Provides methods related to anonymous shared memory objects, including creating, closing, mapping, and unmapping an **Ashmem** object, reading data from and writing data to an **Ashmem** object, obtaining the **Ashmem** size, and setting **Ashmem** protection. Provides methods related to anonymous shared memory objects, including creating, closing, mapping, and unmapping an **Ashmem** object, reading data from and writing data to an **Ashmem** object, obtaining the **Ashmem** size, and setting **Ashmem** protection.
The following table describes the protection types of the mapped memory. The table below describes the protection types of the mapped memory.
| Name | Value | Description | **System capability**: SystemCapability.Communication.IPC.Core
| Name| Value| Description|
| -------- | -------- | -------- | | -------- | -------- | -------- |
| PROT_EXEC | 4 | The&nbsp;mapped&nbsp;memory&nbsp;is&nbsp;executable. | | PROT_EXEC | 4 | The mapped memory is executable.|
| PROT_NONE | 0 | The&nbsp;mapped&nbsp;memory&nbsp;is&nbsp;inaccessible. | | PROT_NONE | 0 | The mapped memory is inaccessible.|
| PROT_READ | 1 | The&nbsp;mapped&nbsp;memory&nbsp;is&nbsp;readable. | | PROT_READ | 1 | The mapped memory is readable.|
| PROT_WRITE | 2 | The&nbsp;mapped&nbsp;memory&nbsp;is&nbsp;writeable. | | PROT_WRITE | 2 | The mapped memory is writeable.|
### createAshmem ### createAshmem<sup>8+</sup>
static createAshmem(name: string, size: number): Ashmem static createAshmem(name: string, size: number): Ashmem
Creates an **Ashmem** object with the specified name and size. Creates an **Ashmem** object with the specified name and size.
**System capability**: SystemCapability.Communication.IPC.Core
- Parameters - Parameters
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| name | string | Yes | Name&nbsp;of&nbsp;the&nbsp;**Ashmem**&nbsp;object&nbsp;to&nbsp;create. | | name | string | Yes| Name of the **Ashmem** object to create.|
| size | number | Yes | Size&nbsp;(in&nbsp;bytes)&nbsp;of&nbsp;the&nbsp;**Ashmem**&nbsp;object&nbsp;to&nbsp;create. | | size | number | Yes| Size (in bytes) of the **Ashmem** object to create.|
- Return values - Return value
| Type | Description | | Type| Description|
| -------- | -------- | | -------- | -------- |
| Ashmem | Returns&nbsp;the&nbsp;**Ashmem**&nbsp;object&nbsp;if&nbsp;it&nbsp;is&nbsp;created&nbsp;successfully;&nbsp;returns&nbsp;**null**&nbsp;otherwise. | | Ashmem | Returns the **Ashmem** object if it is created successfully; returns null otherwise.|
- Example - Example
...@@ -3587,21 +3673,23 @@ Creates an **Ashmem** object with the specified name and size. ...@@ -3587,21 +3673,23 @@ Creates an **Ashmem** object with the specified name and size.
``` ```
### createAshmemFromExisting ### createAshmemFromExisting<sup>8+</sup>
static createAshmemFromExisting(ashmem: Ashmem): Ashmem static createAshmemFromExisting(ashmem: Ashmem): Ashmem
Creates an **Ashmem** object by copying the file descriptor (FD) of an existing **Ashmem** object. The two **Ashmem** objects point to the same shared memory region. Creates an **Ashmem** object by copying the file descriptor (FD) of an existing Ashmem object. The two **Ashmem** objects point to the same shared memory region.
**System capability**: SystemCapability.Communication.IPC.Core
- Parameters - Parameters
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| ashmem | Ashmem | Yes | Existing&nbsp;**Ashmem**&nbsp;object. | | ashmem | Ashmem | Yes| Existing **Ashmem** object.|
- Return values - Return value
| Type | Description | | Type| Description|
| -------- | -------- | | -------- | -------- |
| Ashmem | **Ashmem**&nbsp;object&nbsp;created. | | Ashmem | **Ashmem** object created.|
- Example - Example
...@@ -3614,12 +3702,13 @@ Creates an **Ashmem** object by copying the file descriptor (FD) of an existing ...@@ -3614,12 +3702,13 @@ Creates an **Ashmem** object by copying the file descriptor (FD) of an existing
``` ```
### closeAshmem ### closeAshmem<sup>8+</sup>
closeAshmem(): void closeAshmem(): void
Closes this **Ashmem** object. Closes this **Ashmem** object.
**System capability**: SystemCapability.Communication.IPC.Core
- Example - Example
...@@ -3629,12 +3718,13 @@ Closes this **Ashmem** object. ...@@ -3629,12 +3718,13 @@ Closes this **Ashmem** object.
``` ```
### unmapAshmem ### unmapAshmem<sup>8+</sup>
unmapAshmem(): void unmapAshmem(): void
Deletes the mappings for the specified address range of this **Ashmem** object. Deletes the mappings for the specified address range of this **Ashmem** object.
**System capability**: SystemCapability.Communication.IPC.Core
- Example - Example
...@@ -3644,17 +3734,18 @@ Deletes the mappings for the specified address range of this **Ashmem** object. ...@@ -3644,17 +3734,18 @@ Deletes the mappings for the specified address range of this **Ashmem** object.
``` ```
### getAshmemSize ### getAshmemSize<sup>8+</sup>
getAshmemSize(): number getAshmemSize(): number
Obtains the memory size of this **Ashmem** object. Obtains the memory size of this **Ashmem** object.
**System capability**: SystemCapability.Communication.IPC.Core
- Return values - Return value
| Type | Description | | Type| Description|
| -------- | -------- | | -------- | -------- |
| number | Memory&nbsp;size&nbsp;obtained. | | number | **Ashmem** size obtained.|
- Example - Example
...@@ -3665,22 +3756,23 @@ Obtains the memory size of this **Ashmem** object. ...@@ -3665,22 +3756,23 @@ Obtains the memory size of this **Ashmem** object.
``` ```
### mapAshmem ### mapAshmem<sup>8+</sup>
mapAshmem(mapType: number): boolean mapAshmem(mapType: number): boolean
Creates the shared file mapping on the virtual address space of this process. The size of the mapping region is specified by this **Ashmem** object. Creates the shared file mapping on the virtual address space of this process. The size of the mapping region is specified by this **Ashmem** object.
**System capability**: SystemCapability.Communication.IPC.Core
- Parameters - Parameters
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| mapType | number | Yes | Protection&nbsp;level&nbsp;of&nbsp;the&nbsp;memory&nbsp;region&nbsp;to&nbsp;which&nbsp;the&nbsp;shared&nbsp;file&nbsp;is&nbsp;mapped. | | mapType | number | Yes| Protection level of the memory region to which the shared file is mapped.|
- Return values - Return value
| Type | Description | | Type| Description|
| -------- | -------- | | -------- | -------- |
| boolean | Returns&nbsp;**true**&nbsp;if&nbsp;the&nbsp;operation&nbsp;is&nbsp;successful;&nbsp;returns&nbsp;**false**&nbsp;otherwise. | | boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
- Example - Example
...@@ -3691,17 +3783,18 @@ Creates the shared file mapping on the virtual address space of this process. Th ...@@ -3691,17 +3783,18 @@ Creates the shared file mapping on the virtual address space of this process. Th
``` ```
### mapReadAndWriteAshmem ### mapReadAndWriteAshmem<sup>8+</sup>
mapReadAndWriteAshmem(): boolean mapReadAndWriteAshmem(): boolean
Maps the shared file to the readable and writable virtual address space of the process. Maps the shared file to the readable and writable virtual address space of the process.
**System capability**: SystemCapability.Communication.IPC.Core
- Return values - Return value
| Type | Description | | Type| Description|
| -------- | -------- | | -------- | -------- |
| boolean | Returns&nbsp;**true**&nbsp;if&nbsp;the&nbsp;operation&nbsp;is&nbsp;successful;&nbsp;returns&nbsp;**false**&nbsp;otherwise. | | boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
- Example - Example
...@@ -3712,17 +3805,18 @@ Maps the shared file to the readable and writable virtual address space of the p ...@@ -3712,17 +3805,18 @@ Maps the shared file to the readable and writable virtual address space of the p
``` ```
### mapReadOnlyAshmem ### mapReadOnlyAshmem<sup>8+</sup>
mapReadOnlyAshmem(): boolean mapReadOnlyAshmem(): boolean
Maps the shared file to the read-only virtual address space of the process. Maps the shared file to the read-only virtual address space of the process.
**System capability**: SystemCapability.Communication.IPC.Core
- Return values - Return value
| Type | Description | | Type| Description|
| -------- | -------- | | -------- | -------- |
| boolean | Returns&nbsp;**true**&nbsp;if&nbsp;the&nbsp;operation&nbsp;is&nbsp;successful;&nbsp;returns&nbsp;**false**&nbsp;otherwise. | | boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
- Example - Example
...@@ -3733,22 +3827,23 @@ Maps the shared file to the read-only virtual address space of the process. ...@@ -3733,22 +3827,23 @@ Maps the shared file to the read-only virtual address space of the process.
``` ```
### setProtection ### setProtection<sup>8+</sup>
setProtection(protectionType: number): boolean setProtection(protectionType: number): boolean
Sets the protection level of the memory region to which the shared file is mapped. Sets the protection level of the memory region to which the shared file is mapped.
**System capability**: SystemCapability.Communication.IPC.Core
- Parameters - Parameters
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| protectionType | number | Yes | Protection&nbsp;type&nbsp;to&nbsp;set. | | protectionType | number | Yes| Protection type to set.|
- Return values - Return value
| Type | Description | | Type| Description|
| -------- | -------- | | -------- | -------- |
| boolean | Returns&nbsp;**true**&nbsp;if&nbsp;the&nbsp;operation&nbsp;is&nbsp;successful;&nbsp;returns&nbsp;**false**&nbsp;otherwise. | | boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
- Example - Example
...@@ -3759,24 +3854,25 @@ Sets the protection level of the memory region to which the shared file is mappe ...@@ -3759,24 +3854,25 @@ Sets the protection level of the memory region to which the shared file is mappe
``` ```
### writeToAshmem ### writeToAshmem<sup>8+</sup>
writeToAshmem(buf: number[], size: number, offset: number): boolean writeToAshmem(buf: number[], size: number, offset: number): boolean
Writes data to the shared file associated with this **Ashmem** object. Writes data to the shared file associated with this **Ashmem** object.
**System capability**: SystemCapability.Communication.IPC.Core
- Parameters - Parameters
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| buf | number[] | Yes | Data&nbsp;to&nbsp;write. | | buf | number[] | Yes| Data to write.|
| size | number | Yes | Size&nbsp;of&nbsp;the&nbsp;data&nbsp;to&nbsp;write. | | size | number | Yes| Size of the data to write.|
| offset | number | Yes | Start&nbsp;position&nbsp;of&nbsp;the&nbsp;data&nbsp;to&nbsp;write&nbsp;in&nbsp;the&nbsp;memory&nbsp;region&nbsp;associated&nbsp;with&nbsp;this&nbsp;**Ashmem**&nbsp;object. | | offset | number | Yes| Start position of the data to write in the memory region associated with this **Ashmem** object.|
- Return values - Return value
| Type | Description | | Type| Description|
| -------- | -------- | | -------- | -------- |
| boolean | Returns&nbsp;**true**&nbsp;is&nbsp;the&nbsp;data&nbsp;is&nbsp;written&nbsp;successfully;&nbsp;returns&nbsp;**false**&nbsp;otherwise. | | boolean | Returns **true** is the data is written successfully; returns **false** otherwise.|
- Example - Example
...@@ -3788,22 +3884,24 @@ Writes data to the shared file associated with this **Ashmem** object. ...@@ -3788,22 +3884,24 @@ Writes data to the shared file associated with this **Ashmem** object.
``` ```
### readFromAshmem ### readFromAshmem<sup>8+</sup>
readFromAshmem(size: number, offset: number): number[] readFromAshmem(size: number, offset: number): number[]
Reads data from the shared file associated with this **Ashmem** object. Reads data from the shared file associated with this **Ashmem** object.
**System capability**: SystemCapability.Communication.IPC.Core
- Parameters - Parameters
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| size | number | Yes | Size&nbsp;of&nbsp;the&nbsp;data&nbsp;to&nbsp;read. | | size | number | Yes| Size of the data to read.|
| offset | number | Yes | Start&nbsp;position&nbsp;of&nbsp;the&nbsp;data&nbsp;to&nbsp;read&nbsp;in&nbsp;the&nbsp;memory&nbsp;region&nbsp;associated&nbsp;with&nbsp;this&nbsp;**Ashmem**&nbsp;object. | | offset | number | Yes| Start position of the data to read in the memory region associated with this **Ashmem** object.|
- Return values - Return value
| Type | Description | | Type| Description|
| -------- | -------- | | -------- | -------- |
| number[] | Data&nbsp;read. | | number[] | Data read.|
- Example - Example
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册