未验证 提交 01381b17 编写于 作者: Y Yippo 提交者: Gitee

【IPC&RPC-API参考】IPC与RPC通信API参考文档优化整改

Signed-off-by: NYippo <liuyibo12@huawei.com>
上级 5fc39b85
...@@ -4,10 +4,9 @@ ...@@ -4,10 +4,9 @@
> **说明:** > **说明:**
> >
> 本模块首批接口从API version 7开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 > - 本模块首批接口从API version 7开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
> >
> 本模块从API version 9开始支持异常返回功能。 > - 本模块从API version 9开始支持异常返回功能。
## 导入模块 ## 导入模块
...@@ -15,7 +14,6 @@ ...@@ -15,7 +14,6 @@
import rpc from '@ohos.rpc'; import rpc from '@ohos.rpc';
``` ```
## ErrorCode<sup>9+</sup> ## ErrorCode<sup>9+</sup>
从API version 9起,IPC支持异常返回功能。错误码对应数值及含义如下。 从API version 9起,IPC支持异常返回功能。错误码对应数值及含义如下。
...@@ -42,11 +40,13 @@ import rpc from '@ohos.rpc'; ...@@ -42,11 +40,13 @@ import rpc from '@ohos.rpc';
## MessageSequence<sup>9+</sup> ## MessageSequence<sup>9+</sup>
在RPC过程中,发送方可以使用MessageSequence提供的写方法,将待发送的数据以特定格式写入该对象。接收方可以使用MessageSequence提供的读方法从该对象中读取特定格式的数据。数据格式包括:基础类型及数组、IPC对象、接口描述符和自定义序列化对象。 在RPC或IPC过程中,发送方可以使用MessageSequence提供的写方法,将待发送的数据以特定格式写入该对象。接收方可以使用MessageSequence提供的读方法从该对象中读取特定格式的数据。数据格式包括:基础类型及数组、IPC对象、接口描述符和自定义序列化对象。
### create ### create
create(): MessageSequence static create(): MessageSequence
**描述**
静态方法,创建MessageSequence对象。 静态方法,创建MessageSequence对象。
...@@ -69,6 +69,8 @@ import rpc from '@ohos.rpc'; ...@@ -69,6 +69,8 @@ import rpc from '@ohos.rpc';
reclaim(): void reclaim(): void
**描述**
释放不再使用的MessageSequence对象。 释放不再使用的MessageSequence对象。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -84,6 +86,8 @@ reclaim(): void ...@@ -84,6 +86,8 @@ reclaim(): void
writeRemoteObject(object: [IRemoteObject](#iremoteobject)): void writeRemoteObject(object: [IRemoteObject](#iremoteobject)): void
**描述**
序列化远程对象并将其写入MessageSequence对象。 序列化远程对象并将其写入MessageSequence对象。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -125,6 +129,8 @@ writeRemoteObject(object: [IRemoteObject](#iremoteobject)): void ...@@ -125,6 +129,8 @@ writeRemoteObject(object: [IRemoteObject](#iremoteobject)): void
readRemoteObject(): IRemoteObject readRemoteObject(): IRemoteObject
**描述**
从MessageSequence读取远程对象。此方法用于反序列化MessageSequence对象以生成IRemoteObject。远程对象按写入MessageSequence的顺序读取。 从MessageSequence读取远程对象。此方法用于反序列化MessageSequence对象以生成IRemoteObject。远程对象按写入MessageSequence的顺序读取。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -167,6 +173,8 @@ readRemoteObject(): IRemoteObject ...@@ -167,6 +173,8 @@ readRemoteObject(): IRemoteObject
writeInterfaceToken(token: string): void writeInterfaceToken(token: string): void
**描述**
将接口描述符写入MessageSequence对象,远端对象可使用该信息校验本次通信。 将接口描述符写入MessageSequence对象,远端对象可使用该信息校验本次通信。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -201,7 +209,9 @@ writeInterfaceToken(token: string): void ...@@ -201,7 +209,9 @@ writeInterfaceToken(token: string): void
readInterfaceToken(): string readInterfaceToken(): string
从MessageSequence中读取接口描述符,接口描述符按写入MessageSequence的顺序读取,本地对象可使用该信息检验本次通信。 **描述**
从MessageSequence对象中读取接口描述符,接口描述符按写入MessageSequence的顺序读取,本地对象可使用该信息检验本次通信。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -219,29 +229,30 @@ readInterfaceToken(): string ...@@ -219,29 +229,30 @@ readInterfaceToken(): string
| ------- | ----- | | ------- | ----- |
| 1900010 | read data from message sequence failed | | 1900010 | read data from message sequence failed |
**示例:** **示例:**
``` ```
class Stub extends rpc.RemoteObject { class Stub extends rpc.RemoteObject {
onRemoteRequest(code, data, reply, option) { onRemoteRequest(code, data, reply, option) {
try { try {
let interfaceToken = data.readInterfaceToken(); let interfaceToken = data.readInterfaceToken();
console.log("RpcServer: interfaceToken is " + interfaceToken); console.log("RpcServer: interfaceToken is " + interfaceToken);
} catch(error) { } catch(error) {
console.info("RpcServer: read interfaceToken failed, errorCode " + error.code); console.info("RpcServer: read interfaceToken failed, errorCode " + error.code);
console.info("RpcServer: read interfaceToken failed, errorMessage " + error.message); console.info("RpcServer: read interfaceToken failed, errorMessage " + error.message);
} }
return true; return true;
} }
} }
``` ```
### getSize ### getSize
getSize(): number getSize(): number
获取当前MessageSequence的数据大小。 **描述**
获取当前创建的MessageSequence对象的数据大小。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -249,7 +260,7 @@ getSize(): number ...@@ -249,7 +260,7 @@ getSize(): number
| 类型 | 说明 | | 类型 | 说明 |
| ------ | ----------------------------------------------- | | ------ | ----------------------------------------------- |
| number | 获取的MessageSequence的数据大小。以字节为单位。 | | number | 获取的MessageSequence实例的数据大小。以字节为单位。 |
**示例:** **示例:**
...@@ -263,7 +274,9 @@ getSize(): number ...@@ -263,7 +274,9 @@ getSize(): number
getCapacity(): number getCapacity(): number
获取当前MessageSequence的容量。 **描述**
获取当前MessageSequence对象的容量大小。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -271,7 +284,7 @@ getCapacity(): number ...@@ -271,7 +284,7 @@ getCapacity(): number
| 类型 | 说明 | | 类型 | 说明 |
| ------ | ----- | | ------ | ----- |
| number | 获取的MessageSequence的容量大小。以字节为单位。 | | number | 获取的MessageSequence实例的容量大小。以字节为单位。 |
**示例:** **示例:**
...@@ -285,7 +298,9 @@ getCapacity(): number ...@@ -285,7 +298,9 @@ getCapacity(): number
setSize(size: number): void setSize(size: number): void
设置MessageSequence实例中包含的数据大小。 **描述**
设置MessageSequence对象中包含的数据大小。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -312,7 +327,9 @@ setSize(size: number): void ...@@ -312,7 +327,9 @@ setSize(size: number): void
setCapacity(size: number): void setCapacity(size: number): void
设置MessageSequence实例的存储容量。 **描述**
设置MessageSequence对象的存储容量。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -347,7 +364,9 @@ setCapacity(size: number): void ...@@ -347,7 +364,9 @@ setCapacity(size: number): void
getWritableBytes(): number getWritableBytes(): number
获取MessageSequence的可写字节空间。 **描述**
获取MessageSequence的可写字节空间大小。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -355,24 +374,26 @@ getWritableBytes(): number ...@@ -355,24 +374,26 @@ getWritableBytes(): number
| 类型 | 说明 | | 类型 | 说明 |
| ------ | ------ | | ------ | ------ |
| number | 获取到的MessageSequence的可写字节空间。以字节为单位。 | | number | 获取到的MessageSequence实例的可写字节空间。以字节为单位。 |
**示例:** **示例:**
``` ```
class Stub extends rpc.RemoteObject { class Stub extends rpc.RemoteObject {
onRemoteRequest(code, data, reply, option) { onRemoteRequest(code, data, reply, option) {
let getWritableBytes = data.getWritableBytes(); let getWritableBytes = data.getWritableBytes();
console.log("RpcServer: getWritableBytes is " + getWritableBytes); console.log("RpcServer: getWritableBytes is " + getWritableBytes);
return true; return true;
} }
} }
``` ```
### getReadableBytes ### getReadableBytes
getReadableBytes(): number getReadableBytes(): number
**描述**
获取MessageSequence的可读字节空间。 获取MessageSequence的可读字节空间。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -381,24 +402,26 @@ getReadableBytes(): number ...@@ -381,24 +402,26 @@ getReadableBytes(): number
| 类型 | 说明 | | 类型 | 说明 |
| ------ | ------- | | ------ | ------- |
| number | 获取到的MessageSequence的可读字节空间。以字节为单位。 | | number | 获取到的MessageSequence实例的可读字节空间。以字节为单位。 |
**示例:** **示例:**
``` ```
class Stub extends rpc.RemoteObject { class Stub extends rpc.RemoteObject {
onRemoteRequest(code, data, reply, option) { onRemoteRequest(code, data, reply, option) {
let result = data.getReadableBytes(); let result = data.getReadableBytes();
console.log("RpcServer: getReadableBytes is " + result); console.log("RpcServer: getReadableBytes is " + result);
return true; return true;
} }
} }
``` ```
### getReadPosition ### getReadPosition
getReadPosition(): number getReadPosition(): number
**描述**
获取MessageSequence的读位置。 获取MessageSequence的读位置。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -421,6 +444,8 @@ getReadPosition(): number ...@@ -421,6 +444,8 @@ getReadPosition(): number
getWritePosition(): number getWritePosition(): number
**描述**
获取MessageSequence的写位置。 获取MessageSequence的写位置。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -444,6 +469,8 @@ getWritePosition(): number ...@@ -444,6 +469,8 @@ getWritePosition(): number
rewindRead(pos: number): void rewindRead(pos: number): void
**描述**
重新偏移读取位置到指定的位置。 重新偏移读取位置到指定的位置。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -476,6 +503,8 @@ rewindRead(pos: number): void ...@@ -476,6 +503,8 @@ rewindRead(pos: number): void
rewindWrite(pos: number): void rewindWrite(pos: number): void
**描述**
重新偏移写位置到指定的位置。 重新偏移写位置到指定的位置。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -506,6 +535,8 @@ rewindWrite(pos: number): void ...@@ -506,6 +535,8 @@ rewindWrite(pos: number): void
writeByte(val: number): void writeByte(val: number): void
**描述**
将字节值写入MessageSequence实例。 将字节值写入MessageSequence实例。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -540,6 +571,8 @@ writeByte(val: number): void ...@@ -540,6 +571,8 @@ writeByte(val: number): void
readByte(): number readByte(): number
**描述**
从MessageSequence实例读取字节值。 从MessageSequence实例读取字节值。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -581,6 +614,8 @@ readByte(): number ...@@ -581,6 +614,8 @@ readByte(): number
writeShort(val: number): void writeShort(val: number): void
**描述**
将短整数值写入MessageSequence实例。 将短整数值写入MessageSequence实例。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -615,6 +650,8 @@ writeShort(val: number): void ...@@ -615,6 +650,8 @@ writeShort(val: number): void
readShort(): number readShort(): number
**描述**
从MessageSequence实例读取短整数值。 从MessageSequence实例读取短整数值。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -656,6 +693,8 @@ readShort(): number ...@@ -656,6 +693,8 @@ readShort(): number
writeInt(val: number): void writeInt(val: number): void
**描述**
将整数值写入MessageSequence实例。 将整数值写入MessageSequence实例。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -690,6 +729,8 @@ writeInt(val: number): void ...@@ -690,6 +729,8 @@ writeInt(val: number): void
readInt(): number readInt(): number
**描述**
从MessageSequence实例读取整数值。 从MessageSequence实例读取整数值。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -731,6 +772,8 @@ readInt(): number ...@@ -731,6 +772,8 @@ readInt(): number
writeLong(val: number): void writeLong(val: number): void
**描述**
将长整数值写入MessageSequence实例。 将长整数值写入MessageSequence实例。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -765,6 +808,8 @@ writeLong(val: number): void ...@@ -765,6 +808,8 @@ writeLong(val: number): void
readLong(): number readLong(): number
**描述**
从MessageSequence实例中读取长整数值。 从MessageSequence实例中读取长整数值。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -806,6 +851,8 @@ readLong(): number ...@@ -806,6 +851,8 @@ readLong(): number
writeFloat(val: number): void writeFloat(val: number): void
**描述**
将浮点值写入MessageSequence实例。 将浮点值写入MessageSequence实例。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -840,6 +887,8 @@ writeFloat(val: number): void ...@@ -840,6 +887,8 @@ writeFloat(val: number): void
readFloat(): number readFloat(): number
**描述**
从MessageSequence实例中读取浮点值。 从MessageSequence实例中读取浮点值。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -881,6 +930,8 @@ readFloat(): number ...@@ -881,6 +930,8 @@ readFloat(): number
writeDouble(val: number): void writeDouble(val: number): void
**描述**
将双精度浮点值写入MessageSequence实例。 将双精度浮点值写入MessageSequence实例。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -915,6 +966,8 @@ writeDouble(val: number): void ...@@ -915,6 +966,8 @@ writeDouble(val: number): void
readDouble(): number readDouble(): number
**描述**
从MessageSequence实例读取双精度浮点值。 从MessageSequence实例读取双精度浮点值。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -956,6 +1009,8 @@ readDouble(): number ...@@ -956,6 +1009,8 @@ readDouble(): number
writeBoolean(val: boolean): void writeBoolean(val: boolean): void
**描述**
将布尔值写入MessageSequence实例。 将布尔值写入MessageSequence实例。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -990,6 +1045,8 @@ writeBoolean(val: boolean): void ...@@ -990,6 +1045,8 @@ writeBoolean(val: boolean): void
readBoolean(): boolean readBoolean(): boolean
**描述**
从MessageSequence实例读取布尔值。 从MessageSequence实例读取布尔值。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -1031,6 +1088,8 @@ readBoolean(): boolean ...@@ -1031,6 +1088,8 @@ readBoolean(): boolean
writeChar(val: number): void writeChar(val: number): void
**描述**
将单个字符值写入MessageSequence实例。 将单个字符值写入MessageSequence实例。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -1065,6 +1124,8 @@ writeChar(val: number): void ...@@ -1065,6 +1124,8 @@ writeChar(val: number): void
readChar(): number readChar(): number
**描述**
从MessageSequence实例中读取单个字符值。 从MessageSequence实例中读取单个字符值。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -1106,6 +1167,8 @@ readChar(): number ...@@ -1106,6 +1167,8 @@ readChar(): number
writeString(val: string): void writeString(val: string): void
**描述**
将字符串值写入MessageSequence实例。 将字符串值写入MessageSequence实例。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -1140,6 +1203,8 @@ writeString(val: string): void ...@@ -1140,6 +1203,8 @@ writeString(val: string): void
readString(): string readString(): string
**描述**
从MessageSequence实例读取字符串值。 从MessageSequence实例读取字符串值。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -1181,6 +1246,8 @@ readString(): string ...@@ -1181,6 +1246,8 @@ readString(): string
writeParcelable(val: Parcelable): void writeParcelable(val: Parcelable): void
**描述**
将自定义序列化对象写入MessageSequence实例。 将自定义序列化对象写入MessageSequence实例。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -1234,6 +1301,8 @@ writeParcelable(val: Parcelable): void ...@@ -1234,6 +1301,8 @@ writeParcelable(val: Parcelable): void
readParcelable(dataIn: Parcelable): void readParcelable(dataIn: Parcelable): void
**描述**
从MessageSequence实例中读取成员变量到指定的对象(dataIn)。 从MessageSequence实例中读取成员变量到指定的对象(dataIn)。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -1290,6 +1359,8 @@ readParcelable(dataIn: Parcelable): void ...@@ -1290,6 +1359,8 @@ readParcelable(dataIn: Parcelable): void
writeByteArray(byteArray: number[]): void writeByteArray(byteArray: number[]): void
**描述**
将字节数组写入MessageSequence实例。 将字节数组写入MessageSequence实例。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -1325,6 +1396,8 @@ writeByteArray(byteArray: number[]): void ...@@ -1325,6 +1396,8 @@ writeByteArray(byteArray: number[]): void
readByteArray(dataIn: number[]): void readByteArray(dataIn: number[]): void
**描述**
从MessageSequence实例读取字节数组。 从MessageSequence实例读取字节数组。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -1367,6 +1440,8 @@ readByteArray(dataIn: number[]): void ...@@ -1367,6 +1440,8 @@ readByteArray(dataIn: number[]): void
readByteArray(): number[] readByteArray(): number[]
**描述**
从MessageSequence实例中读取字节数组。 从MessageSequence实例中读取字节数组。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -1409,6 +1484,8 @@ readByteArray(): number[] ...@@ -1409,6 +1484,8 @@ readByteArray(): number[]
writeShortArray(shortArray: number[]): void writeShortArray(shortArray: number[]): void
**描述**
将短整数数组写入MessageSequence实例。 将短整数数组写入MessageSequence实例。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -1443,6 +1520,8 @@ writeShortArray(shortArray: number[]): void ...@@ -1443,6 +1520,8 @@ writeShortArray(shortArray: number[]): void
readShortArray(dataIn: number[]): void readShortArray(dataIn: number[]): void
**描述**
从MessageSequence实例中读取短整数数组。 从MessageSequence实例中读取短整数数组。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -1484,6 +1563,8 @@ readShortArray(dataIn: number[]): void ...@@ -1484,6 +1563,8 @@ readShortArray(dataIn: number[]): void
readShortArray(): number[] readShortArray(): number[]
**描述**
从MessageSequence实例中读取短整数数组。 从MessageSequence实例中读取短整数数组。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -1525,6 +1606,8 @@ readShortArray(): number[] ...@@ -1525,6 +1606,8 @@ readShortArray(): number[]
writeIntArray(intArray: number[]): void writeIntArray(intArray: number[]): void
**描述**
将整数数组写入MessageSequence实例。 将整数数组写入MessageSequence实例。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -1559,6 +1642,8 @@ writeIntArray(intArray: number[]): void ...@@ -1559,6 +1642,8 @@ writeIntArray(intArray: number[]): void
readIntArray(dataIn: number[]): void readIntArray(dataIn: number[]): void
**描述**
从MessageSequence实例中读取整数数组。 从MessageSequence实例中读取整数数组。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -1600,6 +1685,8 @@ readIntArray(dataIn: number[]): void ...@@ -1600,6 +1685,8 @@ readIntArray(dataIn: number[]): void
readIntArray(): number[] readIntArray(): number[]
**描述**
从MessageSequence实例中读取整数数组。 从MessageSequence实例中读取整数数组。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -1641,6 +1728,8 @@ readIntArray(): number[] ...@@ -1641,6 +1728,8 @@ readIntArray(): number[]
writeLongArray(longArray: number[]): void writeLongArray(longArray: number[]): void
**描述**
将长整数数组写入MessageSequence实例。 将长整数数组写入MessageSequence实例。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -1675,7 +1764,9 @@ writeLongArray(longArray: number[]): void ...@@ -1675,7 +1764,9 @@ writeLongArray(longArray: number[]): void
readLongArray(dataIn: number[]): void readLongArray(dataIn: number[]): void
从MessageSequence实例读取长整数数组。 **描述**
从MessageSequence实例读取定长长整数数组。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -1716,7 +1807,9 @@ readLongArray(dataIn: number[]): void ...@@ -1716,7 +1807,9 @@ readLongArray(dataIn: number[]): void
readLongArray(): number[] readLongArray(): number[]
从MessageSequence实例中读取长整数数组。 **描述**
从MessageSequence实例中读取所有的长整数数组。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -1757,6 +1850,8 @@ readLongArray(): number[] ...@@ -1757,6 +1850,8 @@ readLongArray(): number[]
writeFloatArray(floatArray: number[]): void writeFloatArray(floatArray: number[]): void
**描述**
将浮点数组写入MessageSequence实例。 将浮点数组写入MessageSequence实例。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -1791,6 +1886,8 @@ writeFloatArray(floatArray: number[]): void ...@@ -1791,6 +1886,8 @@ writeFloatArray(floatArray: number[]): void
readFloatArray(dataIn: number[]): void readFloatArray(dataIn: number[]): void
**描述**
从MessageSequence实例中读取浮点数组。 从MessageSequence实例中读取浮点数组。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -1832,6 +1929,8 @@ readFloatArray(dataIn: number[]): void ...@@ -1832,6 +1929,8 @@ readFloatArray(dataIn: number[]): void
readFloatArray(): number[] readFloatArray(): number[]
**描述**
从MessageSequence实例中读取浮点数组。 从MessageSequence实例中读取浮点数组。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -1873,6 +1972,8 @@ readFloatArray(): number[] ...@@ -1873,6 +1972,8 @@ readFloatArray(): number[]
writeDoubleArray(doubleArray: number[]): void writeDoubleArray(doubleArray: number[]): void
**描述**
将双精度浮点数组写入MessageSequence实例。 将双精度浮点数组写入MessageSequence实例。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -1907,7 +2008,9 @@ writeDoubleArray(doubleArray: number[]): void ...@@ -1907,7 +2008,9 @@ writeDoubleArray(doubleArray: number[]): void
readDoubleArray(dataIn: number[]): void readDoubleArray(dataIn: number[]): void
从MessageSequence实例中读取双精度浮点数组。 **描述**
从MessageSequence实例中读取定长双精度浮点数组。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -1948,7 +2051,9 @@ readDoubleArray(dataIn: number[]): void ...@@ -1948,7 +2051,9 @@ readDoubleArray(dataIn: number[]): void
readDoubleArray(): number[] readDoubleArray(): number[]
从MessageSequence实例读取双精度浮点数组。 **描述**
从MessageSequence实例读取所有双精度浮点数组。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -1989,6 +2094,8 @@ readDoubleArray(): number[] ...@@ -1989,6 +2094,8 @@ readDoubleArray(): number[]
writeBooleanArray(booleanArray: boolean[]): void writeBooleanArray(booleanArray: boolean[]): void
**描述**
将布尔数组写入MessageSequence实例。 将布尔数组写入MessageSequence实例。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -2023,7 +2130,9 @@ writeBooleanArray(booleanArray: boolean[]): void ...@@ -2023,7 +2130,9 @@ writeBooleanArray(booleanArray: boolean[]): void
readBooleanArray(dataIn: boolean[]): void readBooleanArray(dataIn: boolean[]): void
从MessageSequence实例中读取布尔数组。 **描述**
从MessageSequence实例中读取定长布尔数组。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -2064,7 +2173,9 @@ readBooleanArray(dataIn: boolean[]): void ...@@ -2064,7 +2173,9 @@ readBooleanArray(dataIn: boolean[]): void
readBooleanArray(): boolean[] readBooleanArray(): boolean[]
从MessageSequence实例中读取布尔数组。 **描述**
从MessageSequence实例中读取所有布尔数组。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -2105,6 +2216,8 @@ readBooleanArray(): boolean[] ...@@ -2105,6 +2216,8 @@ readBooleanArray(): boolean[]
writeCharArray(charArray: number[]): void writeCharArray(charArray: number[]): void
**描述**
将单个字符数组写入MessageSequence实例。 将单个字符数组写入MessageSequence实例。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -2139,6 +2252,8 @@ writeCharArray(charArray: number[]): void ...@@ -2139,6 +2252,8 @@ writeCharArray(charArray: number[]): void
readCharArray(dataIn: number[]): void readCharArray(dataIn: number[]): void
**描述**
从MessageSequence实例中读取单个字符数组。 从MessageSequence实例中读取单个字符数组。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -2180,6 +2295,8 @@ readCharArray(dataIn: number[]): void ...@@ -2180,6 +2295,8 @@ readCharArray(dataIn: number[]): void
readCharArray(): number[] readCharArray(): number[]
**描述**
从MessageSequence实例读取单个字符数组。 从MessageSequence实例读取单个字符数组。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -2222,6 +2339,8 @@ readCharArray(): number[] ...@@ -2222,6 +2339,8 @@ readCharArray(): number[]
writeStringArray(stringArray: string[]): void writeStringArray(stringArray: string[]): void
**描述**
将字符串数组写入MessageSequence实例。 将字符串数组写入MessageSequence实例。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -2256,6 +2375,8 @@ writeStringArray(stringArray: string[]): void ...@@ -2256,6 +2375,8 @@ writeStringArray(stringArray: string[]): void
readStringArray(dataIn: string[]): void readStringArray(dataIn: string[]): void
**描述**
从MessageSequence实例读取字符串数组。 从MessageSequence实例读取字符串数组。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -2297,6 +2418,8 @@ readStringArray(dataIn: string[]): void ...@@ -2297,6 +2418,8 @@ readStringArray(dataIn: string[]): void
readStringArray(): string[] readStringArray(): string[]
**描述**
从MessageSequence实例读取字符串数组。 从MessageSequence实例读取字符串数组。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -2338,6 +2461,8 @@ readStringArray(): string[] ...@@ -2338,6 +2461,8 @@ readStringArray(): string[]
writeNoException(): void writeNoException(): void
**描述**
向MessageSequence写入“指示未发生异常”的信息。 向MessageSequence写入“指示未发生异常”的信息。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -2380,6 +2505,8 @@ writeNoException(): void ...@@ -2380,6 +2505,8 @@ writeNoException(): void
readException(): void readException(): void
**描述**
从MessageSequence中读取异常。 从MessageSequence中读取异常。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -2447,6 +2574,8 @@ readException(): void ...@@ -2447,6 +2574,8 @@ readException(): void
writeParcelableArray(parcelableArray: Parcelable[]): void writeParcelableArray(parcelableArray: Parcelable[]): void
**描述**
将可序列化对象数组写入MessageSequence实例。 将可序列化对象数组写入MessageSequence实例。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -2503,6 +2632,8 @@ writeParcelableArray(parcelableArray: Parcelable[]): void ...@@ -2503,6 +2632,8 @@ writeParcelableArray(parcelableArray: Parcelable[]): void
readParcelableArray(parcelableArray: Parcelable[]): void readParcelableArray(parcelableArray: Parcelable[]): void
**描述**
从MessageSequence实例读取可序列化对象数组。 从MessageSequence实例读取可序列化对象数组。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -2564,6 +2695,8 @@ readParcelableArray(parcelableArray: Parcelable[]): void ...@@ -2564,6 +2695,8 @@ readParcelableArray(parcelableArray: Parcelable[]): void
writeRemoteObjectArray(objectArray: IRemoteObject[]): void writeRemoteObjectArray(objectArray: IRemoteObject[]): void
**描述**
将IRemoteObject对象数组写入MessageSequence。 将IRemoteObject对象数组写入MessageSequence。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -2611,6 +2744,8 @@ writeRemoteObjectArray(objectArray: IRemoteObject[]): void ...@@ -2611,6 +2744,8 @@ writeRemoteObjectArray(objectArray: IRemoteObject[]): void
readRemoteObjectArray(objects: IRemoteObject[]): void readRemoteObjectArray(objects: IRemoteObject[]): void
**描述**
从MessageSequence读取IRemoteObject对象数组。 从MessageSequence读取IRemoteObject对象数组。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -2664,6 +2799,8 @@ readRemoteObjectArray(objects: IRemoteObject[]): void ...@@ -2664,6 +2799,8 @@ readRemoteObjectArray(objects: IRemoteObject[]): void
readRemoteObjectArray(): IRemoteObject[] readRemoteObjectArray(): IRemoteObject[]
**描述**
从MessageSequence读取IRemoteObject对象数组。 从MessageSequence读取IRemoteObject对象数组。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -2712,7 +2849,9 @@ readRemoteObjectArray(): IRemoteObject[] ...@@ -2712,7 +2849,9 @@ readRemoteObjectArray(): IRemoteObject[]
static closeFileDescriptor(fd: number): void static closeFileDescriptor(fd: number): void
关闭给定的文件描述符。 **描述**
静态方法,关闭给定的文件描述符。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -2740,7 +2879,9 @@ static closeFileDescriptor(fd: number): void ...@@ -2740,7 +2879,9 @@ static closeFileDescriptor(fd: number): void
static dupFileDescriptor(fd: number) :number static dupFileDescriptor(fd: number) :number
复制给定的文件描述符。 **描述**
静态方法,复制给定的文件描述符。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -2782,6 +2923,8 @@ static dupFileDescriptor(fd: number) :number ...@@ -2782,6 +2923,8 @@ static dupFileDescriptor(fd: number) :number
containFileDescriptors(): boolean containFileDescriptors(): boolean
**描述**
检查此MessageSequence对象是否包含文件描述符。 检查此MessageSequence对象是否包含文件描述符。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -2790,7 +2933,7 @@ containFileDescriptors(): boolean ...@@ -2790,7 +2933,7 @@ containFileDescriptors(): boolean
| 类型 | 说明 | | 类型 | 说明 |
| ------- | -------------------------------------------------------------------- | | ------- | -------------------------------------------------------------------- |
| boolean | 如果此MessageSequence对象包含文件描述符,则返回true;否则返回false。 | | boolean | true:包含文件描述符,false:不包含文件描述符。|
**示例:** **示例:**
...@@ -2820,6 +2963,8 @@ containFileDescriptors(): boolean ...@@ -2820,6 +2963,8 @@ containFileDescriptors(): boolean
writeFileDescriptor(fd: number): void writeFileDescriptor(fd: number): void
**描述**
写入文件描述符到MessageSequence。 写入文件描述符到MessageSequence。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -2853,11 +2998,12 @@ writeFileDescriptor(fd: number): void ...@@ -2853,11 +2998,12 @@ writeFileDescriptor(fd: number): void
} }
``` ```
### readFileDescriptor ### readFileDescriptor
readFileDescriptor(): number readFileDescriptor(): number
**描述**
从MessageSequence中读取文件描述符。 从MessageSequence中读取文件描述符。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -2897,11 +3043,12 @@ readFileDescriptor(): number ...@@ -2897,11 +3043,12 @@ readFileDescriptor(): number
} }
``` ```
### writeAshmem ### writeAshmem
writeAshmem(ashmem: Ashmem): void writeAshmem(ashmem: Ashmem): void
**描述**
将指定的匿名共享对象写入此MessageSequence。 将指定的匿名共享对象写入此MessageSequence。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -2944,6 +3091,8 @@ writeAshmem(ashmem: Ashmem): void ...@@ -2944,6 +3091,8 @@ writeAshmem(ashmem: Ashmem): void
readAshmem(): Ashmem readAshmem(): Ashmem
**描述**
从MessageSequence读取匿名共享对象。 从MessageSequence读取匿名共享对象。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -2988,11 +3137,12 @@ readAshmem(): Ashmem ...@@ -2988,11 +3137,12 @@ readAshmem(): Ashmem
} }
``` ```
### getRawDataCapacity ### getRawDataCapacity
getRawDataCapacity(): number getRawDataCapacity(): number
**描述**
获取MessageSequence可以容纳的最大原始数据量。 获取MessageSequence可以容纳的最大原始数据量。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -3011,11 +3161,12 @@ getRawDataCapacity(): number ...@@ -3011,11 +3161,12 @@ getRawDataCapacity(): number
console.log("RpcTest: sequence get RawDataCapacity result is : " + result); console.log("RpcTest: sequence get RawDataCapacity result is : " + result);
``` ```
### writeRawData ### writeRawData
writeRawData(rawData: number[], size: number): void writeRawData(rawData: number[], size: number): void
**描述**
将原始数据写入MessageSequence对象。 将原始数据写入MessageSequence对象。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -3048,11 +3199,12 @@ writeRawData(rawData: number[], size: number): void ...@@ -3048,11 +3199,12 @@ writeRawData(rawData: number[], size: number): void
} }
``` ```
### readRawData ### readRawData
readRawData(size: number): number[] readRawData(size: number): number[]
**描述**
从MessageSequence读取原始数据。 从MessageSequence读取原始数据。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -3105,7 +3257,9 @@ readRawData(size: number): number[] ...@@ -3105,7 +3257,9 @@ readRawData(size: number): number[]
### create ### create
create(): MessageParcel static create(): MessageParcel
**描述**
静态方法,创建MessageParcel对象。 静态方法,创建MessageParcel对象。
...@@ -3128,6 +3282,8 @@ create(): MessageParcel ...@@ -3128,6 +3282,8 @@ create(): MessageParcel
reclaim(): void reclaim(): void
**描述**
释放不再使用的MessageParcel对象。 释放不再使用的MessageParcel对象。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -3143,6 +3299,8 @@ reclaim(): void ...@@ -3143,6 +3299,8 @@ reclaim(): void
writeRemoteObject(object: [IRemoteObject](#iremoteobject)): boolean writeRemoteObject(object: [IRemoteObject](#iremoteobject)): boolean
**描述**
序列化远程对象并将其写入MessageParcel对象。 序列化远程对象并将其写入MessageParcel对象。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -3157,7 +3315,7 @@ writeRemoteObject(object: [IRemoteObject](#iremoteobject)): boolean ...@@ -3157,7 +3315,7 @@ writeRemoteObject(object: [IRemoteObject](#iremoteobject)): boolean
| 类型 | 说明 | | 类型 | 说明 |
| ------- | ----------------------------------------- | | ------- | ----------------------------------------- |
| boolean | 如果操作成功,则返回true;否则返回false。 | | boolean | true:操作成功,false:操作失败。|
**示例:** **示例:**
...@@ -3190,6 +3348,8 @@ writeRemoteObject(object: [IRemoteObject](#iremoteobject)): boolean ...@@ -3190,6 +3348,8 @@ writeRemoteObject(object: [IRemoteObject](#iremoteobject)): boolean
readRemoteObject(): IRemoteObject readRemoteObject(): IRemoteObject
**描述**
从MessageParcel读取远程对象。此方法用于反序列化MessageParcel对象以生成IRemoteObject。远程对象按写入MessageParcel的顺序读取。 从MessageParcel读取远程对象。此方法用于反序列化MessageParcel对象以生成IRemoteObject。远程对象按写入MessageParcel的顺序读取。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -3232,6 +3392,8 @@ readRemoteObject(): IRemoteObject ...@@ -3232,6 +3392,8 @@ readRemoteObject(): IRemoteObject
writeInterfaceToken(token: string): boolean writeInterfaceToken(token: string): boolean
**描述**
将接口描述符写入MessageParcel对象,远端对象可使用该信息校验本次通信。 将接口描述符写入MessageParcel对象,远端对象可使用该信息校验本次通信。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -3246,7 +3408,7 @@ writeInterfaceToken(token: string): boolean ...@@ -3246,7 +3408,7 @@ writeInterfaceToken(token: string): boolean
| 类型 | 说明 | | 类型 | 说明 |
| ------- | ----------------------------------------- | | ------- | ----------------------------------------- |
| boolean | 如果操作成功,则返回true;否则返回false。 | | boolean | true:操作成功,false:操作失败。|
**示例:** **示例:**
...@@ -3261,6 +3423,8 @@ writeInterfaceToken(token: string): boolean ...@@ -3261,6 +3423,8 @@ writeInterfaceToken(token: string): boolean
readInterfaceToken(): string readInterfaceToken(): string
**描述**
从MessageParcel中读取接口描述符,接口描述符按写入MessageParcel的顺序读取,本地对象可使用该信息检验本次通信。 从MessageParcel中读取接口描述符,接口描述符按写入MessageParcel的顺序读取,本地对象可使用该信息检验本次通信。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -3283,11 +3447,12 @@ readInterfaceToken(): string ...@@ -3283,11 +3447,12 @@ readInterfaceToken(): string
} }
``` ```
### getSize ### getSize
getSize(): number getSize(): number
**描述**
获取当前MessageParcel的数据大小。 获取当前MessageParcel的数据大小。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -3306,11 +3471,12 @@ getSize(): number ...@@ -3306,11 +3471,12 @@ getSize(): number
console.log("RpcClient: size is " + size); console.log("RpcClient: size is " + size);
``` ```
### getCapacity ### getCapacity
getCapacity(): number getCapacity(): number
**描述**
获取当前MessageParcel的容量。 获取当前MessageParcel的容量。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -3329,11 +3495,12 @@ getCapacity(): number ...@@ -3329,11 +3495,12 @@ getCapacity(): number
console.log("RpcClient: capacity is " + result); console.log("RpcClient: capacity is " + result);
``` ```
### setSize ### setSize
setSize(size: number): boolean setSize(size: number): boolean
**描述**
设置MessageParcel实例中包含的数据大小。 设置MessageParcel实例中包含的数据大小。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -3348,7 +3515,7 @@ setSize(size: number): boolean ...@@ -3348,7 +3515,7 @@ setSize(size: number): boolean
| 类型 | 说明 | | 类型 | 说明 |
| ------- | --------------------------------- | | ------- | --------------------------------- |
| boolean | 设置成功返回true,否则返回false。 | | boolean | true:设置成功,false:设置失败。|
**示例:** **示例:**
...@@ -3358,11 +3525,12 @@ setSize(size: number): boolean ...@@ -3358,11 +3525,12 @@ setSize(size: number): boolean
console.log("RpcClient: setSize is " + setSize); console.log("RpcClient: setSize is " + setSize);
``` ```
### setCapacity ### setCapacity
setCapacity(size: number): boolean setCapacity(size: number): boolean
**描述**
设置MessageParcel实例的存储容量。 设置MessageParcel实例的存储容量。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -3377,7 +3545,7 @@ setCapacity(size: number): boolean ...@@ -3377,7 +3545,7 @@ setCapacity(size: number): boolean
| 类型 | 说明 | | 类型 | 说明 |
| ------- | --------------------------------- | | ------- | --------------------------------- |
| boolean | 设置成功返回true,否则返回false。 | | boolean | true:设置成功,false:设置失败。|
**示例:** **示例:**
...@@ -3387,11 +3555,12 @@ setCapacity(size: number): boolean ...@@ -3387,11 +3555,12 @@ setCapacity(size: number): boolean
console.log("RpcClient: setCapacity is " + result); console.log("RpcClient: setCapacity is " + result);
``` ```
### getWritableBytes ### getWritableBytes
getWritableBytes(): number getWritableBytes(): number
**描述**
获取MessageParcel的可写字节空间。 获取MessageParcel的可写字节空间。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -3414,11 +3583,12 @@ getWritableBytes(): number ...@@ -3414,11 +3583,12 @@ getWritableBytes(): number
} }
``` ```
### getReadableBytes ### getReadableBytes
getReadableBytes(): number getReadableBytes(): number
**描述**
获取MessageParcel的可读字节空间。 获取MessageParcel的可读字节空间。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -3441,11 +3611,12 @@ getReadableBytes(): number ...@@ -3441,11 +3611,12 @@ getReadableBytes(): number
} }
``` ```
### getReadPosition ### getReadPosition
getReadPosition(): number getReadPosition(): number
**描述**
获取MessageParcel的读位置。 获取MessageParcel的读位置。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -3464,11 +3635,12 @@ getReadPosition(): number ...@@ -3464,11 +3635,12 @@ getReadPosition(): number
console.log("RpcClient: readPos is " + readPos); console.log("RpcClient: readPos is " + readPos);
``` ```
### getWritePosition ### getWritePosition
getWritePosition(): number getWritePosition(): number
**描述**
获取MessageParcel的写位置。 获取MessageParcel的写位置。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -3488,11 +3660,12 @@ getWritePosition(): number ...@@ -3488,11 +3660,12 @@ getWritePosition(): number
console.log("RpcClient: bwPos is " + bwPos); console.log("RpcClient: bwPos is " + bwPos);
``` ```
### rewindRead ### rewindRead
rewindRead(pos: number): boolean rewindRead(pos: number): boolean
**描述**
重新偏移读取位置到指定的位置。 重新偏移读取位置到指定的位置。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -3507,7 +3680,7 @@ rewindRead(pos: number): boolean ...@@ -3507,7 +3680,7 @@ rewindRead(pos: number): boolean
| 类型 | 说明 | | 类型 | 说明 |
| ------- | ------------------------------------------------- | | ------- | ------------------------------------------------- |
| boolean | 如果读取位置发生更改,则返回true;否则返回false。 | | boolean | true:读取位置发生更改,false:读取位置未发生更改。|
**示例:** **示例:**
...@@ -3522,11 +3695,12 @@ rewindRead(pos: number): boolean ...@@ -3522,11 +3695,12 @@ rewindRead(pos: number): boolean
console.log("RpcClient: rewindRead is " + number2); console.log("RpcClient: rewindRead is " + number2);
``` ```
### rewindWrite ### rewindWrite
rewindWrite(pos: number): boolean rewindWrite(pos: number): boolean
**描述**
重新偏移写位置到指定的位置。 重新偏移写位置到指定的位置。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -3541,7 +3715,7 @@ rewindWrite(pos: number): boolean ...@@ -3541,7 +3715,7 @@ rewindWrite(pos: number): boolean
| 类型 | 说明 | | 类型 | 说明 |
| ------- | --------------------------------------------- | | ------- | --------------------------------------------- |
| boolean | 如果写入位置更改,则返回true;否则返回false。 | | boolean | true:写入位置发生更改,false:写入位置未发生更改。|
**示例:** **示例:**
...@@ -3554,11 +3728,12 @@ rewindWrite(pos: number): boolean ...@@ -3554,11 +3728,12 @@ rewindWrite(pos: number): boolean
console.log("RpcClient: rewindWrite is: " + number); console.log("RpcClient: rewindWrite is: " + number);
``` ```
### writeByte ### writeByte
writeByte(val: number): boolean writeByte(val: number): boolean
**描述**
将字节值写入MessageParcel实例。 将字节值写入MessageParcel实例。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -3583,11 +3758,12 @@ writeByte(val: number): boolean ...@@ -3583,11 +3758,12 @@ writeByte(val: number): boolean
console.log("RpcClient: writeByte is: " + result); console.log("RpcClient: writeByte is: " + result);
``` ```
### readByte ### readByte
readByte(): number readByte(): number
**描述**
从MessageParcel实例读取字节值。 从MessageParcel实例读取字节值。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -3608,11 +3784,12 @@ readByte(): number ...@@ -3608,11 +3784,12 @@ readByte(): number
console.log("RpcClient: readByte is: " + ret); console.log("RpcClient: readByte is: " + ret);
``` ```
### writeShort ### writeShort
writeShort(val: number): boolean writeShort(val: number): boolean
**描述**
将短整数值写入MessageParcel实例。 将短整数值写入MessageParcel实例。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -3627,7 +3804,7 @@ writeShort(val: number): boolean ...@@ -3627,7 +3804,7 @@ writeShort(val: number): boolean
| 类型 | 说明 | | 类型 | 说明 |
| ------- | ----------------------------- | | ------- | ----------------------------- |
| boolean | 写入返回true,否则返回false。 | | boolean | true:写入成功,false:写入失败。|
**示例:** **示例:**
...@@ -3637,11 +3814,12 @@ writeShort(val: number): boolean ...@@ -3637,11 +3814,12 @@ writeShort(val: number): boolean
console.log("RpcClient: writeShort is: " + result); console.log("RpcClient: writeShort is: " + result);
``` ```
### readShort ### readShort
readShort(): number readShort(): number
**描述**
从MessageParcel实例读取短整数值。 从MessageParcel实例读取短整数值。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -3662,11 +3840,12 @@ readShort(): number ...@@ -3662,11 +3840,12 @@ readShort(): number
console.log("RpcClient: readShort is: " + ret); console.log("RpcClient: readShort is: " + ret);
``` ```
### writeInt ### writeInt
writeInt(val: number): boolean writeInt(val: number): boolean
**描述**
将整数值写入MessageParcel实例。 将整数值写入MessageParcel实例。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -3691,11 +3870,12 @@ writeInt(val: number): boolean ...@@ -3691,11 +3870,12 @@ writeInt(val: number): boolean
console.log("RpcClient: writeInt is " + result); console.log("RpcClient: writeInt is " + result);
``` ```
### readInt ### readInt
readInt(): number readInt(): number
**描述**
从MessageParcel实例读取整数值。 从MessageParcel实例读取整数值。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -3716,11 +3896,12 @@ readInt(): number ...@@ -3716,11 +3896,12 @@ readInt(): number
console.log("RpcClient: readInt is " + ret); console.log("RpcClient: readInt is " + ret);
``` ```
### writeLong ### writeLong
writeLong(val: number): boolean writeLong(val: number): boolean
**描述**
将长整数值写入MessageParcel实例。 将长整数值写入MessageParcel实例。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -3735,7 +3916,7 @@ writeLong(val: number): boolean ...@@ -3735,7 +3916,7 @@ writeLong(val: number): boolean
| 类型 | 说明 | | 类型 | 说明 |
| ------- | --------------------------------- | | ------- | --------------------------------- |
| boolean | 写入成功返回true,否则返回false。 | | boolean | true:写入成功,false:写入失败。|
**示例:** **示例:**
...@@ -3745,11 +3926,12 @@ writeLong(val: number): boolean ...@@ -3745,11 +3926,12 @@ writeLong(val: number): boolean
console.log("RpcClient: writeLong is " + result); console.log("RpcClient: writeLong is " + result);
``` ```
### readLong ### readLong
readLong(): number readLong(): number
**描述**
从MessageParcel实例中读取长整数值。 从MessageParcel实例中读取长整数值。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -3770,11 +3952,12 @@ readLong(): number ...@@ -3770,11 +3952,12 @@ readLong(): number
console.log("RpcClient: readLong is " + ret); console.log("RpcClient: readLong is " + ret);
``` ```
### writeFloat ### writeFloat
writeFloat(val: number): boolean writeFloat(val: number): boolean
**描述**
将浮点值写入MessageParcel实例。 将浮点值写入MessageParcel实例。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -3789,7 +3972,7 @@ writeFloat(val: number): boolean ...@@ -3789,7 +3972,7 @@ writeFloat(val: number): boolean
| 类型 | 说明 | | 类型 | 说明 |
| ------- | --------------------------------- | | ------- | --------------------------------- |
| boolean | 写入成功返回true,否则返回false。 | | boolean | true:写入成功,false:写入失败。|
**示例:** **示例:**
...@@ -3799,11 +3982,12 @@ writeFloat(val: number): boolean ...@@ -3799,11 +3982,12 @@ writeFloat(val: number): boolean
console.log("RpcClient: writeFloat is " + result); console.log("RpcClient: writeFloat is " + result);
``` ```
### readFloat ### readFloat
readFloat(): number readFloat(): number
**描述**
从MessageParcel实例中读取浮点值。 从MessageParcel实例中读取浮点值。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -3824,11 +4008,12 @@ readFloat(): number ...@@ -3824,11 +4008,12 @@ readFloat(): number
console.log("RpcClient: readFloat is " + ret); console.log("RpcClient: readFloat is " + ret);
``` ```
### writeDouble ### writeDouble
writeDouble(val: number): boolean writeDouble(val: number): boolean
**描述**
将双精度浮点值写入MessageParcel实例。 将双精度浮点值写入MessageParcel实例。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -3843,7 +4028,7 @@ writeDouble(val: number): boolean ...@@ -3843,7 +4028,7 @@ writeDouble(val: number): boolean
| 类型 | 说明 | | 类型 | 说明 |
| ------- | --------------------------------- | | ------- | --------------------------------- |
| boolean | 写入成功返回true,否则返回false。 | | boolean | true:写入成功,false:写入失败。|
**示例:** **示例:**
...@@ -3853,11 +4038,12 @@ writeDouble(val: number): boolean ...@@ -3853,11 +4038,12 @@ writeDouble(val: number): boolean
console.log("RpcClient: writeDouble is " + result); console.log("RpcClient: writeDouble is " + result);
``` ```
### readDouble ### readDouble
readDouble(): number readDouble(): number
**描述**
从MessageParcel实例读取双精度浮点值。 从MessageParcel实例读取双精度浮点值。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -3882,6 +4068,8 @@ readDouble(): number ...@@ -3882,6 +4068,8 @@ readDouble(): number
writeBoolean(val: boolean): boolean writeBoolean(val: boolean): boolean
**描述**
将布尔值写入MessageParcel实例。 将布尔值写入MessageParcel实例。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -3896,7 +4084,7 @@ writeBoolean(val: boolean): boolean ...@@ -3896,7 +4084,7 @@ writeBoolean(val: boolean): boolean
| 类型 | 说明 | | 类型 | 说明 |
| ------- | --------------------------------- | | ------- | --------------------------------- |
| boolean | 写入成功返回true,否则返回false。 | | boolean | true:写入成功,false:写入失败。|
**示例:** **示例:**
...@@ -3906,11 +4094,12 @@ writeBoolean(val: boolean): boolean ...@@ -3906,11 +4094,12 @@ writeBoolean(val: boolean): boolean
console.log("RpcClient: writeBoolean is " + result); console.log("RpcClient: writeBoolean is " + result);
``` ```
### readBoolean ### readBoolean
readBoolean(): boolean readBoolean(): boolean
**描述**
从MessageParcel实例读取布尔值。 从MessageParcel实例读取布尔值。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -3931,11 +4120,12 @@ readBoolean(): boolean ...@@ -3931,11 +4120,12 @@ readBoolean(): boolean
console.log("RpcClient: readBoolean is " + ret); console.log("RpcClient: readBoolean is " + ret);
``` ```
### writeChar ### writeChar
writeChar(val: number): boolean writeChar(val: number): boolean
**描述**
将单个字符值写入MessageParcel实例。 将单个字符值写入MessageParcel实例。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -3950,7 +4140,7 @@ writeChar(val: number): boolean ...@@ -3950,7 +4140,7 @@ writeChar(val: number): boolean
| 类型 | 说明 | | 类型 | 说明 |
| ------- | ----------------------------- | | ------- | ----------------------------- |
| boolean | 写入返回true,否则返回false。 | | boolean | true:写入成功,false:写入失败。|
**示例:** **示例:**
...@@ -3960,11 +4150,12 @@ writeChar(val: number): boolean ...@@ -3960,11 +4150,12 @@ writeChar(val: number): boolean
console.log("RpcClient: writeChar is " + result); console.log("RpcClient: writeChar is " + result);
``` ```
### readChar ### readChar
readChar(): number readChar(): number
**描述**
从MessageParcel实例中读取单个字符值。 从MessageParcel实例中读取单个字符值。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -3985,11 +4176,12 @@ readChar(): number ...@@ -3985,11 +4176,12 @@ readChar(): number
console.log("RpcClient: readChar is " + ret); console.log("RpcClient: readChar is " + ret);
``` ```
### writeString ### writeString
writeString(val: string): boolean writeString(val: string): boolean
**描述**
将字符串值写入MessageParcel实例。 将字符串值写入MessageParcel实例。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -4004,7 +4196,7 @@ writeString(val: string): boolean ...@@ -4004,7 +4196,7 @@ writeString(val: string): boolean
| 类型 | 说明 | | 类型 | 说明 |
| ------- | --------------------------------- | | ------- | --------------------------------- |
| boolean | 写入成功返回true,否则返回false。 | | boolean | true:写入成功,false:写入失败。|
**示例:** **示例:**
...@@ -4014,11 +4206,12 @@ writeString(val: string): boolean ...@@ -4014,11 +4206,12 @@ writeString(val: string): boolean
console.log("RpcClient: writeString is " + result); console.log("RpcClient: writeString is " + result);
``` ```
### readString ### readString
readString(): string readString(): string
**描述**
从MessageParcel实例读取字符串值。 从MessageParcel实例读取字符串值。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -4039,11 +4232,12 @@ readString(): string ...@@ -4039,11 +4232,12 @@ readString(): string
console.log("RpcClient: readString is " + ret); console.log("RpcClient: readString is " + ret);
``` ```
### writeSequenceable ### writeSequenceable
writeSequenceable(val: Sequenceable): boolean writeSequenceable(val: Sequenceable): boolean
**描述**
将自定义序列化对象写入MessageParcel实例。 将自定义序列化对象写入MessageParcel实例。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -4058,7 +4252,7 @@ writeSequenceable(val: Sequenceable): boolean ...@@ -4058,7 +4252,7 @@ writeSequenceable(val: Sequenceable): boolean
| 类型 | 说明 | | 类型 | 说明 |
| ------- | --------------------------------- | | ------- | --------------------------------- |
| boolean | 写入成功返回true,否则返回false。 | | boolean | true:写入成功,false:写入失败。|
**示例:** **示例:**
...@@ -4087,11 +4281,12 @@ writeSequenceable(val: Sequenceable): boolean ...@@ -4087,11 +4281,12 @@ writeSequenceable(val: Sequenceable): boolean
console.log("RpcClient: writeSequenceable is " + result); console.log("RpcClient: writeSequenceable is " + result);
``` ```
### readSequenceable ### readSequenceable
readSequenceable(dataIn: Sequenceable): boolean readSequenceable(dataIn: Sequenceable): boolean
**描述**
从MessageParcel实例中读取成员变量到指定的对象(dataIn)。 从MessageParcel实例中读取成员变量到指定的对象(dataIn)。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -4106,7 +4301,7 @@ readSequenceable(dataIn: Sequenceable): boolean ...@@ -4106,7 +4301,7 @@ readSequenceable(dataIn: Sequenceable): boolean
| 类型 | 说明 | | 类型 | 说明 |
| ------- | ------------------------------------------- | | ------- | ------------------------------------------- |
| boolean | 如果反序列成功,则返回true;否则返回false。 | | boolean | true:反序列化成功,false:反序列化失败。|
**示例:** **示例:**
...@@ -4138,11 +4333,12 @@ readSequenceable(dataIn: Sequenceable): boolean ...@@ -4138,11 +4333,12 @@ readSequenceable(dataIn: Sequenceable): boolean
console.log("RpcClient: writeSequenceable is " + result2); console.log("RpcClient: writeSequenceable is " + result2);
``` ```
### writeByteArray ### writeByteArray
writeByteArray(byteArray: number[]): boolean writeByteArray(byteArray: number[]): boolean
**描述**
将字节数组写入MessageParcel实例。 将字节数组写入MessageParcel实例。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -4157,7 +4353,7 @@ writeByteArray(byteArray: number[]): boolean ...@@ -4157,7 +4353,7 @@ writeByteArray(byteArray: number[]): boolean
| 类型 | 说明 | | 类型 | 说明 |
| ------- | --------------------------------- | | ------- | --------------------------------- |
| boolean | 写入成功返回true,否则返回false。 | | boolean | true:写入成功,false:写入失败。|
**示例:** **示例:**
...@@ -4168,11 +4364,12 @@ writeByteArray(byteArray: number[]): boolean ...@@ -4168,11 +4364,12 @@ writeByteArray(byteArray: number[]): boolean
console.log("RpcClient: writeByteArray is " + result); console.log("RpcClient: writeByteArray is " + result);
``` ```
### readByteArray ### readByteArray
readByteArray(dataIn: number[]): void readByteArray(dataIn: number[]): void
**描述**
从MessageParcel实例读取字节数组。 从MessageParcel实例读取字节数组。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -4194,11 +4391,12 @@ readByteArray(dataIn: number[]): void ...@@ -4194,11 +4391,12 @@ readByteArray(dataIn: number[]): void
data.readByteArray(array); data.readByteArray(array);
``` ```
### readByteArray ### readByteArray
readByteArray(): number[] readByteArray(): number[]
**描述**
从MessageParcel实例中读取字节数组。 从MessageParcel实例中读取字节数组。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -4220,11 +4418,12 @@ readByteArray(): number[] ...@@ -4220,11 +4418,12 @@ readByteArray(): number[]
console.log("RpcClient: readByteArray is " + array); console.log("RpcClient: readByteArray is " + array);
``` ```
### writeShortArray ### writeShortArray
writeShortArray(shortArray: number[]): boolean writeShortArray(shortArray: number[]): boolean
**描述**
将短整数数组写入MessageParcel实例。 将短整数数组写入MessageParcel实例。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -4239,7 +4438,7 @@ writeShortArray(shortArray: number[]): boolean ...@@ -4239,7 +4438,7 @@ writeShortArray(shortArray: number[]): boolean
| 类型 | 说明 | | 类型 | 说明 |
| ------- | ----------------------------- | | ------- | ----------------------------- |
| boolean | 写入返回true,否则返回false。 | | boolean | true:写入成功,false:写入失败。|
**示例:** **示例:**
...@@ -4249,11 +4448,12 @@ writeShortArray(shortArray: number[]): boolean ...@@ -4249,11 +4448,12 @@ writeShortArray(shortArray: number[]): boolean
console.log("RpcClient: writeShortArray is " + result); console.log("RpcClient: writeShortArray is " + result);
``` ```
### readShortArray ### readShortArray
readShortArray(dataIn: number[]): void readShortArray(dataIn: number[]): void
**描述**
从MessageParcel实例中读取短整数数组。 从MessageParcel实例中读取短整数数组。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -4274,11 +4474,12 @@ readShortArray(dataIn: number[]): void ...@@ -4274,11 +4474,12 @@ readShortArray(dataIn: number[]): void
data.readShortArray(array); data.readShortArray(array);
``` ```
### readShortArray ### readShortArray
readShortArray(): number[] readShortArray(): number[]
**描述**
从MessageParcel实例中读取短整数数组。 从MessageParcel实例中读取短整数数组。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -4299,11 +4500,12 @@ readShortArray(): number[] ...@@ -4299,11 +4500,12 @@ readShortArray(): number[]
console.log("RpcClient: readShortArray is " + array); console.log("RpcClient: readShortArray is " + array);
``` ```
### writeIntArray ### writeIntArray
writeIntArray(intArray: number[]): boolean writeIntArray(intArray: number[]): boolean
**描述**
将整数数组写入MessageParcel实例。 将整数数组写入MessageParcel实例。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -4318,7 +4520,7 @@ writeIntArray(intArray: number[]): boolean ...@@ -4318,7 +4520,7 @@ writeIntArray(intArray: number[]): boolean
| 类型 | 说明 | | 类型 | 说明 |
| ------- | ----------------------------- | | ------- | ----------------------------- |
| boolean | 写入返回true,否则返回false。 | | boolean | true:写入成功,false:写入失败。|
**示例:** **示例:**
...@@ -4328,11 +4530,12 @@ writeIntArray(intArray: number[]): boolean ...@@ -4328,11 +4530,12 @@ writeIntArray(intArray: number[]): boolean
console.log("RpcClient: writeIntArray is " + result); console.log("RpcClient: writeIntArray is " + result);
``` ```
### readIntArray ### readIntArray
readIntArray(dataIn: number[]): void readIntArray(dataIn: number[]): void
**描述**
从MessageParcel实例中读取整数数组。 从MessageParcel实例中读取整数数组。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -4353,7 +4556,6 @@ readIntArray(dataIn: number[]): void ...@@ -4353,7 +4556,6 @@ readIntArray(dataIn: number[]): void
data.readIntArray(array); data.readIntArray(array);
``` ```
### readIntArray ### readIntArray
readIntArray(): number[] readIntArray(): number[]
...@@ -4378,11 +4580,12 @@ readIntArray(): number[] ...@@ -4378,11 +4580,12 @@ readIntArray(): number[]
console.log("RpcClient: readIntArray is " + array); console.log("RpcClient: readIntArray is " + array);
``` ```
### writeLongArray ### writeLongArray
writeLongArray(longArray: number[]): boolean writeLongArray(longArray: number[]): boolean
**描述**
将长整数数组写入MessageParcel实例。 将长整数数组写入MessageParcel实例。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -4397,7 +4600,7 @@ writeLongArray(longArray: number[]): boolean ...@@ -4397,7 +4600,7 @@ writeLongArray(longArray: number[]): boolean
| 类型 | 说明 | | 类型 | 说明 |
| ------- | ----------------------------- | | ------- | ----------------------------- |
| boolean | 写入返回true,否则返回false。 | | boolean | true:写入成功,false:写入失败。|
**示例:** **示例:**
...@@ -4407,11 +4610,12 @@ writeLongArray(longArray: number[]): boolean ...@@ -4407,11 +4610,12 @@ writeLongArray(longArray: number[]): boolean
console.log("RpcClient: writeLongArray is " + result); console.log("RpcClient: writeLongArray is " + result);
``` ```
### readLongArray ### readLongArray
readLongArray(dataIn: number[]): void readLongArray(dataIn: number[]): void
**描述**
从MessageParcel实例读取长整数数组。 从MessageParcel实例读取长整数数组。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -4432,11 +4636,12 @@ readLongArray(dataIn: number[]): void ...@@ -4432,11 +4636,12 @@ readLongArray(dataIn: number[]): void
data.readLongArray(array); data.readLongArray(array);
``` ```
### readLongArray ### readLongArray
readLongArray(): number[] readLongArray(): number[]
**描述**
从MessageParcel实例中读取长整数数组。 从MessageParcel实例中读取长整数数组。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -4457,11 +4662,12 @@ readLongArray(): number[] ...@@ -4457,11 +4662,12 @@ readLongArray(): number[]
console.log("RpcClient: readLongArray is " + array); console.log("RpcClient: readLongArray is " + array);
``` ```
### writeFloatArray ### writeFloatArray
writeFloatArray(floatArray: number[]): boolean writeFloatArray(floatArray: number[]): boolean
**描述**
将浮点数组写入MessageParcel实例。 将浮点数组写入MessageParcel实例。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -4476,7 +4682,7 @@ writeFloatArray(floatArray: number[]): boolean ...@@ -4476,7 +4682,7 @@ writeFloatArray(floatArray: number[]): boolean
| 类型 | 说明 | | 类型 | 说明 |
| ------- | ----------------------------- | | ------- | ----------------------------- |
| boolean | 写入返回true,否则返回false。 | | boolean | true:写入成功,false:写入失败。|
**示例:** **示例:**
...@@ -4486,11 +4692,12 @@ writeFloatArray(floatArray: number[]): boolean ...@@ -4486,11 +4692,12 @@ writeFloatArray(floatArray: number[]): boolean
console.log("RpcClient: writeFloatArray is " + result); console.log("RpcClient: writeFloatArray is " + result);
``` ```
### readFloatArray ### readFloatArray
readFloatArray(dataIn: number[]): void readFloatArray(dataIn: number[]): void
**描述**
从MessageParcel实例中读取浮点数组。 从MessageParcel实例中读取浮点数组。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -4511,11 +4718,12 @@ readFloatArray(dataIn: number[]): void ...@@ -4511,11 +4718,12 @@ readFloatArray(dataIn: number[]): void
data.readFloatArray(array); data.readFloatArray(array);
``` ```
### readFloatArray ### readFloatArray
readFloatArray(): number[] readFloatArray(): number[]
**描述**
从MessageParcel实例中读取浮点数组。 从MessageParcel实例中读取浮点数组。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -4536,11 +4744,12 @@ readFloatArray(): number[] ...@@ -4536,11 +4744,12 @@ readFloatArray(): number[]
console.log("RpcClient: readFloatArray is " + array); console.log("RpcClient: readFloatArray is " + array);
``` ```
### writeDoubleArray ### writeDoubleArray
writeDoubleArray(doubleArray: number[]): boolean writeDoubleArray(doubleArray: number[]): boolean
**描述**
将双精度浮点数组写入MessageParcel实例。 将双精度浮点数组写入MessageParcel实例。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -4555,7 +4764,7 @@ writeDoubleArray(doubleArray: number[]): boolean ...@@ -4555,7 +4764,7 @@ writeDoubleArray(doubleArray: number[]): boolean
| 类型 | 说明 | | 类型 | 说明 |
| ------- | ----------------------------- | | ------- | ----------------------------- |
| boolean | 写入返回true,否则返回false。 | | boolean | true:写入成功,false:写入失败。|
**示例:** **示例:**
...@@ -4565,11 +4774,12 @@ writeDoubleArray(doubleArray: number[]): boolean ...@@ -4565,11 +4774,12 @@ writeDoubleArray(doubleArray: number[]): boolean
console.log("RpcClient: writeDoubleArray is " + result); console.log("RpcClient: writeDoubleArray is " + result);
``` ```
### readDoubleArray ### readDoubleArray
readDoubleArray(dataIn: number[]): void readDoubleArray(dataIn: number[]): void
**描述**
从MessageParcel实例中读取双精度浮点数组。 从MessageParcel实例中读取双精度浮点数组。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -4590,11 +4800,12 @@ readDoubleArray(dataIn: number[]): void ...@@ -4590,11 +4800,12 @@ readDoubleArray(dataIn: number[]): void
data.readDoubleArray(array); data.readDoubleArray(array);
``` ```
### readDoubleArray ### readDoubleArray
readDoubleArray(): number[] readDoubleArray(): number[]
**描述**
从MessageParcel实例读取双精度浮点数组。 从MessageParcel实例读取双精度浮点数组。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -4615,11 +4826,12 @@ readDoubleArray(): number[] ...@@ -4615,11 +4826,12 @@ readDoubleArray(): number[]
console.log("RpcClient: readDoubleArray is " + array); console.log("RpcClient: readDoubleArray is " + array);
``` ```
### writeBooleanArray ### writeBooleanArray
writeBooleanArray(booleanArray: boolean[]): boolean writeBooleanArray(booleanArray: boolean[]): boolean
**描述**
将布尔数组写入MessageParcel实例。 将布尔数组写入MessageParcel实例。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -4634,7 +4846,7 @@ writeBooleanArray(booleanArray: boolean[]): boolean ...@@ -4634,7 +4846,7 @@ writeBooleanArray(booleanArray: boolean[]): boolean
| 类型 | 说明 | | 类型 | 说明 |
| ------- | --------------------------------- | | ------- | --------------------------------- |
| boolean | 写入成功返回true,否则返回false。 | | boolean | true:写入成功,false:写入失败。|
**示例:** **示例:**
...@@ -4644,11 +4856,12 @@ writeBooleanArray(booleanArray: boolean[]): boolean ...@@ -4644,11 +4856,12 @@ writeBooleanArray(booleanArray: boolean[]): boolean
console.log("RpcClient: writeBooleanArray is " + result); console.log("RpcClient: writeBooleanArray is " + result);
``` ```
### readBooleanArray ### readBooleanArray
readBooleanArray(dataIn: boolean[]): void readBooleanArray(dataIn: boolean[]): void
**描述**
从MessageParcel实例中读取布尔数组。 从MessageParcel实例中读取布尔数组。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -4669,11 +4882,12 @@ readBooleanArray(dataIn: boolean[]): void ...@@ -4669,11 +4882,12 @@ readBooleanArray(dataIn: boolean[]): void
data.readBooleanArray(array); data.readBooleanArray(array);
``` ```
### readBooleanArray ### readBooleanArray
readBooleanArray(): boolean[] readBooleanArray(): boolean[]
**描述**
从MessageParcel实例中读取布尔数组。 从MessageParcel实例中读取布尔数组。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -4694,11 +4908,12 @@ readBooleanArray(): boolean[] ...@@ -4694,11 +4908,12 @@ readBooleanArray(): boolean[]
console.log("RpcClient: readBooleanArray is " + array); console.log("RpcClient: readBooleanArray is " + array);
``` ```
### writeCharArray ### writeCharArray
writeCharArray(charArray: number[]): boolean writeCharArray(charArray: number[]): boolean
**描述**
将单个字符数组写入MessageParcel实例。 将单个字符数组写入MessageParcel实例。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -4713,7 +4928,7 @@ writeCharArray(charArray: number[]): boolean ...@@ -4713,7 +4928,7 @@ writeCharArray(charArray: number[]): boolean
| 类型 | 说明 | | 类型 | 说明 |
| ------- | --------------------------------- | | ------- | --------------------------------- |
| boolean | 写入成功返回true,否则返回false。 | | boolean | true:写入成功,false:写入失败。|
**示例:** **示例:**
...@@ -4723,11 +4938,12 @@ writeCharArray(charArray: number[]): boolean ...@@ -4723,11 +4938,12 @@ writeCharArray(charArray: number[]): boolean
console.log("RpcClient: writeCharArray is " + result); console.log("RpcClient: writeCharArray is " + result);
``` ```
### readCharArray ### readCharArray
readCharArray(dataIn: number[]): void readCharArray(dataIn: number[]): void
**描述**
从MessageParcel实例中读取单个字符数组。 从MessageParcel实例中读取单个字符数组。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -4748,11 +4964,12 @@ readCharArray(dataIn: number[]): void ...@@ -4748,11 +4964,12 @@ readCharArray(dataIn: number[]): void
data.readCharArray(array); data.readCharArray(array);
``` ```
### readCharArray ### readCharArray
readCharArray(): number[] readCharArray(): number[]
**描述**
从MessageParcel实例读取单个字符数组。 从MessageParcel实例读取单个字符数组。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -4773,11 +4990,12 @@ readCharArray(): number[] ...@@ -4773,11 +4990,12 @@ readCharArray(): number[]
console.log("RpcClient: readCharArray is " + array); console.log("RpcClient: readCharArray is " + array);
``` ```
### writeStringArray ### writeStringArray
writeStringArray(stringArray: string[]): boolean writeStringArray(stringArray: string[]): boolean
**描述**
将字符串数组写入MessageParcel实例。 将字符串数组写入MessageParcel实例。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -4792,7 +5010,7 @@ writeStringArray(stringArray: string[]): boolean ...@@ -4792,7 +5010,7 @@ writeStringArray(stringArray: string[]): boolean
| 类型 | 说明 | | 类型 | 说明 |
| ------- | --------------------------------- | | ------- | --------------------------------- |
| boolean | 写入成功返回true,否则返回false。 | | boolean | true:写入成功,false:写入失败。|
**示例:** **示例:**
...@@ -4802,11 +5020,12 @@ writeStringArray(stringArray: string[]): boolean ...@@ -4802,11 +5020,12 @@ writeStringArray(stringArray: string[]): boolean
console.log("RpcClient: writeStringArray is " + result); console.log("RpcClient: writeStringArray is " + result);
``` ```
### readStringArray ### readStringArray
readStringArray(dataIn: string[]): void readStringArray(dataIn: string[]): void
**描述**
从MessageParcel实例读取字符串数组。 从MessageParcel实例读取字符串数组。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -4827,11 +5046,12 @@ readStringArray(dataIn: string[]): void ...@@ -4827,11 +5046,12 @@ readStringArray(dataIn: string[]): void
data.readStringArray(array); data.readStringArray(array);
``` ```
### readStringArray ### readStringArray
readStringArray(): string[] readStringArray(): string[]
**描述**
从MessageParcel实例读取字符串数组。 从MessageParcel实例读取字符串数组。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -4852,11 +5072,12 @@ readStringArray(): string[] ...@@ -4852,11 +5072,12 @@ readStringArray(): string[]
console.log("RpcClient: readStringArray is " + array); console.log("RpcClient: readStringArray is " + array);
``` ```
### writeNoException<sup>8+</sup> ### writeNoException<sup>8+</sup>
writeNoException(): void writeNoException(): void
**描述**
向MessageParcel写入“指示未发生异常”的信息。 向MessageParcel写入“指示未发生异常”的信息。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -4899,6 +5120,8 @@ writeNoException(): void ...@@ -4899,6 +5120,8 @@ writeNoException(): void
readException(): void readException(): void
**描述**
从MessageParcel中读取异常。 从MessageParcel中读取异常。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -4953,6 +5176,8 @@ readException(): void ...@@ -4953,6 +5176,8 @@ readException(): void
writeSequenceableArray(sequenceableArray: Sequenceable[]): boolean writeSequenceableArray(sequenceableArray: Sequenceable[]): boolean
**描述**
将可序列化对象数组写入MessageParcel实例。 将可序列化对象数组写入MessageParcel实例。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -4967,7 +5192,7 @@ writeSequenceableArray(sequenceableArray: Sequenceable[]): boolean ...@@ -4967,7 +5192,7 @@ writeSequenceableArray(sequenceableArray: Sequenceable[]): boolean
| 类型 | 说明 | | 类型 | 说明 |
| ------- | --------------------------------- | | ------- | --------------------------------- |
| boolean | 写入成功返回true,否则返回false。 | | boolean | true:写入成功,false:写入失败。|
**示例:** **示例:**
...@@ -4999,11 +5224,12 @@ writeSequenceableArray(sequenceableArray: Sequenceable[]): boolean ...@@ -4999,11 +5224,12 @@ writeSequenceableArray(sequenceableArray: Sequenceable[]): boolean
console.log("RpcClient: writeSequenceableArray is " + result); console.log("RpcClient: writeSequenceableArray is " + result);
``` ```
### readSequenceableArray<sup>8+</sup> ### readSequenceableArray<sup>8+</sup>
readSequenceableArray(sequenceableArray: Sequenceable[]): void readSequenceableArray(sequenceableArray: Sequenceable[]): void
**描述**
从MessageParcel实例读取可序列化对象数组。 从MessageParcel实例读取可序列化对象数组。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -5046,11 +5272,12 @@ readSequenceableArray(sequenceableArray: Sequenceable[]): void ...@@ -5046,11 +5272,12 @@ readSequenceableArray(sequenceableArray: Sequenceable[]): void
data.readSequenceableArray(b); data.readSequenceableArray(b);
``` ```
### writeRemoteObjectArray<sup>8+</sup> ### writeRemoteObjectArray<sup>8+</sup>
writeRemoteObjectArray(objectArray: IRemoteObject[]): boolean writeRemoteObjectArray(objectArray: IRemoteObject[]): boolean
**描述**
将IRemoteObject对象数组写入MessageParcel。 将IRemoteObject对象数组写入MessageParcel。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -5065,7 +5292,7 @@ writeRemoteObjectArray(objectArray: IRemoteObject[]): boolean ...@@ -5065,7 +5292,7 @@ writeRemoteObjectArray(objectArray: IRemoteObject[]): boolean
| 类型 | 说明 | | 类型 | 说明 |
| ------- | -------------------------------------------------------------------------------------------------------------------- | | ------- | -------------------------------------------------------------------------------------------------------------------- |
| boolean | 如果IRemoteObject对象数组成功写入MessageParcel,则返回true;如果对象为null或数组写入MessageParcel失败,则返回false。 | | boolean | true:写入成功,false:写入失败。|
**示例:** **示例:**
...@@ -5099,11 +5326,12 @@ writeRemoteObjectArray(objectArray: IRemoteObject[]): boolean ...@@ -5099,11 +5326,12 @@ writeRemoteObjectArray(objectArray: IRemoteObject[]): boolean
console.log("RpcClient: writeRemoteObjectArray is " + result); console.log("RpcClient: writeRemoteObjectArray is " + result);
``` ```
### readRemoteObjectArray<sup>8+</sup> ### readRemoteObjectArray<sup>8+</sup>
readRemoteObjectArray(objects: IRemoteObject[]): void readRemoteObjectArray(objects: IRemoteObject[]): void
**描述**
从MessageParcel读取IRemoteObject对象数组。 从MessageParcel读取IRemoteObject对象数组。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -5147,11 +5375,12 @@ readRemoteObjectArray(objects: IRemoteObject[]): void ...@@ -5147,11 +5375,12 @@ readRemoteObjectArray(objects: IRemoteObject[]): void
data.readRemoteObjectArray(b); data.readRemoteObjectArray(b);
``` ```
### readRemoteObjectArray<sup>8+</sup> ### readRemoteObjectArray<sup>8+</sup>
readRemoteObjectArray(): IRemoteObject[] readRemoteObjectArray(): IRemoteObject[]
**描述**
从MessageParcel读取IRemoteObject对象数组。 从MessageParcel读取IRemoteObject对象数组。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -5196,12 +5425,13 @@ readRemoteObjectArray(): IRemoteObject[] ...@@ -5196,12 +5425,13 @@ readRemoteObjectArray(): IRemoteObject[]
console.log("RpcClient: readRemoteObjectArray is " + b); console.log("RpcClient: readRemoteObjectArray is " + b);
``` ```
### closeFileDescriptor<sup>8+</sup> ### closeFileDescriptor<sup>8+</sup>
static closeFileDescriptor(fd: number): void static closeFileDescriptor(fd: number): void
关闭给定的文件描述符。 **描述**
静态方法,关闭给定的文件描述符。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -5220,12 +5450,13 @@ static closeFileDescriptor(fd: number): void ...@@ -5220,12 +5450,13 @@ static closeFileDescriptor(fd: number): void
rpc.MessageParcel.closeFileDescriptor(fd); rpc.MessageParcel.closeFileDescriptor(fd);
``` ```
### dupFileDescriptor<sup>8+</sup> ### dupFileDescriptor<sup>8+</sup>
static dupFileDescriptor(fd: number) :number static dupFileDescriptor(fd: number) :number
复制给定的文件描述符。 **描述**
静态方法,复制给定的文件描述符。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -5250,11 +5481,12 @@ static dupFileDescriptor(fd: number) :number ...@@ -5250,11 +5481,12 @@ static dupFileDescriptor(fd: number) :number
let newFd = rpc.MessageParcel.dupFileDescriptor(fd); let newFd = rpc.MessageParcel.dupFileDescriptor(fd);
``` ```
### containFileDescriptors<sup>8+</sup> ### containFileDescriptors<sup>8+</sup>
containFileDescriptors(): boolean containFileDescriptors(): boolean
**描述**
检查此MessageParcel对象是否包含文件描述符。 检查此MessageParcel对象是否包含文件描述符。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -5263,7 +5495,7 @@ containFileDescriptors(): boolean ...@@ -5263,7 +5495,7 @@ containFileDescriptors(): boolean
| 类型 | 说明 | | 类型 | 说明 |
| ------- | ------------------------------------------------------------------ | | ------- | ------------------------------------------------------------------ |
| boolean | 如果此MessageParcel对象包含文件描述符,则返回true;否则返回false。 | | boolean |true:包含文件描述符,false:未包含文件描述符。|
**示例:** **示例:**
...@@ -5279,11 +5511,12 @@ containFileDescriptors(): boolean ...@@ -5279,11 +5511,12 @@ containFileDescriptors(): boolean
console.log("RpcTest: parcel after write fd containFd result is : " + containFD); console.log("RpcTest: parcel after write fd containFd result is : " + containFD);
``` ```
### writeFileDescriptor<sup>8+</sup> ### writeFileDescriptor<sup>8+</sup>
writeFileDescriptor(fd: number): boolean writeFileDescriptor(fd: number): boolean
**描述**
写入文件描述符到MessageParcel。 写入文件描述符到MessageParcel。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -5298,7 +5531,7 @@ writeFileDescriptor(fd: number): boolean ...@@ -5298,7 +5531,7 @@ writeFileDescriptor(fd: number): boolean
| 类型 | 说明 | | 类型 | 说明 |
| ------- | ----------------------------------------- | | ------- | ----------------------------------------- |
| boolean | 如果操作成功,则返回true;否则返回false。 | | boolean | true:操作成功,false:操作失败。|
**示例:** **示例:**
...@@ -5311,11 +5544,12 @@ writeFileDescriptor(fd: number): boolean ...@@ -5311,11 +5544,12 @@ writeFileDescriptor(fd: number): boolean
console.log("RpcTest: parcel writeFd result is : " + writeResult); console.log("RpcTest: parcel writeFd result is : " + writeResult);
``` ```
### readFileDescriptor<sup>8+</sup> ### readFileDescriptor<sup>8+</sup>
readFileDescriptor(): number readFileDescriptor(): number
**描述**
从MessageParcel中读取文件描述符。 从MessageParcel中读取文件描述符。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -5338,11 +5572,12 @@ readFileDescriptor(): number ...@@ -5338,11 +5572,12 @@ readFileDescriptor(): number
console.log("RpcTest: parcel read fd is : " + readFD); console.log("RpcTest: parcel read fd is : " + readFD);
``` ```
### writeAshmem<sup>8+</sup> ### writeAshmem<sup>8+</sup>
writeAshmem(ashmem: Ashmem): boolean writeAshmem(ashmem: Ashmem): boolean
**描述**
将指定的匿名共享对象写入此MessageParcel。 将指定的匿名共享对象写入此MessageParcel。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -5357,7 +5592,7 @@ writeAshmem(ashmem: Ashmem): boolean ...@@ -5357,7 +5592,7 @@ writeAshmem(ashmem: Ashmem): boolean
| 类型 | 说明 | | 类型 | 说明 |
| ------- | -------------------------------------------------------------------- | | ------- | -------------------------------------------------------------------- |
| boolean | 如果匿名共享对象成功写入此MessageParcel,则返回true;否则返回false。 | | boolean | true:写入成功,false:写入失败。|
**示例:** **示例:**
...@@ -5368,11 +5603,12 @@ writeAshmem(ashmem: Ashmem): boolean ...@@ -5368,11 +5603,12 @@ writeAshmem(ashmem: Ashmem): boolean
console.log("RpcTest: write ashmem to result is : " + isWriteSuccess); console.log("RpcTest: write ashmem to result is : " + isWriteSuccess);
``` ```
### readAshmem<sup>8+</sup> ### readAshmem<sup>8+</sup>
readAshmem(): Ashmem readAshmem(): Ashmem
**描述**
从MessageParcel读取匿名共享对象。 从MessageParcel读取匿名共享对象。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -5394,11 +5630,12 @@ readAshmem(): Ashmem ...@@ -5394,11 +5630,12 @@ readAshmem(): Ashmem
console.log("RpcTest: read ashmem to result is : " + readAshmem); console.log("RpcTest: read ashmem to result is : " + readAshmem);
``` ```
### getRawDataCapacity<sup>8+</sup> ### getRawDataCapacity<sup>8+</sup>
getRawDataCapacity(): number getRawDataCapacity(): number
**描述**
获取MessageParcel可以容纳的最大原始数据量。 获取MessageParcel可以容纳的最大原始数据量。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -5417,11 +5654,12 @@ getRawDataCapacity(): number ...@@ -5417,11 +5654,12 @@ getRawDataCapacity(): number
console.log("RpcTest: parcel get RawDataCapacity result is : " + result); console.log("RpcTest: parcel get RawDataCapacity result is : " + result);
``` ```
### writeRawData<sup>8+</sup> ### writeRawData<sup>8+</sup>
writeRawData(rawData: number[], size: number): boolean writeRawData(rawData: number[], size: number): boolean
**描述**
将原始数据写入MessageParcel对象。 将原始数据写入MessageParcel对象。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -5437,7 +5675,7 @@ writeRawData(rawData: number[], size: number): boolean ...@@ -5437,7 +5675,7 @@ writeRawData(rawData: number[], size: number): boolean
| 类型 | 说明 | | 类型 | 说明 |
| ------- | ----------------------------------------- | | ------- | ----------------------------------------- |
| boolean | 如果操作成功,则返回true;否则返回false。 | | boolean | true:写入成功,false:写入失败。|
**示例:** **示例:**
...@@ -5448,11 +5686,12 @@ writeRawData(rawData: number[], size: number): boolean ...@@ -5448,11 +5686,12 @@ writeRawData(rawData: number[], size: number): boolean
console.log("RpcTest: parcel write raw data result is : " + isWriteSuccess); console.log("RpcTest: parcel write raw data result is : " + isWriteSuccess);
``` ```
### readRawData<sup>8+</sup> ### readRawData<sup>8+</sup>
readRawData(size: number): number[] readRawData(size: number): number[]
**描述**
从MessageParcel读取原始数据。 从MessageParcel读取原始数据。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -5480,7 +5719,6 @@ readRawData(size: number): number[] ...@@ -5480,7 +5719,6 @@ readRawData(size: number): number[]
console.log("RpcTest: parcel read raw data result is : " + result); console.log("RpcTest: parcel read raw data result is : " + result);
``` ```
## Parcelable<sup>9+</sup> ## Parcelable<sup>9+</sup>
在进程间通信(IPC)期间,将类的对象写入MessageSequence并从MessageSequence中恢复它们。 在进程间通信(IPC)期间,将类的对象写入MessageSequence并从MessageSequence中恢复它们。
...@@ -5489,6 +5727,8 @@ readRawData(size: number): number[] ...@@ -5489,6 +5727,8 @@ readRawData(size: number): number[]
marshalling(dataOut: MessageSequence): boolean marshalling(dataOut: MessageSequence): boolean
**描述**
将此可序列对象封送到MessageSequence中。 将此可序列对象封送到MessageSequence中。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -5503,8 +5743,7 @@ marshalling(dataOut: MessageSequence): boolean ...@@ -5503,8 +5743,7 @@ marshalling(dataOut: MessageSequence): boolean
| 类型 | 说明 | | 类型 | 说明 |
| ------- | ----------------------------------------- | | ------- | ----------------------------------------- |
| boolean | 如果封送成功,则返回true;否则返回false。 | | boolean | true:封送成功,false:封送失败。
**示例:** **示例:**
``` ```
...@@ -5535,11 +5774,12 @@ marshalling(dataOut: MessageSequence): boolean ...@@ -5535,11 +5774,12 @@ marshalling(dataOut: MessageSequence): boolean
console.log("RpcClient: readParcelable is " + result2); console.log("RpcClient: readParcelable is " + result2);
``` ```
### unmarshalling ### unmarshalling
unmarshalling(dataIn: MessageSequence): boolean unmarshalling(dataIn: MessageSequence): boolean
**描述**
从MessageSequence中解封此可序列对象。 从MessageSequence中解封此可序列对象。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -5554,7 +5794,7 @@ unmarshalling(dataIn: MessageSequence): boolean ...@@ -5554,7 +5794,7 @@ unmarshalling(dataIn: MessageSequence): boolean
| 类型 | 说明 | | 类型 | 说明 |
| ------- | --------------------------------------------- | | ------- | --------------------------------------------- |
| boolean | 如果可序列化成功,则返回true;否则返回false。 | | boolean | true:反序列化成功,false:反序列化失败。|
**示例:** **示例:**
...@@ -5586,7 +5826,6 @@ unmarshalling(dataIn: MessageSequence): boolean ...@@ -5586,7 +5826,6 @@ unmarshalling(dataIn: MessageSequence): boolean
console.log("RpcClient: readParcelable is " + result2); console.log("RpcClient: readParcelable is " + result2);
``` ```
## Sequenceable<sup>(deprecated)</sup> ## Sequenceable<sup>(deprecated)</sup>
>从API version 9 开始不再维护,建议使用[Parcelable](#parcelable9)类替代。 >从API version 9 开始不再维护,建议使用[Parcelable](#parcelable9)类替代。
...@@ -5597,6 +5836,8 @@ unmarshalling(dataIn: MessageSequence): boolean ...@@ -5597,6 +5836,8 @@ unmarshalling(dataIn: MessageSequence): boolean
marshalling(dataOut: MessageParcel): boolean marshalling(dataOut: MessageParcel): boolean
**描述**
将此可序列对象封送到MessageParcel中。 将此可序列对象封送到MessageParcel中。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -5611,8 +5852,7 @@ marshalling(dataOut: MessageParcel): boolean ...@@ -5611,8 +5852,7 @@ marshalling(dataOut: MessageParcel): boolean
| 类型 | 说明 | | 类型 | 说明 |
| ------- | ----------------------------------------- | | ------- | ----------------------------------------- |
| boolean | 如果封送成功,则返回true;否则返回false。 | | boolean | true:封送成功,false:封送失败。
**示例:** **示例:**
``` ```
...@@ -5643,11 +5883,12 @@ marshalling(dataOut: MessageParcel): boolean ...@@ -5643,11 +5883,12 @@ marshalling(dataOut: MessageParcel): boolean
console.log("RpcClient: readSequenceable is " + result2); console.log("RpcClient: readSequenceable is " + result2);
``` ```
### unmarshalling ### unmarshalling
unmarshalling(dataIn: MessageParcel): boolean unmarshalling(dataIn: MessageParcel): boolean
**描述**
从MessageParcel中解封此可序列对象。 从MessageParcel中解封此可序列对象。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -5662,7 +5903,7 @@ unmarshalling(dataIn: MessageParcel): boolean ...@@ -5662,7 +5903,7 @@ unmarshalling(dataIn: MessageParcel): boolean
| 类型 | 说明 | | 类型 | 说明 |
| ------- | --------------------------------------------- | | ------- | --------------------------------------------- |
| boolean | 如果可序列化成功,则返回true;否则返回false。 | | boolean | true:反序列化成功,false:反序列化失败。|
**示例:** **示例:**
...@@ -5694,7 +5935,6 @@ unmarshalling(dataIn: MessageParcel): boolean ...@@ -5694,7 +5935,6 @@ unmarshalling(dataIn: MessageParcel): boolean
console.log("RpcClient: readSequenceable is " + result2); console.log("RpcClient: readSequenceable is " + result2);
``` ```
## IRemoteBroker ## IRemoteBroker
远端对象的代理持有者。用于获取代理对象。 远端对象的代理持有者。用于获取代理对象。
...@@ -5703,6 +5943,8 @@ unmarshalling(dataIn: MessageParcel): boolean ...@@ -5703,6 +5943,8 @@ unmarshalling(dataIn: MessageParcel): boolean
asObject(): IRemoteObject asObject(): IRemoteObject
**描述**
需派生类实现,获取代理或远端对象。 需派生类实现,获取代理或远端对象。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -5721,11 +5963,32 @@ asObject(): IRemoteObject ...@@ -5721,11 +5963,32 @@ asObject(): IRemoteObject
return this; return this;
} }
} }
let remoteObject = new TestAbility().asObject();
``` ```
**示例:** **示例:**
``` ```
import FA from "@ohos.ability.featureAbility";
let proxy;
let connect = {
onConnect: function (elementName, remoteProxy) {
console.log("RpcClient: js onConnect called.");
proxy = remoteProxy;
},
onDisconnect: function (elementName) {
console.log("RpcClient: onDisconnect");
},
onFailed: function () {
console.log("RpcClient: onFailed");
}
};
let want = {
"bundleName": "com.ohos.server",
"abilityName": "com.ohos.server.MainAbility",
};
FA.connectAbility(want, connect);
class TestProxy { class TestProxy {
remote: rpc.RemoteObject; remote: rpc.RemoteObject;
constructor(remote) { constructor(remote) {
...@@ -5735,6 +5998,8 @@ asObject(): IRemoteObject ...@@ -5735,6 +5998,8 @@ asObject(): IRemoteObject
return this.remote; return this.remote;
} }
} }
let iRemoteObject = new TestProxy(proxy).asObject();
``` ```
## DeathRecipient ## DeathRecipient
...@@ -5745,6 +6010,8 @@ asObject(): IRemoteObject ...@@ -5745,6 +6010,8 @@ asObject(): IRemoteObject
onRemoteDied(): void onRemoteDied(): void
**描述**
在成功添加死亡通知订阅后,当远端对象死亡时,将自动调用本方法。 在成功添加死亡通知订阅后,当远端对象死亡时,将自动调用本方法。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -5795,7 +6062,9 @@ onRemoteDied(): void ...@@ -5795,7 +6062,9 @@ onRemoteDied(): void
getLocalInterface(descriptor: string): IRemoteBroker getLocalInterface(descriptor: string): IRemoteBroker
查询接口。 **描述**
查询接口描述符的字符串。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -5817,7 +6086,9 @@ getLocalInterface(descriptor: string): IRemoteBroker ...@@ -5817,7 +6086,9 @@ getLocalInterface(descriptor: string): IRemoteBroker
queryLocalInterface(descriptor: string): IRemoteBroker queryLocalInterface(descriptor: string): IRemoteBroker
查询接口。 **描述**
查询接口描述符的字符串。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -5833,13 +6104,14 @@ queryLocalInterface(descriptor: string): IRemoteBroker ...@@ -5833,13 +6104,14 @@ queryLocalInterface(descriptor: string): IRemoteBroker
| ------------- | --------------------------------------------- | | ------------- | --------------------------------------------- |
| IRemoteBroker | 返回绑定到指定接口描述符的IRemoteBroker对象。 | | IRemoteBroker | 返回绑定到指定接口描述符的IRemoteBroker对象。 |
### sendRequest<sup>(deprecated)</sup> ### sendRequest<sup>(deprecated)</sup>
>从API version 9 开始不再维护,建议使用[sendMessageRequest](#sendmessagerequest9)类替代。 >从API version 9 开始不再维护,建议使用[sendMessageRequest](#sendmessagerequest9)类替代。
sendRequest(code: number, data: MessageParcel, reply: MessageParcel, options: MessageOption): boolean sendRequest(code: number, data: MessageParcel, reply: MessageParcel, options: MessageOption): boolean
**描述**
以同步或异步方式向对端进程发送MessageParcel消息。如果为选项设置了异步模式,则期约立即兑现,reply报文里没有内容。如果为选项设置了同步模式,则期约将在sendRequest返回时兑现,回复内容在reply报文里。 以同步或异步方式向对端进程发送MessageParcel消息。如果为选项设置了异步模式,则期约立即兑现,reply报文里没有内容。如果为选项设置了同步模式,则期约将在sendRequest返回时兑现,回复内容在reply报文里。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -5857,7 +6129,7 @@ sendRequest(code: number, data: MessageParcel, reply: MessageParcel, options: Me ...@@ -5857,7 +6129,7 @@ sendRequest(code: number, data: MessageParcel, reply: MessageParcel, options: Me
| 类型 | 说明 | | 类型 | 说明 |
| ------- | --------------------------------------------- | | ------- | --------------------------------------------- |
| boolean | 返回一个布尔值,true表示成功,false表示失败。 | | boolean | true:发送成功,false:发送失败。|
### sendRequest<sup>8+(deprecated)</sup> ### sendRequest<sup>8+(deprecated)</sup>
...@@ -5890,6 +6162,8 @@ sendRequest(code: number, data: MessageParcel, reply: MessageParcel, options: Me ...@@ -5890,6 +6162,8 @@ sendRequest(code: number, data: MessageParcel, reply: MessageParcel, options: Me
sendMessageRequest(code: number, data: MessageSequence, reply: MessageSequence, options: MessageOption): Promise&lt;RequestResult&gt; sendMessageRequest(code: number, data: MessageSequence, reply: MessageSequence, options: MessageOption): Promise&lt;RequestResult&gt;
**描述**
以同步或异步方式向对端进程发送MessageSequence消息。如果为选项设置了异步模式,则期约立即兑现,reply报文里没有内容。如果为选项设置了同步模式,则期约将在sendMessageRequest返回时兑现,回复内容在reply报文里。 以同步或异步方式向对端进程发送MessageSequence消息。如果为选项设置了异步模式,则期约立即兑现,reply报文里没有内容。如果为选项设置了同步模式,则期约将在sendMessageRequest返回时兑现,回复内容在reply报文里。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -5914,6 +6188,8 @@ sendMessageRequest(code: number, data: MessageSequence, reply: MessageSequence, ...@@ -5914,6 +6188,8 @@ sendMessageRequest(code: number, data: MessageSequence, reply: MessageSequence,
sendMessageRequest(code: number, data: MessageSequence, reply: MessageSequence, options: MessageOption, callback: AsyncCallback&lt;RequestResult&gt;): void sendMessageRequest(code: number, data: MessageSequence, reply: MessageSequence, options: MessageOption, callback: AsyncCallback&lt;RequestResult&gt;): void
**描述**
以同步或异步方式向对端进程发送MessageSequence消息。如果为选项设置了异步模式,则立即收到回调,reply报文里没有内容。如果为选项设置了同步模式,则将在sendRequest返回时收到回调,回复内容在reply报文里。 以同步或异步方式向对端进程发送MessageSequence消息。如果为选项设置了异步模式,则立即收到回调,reply报文里没有内容。如果为选项设置了同步模式,则将在sendRequest返回时收到回调,回复内容在reply报文里。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -5928,13 +6204,14 @@ sendMessageRequest(code: number, data: MessageSequence, reply: MessageSequence, ...@@ -5928,13 +6204,14 @@ sendMessageRequest(code: number, data: MessageSequence, reply: MessageSequence,
| options | [MessageOption](#messageoption) | 是 | 本次请求的同异步模式,默认同步调用。 | | options | [MessageOption](#messageoption) | 是 | 本次请求的同异步模式,默认同步调用。 |
| callback | AsyncCallback&lt;RequestResult&gt; | 是 | 接收发送结果的回调。 | | callback | AsyncCallback&lt;RequestResult&gt; | 是 | 接收发送结果的回调。 |
### sendRequest<sup>8+(deprecated)</sup> ### sendRequest<sup>8+(deprecated)</sup>
>从API version 9 开始不再维护,建议使用[sendMessageRequest](#sendmessagerequest9)类替代。 >从API version 9 开始不再维护,建议使用[sendMessageRequest](#sendmessagerequest9)类替代。
sendRequest(code: number, data: MessageParcel, reply: MessageParcel, options: MessageOption, callback: AsyncCallback&lt;SendRequestResult&gt;): void sendRequest(code: number, data: MessageParcel, reply: MessageParcel, options: MessageOption, callback: AsyncCallback&lt;SendRequestResult&gt;): void
**描述**
以同步或异步方式向对端进程发送MessageParcel消息。如果为选项设置了异步模式,则立即收到回调,reply报文里没有内容。如果为选项设置了同步模式,则将在sendRequest返回时收到回调,回复内容在reply报文里。 以同步或异步方式向对端进程发送MessageParcel消息。如果为选项设置了异步模式,则立即收到回调,reply报文里没有内容。如果为选项设置了同步模式,则将在sendRequest返回时收到回调,回复内容在reply报文里。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -5949,11 +6226,12 @@ sendRequest(code: number, data: MessageParcel, reply: MessageParcel, options: Me ...@@ -5949,11 +6226,12 @@ sendRequest(code: number, data: MessageParcel, reply: MessageParcel, options: Me
| options | [MessageOption](#messageoption) | 是 | 本次请求的同异步模式,默认同步调用。 | | options | [MessageOption](#messageoption) | 是 | 本次请求的同异步模式,默认同步调用。 |
| callback | AsyncCallback&lt;SendRequestResult&gt; | 是 | 接收发送结果的回调。 | | callback | AsyncCallback&lt;SendRequestResult&gt; | 是 | 接收发送结果的回调。 |
### registerDeathRecipient<sup>9+</sup> ### registerDeathRecipient<sup>9+</sup>
registerDeathRecipient(recipient: DeathRecipient, flags: number): void registerDeathRecipient(recipient: DeathRecipient, flags: number): void
**描述**
注册用于接收远程对象死亡通知的回调。如果与RemoteProxy对象匹配的远程对象进程死亡,则调用此方法。 注册用于接收远程对象死亡通知的回调。如果与RemoteProxy对象匹配的远程对象进程死亡,则调用此方法。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -5973,13 +6251,14 @@ registerDeathRecipient(recipient: DeathRecipient, flags: number): void ...@@ -5973,13 +6251,14 @@ registerDeathRecipient(recipient: DeathRecipient, flags: number): void
| ------- | -------- | | ------- | -------- |
| 1900008 | proxy or remote object is invalid | | 1900008 | proxy or remote object is invalid |
### addDeathrecipient<sup>(deprecated)</sup> ### addDeathrecipient<sup>(deprecated)</sup>
>从API version 9 开始不再维护,建议使用[registerDeathRecipient](#registerdeathrecipient9)类替代。 >从API version 9 开始不再维护,建议使用[registerDeathRecipient](#registerdeathrecipient9)类替代。
addDeathRecipient(recipient: DeathRecipient, flags: number): boolean addDeathRecipient(recipient: DeathRecipient, flags: number): boolean
**描述**
注册用于接收远程对象死亡通知的回调。如果与RemoteProxy对象匹配的远程对象进程死亡,则调用此方法。 注册用于接收远程对象死亡通知的回调。如果与RemoteProxy对象匹配的远程对象进程死亡,则调用此方法。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -5995,13 +6274,15 @@ addDeathRecipient(recipient: DeathRecipient, flags: number): boolean ...@@ -5995,13 +6274,15 @@ addDeathRecipient(recipient: DeathRecipient, flags: number): boolean
| 类型 | 说明 | | 类型 | 说明 |
| ------- | --------------------------------------------- | | ------- | --------------------------------------------- |
| boolean | 如果回调注册成功,则返回true;否则返回false。 | | boolean | true:回调注册成功,false:回调注册失败。|
### unregisterDeathRecipient<sup>9+</sup> ### unregisterDeathRecipient<sup>9+</sup>
unregisterDeathRecipient(recipient: DeathRecipient, flags: number): void unregisterDeathRecipient(recipient: DeathRecipient, flags: number): void
**描述**
注销用于接收远程对象死亡通知的回调。 注销用于接收远程对象死亡通知的回调。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -6021,13 +6302,14 @@ unregisterDeathRecipient(recipient: DeathRecipient, flags: number): void ...@@ -6021,13 +6302,14 @@ unregisterDeathRecipient(recipient: DeathRecipient, flags: number): void
| ------- | -------- | | ------- | -------- |
| 1900008 | proxy or remote object is invalid | | 1900008 | proxy or remote object is invalid |
### removeDeathRecipient<sup>(deprecated)</sup> ### removeDeathRecipient<sup>(deprecated)</sup>
>从API version 9 开始不再维护,建议使用[unregisterDeathRecipient](#unregisterdeathrecipient9)类替代。 >从API version 9 开始不再维护,建议使用[unregisterDeathRecipient](#unregisterdeathrecipient9)类替代。
removeDeathRecipient(recipient: DeathRecipient, flags: number): boolean removeDeathRecipient(recipient: DeathRecipient, flags: number): boolean
**描述**
注销用于接收远程对象死亡通知的回调。 注销用于接收远程对象死亡通知的回调。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -6043,14 +6325,15 @@ removeDeathRecipient(recipient: DeathRecipient, flags: number): boolean ...@@ -6043,14 +6325,15 @@ removeDeathRecipient(recipient: DeathRecipient, flags: number): boolean
| 类型 | 说明 | | 类型 | 说明 |
| ------- | --------------------------------------------- | | ------- | --------------------------------------------- |
| boolean | 如果回调成功注销,则返回true;否则返回false。 | | boolean | true:回调注销成功,false:回调注销失败。|
### getDescriptor<sup>9+</sup> ### getDescriptor<sup>9+</sup>
getDescriptor(): string getDescriptor(): string
获取对象的接口描述符。接口描述符为字符串。 **描述**
获取对象的接口描述符,接口描述符为字符串。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -6075,7 +6358,9 @@ getDescriptor(): string ...@@ -6075,7 +6358,9 @@ getDescriptor(): string
getInterfaceDescriptor(): string getInterfaceDescriptor(): string
获取对象的接口描述符。接口描述符为字符串。 **描述**
获取对象的接口描述符,接口描述符为字符串。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -6098,7 +6383,7 @@ isObjectDead(): boolean ...@@ -6098,7 +6383,7 @@ isObjectDead(): boolean
| 类型 | 说明 | | 类型 | 说明 |
| ------- | ------------------------------------------- | | ------- | ------------------------------------------- |
| boolean | 如果对象已死亡,则返回true;否则返回false。 | | boolean | true:对象死亡,false:对象未死亡。|
## RemoteProxy ## RemoteProxy
...@@ -6107,7 +6392,7 @@ isObjectDead(): boolean ...@@ -6107,7 +6392,7 @@ isObjectDead(): boolean
**系统能力**:以下各项对应的系统能力均为SystemCapability.Communication.IPC.Core。 **系统能力**:以下各项对应的系统能力均为SystemCapability.Communication.IPC.Core。
| 名称 | 值 | 说明 | | 名称 | 默认值 | 说明 |
| --------------------- | ----------------------- | --------------------------------- | | --------------------- | ----------------------- | --------------------------------- |
| PING_TRANSACTION | 1599098439 (0x5f504e47) | 内部指令码,用于测试IPC服务正常。 | | PING_TRANSACTION | 1599098439 (0x5f504e47) | 内部指令码,用于测试IPC服务正常。 |
| DUMP_TRANSACTION | 1598311760 (0x5f444d50) | 内部指令码,获取Binder内部状态。 | | DUMP_TRANSACTION | 1598311760 (0x5f444d50) | 内部指令码,获取Binder内部状态。 |
...@@ -6115,13 +6400,14 @@ isObjectDead(): boolean ...@@ -6115,13 +6400,14 @@ isObjectDead(): boolean
| MIN_TRANSACTION_ID | 1 (0x00000001) | 最小有效指令码。 | | MIN_TRANSACTION_ID | 1 (0x00000001) | 最小有效指令码。 |
| MAX_TRANSACTION_ID | 16777215 (0x00FFFFFF) | 最大有效指令码。 | | MAX_TRANSACTION_ID | 16777215 (0x00FFFFFF) | 最大有效指令码。 |
### sendRequest<sup>(deprecated)</sup> ### sendRequest<sup>(deprecated)</sup>
>从API version 9 开始不再维护,建议使用[sendMessageRequest](#sendmessagerequest9)类替代。 >从API version 9 开始不再维护,建议使用[sendMessageRequest](#sendmessagerequest9)类替代。
sendRequest(code: number, data: MessageParcel, reply: MessageParcel, options: MessageOption): boolean sendRequest(code: number, data: MessageParcel, reply: MessageParcel, options: MessageOption): boolean
**描述**
以同步或异步方式向对端进程发送MessageParcel消息。如果为选项设置了异步模式,则期约立即兑现,reply报文里没有内容。如果为选项设置了同步模式,则期约将在sendRequest返回时兑现,回复内容在reply报文里。 以同步或异步方式向对端进程发送MessageParcel消息。如果为选项设置了异步模式,则期约立即兑现,reply报文里没有内容。如果为选项设置了同步模式,则期约将在sendRequest返回时兑现,回复内容在reply报文里。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -6139,7 +6425,7 @@ sendRequest(code: number, data: MessageParcel, reply: MessageParcel, options: Me ...@@ -6139,7 +6425,7 @@ sendRequest(code: number, data: MessageParcel, reply: MessageParcel, options: Me
| 类型 | 说明 | | 类型 | 说明 |
| ------- | --------------------------------------------- | | ------- | --------------------------------------------- |
| boolean | 返回一个布尔值,true表示成功,false表示失败。 | | boolean | true:发送成功,false:发送失败。|
**示例:** **示例:**
...@@ -6181,11 +6467,12 @@ sendRequest(code: number, data: MessageParcel, reply: MessageParcel, options: Me ...@@ -6181,11 +6467,12 @@ sendRequest(code: number, data: MessageParcel, reply: MessageParcel, options: Me
reply.reclaim(); reply.reclaim();
``` ```
### sendMessageRequest<sup>9+</sup> ### sendMessageRequest<sup>9+</sup>
sendMessageRequest(code: number, data: MessageSequence, reply: MessageSequence, options: MessageOption): Promise&lt;RequestResult&gt; sendMessageRequest(code: number, data: MessageSequence, reply: MessageSequence, options: MessageOption): Promise&lt;RequestResult&gt;
**描述**
以同步或异步方式向对端进程发送MessageSequence消息。如果为选项设置了异步模式,则期约立即兑现,reply报文里没有内容。如果为选项设置了同步模式,则期约将在sendMessageRequest返回时兑现,回复内容在reply报文里。 以同步或异步方式向对端进程发送MessageSequence消息。如果为选项设置了异步模式,则期约立即兑现,reply报文里没有内容。如果为选项设置了同步模式,则期约将在sendMessageRequest返回时兑现,回复内容在reply报文里。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -6251,13 +6538,14 @@ sendMessageRequest(code: number, data: MessageSequence, reply: MessageSequence, ...@@ -6251,13 +6538,14 @@ sendMessageRequest(code: number, data: MessageSequence, reply: MessageSequence,
}); });
``` ```
### sendRequest<sup>8+(deprecated)</sup> ### sendRequest<sup>8+(deprecated)</sup>
>从API version 9 开始不再维护,建议使用[sendMessageRequest](#sendmessagerequest9)类替代。 >从API version 9 开始不再维护,建议使用[sendMessageRequest](#sendmessagerequest9)类替代。
sendRequest(code: number, data: MessageParcel, reply: MessageParcel, options: MessageOption): Promise&lt;SendRequestResult&gt; sendRequest(code: number, data: MessageParcel, reply: MessageParcel, options: MessageOption): Promise&lt;SendRequestResult&gt;
**描述**
以同步或异步方式向对端进程发送MessageParcel消息。如果为选项设置了异步模式,则期约立即兑现,reply报文里没有内容。如果为选项设置了同步模式,则期约将在sendRequest返回时兑现,回复内容在reply报文里。 以同步或异步方式向对端进程发送MessageParcel消息。如果为选项设置了异步模式,则期约立即兑现,reply报文里没有内容。如果为选项设置了同步模式,则期约将在sendRequest返回时兑现,回复内容在reply报文里。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -6327,6 +6615,8 @@ sendRequest(code: number, data: MessageParcel, reply: MessageParcel, options: Me ...@@ -6327,6 +6615,8 @@ sendRequest(code: number, data: MessageParcel, reply: MessageParcel, options: Me
sendMessageRequest(code: number, data: MessageSequence, reply: MessageSequence, options: MessageOption, callback: AsyncCallback&lt;RequestResult&gt;): void sendMessageRequest(code: number, data: MessageSequence, reply: MessageSequence, options: MessageOption, callback: AsyncCallback&lt;RequestResult&gt;): void
**描述**
以同步或异步方式向对端进程发送MessageSequence消息。如果为选项设置了异步模式,则立即收到回调,reply报文里没有内容。如果为选项设置了同步模式,则将在sendMessageRequest返回后的某个时机执行回调,回复内容在RequestResult的reply报文里。 以同步或异步方式向对端进程发送MessageSequence消息。如果为选项设置了异步模式,则立即收到回调,reply报文里没有内容。如果为选项设置了同步模式,则将在sendMessageRequest返回后的某个时机执行回调,回复内容在RequestResult的reply报文里。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -6341,7 +6631,6 @@ sendMessageRequest(code: number, data: MessageSequence, reply: MessageSequence, ...@@ -6341,7 +6631,6 @@ sendMessageRequest(code: number, data: MessageSequence, reply: MessageSequence,
| options | [MessageOption](#messageoption) | 是 | 本次请求的同异步模式,默认同步调用。 | | options | [MessageOption](#messageoption) | 是 | 本次请求的同异步模式,默认同步调用。 |
| callback | AsyncCallback&lt;RequestResult&gt; | 是 | 接收发送结果的回调。 | | callback | AsyncCallback&lt;RequestResult&gt; | 是 | 接收发送结果的回调。 |
**示例:** **示例:**
``` ```
...@@ -6390,13 +6679,14 @@ sendMessageRequest(code: number, data: MessageSequence, reply: MessageSequence, ...@@ -6390,13 +6679,14 @@ sendMessageRequest(code: number, data: MessageSequence, reply: MessageSequence,
} }
``` ```
### sendRequest<sup>8+(deprecated)</sup> ### sendRequest<sup>8+(deprecated)</sup>
>从API version 9 开始不再维护,建议使用[sendMessageRequest](#sendmessagerequest9)类替代。 >从API version 9 开始不再维护,建议使用[sendMessageRequest](#sendmessagerequest9)类替代。
sendRequest(code: number, data: MessageParcel, reply: MessageParcel, options: MessageOption, callback: AsyncCallback&lt;SendRequestResult&gt;): void sendRequest(code: number, data: MessageParcel, reply: MessageParcel, options: MessageOption, callback: AsyncCallback&lt;SendRequestResult&gt;): void
**描述**
以同步或异步方式向对端进程发送MessageParcel消息。如果为选项设置了异步模式,则立即收到回调,reply报文里没有内容。如果为选项设置了同步模式,则将在sendRequest返回时收到回调,回复内容在reply报文里。 以同步或异步方式向对端进程发送MessageParcel消息。如果为选项设置了异步模式,则立即收到回调,reply报文里没有内容。如果为选项设置了同步模式,则将在sendRequest返回时收到回调,回复内容在reply报文里。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -6454,11 +6744,12 @@ sendRequest(code: number, data: MessageParcel, reply: MessageParcel, options: Me ...@@ -6454,11 +6744,12 @@ sendRequest(code: number, data: MessageParcel, reply: MessageParcel, options: Me
proxy.sendRequest(1, data, reply, option, sendRequestCallback); proxy.sendRequest(1, data, reply, option, sendRequestCallback);
``` ```
### getLocalInterface<sup>9+</sup> ### getLocalInterface<sup>9+</sup>
getLocalInterface(interface: string): IRemoteBroker getLocalInterface(interface: string): IRemoteBroker
**描述**
查询并获取当前接口描述符对应的本地接口对象。 查询并获取当前接口描述符对应的本地接口对象。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -6514,13 +6805,14 @@ getLocalInterface(interface: string): IRemoteBroker ...@@ -6514,13 +6805,14 @@ getLocalInterface(interface: string): IRemoteBroker
} }
``` ```
### queryLocalInterface<sup>(deprecated)</sup> ### queryLocalInterface<sup>(deprecated)</sup>
>从API version 9 开始不再维护,建议使用[getLocalInterface](#getlocalinterface9)类替代。 >从API version 9 开始不再维护,建议使用[getLocalInterface](#getlocalinterface9)类替代。
queryLocalInterface(interface: string): IRemoteBroker queryLocalInterface(interface: string): IRemoteBroker
**描述**
查询并获取当前接口描述符对应的本地接口对象。 查询并获取当前接口描述符对应的本地接口对象。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -6563,11 +6855,12 @@ queryLocalInterface(interface: string): IRemoteBroker ...@@ -6563,11 +6855,12 @@ queryLocalInterface(interface: string): IRemoteBroker
console.log("RpcClient: queryLocalInterface is " + broker); console.log("RpcClient: queryLocalInterface is " + broker);
``` ```
### registerDeathRecipient<sup>9+</sup> ### registerDeathRecipient<sup>9+</sup>
registerDeathRecipient(recipient: DeathRecipient, flags: number): void registerDeathRecipient(recipient: DeathRecipient, flags: number): void
**描述**
注册用于接收远程对象死亡通知的回调。如果与RemoteProxy对象匹配的远程对象进程死亡,则调用此方法。 注册用于接收远程对象死亡通知的回调。如果与RemoteProxy对象匹配的远程对象进程死亡,则调用此方法。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -6623,13 +6916,14 @@ registerDeathRecipient(recipient: DeathRecipient, flags: number): void ...@@ -6623,13 +6916,14 @@ registerDeathRecipient(recipient: DeathRecipient, flags: number): void
} }
``` ```
### addDeathRecippient<sup>(deprecated)</sup> ### addDeathRecippient<sup>(deprecated)</sup>
>从API version 9 开始不再维护,建议使用[registerDeathRecipient](#registerdeathrecipient9)类替代。 >从API version 9 开始不再维护,建议使用[registerDeathRecipient](#registerdeathrecipient9)类替代。
addDeathRecipient(recipient: DeathRecipient, flags: number): boolean addDeathRecipient(recipient: DeathRecipient, flags: number): boolean
**描述**
注册用于接收远程对象死亡通知的回调,增加proxy对象上的死亡通知。 注册用于接收远程对象死亡通知的回调,增加proxy对象上的死亡通知。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -6645,7 +6939,7 @@ addDeathRecipient(recipient: DeathRecipient, flags: number): boolean ...@@ -6645,7 +6939,7 @@ addDeathRecipient(recipient: DeathRecipient, flags: number): boolean
| 类型 | 说明 | | 类型 | 说明 |
| ------- | --------------------------------------------- | | ------- | --------------------------------------------- |
| boolean | 如果回调注册成功,则返回true;否则返回false。 | | boolean | true:回调注册成功,false:回调注册失败。|
**示例:** **示例:**
...@@ -6682,6 +6976,8 @@ addDeathRecipient(recipient: DeathRecipient, flags: number): boolean ...@@ -6682,6 +6976,8 @@ addDeathRecipient(recipient: DeathRecipient, flags: number): boolean
unregisterDeathRecipient(recipient: DeathRecipient, flags: number): boolean unregisterDeathRecipient(recipient: DeathRecipient, flags: number): boolean
**描述**
注销用于接收远程对象死亡通知的回调。 注销用于接收远程对象死亡通知的回调。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -6738,13 +7034,14 @@ unregisterDeathRecipient(recipient: DeathRecipient, flags: number): boolean ...@@ -6738,13 +7034,14 @@ unregisterDeathRecipient(recipient: DeathRecipient, flags: number): boolean
} }
``` ```
### removeDeathRecipient<sup>(deprecated)</sup> ### removeDeathRecipient<sup>(deprecated)</sup>
>从API version 9 开始不再维护,建议使用[unregisterDeathRecipient](#unregisterdeathrecipient9)类替代。 >从API version 9 开始不再维护,建议使用[unregisterDeathRecipient](#unregisterdeathrecipient9)类替代。
removeDeathRecipient(recipient: DeathRecipient, flags: number): boolean removeDeathRecipient(recipient: DeathRecipient, flags: number): boolean
**描述**
注销用于接收远程对象死亡通知的回调。 注销用于接收远程对象死亡通知的回调。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -6760,7 +7057,7 @@ removeDeathRecipient(recipient: DeathRecipient, flags: number): boolean ...@@ -6760,7 +7057,7 @@ removeDeathRecipient(recipient: DeathRecipient, flags: number): boolean
| 类型 | 说明 | | 类型 | 说明 |
| ------- | --------------------------------------------- | | ------- | --------------------------------------------- |
| boolean | 如果回调成功注销,则返回true;否则返回false。 | | boolean | true:回调注销成功,false:回调注销失败。|
**示例:** **示例:**
...@@ -6794,12 +7091,13 @@ removeDeathRecipient(recipient: DeathRecipient, flags: number): boolean ...@@ -6794,12 +7091,13 @@ removeDeathRecipient(recipient: DeathRecipient, flags: number): boolean
proxy.removeDeathRecipient(deathRecipient, 0); proxy.removeDeathRecipient(deathRecipient, 0);
``` ```
### getDescriptor<sup>9+</sup> ### getDescriptor<sup>9+</sup>
getDescriptor(): string getDescriptor(): string
获取对象的接口描述符。接口描述符为字符串。 **描述**
获取对象的接口描述符,接口描述符为字符串。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -6849,13 +7147,14 @@ getDescriptor(): string ...@@ -6849,13 +7147,14 @@ getDescriptor(): string
} }
``` ```
### getInterfaceDescriptor<sup>(deprecated)</sup> ### getInterfaceDescriptor<sup>(deprecated)</sup>
>从API version 9 开始不再维护,建议使用[getDescriptor](#getdescriptor9)类替代。 >从API version 9 开始不再维护,建议使用[getDescriptor](#getdescriptor9)类替代。
getInterfaceDescriptor(): string getInterfaceDescriptor(): string
**描述**
查询当前代理对象接口的描述符。 查询当前代理对象接口的描述符。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -6892,11 +7191,12 @@ getInterfaceDescriptor(): string ...@@ -6892,11 +7191,12 @@ getInterfaceDescriptor(): string
console.log("RpcClient: descriptor is " + descriptor); console.log("RpcClient: descriptor is " + descriptor);
``` ```
### isObjectDead ### isObjectDead
isObjectDead(): boolean isObjectDead(): boolean
**描述**
指示对应的RemoteObject是否死亡。 指示对应的RemoteObject是否死亡。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -6905,7 +7205,7 @@ isObjectDead(): boolean ...@@ -6905,7 +7205,7 @@ isObjectDead(): boolean
| 类型 | 说明 | | 类型 | 说明 |
| ------- | --------------------------------------------------------- | | ------- | --------------------------------------------------------- |
| boolean | 如果对应的RemoteObject已经死亡,返回true,否则返回false。 | | boolean | true:对应的对象已经死亡,false:对应的对象未死亡|
**示例:** **示例:**
...@@ -6933,14 +7233,13 @@ isObjectDead(): boolean ...@@ -6933,14 +7233,13 @@ isObjectDead(): boolean
console.log("RpcClient: isObjectDead is " + isDead); console.log("RpcClient: isObjectDead is " + isDead);
``` ```
## MessageOption ## MessageOption
公共消息选项(int标志,int等待时间),使用标志中指定的标志构造指定的MessageOption对象。 公共消息选项(int标志,int等待时间),使用标志中指定的标志构造指定的MessageOption对象。
**系统能力**:以下各项对应的系统能力均为SystemCapability.Communication.IPC.Core。 **系统能力**:以下各项对应的系统能力均为SystemCapability.Communication.IPC.Core。
| 名称 | 值 | 说明 | | 名称 | 默认值 | 说明 |
| ------------- | ---- | ----------------------------------------------------------- | | ------------- | ---- | ----------------------------------------------------------- |
| TF_SYNC | 0 | 同步调用标识。 | | TF_SYNC | 0 | 同步调用标识。 |
| TF_ASYNC | 1 | 异步调用标识。 | | TF_ASYNC | 1 | 异步调用标识。 |
...@@ -6952,6 +7251,8 @@ isObjectDead(): boolean ...@@ -6952,6 +7251,8 @@ isObjectDead(): boolean
constructor(async?: boolean); constructor(async?: boolean);
**描述**
MessageOption构造函数。 MessageOption构造函数。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -6963,10 +7264,22 @@ MessageOption构造函数。 ...@@ -6963,10 +7264,22 @@ MessageOption构造函数。
| syncFlags | number | 否 | 同步调用或异步调用标志。默认同步调用。 | | syncFlags | number | 否 | 同步调用或异步调用标志。默认同步调用。 |
**示例:**
```
class TestRemoteObject extends rpc.MessageOption {
constructor(async) {
super(async);
}
}
```
### constructor ### constructor
constructor(syncFlags?: number, waitTime?: number) constructor(syncFlags?: number, waitTime?: number)
**描述**
MessageOption构造函数。 MessageOption构造函数。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -6978,11 +7291,21 @@ MessageOption构造函数。 ...@@ -6978,11 +7291,21 @@ MessageOption构造函数。
| syncFlags | number | 否 | 同步调用或异步调用标志。默认同步调用。 | | syncFlags | number | 否 | 同步调用或异步调用标志。默认同步调用。 |
| waitTime | number | 否 | 调用rpc最长等待时间。默认&nbsp;TF_WAIT_TIME。 | | waitTime | number | 否 | 调用rpc最长等待时间。默认&nbsp;TF_WAIT_TIME。 |
**示例:**
```
class TestRemoteObject extends rpc.MessageOption {
constructor(syncFlags,waitTime) {
super(syncFlags,waitTime);
}
}
```
### isAsync<sup>9+</sup> ### isAsync<sup>9+</sup>
isAsync(): boolean; isAsync(): boolean;
**描述**
获取SendMessageRequest调用中确定同步或是异步的标志。 获取SendMessageRequest调用中确定同步或是异步的标志。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -6991,22 +7314,39 @@ isAsync(): boolean; ...@@ -6991,22 +7314,39 @@ isAsync(): boolean;
| 类型 | 说明 | | 类型 | 说明 |
| ------- | ------------------------------------ | | ------- | ------------------------------------ |
| boolean | 调用成功返回同步调用或异步调用标志。 | | boolean | true:同步调用成功,false:异步调用成功。 |
**示例:**
```
let option = new rpc.MessageOption();
let isAsync = option.isAsync();
```
### setAsync<sup>9+</sup> ### setAsync<sup>9+</sup>
setAsync(async: boolean): void; setAsync(async: boolean): void;
**描述**
设置SendMessageRequest调用中确定同步或是异步的标志。 设置SendMessageRequest调用中确定同步或是异步的标志。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
**示例:**
```
let option = new rpc.MessageOption();
let setAsync = option.setAsync(true);
console.log("Set synchronization flag");
```
### getFlags ### getFlags
getFlags(): number getFlags(): number
**描述**
获取同步调用或异步调用标志。 获取同步调用或异步调用标志。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -7017,11 +7357,29 @@ getFlags(): number ...@@ -7017,11 +7357,29 @@ getFlags(): number
| ------ | ------------------------------------ | | ------ | ------------------------------------ |
| number | 调用成功返回同步调用或异步调用标志。 | | number | 调用成功返回同步调用或异步调用标志。 |
**示例:**
```
try {
let option = new rpc.MessageOption();
console.info("create object successfully.");
let flog = option.getFlags();
console.info("run getFlags success, flog is " + flog);
option.setFlags(1)
console.info("run setFlags success");
let flog2 = option.getFlags();
console.info("run getFlags success, flog2 is " + flog2);
} catch (error) {
console.info("error " + error);
}
```
### setFlags ### setFlags
setFlags(flags: number): void setFlags(flags: number): void
**描述**
设置同步调用或异步调用标志。 设置同步调用或异步调用标志。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -7032,6 +7390,19 @@ setFlags(flags: number): void ...@@ -7032,6 +7390,19 @@ setFlags(flags: number): void
| ------ | ------ | ---- | ------------------------ | | ------ | ------ | ---- | ------------------------ |
| flags | number | 是 | 同步调用或异步调用标志。 | | flags | number | 是 | 同步调用或异步调用标志。 |
**示例:**
```
try {
let option = new rpc.MessageOption();
option.setFlags(1)
console.info("run setFlags success");
let flog = option.getFlags();
console.info("run getFlags success, flog is " + flog);
} catch (error) {
console.info("error " + error);
}
```
### getWaitTime ### getWaitTime
...@@ -7047,11 +7418,27 @@ getWaitTime(): number ...@@ -7047,11 +7418,27 @@ getWaitTime(): number
| ------ | ----------------- | | ------ | ----------------- |
| number | rpc最长等待时间。 | | number | rpc最长等待时间。 |
**示例:**
```
try {
let option = new rpc.MessageOption();
let time = option.getWaitTime();
console.info("run getWaitTime success");
option.setWaitTime(16);
let time2 = option.getWaitTime();
console.info("run getWaitTime success, time is " + time);
} catch (error) {
console.info("error " + error);
}
```
### setWaitTime ### setWaitTime
setWaitTime(waitTime: number): void setWaitTime(waitTime: number): void
**描述**
设置rpc调用最长等待时间。 设置rpc调用最长等待时间。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -7062,6 +7449,18 @@ setWaitTime(waitTime: number): void ...@@ -7062,6 +7449,18 @@ setWaitTime(waitTime: number): void
| -------- | ------ | ---- | --------------------- | | -------- | ------ | ---- | --------------------- |
| waitTime | number | 是 | rpc调用最长等待时间。 | | waitTime | number | 是 | rpc调用最长等待时间。 |
**示例:**
```
try {
let option = new rpc.MessageOption();
option.setWaitTime(16);
let time = option.getWaitTime();
console.info("run getWaitTime success, time is " + time);
} catch (error) {
console.info("error " + error);
}
```
## IPCSkeleton ## IPCSkeleton
...@@ -7071,7 +7470,9 @@ setWaitTime(waitTime: number): void ...@@ -7071,7 +7470,9 @@ setWaitTime(waitTime: number): void
static getContextObject(): IRemoteObject static getContextObject(): IRemoteObject
获取系统能力的管理者。 **描述**
静态方法,获取系统能力的管理者。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -7088,12 +7489,13 @@ static getContextObject(): IRemoteObject ...@@ -7088,12 +7489,13 @@ static getContextObject(): IRemoteObject
console.log("RpcServer: getContextObject result: " + samgr); console.log("RpcServer: getContextObject result: " + samgr);
``` ```
### getCallingPid ### getCallingPid
static getCallingPid(): number static getCallingPid(): number
获取调用者的PID。此方法由RemoteObject对象在onRemoteRequest方法中调用,不在IPC上下文环境(onRemoteRequest)中调用则返回本进程的PID。 **描述**
静态方法,获取调用者的PID。此方法由RemoteObject对象在onRemoteRequest方法中调用,不在IPC上下文环境(onRemoteRequest)中调用则返回本进程的PID。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -7115,12 +7517,13 @@ static getCallingPid(): number ...@@ -7115,12 +7517,13 @@ static getCallingPid(): number
} }
``` ```
### getCallingUid ### getCallingUid
static getCallingUid(): number static getCallingUid(): number
获取调用者的UID。此方法由RemoteObject对象在onRemoteRequest方法中调用,不在IPC上下文环境(onRemoteRequest)中调用则返回本进程的UID。 **描述**
静态方法,获取调用者的UID。此方法由RemoteObject对象在onRemoteRequest方法中调用,不在IPC上下文环境(onRemoteRequest)中调用则返回本进程的UID。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -7142,15 +7545,15 @@ static getCallingUid(): number ...@@ -7142,15 +7545,15 @@ static getCallingUid(): number
} }
``` ```
### getCallingTokenId<sup>8+</sup> ### getCallingTokenId<sup>8+</sup>
static getCallingTokenId(): number; static getCallingTokenId(): number;
获取调用者的TokenId,用于被调用方对调用方的身份校验。 **描述**
**系统能力**:SystemCapability.Communication.IPC.Core 静态方法,获取调用者的TokenId,用于被调用方对调用方的身份校验。
**系统能力**:SystemCapability.Communication.IPC.Core
**返回值:** **返回值:**
...@@ -7175,7 +7578,9 @@ static getCallingTokenId(): number; ...@@ -7175,7 +7578,9 @@ static getCallingTokenId(): number;
static getCallingDeviceID(): string static getCallingDeviceID(): string
获取调用者进程所在的设备ID。 **描述**
静态方法,获取调用者进程所在的设备ID。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -7197,12 +7602,13 @@ static getCallingDeviceID(): string ...@@ -7197,12 +7602,13 @@ static getCallingDeviceID(): string
} }
``` ```
### getLocalDeviceID ### getLocalDeviceID
static getLocalDeviceID(): string static getLocalDeviceID(): string
获取本端设备ID。 **描述**
静态方法,获取本端设备ID。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -7224,12 +7630,13 @@ static getLocalDeviceID(): string ...@@ -7224,12 +7630,13 @@ static getLocalDeviceID(): string
} }
``` ```
### isLocalCalling ### isLocalCalling
static isLocalCalling(): boolean static isLocalCalling(): boolean
检查当前通信对端是否是本设备的进程。 **描述**
静态方法,检查当前通信对端是否是本设备的进程。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -7237,7 +7644,7 @@ static isLocalCalling(): boolean ...@@ -7237,7 +7644,7 @@ static isLocalCalling(): boolean
| 类型 | 说明 | | 类型 | 说明 |
| ------- | --------------------------------------------------------- | | ------- | --------------------------------------------------------- |
| boolean | 如果调用是在同一设备上进行的,则返回true,否则返回false。 | | boolean | true:调用在同一台设备,false:调用未在同一台设备。|
**示例:** **示例:**
...@@ -7251,12 +7658,13 @@ static isLocalCalling(): boolean ...@@ -7251,12 +7658,13 @@ static isLocalCalling(): boolean
} }
``` ```
### flushCmdBuffer<sup>9+</sup> ### flushCmdBuffer<sup>9+</sup>
static flushCmdBuffer(object: IRemoteObject): void static flushCmdBuffer(object: IRemoteObject): void
将所有挂起的命令从指定的RemoteProxy刷新到相应的RemoteObject。建议在执行任何时间敏感操作之前调用此方法。 **描述**
静态方法,将所有挂起的命令从指定的RemoteProxy刷新到相应的RemoteObject。建议在执行任何时间敏感操作之前调用此方法。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -7284,14 +7692,15 @@ static flushCmdBuffer(object: IRemoteObject): void ...@@ -7284,14 +7692,15 @@ static flushCmdBuffer(object: IRemoteObject): void
} }
``` ```
### flushCommands<sup>(deprecated)</sup> ### flushCommands<sup>(deprecated)</sup>
>从API version 9 开始不再维护,建议使用[flushCmdBuffer](#flushcmdbuffer9)类替代。 >从API version 9 开始不再维护,建议使用[flushCmdBuffer](#flushcmdbuffer9)类替代。
static flushCommands(object: IRemoteObject): number static flushCommands(object: IRemoteObject): number
将所有挂起的命令从指定的RemoteProxy刷新到相应的RemoteObject。建议在执行任何时间敏感操作之前调用此方法。 **描述**
静态方法,将所有挂起的命令从指定的RemoteProxy刷新到相应的RemoteObject。建议在执行任何时间敏感操作之前调用此方法。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -7338,7 +7747,9 @@ static flushCommands(object: IRemoteObject): number ...@@ -7338,7 +7747,9 @@ static flushCommands(object: IRemoteObject): number
static resetCallingIdentity(): string static resetCallingIdentity(): string
将远程用户的UID和PID替换为本地用户的UID和PID。它可以用于身份验证等场景。 **描述**
静态方法,将远程用户的UID和PID替换为本地用户的UID和PID。它可以用于身份验证等场景。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -7365,7 +7776,9 @@ static resetCallingIdentity(): string ...@@ -7365,7 +7776,9 @@ static resetCallingIdentity(): string
static restoreCallingIdentity(identity: string): void static restoreCallingIdentity(identity: string): void
将远程用户的UID和PID替换为本地用户的UID和PID。它可以用于身份验证等场景。 **描述**
静态方法,将远程用户的UID和PID替换为本地用户的UID和PID。它可以用于身份验证等场景。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -7392,14 +7805,15 @@ static restoreCallingIdentity(identity: string): void ...@@ -7392,14 +7805,15 @@ static restoreCallingIdentity(identity: string): void
} }
``` ```
### setCallingIdentity<sup>(deprecated)</sup> ### setCallingIdentity<sup>(deprecated)</sup>
>从API version 9 开始不再维护,建议使用[restoreCallingIdentity](#restorecallingidentity9)类替代。 >从API version 9 开始不再维护,建议使用[restoreCallingIdentity](#restorecallingidentity9)类替代。
static setCallingIdentity(identity: string): boolean static setCallingIdentity(identity: string): boolean
将UID和PID恢复为远程用户的UID和PID。它通常在使用resetCallingIdentity后调用,需要resetCallingIdentity返回的远程用户的UID和PID。 **描述**
静态方法,将UID和PID恢复为远程用户的UID和PID。它通常在使用resetCallingIdentity后调用,需要resetCallingIdentity返回的远程用户的UID和PID。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -7413,7 +7827,7 @@ static setCallingIdentity(identity: string): boolean ...@@ -7413,7 +7827,7 @@ static setCallingIdentity(identity: string): boolean
| 类型 | 说明 | | 类型 | 说明 |
| ------- | ----------------------------------------- | | ------- | ----------------------------------------- |
| boolean | 如果操作成功,则返回true;否则返回false。 | | boolean | true:设置成功,false:设置失败。|
**示例:** **示例:**
...@@ -7433,7 +7847,6 @@ static setCallingIdentity(identity: string): boolean ...@@ -7433,7 +7847,6 @@ static setCallingIdentity(identity: string): boolean
} }
``` ```
## RemoteObject ## RemoteObject
实现远程对象。服务提供者必须继承此类。 实现远程对象。服务提供者必须继承此类。
...@@ -7442,6 +7855,8 @@ static setCallingIdentity(identity: string): boolean ...@@ -7442,6 +7855,8 @@ static setCallingIdentity(identity: string): boolean
constructor(descriptor: string) constructor(descriptor: string)
**描述**
RemoteObject构造函数。 RemoteObject构造函数。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -7476,7 +7891,7 @@ sendRequest(code: number, data: MessageParcel, reply: MessageParcel, options: Me ...@@ -7476,7 +7891,7 @@ sendRequest(code: number, data: MessageParcel, reply: MessageParcel, options: Me
| 类型 | 说明 | | 类型 | 说明 |
| ------- | --------------------------------------------- | | ------- | --------------------------------------------- |
| boolean | 返回一个布尔值,true表示成功,false表示失败。 | | boolean | true:发送成功,false:发送失败。|
**示例:** **示例:**
...@@ -7519,13 +7934,14 @@ sendRequest(code: number, data: MessageParcel, reply: MessageParcel, options: Me ...@@ -7519,13 +7934,14 @@ sendRequest(code: number, data: MessageParcel, reply: MessageParcel, options: Me
reply.reclaim(); reply.reclaim();
``` ```
### sendRequest<sup>8+(deprecated)</sup> ### sendRequest<sup>8+(deprecated)</sup>
>从API version 9 开始不再维护,建议使用[sendMessageRequest](#sendmessagerequest9)类替代。 >从API version 9 开始不再维护,建议使用[sendMessageRequest](#sendmessagerequest9)类替代。
sendRequest(code: number, data: MessageParcel, reply: MessageParcel, options: MessageOption): Promise&lt;SendRequestResult&gt; sendRequest(code: number, data: MessageParcel, reply: MessageParcel, options: MessageOption): Promise&lt;SendRequestResult&gt;
**描述**
以同步或异步方式向对端进程发送MessageParcel消息。如果为选项设置了异步模式,则期约立即兑现,reply报文里没有内容。如果为选项设置了同步模式,则期约将在sendRequest返回时兑现,回复内容在reply报文里。 以同步或异步方式向对端进程发送MessageParcel消息。如果为选项设置了异步模式,则期约立即兑现,reply报文里没有内容。如果为选项设置了同步模式,则期约将在sendRequest返回时兑现,回复内容在reply报文里。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -7596,6 +8012,8 @@ sendRequest(code: number, data: MessageParcel, reply: MessageParcel, options: Me ...@@ -7596,6 +8012,8 @@ sendRequest(code: number, data: MessageParcel, reply: MessageParcel, options: Me
sendMessageRequest(code: number, data: MessageSequence, reply: MessageSequence, options: MessageOption): Promise&lt;RequestResult&gt; sendMessageRequest(code: number, data: MessageSequence, reply: MessageSequence, options: MessageOption): Promise&lt;RequestResult&gt;
**描述**
以同步或异步方式向对端进程发送MessageSequence消息。如果为选项设置了异步模式,则期约立即兑现,reply报文里没有内容。如果为选项设置了同步模式,则期约将在sendMessageRequest返回时兑现,回复内容在reply报文里。 以同步或异步方式向对端进程发送MessageSequence消息。如果为选项设置了异步模式,则期约立即兑现,reply报文里没有内容。如果为选项设置了同步模式,则期约将在sendMessageRequest返回时兑现,回复内容在reply报文里。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -7648,11 +8066,12 @@ sendMessageRequest(code: number, data: MessageSequence, reply: MessageSequence, ...@@ -7648,11 +8066,12 @@ sendMessageRequest(code: number, data: MessageSequence, reply: MessageSequence,
}); });
``` ```
### sendMessageRequest<sup>9+</sup> ### sendMessageRequest<sup>9+</sup>
sendMessageRequest(code: number, data: MessageSequence, reply: MessageSequence, options: MessageOption, callback: AsyncCallback&lt;RequestResult&gt;): void sendMessageRequest(code: number, data: MessageSequence, reply: MessageSequence, options: MessageOption, callback: AsyncCallback&lt;RequestResult&gt;): void
**描述**
以同步或异步方式向对端进程发送MessageSequence消息。如果为选项设置了异步模式,则立即收到回调,reply报文里没有内容。如果为选项设置了同步模式,则将在sendMessageRequest返回时收到回调,回复内容在reply报文里。 以同步或异步方式向对端进程发送MessageSequence消息。如果为选项设置了异步模式,则立即收到回调,reply报文里没有内容。如果为选项设置了同步模式,则将在sendMessageRequest返回时收到回调,回复内容在reply报文里。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -7697,13 +8116,14 @@ sendMessageRequest(code: number, data: MessageSequence, reply: MessageSequence, ...@@ -7697,13 +8116,14 @@ sendMessageRequest(code: number, data: MessageSequence, reply: MessageSequence,
testRemoteObject.sendMessageRequest(1, data, reply, option, sendRequestCallback); testRemoteObject.sendMessageRequest(1, data, reply, option, sendRequestCallback);
``` ```
### sendRequest<sup>8+(deprecated)</sup> ### sendRequest<sup>8+(deprecated)</sup>
>从API version 9 开始不再维护,建议使用[sendMessageRequest](#sendmessagerequest9)类替代。 >从API version 9 开始不再维护,建议使用[sendMessageRequest](#sendmessagerequest9)类替代。
sendRequest(code: number, data: MessageParcel, reply: MessageParcel, options: MessageOption, callback: AsyncCallback&lt;SendRequestResult&gt;): void sendRequest(code: number, data: MessageParcel, reply: MessageParcel, options: MessageOption, callback: AsyncCallback&lt;SendRequestResult&gt;): void
**描述**
以同步或异步方式向对端进程发送MessageParcel消息。如果为选项设置了异步模式,则立即收到回调,reply报文里没有内容。如果为选项设置了同步模式,则将在sendRequest返回时收到回调,回复内容在reply报文里。 以同步或异步方式向对端进程发送MessageParcel消息。如果为选项设置了异步模式,则立即收到回调,reply报文里没有内容。如果为选项设置了同步模式,则将在sendRequest返回时收到回调,回复内容在reply报文里。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -7762,13 +8182,14 @@ sendRequest(code: number, data: MessageParcel, reply: MessageParcel, options: Me ...@@ -7762,13 +8182,14 @@ sendRequest(code: number, data: MessageParcel, reply: MessageParcel, options: Me
testRemoteObject.sendRequest(1, data, reply, option, sendRequestCallback); testRemoteObject.sendRequest(1, data, reply, option, sendRequestCallback);
``` ```
### onRemoteRequest<sup>8+(deprecated)</sup> ### onRemoteRequest<sup>8+(deprecated)</sup>
>从API version 9 开始不再维护,建议使用[onRemoteMessageRequest](#onremotemessagerequest9)类替代。 >从API version 9 开始不再维护,建议使用[onRemoteMessageRequest](#onremotemessagerequest9)类替代。
onRemoteRequest(code: number, data: MessageParcel, reply: MessageParcel, options: MessageOption): boolean onRemoteRequest(code: number, data: MessageParcel, reply: MessageParcel, options: MessageOption): boolean
**描述**
sendMessageRequest请求的响应处理函数,服务端在该函数里处理请求,回复结果。 sendMessageRequest请求的响应处理函数,服务端在该函数里处理请求,回复结果。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -7786,7 +8207,7 @@ sendMessageRequest请求的响应处理函数,服务端在该函数里处理 ...@@ -7786,7 +8207,7 @@ sendMessageRequest请求的响应处理函数,服务端在该函数里处理
| 类型 | 说明 | | 类型 | 说明 |
| ------- | ----------------------------------------- | | ------- | ----------------------------------------- |
| boolean | 如果操作成功,则返回true;否则返回false。 | | boolean | true:操作成功,false:操作失败。|
**示例:** **示例:**
...@@ -7847,7 +8268,7 @@ sendMessageRequest请求的响应处理函数,服务端在该函数里同步 ...@@ -7847,7 +8268,7 @@ sendMessageRequest请求的响应处理函数,服务端在该函数里同步
| 类型 | 说明 | | 类型 | 说明 |
| ----------------- | ---------------------------------------------------------------------------------------------- | | ----------------- | ---------------------------------------------------------------------------------------------- |
| boolean | 若在onRemoteMessageRequest中同步地处理请求,则返回一个布尔值:操作成功,则返回true;否则返回false。 | | boolean | 若在onRemoteMessageRequest中同步地处理请求,则返回一个布尔值:true:操作成功,false:操作失败。 |
| Promise\<boolean> | 若在onRemoteMessageRequest中异步地处理请求,则返回一个Promise对象。 | | Promise\<boolean> | 若在onRemoteMessageRequest中异步地处理请求,则返回一个Promise对象。 |
**重载onRemoteMessageRequest方法同步处理请求示例:** **重载onRemoteMessageRequest方法同步处理请求示例:**
...@@ -7957,11 +8378,12 @@ sendMessageRequest请求的响应处理函数,服务端在该函数里同步 ...@@ -7957,11 +8378,12 @@ sendMessageRequest请求的响应处理函数,服务端在该函数里同步
} }
``` ```
### getCallingUid ### getCallingUid
getCallingUid(): number getCallingUid(): number
**描述**
获取通信对端的进程Uid。 获取通信对端的进程Uid。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -7987,6 +8409,8 @@ getCallingUid(): number ...@@ -7987,6 +8409,8 @@ getCallingUid(): number
getCallingPid(): number getCallingPid(): number
**描述**
获取通信对端的进程Pid。 获取通信对端的进程Pid。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -8013,7 +8437,9 @@ getCallingPid(): number ...@@ -8013,7 +8437,9 @@ getCallingPid(): number
getLocalInterface(descriptor: string): IRemoteBroker getLocalInterface(descriptor: string): IRemoteBroker
查询接口。 **描述**
查询接口描述符的字符串。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -8057,13 +8483,14 @@ getLocalInterface(descriptor: string): IRemoteBroker ...@@ -8057,13 +8483,14 @@ getLocalInterface(descriptor: string): IRemoteBroker
} }
``` ```
### queryLocalInterface<sup>(deprecated)</sup> ### queryLocalInterface<sup>(deprecated)</sup>
>从API version 9 开始不再维护,建议使用[getLocalInterface](#getlocalinterface9)类替代。 >从API version 9 开始不再维护,建议使用[getLocalInterface](#getlocalinterface9)类替代。
queryLocalInterface(descriptor: string): IRemoteBroker queryLocalInterface(descriptor: string): IRemoteBroker
**描述**
查询并获取当前接口描述符对应的远端对象是否已经存在。 查询并获取当前接口描述符对应的远端对象是否已经存在。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -8106,11 +8533,12 @@ queryLocalInterface(descriptor: string): IRemoteBroker ...@@ -8106,11 +8533,12 @@ queryLocalInterface(descriptor: string): IRemoteBroker
let broker = testRemoteObject.queryLocalInterface("testObject"); let broker = testRemoteObject.queryLocalInterface("testObject");
``` ```
### getDescriptor<sup>9+</sup> ### getDescriptor<sup>9+</sup>
getDescriptor(): string getDescriptor(): string
**描述**
获取对象的接口描述符。接口描述符为字符串。 获取对象的接口描述符。接口描述符为字符串。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -8157,13 +8585,14 @@ getDescriptor(): string ...@@ -8157,13 +8585,14 @@ getDescriptor(): string
console.log("RpcServer: descriptor is: " + descriptor); console.log("RpcServer: descriptor is: " + descriptor);
``` ```
### getInterfaceDescriptor<sup>(deprecated)</sup> ### getInterfaceDescriptor<sup>(deprecated)</sup>
>从API version 9 开始不再维护,建议使用[getDescriptor](#getdescriptor9)类替代。 >从API version 9 开始不再维护,建议使用[getDescriptor](#getdescriptor9)类替代。
getInterfaceDescriptor(): string getInterfaceDescriptor(): string
**描述**
查询接口描述符。 查询接口描述符。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -8201,11 +8630,12 @@ getInterfaceDescriptor(): string ...@@ -8201,11 +8630,12 @@ getInterfaceDescriptor(): string
console.log("RpcServer: descriptor is: " + descriptor); console.log("RpcServer: descriptor is: " + descriptor);
``` ```
### modifyLocalInterface<sup>9+</sup> ### modifyLocalInterface<sup>9+</sup>
modifyLocalInterface(localInterface: IRemoteBroker, descriptor: string): void modifyLocalInterface(localInterface: IRemoteBroker, descriptor: string): void
**描述**
此接口用于把接口描述符和IRemoteBroker对象绑定。 此接口用于把接口描述符和IRemoteBroker对象绑定。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -8217,7 +8647,6 @@ modifyLocalInterface(localInterface: IRemoteBroker, descriptor: string): void ...@@ -8217,7 +8647,6 @@ modifyLocalInterface(localInterface: IRemoteBroker, descriptor: string): void
| localInterface | IRemoteBroker | 是 | 将与描述符绑定的IRemoteBroker对象。 | | localInterface | IRemoteBroker | 是 | 将与描述符绑定的IRemoteBroker对象。 |
| descriptor | string | 是 | 用于与IRemoteBroker对象绑定的描述符。 | | descriptor | string | 是 | 用于与IRemoteBroker对象绑定的描述符。 |
**示例:** **示例:**
``` ```
...@@ -8254,6 +8683,8 @@ modifyLocalInterface(localInterface: IRemoteBroker, descriptor: string): void ...@@ -8254,6 +8683,8 @@ modifyLocalInterface(localInterface: IRemoteBroker, descriptor: string): void
attachLocalInterface(localInterface: IRemoteBroker, descriptor: string): void attachLocalInterface(localInterface: IRemoteBroker, descriptor: string): void
**描述**
此接口用于把接口描述符和IRemoteBroker对象绑定。 此接口用于把接口描述符和IRemoteBroker对象绑定。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -8294,28 +8725,28 @@ attachLocalInterface(localInterface: IRemoteBroker, descriptor: string): void ...@@ -8294,28 +8725,28 @@ attachLocalInterface(localInterface: IRemoteBroker, descriptor: string): void
let testRemoteObject = new TestRemoteObject("testObject"); let testRemoteObject = new TestRemoteObject("testObject");
``` ```
## Ashmem<sup>8+</sup> ## Ashmem<sup>8+</sup>
提供与匿名共享内存对象相关的方法,包括创建、关闭、映射和取消映射Ashmem、从Ashmem读取数据和写入数据、获取Ashmem大小、设置Ashmem保护。 提供与匿名共享内存对象相关的方法,包括创建、关闭、映射和取消映射Ashmem、从Ashmem读取数据和写入数据、获取Ashmem大小、设置Ashmem保护。
映射内存保护类型:
**系统能力**:以下各项对应的系统能力均为SystemCapability.Communication.IPC.Core。 **系统能力**:以下各项对应的系统能力均为SystemCapability.Communication.IPC.Core。
| 名称 | 值 | 说明 | 映射内存保护类型:
| 名称 | 默认值 | 说明 |
| ---------- | --- | ------------------ | | ---------- | --- | ------------------ |
| PROT_EXEC | 4 | 映射的内存可执行 | | PROT_EXEC | 4 | 映射的内存可执行 |
| PROT_NONE | 0 | 映射的内存不可访问 | | PROT_NONE | 0 | 映射的内存不可访问 |
| PROT_READ | 1 | 映射的内存可读 | | PROT_READ | 1 | 映射的内存可读 |
| PROT_WRITE | 2 | 映射的内存可写 | | PROT_WRITE | 2 | 映射的内存可写 |
### create<sup>9+</sup> ### create<sup>9+</sup>
static create(name: string, size: number): Ashmem static create(name: string, size: number): Ashmem
根据指定的名称和大小创建Ashmem对象。 **描述**
静态方法,根据指定的名称和大小创建Ashmem对象。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -8332,7 +8763,6 @@ static create(name: string, size: number): Ashmem ...@@ -8332,7 +8763,6 @@ static create(name: string, size: number): Ashmem
| ------ | ---------------------------------------------- | | ------ | ---------------------------------------------- |
| Ashmem | 返回创建的Ashmem对象;如果创建失败,返回null。 | | Ashmem | 返回创建的Ashmem对象;如果创建失败,返回null。 |
**示例:** **示例:**
``` ```
...@@ -8347,14 +8777,15 @@ static create(name: string, size: number): Ashmem ...@@ -8347,14 +8777,15 @@ static create(name: string, size: number): Ashmem
console.log("RpcTest: get ashemm by create : " + ashmem + " size is : " + size); console.log("RpcTest: get ashemm by create : " + ashmem + " size is : " + size);
``` ```
### createAshmem<sup>8+(deprecated)</sup> ### createAshmem<sup>8+(deprecated)</sup>
>从API version 9 开始不再维护,建议使用[create](#create9)类替代。 >从API version 9 开始不再维护,建议使用[create](#create9)类替代。
static createAshmem(name: string, size: number): Ashmem static createAshmem(name: string, size: number): Ashmem
根据指定的名称和大小创建Ashmem对象。 **描述**
静态方法,根据指定的名称和大小创建Ashmem对象。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -8379,12 +8810,13 @@ static createAshmem(name: string, size: number): Ashmem ...@@ -8379,12 +8810,13 @@ static createAshmem(name: string, size: number): Ashmem
console.log("RpcTest: get ashemm by createAshmem : " + ashmem + " size is : " + size); console.log("RpcTest: get ashemm by createAshmem : " + ashmem + " size is : " + size);
``` ```
### create<sup>9+</sup> ### create<sup>9+</sup>
static create(ashmem: Ashmem): Ashmem static create(ashmem: Ashmem): Ashmem
通过复制现有Ashmem对象的文件描述符(fd)来创建Ashmem对象。两个Ashmem对象指向同一个共享内存区域。 **描述**
静态方法,通过复制现有Ashmem对象的文件描述符(fd)来创建Ashmem对象。两个Ashmem对象指向同一个共享内存区域。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -8416,14 +8848,15 @@ static create(ashmem: Ashmem): Ashmem ...@@ -8416,14 +8848,15 @@ static create(ashmem: Ashmem): Ashmem
console.log("RpcTest: get ashemm by create : " + ashmem2 + " size is : " + size); console.log("RpcTest: get ashemm by create : " + ashmem2 + " size is : " + size);
``` ```
### createAshmemFromExisting<sup>8+(deprecated)</sup> ### createAshmemFromExisting<sup>8+(deprecated)</sup>
>从API version 9 开始不再维护,建议使用[create](#create9)类替代。 >从API version 9 开始不再维护,建议使用[create](#create9)类替代。
static createAshmemFromExisting(ashmem: Ashmem): Ashmem static createAshmemFromExisting(ashmem: Ashmem): Ashmem
通过复制现有Ashmem对象的文件描述符(fd)来创建Ashmem对象。两个Ashmem对象指向同一个共享内存区域。 **描述**
静态方法,通过复制现有Ashmem对象的文件描述符(fd)来创建Ashmem对象。两个Ashmem对象指向同一个共享内存区域。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -8448,11 +8881,12 @@ static createAshmemFromExisting(ashmem: Ashmem): Ashmem ...@@ -8448,11 +8881,12 @@ static createAshmemFromExisting(ashmem: Ashmem): Ashmem
console.log("RpcTest: get ashemm by createAshmemFromExisting : " + ashmem2 + " size is : " + size); console.log("RpcTest: get ashemm by createAshmemFromExisting : " + ashmem2 + " size is : " + size);
``` ```
### closeAshmem<sup>8+</sup> ### closeAshmem<sup>8+</sup>
closeAshmem(): void closeAshmem(): void
**描述**
关闭这个Ashmem。 关闭这个Ashmem。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -8464,11 +8898,12 @@ closeAshmem(): void ...@@ -8464,11 +8898,12 @@ closeAshmem(): void
ashmem.closeAshmem(); ashmem.closeAshmem();
``` ```
### unmapAshmem<sup>8+</sup> ### unmapAshmem<sup>8+</sup>
unmapAshmem(): void unmapAshmem(): void
**描述**
删除该Ashmem对象的地址映射。 删除该Ashmem对象的地址映射。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -8480,11 +8915,12 @@ unmapAshmem(): void ...@@ -8480,11 +8915,12 @@ unmapAshmem(): void
ashmem.unmapAshmem(); ashmem.unmapAshmem();
``` ```
### getAshmemSize<sup>8+</sup> ### getAshmemSize<sup>8+</sup>
getAshmemSize(): number getAshmemSize(): number
**描述**
获取Ashmem对象的内存大小。 获取Ashmem对象的内存大小。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -8503,11 +8939,12 @@ getAshmemSize(): number ...@@ -8503,11 +8939,12 @@ getAshmemSize(): number
console.log("RpcTest: get ashmem is " + ashmem + " size is : " + size); console.log("RpcTest: get ashmem is " + ashmem + " size is : " + size);
``` ```
### mapTypedAshmem<sup>9+</sup> ### mapTypedAshmem<sup>9+</sup>
mapTypedAshmem(mapType: number): void mapTypedAshmem(mapType: number): void
**描述**
在此进程的虚拟地址空间上创建共享文件映射,映射区域大小由此Ashmem对象指定。 在此进程的虚拟地址空间上创建共享文件映射,映射区域大小由此Ashmem对象指定。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -8538,13 +8975,14 @@ mapTypedAshmem(mapType: number): void ...@@ -8538,13 +8975,14 @@ mapTypedAshmem(mapType: number): void
} }
``` ```
### mapAshmem<sup>8+(deprecated)</sup> ### mapAshmem<sup>8+(deprecated)</sup>
>从API version 9 开始不再维护,建议使用[mapTypedAshmem](#maptypedashmem9)类替代。 >从API version 9 开始不再维护,建议使用[mapTypedAshmem](#maptypedashmem9)类替代。
mapAshmem(mapType: number): boolean mapAshmem(mapType: number): boolean
**描述**
在此进程的虚拟地址空间上创建共享文件映射,映射区域大小由此Ashmem对象指定。 在此进程的虚拟地址空间上创建共享文件映射,映射区域大小由此Ashmem对象指定。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -8559,7 +8997,7 @@ mapAshmem(mapType: number): boolean ...@@ -8559,7 +8997,7 @@ mapAshmem(mapType: number): boolean
| 类型 | 说明 | | 类型 | 说明 |
| ------- | ----------------------------------------- | | ------- | ----------------------------------------- |
| boolean | 如果映射成功,则返回true;否则返回false。 | | boolean | true:映射成功,false:映射失败。|
**示例:** **示例:**
...@@ -8569,11 +9007,12 @@ mapAshmem(mapType: number): boolean ...@@ -8569,11 +9007,12 @@ mapAshmem(mapType: number): boolean
console.log("RpcTest: map ashmem result is : " + mapReadAndWrite); console.log("RpcTest: map ashmem result is : " + mapReadAndWrite);
``` ```
### mapReadWriteAshmem<sup>9+</sup> ### mapReadWriteAshmem<sup>9+</sup>
mapReadWriteAshmem(): void mapReadWriteAshmem(): void
**描述**
在此进程虚拟地址空间上创建可读写的共享文件映射。 在此进程虚拟地址空间上创建可读写的共享文件映射。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -8598,13 +9037,14 @@ mapReadWriteAshmem(): void ...@@ -8598,13 +9037,14 @@ mapReadWriteAshmem(): void
} }
``` ```
### mapReadAndWriteAshmem<sup>8+(deprecated)</sup> ### mapReadAndWriteAshmem<sup>8+(deprecated)</sup>
>从API version 9 开始不再维护,建议使用[mapReadWriteAshmem](#mapreadwriteashmem9)类替代。 >从API version 9 开始不再维护,建议使用[mapReadWriteAshmem](#mapreadwriteashmem9)类替代。
mapReadAndWriteAshmem(): boolean mapReadAndWriteAshmem(): boolean
**描述**
在此进程虚拟地址空间上创建可读写的共享文件映射。 在此进程虚拟地址空间上创建可读写的共享文件映射。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -8613,7 +9053,7 @@ mapReadAndWriteAshmem(): boolean ...@@ -8613,7 +9053,7 @@ mapReadAndWriteAshmem(): boolean
| 类型 | 说明 | | 类型 | 说明 |
| ------- | ----------------------------------------- | | ------- | ----------------------------------------- |
| boolean | 如果映射成功,则返回true;否则返回false。 | | boolean | true:映射成功,false:映射失败。|
**示例:** **示例:**
...@@ -8623,11 +9063,12 @@ mapReadAndWriteAshmem(): boolean ...@@ -8623,11 +9063,12 @@ mapReadAndWriteAshmem(): boolean
console.log("RpcTest: map ashmem result is : " + mapResult); console.log("RpcTest: map ashmem result is : " + mapResult);
``` ```
### mapReadonlyAshmem<sup>9+</sup> ### mapReadonlyAshmem<sup>9+</sup>
mapReadonlyAshmem(): void mapReadonlyAshmem(): void
**描述**
在此进程虚拟地址空间上创建只读的共享文件映射。 在此进程虚拟地址空间上创建只读的共享文件映射。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -8652,13 +9093,14 @@ mapReadonlyAshmem(): void ...@@ -8652,13 +9093,14 @@ mapReadonlyAshmem(): void
} }
``` ```
### mapReadOnlyAshmem<sup>8+(deprecated)</sup> ### mapReadOnlyAshmem<sup>8+(deprecated)</sup>
>从API version 9 开始不再维护,建议使用[mapReadonlyAshmem](#mapreadonlyashmem9)类替代。 >从API version 9 开始不再维护,建议使用[mapReadonlyAshmem](#mapreadonlyashmem9)类替代。
mapReadOnlyAshmem(): boolean mapReadOnlyAshmem(): boolean
**描述**
在此进程虚拟地址空间上创建只读的共享文件映射。 在此进程虚拟地址空间上创建只读的共享文件映射。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -8667,7 +9109,7 @@ mapReadOnlyAshmem(): boolean ...@@ -8667,7 +9109,7 @@ mapReadOnlyAshmem(): boolean
| 类型 | 说明 | | 类型 | 说明 |
| ------- | ----------------------------------------- | | ------- | ----------------------------------------- |
| boolean | 如果映射成功,则返回true;否则返回false。 | | boolean | true:映射成功,false:映射失败。|
**示例:** **示例:**
...@@ -8677,11 +9119,12 @@ mapReadOnlyAshmem(): boolean ...@@ -8677,11 +9119,12 @@ mapReadOnlyAshmem(): boolean
console.log("RpcTest: Ashmem mapReadOnlyAshmem result is : " + mapResult); console.log("RpcTest: Ashmem mapReadOnlyAshmem result is : " + mapResult);
``` ```
### setProtectionType<sup>9+</sup> ### setProtectionType<sup>9+</sup>
setProtectionType(protectionType: number): void setProtectionType(protectionType: number): void
**描述**
设置映射内存区域的保护等级。 设置映射内存区域的保护等级。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -8712,13 +9155,14 @@ setProtectionType(protectionType: number): void ...@@ -8712,13 +9155,14 @@ setProtectionType(protectionType: number): void
} }
``` ```
### setProtection<sup>8+(deprecated)</sup> ### setProtection<sup>8+(deprecated)</sup>
>从API version 9 开始不再维护,建议使用[setProtectionType](#setprotectiontype9)类替代。 >从API version 9 开始不再维护,建议使用[setProtectionType](#setprotectiontype9)类替代。
setProtection(protectionType: number): boolean setProtection(protectionType: number): boolean
**描述**
设置映射内存区域的保护等级。 设置映射内存区域的保护等级。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -8733,7 +9177,7 @@ setProtection(protectionType: number): boolean ...@@ -8733,7 +9177,7 @@ setProtection(protectionType: number): boolean
| 类型 | 说明 | | 类型 | 说明 |
| ------- | ----------------------------------------- | | ------- | ----------------------------------------- |
| boolean | 如果设置成功,则返回true;否则返回false。 | | boolean | true:设置成功,false:设置失败。|
**示例:** **示例:**
...@@ -8743,11 +9187,12 @@ setProtection(protectionType: number): boolean ...@@ -8743,11 +9187,12 @@ setProtection(protectionType: number): boolean
console.log("RpcTest: Ashmem setProtection result is : " + result); console.log("RpcTest: Ashmem setProtection result is : " + result);
``` ```
### writeAshmem<sup>9+</sup> ### writeAshmem<sup>9+</sup>
writeAshmem(buf: number[], size: number, offset: number): void writeAshmem(buf: number[], size: number, offset: number): void
**描述**
将数据写入此Ashmem对象关联的共享文件。 将数据写入此Ashmem对象关联的共享文件。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -8782,13 +9227,14 @@ writeAshmem(buf: number[], size: number, offset: number): void ...@@ -8782,13 +9227,14 @@ writeAshmem(buf: number[], size: number, offset: number): void
} }
``` ```
### writeToAshmem<sup>8+(deprecated)</sup> ### writeToAshmem<sup>8+(deprecated)</sup>
>从API version 9 开始不再维护,建议使用[writeAshmem](#writeashmem9)类替代。 >从API version 9 开始不再维护,建议使用[writeAshmem](#writeashmem9)类替代。
writeToAshmem(buf: number[], size: number, offset: number): boolean writeToAshmem(buf: number[], size: number, offset: number): boolean
**描述**
将数据写入此Ashmem对象关联的共享文件。 将数据写入此Ashmem对象关联的共享文件。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -8805,7 +9251,7 @@ writeToAshmem(buf: number[], size: number, offset: number): boolean ...@@ -8805,7 +9251,7 @@ writeToAshmem(buf: number[], size: number, offset: number): boolean
| 类型 | 说明 | | 类型 | 说明 |
| ------- | ----------------------------------------------------------------------------------------- | | ------- | ----------------------------------------------------------------------------------------- |
| boolean | 如果数据写入成功,则返回true;在其他情况下,如数据写入越界或未获得写入权限,则返回false。 | | boolean | true:如果数据写入成功,false:在其他情况下,如数据写入越界或未获得写入权限。。 |
**示例:** **示例:**
...@@ -8818,11 +9264,12 @@ writeToAshmem(buf: number[], size: number, offset: number): boolean ...@@ -8818,11 +9264,12 @@ writeToAshmem(buf: number[], size: number, offset: number): boolean
console.log("RpcTest: write to Ashmem result is : " + writeResult); console.log("RpcTest: write to Ashmem result is : " + writeResult);
``` ```
### readAshmem<sup>9+</sup> ### readAshmem<sup>9+</sup>
readAshmem(size: number, offset: number): number[] readAshmem(size: number, offset: number): number[]
**描述**
从此Ashmem对象关联的共享文件中读取数据。 从此Ashmem对象关联的共享文件中读取数据。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
...@@ -8864,13 +9311,14 @@ readAshmem(size: number, offset: number): number[] ...@@ -8864,13 +9311,14 @@ readAshmem(size: number, offset: number): number[]
} }
``` ```
### readFromAshmem<sup>8+(deprecated)</sup> ### readFromAshmem<sup>8+(deprecated)</sup>
>从API version 9 开始不再维护,建议使用[readAshmem](#readashmem9)类替代。 >从API version 9 开始不再维护,建议使用[readAshmem](#readashmem9)类替代。
readFromAshmem(size: number, offset: number): number[] readFromAshmem(size: number, offset: number): number[]
**描述**
从此Ashmem对象关联的共享文件中读取数据。 从此Ashmem对象关联的共享文件中读取数据。
**系统能力**:SystemCapability.Communication.IPC.Core **系统能力**:SystemCapability.Communication.IPC.Core
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册