1# DSoftBus Subsystem Changelog 2 3## Support for Exception Handling and Determining Synchronous or Asynchronous Message Sending by Passing in a Boolean or Numeric Value in IPC&RPC APIs 41. Some IPC&RPC APIs of DSoftBus use service logic return values to indicate error information, which does not comply with the API error code specifications of OpenHarmony. 52. A Boolean value can be passed in to specify the message transfer mode, which can be asynchronous or synchronous. 6#### Change Impact 7 8This version is compatible with earlier versions and no adaptation is required. Newly added APIs can be called to support the following changes: 91. Implement exception handling and return of error codes. 102. Enable messages to be sent synchronously or asynchronously by using a Boolean value or a number of **0** or non-0. 11 12#### **Key API/Component Changes** 13 14To ease the adaptation, the related IPC&RPC APIs are deprecated and replaced by new APIs. The newly added APIs support unified error code handling specifications and function the same as the original APIs. 15| Class| Deprecated API | New Class | New API | 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 \| Promise<boolean> | NA | onRemoteMessageRequest(code: number, data: MessageSequence, reply: MessageSequence, options: MessageOption): boolean \| 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#### Adaptation Guide 132 133The new APIs return error codes and error information by throwing exceptions. The following uses the **create()** API of **MessageParcel** as an example. 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``` 145For details about the APIs, see [RPC](../../../application-dev/reference/apis/js-apis-rpc.md). 146