提交 f1ad9a63 编写于 作者: A Annie_wang

update docs

Signed-off-by: NAnnie_wang <annie.wangli@huawei.com>
上级 62e42ae3
...@@ -41,7 +41,6 @@ The APIs of this module return exceptions since API version 9. The following tab ...@@ -41,7 +41,6 @@ The APIs of this module return exceptions since API version 9. The following tab
## MessageSequence<sup>9+</sup> ## MessageSequence<sup>9+</sup>
Provides APIs for reading and writing data in specific format. Provides APIs for reading and writing data in specific format.
During RPC or IPC, the sender can use the **write()** method provided by **MessageSequence** to write data in specific format to a **MessageSequence** object. The receiver can use the **read()** method provided by **MessageSequence** to read data in specific format from a **MessageSequence** object. The data formats include basic data types and arrays, IPC objects, interface tokens, and custom sequenceable objects. During RPC or IPC, the sender can use the **write()** method provided by **MessageSequence** to write data in specific format to a **MessageSequence** object. The receiver can use the **read()** method provided by **MessageSequence** to read data in specific format from a **MessageSequence** object. The data formats include basic data types and arrays, IPC objects, interface tokens, and custom sequenceable objects.
### create ### create
...@@ -99,7 +98,7 @@ Serializes a remote object and writes it to this **MessageSequence** object. ...@@ -99,7 +98,7 @@ Serializes a remote object and writes it to this **MessageSequence** object.
For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md).
| ID| Error Message| | ID| Error Message|
| -------- | ------- | | -------- | -------- |
| 1900008 | proxy or remote object is invalid | | 1900008 | proxy or remote object is invalid |
| 1900009 | write data to message sequence failed | | 1900009 | write data to message sequence failed |
...@@ -140,7 +139,7 @@ Reads the remote object from **MessageSequence**. You can use this API to deseri ...@@ -140,7 +139,7 @@ Reads the remote object from **MessageSequence**. You can use this API to deseri
For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md).
| ID| Error Message| | ID| Error Message|
| ------- | -------- | | -------- | -------- |
| 1900008 | proxy or remote object is invalid | | 1900008 | proxy or remote object is invalid |
| 1900010 | read data from message sequence failed | | 1900010 | read data from message sequence failed |
...@@ -182,7 +181,7 @@ Writes an interface token to this **MessageSequence** object. The remote object ...@@ -182,7 +181,7 @@ Writes an interface token to this **MessageSequence** object. The remote object
For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md).
| ID| Error Message| | ID| Error Message|
| ------- | -------- | | -------- | -------- |
| 1900009 | write data to message sequence failed | | 1900009 | write data to message sequence failed |
**Example** **Example**
...@@ -216,7 +215,7 @@ Reads the interface token from this **MessageSequence** object. The interface to ...@@ -216,7 +215,7 @@ Reads the interface token from this **MessageSequence** object. The interface to
For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md).
| ID| Error Message| | ID| Error Message|
| ------- | ----- | | -------- | -------- |
| 1900010 | read data from message sequence failed | | 1900010 | read data from message sequence failed |
**Example** **Example**
...@@ -268,7 +267,7 @@ Obtains the capacity of this **MessageSequence** object. ...@@ -268,7 +267,7 @@ Obtains the capacity of this **MessageSequence** object.
**Return value** **Return value**
| Type | Description| | Type | Description |
| ------ | ----- | | ------ | ----- |
| number | **MessageSequence** capacity obtained, in bytes.| | number | **MessageSequence** capacity obtained, in bytes.|
...@@ -290,7 +289,7 @@ Sets the size of the data contained in this **MessageSequence** object. ...@@ -290,7 +289,7 @@ Sets the size of the data contained in this **MessageSequence** object.
**Parameters** **Parameters**
| Name| Type | Mandatory| Description| | Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------ | | ------ | ------ | ---- | ------ |
| size | number | Yes | Data size to set, in bytes.| | size | number | Yes | Data size to set, in bytes.|
...@@ -326,7 +325,7 @@ Sets the storage capacity of this **MessageSequence** object. ...@@ -326,7 +325,7 @@ Sets the storage capacity of this **MessageSequence** object.
For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md).
| ID| Error Message| | ID| Error Message|
| -------- | ------ | | -------- | -------- |
| 1900011 | parcel memory alloc failed | | 1900011 | parcel memory alloc failed |
**Example** **Example**
...@@ -352,7 +351,7 @@ Obtains the writable capacity (in bytes) of this **MessageSequence** object. ...@@ -352,7 +351,7 @@ Obtains the writable capacity (in bytes) of this **MessageSequence** object.
**Return value** **Return value**
| Type| Description| | Type | Description |
| ------ | ------ | | ------ | ------ |
| number | Writable capacity of the **MessageSequence** instance, in bytes.| | number | Writable capacity of the **MessageSequence** instance, in bytes.|
...@@ -378,7 +377,7 @@ Obtains the readable capacity of this **MessageSequence** object. ...@@ -378,7 +377,7 @@ Obtains the readable capacity of this **MessageSequence** object.
**Return value** **Return value**
| Type| Description| | Type | Description |
| ------ | ------- | | ------ | ------- |
| number | Readable capacity of the **MessageSequence** instance, in bytes.| | number | Readable capacity of the **MessageSequence** instance, in bytes.|
...@@ -404,7 +403,7 @@ Obtains the read position of this **MessageSequence** object. ...@@ -404,7 +403,7 @@ Obtains the read position of this **MessageSequence** object.
**Return value** **Return value**
| Type| Description| | Type | Description |
| ------ | ------ | | ------ | ------ |
| number | Read position obtained.| | number | Read position obtained.|
...@@ -426,7 +425,7 @@ Obtains the write position of this **MessageSequence** object. ...@@ -426,7 +425,7 @@ Obtains the write position of this **MessageSequence** object.
**Return value** **Return value**
| Type| Description| | Type | Description |
| ------ | ----- | | ------ | ----- |
| number | Write position obtained.| | number | Write position obtained.|
...@@ -449,7 +448,7 @@ Moves the read pointer to the specified position. ...@@ -449,7 +448,7 @@ Moves the read pointer to the specified position.
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- | | ------ | ------ | ---- | ------- |
| pos | number | Yes | Position from which data is to read.| | pos | number | Yes | Position from which data is to read.|
...@@ -481,7 +480,7 @@ Moves the write pointer to the specified position. ...@@ -481,7 +480,7 @@ Moves the write pointer to the specified position.
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ----- | | ------ | ------ | ---- | ----- |
| pos | number | Yes | Position from which data is to write.| | pos | number | Yes | Position from which data is to write.|
...@@ -511,9 +510,9 @@ Writes a byte value to this **MessageSequence** object. ...@@ -511,9 +510,9 @@ Writes a byte value to this **MessageSequence** object.
**Parameters** **Parameters**
| Name| Type | Mandatory| Description| | Name| Type | Mandatory| Description |
| ----- | ------ | ---- | ----- | | ------ | ------ | ---- | ----- |
| val | number | Yes| Byte value to write.| | val | number | Yes | Byte value to write.|
**Error codes** **Error codes**
...@@ -545,7 +544,7 @@ Reads the byte value from this **MessageSequence** object. ...@@ -545,7 +544,7 @@ Reads the byte value from this **MessageSequence** object.
**Return value** **Return value**
| Type | Description| | Type | Description |
| ------ | ----- | | ------ | ----- |
| number | Byte value read.| | number | Byte value read.|
...@@ -588,14 +587,14 @@ Writes a short integer to this **MessageSequence** object. ...@@ -588,14 +587,14 @@ Writes a short integer to this **MessageSequence** object.
| Name| Type | Mandatory| Description| | Name| Type | Mandatory| Description|
| ------ | ------ | --- | --- | | ------ | ------ | --- | --- |
| val | number | Yes| Short integer to write.| | val | number | Yes | Short integer to write.|
**Error codes** **Error codes**
For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md).
| ID| Error Message| | ID| Error Message|
| ------- | ------ | | -------- | -------- |
| 1900009 | write data to message sequence failed | | 1900009 | write data to message sequence failed |
**Example** **Example**
...@@ -629,7 +628,7 @@ Reads the short integer from this **MessageSequence** object. ...@@ -629,7 +628,7 @@ Reads the short integer from this **MessageSequence** object.
For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md).
| ID| Error Message| | ID| Error Message|
| ------- | -------- | | -------- | -------- |
| 1900010 | read data from message sequence failed | | 1900010 | read data from message sequence failed |
**Example** **Example**
...@@ -670,7 +669,7 @@ Writes an integer to this **MessageSequence** object. ...@@ -670,7 +669,7 @@ Writes an integer to this **MessageSequence** object.
For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md).
| ID| Error Message| | ID| Error Message|
| -------- | ------- | | -------- | -------- |
| 1900009 | write data to message sequence failed | | 1900009 | write data to message sequence failed |
**Example** **Example**
...@@ -704,7 +703,7 @@ Reads the integer from this **MessageSequence** object. ...@@ -704,7 +703,7 @@ Reads the integer from this **MessageSequence** object.
For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md).
| ID| Error Message| | ID| Error Message|
| ------- | ------- | | -------- | -------- |
| 1900010 | read data from message sequence failed | | 1900010 | read data from message sequence failed |
**Example** **Example**
...@@ -745,7 +744,7 @@ Writes a long integer to this **MessageSequence** object. ...@@ -745,7 +744,7 @@ Writes a long integer to this **MessageSequence** object.
For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md).
| ID| Error Message| | ID| Error Message|
| ------- | ------- | | -------- | -------- |
| 1900009 | write data to message sequence failed | | 1900009 | write data to message sequence failed |
**Example** **Example**
...@@ -779,7 +778,7 @@ Reads the long integer from this **MessageSequence** object. ...@@ -779,7 +778,7 @@ Reads the long integer from this **MessageSequence** object.
For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md).
| ID| Error Message| | ID| Error Message|
| ------- | -------- | | -------- | -------- |
| 1900010 | read data from message sequence failed | | 1900010 | read data from message sequence failed |
**Example** **Example**
...@@ -811,16 +810,16 @@ Writes a floating-point number to this **MessageSequence** object. ...@@ -811,16 +810,16 @@ Writes a floating-point number to this **MessageSequence** object.
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type | Mandatory| Description |
| ----- | ---- | ---- | ----- | | ------ | ------ | ---- | ----- |
| val | number | Yes| Floating-point number to write.| | val | number | Yes | Floating-point number to write.|
**Error codes** **Error codes**
For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md).
| ID| Error Message| | ID| Error Message|
| ------- | ------- | | -------- | -------- |
| 1900009 | write data to message sequence failed | | 1900009 | write data to message sequence failed |
**Example** **Example**
...@@ -854,7 +853,7 @@ Reads the floating-pointer number from this **MessageSequence** object. ...@@ -854,7 +853,7 @@ Reads the floating-pointer number from this **MessageSequence** object.
For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md).
| ID| Error Message| | ID| Error Message|
| ------- | -------- | | -------- | -------- |
| 1900010 | read data from message sequence failed | | 1900010 | read data from message sequence failed |
**Example** **Example**
...@@ -895,7 +894,7 @@ Writes a double-precision floating-point number to this **MessageSequence** obje ...@@ -895,7 +894,7 @@ Writes a double-precision floating-point number to this **MessageSequence** obje
For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md).
| ID| Error Message| | ID| Error Message|
| ------- | -------- | | -------- | -------- |
| 1900009 | write data to message sequence failed | | 1900009 | write data to message sequence failed |
**Example** **Example**
...@@ -929,7 +928,7 @@ Reads the double-precision floating-point number from this **MessageSequence** o ...@@ -929,7 +928,7 @@ Reads the double-precision floating-point number from this **MessageSequence** o
For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md).
| ID| Error Message| | ID| Error Message|
| ------- | -------- | | -------- | -------- |
| 1900010 | read data from message sequence failed | | 1900010 | read data from message sequence failed |
**Example** **Example**
...@@ -970,7 +969,7 @@ Writes a Boolean value to this **MessageSequence** object. ...@@ -970,7 +969,7 @@ Writes a Boolean value to this **MessageSequence** object.
For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md).
| ID| Error Message| | ID| Error Message|
| ------- | ------- | | -------- | -------- |
| 1900009 | write data to message sequence failed | | 1900009 | write data to message sequence failed |
**Example** **Example**
...@@ -1004,7 +1003,7 @@ Reads the Boolean value from this **MessageSequence** object. ...@@ -1004,7 +1003,7 @@ Reads the Boolean value from this **MessageSequence** object.
For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md).
| ID| Error Message| | ID| Error Message|
| -------- | ------- | | -------- | -------- |
| 1900010 | read data from message sequence failed | | 1900010 | read data from message sequence failed |
**Example** **Example**
...@@ -1045,7 +1044,7 @@ Writes a character to this **MessageSequence** object. ...@@ -1045,7 +1044,7 @@ Writes a character to this **MessageSequence** object.
For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md).
| ID| Error Message| | ID| Error Message|
| ------- | -------- | | -------- | -------- |
| 1900009 | write data to message sequence failed | | 1900009 | write data to message sequence failed |
**Example** **Example**
...@@ -1079,7 +1078,7 @@ Reads the character from this **MessageSequence** object. ...@@ -1079,7 +1078,7 @@ Reads the character from this **MessageSequence** object.
For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md).
| ID| Error Message| | ID| Error Message|
| ------ | --------- | | -------- | -------- |
| 1900010 | read data from message sequence failed | | 1900010 | read data from message sequence failed |
**Example** **Example**
...@@ -1120,7 +1119,7 @@ Writes a string to this **MessageSequence** object. ...@@ -1120,7 +1119,7 @@ Writes a string to this **MessageSequence** object.
For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md).
| ID| Error Message| | ID| Error Message|
| ------- | -------- | | -------- | -------- |
| 1900009 | write data to message sequence failed | | 1900009 | write data to message sequence failed |
**Example** **Example**
...@@ -1154,7 +1153,7 @@ Reads the string from this **MessageSequence** object. ...@@ -1154,7 +1153,7 @@ Reads the string from this **MessageSequence** object.
For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md).
| ID| Error Message| | ID| Error Message|
| ------- | -------- | | -------- | -------- |
| 1900010 | read data from message sequence failed | | 1900010 | read data from message sequence failed |
**Example** **Example**
...@@ -1195,7 +1194,7 @@ Writes a **Parcelable** object to this **MessageSequence** object. ...@@ -1195,7 +1194,7 @@ Writes a **Parcelable** object to this **MessageSequence** object.
For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md).
| ID| Error Message| | ID| Error Message|
| ------- | -------- | | -------- | -------- |
| 1900009 | write data to message sequence failed | | 1900009 | write data to message sequence failed |
**Example** **Example**
...@@ -1248,7 +1247,7 @@ Reads a **Parcelable** object from this **MessageSequence** object to the specif ...@@ -1248,7 +1247,7 @@ Reads a **Parcelable** object from this **MessageSequence** object to the specif
For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md).
| ID| Error Message| | ID| Error Message|
| -------- | ------- | | -------- | -------- |
| 1900010 | read data from message sequence failed | | 1900010 | read data from message sequence failed |
| 1900012 | call js callback function failed | | 1900012 | call js callback function failed |
...@@ -1304,7 +1303,7 @@ Writes a byte array to this **MessageSequence** object. ...@@ -1304,7 +1303,7 @@ Writes a byte array to this **MessageSequence** object.
For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md).
| ID| Error Message| | ID| Error Message|
| ------- | -------- | | -------- | -------- |
| 1900009 | write data to message sequence failed | | 1900009 | write data to message sequence failed |
**Example** **Example**
...@@ -1339,7 +1338,7 @@ Reads a byte array from this **MessageSequence** object. ...@@ -1339,7 +1338,7 @@ Reads a byte array from this **MessageSequence** object.
For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md).
| ID| Error Message| | ID| Error Message|
| ------- | -------- | | -------- | -------- |
| 1900010 | read data from message sequence failed | | 1900010 | read data from message sequence failed |
**Example** **Example**
...@@ -1381,7 +1380,7 @@ Reads the byte array from this **MessageSequence** object. ...@@ -1381,7 +1380,7 @@ Reads the byte array from this **MessageSequence** object.
For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md).
| ID| Error Message| | ID| Error Message|
| -------- | ------- | | -------- | -------- |
| 1900010 | read data from message sequence failed | | 1900010 | read data from message sequence failed |
**Example** **Example**
...@@ -1423,7 +1422,7 @@ Writes a short array to this **MessageSequence** object. ...@@ -1423,7 +1422,7 @@ Writes a short array to this **MessageSequence** object.
For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md).
| ID| Error Message| | ID| Error Message|
| ----- | ----- | | -------- | -------- |
| 1900009 | write data to message sequence failed | | 1900009 | write data to message sequence failed |
**Example** **Example**
...@@ -1457,7 +1456,7 @@ Reads a short array from this **MessageSequence** object. ...@@ -1457,7 +1456,7 @@ Reads a short array from this **MessageSequence** object.
For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md).
| ID| Error Message| | ID| Error Message|
| ------ | ------- | | -------- | -------- |
| 1900010 | read data from message sequence failed | | 1900010 | read data from message sequence failed |
**Example** **Example**
...@@ -1498,7 +1497,7 @@ Reads the short array from this **MessageSequence** object. ...@@ -1498,7 +1497,7 @@ Reads the short array from this **MessageSequence** object.
For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md).
| ID| Error Message| | ID| Error Message|
| -------- | ------- | | -------- | -------- |
| 1900010 | read data from message sequence failed | | 1900010 | read data from message sequence failed |
**Example** **Example**
...@@ -1539,7 +1538,7 @@ Writes an integer array to this **MessageSequence** object. ...@@ -1539,7 +1538,7 @@ Writes an integer array to this **MessageSequence** object.
For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md).
| ID| Error Message| | ID| Error Message|
| ----- | --------- | | -------- | -------- |
| 1900009 | write data to message sequence failed | | 1900009 | write data to message sequence failed |
**Example** **Example**
...@@ -1573,7 +1572,7 @@ Reads an integer array from this **MessageSequence** object. ...@@ -1573,7 +1572,7 @@ Reads an integer array from this **MessageSequence** object.
For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md).
| ID| Error Message| | ID| Error Message|
| ------- | -------- | | -------- | -------- |
| 1900010 | read data from message sequence failed | | 1900010 | read data from message sequence failed |
**Example** **Example**
...@@ -1614,7 +1613,7 @@ Reads the integer array from this **MessageSequence** object. ...@@ -1614,7 +1613,7 @@ Reads the integer array from this **MessageSequence** object.
For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md).
| ID| Error Message| | ID| Error Message|
| ----- | ------- | | -------- | -------- |
| 1900010 | read data from message sequence failed | | 1900010 | read data from message sequence failed |
**Example** **Example**
...@@ -1655,7 +1654,7 @@ Writes a long array to this **MessageSequence** object. ...@@ -1655,7 +1654,7 @@ Writes a long array to this **MessageSequence** object.
For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md).
| ID| Error Message| | ID| Error Message|
| ------- | ----- | | -------- | -------- |
| 1900009 | write data to message sequence failed | | 1900009 | write data to message sequence failed |
**Example** **Example**
...@@ -1689,7 +1688,7 @@ Reads a long array from this **MessageSequence** object. ...@@ -1689,7 +1688,7 @@ Reads a long array from this **MessageSequence** object.
For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md).
| ID| Error Message| | ID| Error Message|
| ------- | ------ | | -------- | -------- |
| 1900010 | read data from message sequence failed | | 1900010 | read data from message sequence failed |
**Example** **Example**
...@@ -1730,7 +1729,7 @@ Reads the long array from this **MessageSequence** object. ...@@ -1730,7 +1729,7 @@ Reads the long array from this **MessageSequence** object.
For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md).
| ID| Error Message| | ID| Error Message|
| ------- | -------- | | -------- | -------- |
| 1900010 | read data from message sequence failed | | 1900010 | read data from message sequence failed |
**Example** **Example**
...@@ -1771,7 +1770,7 @@ Writes a floating-point array to this **MessageSequence** object. ...@@ -1771,7 +1770,7 @@ Writes a floating-point array to this **MessageSequence** object.
For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md).
| ID| Error Message| | ID| Error Message|
| ------- | -------- | | -------- | -------- |
| 1900009 | write data to message sequence failed | | 1900009 | write data to message sequence failed |
**Example** **Example**
...@@ -1805,7 +1804,7 @@ Reads a floating-point array from this **MessageSequence** object. ...@@ -1805,7 +1804,7 @@ Reads a floating-point array from this **MessageSequence** object.
For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md).
| ID| Error Message| | ID| Error Message|
| ------- | -------- | | -------- | -------- |
| 1900010 | read data from message sequence failed | | 1900010 | read data from message sequence failed |
**Example** **Example**
...@@ -1846,7 +1845,7 @@ Reads the floating-point array from this **MessageSequence** object. ...@@ -1846,7 +1845,7 @@ Reads the floating-point array from this **MessageSequence** object.
For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md).
| ID| Error Message| | ID| Error Message|
| ------- | -------- | | -------- | -------- |
| 1900010 | read data from message sequence failed | | 1900010 | read data from message sequence failed |
**Example** **Example**
...@@ -1887,7 +1886,7 @@ Writes a double-precision floating-point array to this **MessageSequence** objec ...@@ -1887,7 +1886,7 @@ Writes a double-precision floating-point array to this **MessageSequence** objec
For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md).
| ID| Error Message| | ID| Error Message|
| ------- | -------- | | -------- | -------- |
| 1900009 | write data to message sequence failed | | 1900009 | write data to message sequence failed |
**Example** **Example**
...@@ -1921,7 +1920,7 @@ Reads a double-precision floating-point array from this **MessageSequence** obje ...@@ -1921,7 +1920,7 @@ Reads a double-precision floating-point array from this **MessageSequence** obje
For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md).
| ID| Error Message| | ID| Error Message|
| ------- | -------- | | -------- | -------- |
| 1900010 | read data from message sequence failed | | 1900010 | read data from message sequence failed |
**Example** **Example**
...@@ -1962,7 +1961,7 @@ Reads the double-precision floating-point array from this **MessageSequence** ob ...@@ -1962,7 +1961,7 @@ Reads the double-precision floating-point array from this **MessageSequence** ob
For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md).
| ID| Error Message| | ID| Error Message|
| ------- | -------- | | -------- | -------- |
| 1900010 | read data from message sequence failed | | 1900010 | read data from message sequence failed |
**Example** **Example**
...@@ -2003,7 +2002,7 @@ Writes a Boolean array to this **MessageSequence** object. ...@@ -2003,7 +2002,7 @@ Writes a Boolean array to this **MessageSequence** object.
For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md).
| ID| Error Message| | ID| Error Message|
| ------- | -------- | | -------- | -------- |
| 1900009 | write data to message sequence failed | | 1900009 | write data to message sequence failed |
**Example** **Example**
...@@ -2037,7 +2036,7 @@ Reads a Boolean array from this **MessageSequence** object. ...@@ -2037,7 +2036,7 @@ Reads a Boolean array from this **MessageSequence** object.
For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md).
| ID| Error Message| | ID| Error Message|
| ------- | -------- | | -------- | -------- |
| 1900010 | read data from message sequence failed | | 1900010 | read data from message sequence failed |
**Example** **Example**
...@@ -2078,7 +2077,7 @@ Reads the Boolean array from this **MessageSequence** object. ...@@ -2078,7 +2077,7 @@ Reads the Boolean array from this **MessageSequence** object.
For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md).
| ID| Error Message| | ID| Error Message|
| ------- | -------- | | -------- | -------- |
| 1900010 | read data from message sequence failed | | 1900010 | read data from message sequence failed |
**Example** **Example**
...@@ -2119,7 +2118,7 @@ Writes a character array to this **MessageSequence** object. ...@@ -2119,7 +2118,7 @@ Writes a character array to this **MessageSequence** object.
For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md).
| ID| Error Message| | ID| Error Message|
| -------- | ------ | | -------- | -------- |
| 1900009 | write data to message sequence failed | | 1900009 | write data to message sequence failed |
**Example** **Example**
...@@ -2153,7 +2152,7 @@ Reads a character array from this **MessageSequence** object. ...@@ -2153,7 +2152,7 @@ Reads a character array from this **MessageSequence** object.
For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md).
| ID| Error Message| | ID| Error Message|
| ------- | -------- | | -------- | -------- |
| 1900010 | read data from message sequence failed | | 1900010 | read data from message sequence failed |
**Example** **Example**
...@@ -2194,7 +2193,7 @@ Reads the character array from this **MessageSequence** object. ...@@ -2194,7 +2193,7 @@ Reads the character array from this **MessageSequence** object.
For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md).
| ID| Error Message| | ID| Error Message|
| ------- | -------- | | -------- | -------- |
| 1900010 | read data from message sequence failed | | 1900010 | read data from message sequence failed |
**Example** **Example**
...@@ -2236,7 +2235,7 @@ Writes a string array to this **MessageSequence** object. ...@@ -2236,7 +2235,7 @@ Writes a string array to this **MessageSequence** object.
For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md).
| ID| Error Message| | ID| Error Message|
| ------- | -------- | | -------- | -------- |
| 1900009 | write data to message sequence failed | | 1900009 | write data to message sequence failed |
**Example** **Example**
...@@ -2270,7 +2269,7 @@ Reads a string array from this **MessageSequence** object. ...@@ -2270,7 +2269,7 @@ Reads a string array from this **MessageSequence** object.
For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md).
| ID| Error Message| | ID| Error Message|
| ------- | -------- | | -------- | -------- |
| 1900010 | read data from message sequence failed | | 1900010 | read data from message sequence failed |
**Example** **Example**
...@@ -2311,7 +2310,7 @@ Reads the string array from this **MessageSequence** object. ...@@ -2311,7 +2310,7 @@ Reads the string array from this **MessageSequence** object.
For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md).
| ID| Error Message| | ID| Error Message|
| ------- | -------- | | -------- | -------- |
| 1900010 | read data from message sequence failed | | 1900010 | read data from message sequence failed |
**Example** **Example**
...@@ -2346,7 +2345,7 @@ Writes information to this **MessageSequence** object indicating that no excepti ...@@ -2346,7 +2345,7 @@ Writes information to this **MessageSequence** object indicating that no excepti
For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md).
| ID| Error Message| | ID| Error Message|
| ------- | -------- | | -------- | -------- |
| 1900009 | write data to message sequence failed | | 1900009 | write data to message sequence failed |
**Example** **Example**
...@@ -2388,15 +2387,17 @@ Reads the exception information from this **MessageSequence** object. ...@@ -2388,15 +2387,17 @@ Reads the exception information from this **MessageSequence** object.
For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md).
| ID| Error Message| | ID| Error Message|
| ------- | -------- | | -------- | -------- |
| 1900010 | read data from message sequence failed | | 1900010 | read data from message sequence failed |
**Example** **Example**
Obtain the service. Before obtaining the ability for the application developed based on the stage model, obtain the context. For details, see [Obtaining the Context](#obtaining-the-context).
```ts ```ts
import FA from "@ohos.ability.featureAbility"; // Import @ohos.ability.featureAbility only for the application developed based on the FA model.
// import FA from "@ohos.ability.featureAbility";
let proxy; let proxy;
let connect = { let connect = {
onConnect: function(elementName, remoteProxy) { onConnect: function(elementName, remoteProxy) {
...@@ -2414,7 +2415,11 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode ...@@ -2414,7 +2415,11 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
"bundleName": "com.ohos.server", "bundleName": "com.ohos.server",
"abilityName": "com.ohos.server.EntryAbility", "abilityName": "com.ohos.server.EntryAbility",
}; };
FA.connectAbility(want, connect);
// Use this method to connect to the ability for the FA model.
// FA.connectAbility(want,connect);
globalThis.context.connectServiceExtensionAbility(want, connect);
``` ```
The proxy object in the **onConnect** callback can be assigned a value only after the ability is connected asynchronously. Then, **sendMessageRequest()** of the proxy object is called to send a message. The proxy object in the **onConnect** callback can be assigned a value only after the ability is connected asynchronously. Then, **sendMessageRequest()** of the proxy object is called to send a message.
...@@ -2468,7 +2473,7 @@ Writes a **Parcelable** array to this **MessageSequence** object. ...@@ -2468,7 +2473,7 @@ Writes a **Parcelable** array to this **MessageSequence** object.
For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md).
| ID| Error Message| | ID| Error Message|
| ------- | -------- | | -------- | -------- |
| 1900009 | write data to message sequence failed | | 1900009 | write data to message sequence failed |
**Example** **Example**
...@@ -2524,7 +2529,7 @@ Reads a **Parcelable** array from this **MessageSequence** object. ...@@ -2524,7 +2529,7 @@ Reads a **Parcelable** array from this **MessageSequence** object.
For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md).
| ID| Error Message| | ID| Error Message|
| ------- | -------- | | -------- | -------- |
| 1900010 | read data from message sequence failed | | 1900010 | read data from message sequence failed |
| 1900012 | call js callback function failed | | 1900012 | call js callback function failed |
...@@ -2585,7 +2590,7 @@ Writes an array of **IRemoteObject** objects to this **MessageSequence** object. ...@@ -2585,7 +2590,7 @@ Writes an array of **IRemoteObject** objects to this **MessageSequence** object.
For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md).
| ID| Error Message| | ID| Error Message|
| ------- | ------- | | -------- | -------- |
| 1900009 | write data to message sequence failed | | 1900009 | write data to message sequence failed |
**Example** **Example**
...@@ -2632,7 +2637,7 @@ Reads an array of **IRemoteObject** objects from this **MessageSequence** object ...@@ -2632,7 +2637,7 @@ Reads an array of **IRemoteObject** objects from this **MessageSequence** object
For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md).
| ID| Error Message| | ID| Error Message|
| ------- | -------- | | -------- | -------- |
| 1900010 | read data from message sequence failed | | 1900010 | read data from message sequence failed |
**Example** **Example**
...@@ -2685,7 +2690,7 @@ Reads the **IRemoteObject** object array from this **MessageSequence** object. ...@@ -2685,7 +2690,7 @@ Reads the **IRemoteObject** object array from this **MessageSequence** object.
For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md).
| ID| Error Message| | ID| Error Message|
| ------- | -------- | | -------- | -------- |
| 1900010 | read data from message sequence failed | | 1900010 | read data from message sequence failed |
**Example** **Example**
...@@ -2731,11 +2736,11 @@ Closes a file descriptor. This API is a static method. ...@@ -2731,11 +2736,11 @@ Closes a file descriptor. This API is a static method.
**Example** **Example**
```ts ```ts
import fileio from '@ohos.fileio'; import fs from '@ohos.file.fs';
let filePath = "path/to/file"; let filePath = "path/to/file";
let fd = fileio.openSync(filePath, 0o2| 0o100, 0o666); let file = fs.openSync(filePath, fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE);
try { try {
rpc.MessageSequence.closeFileDescriptor(fd); rpc.MessageSequence.closeFileDescriptor(file.fd);
} catch(error) { } catch(error) {
console.info("rpc close file descriptor fail, errorCode " + error.code); console.info("rpc close file descriptor fail, errorCode " + error.code);
console.info("rpc close file descriptor fail, errorMessage" + error.message); console.info("rpc close file descriptor fail, errorMessage" + error.message);
...@@ -2767,17 +2772,17 @@ Duplicates a file descriptor. This API is a static method. ...@@ -2767,17 +2772,17 @@ Duplicates a file descriptor. This API is a static method.
For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md).
| ID| Error Message| | ID| Error Message|
| ------- | ------- | | -------- | -------- |
| 1900013 | call os dup function failed | | 1900013 | call os dup function failed |
**Example** **Example**
```ts ```ts
import fileio from '@ohos.fileio'; import fs from '@ohos.file.fs';
let filePath = "path/to/file"; let filePath = "path/to/file";
let fd = fileio.openSync(filePath, 0o2| 0o100, 0o666); let file = fs.openSync(filePath, fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE);
try { try {
let newFd = rpc.MessageSequence.dupFileDescriptor(fd); let newFd = rpc.MessageSequence.dupFileDescriptor(file.fd);
} catch(error) { } catch(error) {
console.info("rpc dup file descriptor fail, errorCode " + error.code); console.info("rpc dup file descriptor fail, errorCode " + error.code);
console.info("rpc dup file descriptor fail, errorMessage" + error.message); console.info("rpc dup file descriptor fail, errorMessage" + error.message);
...@@ -2802,13 +2807,13 @@ Checks whether this **MessageSequence** object contains file descriptors. ...@@ -2802,13 +2807,13 @@ Checks whether this **MessageSequence** object contains file descriptors.
```ts ```ts
import fileio from '@ohos.fileio'; import fs from '@ohos.file.fs';
let sequence = new rpc.MessageSequence(); let sequence = new rpc.MessageSequence();
let filePath = "path/to/file"; let filePath = "path/to/file";
let r1 = sequence.containFileDescriptors(); let r1 = sequence.containFileDescriptors();
let fd = fileio.openSync(filePath, 0o2| 0o100, 0o666); let file = fs.openSync(filePath, fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE);
try { try {
sequence.writeFileDescriptor(fd); sequence.writeFileDescriptor(file.fd);
} catch(error) { } catch(error) {
console.info("rpc write file descriptor fail, errorCode " + error.code); console.info("rpc write file descriptor fail, errorCode " + error.code);
console.info("rpc write file descriptor fail, errorMessage" + error.message); console.info("rpc write file descriptor fail, errorMessage" + error.message);
...@@ -2841,18 +2846,18 @@ Writes a file descriptor to this **MessageSequence** object. ...@@ -2841,18 +2846,18 @@ Writes a file descriptor to this **MessageSequence** object.
For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md).
| ID| Error Message| | ID| Error Message|
| -------- | ------ | | -------- | -------- |
| 1900009 | write data to message sequence failed | | 1900009 | write data to message sequence failed |
**Example** **Example**
```ts ```ts
import fileio from '@ohos.fileio'; import fs from '@ohos.file.fs';
let sequence = new rpc.MessageSequence(); let sequence = new rpc.MessageSequence();
let filePath = "path/to/file"; let filePath = "path/to/file";
let fd = fileio.openSync(filePath, 0o2| 0o100, 0o666); let file = fs.openSync(filePath, fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE);
try { try {
sequence.writeFileDescriptor(fd); sequence.writeFileDescriptor(file.fd);
} catch(error) { } catch(error) {
console.info("rpc write file descriptor fail, errorCode " + error.code); console.info("rpc write file descriptor fail, errorCode " + error.code);
console.info("rpc write file descriptor fail, errorMessage" + error.message); console.info("rpc write file descriptor fail, errorMessage" + error.message);
...@@ -2878,18 +2883,18 @@ Reads the file descriptor from this **MessageSequence** object. ...@@ -2878,18 +2883,18 @@ Reads the file descriptor from this **MessageSequence** object.
For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md).
| ID| Error Message| | ID| Error Message|
| ------- | -------- | | -------- | -------- |
| 1900010 | read data from message sequence failed | | 1900010 | read data from message sequence failed |
**Example** **Example**
```ts ```ts
import fileio from '@ohos.fileio'; import fs from '@ohos.file.fs';
let sequence = new rpc.MessageSequence(); let sequence = new rpc.MessageSequence();
let filePath = "path/to/file"; let filePath = "path/to/file";
let fd = fileio.openSync(filePath, 0o2| 0o100, 0o666); let file = fs.openSync(filePath, fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE);
try { try {
sequence.writeFileDescriptor(fd); sequence.writeFileDescriptor(file.fd);
} catch(error) { } catch(error) {
console.info("rpc write file descriptor fail, errorCode " + error.code); console.info("rpc write file descriptor fail, errorCode " + error.code);
console.info("rpc write file descriptor fail, errorMessage" + error.message); console.info("rpc write file descriptor fail, errorMessage" + error.message);
...@@ -2921,7 +2926,7 @@ Writes an anonymous shared object to this **MessageSequence** object. ...@@ -2921,7 +2926,7 @@ Writes an anonymous shared object to this **MessageSequence** object.
For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md).
| ID| Error Message| | ID| Error Message|
| ------- | ------- | | -------- | ------- |
| 1900003 | write to ashmem failed | | 1900003 | write to ashmem failed |
**Example** **Example**
...@@ -2963,7 +2968,7 @@ Reads the anonymous shared object from this **MessageSequence** object. ...@@ -2963,7 +2968,7 @@ Reads the anonymous shared object from this **MessageSequence** object.
For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md).
| ID| Error Message| | ID| Error Message|
| ------- | -------- | | -------- | -------- |
| 1900004 | read from ashmem failed | | 1900004 | read from ashmem failed |
**Example** **Example**
...@@ -3034,7 +3039,7 @@ Writes raw data to this **MessageSequence** object. ...@@ -3034,7 +3039,7 @@ Writes raw data to this **MessageSequence** object.
For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md).
| ID| Error Message| | ID| Error Message|
| ------- | ------ | | -------- | -------- |
| 1900009 | write data to message sequence failed | | 1900009 | write data to message sequence failed |
**Example** **Example**
...@@ -3075,7 +3080,7 @@ Reads raw data from this **MessageSequence** object. ...@@ -3075,7 +3080,7 @@ Reads raw data from this **MessageSequence** object.
For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md).
| ID| Error Message| | ID| Error Message|
| ------- | -------- | | -------- | -------- |
| 1900010 | read data from message sequence failed | | 1900010 | read data from message sequence failed |
**Example** **Example**
...@@ -3103,7 +3108,6 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode ...@@ -3103,7 +3108,6 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
>This class is no longer maintained since API version 9. You are advised to use [MessageSequence](#messagesequence9). >This class is no longer maintained since API version 9. You are advised to use [MessageSequence](#messagesequence9).
Provides APIs for reading and writing data in specific format. Provides APIs for reading and writing data in specific format.
During RPC, the sender can use the **write()** method provided by **MessageParcel** to write data in specific format to a **MessageParcel** object. The receiver can use the **read()** method provided by **MessageParcel** to read data in specific format from a **MessageParcel** object. The data formats include basic data types and arrays, IPC objects, interface tokens, and custom sequenceable objects. During RPC, the sender can use the **write()** method provided by **MessageParcel** to write data in specific format to a **MessageParcel** object. The receiver can use the **read()** method provided by **MessageParcel** to read data in specific format from a **MessageParcel** object. The data formats include basic data types and arrays, IPC objects, interface tokens, and custom sequenceable objects.
### create ### create
...@@ -4032,7 +4036,7 @@ Writes a sequenceable object to this **MessageParcel** object. ...@@ -4032,7 +4036,7 @@ Writes a sequenceable object to this **MessageParcel** object.
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------- | --------------------------------- | | ------- | -------------------------------- |
| boolean | Returns **true** if the data is written successfully; returns **false** otherwise.| | boolean | Returns **true** if the data is written successfully; returns **false** otherwise.|
**Example** **Example**
...@@ -4072,14 +4076,14 @@ Reads member variables from this **MessageParcel** object. ...@@ -4072,14 +4076,14 @@ Reads member variables from this **MessageParcel** object.
**Parameters** **Parameters**
| Name| Type | Mandatory| Description | | Name| Type | Mandatory | Description |
| ------ | ----------------------------- | ---- | --------------------------------------- | | ------ | ----------------------------- | ------- | ---------------------------------------------- |
| dataIn | [Sequenceable](#sequenceabledeprecated) | Yes | Object that reads member variables from the **MessageParcel** object.| | dataIn | [Sequenceable](#sequenceabledeprecated) | Yes | Object that reads member variables from the **MessageParcel** object.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------- | ------------------------------------------- | | ------- | ---------------------------------------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.| | boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
**Example** **Example**
...@@ -4129,7 +4133,7 @@ Writes a byte array to this **MessageParcel** object. ...@@ -4129,7 +4133,7 @@ Writes a byte array to this **MessageParcel** object.
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------- | --------------------------------- | | ------- | -------------------------------- |
| boolean | Returns **true** if the data is written successfully; returns **false** otherwise.| | boolean | Returns **true** if the data is written successfully; returns **false** otherwise.|
**Example** **Example**
...@@ -4208,7 +4212,7 @@ Writes a short array to this **MessageParcel** object. ...@@ -4208,7 +4212,7 @@ Writes a short array to this **MessageParcel** object.
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------- | ----------------------------- | | ------- | -------------------------------- |
| boolean | Returns **true** if the data is written successfully; returns **false** otherwise.| | boolean | Returns **true** if the data is written successfully; returns **false** otherwise.|
**Example** **Example**
...@@ -4284,7 +4288,7 @@ Writes an integer array to this **MessageParcel** object. ...@@ -4284,7 +4288,7 @@ Writes an integer array to this **MessageParcel** object.
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------- | ----------------------------- | | ------- | -------------------------------- |
| boolean | Returns **true** if the data is written successfully; returns **false** otherwise.| | boolean | Returns **true** if the data is written successfully; returns **false** otherwise.|
**Example** **Example**
...@@ -4429,14 +4433,14 @@ Writes a FloatArray to this **MessageParcel** object. ...@@ -4429,14 +4433,14 @@ Writes a FloatArray to this **MessageParcel** object.
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description |
| ---------- | -------- | ---- | --- | | ---------- | -------- | ---- | --- |
| floatArray | number[] | Yes | Floating-point array to write. The system processes Float data as that of the Double type. Therefore, the total number of bytes occupied by a FloatArray must be calculated as the Double type.| | floatArray | number[] | Yes | Floating-point array to write. The system processes Float data as that of the Double type. Therefore, the total number of bytes occupied by a FloatArray must be calculated as the Double type.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------- | ----------------------------- | | ------- | -------------------------------- |
| boolean | Returns **true** if the data is written successfully; returns **false** otherwise.| | boolean | Returns **true** if the data is written successfully; returns **false** otherwise.|
**Example** **Example**
...@@ -4457,7 +4461,7 @@ Reads a FloatArray from this **MessageParcel** object. ...@@ -4457,7 +4461,7 @@ Reads a FloatArray from this **MessageParcel** object.
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type | Mandatory| Description |
| ------ | -------- | ---- | ------ | | ------ | -------- | ---- | ------ |
| dataIn | number[] | Yes | Floating-point array to read. The system processes Float data as that of the Double type. Therefore, the total number of bytes occupied by a FloatArray must be calculated as the Double type.| | dataIn | number[] | Yes | Floating-point array to read. The system processes Float data as that of the Double type. Therefore, the total number of bytes occupied by a FloatArray must be calculated as the Double type.|
...@@ -4512,7 +4516,7 @@ Writes a DoubleArray to this **MessageParcel** object. ...@@ -4512,7 +4516,7 @@ Writes a DoubleArray to this **MessageParcel** object.
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------- | ----------------------------- | | ------- | -------------------------------- |
| boolean | Returns **true** if the data is written successfully; returns **false** otherwise.| | boolean | Returns **true** if the data is written successfully; returns **false** otherwise.|
**Example** **Example**
...@@ -4588,7 +4592,7 @@ Writes a Boolean array to this **MessageParcel** object. ...@@ -4588,7 +4592,7 @@ Writes a Boolean array to this **MessageParcel** object.
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------- | --------------------------------- | | ------- | -------------------------------- |
| boolean | Returns **true** if the data is written successfully; returns **false** otherwise.| | boolean | Returns **true** if the data is written successfully; returns **false** otherwise.|
**Example** **Example**
...@@ -4664,7 +4668,7 @@ Writes a character array to this **MessageParcel** object. ...@@ -4664,7 +4668,7 @@ Writes a character array to this **MessageParcel** object.
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------- | --------------------------------- | | ------- | -------------------------------- |
| boolean | Returns **true** if the data is written successfully; returns **false** otherwise.| | boolean | Returns **true** if the data is written successfully; returns **false** otherwise.|
**Example** **Example**
...@@ -4733,14 +4737,14 @@ Writes a string array to this **MessageParcel** object. ...@@ -4733,14 +4737,14 @@ Writes a string array to this **MessageParcel** object.
**Parameters** **Parameters**
| Name | Type | Mandatory| Description| | Name | Type | Mandatory| Description |
| ----------- | -------- | ---- | ---------------- | | ----------- | -------- | ---- | ---------------- |
| stringArray | string[] | Yes | String array to write. The length of a single element in the array must be less than 40960 bytes.| | stringArray | string[] | Yes | String array to write. The length of a single element in the array must be less than 40960 bytes.|
**Return value** **Return value**
| Type | Description| | Type | Description|
| ------- | --------------------------------- | | ------- | -------------------------------- |
| boolean | Returns **true** if the data is written successfully; returns **false** otherwise.| | boolean | Returns **true** if the data is written successfully; returns **false** otherwise.|
**Example** **Example**
...@@ -4851,10 +4855,12 @@ Reads the exception information from this **MessageParcel** object. ...@@ -4851,10 +4855,12 @@ Reads the exception information from this **MessageParcel** object.
**Example** **Example**
Obtain the service. Before obtaining the ability for the application developed based on the stage model, obtain the context. For details, see [Obtaining the Context](#obtaining-the-context).
```ts ```ts
import FA from "@ohos.ability.featureAbility"; // Import @ohos.ability.featureAbility only for the application developed based on the FA model.
// import FA from "@ohos.ability.featureAbility";
let proxy; let proxy;
let connect = { let connect = {
onConnect: function(elementName, remoteProxy) { onConnect: function(elementName, remoteProxy) {
...@@ -4872,7 +4878,11 @@ Reads the exception information from this **MessageParcel** object. ...@@ -4872,7 +4878,11 @@ Reads the exception information from this **MessageParcel** object.
"bundleName": "com.ohos.server", "bundleName": "com.ohos.server",
"abilityName": "com.ohos.server.EntryAbility", "abilityName": "com.ohos.server.EntryAbility",
}; };
FA.connectAbility(want, connect);
// Use this method to connect to the ability for the FA model.
// FA.connectAbility(want,connect);
globalThis.context.connectServiceExtensionAbility(want, connect);
``` ```
The proxy object in the **onConnect** callback can be assigned a value only after the ability is connected asynchronously. Then, **sendMessageRequest()** of the proxy object is called to send a message. The proxy object in the **onConnect** callback can be assigned a value only after the ability is connected asynchronously. Then, **sendMessageRequest()** of the proxy object is called to send a message.
...@@ -4919,7 +4929,7 @@ Writes a sequenceable array to this **MessageParcel** object. ...@@ -4919,7 +4929,7 @@ Writes a sequenceable array to this **MessageParcel** object.
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------- | --------------------------------- | | ------- | -------------------------------- |
| boolean | Returns **true** if the data is written successfully; returns **false** otherwise.| | boolean | Returns **true** if the data is written successfully; returns **false** otherwise.|
**Example** **Example**
...@@ -5008,14 +5018,14 @@ Writes an array of **IRemoteObject** objects to this **MessageParcel** object. ...@@ -5008,14 +5018,14 @@ Writes an array of **IRemoteObject** objects to this **MessageParcel** object.
**Parameters** **Parameters**
| Name | Type | Mandatory| Description| | Name | Type | Mandatory| Description |
| ----------- | --------------- | ---- | ----- | | ----------- | --------------- | ---- | ----- |
| objectArray | IRemoteObject[] | Yes | Array of **IRemoteObject** objects to write.| | objectArray | IRemoteObject[] | Yes | Array of **IRemoteObject** objects to write.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------- | -------------------------------------------------------------------------------------------------------------------- | | ------- | -------------------------------- |
| boolean | Returns **true** if the data is written successfully; returns **false** otherwise.| | boolean | Returns **true** if the data is written successfully; returns **false** otherwise.|
**Example** **Example**
...@@ -5060,7 +5070,7 @@ Reads an **IRemoteObject** array from this **MessageParcel** object. ...@@ -5060,7 +5070,7 @@ Reads an **IRemoteObject** array from this **MessageParcel** object.
**Parameters** **Parameters**
| Name | Type | Mandatory| Description| | Name | Type | Mandatory| Description |
| ------- | --------------- | ---- | --------- | | ------- | --------------- | ---- | --------- |
| objects | IRemoteObject[] | Yes | **IRemoteObject** array to read.| | objects | IRemoteObject[] | Yes | **IRemoteObject** array to read.|
...@@ -5107,8 +5117,8 @@ Reads the **IRemoteObject** array from this **MessageParcel** object. ...@@ -5107,8 +5117,8 @@ Reads the **IRemoteObject** array from this **MessageParcel** object.
**Return value** **Return value**
| Type| Description| | Type | Description |
| --------------- | -------- | | --------------- | --------------------------- |
| IRemoteObject[] | **IRemoteObject** object array obtained.| | IRemoteObject[] | **IRemoteObject** object array obtained.|
**Example** **Example**
...@@ -5162,10 +5172,10 @@ Closes a file descriptor. This API is a static method. ...@@ -5162,10 +5172,10 @@ Closes a file descriptor. This API is a static method.
**Example** **Example**
```ts ```ts
import fileio from '@ohos.fileio'; import fs from '@ohos.file.fs';
let filePath = "path/to/file"; let filePath = "path/to/file";
let fd = fileio.openSync(filePath, 0o2| 0o100, 0o666); let file = fs.openSync(filePath, fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE);
rpc.MessageParcel.closeFileDescriptor(fd); rpc.MessageParcel.closeFileDescriptor(file.fd);
``` ```
### dupFileDescriptor<sup>8+</sup> ### dupFileDescriptor<sup>8+</sup>
...@@ -5191,10 +5201,10 @@ Duplicates a file descriptor. This API is a static method. ...@@ -5191,10 +5201,10 @@ Duplicates a file descriptor. This API is a static method.
**Example** **Example**
```ts ```ts
import fileio from '@ohos.fileio'; import fs from '@ohos.file.fs';
let filePath = "path/to/file"; let filePath = "path/to/file";
let fd = fileio.openSync(filePath, 0o2| 0o100, 0o666); let file = fs.openSync(filePath, fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE);
let newFd = rpc.MessageParcel.dupFileDescriptor(fd); let newFd = rpc.MessageParcel.dupFileDescriptor(file.fd);
``` ```
### containFileDescriptors<sup>8+</sup> ### containFileDescriptors<sup>8+</sup>
...@@ -5208,18 +5218,18 @@ Checks whether this **MessageParcel** object contains file descriptors. ...@@ -5208,18 +5218,18 @@ Checks whether this **MessageParcel** object contains file descriptors.
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------- | ------------------------------------------------------------------ | | ------- | --------------------------------------------- |
| boolean |Returns **true** if the **MessageParcel** object contains file descriptors; returns **false** otherwise.| | boolean |Returns **true** if the **MessageParcel** object contains file descriptors; returns **false** otherwise.|
**Example** **Example**
```ts ```ts
import fileio from '@ohos.fileio'; import fs from '@ohos.file.fs';
let parcel = new rpc.MessageParcel(); let parcel = new rpc.MessageParcel();
let filePath = "path/to/file"; let filePath = "path/to/file";
let r1 = parcel.containFileDescriptors(); let r1 = parcel.containFileDescriptors();
let fd = fileio.openSync(filePath, 0o2| 0o100, 0o666); let file = fs.openSync(filePath, fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE);
let writeResult = parcel.writeFileDescriptor(fd); let writeResult = parcel.writeFileDescriptor(file.fd);
console.log("RpcTest: parcel writeFd result is : " + writeResult); console.log("RpcTest: parcel writeFd result is : " + writeResult);
let containFD = parcel.containFileDescriptors(); let containFD = parcel.containFileDescriptors();
console.log("RpcTest: parcel after write fd containFd result is : " + containFD); console.log("RpcTest: parcel after write fd containFd result is : " + containFD);
...@@ -5242,17 +5252,17 @@ Writes a file descriptor to this **MessageParcel** object. ...@@ -5242,17 +5252,17 @@ Writes a file descriptor to this **MessageParcel** object.
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------- | ----------------------------------------- | | ------- | -------------------------------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.| | boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
**Example** **Example**
```ts ```ts
import fileio from '@ohos.fileio'; import fs from '@ohos.file.fs';
let parcel = new rpc.MessageParcel(); let parcel = new rpc.MessageParcel();
let filePath = "path/to/file"; let filePath = "path/to/file";
let fd = fileio.openSync(filePath, 0o2| 0o100, 0o666); let file = fs.openSync(filePath, fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE);
let writeResult = parcel.writeFileDescriptor(fd); let writeResult = parcel.writeFileDescriptor(file.fd);
console.log("RpcTest: parcel writeFd result is : " + writeResult); console.log("RpcTest: parcel writeFd result is : " + writeResult);
``` ```
...@@ -5273,11 +5283,11 @@ Reads the file descriptor from this **MessageParcel** object. ...@@ -5273,11 +5283,11 @@ Reads the file descriptor from this **MessageParcel** object.
**Example** **Example**
```ts ```ts
import fileio from '@ohos.fileio'; import fs from '@ohos.file.fs';
let parcel = new rpc.MessageParcel(); let parcel = new rpc.MessageParcel();
let filePath = "path/to/file"; let filePath = "path/to/file";
let fd = fileio.openSync(filePath, 0o2| 0o100, 0o666); let file = fs.openSync(filePath, fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE);
let writeResult = parcel.writeFileDescriptor(fd); let writeResult = parcel.writeFileDescriptor(file.fd);
let readFD = parcel.readFileDescriptor(); let readFD = parcel.readFileDescriptor();
console.log("RpcTest: parcel read fd is : " + readFD); console.log("RpcTest: parcel read fd is : " + readFD);
``` ```
...@@ -5299,7 +5309,7 @@ Writes an anonymous shared object to this **MessageParcel** object. ...@@ -5299,7 +5309,7 @@ Writes an anonymous shared object to this **MessageParcel** object.
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------- | -------------------------------------------------------------------- | | ------- | -------------------------------- |
| boolean | Returns **true** if the data is written successfully; returns **false** otherwise.| | boolean | Returns **true** if the data is written successfully; returns **false** otherwise.|
**Example** **Example**
...@@ -5376,7 +5386,7 @@ Writes raw data to this **MessageParcel** object. ...@@ -5376,7 +5386,7 @@ Writes raw data to this **MessageParcel** object.
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------- | ----------------------------------------- | | ------- | -------------------------------- |
| boolean | Returns **true** if the data is written successfully; returns **false** otherwise.| | boolean | Returns **true** if the data is written successfully; returns **false** otherwise.|
**Example** **Example**
...@@ -5440,7 +5450,7 @@ Marshals this **Parcelable** object into a **MessageSequence** object. ...@@ -5440,7 +5450,7 @@ Marshals this **Parcelable** object into a **MessageSequence** object.
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------- | ----------------------------------------- | | ------- | -------------------------------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.| | boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
**Example** **Example**
...@@ -5489,7 +5499,7 @@ Unmarshals this **Parcelable** object from a **MessageSequence** object. ...@@ -5489,7 +5499,7 @@ Unmarshals this **Parcelable** object from a **MessageSequence** object.
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------- | --------------------------------------------- | | ------- | ---------------------------------------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.| | boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
**Example** **Example**
...@@ -5539,13 +5549,13 @@ Marshals the sequenceable object into a **MessageParcel** object. ...@@ -5539,13 +5549,13 @@ Marshals the sequenceable object into a **MessageParcel** object.
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ------- | ------------------------------- | ---- | ----------------------------------------- | | ------- | ----------------------------------------- | ---- | ----------------------------------------- |
| dataOut | [MessageParcel](#messageparceldeprecated) | Yes | **MessageParcel** object to which the sequenceable object is to be marshaled.| | dataOut | [MessageParcel](#messageparceldeprecated) | Yes | **MessageParcel** object to which the sequenceable object is to be marshaled.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------- | ----------------------------------------- | | ------- | -------------------------------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.| | boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
**Example** **Example**
...@@ -5588,13 +5598,13 @@ Unmarshals this sequenceable object from a **MessageParcel** object. ...@@ -5588,13 +5598,13 @@ Unmarshals this sequenceable object from a **MessageParcel** object.
**Parameters** **Parameters**
| Name| Type | Mandatory| Description | | Name| Type | Mandatory| Description |
| ------ | ------------------------------- | ---- | --------------------------------------------- | | ------ | ----------------------------------------- | ---- | --------------------------------------------- |
| dataIn | [MessageParcel](#messageparceldeprecated) | Yes | **MessageParcel** object in which the sequenceable object is to be unmarshaled.| | dataIn | [MessageParcel](#messageparceldeprecated) | Yes | **MessageParcel** object in which the sequenceable object is to be unmarshaled.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------- | --------------------------------------------- | | ------- | ---------------------------------------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.| | boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
**Example** **Example**
...@@ -5641,8 +5651,8 @@ Obtains a proxy or remote object. This API must be implemented by its derived cl ...@@ -5641,8 +5651,8 @@ Obtains a proxy or remote object. This API must be implemented by its derived cl
**Return value** **Return value**
| Type | Description| | Type | Description |
| ---- | ----- | | ----- | ----- |
| [IRemoteObject](#iremoteobject) | Returns the **RemoteObject** if it is the caller; returns the [IRemoteObject](#iremoteobject), the holder of this **RemoteProxy** object, if the caller is a [RemoteProxy](#remoteproxy) object.| | [IRemoteObject](#iremoteobject) | Returns the **RemoteObject** 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**
...@@ -5658,20 +5668,22 @@ Obtains a proxy or remote object. This API must be implemented by its derived cl ...@@ -5658,20 +5668,22 @@ Obtains a proxy or remote object. This API must be implemented by its derived cl
**Example** **Example**
Obtain the service. Before obtaining the ability for the application developed based on the stage model, obtain the context. For details, see [Obtaining the Context](#obtaining-the-context).
```ts ```ts
import FA from "@ohos.ability.featureAbility"; // Import @ohos.ability.featureAbility only for the application developed based on the FA model.
// import FA from "@ohos.ability.featureAbility";
let proxy; let proxy;
let connect = { let connect = {
onConnect: function (elementName, remoteProxy) { onConnect: function(elementName, remoteProxy) {
console.log("RpcClient: js onConnect called."); console.log("RpcClient: js onConnect called.");
proxy = remoteProxy; proxy = remoteProxy;
}, },
onDisconnect: function (elementName) { onDisconnect: function(elementName) {
console.log("RpcClient: onDisconnect"); console.log("RpcClient: onDisconnect");
}, },
onFailed: function () { onFailed: function() {
console.log("RpcClient: onFailed"); console.log("RpcClient: onFailed");
} }
}; };
...@@ -5679,7 +5691,11 @@ Obtains a proxy or remote object. This API must be implemented by its derived cl ...@@ -5679,7 +5691,11 @@ Obtains a proxy or remote object. This API must be implemented by its derived cl
"bundleName": "com.ohos.server", "bundleName": "com.ohos.server",
"abilityName": "com.ohos.server.EntryAbility", "abilityName": "com.ohos.server.EntryAbility",
}; };
FA.connectAbility(want, connect);
// Use this method to connect to the ability for the FA model.
// FA.connectAbility(want,connect);
globalThis.context.connectServiceExtensionAbility(want, connect);
``` ```
The proxy object in the **onConnect** callback can be assigned a value only after the ability is connected asynchronously. Then, **asObject()** of the proxy object is called to obtain the proxy or remote object. The proxy object in the **onConnect** callback can be assigned a value only after the ability is connected asynchronously. Then, **asObject()** of the proxy object is called to obtain the proxy or remote object.
...@@ -5695,7 +5711,6 @@ Obtains a proxy or remote object. This API must be implemented by its derived cl ...@@ -5695,7 +5711,6 @@ Obtains a proxy or remote object. This API must be implemented by its derived cl
} }
} }
let iRemoteObject = new TestProxy(proxy).asObject(); let iRemoteObject = new TestProxy(proxy).asObject();
``` ```
## DeathRecipient ## DeathRecipient
...@@ -5806,8 +5821,8 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch ...@@ -5806,8 +5821,8 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch
**Parameters** **Parameters**
| Name | Type| Mandatory| Description | | Name | Type | Mandatory| Description |
| ------- | ------------------------------- | ---- | ---- | | ------- | ----------------------------------------- | ---- | -------------------------------------------------------------------------------------- |
| 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.| | 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](#messageparceldeprecated) | Yes | **MessageParcel** object holding the data to send. | | data | [MessageParcel](#messageparceldeprecated) | Yes | **MessageParcel** object holding the data to send. |
| reply | [MessageParcel](#messageparceldeprecated) | Yes | **MessageParcel** object that receives the response. | | reply | [MessageParcel](#messageparceldeprecated) | Yes | **MessageParcel** object that receives the response. |
...@@ -5816,7 +5831,7 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch ...@@ -5816,7 +5831,7 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------- | --------------------------------------------- | | ------- | -------------------------------- |
| boolean | Returns **true** if the message is sent successfully; returns **false** otherwise.| | boolean | Returns **true** if the message is sent successfully; returns **false** otherwise.|
...@@ -5833,7 +5848,7 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch ...@@ -5833,7 +5848,7 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ------- | ------------------------------- | ---- | -------------------------------------------------------------------------------------- | | ------- | ---------------------------------------- | ---- | -------------------------------------------------------------------------------------- |
| 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.| | 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](#messageparceldeprecated) | Yes | **MessageParcel** object holding the data to send. | | data | [MessageParcel](#messageparceldeprecated) | Yes | **MessageParcel** object holding the data to send. |
| reply | [MessageParcel](#messageparceldeprecated) | Yes | **MessageParcel** object that receives the response. | | reply | [MessageParcel](#messageparceldeprecated) | Yes | **MessageParcel** object that receives the response. |
...@@ -5857,7 +5872,7 @@ Sends a **MessageSequence** message to the remote process in synchronous or asyn ...@@ -5857,7 +5872,7 @@ Sends a **MessageSequence** message to the remote process in synchronous or asyn
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ------- | ------------------------------- | ---- | -------------------------------------------------------------------------------------- | | ------- | ------------------------------------ | ---- | -------------------------------------------------------------------------------------- |
| 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.| | 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 | [MessageSequence](#messagesequence9) | Yes | **MessageSequence** object holding the data to send. | | data | [MessageSequence](#messagesequence9) | Yes | **MessageSequence** object holding the data to send. |
| reply | [MessageSequence](#messagesequence9) | Yes | **MessageSequence** object that receives the response. | | reply | [MessageSequence](#messagesequence9) | Yes | **MessageSequence** object that receives the response. |
...@@ -5881,7 +5896,7 @@ Sends a **MessageSequence** message to the remote process in synchronous or asyn ...@@ -5881,7 +5896,7 @@ Sends a **MessageSequence** message to the remote process in synchronous or asyn
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ---------------------------------- | ---- | -------------------------------------------------------------------------------------- | | -------- | ------------------------------------ | ---- | -------------------------------------------------------------------------------------- |
| 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.| | 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 | [MessageSequence](#messagesequence9) | Yes | **MessageSequence** object holding the data to send. | | data | [MessageSequence](#messagesequence9) | Yes | **MessageSequence** object holding the data to send. |
| reply | [MessageSequence](#messagesequence9) | Yes | **MessageSequence** object that receives the response. | | reply | [MessageSequence](#messagesequence9) | Yes | **MessageSequence** object that receives the response. |
...@@ -5901,7 +5916,7 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch ...@@ -5901,7 +5916,7 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | -------------------------------------- | ---- | -------------------------------------------------------------------------------------- | | -------- | ----------------------------------------- | ---- | -------------------------------------------------------------------------------------- |
| 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.| | 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](#messageparceldeprecated) | Yes | **MessageParcel** object holding the data to send. | | data | [MessageParcel](#messageparceldeprecated) | Yes | **MessageParcel** object holding the data to send. |
| reply | [MessageParcel](#messageparceldeprecated) | Yes | **MessageParcel** object that receives the response. | | reply | [MessageParcel](#messageparceldeprecated) | Yes | **MessageParcel** object that receives the response. |
...@@ -5928,7 +5943,7 @@ Registers a callback for receiving death notifications of the remote object. The ...@@ -5928,7 +5943,7 @@ Registers a callback for receiving death notifications of the remote object. The
For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md).
| ID| Error Message| | ID| Error Message|
| ------- | -------- | | -------- | -------- |
| 1900008 | proxy or remote object is invalid | | 1900008 | proxy or remote object is invalid |
### addDeathrecipient<sup>(deprecated)</sup> ### addDeathrecipient<sup>(deprecated)</sup>
...@@ -5951,7 +5966,7 @@ Adds a callback for receiving death notifications of the remote object. This met ...@@ -5951,7 +5966,7 @@ Adds a callback for receiving death notifications of the remote object. This met
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------- | --------------------------------------------- | | ------- | ---------------------------------------- |
| boolean | Returns **true** if the callback is added successfully; returns **false** otherwise.| | boolean | Returns **true** if the callback is added successfully; returns **false** otherwise.|
...@@ -5975,7 +5990,7 @@ Unregisters the callback used to receive death notifications of the remote objec ...@@ -5975,7 +5990,7 @@ Unregisters the callback used to receive death notifications of the remote objec
For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md).
| ID| Error Message| | ID| Error Message|
| ------- | -------- | | -------- | -------- |
| 1900008 | proxy or remote object is invalid | | 1900008 | proxy or remote object is invalid |
### removeDeathRecipient<sup>(deprecated)</sup> ### removeDeathRecipient<sup>(deprecated)</sup>
...@@ -5998,7 +6013,7 @@ Removes the callback used to receive death notifications of the remote object. ...@@ -5998,7 +6013,7 @@ Removes the callback used to receive death notifications of the remote object.
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------- | --------------------------------------------- | | ------- | -----------------------------------------|
| boolean | Returns **true** if the callback is removed; returns **false** otherwise.| | boolean | Returns **true** if the callback is removed; returns **false** otherwise.|
### getDescriptor<sup>9+</sup> ### getDescriptor<sup>9+</sup>
...@@ -6020,7 +6035,7 @@ Obtains the interface descriptor (which is a string) of this object. ...@@ -6020,7 +6035,7 @@ Obtains the interface descriptor (which is a string) of this object.
For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md).
| ID| Error Message| | ID| Error Message|
| ------- | -------- | | -------- | -------- |
| 1900008 | proxy or remote object is invalid | | 1900008 | proxy or remote object is invalid |
...@@ -6052,7 +6067,7 @@ Checks whether this object is dead. ...@@ -6052,7 +6067,7 @@ Checks whether this object is dead.
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------- | ------------------------------------------- | | ------- | ---------------------------------- |
| boolean | Returns **true** if the object is dead; returns **false** otherwise.| | boolean | Returns **true** if the object is dead; returns **false** otherwise.|
...@@ -6083,7 +6098,7 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch ...@@ -6083,7 +6098,7 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ------- | ------------------------------- | ---- | -------------------------------------------------------------------------------------- | | ------- | ----------------------------------------- | ---- | -------------------------------------------------------------------------------------- |
| 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.| | 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](#messageparceldeprecated) | Yes | **MessageParcel** object holding the data to send. | | data | [MessageParcel](#messageparceldeprecated) | Yes | **MessageParcel** object holding the data to send. |
| reply | [MessageParcel](#messageparceldeprecated) | Yes | **MessageParcel** object that receives the response. | | reply | [MessageParcel](#messageparceldeprecated) | Yes | **MessageParcel** object that receives the response. |
...@@ -6092,15 +6107,17 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch ...@@ -6092,15 +6107,17 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------- | --------------------------------------------- | | ------- | ---------------------------------|
| boolean | Returns **true** if the message is sent successfully; returns **false** otherwise.| | boolean | Returns **true** if the message is sent successfully; returns **false** otherwise.|
**Example** **Example**
Obtain the service. Before obtaining the ability for the application developed based on the stage model, obtain the context. For details, see [Obtaining the Context](#obtaining-the-context).
```ts ```ts
import FA from "@ohos.ability.featureAbility"; // Import @ohos.ability.featureAbility only for the application developed based on the FA model.
// import FA from "@ohos.ability.featureAbility";
let proxy; let proxy;
let connect = { let connect = {
onConnect: function(elementName, remoteProxy) { onConnect: function(elementName, remoteProxy) {
...@@ -6118,7 +6135,11 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch ...@@ -6118,7 +6135,11 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch
"bundleName": "com.ohos.server", "bundleName": "com.ohos.server",
"abilityName": "com.ohos.server.EntryAbility", "abilityName": "com.ohos.server.EntryAbility",
}; };
FA.connectAbility(want, connect);
// Use this method to connect to the ability for the FA model.
// FA.connectAbility(want,connect);
globalThis.context.connectServiceExtensionAbility(want, connect);
``` ```
The proxy object in the **onConnect** callback can be assigned a value only after the ability is connected asynchronously. Then, **sendMessageRequest()** of the proxy object is called to send a message. The proxy object in the **onConnect** callback can be assigned a value only after the ability is connected asynchronously. Then, **sendMessageRequest()** of the proxy object is called to send a message.
...@@ -6153,7 +6174,7 @@ Sends a **MessageSequence** message to the remote process in synchronous or asyn ...@@ -6153,7 +6174,7 @@ Sends a **MessageSequence** message to the remote process in synchronous or asyn
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ------- | ------------------------------- | ---- | -------------------------------------------------------------------------------------- | | ------- | ------------------------------------ | ---- | -------------------------------------------------------------------------------------- |
| 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.| | 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 | [MessageSequence](#messagesequence9) | Yes | **MessageSequence** object holding the data to send. | | data | [MessageSequence](#messagesequence9) | Yes | **MessageSequence** object holding the data to send. |
| reply | [MessageSequence](#messagesequence9) | Yes | **MessageSequence** object that receives the response. | | reply | [MessageSequence](#messagesequence9) | Yes | **MessageSequence** object that receives the response. |
...@@ -6167,10 +6188,12 @@ Sends a **MessageSequence** message to the remote process in synchronous or asyn ...@@ -6167,10 +6188,12 @@ Sends a **MessageSequence** message to the remote process in synchronous or asyn
**Example** **Example**
Obtain the service. Before obtaining the ability for the application developed based on the stage model, obtain the context. For details, see [Obtaining the Context](#obtaining-the-context).
```ts ```ts
import FA from "@ohos.ability.featureAbility"; // Import @ohos.ability.featureAbility only for the application developed based on the FA model.
// import FA from "@ohos.ability.featureAbility";
let proxy; let proxy;
let connect = { let connect = {
onConnect: function(elementName, remoteProxy) { onConnect: function(elementName, remoteProxy) {
...@@ -6188,7 +6211,11 @@ Sends a **MessageSequence** message to the remote process in synchronous or asyn ...@@ -6188,7 +6211,11 @@ Sends a **MessageSequence** message to the remote process in synchronous or asyn
"bundleName": "com.ohos.server", "bundleName": "com.ohos.server",
"abilityName": "com.ohos.server.EntryAbility", "abilityName": "com.ohos.server.EntryAbility",
}; };
FA.connectAbility(want, connect);
// Use this method to connect to the ability for the FA model.
// FA.connectAbility(want,connect);
globalThis.context.connectServiceExtensionAbility(want, connect);
``` ```
The proxy object in the **onConnect** callback can be assigned a value only after the ability is connected asynchronously. Then, **sendMessageRequest()** of the proxy object is called to send a message. The proxy object in the **onConnect** callback can be assigned a value only after the ability is connected asynchronously. Then, **sendMessageRequest()** of the proxy object is called to send a message.
...@@ -6231,7 +6258,7 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch ...@@ -6231,7 +6258,7 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ------- | ------------------------------- | ---- | -------------------------------------------------------------------------------------- | | ------- | ----------------------------------------- | ---- | -------------------------------------------------------------------------------------- |
| 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.| | 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](#messageparceldeprecated) | Yes | **MessageParcel** object holding the data to send. | | data | [MessageParcel](#messageparceldeprecated) | Yes | **MessageParcel** object holding the data to send. |
| reply | [MessageParcel](#messageparceldeprecated) | Yes | **MessageParcel** object that receives the response. | | reply | [MessageParcel](#messageparceldeprecated) | Yes | **MessageParcel** object that receives the response. |
...@@ -6245,10 +6272,12 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch ...@@ -6245,10 +6272,12 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch
**Example** **Example**
Obtain the service. Before obtaining the ability for the application developed based on the stage model, obtain the context. For details, see [Obtaining the Context](#obtaining-the-context).
```ts ```ts
import FA from "@ohos.ability.featureAbility"; // Import @ohos.ability.featureAbility only for the application developed based on the FA model.
// import FA from "@ohos.ability.featureAbility";
let proxy; let proxy;
let connect = { let connect = {
onConnect: function(elementName, remoteProxy) { onConnect: function(elementName, remoteProxy) {
...@@ -6266,7 +6295,11 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch ...@@ -6266,7 +6295,11 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch
"bundleName": "com.ohos.server", "bundleName": "com.ohos.server",
"abilityName": "com.ohos.server.EntryAbility", "abilityName": "com.ohos.server.EntryAbility",
}; };
FA.connectAbility(want, connect);
// Use this method to connect to the ability for the FA model.
// FA.connectAbility(want,connect);
globalThis.context.connectServiceExtensionAbility(want, connect);
``` ```
The proxy object in the **onConnect** callback can be assigned a value only after the ability is connected asynchronously. Then, **sendMessageRequest()** of the proxy object is called to send a message. The proxy object in the **onConnect** callback can be assigned a value only after the ability is connected asynchronously. Then, **sendMessageRequest()** of the proxy object is called to send a message.
...@@ -6307,7 +6340,7 @@ Sends a **MessageSequence** message to the remote process in synchronous or asyn ...@@ -6307,7 +6340,7 @@ Sends a **MessageSequence** message to the remote process in synchronous or asyn
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ---------------------------------- | ---- | -------------------------------------------------------------------------------------- | | -------- | ------------------------------------ | ---- | -------------------------------------------------------------------------------------- |
| 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.| | 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 | [MessageSequence](#messagesequence9) | Yes | **MessageSequence** object holding the data to send. | | data | [MessageSequence](#messagesequence9) | Yes | **MessageSequence** object holding the data to send. |
| reply | [MessageSequence](#messagesequence9) | Yes | **MessageSequence** object that receives the response. | | reply | [MessageSequence](#messagesequence9) | Yes | **MessageSequence** object that receives the response. |
...@@ -6316,10 +6349,12 @@ Sends a **MessageSequence** message to the remote process in synchronous or asyn ...@@ -6316,10 +6349,12 @@ Sends a **MessageSequence** message to the remote process in synchronous or asyn
**Example** **Example**
Obtain the service. Before obtaining the ability for the application developed based on the stage model, obtain the context. For details, see [Obtaining the Context](#obtaining-the-context).
```ts ```ts
import FA from "@ohos.ability.featureAbility"; // Import @ohos.ability.featureAbility only for the application developed based on the FA model.
// import FA from "@ohos.ability.featureAbility";
let proxy; let proxy;
let connect = { let connect = {
onConnect: function(elementName, remoteProxy) { onConnect: function(elementName, remoteProxy) {
...@@ -6350,7 +6385,11 @@ Sends a **MessageSequence** message to the remote process in synchronous or asyn ...@@ -6350,7 +6385,11 @@ Sends a **MessageSequence** message to the remote process in synchronous or asyn
result.data.reclaim(); result.data.reclaim();
result.reply.reclaim(); result.reply.reclaim();
} }
FA.connectAbility(want, connect);
// Use this method to connect to the ability for the FA model.
// FA.connectAbility(want,connect);
globalThis.context.connectServiceExtensionAbility(want, connect);
``` ```
The proxy object in the **onConnect** callback can be assigned a value only after the ability is connected asynchronously. Then, **sendMessageRequest()** of the proxy object is called to send a message. The proxy object in the **onConnect** callback can be assigned a value only after the ability is connected asynchronously. Then, **sendMessageRequest()** of the proxy object is called to send a message.
...@@ -6362,7 +6401,7 @@ Sends a **MessageSequence** message to the remote process in synchronous or asyn ...@@ -6362,7 +6401,7 @@ Sends a **MessageSequence** message to the remote process in synchronous or asyn
data.writeInt(1); data.writeInt(1);
data.writeString("hello"); data.writeString("hello");
try { try {
proxy.sendRequest(1, data, reply, option, sendRequestCallback); proxy.sendMessageRequest(1, data, reply, option, sendRequestCallback);
} catch(error) { } catch(error) {
console.info("rpc send sequence request fail, errorCode " + error.code); console.info("rpc send sequence request fail, errorCode " + error.code);
console.info("rpc send sequence request fail, errorMessage " + error.message); console.info("rpc send sequence request fail, errorMessage " + error.message);
...@@ -6382,7 +6421,7 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch ...@@ -6382,7 +6421,7 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | -------------------------------------- | ---- | -------------------------------------------------------------------------------------- | | -------- | ----------------------------------------- | ---- | -------------------------------------------------------------------------------------- |
| 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.| | 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](#messageparceldeprecated) | Yes | **MessageParcel** object holding the data to send. | | data | [MessageParcel](#messageparceldeprecated) | Yes | **MessageParcel** object holding the data to send. |
| reply | [MessageParcel](#messageparceldeprecated) | Yes | **MessageParcel** object that receives the response. | | reply | [MessageParcel](#messageparceldeprecated) | Yes | **MessageParcel** object that receives the response. |
...@@ -6391,10 +6430,12 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch ...@@ -6391,10 +6430,12 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch
**Example** **Example**
Obtain the service. Before obtaining the ability for the application developed based on the stage model, obtain the context. For details, see [Obtaining the Context](#obtaining-the-context).
```ts ```ts
import FA from "@ohos.ability.featureAbility"; // Import @ohos.ability.featureAbility only for the application developed based on the FA model.
// import FA from "@ohos.ability.featureAbility";
let proxy; let proxy;
let connect = { let connect = {
onConnect: function(elementName, remoteProxy) { onConnect: function(elementName, remoteProxy) {
...@@ -6425,7 +6466,11 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch ...@@ -6425,7 +6466,11 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch
result.data.reclaim(); result.data.reclaim();
result.reply.reclaim(); result.reply.reclaim();
} }
FA.connectAbility(want, connect);
// Use this method to connect to the ability for the FA model.
// FA.connectAbility(want,connect);
globalThis.context.connectServiceExtensionAbility(want, connect);
``` ```
The proxy object in the **onConnect** callback can be assigned a value only after the ability is connected asynchronously. Then, **sendMessageRequest()** of the proxy object is called to send a message. The proxy object in the **onConnect** callback can be assigned a value only after the ability is connected asynchronously. Then, **sendMessageRequest()** of the proxy object is called to send a message.
...@@ -6464,22 +6509,24 @@ Obtains the **LocalInterface** object of an interface token. ...@@ -6464,22 +6509,24 @@ Obtains the **LocalInterface** object of an interface token.
For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md).
| ID| Error Message| | ID| Error Message|
| ------- | -------- | | -------- | -------- |
| 1900006 | only remote object permitted | | 1900006 | only remote object permitted |
**Example** **Example**
Obtain the service. Before obtaining the ability for the application developed based on the stage model, obtain the context. For details, see [Obtaining the Context](#obtaining-the-context).
```ts ```ts
import FA from "@ohos.ability.featureAbility"; // Import @ohos.ability.featureAbility only for the application developed based on the FA model.
// import FA from "@ohos.ability.featureAbility";
let proxy; let proxy;
let connect = { let connect = {
onConnect: function(elementName, remoteProxy) { onConnect: function(elementName, remoteProxy) {
console.log("RpcClient: js onConnect called."); console.log("RpcClient: js onConnect called.");
proxy = remoteProxy; proxy = remoteProxy;
}, },
onDisconnect: function (elementName) { onDisconnect: function(elementName) {
console.log("RpcClient: onDisconnect"); console.log("RpcClient: onDisconnect");
}, },
onFailed: function() { onFailed: function() {
...@@ -6487,10 +6534,14 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode ...@@ -6487,10 +6534,14 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
} }
}; };
let want = { let want = {
"bundleName":"com.ohos.server", "bundleName": "com.ohos.server",
"abilityName":"com.ohos.server.EntryAbility", "abilityName": "com.ohos.server.EntryAbility",
}; };
FA.connectAbility(want, connect);
// Use this method to connect to the ability for the FA model.
// FA.connectAbility(want,connect);
globalThis.context.connectServiceExtensionAbility(want, connect);
``` ```
The proxy object in the **onConnect** callback can be assigned a value only after the ability is connected asynchronously. Then, **getLocalInterface()** of the proxy object is called to obtain the interface descriptor. The proxy object in the **onConnect** callback can be assigned a value only after the ability is connected asynchronously. Then, **getLocalInterface()** of the proxy object is called to obtain the interface descriptor.
...@@ -6529,17 +6580,19 @@ Obtains the **LocalInterface** object of an interface token. ...@@ -6529,17 +6580,19 @@ Obtains the **LocalInterface** object of an interface token.
**Example** **Example**
Obtain the service. Before obtaining the ability for the application developed based on the stage model, obtain the context. For details, see [Obtaining the Context](#obtaining-the-context).
```ts ```ts
import FA from "@ohos.ability.featureAbility"; // Import @ohos.ability.featureAbility only for the application developed based on the FA model.
// import FA from "@ohos.ability.featureAbility";
let proxy; let proxy;
let connect = { let connect = {
onConnect: function(elementName, remoteProxy) { onConnect: function(elementName, remoteProxy) {
console.log("RpcClient: js onConnect called."); console.log("RpcClient: js onConnect called.");
proxy = remoteProxy; proxy = remoteProxy;
}, },
onDisconnect: function (elementName) { onDisconnect: function(elementName) {
console.log("RpcClient: onDisconnect"); console.log("RpcClient: onDisconnect");
}, },
onFailed: function() { onFailed: function() {
...@@ -6547,10 +6600,14 @@ Obtains the **LocalInterface** object of an interface token. ...@@ -6547,10 +6600,14 @@ Obtains the **LocalInterface** object of an interface token.
} }
}; };
let want = { let want = {
"bundleName":"com.ohos.server", "bundleName": "com.ohos.server",
"abilityName":"com.ohos.server.EntryAbility", "abilityName": "com.ohos.server.EntryAbility",
}; };
FA.connectAbility(want, connect);
// Use this method to connect to the ability for the FA model.
// FA.connectAbility(want,connect);
globalThis.context.connectServiceExtensionAbility(want, connect);
``` ```
The proxy object in the **onConnect** callback can be assigned a value only after the ability is connected asynchronously. Then, **queryLocalInterface()** of the proxy object is called to obtain the interface descriptor. The proxy object in the **onConnect** callback can be assigned a value only after the ability is connected asynchronously. Then, **queryLocalInterface()** of the proxy object is called to obtain the interface descriptor.
...@@ -6580,15 +6637,17 @@ Registers a callback for receiving death notifications of the remote object. The ...@@ -6580,15 +6637,17 @@ Registers a callback for receiving death notifications of the remote object. The
For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md).
| ID| Error Message| | ID| Error Message|
| ------- | -------- | | -------- | -------- |
| 1900008 | proxy or remote object is invalid | | 1900008 | proxy or remote object is invalid |
**Example** **Example**
Obtain the service. Before obtaining the ability for the application developed based on the stage model, obtain the context. For details, see [Obtaining the Context](#obtaining-the-context).
```ts ```ts
import FA from "@ohos.ability.featureAbility"; // Import @ohos.ability.featureAbility only for the application developed based on the FA model.
// import FA from "@ohos.ability.featureAbility";
let proxy; let proxy;
let connect = { let connect = {
onConnect: function(elementName, remoteProxy) { onConnect: function(elementName, remoteProxy) {
...@@ -6606,7 +6665,11 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode ...@@ -6606,7 +6665,11 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
"bundleName": "com.ohos.server", "bundleName": "com.ohos.server",
"abilityName": "com.ohos.server.EntryAbility", "abilityName": "com.ohos.server.EntryAbility",
}; };
FA.connectAbility(want, connect);
// Use this method to connect to the ability for the FA model.
// FA.connectAbility(want,connect);
globalThis.context.connectServiceExtensionAbility(want, connect);
``` ```
The proxy object in the **onConnect** callback can be assigned a value only after the ability is connected asynchronously. Then, **registerDeathRecipient()** of the proxy object is called to register a callback for receiving the death notification of the remote object. The proxy object in the **onConnect** callback can be assigned a value only after the ability is connected asynchronously. Then, **registerDeathRecipient()** of the proxy object is called to register a callback for receiving the death notification of the remote object.
...@@ -6646,15 +6709,17 @@ Adds a callback for receiving the death notifications of the remote object, incl ...@@ -6646,15 +6709,17 @@ Adds a callback for receiving the death notifications of the remote object, incl
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------- | --------------------------------------------- | | ------- | ---------------------------------------- |
| boolean | Returns **true** if the callback is added successfully; returns **false** otherwise.| | boolean | Returns **true** if the callback is added successfully; returns **false** otherwise.|
**Example** **Example**
Obtain the service. Before obtaining the ability for the application developed based on the stage model, obtain the context. For details, see [Obtaining the Context](#obtaining-the-context).
```ts ```ts
import FA from "@ohos.ability.featureAbility"; // Import @ohos.ability.featureAbility only for the application developed based on the FA model.
// import FA from "@ohos.ability.featureAbility";
let proxy; let proxy;
let connect = { let connect = {
onConnect: function(elementName, remoteProxy) { onConnect: function(elementName, remoteProxy) {
...@@ -6672,7 +6737,11 @@ Adds a callback for receiving the death notifications of the remote object, incl ...@@ -6672,7 +6737,11 @@ Adds a callback for receiving the death notifications of the remote object, incl
"bundleName": "com.ohos.server", "bundleName": "com.ohos.server",
"abilityName": "com.ohos.server.EntryAbility", "abilityName": "com.ohos.server.EntryAbility",
}; };
FA.connectAbility(want, connect);
// Use this method to connect to the ability for the FA model.
// FA.connectAbility(want,connect);
globalThis.context.connectServiceExtensionAbility(want, connect);
``` ```
The proxy object in the **onConnect** callback can be assigned a value only after the ability is connected asynchronously. Then, **addDeathRecippient()** of the proxy object is called to add a callback for receiving the death notification of the remove object. The proxy object in the **onConnect** callback can be assigned a value only after the ability is connected asynchronously. Then, **addDeathRecippient()** of the proxy object is called to add a callback for receiving the death notification of the remove object.
...@@ -6707,15 +6776,17 @@ Unregisters the callback used to receive death notifications of the remote objec ...@@ -6707,15 +6776,17 @@ Unregisters the callback used to receive death notifications of the remote objec
For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md).
| ID| Error Message| | ID| Error Message|
| ------- | -------- | | -------- | -------- |
| 1900008 | proxy or remote object is invalid | | 1900008 | proxy or remote object is invalid |
**Example** **Example**
Obtain the service. Before obtaining the ability for the application developed based on the stage model, obtain the context. For details, see [Obtaining the Context](#obtaining-the-context).
```ts ```ts
import FA from "@ohos.ability.featureAbility"; // Import @ohos.ability.featureAbility only for the application developed based on the FA model.
// import FA from "@ohos.ability.featureAbility";
let proxy; let proxy;
let connect = { let connect = {
onConnect: function(elementName, remoteProxy) { onConnect: function(elementName, remoteProxy) {
...@@ -6733,7 +6804,11 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode ...@@ -6733,7 +6804,11 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
"bundleName": "com.ohos.server", "bundleName": "com.ohos.server",
"abilityName": "com.ohos.server.EntryAbility", "abilityName": "com.ohos.server.EntryAbility",
}; };
FA.connectAbility(want, connect);
// Use this method to connect to the ability for the FA model.
// FA.connectAbility(want,connect);
globalThis.context.connectServiceExtensionAbility(want, connect);
``` ```
The proxy object in the **onConnect** callback can be assigned a value only after the ability is connected asynchronously. Then, **unregisterDeathRecipient()** of the proxy object is called to unregister the callback for receiving the death notification of the remote object. The proxy object in the **onConnect** callback can be assigned a value only after the ability is connected asynchronously. Then, **unregisterDeathRecipient()** of the proxy object is called to unregister the callback for receiving the death notification of the remote object.
...@@ -6774,15 +6849,17 @@ Removes the callback used to receive death notifications of the remote object. ...@@ -6774,15 +6849,17 @@ Removes the callback used to receive death notifications of the remote object.
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------- | --------------------------------------------- | | ------- | ---------------------------------------- |
| boolean | Returns **true** if the callback is removed; returns **false** otherwise.| | boolean | Returns **true** if the callback is removed; returns **false** otherwise.|
**Example** **Example**
Obtain the service. Before obtaining the ability for the application developed based on the stage model, obtain the context. For details, see [Obtaining the Context](#obtaining-the-context).
```ts ```ts
import FA from "@ohos.ability.featureAbility"; // Import @ohos.ability.featureAbility only for the application developed based on the FA model.
// import FA from "@ohos.ability.featureAbility";
let proxy; let proxy;
let connect = { let connect = {
onConnect: function(elementName, remoteProxy) { onConnect: function(elementName, remoteProxy) {
...@@ -6800,7 +6877,11 @@ Removes the callback used to receive death notifications of the remote object. ...@@ -6800,7 +6877,11 @@ Removes the callback used to receive death notifications of the remote object.
"bundleName": "com.ohos.server", "bundleName": "com.ohos.server",
"abilityName": "com.ohos.server.EntryAbility", "abilityName": "com.ohos.server.EntryAbility",
}; };
FA.connectAbility(want, connect);
// Use this method to connect to the ability for the FA model.
// FA.connectAbility(want,connect);
globalThis.context.connectServiceExtensionAbility(want, connect);
``` ```
The proxy object in the **onConnect** callback can be assigned a value only after the ability is connected asynchronously. Then, **removeDeathRecipient()** of the proxy object is called to remove the callback used to receive the death notification of the remote object. The proxy object in the **onConnect** callback can be assigned a value only after the ability is connected asynchronously. Then, **removeDeathRecipient()** of the proxy object is called to remove the callback used to receive the death notification of the remote object.
...@@ -6835,16 +6916,18 @@ Obtains the interface descriptor (which is a string) of this proxy object. ...@@ -6835,16 +6916,18 @@ Obtains the interface descriptor (which is a string) of this proxy object.
For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md).
| ID| Error Message| | ID| Error Message|
| -------- | ------- | | -------- | -------- |
| 1900008 | proxy or remote object is invalid | | 1900008 | proxy or remote object is invalid |
| 1900007 | communication failed | | 1900007 | communication failed |
**Example** **Example**
Obtain the service. Before obtaining the ability for the application developed based on the stage model, obtain the context. For details, see [Obtaining the Context](#obtaining-the-context).
```ts ```ts
import FA from "@ohos.ability.featureAbility"; // Import @ohos.ability.featureAbility only for the application developed based on the FA model.
// import FA from "@ohos.ability.featureAbility";
let proxy; let proxy;
let connect = { let connect = {
onConnect: function(elementName, remoteProxy) { onConnect: function(elementName, remoteProxy) {
...@@ -6862,7 +6945,11 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode ...@@ -6862,7 +6945,11 @@ For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode
"bundleName": "com.ohos.server", "bundleName": "com.ohos.server",
"abilityName": "com.ohos.server.EntryAbility", "abilityName": "com.ohos.server.EntryAbility",
}; };
FA.connectAbility(want, connect);
// Use this method to connect to the ability for the FA model.
// FA.connectAbility(want,connect);
globalThis.context.connectServiceExtensionAbility(want, connect);
``` ```
The proxy object in the **onConnect** callback can be assigned a value only after the ability is connected asynchronously. Then, **getDescriptor()** of the proxy object is called to obtain the interface descriptor of the object. The proxy object in the **onConnect** callback can be assigned a value only after the ability is connected asynchronously. Then, **getDescriptor()** of the proxy object is called to obtain the interface descriptor of the object.
...@@ -6894,10 +6981,12 @@ Obtains the interface descriptor of this proxy object. ...@@ -6894,10 +6981,12 @@ Obtains the interface descriptor of this proxy object.
**Example** **Example**
Obtain the service. Before obtaining the ability for the application developed based on the stage model, obtain the context. For details, see [Obtaining the Context](#obtaining-the-context).
```ts ```ts
import FA from "@ohos.ability.featureAbility"; // Import @ohos.ability.featureAbility only for the application developed based on the FA model.
// import FA from "@ohos.ability.featureAbility";
let proxy; let proxy;
let connect = { let connect = {
onConnect: function(elementName, remoteProxy) { onConnect: function(elementName, remoteProxy) {
...@@ -6915,7 +7004,11 @@ Obtains the interface descriptor of this proxy object. ...@@ -6915,7 +7004,11 @@ Obtains the interface descriptor of this proxy object.
"bundleName": "com.ohos.server", "bundleName": "com.ohos.server",
"abilityName": "com.ohos.server.EntryAbility", "abilityName": "com.ohos.server.EntryAbility",
}; };
FA.connectAbility(want, connect);
// Use this method to connect to the ability for the FA model.
// FA.connectAbility(want,connect);
globalThis.context.connectServiceExtensionAbility(want, connect);
``` ```
The proxy object in the **onConnect** callback can be assigned a value only after the ability is connected asynchronously. Then, **getInterfaceDescriptor()** of the proxy object is called to obtain the interface descriptor of the current proxy object. The proxy object in the **onConnect** callback can be assigned a value only after the ability is connected asynchronously. Then, **getInterfaceDescriptor()** of the proxy object is called to obtain the interface descriptor of the current proxy object.
...@@ -6936,15 +7029,17 @@ Checks whether the **RemoteObject** is dead. ...@@ -6936,15 +7029,17 @@ Checks whether the **RemoteObject** is dead.
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------- | --------------------------------------------------------- | | ------- | ------------------------------------------------- |
| boolean | Returns **true** if the **RemoteObject** is dead; returns **false** otherwise.| | boolean | Returns **true** if the **RemoteObject** is dead; returns **false** otherwise.|
**Example** **Example**
Obtain the service. Before obtaining the ability for the application developed based on the stage model, obtain the context. For details, see [Obtaining the Context](#obtaining-the-context).
```ts ```ts
import FA from "@ohos.ability.featureAbility"; // Import @ohos.ability.featureAbility only for the application developed based on the FA model.
// import FA from "@ohos.ability.featureAbility";
let proxy; let proxy;
let connect = { let connect = {
onConnect: function(elementName, remoteProxy) { onConnect: function(elementName, remoteProxy) {
...@@ -6962,7 +7057,11 @@ Checks whether the **RemoteObject** is dead. ...@@ -6962,7 +7057,11 @@ Checks whether the **RemoteObject** is dead.
"bundleName": "com.ohos.server", "bundleName": "com.ohos.server",
"abilityName": "com.ohos.server.EntryAbility", "abilityName": "com.ohos.server.EntryAbility",
}; };
FA.connectAbility(want, connect);
// Use this method to connect to the ability for the FA model.
// FA.connectAbility(want,connect);
globalThis.context.connectServiceExtensionAbility(want, connect);
``` ```
The proxy object in the **onConnect** callback can be assigned a value only after the ability is connected asynchronously. Then, **isObjectDead()** of the proxy object is called to check whether this object is dead. The proxy object in the **onConnect** callback can be assigned a value only after the ability is connected asynchronously. Then, **isObjectDead()** of the proxy object is called to check whether this object is dead.
...@@ -7046,7 +7145,7 @@ Checks whether **SendMessageRequest** is called synchronously or asynchronously. ...@@ -7046,7 +7145,7 @@ Checks whether **SendMessageRequest** is called synchronously or asynchronously.
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------- | ------------------------------------ | | ------- | ---------------------------------------- |
| boolean | Returns **true** if **SendMessageRequest** is called synchronously; returns **false** if **SendMessageRequest** is called asynchronously.| | boolean | Returns **true** if **SendMessageRequest** is called synchronously; returns **false** if **SendMessageRequest** is called asynchronously.|
**Example** **Example**
...@@ -7354,7 +7453,7 @@ Checks whether the remote process is a process of the local device. This API is ...@@ -7354,7 +7453,7 @@ Checks whether the remote process is a process of the local device. This API is
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------- | --------------------------------------------------------- | | ------- | -------------------------------------------------- |
| boolean | Returns **true** if the local and remote processes are on the same device; returns **false** otherwise.| | boolean | Returns **true** if the local and remote processes are on the same device; returns **false** otherwise.|
**Example** **Example**
...@@ -7527,7 +7626,7 @@ Sets the UID and PID of the remote user. This API is a static method. It is usua ...@@ -7527,7 +7626,7 @@ Sets the UID and PID of the remote user. This API is a static method. It is usua
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------- | ----------------------------------------- | | ------- | ---------------------------------|
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.| | boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
**Example** **Example**
...@@ -7580,7 +7679,7 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch ...@@ -7580,7 +7679,7 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ------- | ------------------------------- | ---- | -------------------------------------------------------------------------------------- | | ------- | ----------------------------------------- | ---- | -------------------------------------------------------------------------------------- |
| 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.| | 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](#messageparceldeprecated) | Yes | **MessageParcel** object holding the data to send. | | data | [MessageParcel](#messageparceldeprecated) | Yes | **MessageParcel** object holding the data to send. |
| reply | [MessageParcel](#messageparceldeprecated) | Yes | **MessageParcel** object that receives the response. | | reply | [MessageParcel](#messageparceldeprecated) | Yes | **MessageParcel** object that receives the response. |
...@@ -7589,7 +7688,7 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch ...@@ -7589,7 +7688,7 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------- | --------------------------------------------- | | ------- | -------------------------------- |
| boolean | Returns **true** if the message is sent successfully; returns **false** otherwise.| | boolean | Returns **true** if the message is sent successfully; returns **false** otherwise.|
**Example** **Example**
...@@ -7646,7 +7745,7 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch ...@@ -7646,7 +7745,7 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ------- | ------------------------------- | ---- | -------------------------------------------------------------------------------------- | | ------- | ----------------------------------------- | ---- | -------------------------------------------------------------------------------------- |
| 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.| | 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](#messageparceldeprecated) | Yes | **MessageParcel** object holding the data to send. | | data | [MessageParcel](#messageparceldeprecated) | Yes | **MessageParcel** object holding the data to send. |
| reply | [MessageParcel](#messageparceldeprecated) | Yes | **MessageParcel** object that receives the response. | | reply | [MessageParcel](#messageparceldeprecated) | Yes | **MessageParcel** object that receives the response. |
...@@ -7716,7 +7815,7 @@ Sends a **MessageSequence** message to the remote process in synchronous or asyn ...@@ -7716,7 +7815,7 @@ Sends a **MessageSequence** message to the remote process in synchronous or asyn
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ------- | ------------------------------- | ---- | -------------------------------------------------------------------------------------- | | ------- | ------------------------------------ | ---- | -------------------------------------------------------------------------------------- |
| 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.| | 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 | [MessageSequence](#messagesequence9) | Yes | **MessageSequence** object holding the data to send. | | data | [MessageSequence](#messagesequence9) | Yes | **MessageSequence** object holding the data to send. |
| reply | [MessageSequence](#messagesequence9) | Yes | **MessageSequence** object that receives the response. | | reply | [MessageSequence](#messagesequence9) | Yes | **MessageSequence** object that receives the response. |
...@@ -7772,7 +7871,7 @@ Sends a **MessageSequence** message to the remote process in synchronous or asyn ...@@ -7772,7 +7871,7 @@ Sends a **MessageSequence** message to the remote process in synchronous or asyn
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ------------- | ---------------------------------- | ---- | -------------------------------------------------------------------------------------- | | ------------- | ------------------------------------ | ---- | -------------------------------------------------------------------------------------- |
| 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.| | 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 | [MessageSequence](#messagesequence9) | Yes | **MessageSequence** object holding the data to send. | | data | [MessageSequence](#messagesequence9) | Yes | **MessageSequence** object holding the data to send. |
| reply | [MessageSequence](#messagesequence9) | Yes | **MessageSequence** object that receives the response. | | reply | [MessageSequence](#messagesequence9) | Yes | **MessageSequence** object that receives the response. |
...@@ -7822,7 +7921,7 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch ...@@ -7822,7 +7921,7 @@ Sends a **MessageParcel** message to the remote process in synchronous or asynch
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ------------- | -------------------------------------- | ---- | -------------------------------------------------------------------------------------- | | ------------- | ----------------------------------------- | ---- | -------------------------------------------------------------------------------------- |
| 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.| | 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](#messageparceldeprecated) | Yes | **MessageParcel** object holding the data to send. | | data | [MessageParcel](#messageparceldeprecated) | Yes | **MessageParcel** object holding the data to send. |
| reply | [MessageParcel](#messageparceldeprecated) | Yes | **MessageParcel** object that receives the response. | | reply | [MessageParcel](#messageparceldeprecated) | Yes | **MessageParcel** object that receives the response. |
...@@ -7886,7 +7985,7 @@ Provides a response to **sendMessageRequest()**. The server processes the reques ...@@ -7886,7 +7985,7 @@ Provides a response to **sendMessageRequest()**. The server processes the reques
**Parameters** **Parameters**
| Name| Type | Mandatory| Description | | Name| Type | Mandatory| Description |
| ------ | ------------------------------- | ---- | --------------------------------------- | | ------ | ----------------------------------------- | ---- | --------------------------------------- |
| code | number | Yes | Service request code sent by the remote end. | | code | number | Yes | Service request code sent by the remote end. |
| data | [MessageParcel](#messageparceldeprecated) | Yes | **MessageParcel** object that holds the parameters called by the client.| | data | [MessageParcel](#messageparceldeprecated) | Yes | **MessageParcel** object that holds the parameters called by the client.|
| reply | [MessageParcel](#messageparceldeprecated) | Yes | **MessageParcel** object carrying the result. | | reply | [MessageParcel](#messageparceldeprecated) | Yes | **MessageParcel** object carrying the result. |
...@@ -7895,7 +7994,7 @@ Provides a response to **sendMessageRequest()**. The server processes the reques ...@@ -7895,7 +7994,7 @@ Provides a response to **sendMessageRequest()**. The server processes the reques
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------- | ----------------------------------------- | | ------- | -------------------------------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.| | boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
**Example** **Example**
...@@ -7947,7 +8046,7 @@ Provides a response to **sendMessageRequest()**. The server processes the reques ...@@ -7947,7 +8046,7 @@ Provides a response to **sendMessageRequest()**. The server processes the reques
**Parameters** **Parameters**
| Name| Type | Mandatory| Description | | Name| Type | Mandatory| Description |
| ------ | ------------------------------- | ---- | ----------------------------------------- | | ------ | ------------------------------------ | ---- | ----------------------------------------- |
| code | number | Yes | Service request code sent by the remote end. | | code | number | Yes | Service request code sent by the remote end. |
| data | [MessageSequence](#messagesequence9) | Yes | **MessageSequence** object that holds the parameters called by the client.| | data | [MessageSequence](#messagesequence9) | Yes | **MessageSequence** object that holds the parameters called by the client.|
| reply | [MessageSequence](#messagesequence9) | Yes | **MessageSequence** object to which the result is written. | | reply | [MessageSequence](#messagesequence9) | Yes | **MessageSequence** object to which the result is written. |
...@@ -7956,7 +8055,7 @@ Provides a response to **sendMessageRequest()**. The server processes the reques ...@@ -7956,7 +8055,7 @@ Provides a response to **sendMessageRequest()**. The server processes the reques
**Return value** **Return value**
| Type | Description | | Type | Description |
| ----------------- | ---------------------------------------------------------------------------------------------- | | ----------------- | ----------------------------------------------------------------------------------------------- |
| boolean | Returns a Boolean value if the request is processed synchronously in **onRemoteMessageRequest**. The value **true** means the operation is successful; the value **false** means the opposite.| | boolean | Returns a Boolean value if the request is processed synchronously in **onRemoteMessageRequest**. The value **true** means the operation is successful; the value **false** means the opposite.|
| Promise\<boolean> | Returns a promise object if the request is processed asynchronously in **onRemoteMessageRequest**. | | Promise\<boolean> | Returns a promise object if the request is processed asynchronously in **onRemoteMessageRequest**. |
...@@ -8237,7 +8336,7 @@ Obtains the interface descriptor of this object. The interface descriptor is a s ...@@ -8237,7 +8336,7 @@ Obtains the interface descriptor of this object. The interface descriptor is a s
For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md).
| ID| Error Message| | ID| Error Message|
| ------- | -------- | | -------- | -------- |
| 1900008 | proxy or remote object is invalid | | 1900008 | proxy or remote object is invalid |
**Example** **Example**
...@@ -8629,7 +8728,7 @@ Creates the shared file mapping on the virtual address space of this process. Th ...@@ -8629,7 +8728,7 @@ Creates the shared file mapping on the virtual address space of this process. Th
For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md).
| ID| Error Message| | ID| Error Message|
| ------- | ------ | | -------- | -------- |
| 1900001 | call mmap function failed | | 1900001 | call mmap function failed |
**Example** **Example**
...@@ -8663,7 +8762,7 @@ Creates the shared file mapping on the virtual address space of this process. Th ...@@ -8663,7 +8762,7 @@ Creates the shared file mapping on the virtual address space of this process. Th
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------- | ----------------------------------------- | | ------- | -------------------------------- |
| boolean | Returns **true** if the mapping is created; returns **false** otherwise.| | boolean | Returns **true** if the mapping is created; returns **false** otherwise.|
**Example** **Example**
...@@ -8687,7 +8786,7 @@ Maps the shared file to the readable and writable virtual address space of the p ...@@ -8687,7 +8786,7 @@ Maps the shared file to the readable and writable virtual address space of the p
For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md).
| ID| Error Message| | ID| Error Message|
| ------- | -------- | | -------- | -------- |
| 1900001 | call mmap function failed | | 1900001 | call mmap function failed |
**Example** **Example**
...@@ -8715,7 +8814,7 @@ Maps the shared file to the readable and writable virtual address space of the p ...@@ -8715,7 +8814,7 @@ Maps the shared file to the readable and writable virtual address space of the p
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------- | ----------------------------------------- | | ------- | -------------------------------- |
| boolean | Returns **true** if the mapping is created; returns **false** otherwise.| | boolean | Returns **true** if the mapping is created; returns **false** otherwise.|
**Example** **Example**
...@@ -8739,7 +8838,7 @@ Maps the shared file to the read-only virtual address space of the process. ...@@ -8739,7 +8838,7 @@ Maps the shared file to the read-only virtual address space of the process.
For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md).
| ID| Error Message| | ID| Error Message|
| ------- | -------- | | -------- | -------- |
| 1900001 | call mmap function failed | | 1900001 | call mmap function failed |
**Example** **Example**
...@@ -8767,7 +8866,7 @@ Maps the shared file to the read-only virtual address space of the process. ...@@ -8767,7 +8866,7 @@ Maps the shared file to the read-only virtual address space of the process.
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------- | ----------------------------------------- | | ------- | -------------------------------- |
| boolean | Returns **true** if the mapping is created; returns **false** otherwise.| | boolean | Returns **true** if the mapping is created; returns **false** otherwise.|
**Example** **Example**
...@@ -8797,7 +8896,7 @@ Sets the protection level of the memory region to which the shared file is mappe ...@@ -8797,7 +8896,7 @@ Sets the protection level of the memory region to which the shared file is mappe
For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md).
| ID| Error Message| | ID| Error Message|
| -------- | ------- | | -------- | -------- |
| 1900002 | call os ioctl function failed | | 1900002 | call os ioctl function failed |
**Example** **Example**
...@@ -8831,7 +8930,7 @@ Sets the protection level of the memory region to which the shared file is mappe ...@@ -8831,7 +8930,7 @@ Sets the protection level of the memory region to which the shared file is mappe
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------- | ----------------------------------------- | | ------- | -------------------------------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.| | boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
**Example** **Example**
...@@ -8863,7 +8962,7 @@ Writes data to the shared file associated with this **Ashmem** object. ...@@ -8863,7 +8962,7 @@ Writes data to the shared file associated with this **Ashmem** object.
For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md).
| ID| Error Message| | ID| Error Message|
| ------- | -------- | | -------- | -------- |
| 1900003 | write to ashmem failed | | 1900003 | write to ashmem failed |
**Example** **Example**
...@@ -8901,7 +9000,7 @@ Writes data to the shared file associated with this **Ashmem** object. ...@@ -8901,7 +9000,7 @@ Writes data to the shared file associated with this **Ashmem** object.
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------- | ----------------------------------------------------------------------------------------- | | ------- | ----------------------------------------------------------------------------- |
| boolean | Returns **true** if the data is written successfully; returns **false** otherwise.| | boolean | Returns **true** if the data is written successfully; returns **false** otherwise.|
**Example** **Example**
...@@ -8940,7 +9039,7 @@ Reads data from the shared file associated with this **Ashmem** object. ...@@ -8940,7 +9039,7 @@ Reads data from the shared file associated with this **Ashmem** object.
For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md). For details about the error codes, see [RPC Error Codes](../errorcodes/errorcode-rpc.md).
| ID | Error Message| | ID| Error Message|
| -------- | -------- | | -------- | -------- |
| 1900004 | read from ashmem failed | | 1900004 | read from ashmem failed |
...@@ -8985,7 +9084,7 @@ Reads data from the shared file associated with this **Ashmem** object. ...@@ -8985,7 +9084,7 @@ Reads data from the shared file associated with this **Ashmem** object.
**Example** **Example**
```ts ``` ts
let ashmem = rpc.Ashmem.createAshmem("ashmem", 1024*1024); let ashmem = rpc.Ashmem.createAshmem("ashmem", 1024*1024);
let mapResult = ashmem.mapReadAndWriteAshmem(); let mapResult = ashmem.mapReadAndWriteAshmem();
console.info("RpcTest map ashmem result is " + mapResult); console.info("RpcTest map ashmem result is " + mapResult);
...@@ -8995,3 +9094,36 @@ Reads data from the shared file associated with this **Ashmem** object. ...@@ -8995,3 +9094,36 @@ Reads data from the shared file associated with this **Ashmem** object.
let readResult = ashmem.readFromAshmem(5, 0); let readResult = ashmem.readFromAshmem(5, 0);
console.log("RpcTest: read to Ashmem result is : " + readResult); console.log("RpcTest: read to Ashmem result is : " + readResult);
``` ```
## Obtaining the Context
**Example**
```ts
import Ability from '@ohos.app.ability.UIAbility';
export default class MainAbility extends Ability {
onCreate(want, launchParam) {
console.log("[Demo] MainAbility onCreate");
globalThis.context = this.context;
}
onDestroy() {
console.log("[Demo] MainAbility onDestroy");
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("[Demo] MainAbility onWindowStageCreate");
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
console.log("[Demo] MainAbility onWindowStageDestroy");
}
onForeground() {
// Ability has brought to foreground
console.log("[Demo] MainAbility onForeground");
}
onBackground() {
// Ability has back to background
console.log("[Demo] MainAbility onBackground");
}
};
```
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册