• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# 软总线子系统Changelog
2
3## IPC&RPC API支持异常处理方式和支持传入布尔值与数值选择同步或异步方式发送信息变更
41. 软总线IPC&RPC部分接口使用业务逻辑返回值表示错误信息,不符合OpenHarmony接口错误规范;
52. 支持传入布尔值选择同步或异步方式发送信息。
6#### 变更影响
7
8此版本兼容之前的应用开发,不需要适配,后续可调用新增接口支持以下两个变更:
91. 支持异常处理并返回错误码;
102. 提供通过布尔值或通过0与非0数字选择同步或异步发消息。
11
12#### 关键接口/组件变更
13
14为适配统一的API异常处理方式,对IPC&RPC相关接口进行废弃,并新增对应接口和方法。新增接口支持统一的错误码异常处理规范,功能上与原接口保持一致。
15|  类名 | 废弃接口  | 新增替换类名  | 新增替代接口  |
16| ------------ | ------------ | ------------ | ------------ |
17| MessageParcel | static create(): MessageParcel | MessageSequence  | static create(): MessageSequence |
18| MessageParcel | reclaim(): void | MessageSequence | reclaim(): void |
19| MessageParcel | writeRemoteObject(object: IRemoteObject): boolean| MessageSequence |writeRemoteObject(object: IRemoteObject): void|
20| MessageParcel | readRemoteObject(): IRemoteObject | MessageSequence | readRemoteObject(): IRemoteObject |
21|  MessageParcel | writeInterfaceToken(token: string): boolean | MessageSequence | writeInterfaceToken(token: string): void |
22|  MessageParcel | readInterfaceToken(): string | MessageSequence | readInterfaceToken(): string |
23|  MessageParcel | getSize(): number | MessageSequence | getSize(): number |
24|  MessageParcel | getCapacity(): number | MessageSequence | getCapacity(): number|
25|  MessageParcel | setSize(size: number): boolean | MessageSequence | setCapacity(size: number): void |
26|  MessageParcel | getReadableBytes(): number | MessageSequence | getReadableBytes(): number |
27|  MessageParcel | getReadPosition(): number | MessageSequence | getReadPosition(): number |
28|  MessageParcel | getWritePosition(): number | MessageSequence | getWritePosition(): number |
29|  MessageParcel | rewindRead(pos: number): boolean | MessageSequence | rewindRead(pos: number): void |
30|  MessageParcel | rewindWrite(pos: number): boolean | MessageSequence  | rewindWrite(pos: number): void |
31|  MessageParcel | writeNoException(): void | MessageSequence | writeNoException(): void |
32|  MessageParcel | readException(): void | MessageSequence  | readException(): void |
33|  MessageParcel | writeByte(val: number): boolean | MessageSequence  | writeByte(val: number): void |
34|  MessageParcel | writeShort(val: number): boolean | MessageSequence | writeShort(val: number): void |
35|  MessageParcel | writeInt(val: number): boolean | MessageSequence | writeInt(val: number): void |
36|  MessageParcel | writeLong(val: number): boolean | MessageSequence | writeLong(val: number): void |
37|  MessageParcel | writeFloat(val: number): boolean | MessageSequence | writeFloat(val: number): void |
38|  MessageParcel | writeDouble(val: number): boolean | MessageSequence | writeDouble(val: number): void |
39|  MessageParcel | writeBoolean(val: boolean): boolean | MessageSequence | writeBoolean(val: boolean): void |
40|  MessageParcel | writeChar(val: number): boolean | MessageSequence | writeChar(val: number): void |
41|  MessageParcel | writeString(val: string): boolean | MessageSequence | writeString(val: string): void |
42|  MessageParcel | writeSequenceable(val: Sequenceable): boolean | MessageSequence | writeParcelable(val: Parcelable): void |
43|  MessageParcel | writeByteArray(byteArray: number[]): boolean | MessageSequence | writeByteArray(byteArray: number[]): void |
44|  MessageParcel | writeShortArray(shortArray: number[]): boolean | MessageSequence | writeShortArray(shortArray: number[]): void |
45|  MessageParcel | writeIntArray(intArray: number[]): boolean | MessageSequence | writeIntArray(intArray: number[]): void |
46|  MessageParcel | writeLongArray(longArray: number[]): boolean | MessageSequence | writeLongArray(longArray: number[]): void |
47|  MessageParcel | writeFloatArray(floatArray: number[]): boolean | MessageSequence | writeFloatArray(floatArray: number[]): void |
48|  MessageParcel | writeDoubleArray(doubleArray: number[]): boolean | MessageSequence | writeDoubleArray(doubleArray: number[]): void |
49|  MessageParcel | writeBooleanArray(booleanArray: boolean[]): boolean | MessageSequence | writeBooleanArray(booleanArray: boolean[]): void |
50|  MessageParcel | writeCharArray(charArray: number[]): boolean | MessageSequence | writeCharArray(charArray: number[]): void |
51|  MessageParcel | writeStringArray(stringArray: string[]): boolean | MessageSequence  | writeStringArray(stringArray: string[]): void |
52|  MessageParcel | writeSequenceableArray(sequenceableArray: Sequenceable[]): boolean | MessageSequence  | writeParcelableArray(sequenceableArray: Parcelable[]): void |
53|  MessageParcel | writeRemoteObjectArray(objectArray: IRemoteObject[]): boolean | MessageSequence  | writeRemoteObjectArray(objectArray: IRemoteObject[]): void |
54|  MessageParcel | readByte(): number | MessageSequence | readByte(): number |
55|  MessageParcel | readShort(): number | MessageSequence | readShort(): number |
56|  MessageParcel | readLong(): number | MessageSequence | readLong(): number |
57|  MessageParcel | readFloat(): number | MessageSequence | readFloat(): number |
58|  MessageParcel | readDouble(): number | MessageSequence | readDouble(): number |
59|  MessageParcel | readBoolean(): boolean | MessageSequence | readBoolean(): boolean |
60|  MessageParcel | readChar(): number | MessageSequence | readChar(): number |
61|  MessageParcel | readString(): string | MessageSequence | readString(): string |
62|  MessageParcel | readSequenceable(dataIn: Sequenceable) : boolean | MessageSequence | readSequenceable(dataIn: Parcelable) : void |
63|  MessageParcel | readByteArray(dataIn: number[]) : void | MessageSequence | readByteArray(dataIn: number[]) : void |
64|  MessageParcel | readByteArray(): number[] | MessageSequence | readByteArray(): number[] |
65|  MessageParcel | readShortArray(dataIn: number[]) : void | MessageSequence | readShortArray(dataIn: number[]) : void |
66|  MessageParcel | readShortArray(): number[] | MessageSequence | readShortArray(): number[] |
67|  MessageParcel | readIntArray(dataIn: number[]) : void | MessageSequence | readIntArray(dataIn: number[]) : void |
68|  MessageParcel | readIntArray() : number[] | MessageSequence | readIntArray() : number[] |
69|  MessageParcel | readLongArray(dataIn: number[]) : void | MessageSequence | readLongArray(dataIn: number[]) : void |
70|  MessageParcel | readLongArray(): number[] | MessageSequence | readLongArray(): number[] |
71|  MessageParcel | readFloatArray(dataIn: number[]) : void | MessageSequence | readFloatArray(dataIn: number[]) : void |
72|  MessageParcel | readFloatArray(): number[] | MessageSequence | readFloatArray(): number[] |
73|  MessageParcel | readDoubleArray(dataIn: number[]) : void | MessageSequence | readDoubleArray(dataIn: number[]) : void |
74|  MessageParcel | readDoubleArray(): number[] | MessageSequence | readDoubleArray(): number[] |
75|  MessageParcel | readBooleanArray(dataIn: boolean[]) : void | MessageSequence | readBooleanArray(dataIn: boolean[]) : void |
76|  MessageParcel | readBooleanArray(): boolean[] | MessageSequence | readBooleanArray(): boolean[] |
77|  MessageParcel | readCharArray(dataIn: number[]) : void | MessageSequence | readCharArray(dataIn: number[]) : void |
78|  MessageParcel | readCharArray(): number[] | MessageSequence | readCharArray(): number[] |
79|  MessageParcel | readStringArray(dataIn: string[]) : void | MessageSequence | readStringArray(dataIn: string[]) : void |
80|  MessageParcel | readStringArray(): string[] | MessageSequence | readStringArray(): string[] |
81| MessageParcel | readSequenceableArray(sequenceableArray: Sequenceable[]): void | MessageSequence | readSequenceableArray(sequenceableArray: Parcelable[]): void |
82| MessageParcel | readRemoteObjectArray(objects: IRemoteObject[]): void | MessageSequence | readRemoteObjectArray(objects: IRemoteObject[]): void |
83| MessageParcel | readRemoteObjectArray(): IRemoteObject[] | MessageSequence | readRemoteObjectArray(): IRemoteObject[] |
84| MessageParcel | static closeFileDescriptor(fd: number): void | MessageSequence | static closeFileDescriptor(fd: number): void |
85| MessageParcel | static dupFileDescriptor(fd: number) :number | MessageSequence | static dupFileDescriptor(fd: number) :number |
86| MessageParcel | containFileDescriptors(): boolean | MessageSequence | containFileDescriptors(): boolean |
87| MessageParcel | writeFileDescriptor(fd: number): boolean | MessageSequence | writeFileDescriptor(fd: number): void |
88| MessageParcel | readFileDescriptor(): number | MessageSequence | readFileDescriptor(): number |
89| MessageParcel | writeAshmem(ashmem: Ashmem): boolean | MessageSequence | writeAshmem(ashmem: Ashmem): void |
90| MessageParcel | readAshmem(): Ashmem | MessageSequence | readAshmem(): Ashmem |
91| MessageParcel | writeRawData(rawData: number[], size: number): boolean | MessageSequence | writeRawData(rawData: number[], size: number): void |
92| MessageParcel | readRawData(size: number): number[] | MessageSequence | readRawData(size: number): number[] |
93| Sequenceable | marshalling(dataOut: MessageParcel): boolean | Parcelable | marshalling(dataOut: MessageSequence): boolean |
94| Sequenceable | unmarshalling(dataIn: MessageParcel) : boolean | Parcelable | unmarshalling(dataIn: MessageSequence) : boolean |
95| SendRequestResult | errCode: number | RequestResult | errCode: number |
96| SendRequestResult | code: number | RequestResult | code: number |
97| SendRequestResult | data: MessageParcel | RequestResult | data: MessageSequence |
98| SendRequestResult | reply: MessageParcel | RequestResult | reply: MessageSequence |
99| IRemoteObject | queryLocalInterface(descriptor: string): IRemoteBroker | NA | getLocalInterface(descriptor: string): IRemoteBroker |
100| IRemoteObject | getInterfaceDescriptor(): string | NA | getDescriptor(): string |
101| IRemoteObject | addDeathRecipient(recipient: DeathRecipient, flags: number): boolean | NA | registerDeathRecipient(recipient: DeathRecipient, flags: number): void |
102| IRemoteObject | removeDeathRecipient(recipient: DeathRecipient, flags: number): boolean | NA | unregisterDeathRecipient(recipient: DeathRecipient, flags: number): void |
103| IRemoteObject | NA | NA | sendMessageRequest(code: number, data: MessageSequence, reply: MessageSequence, options: MessageOption): Promise<RequestResult> |
104| IRemoteObject | sendRequest(code: number, data: MessageParcel, reply: MessageParcel, options: MessageOption, callback: AsyncCallback<SendRequestResult>): void | NA | sendMessageRequest(code: number, data: MessageSequence, reply: MessageSequence, options: MessageOption,callback: AsyncCallback<RequestResult>): void |
105| MessageOption | NA | NA | isAsync(): boolean |
106| MessageOption | NA | NA | setAsync(async: boolean): void |
107| MessageOption | NA | NA | constructor(async?: boolean) |
108| RemoteObject | queryLocalInterface(descriptor: string): IRemoteBroker | NA | getLocalInterface(descriptor: string): IRemoteBroker |
109| RemoteObject | attachLocalInterface(localInterface: IRemoteBroker, descriptor: string): void  | NA | modifyLocalInterface(localInterface: IRemoteBroker, descriptor: string): void |
110| RemoteObject | getInterfaceDescriptor(): string | NA | getDescriptor(): string |
111| RemoteObject | onRemoteRequestEx(code : number, data : MessageParcel, reply: MessageParcel, options : MessageOption): boolean&nbsp;\|&nbsp;Promise<boolean> | NA | onRemoteMessageRequest(code: number, data: MessageSequence, reply: MessageSequence, options: MessageOption): boolean&nbsp;\|&nbsp;Promise<boolean> |
112| RemoteObject | sendRequest(code: number, data: MessageParcel, reply: MessageParcel, options: MessageOption): Promise<SendRequestResult> | NA | sendMessageRequest(code: number, data: MessageSequence, reply: MessageSequence, options: MessageOption): Promise<RequestResult> |
113| RemoteObject | sendRequest(code: number, data: MessageParcel, reply: MessageParcel, options: MessageOption, callback: AsyncCallback<SendRequestResult>): void | NA | sendMessageRequest(code: number, data: MessageSequence, reply: MessageSequence, options: MessageOption, callback: AsyncCallback<RequestResult>): void |
114| RemoteProxy | queryLocalInterface(interface: string): IRemoteBroker | NA | getLocalInterface(descriptor: string): IRemoteBroker |
115| RemoteProxy | getInterfaceDescriptor(): string | NA | getDescriptor(): string |
116| RemoteProxy | addDeathRecipient(recipient: DeathRecipient, flags: number): boolean | NA | registerDeathRecipient(recipient: DeathRecipient, flags: number): void |
117| RemoteProxy | removeDeathRecipient(recipient: DeathRecipient, flags: number): boolean | NA | unregisterDeathRecipient(recipient: DeathRecipient, flags: number): void |
118| RemoteProxy | NA | NA | sendMessageRequest(code: number, data: MessageSequence, reply: MessageSequence, options: MessageOption): Promise<RequestResult> |
119| RemoteProxy | sendRequest(code: number, data: MessageParcel, reply: MessageParcel, options: MessageOption, callback: AsyncCallback<SendRequestResult>): void | NA | sendMessageRequest(code: number, data: MessageSequence, reply: MessageSequence, options: MessageOption, callback: AsyncCallback<RequestResult>): void |
120| IPCSkeleton | static flushCommands(object: IRemoteObject): number | NA | static flushCmdBuffer(object: IRemoteObject): void |
121| IPCSkeleton | static setCallingIdentity(identity: string): boolean | NA | static restoreCallingIdentity(identity: string): void |
122| Ashmem | static createAshmem(name: string, size: number): Ashmem | NA | static create(name: string, size: number): Ashmem |
123| Ashmem  | static createAshmemFromExisting(ashmem: Ashmem): Ashmem | NA | static create(ashmem: Ashmem): Ashmem |
124| Ashmem  | mapAshmem(mapType: number): boolean | NA | mapTypedAshmem(mapType: number): void |
125| Ashmem  | mapReadAndWriteAshmem(): boolean | NA | mapReadWriteAshmem(): void |
126| Ashmem  | mapReadOnlyAshmem(): boolean | NA | mapReadonlyAshmem(): void |
127| Ashmem  | setProtection(protectionType: number): boolean | NA | setProtectionType(protectionType: number): void |
128| Ashmem  | writeToAshmem(buf: number[], size: number, offset: number): boolean | NA | writeAshmem(buf: number[], size: number, offset: number): void |
129| Ashmem  | readFromAshmem(size: number, offset: number): number[] | NA | readAshmem(size: number, offset: number): number[] |
130
131#### 适配指导
132
133新增的接口以抛异常的方式返回错误码及对应的错误信息,以MessageParcel中的create接口为例,使用示例代码如下:
134```js
135import rpc from '@ohos.rpc'
136
137try {
138    var data = rpc.MessageParcel.create();
139    data.reclaim();
140} catch (error) {
141    console.info("create meassageParcel failed, errorCode = " + error.errCode);
142    console.info("create meassageParcel failed, errorMessage = " + error.errorMessage);
143}
144```
145更多接口的示例代码可参考[RPC通信API文档](../../../application-dev/reference/apis/js-apis-rpc.md)。