diff --git a/zh-cn/application-dev/reference/apis/js-apis-rpc.md b/zh-cn/application-dev/reference/apis/js-apis-rpc.md
index edf7e7169821b9950ddd0f7cd28cd2e6df300c16..43aa4fdd192d47ab46b0873c24c306e41d0a91dd 100644
--- a/zh-cn/application-dev/reference/apis/js-apis-rpc.md
+++ b/zh-cn/application-dev/reference/apis/js-apis-rpc.md
@@ -97,9 +97,9 @@ writeRemoteObject(object: [IRemoteObject](#iremoteobject)): void
以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md)
| 错误码ID | 错误信息 |
- | -------- | ------- |
- | 1900008 | proxy or remote object is invalid |
- | 1900009 | write data to message sequence failed |
+ | -------- | -------- |
+ | 1900008 | proxy or remote object is invalid |
+ | 1900009 | write data to message sequence failed |
**示例:**
@@ -138,9 +138,9 @@ readRemoteObject(): IRemoteObject
以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md)
| 错误码ID | 错误信息 |
- | ------- | -------- |
- | 1900008 | proxy or remote object is invalid |
- | 1900010 | read data from message sequence failed |
+ | -------- | -------- |
+ | 1900008 | proxy or remote object is invalid |
+ | 1900010 | read data from message sequence failed |
**示例:**
@@ -180,8 +180,8 @@ writeInterfaceToken(token: string): void
以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md)
| 错误码ID | 错误信息 |
- | ------- | -------- |
- | 1900009 | write data to message sequence failed |
+ | -------- | -------- |
+ | 1900009 | write data to message sequence failed |
**示例:**
@@ -214,8 +214,8 @@ readInterfaceToken(): string
以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md)
| 错误码ID | 错误信息 |
- | ------- | ----- |
- | 1900010 | read data from message sequence failed |
+ | -------- | -------- |
+ | 1900010 | read data from message sequence failed |
**示例:**
@@ -266,7 +266,7 @@ getCapacity(): number
**返回值:**
- | 类型 | 说明 |
+ | 类型 | 说明 |
| ------ | ----- |
| number | 获取的MessageSequence实例的容量大小。以字节为单位。 |
@@ -288,7 +288,7 @@ setSize(size: number): void
**参数:**
- | 参数名 | 类型 | 必填 | 说明 |
+ | 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | ------ |
| size | number | 是 | MessageSequence实例的数据大小。以字节为单位。 |
@@ -324,8 +324,8 @@ setCapacity(size: number): void
以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md)
| 错误码ID | 错误信息 |
- | -------- | ------ |
- | 1900011 | parcel memory alloc failed |
+ | -------- | -------- |
+ | 1900011 | parcel memory alloc failed |
**示例:**
@@ -350,7 +350,7 @@ getWritableBytes(): number
**返回值:**
- | 类型 | 说明 |
+ | 类型 | 说明 |
| ------ | ------ |
| number | 获取到的MessageSequence实例的可写字节空间。以字节为单位。 |
@@ -376,7 +376,7 @@ getReadableBytes(): number
**返回值:**
- | 类型 | 说明 |
+ | 类型 | 说明 |
| ------ | ------- |
| number | 获取到的MessageSequence实例的可读字节空间。以字节为单位。 |
@@ -402,7 +402,7 @@ getReadPosition(): number
**返回值:**
- | 类型 | 说明 |
+ | 类型 | 说明 |
| ------ | ------ |
| number | 返回MessageSequence实例中的当前读取位置。 |
@@ -424,7 +424,7 @@ getWritePosition(): number
**返回值:**
- | 类型 | 说明 |
+ | 类型 | 说明 |
| ------ | ----- |
| number | 返回MessageSequence实例中的当前写入位置。 |
@@ -447,7 +447,7 @@ rewindRead(pos: number): void
**参数:**
- | 参数名 | 类型 | 必填 | 说明 |
+ | 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | ------- |
| pos | number | 是 | 开始读取数据的目标位置。 |
@@ -479,7 +479,7 @@ rewindWrite(pos: number): void
**参数:**
- | 参数名 | 类型 | 必填 | 说明 |
+ | 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | ----- |
| pos | number | 是 | 开始写入数据的目标位置。 |
@@ -509,17 +509,17 @@ writeByte(val: number): void
**参数:**
- | 参数名 | 类型 | 必填 | 说明 |
- | ----- | ------ | ---- | ----- |
- | val | number | 是 | 要写入的字节值。 |
+ | 参数名 | 类型 | 必填 | 说明 |
+ | ------ | ------ | ---- | ----- |
+ | val | number | 是 | 要写入的字节值。 |
**错误码:**
以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md)
| 错误码ID | 错误信息 |
- | -------- | ------- |
- | 1900009 | write data to message sequence failed |
+ | -------- | ------- |
+ | 1900009 | write data to message sequence failed |
**示例:**
@@ -543,7 +543,7 @@ readByte(): number
**返回值:**
- | 类型 | 说明 |
+ | 类型 | 说明 |
| ------ | ----- |
| number | 返回字节值。 |
@@ -585,16 +585,16 @@ writeShort(val: number): void
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
- | ------ | ------ | --- | --- |
- | val | number | 是 | 要写入的短整数值。 |
+ | ------ | ------ | --- | --- |
+ | val | number | 是 | 要写入的短整数值。 |
**错误码:**
以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md)
| 错误码ID | 错误信息 |
- | ------- | ------ |
- | 1900009 | write data to message sequence failed |
+ | -------- | -------- |
+ | 1900009 | write data to message sequence failed |
**示例:**
@@ -627,8 +627,8 @@ readShort(): number
以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md)
| 错误码ID | 错误信息 |
- | ------- | -------- |
- | 1900010 | read data from message sequence failed |
+ | -------- | -------- |
+ | 1900010 | read data from message sequence failed |
**示例:**
@@ -668,8 +668,8 @@ writeInt(val: number): void
以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md)
| 错误码ID | 错误信息 |
- | -------- | ------- |
- | 1900009 | write data to message sequence failed |
+ | -------- | -------- |
+ | 1900009 | write data to message sequence failed |
**示例:**
@@ -702,8 +702,8 @@ readInt(): number
以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md)
| 错误码ID | 错误信息 |
- | ------- | ------- |
- | 1900010 | read data from message sequence failed |
+ | -------- | -------- |
+ | 1900010 | read data from message sequence failed |
**示例:**
@@ -743,8 +743,8 @@ writeLong(val: number): void
以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md)
| 错误码ID | 错误信息 |
- | ------- | ------- |
- | 1900009 | write data to message sequence failed |
+ | -------- | -------- |
+ | 1900009 | write data to message sequence failed |
**示例:**
@@ -777,8 +777,8 @@ readLong(): number
以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md)
| 错误码ID | 错误信息 |
- | ------- | -------- |
- | 1900010 | read data from message sequence failed |
+ | -------- | -------- |
+ | 1900010 | read data from message sequence failed |
**示例:**
@@ -809,17 +809,17 @@ writeFloat(val: number): void
**参数:**
- | 参数名 | 类型 | 必填 | 说明 |
- | ----- | ---- | ---- | ----- |
- | val | number | 是 | 要写入的浮点值。 |
+ | 参数名 | 类型 | 必填 | 说明 |
+ | ------ | ------ | ---- | ----- |
+ | val | number | 是 | 要写入的浮点值。 |
**错误码:**
以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md)
| 错误码ID | 错误信息 |
- | ------- | ------- |
- | 1900009 | write data to message sequence failed |
+ | -------- | -------- |
+ | 1900009 | write data to message sequence failed |
**示例:**
@@ -852,8 +852,8 @@ readFloat(): number
以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md)
| 错误码ID | 错误信息 |
- | ------- | -------- |
- | 1900010 | read data from message sequence failed |
+ | -------- | -------- |
+ | 1900010 | read data from message sequence failed |
**示例:**
@@ -893,8 +893,8 @@ writeDouble(val: number): void
以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md)
| 错误码ID | 错误信息 |
- | ------- | -------- |
- | 1900009 | write data to message sequence failed |
+ | -------- | -------- |
+ | 1900009 | write data to message sequence failed |
**示例:**
@@ -927,8 +927,8 @@ readDouble(): number
以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md)
| 错误码ID | 错误信息 |
- | ------- | -------- |
- | 1900010 | read data from message sequence failed |
+ | -------- | -------- |
+ | 1900010 | read data from message sequence failed |
**示例:**
@@ -968,8 +968,8 @@ writeBoolean(val: boolean): void
以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md)
| 错误码ID | 错误信息 |
- | ------- | ------- |
- | 1900009 | write data to message sequence failed |
+ | -------- | -------- |
+ | 1900009 | write data to message sequence failed |
**示例:**
@@ -1002,8 +1002,8 @@ readBoolean(): boolean
以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md)
| 错误码ID | 错误信息 |
- | -------- | ------- |
- | 1900010 | read data from message sequence failed |
+ | -------- | -------- |
+ | 1900010 | read data from message sequence failed |
**示例:**
@@ -1043,8 +1043,8 @@ writeChar(val: number): void
以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md)
| 错误码ID | 错误信息 |
- | ------- | -------- |
- | 1900009 | write data to message sequence failed |
+ | -------- | -------- |
+ | 1900009 | write data to message sequence failed |
**示例:**
@@ -1077,8 +1077,8 @@ readChar(): number
以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md)
| 错误码ID | 错误信息 |
- | ------ | --------- |
- | 1900010 | read data from message sequence failed |
+ | -------- | -------- |
+ | 1900010 | read data from message sequence failed |
**示例:**
@@ -1118,8 +1118,8 @@ writeString(val: string): void
以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md)
| 错误码ID | 错误信息 |
- | ------- | -------- |
- | 1900009 | write data to message sequence failed |
+ | -------- | -------- |
+ | 1900009 | write data to message sequence failed |
**示例:**
@@ -1152,8 +1152,8 @@ readString(): string
以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md)
| 错误码ID | 错误信息 |
- | ------- | -------- |
- | 1900010 | read data from message sequence failed |
+ | -------- | -------- |
+ | 1900010 | read data from message sequence failed |
**示例:**
@@ -1193,8 +1193,8 @@ writeParcelable(val: Parcelable): void
以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md)
| 错误码ID | 错误信息 |
- | ------- | -------- |
- | 1900009 | write data to message sequence failed |
+ | -------- | -------- |
+ | 1900009 | write data to message sequence failed |
**示例:**
@@ -1239,16 +1239,16 @@ readParcelable(dataIn: Parcelable): void
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------------------------- | ---- | ----------------------------------------- |
- | dataIn | Parcelable | 是 | 需要从MessageSequence读取成员变量的对象。 |
+ | dataIn | Parcelable | 是 | 需要从MessageSequence读取成员变量的对象。 |
**错误码:**
以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md)
| 错误码ID | 错误信息 |
- | -------- | ------- |
- | 1900010 | read data from message sequence failed |
- | 1900012 | call js callback function failed |
+ | -------- | -------- |
+ | 1900010 | read data from message sequence failed |
+ | 1900012 | call js callback function failed |
**示例:**
@@ -1302,8 +1302,8 @@ writeByteArray(byteArray: number[]): void
以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md)
| 错误码ID | 错误信息 |
- | ------- | -------- |
- | 1900009 | write data to message sequence failed |
+ | -------- | -------- |
+ | 1900009 | write data to message sequence failed |
**示例:**
@@ -1337,8 +1337,8 @@ readByteArray(dataIn: number[]): void
以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md)
| 错误码ID | 错误信息 |
- | ------- | -------- |
- | 1900010 | read data from message sequence failed |
+ | -------- | -------- |
+ | 1900010 | read data from message sequence failed |
**示例:**
@@ -1379,8 +1379,8 @@ readByteArray(): number[]
以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md)
| 错误码ID | 错误信息 |
- | -------- | ------- |
- | 1900010 | read data from message sequence failed |
+ | -------- | -------- |
+ | 1900010 | read data from message sequence failed |
**示例:**
@@ -1421,8 +1421,8 @@ writeShortArray(shortArray: number[]): void
以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md)
| 错误码ID | 错误信息 |
- | ----- | ----- |
- | 1900009 | write data to message sequence failed |
+ | -------- | -------- |
+ | 1900009 | write data to message sequence failed |
**示例:**
@@ -1455,8 +1455,8 @@ readShortArray(dataIn: number[]): void
以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md)
| 错误码ID | 错误信息 |
- | ------ | ------- |
- | 1900010 | read data from message sequence failed |
+ | -------- | -------- |
+ | 1900010 | read data from message sequence failed |
**示例:**
@@ -1496,8 +1496,8 @@ readShortArray(): number[]
以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md)
| 错误码ID | 错误信息 |
- | -------- | ------- |
- | 1900010 | read data from message sequence failed |
+ | -------- | -------- |
+ | 1900010 | read data from message sequence failed |
**示例:**
@@ -1537,8 +1537,8 @@ writeIntArray(intArray: number[]): void
以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md)
| 错误码ID | 错误信息 |
- | ----- | --------- |
- | 1900009 | write data to message sequence failed |
+ | -------- | -------- |
+ | 1900009 | write data to message sequence failed |
**示例:**
@@ -1571,8 +1571,8 @@ readIntArray(dataIn: number[]): void
以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md)
| 错误码ID | 错误信息 |
- | ------- | -------- |
- | 1900010 | read data from message sequence failed |
+ | -------- | -------- |
+ | 1900010 | read data from message sequence failed |
**示例:**
@@ -1612,8 +1612,8 @@ readIntArray(): number[]
以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md)
| 错误码ID | 错误信息 |
- | ----- | ------- |
- | 1900010 | read data from message sequence failed |
+ | -------- | -------- |
+ | 1900010 | read data from message sequence failed |
**示例:**
@@ -1653,8 +1653,8 @@ writeLongArray(longArray: number[]): void
以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md)
| 错误码ID | 错误信息 |
- | ------- | ----- |
- | 1900009 | write data to message sequence failed |
+ | -------- | -------- |
+ | 1900009 | write data to message sequence failed |
**示例:**
@@ -1687,8 +1687,8 @@ readLongArray(dataIn: number[]): void
以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md)
| 错误码ID | 错误信息 |
- | ------- | ------ |
- | 1900010 | read data from message sequence failed |
+ | -------- | -------- |
+ | 1900010 | read data from message sequence failed |
**示例:**
@@ -1728,8 +1728,8 @@ readLongArray(): number[]
以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md)
| 错误码ID | 错误信息 |
- | ------- | -------- |
- | 1900010 | read data from message sequence failed |
+ | -------- | -------- |
+ | 1900010 | read data from message sequence failed |
**示例:**
@@ -1769,8 +1769,8 @@ writeFloatArray(floatArray: number[]): void
以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md)
| 错误码ID | 错误信息 |
- | ------- | -------- |
- | 1900009 | write data to message sequence failed |
+ | -------- | -------- |
+ | 1900009 | write data to message sequence failed |
**示例:**
@@ -1803,8 +1803,8 @@ readFloatArray(dataIn: number[]): void
以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md)
| 错误码ID | 错误信息 |
- | ------- | -------- |
- | 1900010 | read data from message sequence failed |
+ | -------- | -------- |
+ | 1900010 | read data from message sequence failed |
**示例:**
@@ -1844,8 +1844,8 @@ readFloatArray(): number[]
以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md)
| 错误码ID | 错误信息 |
- | ------- | -------- |
- | 1900010 | read data from message sequence failed |
+ | -------- | -------- |
+ | 1900010 | read data from message sequence failed |
**示例:**
@@ -1885,8 +1885,8 @@ writeDoubleArray(doubleArray: number[]): void
以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md)
| 错误码ID | 错误信息 |
- | ------- | -------- |
- | 1900009 | write data to message sequence failed |
+ | -------- | -------- |
+ | 1900009 | write data to message sequence failed |
**示例:**
@@ -1919,8 +1919,8 @@ readDoubleArray(dataIn: number[]): void
以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md)
| 错误码ID | 错误信息 |
- | ------- | -------- |
- | 1900010 | read data from message sequence failed |
+ | -------- | -------- |
+ | 1900010 | read data from message sequence failed |
**示例:**
@@ -1960,8 +1960,8 @@ readDoubleArray(): number[]
以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md)
| 错误码ID | 错误信息 |
- | ------- | -------- |
- | 1900010 | read data from message sequence failed |
+ | -------- | -------- |
+ | 1900010 | read data from message sequence failed |
**示例:**
@@ -2001,8 +2001,8 @@ writeBooleanArray(booleanArray: boolean[]): void
以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md)
| 错误码ID | 错误信息 |
- | ------- | -------- |
- | 1900009 | write data to message sequence failed |
+ | -------- | -------- |
+ | 1900009 | write data to message sequence failed |
**示例:**
@@ -2035,8 +2035,8 @@ readBooleanArray(dataIn: boolean[]): void
以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md)
| 错误码ID | 错误信息 |
- | ------- | -------- |
- | 1900010 | read data from message sequence failed |
+ | -------- | -------- |
+ | 1900010 | read data from message sequence failed |
**示例:**
@@ -2076,8 +2076,8 @@ readBooleanArray(): boolean[]
以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md)
| 错误码ID | 错误信息 |
- | ------- | -------- |
- | 1900010 | read data from message sequence failed |
+ | -------- | -------- |
+ | 1900010 | read data from message sequence failed |
**示例:**
@@ -2117,8 +2117,8 @@ writeCharArray(charArray: number[]): void
以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md)
| 错误码ID | 错误信息 |
- | -------- | ------ |
- | 1900009 | write data to message sequence failed |
+ | -------- | -------- |
+ | 1900009 | write data to message sequence failed |
**示例:**
@@ -2151,8 +2151,8 @@ readCharArray(dataIn: number[]): void
以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md)
| 错误码ID | 错误信息 |
- | ------- | -------- |
- | 1900010 | read data from message sequence failed |
+ | -------- | -------- |
+ | 1900010 | read data from message sequence failed |
**示例:**
@@ -2192,8 +2192,8 @@ readCharArray(): number[]
以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md)
| 错误码ID | 错误信息 |
- | ------- | -------- |
- | 1900010 | read data from message sequence failed |
+ | -------- | -------- |
+ | 1900010 | read data from message sequence failed |
**示例:**
@@ -2234,8 +2234,8 @@ writeStringArray(stringArray: string[]): void
以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md)
| 错误码ID | 错误信息 |
- | ------- | -------- |
- | 1900009 | write data to message sequence failed |
+ | -------- | -------- |
+ | 1900009 | write data to message sequence failed |
**示例:**
@@ -2268,8 +2268,8 @@ readStringArray(dataIn: string[]): void
以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md)
| 错误码ID | 错误信息 |
- | ------- | -------- |
- | 1900010 | read data from message sequence failed |
+ | -------- | -------- |
+ | 1900010 | read data from message sequence failed |
**示例:**
@@ -2309,8 +2309,8 @@ readStringArray(): string[]
以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md)
| 错误码ID | 错误信息 |
- | ------- | -------- |
- | 1900010 | read data from message sequence failed |
+ | -------- | -------- |
+ | 1900010 | read data from message sequence failed |
**示例:**
@@ -2344,8 +2344,8 @@ writeNoException(): void
以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md)
| 错误码ID | 错误信息 |
- | ------- | -------- |
- | 1900009 | write data to message sequence failed |
+ | -------- | -------- |
+ | 1900009 | write data to message sequence failed |
**示例:**
@@ -2386,15 +2386,17 @@ readException(): void
以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md)
| 错误码ID | 错误信息 |
- | ------- | -------- |
- | 1900010 | read data from message sequence failed |
+ | -------- | -------- |
+ | 1900010 | read data from message sequence failed |
**示例:**
- 获取服务
+ Stage模型的应用在获取服务前需要先获取context,具体方法可参考[获取context](#获取context)
```ts
- import FA from "@ohos.ability.featureAbility";
+ //仅FA模型需要导入@ohos.ability.featureAbility
+ //import FA from "@ohos.ability.featureAbility";
+
let proxy;
let connect = {
onConnect: function(elementName, remoteProxy) {
@@ -2412,7 +2414,11 @@ readException(): void
"bundleName": "com.ohos.server",
"abilityName": "com.ohos.server.EntryAbility",
};
- FA.connectAbility(want, connect);
+
+ //FA模型使用此方法连接服务
+ //FA.connectAbility(want,connect);
+
+ globalThis.context.connectServiceExtensionAbility(want, connect);
```
上述onConnect回调函数中的proxy对象需要等ability异步连接成功后才会被赋值,然后才可调用proxy对象的sendMessageRequest接口方法发送消息
@@ -2466,8 +2472,8 @@ writeParcelableArray(parcelableArray: Parcelable[]): void
以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md)
| 错误码ID | 错误信息 |
- | ------- | -------- |
- | 1900009 | write data to message sequence failed |
+ | -------- | -------- |
+ | 1900009 | write data to message sequence failed |
**示例:**
@@ -2522,9 +2528,9 @@ readParcelableArray(parcelableArray: Parcelable[]): void
以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md)
| 错误码ID | 错误信息 |
- | ------- | -------- |
- | 1900010 | read data from message sequence failed |
- | 1900012 | call js callback function failed |
+ | -------- | -------- |
+ | 1900010 | read data from message sequence failed |
+ | 1900012 | call js callback function failed |
**示例:**
@@ -2583,8 +2589,8 @@ writeRemoteObjectArray(objectArray: IRemoteObject[]): void
以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md)
| 错误码ID | 错误信息 |
- | ------- | ------- |
- | 1900009 | write data to message sequence failed |
+ | -------- | -------- |
+ | 1900009 | write data to message sequence failed |
**示例:**
@@ -2630,8 +2636,8 @@ readRemoteObjectArray(objects: IRemoteObject[]): void
以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md)
| 错误码ID | 错误信息 |
- | ------- | -------- |
- | 1900010 | read data from message sequence failed |
+ | -------- | -------- |
+ | 1900010 | read data from message sequence failed |
**示例:**
@@ -2683,8 +2689,8 @@ readRemoteObjectArray(): IRemoteObject[]
以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md)
| 错误码ID | 错误信息 |
- | ------- | -------- |
- | 1900010 | read data from message sequence failed |
+ | -------- | -------- |
+ | 1900010 | read data from message sequence failed |
**示例:**
@@ -2765,8 +2771,8 @@ static dupFileDescriptor(fd: number) :number
以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md)
| 错误码ID | 错误信息 |
- | ------- | ------- |
- | 1900013 | call os dup function failed |
+ | -------- | -------- |
+ | 1900013 | call os dup function failed |
**示例:**
@@ -2839,8 +2845,8 @@ writeFileDescriptor(fd: number): void
以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md)
| 错误码ID | 错误信息 |
- | -------- | ------ |
- | 1900009 | write data to message sequence failed |
+ | -------- | -------- |
+ | 1900009 | write data to message sequence failed |
**示例:**
@@ -2876,8 +2882,8 @@ readFileDescriptor(): number
以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md)
| 错误码ID | 错误信息 |
- | ------- | -------- |
- | 1900010 | read data from message sequence failed |
+ | -------- | -------- |
+ | 1900010 | read data from message sequence failed |
**示例:**
@@ -2919,8 +2925,8 @@ writeAshmem(ashmem: Ashmem): void
以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md)
| 错误码ID | 错误信息 |
- | ------- | ------- |
- | 1900003 | write to ashmem failed |
+ | -------- | ------- |
+ | 1900003 | write to ashmem failed |
**示例:**
@@ -2961,8 +2967,8 @@ readAshmem(): Ashmem
以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md)
| 错误码ID | 错误信息 |
- | ------- | -------- |
- | 1900004 | read from ashmem failed |
+ | -------- | -------- |
+ | 1900004 | read from ashmem failed |
**示例:**
@@ -3032,8 +3038,8 @@ writeRawData(rawData: number[], size: number): void
以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md)
| 错误码ID | 错误信息 |
- | ------- | ------ |
- | 1900009 | write data to message sequence failed |
+ | -------- | -------- |
+ | 1900009 | write data to message sequence failed |
**示例:**
@@ -3073,8 +3079,8 @@ readRawData(size: number): number[]
以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md)
| 错误码ID | 错误信息 |
- | ------- | -------- |
- | 1900010 | read data from message sequence failed |
+ | -------- | -------- |
+ | 1900010 | read data from message sequence failed |
**示例:**
@@ -4027,8 +4033,8 @@ writeSequenceable(val: Sequenceable): boolean
**返回值:**
- | 类型 | 说明 |
- | ------- | --------------------------------- |
+ | 类型 | 说明 |
+ | ------- | -------------------------------- |
| boolean | true:写入成功,false:写入失败。|
**示例:**
@@ -4068,14 +4074,14 @@ readSequenceable(dataIn: Sequenceable): boolean
**参数:**
- | 参数名 | 类型 | 必填 | 说明 |
- | ------ | ----------------------------- | ---- | --------------------------------------- |
+ | 参数名 | 类型 | 必填 | 说明 |
+ | ------ | ----------------------------- | ------- | ---------------------------------------------- |
| dataIn | [Sequenceable](#sequenceabledeprecated) | 是 | 需要从MessageParcel读取成员变量的对象。 |
**返回值:**
- | 类型 | 说明 |
- | ------- | ------------------------------------------- |
+ | 类型 | 说明 |
+ | ------- | ---------------------------------------- |
| boolean | true:反序列化成功,false:反序列化失败。|
**示例:**
@@ -4124,8 +4130,8 @@ writeByteArray(byteArray: number[]): boolean
**返回值:**
- | 类型 | 说明 |
- | ------- | --------------------------------- |
+ | 类型 | 说明 |
+ | ------- | -------------------------------- |
| boolean | true:写入成功,false:写入失败。|
**示例:**
@@ -4203,8 +4209,8 @@ writeShortArray(shortArray: number[]): boolean
**返回值:**
- | 类型 | 说明 |
- | ------- | ----------------------------- |
+ | 类型 | 说明 |
+ | ------- | -------------------------------- |
| boolean | true:写入成功,false:写入失败。|
**示例:**
@@ -4279,8 +4285,8 @@ writeIntArray(intArray: number[]): boolean
**返回值:**
- | 类型 | 说明 |
- | ------- | ----------------------------- |
+ | 类型 | 说明 |
+ | ------- | -------------------------------- |
| boolean | true:写入成功,false:写入失败。|
**示例:**
@@ -4425,14 +4431,14 @@ writeFloatArray(floatArray: number[]): boolean
**参数:**
- | 参数名 | 类型 | 必填 | 说明 |
+ | 参数名 | 类型 | 必填 | 说明 |
| ---------- | -------- | ---- | --- |
| floatArray | number[] | 是 | 要写入的浮点数组。由于系统内部对float类型的数据是按照double处理的,使用时对于数组所占的总字节数应按照double类型来计算。 |
**返回值:**
- | 类型 | 说明 |
- | ------- | ----------------------------- |
+ | 类型 | 说明 |
+ | ------- | -------------------------------- |
| boolean | true:写入成功,false:写入失败。|
**示例:**
@@ -4453,7 +4459,7 @@ readFloatArray(dataIn: number[]): void
**参数:**
- | 参数名 | 类型 | 必填 | 说明 |
+ | 参数名 | 类型 | 必填 | 说明 |
| ------ | -------- | ---- | ------ |
| dataIn | number[] | 是 | 要读取的浮点数组。由于系统内部对float类型的数据是按照double处理的,使用时对于数组所占的总字节数应按照double类型来计算。 |
@@ -4507,8 +4513,8 @@ writeDoubleArray(doubleArray: number[]): boolean
**返回值:**
- | 类型 | 说明 |
- | ------- | ----------------------------- |
+ | 类型 | 说明 |
+ | ------- | -------------------------------- |
| boolean | true:写入成功,false:写入失败。|
**示例:**
@@ -4583,8 +4589,8 @@ writeBooleanArray(booleanArray: boolean[]): boolean
**返回值:**
- | 类型 | 说明 |
- | ------- | --------------------------------- |
+ | 类型 | 说明 |
+ | ------- | -------------------------------- |
| boolean | true:写入成功,false:写入失败。|
**示例:**
@@ -4659,8 +4665,8 @@ writeCharArray(charArray: number[]): boolean
**返回值:**
- | 类型 | 说明 |
- | ------- | --------------------------------- |
+ | 类型 | 说明 |
+ | ------- | -------------------------------- |
| boolean | true:写入成功,false:写入失败。|
**示例:**
@@ -4729,14 +4735,14 @@ writeStringArray(stringArray: string[]): boolean
**参数:**
- | 参数名 | 类型 | 必填 | 说明 |
+ | 参数名 | 类型 | 必填 | 说明 |
| ----------- | -------- | ---- | ---------------- |
| stringArray | string[] | 是 | 要写入的字符串数组,数组单个元素的长度应小于40960字节。 |
**返回值:**
| 类型 | 说明 |
- | ------- | --------------------------------- |
+ | ------- | -------------------------------- |
| boolean | true:写入成功,false:写入失败。|
**示例:**
@@ -4846,11 +4852,13 @@ readException(): void
**系统能力**:SystemCapability.Communication.IPC.Core
**示例:**
-
- 获取服务
+
+ Stage模型的应用在获取服务前需要先获取context,具体方法可参考[获取context](#获取context)
```ts
- import FA from "@ohos.ability.featureAbility";
+ //仅FA模型需要导入@ohos.ability.;featureAbility
+ //import FA from "@ohos.ability.featureAbility";
+
let proxy;
let connect = {
onConnect: function(elementName, remoteProxy) {
@@ -4868,7 +4876,11 @@ readException(): void
"bundleName": "com.ohos.server",
"abilityName": "com.ohos.server.EntryAbility",
};
- FA.connectAbility(want, connect);
+
+ //FA模型使用此方法连接服务
+ //FA.connectAbility(want,connect);
+
+ globalThis.context.connectServiceExtensionAbility(want, connect);
```
上述onConnect回调函数中的proxy对象需要等ability异步连接成功后才会被赋值,然后才可调用proxy对象的sendMessageRequest接口方法发送消息
@@ -4914,8 +4926,8 @@ writeSequenceableArray(sequenceableArray: Sequenceable[]): boolean
**返回值:**
- | 类型 | 说明 |
- | ------- | --------------------------------- |
+ | 类型 | 说明 |
+ | ------- | -------------------------------- |
| boolean | true:写入成功,false:写入失败。|
**示例:**
@@ -5004,14 +5016,14 @@ writeRemoteObjectArray(objectArray: IRemoteObject[]): boolean
**参数:**
- | 参数名 | 类型 | 必填 | 说明 |
+ | 参数名 | 类型 | 必填 | 说明 |
| ----------- | --------------- | ---- | ----- |
| objectArray | IRemoteObject[] | 是 | 要写入MessageParcel的IRemoteObject对象数组。 |
**返回值:**
| 类型 | 说明 |
- | ------- | -------------------------------------------------------------------------------------------------------------------- |
+ | ------- | -------------------------------- |
| boolean | true:写入成功,false:写入失败。|
**示例:**
@@ -5056,7 +5068,7 @@ readRemoteObjectArray(objects: IRemoteObject[]): void
**参数:**
- | 参数名 | 类型 | 必填 | 说明 |
+ | 参数名 | 类型 | 必填 | 说明 |
| ------- | --------------- | ---- | --------- |
| objects | IRemoteObject[] | 是 | 从MessageParcel读取的IRemoteObject对象数组。 |
@@ -5103,8 +5115,8 @@ readRemoteObjectArray(): IRemoteObject[]
**返回值:**
- | 类型 | 说明 |
- | --------------- | -------- |
+ | 类型 | 说明 |
+ | --------------- | --------------------------- |
| IRemoteObject[] | 返回IRemoteObject对象数组。 |
**示例:**
@@ -5203,8 +5215,8 @@ containFileDescriptors(): boolean
**返回值:**
- | 类型 | 说明 |
- | ------- | ------------------------------------------------------------------ |
+ | 类型 | 说明 |
+ | ------- | --------------------------------------------- |
| boolean |true:包含文件描述符,false:未包含文件描述符。|
**示例:**
@@ -5237,8 +5249,8 @@ writeFileDescriptor(fd: number): boolean
**返回值:**
- | 类型 | 说明 |
- | ------- | ----------------------------------------- |
+ | 类型 | 说明 |
+ | ------- | -------------------------------- |
| boolean | true:操作成功,false:操作失败。|
**示例:**
@@ -5294,8 +5306,8 @@ writeAshmem(ashmem: Ashmem): boolean
**返回值:**
- | 类型 | 说明 |
- | ------- | -------------------------------------------------------------------- |
+ | 类型 | 说明 |
+ | ------- | -------------------------------- |
| boolean | true:写入成功,false:写入失败。|
**示例:**
@@ -5371,8 +5383,8 @@ writeRawData(rawData: number[], size: number): boolean
**返回值:**
- | 类型 | 说明 |
- | ------- | ----------------------------------------- |
+ | 类型 | 说明 |
+ | ------- | -------------------------------- |
| boolean | true:写入成功,false:写入失败。|
**示例:**
@@ -5435,9 +5447,9 @@ marshalling(dataOut: MessageSequence): boolean
**返回值:**
- | 类型 | 说明 |
- | ------- | ----------------------------------------- |
- | boolean | true:封送成功,false:封送失败。
+ | 类型 | 说明 |
+ | ------- | -------------------------------- |
+ | boolean | true:封送成功,false:封送失败。|
**示例:**
```ts
@@ -5484,8 +5496,8 @@ unmarshalling(dataIn: MessageSequence): boolean
**返回值:**
- | 类型 | 说明 |
- | ------- | --------------------------------------------- |
+ | 类型 | 说明 |
+ | ------- | ---------------------------------------- |
| boolean | true:反序列化成功,false:反序列化失败。|
**示例:**
@@ -5534,15 +5546,15 @@ marshalling(dataOut: MessageParcel): boolean
**参数:**
- | 参数名 | 类型 | 必填 | 说明 |
- | ------- | ------------------------------- | ---- | ----------------------------------------- |
+ | 参数名 | 类型 | 必填 | 说明 |
+ | ------- | ----------------------------------------- | ---- | ----------------------------------------- |
| dataOut | [MessageParcel](#messageparceldeprecated) | 是 | 可序列对象将被封送到的MessageParcel对象。 |
**返回值:**
- | 类型 | 说明 |
- | ------- | ----------------------------------------- |
- | boolean | true:封送成功,false:封送失败。
+ | 类型 | 说明 |
+ | ------- | -------------------------------- |
+ | boolean | true:封送成功,false:封送失败。 |
**示例:**
```ts
@@ -5583,14 +5595,14 @@ unmarshalling(dataIn: MessageParcel): boolean
**参数:**
- | 参数名 | 类型 | 必填 | 说明 |
- | ------ | ------------------------------- | ---- | --------------------------------------------- |
+ | 参数名 | 类型 | 必填 | 说明 |
+ | ------ | ----------------------------------------- | ---- | --------------------------------------------- |
| dataIn | [MessageParcel](#messageparceldeprecated) | 是 | 已将可序列对象封送到其中的MessageParcel对象。 |
**返回值:**
- | 类型 | 说明 |
- | ------- | --------------------------------------------- |
+ | 类型 | 说明 |
+ | ------- | ---------------------------------------- |
| boolean | true:反序列化成功,false:反序列化失败。|
**示例:**
@@ -5637,8 +5649,8 @@ asObject(): IRemoteObject
**返回值:**
- | 类型 | 说明 |
- | ---- | ----- |
+ | 类型 | 说明 |
+ | ----- | ----- |
| [IRemoteObject](#iremoteobject) | 如果调用者是RemoteObject对象,则直接返回本身;如果调用者是[RemoteProxy](#remoteproxy)对象,则返回它的持有者[IRemoteObject](#iremoteobject)。 |
**示例:**
@@ -5654,20 +5666,22 @@ asObject(): IRemoteObject
**示例:**
- 获取服务
+ Stage模型的应用在获取服务前需要先获取context,具体方法可参考[获取context](#获取context)
```ts
- import FA from "@ohos.ability.featureAbility";
+ //仅FA模型需要导入@ohos.ability.featureAbility
+ //import FA from "@ohos.ability.featureAbility";
+
let proxy;
let connect = {
- onConnect: function (elementName, remoteProxy) {
+ onConnect: function(elementName, remoteProxy) {
console.log("RpcClient: js onConnect called.");
proxy = remoteProxy;
},
- onDisconnect: function (elementName) {
+ onDisconnect: function(elementName) {
console.log("RpcClient: onDisconnect");
},
- onFailed: function () {
+ onFailed: function() {
console.log("RpcClient: onFailed");
}
};
@@ -5675,11 +5689,15 @@ asObject(): IRemoteObject
"bundleName": "com.ohos.server",
"abilityName": "com.ohos.server.EntryAbility",
};
- FA.connectAbility(want, connect);
- ```
- 上述onConnect回调函数中的proxy对象需要等ability异步连接成功后才会被赋值,然后才可调用proxy对象的asObject接口方法获取代理或远端对象
+ //FA模型使用此方法连接服务
+ //FA.connectAbility(want,connect);
+ globalThis.context.connectServiceExtensionAbility(want, connect);
+ ```
+
+ 上述onConnect回调函数中的proxy对象需要等ability异步连接成功后才会被赋值,然后才可调用proxy对象的asObject接口方法获取代理或远端对象
+
```ts
class TestProxy {
remote: rpc.RemoteObject;
@@ -5691,7 +5709,6 @@ asObject(): IRemoteObject
}
}
let iRemoteObject = new TestProxy(proxy).asObject();
-
```
## DeathRecipient
@@ -5802,17 +5819,17 @@ sendRequest(code: number, data: MessageParcel, reply: MessageParcel, options: Me
**参数:**
- | 参数名 | 类型 | 必填 | 说明 |
- | ------- | ------------------------------- | ---- | ---- |
- | code | number | 是 | 本次请求调用的消息码,由通信双方确定。如果接口由IDL工具生成,则消息代码由IDL自动生成。 |
+ | 参数名 | 类型 | 必填 | 说明 |
+ | ------- | ----------------------------------------- | ---- | -------------------------------------------------------------------------------------- |
+ | code | number | 是 | 本次请求调用的消息码,由通信双方确定。如果接口由IDL工具生成,则消息代码由IDL自动生成。 |
| data | [MessageParcel](#messageparceldeprecated) | 是 | 保存待发送数据的 MessageParcel对象。 |
| reply | [MessageParcel](#messageparceldeprecated) | 是 | 接收应答数据的MessageParcel对象。 |
- | options | [MessageOption](#messageoption) | 是 | 本次请求的同异步模式,默认同步调用。 |
+ | options | [MessageOption](#messageoption) | 是 | 本次请求的同异步模式,默认同步调用。 |
**返回值:**
- | 类型 | 说明 |
- | ------- | --------------------------------------------- |
+ | 类型 | 说明 |
+ | ------- | -------------------------------- |
| boolean | true:发送成功,false:发送失败。|
@@ -5828,12 +5845,12 @@ sendRequest(code: number, data: MessageParcel, reply: MessageParcel, options: Me
**参数:**
- | 参数名 | 类型 | 必填 | 说明 |
- | ------- | ------------------------------- | ---- | -------------------------------------------------------------------------------------- |
- | code | number | 是 | 本次请求调用的消息码,由通信双方确定。如果接口由IDL工具生成,则消息代码由IDL自动生成。 |
+ | 参数名 | 类型 | 必填 | 说明 |
+ | ------- | ---------------------------------------- | ---- | -------------------------------------------------------------------------------------- |
+ | code | number | 是 | 本次请求调用的消息码,由通信双方确定。如果接口由IDL工具生成,则消息代码由IDL自动生成。 |
| data | [MessageParcel](#messageparceldeprecated) | 是 | 保存待发送数据的 MessageParcel对象。 |
| reply | [MessageParcel](#messageparceldeprecated) | 是 | 接收应答数据的MessageParcel对象。 |
- | options | [MessageOption](#messageoption) | 是 | 本次请求的同异步模式,默认同步调用。 |
+ | options | [MessageOption](#messageoption) | 是 | 本次请求的同异步模式,默认同步调用。 |
**返回值:**
@@ -5852,12 +5869,12 @@ sendMessageRequest(code: number, data: MessageSequence, reply: MessageSequence,
**参数:**
- | 参数名 | 类型 | 必填 | 说明 |
- | ------- | ------------------------------- | ---- | -------------------------------------------------------------------------------------- |
- | code | number | 是 | 本次请求调用的消息码,由通信双方确定。如果接口由IDL工具生成,则消息代码由IDL自动生成。 |
+ | 参数名 | 类型 | 必填 | 说明 |
+ | ------- | ------------------------------------ | ---- | -------------------------------------------------------------------------------------- |
+ | code | number | 是 | 本次请求调用的消息码,由通信双方确定。如果接口由IDL工具生成,则消息代码由IDL自动生成。 |
| data | [MessageSequence](#messagesequence9) | 是 | 保存待发送数据的 MessageSequence对象。 |
| reply | [MessageSequence](#messagesequence9) | 是 | 接收应答数据的MessageSequence对象。 |
- | options | [MessageOption](#messageoption) | 是 | 本次请求的同异步模式,默认同步调用。 |
+ | options | [MessageOption](#messageoption) | 是 | 本次请求的同异步模式,默认同步调用。 |
**返回值:**
@@ -5876,13 +5893,13 @@ sendMessageRequest(code: number, data: MessageSequence, reply: MessageSequence,
**参数:**
- | 参数名 | 类型 | 必填 | 说明 |
- | -------- | ---------------------------------- | ---- | -------------------------------------------------------------------------------------- |
- | code | number | 是 | 本次请求调用的消息码,由通信双方确定。如果接口由IDL工具生成,则消息代码由IDL自动生成。 |
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | ------------------------------------ | ---- | -------------------------------------------------------------------------------------- |
+ | code | number | 是 | 本次请求调用的消息码,由通信双方确定。如果接口由IDL工具生成,则消息代码由IDL自动生成。 |
| data | [MessageSequence](#messagesequence9) | 是 | 保存待发送数据的 MessageSequence对象。 |
| reply | [MessageSequence](#messagesequence9) | 是 | 接收应答数据的MessageSequence对象。 |
- | options | [MessageOption](#messageoption) | 是 | 本次请求的同异步模式,默认同步调用。 |
- | callback | AsyncCallback<RequestResult> | 是 | 接收发送结果的回调。 |
+ | options | [MessageOption](#messageoption) | 是 | 本次请求的同异步模式,默认同步调用。 |
+ | callback | AsyncCallback<RequestResult> | 是 | 接收发送结果的回调。 |
### sendRequest8+(deprecated)
@@ -5896,13 +5913,13 @@ sendRequest(code: number, data: MessageParcel, reply: MessageParcel, options: Me
**参数:**
- | 参数名 | 类型 | 必填 | 说明 |
- | -------- | -------------------------------------- | ---- | -------------------------------------------------------------------------------------- |
- | code | number | 是 | 本次请求调用的消息码,由通信双方确定。如果接口由IDL工具生成,则消息代码由IDL自动生成。 |
- | data | [MessageParcel](#messageparceldeprecated) | 是 | 保存待发送数据的 MessageParcel对象。 |
- | reply | [MessageParcel](#messageparceldeprecated) | 是 | 接收应答数据的MessageParcel对象。 |
- | options | [MessageOption](#messageoption) | 是 | 本次请求的同异步模式,默认同步调用。 |
- | callback | AsyncCallback<SendRequestResult> | 是 | 接收发送结果的回调。 |
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | ----------------------------------------- | ---- | -------------------------------------------------------------------------------------- |
+ | code | number | 是 | 本次请求调用的消息码,由通信双方确定。如果接口由IDL工具生成,则消息代码由IDL自动生成。 |
+ | data | [MessageParcel](#messageparceldeprecated) | 是 | 保存待发送数据的 MessageParcel对象。 |
+ | reply | [MessageParcel](#messageparceldeprecated) | 是 | 接收应答数据的MessageParcel对象。 |
+ | options | [MessageOption](#messageoption) | 是 | 本次请求的同异步模式,默认同步调用。 |
+ | callback | AsyncCallback<SendRequestResult> | 是 | 接收发送结果的回调。 |
### registerDeathRecipient9+
@@ -5924,8 +5941,8 @@ registerDeathRecipient(recipient: DeathRecipient, flags: number): void
以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md)
| 错误码ID | 错误信息 |
- | ------- | -------- |
- | 1900008 | proxy or remote object is invalid |
+ | -------- | -------- |
+ | 1900008 | proxy or remote object is invalid |
### addDeathrecipient(deprecated)
@@ -5946,8 +5963,8 @@ addDeathRecipient(recipient: DeathRecipient, flags: number): boolean
**返回值:**
- | 类型 | 说明 |
- | ------- | --------------------------------------------- |
+ | 类型 | 说明 |
+ | ------- | ---------------------------------------- |
| boolean | true:回调注册成功,false:回调注册失败。|
@@ -5971,8 +5988,8 @@ unregisterDeathRecipient(recipient: DeathRecipient, flags: number): void
以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md)
| 错误码ID | 错误信息 |
- | ------- | -------- |
- | 1900008 | proxy or remote object is invalid |
+ | -------- | -------- |
+ | 1900008 | proxy or remote object is invalid |
### removeDeathRecipient(deprecated)
@@ -5993,8 +6010,8 @@ removeDeathRecipient(recipient: DeathRecipient, flags: number): boolean
**返回值:**
- | 类型 | 说明 |
- | ------- | --------------------------------------------- |
+ | 类型 | 说明 |
+ | ------- | -----------------------------------------|
| boolean | true:回调注销成功,false:回调注销失败。|
### getDescriptor9+
@@ -6016,8 +6033,8 @@ getDescriptor(): string
以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md)
| 错误码ID | 错误信息 |
- | ------- | -------- |
- | 1900008 | proxy or remote object is invalid |
+ | -------- | -------- |
+ | 1900008 | proxy or remote object is invalid |
### getInterfaceDescriptor(deprecated)
@@ -6047,8 +6064,8 @@ isObjectDead(): boolean
**返回值:**
- | 类型 | 说明 |
- | ------- | ------------------------------------------- |
+ | 类型 | 说明 |
+ | ------- | ---------------------------------- |
| boolean | true:对象死亡,false:对象未死亡。|
@@ -6078,25 +6095,27 @@ sendRequest(code: number, data: MessageParcel, reply: MessageParcel, options: Me
**参数:**
- | 参数名 | 类型 | 必填 | 说明 |
- | ------- | ------------------------------- | ---- | -------------------------------------------------------------------------------------- |
- | code | number | 是 | 本次请求调用的消息码,由通信双方确定。如果接口由IDL工具生成,则消息代码由IDL自动生成。 |
+ | 参数名 | 类型 | 必填 | 说明 |
+ | ------- | ----------------------------------------- | ---- | -------------------------------------------------------------------------------------- |
+ | code | number | 是 | 本次请求调用的消息码,由通信双方确定。如果接口由IDL工具生成,则消息代码由IDL自动生成。 |
| data | [MessageParcel](#messageparceldeprecated) | 是 | 保存待发送数据的 MessageParcel对象。 |
| reply | [MessageParcel](#messageparceldeprecated) | 是 | 接收应答数据的MessageParcel对象。 |
- | options | [MessageOption](#messageoption) | 是 | 本次请求的同异步模式,默认同步调用。 |
+ | options | [MessageOption](#messageoption) | 是 | 本次请求的同异步模式,默认同步调用。 |
**返回值:**
- | 类型 | 说明 |
- | ------- | --------------------------------------------- |
+ | 类型 | 说明 |
+ | ------- | ---------------------------------|
| boolean | true:发送成功,false:发送失败。|
**示例:**
- 获取服务
+ Stage模型的应用在获取服务前需要先获取context,具体方法可参考[获取context](#获取context)
```ts
- import FA from "@ohos.ability.featureAbility";
+ //仅FA模型需要导入@ohos.ability.featureAbility
+ //import FA from "@ohos.ability.featureAbility";
+
let proxy;
let connect = {
onConnect: function(elementName, remoteProxy) {
@@ -6114,11 +6133,15 @@ sendRequest(code: number, data: MessageParcel, reply: MessageParcel, options: Me
"bundleName": "com.ohos.server",
"abilityName": "com.ohos.server.EntryAbility",
};
- FA.connectAbility(want, connect);
- ```
- 上述onConnect回调函数中的proxy对象需要等ability异步连接成功后才会被赋值,然后才可调用proxy对象的sendRequest接口方法发送消息
+ //FA模型使用此方法连接服务
+ //FA.connectAbility(want,connect);
+ globalThis.context.connectServiceExtensionAbility(want, connect);
+ ```
+
+ 上述onConnect回调函数中的proxy对象需要等ability异步连接成功后才会被赋值,然后才可调用proxy对象的sendRequest接口方法发送消息
+
```ts
let option = new rpc.MessageOption();
let data = rpc.MessageParcel.create();
@@ -6148,12 +6171,12 @@ sendMessageRequest(code: number, data: MessageSequence, reply: MessageSequence,
**参数:**
- | 参数名 | 类型 | 必填 | 说明 |
- | ------- | ------------------------------- | ---- | -------------------------------------------------------------------------------------- |
- | code | number | 是 | 本次请求调用的消息码,由通信双方确定。如果接口由IDL工具生成,则消息代码由IDL自动生成。 |
+ | 参数名 | 类型 | 必填 | 说明 |
+ | ------- | ------------------------------------ | ---- | -------------------------------------------------------------------------------------- |
+ | code | number | 是 | 本次请求调用的消息码,由通信双方确定。如果接口由IDL工具生成,则消息代码由IDL自动生成。 |
| data | [MessageSequence](#messagesequence9) | 是 | 保存待发送数据的 MessageSequence对象。 |
- | reply | [MessageSequence](#messagesequence9) | 是 | 接收应答数据的MessageSequence对象。 |
- | options | [MessageOption](#messageoption) | 是 | 本次请求的同异步模式,默认同步调用。 |
+ | reply | [MessageSequence](#messagesequence9) | 是 | 接收应答数据的MessageSequence对象。 |
+ | options | [MessageOption](#messageoption) | 是 | 本次请求的同异步模式,默认同步调用。 |
**返回值:**
@@ -6163,10 +6186,12 @@ sendMessageRequest(code: number, data: MessageSequence, reply: MessageSequence,
**示例:**
- 获取服务
+ Stage模型的应用在获取服务前需要先获取context,具体方法可参考[获取context](#获取context)
```ts
- import FA from "@ohos.ability.featureAbility";
+ //仅FA模型需要导入@ohos.ability.featureAbility
+ //import FA from "@ohos.ability.featureAbility";
+
let proxy;
let connect = {
onConnect: function(elementName, remoteProxy) {
@@ -6184,9 +6209,13 @@ sendMessageRequest(code: number, data: MessageSequence, reply: MessageSequence,
"bundleName": "com.ohos.server",
"abilityName": "com.ohos.server.EntryAbility",
};
- FA.connectAbility(want, connect);
- ```
+ //FA模型使用此方法连接服务
+ //FA.connectAbility(want,connect);
+
+ globalThis.context.connectServiceExtensionAbility(want, connect);
+ ```
+
上述onConnect回调函数中的proxy对象需要等ability异步连接成功后才会被赋值,然后才可调用proxy对象的sendMessageRequest接口方法发送消息
```ts
@@ -6226,12 +6255,12 @@ sendRequest(code: number, data: MessageParcel, reply: MessageParcel, options: Me
**参数:**
- | 参数名 | 类型 | 必填 | 说明 |
- | ------- | ------------------------------- | ---- | -------------------------------------------------------------------------------------- |
- | code | number | 是 | 本次请求调用的消息码,由通信双方确定。如果接口由IDL工具生成,则消息代码由IDL自动生成。 |
+ | 参数名 | 类型 | 必填 | 说明 |
+ | ------- | ----------------------------------------- | ---- | -------------------------------------------------------------------------------------- |
+ | code | number | 是 | 本次请求调用的消息码,由通信双方确定。如果接口由IDL工具生成,则消息代码由IDL自动生成。 |
| data | [MessageParcel](#messageparceldeprecated) | 是 | 保存待发送数据的 MessageParcel对象。 |
| reply | [MessageParcel](#messageparceldeprecated) | 是 | 接收应答数据的MessageParcel对象。 |
- | options | [MessageOption](#messageoption) | 是 | 本次请求的同异步模式,默认同步调用。 |
+ | options | [MessageOption](#messageoption) | 是 | 本次请求的同异步模式,默认同步调用。 |
**返回值:**
@@ -6241,10 +6270,12 @@ sendRequest(code: number, data: MessageParcel, reply: MessageParcel, options: Me
**示例:**
- 获取服务
+ Stage模型的应用在获取服务前需要先获取context,具体方法可参考[获取context](#获取context)
```ts
- import FA from "@ohos.ability.featureAbility";
+ //仅FA模型需要导入@ohos.ability.featureAbility
+ //import FA from "@ohos.ability.featureAbility";
+
let proxy;
let connect = {
onConnect: function(elementName, remoteProxy) {
@@ -6262,7 +6293,11 @@ sendRequest(code: number, data: MessageParcel, reply: MessageParcel, options: Me
"bundleName": "com.ohos.server",
"abilityName": "com.ohos.server.EntryAbility",
};
- FA.connectAbility(want, connect);
+
+ //FA模型使用此方法连接服务
+ //FA.connectAbility(want,connect);
+
+ globalThis.context.connectServiceExtensionAbility(want, connect);
```
上述onConnect回调函数中的proxy对象需要等ability异步连接成功后才会被赋值,然后才可调用proxy对象的sendRequest接口方法发送消息
@@ -6302,20 +6337,22 @@ sendMessageRequest(code: number, data: MessageSequence, reply: MessageSequence,
**参数:**
- | 参数名 | 类型 | 必填 | 说明 |
- | -------- | ---------------------------------- | ---- | -------------------------------------------------------------------------------------- |
- | code | number | 是 | 本次请求调用的消息码,由通信双方确定。如果接口由IDL工具生成,则消息代码由IDL自动生成。 |
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | ------------------------------------ | ---- | -------------------------------------------------------------------------------------- |
+ | code | number | 是 | 本次请求调用的消息码,由通信双方确定。如果接口由IDL工具生成,则消息代码由IDL自动生成。 |
| data | [MessageSequence](#messagesequence9) | 是 | 保存待发送数据的 MessageSequence对象。 |
| reply | [MessageSequence](#messagesequence9) | 是 | 接收应答数据的MessageSequence对象。 |
- | options | [MessageOption](#messageoption) | 是 | 本次请求的同异步模式,默认同步调用。 |
- | callback | AsyncCallback<RequestResult> | 是 | 接收发送结果的回调。 |
+ | options | [MessageOption](#messageoption) | 是 | 本次请求的同异步模式,默认同步调用。 |
+ | callback | AsyncCallback<RequestResult> | 是 | 接收发送结果的回调。 |
**示例:**
-
- 获取服务
+
+ Stage模型的应用在获取服务前需要先获取context,具体方法可参考[获取context](#获取context)
```ts
- import FA from "@ohos.ability.featureAbility";
+ //仅FA模型需要导入@ohos.ability.featureAbility
+ //import FA from "@ohos.ability.featureAbility";
+
let proxy;
let connect = {
onConnect: function(elementName, remoteProxy) {
@@ -6346,7 +6383,11 @@ sendMessageRequest(code: number, data: MessageSequence, reply: MessageSequence,
result.data.reclaim();
result.reply.reclaim();
}
- FA.connectAbility(want, connect);
+
+ //FA模型使用此方法链接服务
+ //FA.connectAbility(want,connect);
+
+ globalThis.context.connectServiceExtensionAbility(want, connect);
```
上述onConnect回调函数中的proxy对象需要等ability异步连接成功后才会被赋值,然后才可调用proxy对象的sendMessageRequest接口方法发送消息
@@ -6358,7 +6399,7 @@ sendMessageRequest(code: number, data: MessageSequence, reply: MessageSequence,
data.writeInt(1);
data.writeString("hello");
try {
- proxy.sendRequest(1, data, reply, option, sendRequestCallback);
+ proxy.sendMessageRequest(1, data, reply, option, sendRequestCallback);
} catch(error) {
console.info("rpc send sequence request fail, errorCode " + error.code);
console.info("rpc send sequence request fail, errorMessage " + error.message);
@@ -6377,20 +6418,22 @@ sendRequest(code: number, data: MessageParcel, reply: MessageParcel, options: Me
**参数:**
- | 参数名 | 类型 | 必填 | 说明 |
- | -------- | -------------------------------------- | ---- | -------------------------------------------------------------------------------------- |
- | code | number | 是 | 本次请求调用的消息码,由通信双方确定。如果接口由IDL工具生成,则消息代码由IDL自动生成。 |
- | data | [MessageParcel](#messageparceldeprecated) | 是 | 保存待发送数据的 MessageParcel对象。 |
- | reply | [MessageParcel](#messageparceldeprecated) | 是 | 接收应答数据的MessageParcel对象。 |
- | options | [MessageOption](#messageoption) | 是 | 本次请求的同异步模式,默认同步调用。 |
- | callback | AsyncCallback<SendRequestResult> | 是 | 接收发送结果的回调。 |
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | ----------------------------------------- | ---- | -------------------------------------------------------------------------------------- |
+ | code | number | 是 | 本次请求调用的消息码,由通信双方确定。如果接口由IDL工具生成,则消息代码由IDL自动生成。 |
+ | data | [MessageParcel](#messageparceldeprecated) | 是 | 保存待发送数据的 MessageParcel对象。 |
+ | reply | [MessageParcel](#messageparceldeprecated) | 是 | 接收应答数据的MessageParcel对象。 |
+ | options | [MessageOption](#messageoption) | 是 | 本次请求的同异步模式,默认同步调用。 |
+ | callback | AsyncCallback<SendRequestResult> | 是 | 接收发送结果的回调。 |
**示例:**
- 获取服务
+ Stage模型的应用在获取服务前需要先获取context,具体方法可参考[获取context](#获取context)
```ts
- import FA from "@ohos.ability.featureAbility";
+ //仅FA模型需要导入@ohos.ability.featureAbility
+ //import FA from "@ohos.ability.featureAbility";
+
let proxy;
let connect = {
onConnect: function(elementName, remoteProxy) {
@@ -6408,7 +6451,7 @@ sendRequest(code: number, data: MessageParcel, reply: MessageParcel, options: Me
"bundleName": "com.ohos.server",
"abilityName": "com.ohos.server.EntryAbility",
};
- function sendRequestCallback(result) {
+ function sendRequestCallback(result) {
if (result.errCode === 0) {
console.log("sendRequest got result");
result.reply.readException();
@@ -6421,7 +6464,11 @@ sendRequest(code: number, data: MessageParcel, reply: MessageParcel, options: Me
result.data.reclaim();
result.reply.reclaim();
}
- FA.connectAbility(want, connect);
+
+ //FA模型使用此方法链接服务
+ //FA.connectAbility(want,connect);
+
+ globalThis.context.connectServiceExtensionAbility(want, connect);
```
上述onConnect回调函数中的proxy对象需要等ability异步连接成功后才会被赋值,然后才可调用proxy对象的sendRequest接口方法发送消息
@@ -6460,22 +6507,24 @@ getLocalInterface(interface: string): IRemoteBroker
以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md)
| 错误码ID | 错误信息 |
- | ------- | -------- |
- | 1900006 | only remote object permitted |
+ | -------- | -------- |
+ | 1900006 | only remote object permitted |
**示例:**
- 获取服务
+ Stage模型的应用在获取服务前需要先获取context,具体方法可参考[获取context](#获取context)
```ts
- import FA from "@ohos.ability.featureAbility";
+ //仅FA模型需要导入@ohos.ability.featureAbility
+ //import FA from "@ohos.ability.featureAbility";
+
let proxy;
let connect = {
onConnect: function(elementName, remoteProxy) {
console.log("RpcClient: js onConnect called.");
proxy = remoteProxy;
},
- onDisconnect: function (elementName) {
+ onDisconnect: function(elementName) {
console.log("RpcClient: onDisconnect");
},
onFailed: function() {
@@ -6483,10 +6532,14 @@ getLocalInterface(interface: string): IRemoteBroker
}
};
let want = {
- "bundleName":"com.ohos.server",
- "abilityName":"com.ohos.server.EntryAbility",
+ "bundleName": "com.ohos.server",
+ "abilityName": "com.ohos.server.EntryAbility",
};
- FA.connectAbility(want, connect);
+
+ //FA模型使用此方法连接服务
+ //FA.connectAbility(want,connect);
+
+ globalThis.context.connectServiceExtensionAbility(want, connect);
```
上述onConnect回调函数中的proxy对象需要等ability异步连接成功后才会被赋值,然后才可调用proxy对象的getLocalInterface接口方法查询接口对象
@@ -6525,17 +6578,19 @@ queryLocalInterface(interface: string): IRemoteBroker
**示例:**
- 获取服务
+ Stage模型的应用在获取服务前需要先获取context,具体方法可参考[获取context](#获取context)
```ts
- import FA from "@ohos.ability.featureAbility";
+ //仅FA模型需要导入@ohos.ability.featureAbility
+ //import FA from "@ohos.ability.featureAbility";
+
let proxy;
let connect = {
onConnect: function(elementName, remoteProxy) {
console.log("RpcClient: js onConnect called.");
proxy = remoteProxy;
},
- onDisconnect: function (elementName) {
+ onDisconnect: function(elementName) {
console.log("RpcClient: onDisconnect");
},
onFailed: function() {
@@ -6543,12 +6598,16 @@ queryLocalInterface(interface: string): IRemoteBroker
}
};
let want = {
- "bundleName":"com.ohos.server",
- "abilityName":"com.ohos.server.EntryAbility",
+ "bundleName": "com.ohos.server",
+ "abilityName": "com.ohos.server.EntryAbility",
};
- FA.connectAbility(want, connect);
- ```
+ //FA模型使用此方法连接服务
+ //FA.connectAbility(want,connect);
+
+ globalThis.context.connectServiceExtensionAbility(want, connect);
+ ```
+
上述onConnect回调函数中的proxy对象需要等ability异步连接成功后才会被赋值,然后才可调用proxy对象的queryLocalInterface接口获取接口对象
```ts
@@ -6576,15 +6635,17 @@ registerDeathRecipient(recipient: DeathRecipient, flags: number): void
以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md)
| 错误码ID | 错误信息 |
- | ------- | -------- |
- | 1900008 | proxy or remote object is invalid |
+ | -------- | -------- |
+ | 1900008 | proxy or remote object is invalid |
**示例:**
- 获取服务
+ Stage模型的应用在获取服务前需要先获取context,具体方法可参考[获取context](#获取context)
```ts
- import FA from "@ohos.ability.featureAbility";
+ //仅FA模型需要导入@ohos.ability.featureAbility
+ //import FA from "@ohos.ability.featureAbility";
+
let proxy;
let connect = {
onConnect: function(elementName, remoteProxy) {
@@ -6602,11 +6663,15 @@ registerDeathRecipient(recipient: DeathRecipient, flags: number): void
"bundleName": "com.ohos.server",
"abilityName": "com.ohos.server.EntryAbility",
};
- FA.connectAbility(want, connect);
+
+ //FA模型使用此方法连接服务
+ //FA.connectAbility(want,connect);
+
+ globalThis.context.connectServiceExtensionAbility(want, connect);
```
上述onConnect回调函数中的proxy对象需要等ability异步连接成功后才会被赋值,然后才可调用proxy对象的registerDeathRecipient接口注册死亡回调
-
+
```ts
class MyDeathRecipient {
onRemoteDied() {
@@ -6641,16 +6706,18 @@ addDeathRecipient(recipient: DeathRecipient, flags: number): boolean
**返回值:**
- | 类型 | 说明 |
- | ------- | --------------------------------------------- |
+ | 类型 | 说明 |
+ | ------- | ---------------------------------------- |
| boolean | true:回调注册成功,false:回调注册失败。|
**示例:**
- 获取服务
+ Stage模型的应用在获取服务前需要先获取context,具体方法可参考[获取context](#获取context)
```ts
- import FA from "@ohos.ability.featureAbility";
+ //仅FA模型需要导入@ohos.ability.featureAbility
+ //import FA from "@ohos.ability.featureAbility";
+
let proxy;
let connect = {
onConnect: function(elementName, remoteProxy) {
@@ -6668,9 +6735,13 @@ addDeathRecipient(recipient: DeathRecipient, flags: number): boolean
"bundleName": "com.ohos.server",
"abilityName": "com.ohos.server.EntryAbility",
};
- FA.connectAbility(want, connect);
- ```
+ //FA模型使用此方法连接服务
+ //FA.connectAbility(want,connect);
+
+ globalThis.context.connectServiceExtensionAbility(want, connect);
+ ```
+
上述onConnect回调函数中的proxy对象需要等ability异步连接成功后才会被赋值,然后才可调用proxy对象的addDeathRecippient接口方法新增死亡回调
```ts
@@ -6703,15 +6774,17 @@ unregisterDeathRecipient(recipient: DeathRecipient, flags: number): void
以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md)
| 错误码ID | 错误信息 |
- | ------- | -------- |
- | 1900008 | proxy or remote object is invalid |
+ | -------- | -------- |
+ | 1900008 | proxy or remote object is invalid |
**示例:**
- 获取服务
+ Stage模型的应用在获取服务前需要先获取context,具体方法可参考[获取context](#获取context)
```ts
- import FA from "@ohos.ability.featureAbility";
+ //仅FA模型需要导入@ohos.ability.featureAbility
+ //import FA from "@ohos.ability.featureAbility";
+
let proxy;
let connect = {
onConnect: function(elementName, remoteProxy) {
@@ -6729,9 +6802,13 @@ unregisterDeathRecipient(recipient: DeathRecipient, flags: number): void
"bundleName": "com.ohos.server",
"abilityName": "com.ohos.server.EntryAbility",
};
- FA.connectAbility(want, connect);
- ```
+ //FA模型使用此方法连接服务
+ //FA.connectAbility(want,connect);
+
+ globalThis.context.connectServiceExtensionAbility(want, connect);
+ ```
+
上述onConnect回调函数中的proxy对象需要等ability异步连接成功后才会被赋值,然后才可调用proxy对象的unregisterDeathRecipient接口方法注销死亡回调
```ts
@@ -6769,16 +6846,18 @@ removeDeathRecipient(recipient: DeathRecipient, flags: number): boolean
**返回值:**
- | 类型 | 说明 |
- | ------- | --------------------------------------------- |
+ | 类型 | 说明 |
+ | ------- | ---------------------------------------- |
| boolean | true:回调注销成功,false:回调注销失败。|
**示例:**
- 获取服务
+ Stage模型的应用在获取服务前需要先获取context,具体方法可参考[获取context](#获取context)
```ts
- import FA from "@ohos.ability.featureAbility";
+ //仅FA模型需要导入@ohos.ability.featureAbility
+ //import FA from "@ohos.ability.featureAbility";
+
let proxy;
let connect = {
onConnect: function(elementName, remoteProxy) {
@@ -6796,9 +6875,13 @@ removeDeathRecipient(recipient: DeathRecipient, flags: number): boolean
"bundleName": "com.ohos.server",
"abilityName": "com.ohos.server.EntryAbility",
};
- FA.connectAbility(want, connect);
- ```
+ //FA模型使用此方法连接服务
+ //FA.connectAbility(want,connect);
+
+ globalThis.context.connectServiceExtensionAbility(want, connect);
+ ```
+
上述onConnect回调函数中的proxy对象需要等ability异步连接成功后才会被赋值,然后才可调用proxy对象的removeDeathRecipient接口方法去注册死亡回调
```ts
@@ -6831,16 +6914,18 @@ getDescriptor(): string
以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md)
| 错误码ID | 错误信息 |
- | -------- | ------- |
- | 1900008 | proxy or remote object is invalid |
- | 1900007 | communication failed |
+ | -------- | -------- |
+ | 1900008 | proxy or remote object is invalid |
+ | 1900007 | communication failed |
**示例:**
- 获取服务
+ Stage模型的应用在获取服务前需要先获取context,具体方法可参考[获取context](#获取context)
```ts
- import FA from "@ohos.ability.featureAbility";
+ //仅FA模型需要导入@ohos.ability.featureAbility
+ //import FA from "@ohos.ability.featureAbility";
+
let proxy;
let connect = {
onConnect: function(elementName, remoteProxy) {
@@ -6858,7 +6943,11 @@ getDescriptor(): string
"bundleName": "com.ohos.server",
"abilityName": "com.ohos.server.EntryAbility",
};
- FA.connectAbility(want, connect);
+
+ //FA模型使用此方法连接服务
+ //FA.connectAbility(want,connect);
+
+ globalThis.context.connectServiceExtensionAbility(want, connect);
```
上述onConnect回调函数中的proxy对象需要等ability异步连接成功后才会被赋值,然后才可调用proxy对象的getDescriptor接口方法获取对象的接口描述符
@@ -6890,10 +6979,12 @@ getInterfaceDescriptor(): string
**示例:**
- 获取服务
+ Stage模型的应用在获取服务前需要先获取context,具体方法可参考[获取context](#获取context)
```ts
- import FA from "@ohos.ability.featureAbility";
+ //仅FA模型需要导入@ohos.ability.featureAbility
+ //import FA from "@ohos.ability.featureAbility";
+
let proxy;
let connect = {
onConnect: function(elementName, remoteProxy) {
@@ -6911,9 +7002,13 @@ getInterfaceDescriptor(): string
"bundleName": "com.ohos.server",
"abilityName": "com.ohos.server.EntryAbility",
};
- FA.connectAbility(want, connect);
- ```
+ //FA模型使用此方法连接服务
+ //FA.connectAbility(want,connect);
+
+ globalThis.context.connectServiceExtensionAbility(want, connect);
+ ```
+
上述onConnect回调函数中的proxy对象需要等ability异步连接成功后才会被赋值,然后才可调用proxy对象的getInterfaceDescriptor接口方法查询当前代理对象接口的描述符
```ts
@@ -6931,16 +7026,18 @@ isObjectDead(): boolean
**返回值:**
- | 类型 | 说明 |
- | ------- | --------------------------------------------------------- |
- | boolean | true:对应的对象已经死亡,false:对应的对象未死亡|
+ | 类型 | 说明 |
+ | ------- | ------------------------------------------------- |
+ | boolean | true:对应的对象已经死亡,false:对应的对象未死亡 |
**示例:**
- 获取服务
+ Stage模型的应用在获取服务前需要先获取context,具体方法可参考[获取context](#获取context)
```ts
- import FA from "@ohos.ability.featureAbility";
+ //仅FA模型需要导入@ohos.ability.featureAbility
+ //import FA from "@ohos.ability.featureAbility";
+
let proxy;
let connect = {
onConnect: function(elementName, remoteProxy) {
@@ -6958,7 +7055,11 @@ isObjectDead(): boolean
"bundleName": "com.ohos.server",
"abilityName": "com.ohos.server.EntryAbility",
};
- FA.connectAbility(want, connect);
+
+ //FA模型使用此方法连接服务
+ //FA.connectAbility(want,connect);
+
+ globalThis.context.connectServiceExtensionAbility(want, connect);
```
上述onConnect回调函数中的proxy对象需要等ability异步连接成功后才会被赋值,然后才可调用proxy对象的isObjectDead接口方法判断当前对象是否已经死亡
@@ -6976,10 +7077,10 @@ isObjectDead(): boolean
| 名称 | 值 | 说明 |
| ------------- | ---- | ----------------------------------------------------------- |
- | TF_SYNC | 0 | 同步调用标识。 |
- | TF_ASYNC | 1 | 异步调用标识。 |
+ | TF_SYNC | 0 | 同步调用标识。 |
+ | TF_ASYNC | 1 | 异步调用标识。 |
| TF_ACCEPT_FDS | 0x10 | 指示sendMessageRequest9+接口可以返回文件描述符。 |
- | TF_WAIT_TIME | 8 | 默认等待时间(单位/秒)。 |
+ | TF_WAIT_TIME | 8 | 默认等待时间(单位/秒)。 |
### constructor9+
@@ -7041,9 +7142,9 @@ isAsync(): boolean;
**返回值:**
- | 类型 | 说明 |
- | ------- | ------------------------------------ |
- | boolean | true:同步调用成功,false:异步调用成功。 |
+ | 类型 | 说明 |
+ | ------- | ---------------------------------------- |
+ | boolean | true:同步调用成功,false:异步调用成功。|
**示例:**
@@ -7349,8 +7450,8 @@ static isLocalCalling(): boolean
**返回值:**
- | 类型 | 说明 |
- | ------- | --------------------------------------------------------- |
+ | 类型 | 说明 |
+ | ------- | -------------------------------------------------- |
| boolean | true:调用在同一台设备,false:调用未在同一台设备。|
**示例:**
@@ -7522,8 +7623,8 @@ static setCallingIdentity(identity: string): boolean
**返回值:**
- | 类型 | 说明 |
- | ------- | ----------------------------------------- |
+ | 类型 | 说明 |
+ | ------- | ---------------------------------|
| boolean | true:设置成功,false:设置失败。|
**示例:**
@@ -7575,17 +7676,17 @@ sendRequest(code: number, data: MessageParcel, reply: MessageParcel, options: Me
**参数:**
- | 参数名 | 类型 | 必填 | 说明 |
- | ------- | ------------------------------- | ---- | -------------------------------------------------------------------------------------- |
- | code | number | 是 | 本次请求调用的消息码,由通信双方确定。如果接口由IDL工具生成,则消息代码由IDL自动生成。 |
+ | 参数名 | 类型 | 必填 | 说明 |
+ | ------- | ----------------------------------------- | ---- | -------------------------------------------------------------------------------------- |
+ | code | number | 是 | 本次请求调用的消息码,由通信双方确定。如果接口由IDL工具生成,则消息代码由IDL自动生成。 |
| data | [MessageParcel](#messageparceldeprecated) | 是 | 保存待发送数据的 MessageParcel对象。 |
| reply | [MessageParcel](#messageparceldeprecated) | 是 | 接收应答数据的MessageParcel对象。 |
- | options | [MessageOption](#messageoption) | 是 | 本次请求的同异步模式,默认同步调用。 |
+ | options | [MessageOption](#messageoption) | 是 | 本次请求的同异步模式,默认同步调用。 |
**返回值:**
- | 类型 | 说明 |
- | ------- | --------------------------------------------- |
+ | 类型 | 说明 |
+ | ------- | -------------------------------- |
| boolean | true:发送成功,false:发送失败。|
**示例:**
@@ -7641,12 +7742,12 @@ sendRequest(code: number, data: MessageParcel, reply: MessageParcel, options: Me
**参数:**
- | 参数名 | 类型 | 必填 | 说明 |
- | ------- | ------------------------------- | ---- | -------------------------------------------------------------------------------------- |
- | code | number | 是 | 本次请求调用的消息码,由通信双方确定。如果接口由IDL工具生成,则消息代码由IDL自动生成。 |
+ | 参数名 | 类型 | 必填 | 说明 |
+ | ------- | ----------------------------------------- | ---- | -------------------------------------------------------------------------------------- |
+ | code | number | 是 | 本次请求调用的消息码,由通信双方确定。如果接口由IDL工具生成,则消息代码由IDL自动生成。 |
| data | [MessageParcel](#messageparceldeprecated) | 是 | 保存待发送数据的 MessageParcel对象。 |
| reply | [MessageParcel](#messageparceldeprecated) | 是 | 接收应答数据的MessageParcel对象。 |
- | options | [MessageOption](#messageoption) | 是 | 本次请求的同异步模式,默认同步调用。 |
+ | options | [MessageOption](#messageoption) | 是 | 本次请求的同异步模式,默认同步调用。 |
**返回值:**
@@ -7711,12 +7812,12 @@ sendMessageRequest(code: number, data: MessageSequence, reply: MessageSequence,
**参数:**
- | 参数名 | 类型 | 必填 | 说明 |
- | ------- | ------------------------------- | ---- | -------------------------------------------------------------------------------------- |
- | code | number | 是 | 本次请求调用的消息码,由通信双方确定。如果接口由IDL工具生成,则消息代码由IDL自动生成。 |
+ | 参数名 | 类型 | 必填 | 说明 |
+ | ------- | ------------------------------------ | ---- | -------------------------------------------------------------------------------------- |
+ | code | number | 是 | 本次请求调用的消息码,由通信双方确定。如果接口由IDL工具生成,则消息代码由IDL自动生成。 |
| data | [MessageSequence](#messagesequence9) | 是 | 保存待发送数据的 MessageSequence对象。 |
| reply | [MessageSequence](#messagesequence9) | 是 | 接收应答数据的MessageSequence对象。 |
- | options | [MessageOption](#messageoption) | 是 | 本次请求的同异步模式,默认同步调用。 |
+ | options | [MessageOption](#messageoption) | 是 | 本次请求的同异步模式,默认同步调用。 |
**返回值:**
@@ -7767,13 +7868,13 @@ sendMessageRequest(code: number, data: MessageSequence, reply: MessageSequence,
**参数:**
- | 参数名 | 类型 | 必填 | 说明 |
- | ------------- | ---------------------------------- | ---- | -------------------------------------------------------------------------------------- |
- | code | number | 是 | 本次请求调用的消息码,由通信双方确定。如果接口由IDL工具生成,则消息代码由IDL自动生成。 |
+ | 参数名 | 类型 | 必填 | 说明 |
+ | ------------- | ------------------------------------ | ---- | -------------------------------------------------------------------------------------- |
+ | code | number | 是 | 本次请求调用的消息码,由通信双方确定。如果接口由IDL工具生成,则消息代码由IDL自动生成。 |
| data | [MessageSequence](#messagesequence9) | 是 | 保存待发送数据的 MessageSequence对象。 |
| reply | [MessageSequence](#messagesequence9) | 是 | 接收应答数据的MessageSequence对象。 |
- | options | [MessageOption](#messageoption) | 是 | 本次请求的同异步模式,默认同步调用。 |
- | AsyncCallback | AsyncCallback<RequestResult> | 是 | 接收发送结果的回调。 |
+ | options | [MessageOption](#messageoption) | 是 | 本次请求的同异步模式,默认同步调用。 |
+ | AsyncCallback | AsyncCallback<RequestResult> | 是 | 接收发送结果的回调。 |
**示例:**
@@ -7817,13 +7918,13 @@ sendRequest(code: number, data: MessageParcel, reply: MessageParcel, options: Me
**参数:**
- | 参数名 | 类型 | 必填 | 说明 |
- | ------------- | -------------------------------------- | ---- | -------------------------------------------------------------------------------------- |
- | code | number | 是 | 本次请求调用的消息码,由通信双方确定。如果接口由IDL工具生成,则消息代码由IDL自动生成。 |
- | data | [MessageParcel](#messageparceldeprecated) | 是 | 保存待发送数据的 MessageParcel对象。 |
- | reply | [MessageParcel](#messageparceldeprecated) | 是 | 接收应答数据的MessageParcel对象。 |
- | options | [MessageOption](#messageoption) | 是 | 本次请求的同异步模式,默认同步调用。 |
- | AsyncCallback | AsyncCallback<SendRequestResult> | 是 | 接收发送结果的回调。 |
+ | 参数名 | 类型 | 必填 | 说明 |
+ | ------------- | ----------------------------------------- | ---- | -------------------------------------------------------------------------------------- |
+ | code | number | 是 | 本次请求调用的消息码,由通信双方确定。如果接口由IDL工具生成,则消息代码由IDL自动生成。 |
+ | data | [MessageParcel](#messageparceldeprecated) | 是 | 保存待发送数据的 MessageParcel对象。 |
+ | reply | [MessageParcel](#messageparceldeprecated) | 是 | 接收应答数据的MessageParcel对象。 |
+ | options | [MessageOption](#messageoption) | 是 | 本次请求的同异步模式,默认同步调用。 |
+ | AsyncCallback | AsyncCallback<SendRequestResult> | 是 | 接收发送结果的回调。 |
**示例:**
@@ -7881,17 +7982,17 @@ sendMessageRequest请求的响应处理函数,服务端在该函数里处理
**参数:**
- | 参数名 | 类型 | 必填 | 说明 |
- | ------ | ------------------------------- | ---- | --------------------------------------- |
- | code | number | 是 | 对端发送的服务请求码。 |
+ | 参数名 | 类型 | 必填 | 说明 |
+ | ------ | ----------------------------------------- | ---- | --------------------------------------- |
+ | code | number | 是 | 对端发送的服务请求码。 |
| data | [MessageParcel](#messageparceldeprecated) | 是 | 携带客户端调用参数的MessageParcel对象。 |
| reply | [MessageParcel](#messageparceldeprecated) | 是 | 写入结果的MessageParcel对象。 |
- | option | [MessageOption](#messageoption) | 是 | 指示操作是同步还是异步。 |
+ | option | [MessageOption](#messageoption) | 是 | 指示操作是同步还是异步。 |
**返回值:**
- | 类型 | 说明 |
- | ------- | ----------------------------------------- |
+ | 类型 | 说明 |
+ | ------- | -------------------------------- |
| boolean | true:操作成功,false:操作失败。|
**示例:**
@@ -7942,17 +8043,17 @@ sendMessageRequest请求的响应处理函数,服务端在该函数里同步
**参数:**
- | 参数名 | 类型 | 必填 | 说明 |
- | ------ | ------------------------------- | ---- | ----------------------------------------- |
- | code | number | 是 | 对端发送的服务请求码。 |
+ | 参数名 | 类型 | 必填 | 说明 |
+ | ------ | ------------------------------------ | ---- | ----------------------------------------- |
+ | code | number | 是 | 对端发送的服务请求码。 |
| data | [MessageSequence](#messagesequence9) | 是 | 携带客户端调用参数的MessageSequence对象。 |
| reply | [MessageSequence](#messagesequence9) | 是 | 写入结果的MessageSequence对象。 |
- | option | [MessageOption](#messageoption) | 是 | 指示操作是同步还是异步。 |
+ | option | [MessageOption](#messageoption) | 是 | 指示操作是同步还是异步。 |
**返回值:**
- | 类型 | 说明 |
- | ----------------- | ---------------------------------------------------------------------------------------------- |
+ | 类型 | 说明 |
+ | ----------------- | ----------------------------------------------------------------------------------------------- |
| boolean | 若在onRemoteMessageRequest中同步地处理请求,则返回一个布尔值:true:操作成功,false:操作失败。 |
| Promise\ | 若在onRemoteMessageRequest中异步地处理请求,则返回一个Promise对象。 |
@@ -8233,8 +8334,8 @@ getDescriptor(): string
以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md)
| 错误码ID | 错误信息 |
- | ------- | -------- |
- | 1900008 | proxy or remote object is invalid |
+ | -------- | -------- |
+ | 1900008 | proxy or remote object is invalid |
**示例:**
@@ -8625,8 +8726,8 @@ mapTypedAshmem(mapType: number): void
以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md)
| 错误码ID | 错误信息 |
- | ------- | ------ |
- | 1900001 | call mmap function failed |
+ | -------- | -------- |
+ | 1900001 | call mmap function failed |
**示例:**
@@ -8658,8 +8759,8 @@ mapAshmem(mapType: number): boolean
**返回值:**
- | 类型 | 说明 |
- | ------- | ----------------------------------------- |
+ | 类型 | 说明 |
+ | ------- | -------------------------------- |
| boolean | true:映射成功,false:映射失败。|
**示例:**
@@ -8683,8 +8784,8 @@ mapReadWriteAshmem(): void
以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md)
| 错误码ID | 错误信息 |
- | ------- | -------- |
- | 1900001 | call mmap function failed |
+ | -------- | -------- |
+ | 1900001 | call mmap function failed |
**示例:**
@@ -8710,8 +8811,8 @@ mapReadAndWriteAshmem(): boolean
**返回值:**
- | 类型 | 说明 |
- | ------- | ----------------------------------------- |
+ | 类型 | 说明 |
+ | ------- | -------------------------------- |
| boolean | true:映射成功,false:映射失败。|
**示例:**
@@ -8735,8 +8836,8 @@ mapReadonlyAshmem(): void
以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md)
| 错误码ID | 错误信息 |
- | ------- | -------- |
- | 1900001 | call mmap function failed |
+ | -------- | -------- |
+ | 1900001 | call mmap function failed |
**示例:**
@@ -8762,8 +8863,8 @@ mapReadOnlyAshmem(): boolean
**返回值:**
- | 类型 | 说明 |
- | ------- | ----------------------------------------- |
+ | 类型 | 说明 |
+ | ------- | -------------------------------- |
| boolean | true:映射成功,false:映射失败。|
**示例:**
@@ -8793,8 +8894,8 @@ setProtectionType(protectionType: number): void
以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md)
| 错误码ID | 错误信息 |
- | -------- | ------- |
- | 1900002 | call os ioctl function failed |
+ | -------- | -------- |
+ | 1900002 | call os ioctl function failed |
**示例:**
@@ -8826,8 +8927,8 @@ setProtection(protectionType: number): boolean
**返回值:**
- | 类型 | 说明 |
- | ------- | ----------------------------------------- |
+ | 类型 | 说明 |
+ | ------- | -------------------------------- |
| boolean | true:设置成功,false:设置失败。|
**示例:**
@@ -8859,8 +8960,8 @@ writeAshmem(buf: number[], size: number, offset: number): void
以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md)
| 错误码ID | 错误信息 |
- | ------- | -------- |
- | 1900003 | write to ashmem failed |
+ | -------- | -------- |
+ | 1900003 | write to ashmem failed |
**示例:**
@@ -8896,9 +8997,9 @@ writeToAshmem(buf: number[], size: number, offset: number): boolean
**返回值:**
- | 类型 | 说明 |
- | ------- | ----------------------------------------------------------------------------------------- |
- | boolean | true:如果数据写入成功,false:在其他情况下,如数据写入越界或未获得写入权限。。 |
+ | 类型 | 说明 |
+ | ------- | ----------------------------------------------------------------------------- |
+ | boolean | true:如果数据写入成功,false:在其他情况下,如数据写入越界或未获得写入权限。 |
**示例:**
@@ -8936,9 +9037,9 @@ readAshmem(size: number, offset: number): number[]
以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md)
- | 错误码ID | 错误信息 |
+ | 错误码ID | 错误信息 |
| -------- | -------- |
- | 1900004 | read from ashmem failed |
+ | 1900004 | read from ashmem failed |
**示例:**
@@ -8981,7 +9082,7 @@ readFromAshmem(size: number, offset: number): number[]
**示例:**
- ```ts
+ ``` ts
let ashmem = rpc.Ashmem.createAshmem("ashmem", 1024*1024);
let mapResult = ashmem.mapReadAndWriteAshmem();
console.info("RpcTest map ashmem result is " + mapResult);
@@ -8990,4 +9091,38 @@ readFromAshmem(size: number, offset: number): number[]
console.log("RpcTest: write to Ashmem result is : " + writeResult);
let readResult = ashmem.readFromAshmem(5, 0);
console.log("RpcTest: read to Ashmem result is : " + readResult);
- ```
\ No newline at end of file
+ ```
+
+## 获取context
+
+**示例:**
+
+ ```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");
+ }
+ };
+ ```
+