• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (C) 2021-2022 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16import { AsyncCallback } from './basic'
17
18declare namespace rpc {
19    /**
20     * The error code of rpc.
21     * @syscap SystemCapability.Communication.IPC.Core
22     * @since 9
23     */
24    enum ErrorCode {
25        /* Check param failed */
26        CHECK_PARAM_ERROR = 401,
27
28        /* Os mmap function failed */
29        OS_MMAP_ERROR = 1900001,
30
31        /* Os ioctl function failed */
32        OS_IOCTL_ERROR = 1900002,
33
34        /* Write to ashmem failed */
35        WRITE_TO_ASHMEM_ERROR = 1900003,
36
37        /* Read from ashmem failed */
38        READ_FROM_ASHMEM_ERROR = 1900004,
39
40        /* Only proxy object permitted */
41        ONLY_PROXY_OBJECT_PERMITTED_ERROR = 1900005,
42
43        /* Only remote object permitted */
44        ONLY_REMOTE_OBJECT_PERMITTED_ERROR = 1900006,
45
46        /* Communication failed */
47        COMMUNICATION_ERROR = 1900007,
48
49        /* Proxy or remote object is invalid */
50        PROXY_OR_REMOTE_OBJECT_INVALID_ERROR = 1900008,
51
52        /* Write data to message sequence failed */
53        WRITE_DATA_TO_MESSAGE_SEQUENCE_ERROR = 1900009,
54
55        /* Read data from message sequence failed */
56        READ_DATA_FROM_MESSAGE_SEQUENCE_ERROR = 1900010,
57
58        /* Parcel memory alloc failed */
59        PARCEL_MEMORY_ALLOC_ERROR = 1900011,
60
61        /* Call js method failed */
62        CALL_JS_METHOD_ERROR = 1900012,
63
64        /* Os dup function failed */
65        OS_DUP_ERROR = 1900013
66    }
67
68    /**
69     * A data object used for remote procedure call (RPC).
70     * <p>
71     * During RPC, the sender can use the write methods provided by {@link MessageParcel} to
72     * write the to-be-sent data into a {@link MessageParcel} object in a specific format, and the receiver can use the
73     * read methods provided by {@link MessageParcel} to read data of the specific format from the {@link MessageParcel} object.
74     * <p>
75     * <p>
76     * The default capacity of a {@link MessageParcel} instance is 200KB. If you want more or less, use {@link #setCapacity(int)}
77     * to change it.
78     * </p>
79     * <b>Note</b>: Only data of the following data types can be written into or read from a {@link MessageParcel}: byte,
80     * byteArray, short, shortArray, int, intArray, long, longArray, float, floatArray, double, doubleArray, boolean,
81     * booleanArray, char, charArray, String, StringArray, {@link IRemoteObject}, IRemoteObjectArray,
82     * {@link Sequenceable}, and SequenceableArray.
83     *
84     * @since 7
85     * @deprecated since 9
86     * @useinstead ohos.rpc.MessageSequence
87     * @syscap SystemCapability.Communication.IPC.Core
88     */
89    class MessageParcel {
90        /**
91         * Creates an empty {@link MessageParcel} object.
92         * @returns Return the object created.
93         * @since 7
94         */
95        static create(): MessageParcel;
96
97        /**
98         * Reclaim the {@link MessageParcel} object.
99         * @since 7
100         */
101        reclaim(): void;
102
103        /**
104         * Serialize a remote object and writes it to the {@link MessageParcel} object.
105         * @param object Remote object to serialize.
106         * @returns Return true if it is successful; return false otherwise.
107         * @since 7
108         */
109        writeRemoteObject(object: IRemoteObject): boolean;
110
111        /**
112         * Reads a remote object from {@link MessageParcel} object.
113         * @returns Return the remote object.
114         * @since 7
115         */
116        readRemoteObject(): IRemoteObject;
117
118        /**
119         * Writes an interface token into the {@link MessageParcel} object.
120         * @param token Interface descriptor to write.
121         * @returns Return {@code true} if the interface token has been written into the {@link MessageParcel};
122         *          return {@code false} otherwise.
123         * @since 7
124         */
125        writeInterfaceToken(token: string): boolean;
126
127        /**
128         * Reads an interface token from the {@link MessageParcel} object.
129         * @returns Return a string value.
130         * @since 7
131         */
132        readInterfaceToken(): string;
133
134        /**
135         * Obtains the size of data (in bytes) contained in the {@link MessageParcel} object.
136         * @returns Return the size of data contained in the {@link MessageParcel} object.
137         * @since 7
138         */
139        getSize(): number;
140
141        /**
142         * Obtains the storage capacity (in bytes) of the {@link MessageParcel} object.
143         * @returns Return the storage capacity of the {@link MessageParcel} object.
144         * @since 7
145         */
146        getCapacity(): number;
147
148        /**
149         * Sets the size of data (in bytes) contained in the {@link MessageParcel} object.
150         * <p>{@code false} is returned if the data size set in this method is greater
151         * than the storage capacity of the {@link MessageParcel}.
152         *
153         * @param size Indicates the data size of the {@link MessageParcel} object.
154         * @returns Return {@code true} if the setting is successful; return {@code false} otherwise.
155         * @since 7
156         */
157        setSize(size: number): boolean;
158
159        /**
160         * Sets the storage capacity (in bytes) of the {@link MessageParcel} object.
161         * <p>{@code false} is returned if the capacity set in this method is less than
162         * the size of data contained in the {@link MessageParcel}.
163         *
164         * @param size Indicates the storage capacity of the {@link MessageParcel} object.
165         * @returns Return {@code true} if the setting is successful; return {@code false} otherwise.
166         * @since 7
167         */
168        setCapacity(size: number): boolean;
169
170        /**
171         * Obtains the writable data space (in bytes) in the {@link MessageParcel} object.
172         * <p>Writable data space = Storage capacity of the {@link MessageParcel} – Size of data contained in the {@link MessageParcel}.
173         *
174         * @returns Return the writable data space of the {@link MessageParcel} object.
175         * @since 7
176         */
177        getWritableBytes(): number;
178
179        /**
180         * Obtains the readable data space (in bytes) in the {@link MessageParcel} object.
181         * <p>Readable data space = Size of data contained in the {@link MessageParcel} – Size of data that has been read.
182         *
183         * @returns Return the readable data space of the {@link MessageParcel} object.
184         * @since 7
185         */
186        getReadableBytes(): number;
187
188        /**
189         * Obtains the current read position in the {@link MessageParcel} object.
190         * @returns Return the current read position in the {@link MessageParcel} object.
191         * @since 7
192         */
193        getReadPosition(): number;
194
195        /**
196         * Obtains the current write position in the {@link MessageParcel} object.
197         * @returns Return the current write position in the {@link MessageParcel} object.
198         * @since 7
199         */
200        getWritePosition(): number;
201
202        /**
203         * Changes the current read position in the {@link MessageParcel} object.
204         * <p>Generally, you are advised not to change the current read position. If you must
205         * change it, change it to an accurate position. Otherwise, the read data may be incorrect.
206         *
207         * @param pos Indicates the target position to start data reading.
208         * @returns Return {@code true} if the read position is changed; return {@code false} otherwise.
209         * @since 7
210         */
211        rewindRead(pos: number): boolean;
212
213        /**
214         * Changes the current write position in the {@link MessageParcel} object.
215         * <p>Generally, you are advised not to change the current write position. If you must
216         * change it, change it to an accurate position. Otherwise, the data to be read may be incorrect.
217         *
218         * @param pos Indicates the target position to start data writing.
219         * @returns Return {@code true} if the write position is changed; return {@code false} otherwise.
220         * @since 7
221         */
222        rewindWrite(pos: number): boolean;
223
224        /**
225         * Writes information to this MessageParcel object indicating that no exception occurred.
226         * <p>After handling requests, you should call this method before writing any data to reply {@link MessageParcel}.
227         * @since 8
228         */
229        writeNoException(): void;
230
231        /**
232         * Reads the exception information from this MessageParcel object.
233         * <p>If exception was thrown in server side, it will be thrown here.
234         * This method should be called before reading any data from reply {@link MessageParcel}
235         * if {@link writeNoException} was invoked in server side.
236         * @throws Throws an exception if it thrown in server side.
237         * @since 8
238         */
239        readException(): void;
240
241        /**
242         * Writes a byte value into the {@link MessageParcel} object.
243         * @param val Indicates the byte value to write.
244         * @returns Return {@code true} if the value has been written into the {@link MessageParcel};
245         *          return {@code false} otherwise.
246         * @throws ParcelException When capacity in this parcel is insufficient,
247         *         exception message: {@link ParcelException#NO_CAPACITY_ERROR}.
248         * @since 7
249         */
250        writeByte(val: number): boolean;
251
252        /**
253         * Writes a short integer value into the {@link MessageParcel} object.
254         * @param val Indicates the short integer value to write.
255         * @returns Return {@code true} if the value has been written into the {@link MessageParcel};
256         *          return {@code false} otherwise.
257         * @throws ParcelException When capacity in this parcel is insufficient,
258         *         exception message: {@link ParcelException#NO_CAPACITY_ERROR}.
259         * @since 7
260         */
261        writeShort(val: number): boolean;
262
263        /**
264         * Writes an integer value into the {@link MessageParcel} object.
265         * @param val Indicates the integer value to write.
266         * @returns Return {@code true} if the value has been written into the {@link MessageParcel};
267         *          return {@code false} otherwise.
268         * @throws ParcelException When capacity in this parcel is insufficient,
269         *         exception message: {@link ParcelException#NO_CAPACITY_ERROR}.
270         * @since 7
271         */
272        writeInt(val: number): boolean;
273
274        /**
275         * Writes a long integer value into the {@link MessageParcel} object.
276         * @param val Indicates the long integer value to write.
277         * @returns Return {@code true} if the value has been written into the {@link MessageParcel};
278         *          return {@code false} otherwise.
279         * @throws ParcelException When capacity in this parcel is insufficient,
280         *         exception message: {@link ParcelException#NO_CAPACITY_ERROR}.
281         * @since 7
282         */
283        writeLong(val: number): boolean;
284
285        /**
286         * Writes a floating point value into the {@link MessageParcel} object.
287         * @param val Indicates the floating point value to write.
288         * @returns Return {@code true} if the value has been written into the {@link MessageParcel};
289         *          return {@code false} otherwise.
290         * @throws ParcelException When capacity in this parcel is insufficient,
291         *         exception message: {@link ParcelException#NO_CAPACITY_ERROR}.
292         * @since 7
293         */
294        writeFloat(val: number): boolean;
295
296        /**
297         * Writes a double-precision floating point value into the {@link MessageParcel} object.
298         * @param val Indicates the double-precision floating point value to write.
299         * @returns Return {@code true} if the value has been written into the {@link MessageParcel};
300         *          return {@code false} otherwise.
301         * @throws ParcelException When capacity in this parcel is insufficient,
302         *         exception message: {@link ParcelException#NO_CAPACITY_ERROR}.
303         * @since 7
304         */
305        writeDouble(val: number): boolean;
306
307        /**
308         * Writes a boolean value into the {@link MessageParcel} object.
309         * @param val Indicates the boolean value to write.
310         * @returns Return {@code true} if the value has been written into the {@link MessageParcel};
311         *          return {@code false} otherwise.
312         * @throws ParcelException When capacity in this parcel is insufficient,
313         *         exception message: {@link ParcelException#NO_CAPACITY_ERROR}.
314         * @since 7
315         */
316        writeBoolean(val: boolean): boolean;
317
318        /**
319         * Writes a single character value into the {@link MessageParcel} object.
320         * @param val Indicates the single character value to write.
321         * @returns Return {@code true} if the value has been written into the {@link MessageParcel};
322         *          return {@code false} otherwise.
323         * @throws ParcelException When capacity in this parcel is insufficient,
324         *         exception message: {@link ParcelException#NO_CAPACITY_ERROR}.
325         * @since 7
326         */
327        writeChar(val: number): boolean;
328
329        /**
330         * Writes a string value into the {@link MessageParcel} object.
331         * @param val Indicates the string value to write.
332         * @returns Return {@code true} if the value has been written into the {@link MessageParcel};
333         *          return {@code false} otherwise.
334         * @throws ParcelException When capacity in this parcel is insufficient,
335         *         exception message: {@link ParcelException#NO_CAPACITY_ERROR}.
336         * @since 7
337         */
338        writeString(val: string): boolean;
339
340        /**
341         * Writes a {@link Sequenceable} object into the {@link MessageParcel} object.
342         * @param val Indicates the {@link Sequenceable} object to write.
343         * @throws ParcelException When capacity in this parcel is insufficient,
344         *         exception message: {@link ParcelException#NO_CAPACITY_ERROR}.
345         * @since 7
346         */
347        writeSequenceable(val: Sequenceable): boolean;
348
349        /**
350         * Writes a byte array into the {@link MessageParcel} object.
351         * @param byteArray Indicates the byte array to write.
352         * @returns Return {@code true} if the array has been written into the {@link MessageParcel};
353         *          return {@code false} otherwise.
354         * @throws ParcelException When capacity in this parcel is insufficient,
355         *         exception message: {@link ParcelException#NO_CAPACITY_ERROR}.
356         * @since 7
357         */
358        writeByteArray(byteArray: number[]): boolean;
359
360        /**
361         * Writes a short integer array into the {@link MessageParcel} object.
362         * Ensure that the data type and size comply with the interface definition.
363         * Otherwise,data may be truncated.
364         * @param shortArray Indicates the short integer array to write.
365         * @returns Return {@code true} if the array has been written into the {@link MessageParcel};
366         *          return {@code false} otherwise.
367         * @throws ParcelException When capacity in this parcel is insufficient,
368         *         exception message: {@link ParcelException#NO_CAPACITY_ERROR}.
369         * @since 7
370         */
371        writeShortArray(shortArray: number[]): boolean;
372
373        /**
374         * Writes an integer array into the {@link MessageParcel} object.
375         * Ensure that the data type and size comply with the interface definition.
376         * Otherwise,data may be truncated.
377         * @param intArray Indicates the integer array to write.
378         * @returns Return {@code true} if the array has been written into the {@link MessageParcel};
379         *          return {@code false} otherwise.
380         * @throws ParcelException When capacity in this parcel is insufficient,
381         *         exception message: {@link ParcelException#NO_CAPACITY_ERROR}.
382         * @since 7
383         */
384        writeIntArray(intArray: number[]): boolean;
385
386        /**
387         * Writes a long integer array into the {@link MessageParcel} object.
388         * Ensure that the data type and size comply with the interface definition.
389         * Otherwise,data may be truncated.
390         * @param longArray Indicates the long integer array to write.
391         * @returns Return {@code true} if the array has been written into the {@link MessageParcel};
392         *          return {@code false} otherwise.
393         * @throws ParcelException When capacity in this parcel is insufficient,
394         *         exception message: {@link ParcelException#NO_CAPACITY_ERROR}.
395         * @since 7
396         */
397        writeLongArray(longArray: number[]): boolean;
398
399        /**
400         * Writes a floating point array into the {@link MessageParcel} object.
401         * Ensure that the data type and size comply with the interface definition.
402         * Otherwise,data may be truncated.
403         * @param floatArray Indicates the floating point array to write.
404         * @returns Return {@code true} if the array has been written into the {@link MessageParcel};
405         *          return {@code false} otherwise.
406         * @throws ParcelException When capacity in this parcel is insufficient,
407         *         exception message: {@link ParcelException#NO_CAPACITY_ERROR}.
408         * @since 7
409         */
410        writeFloatArray(floatArray: number[]): boolean;
411
412        /**
413         * Writes a double-precision floating point array into the {@link MessageParcel} object.
414         * Ensure that the data type and size comply with the interface definition.
415         * Otherwise,data may be truncated.
416         * @param doubleArray Indicates the double-precision floating point array to write.
417         * @returns Return {@code true} if the array has been written into the {@link MessageParcel};
418         *          return {@code false} otherwise.
419         * @throws ParcelException When capacity in this parcel is insufficient,
420         *         exception message: {@link ParcelException#NO_CAPACITY_ERROR}.
421         * @since 7
422         */
423        writeDoubleArray(doubleArray: number[]): boolean;
424
425        /**
426         * Writes a boolean array into the {@link MessageParcel} object.
427         * Ensure that the data type and size comply with the interface definition.
428         * Otherwise,data may be truncated.
429         * @param booleanArray Indicates the boolean array to write.
430         * @returns Return {@code true} if the array has been written into the {@link MessageParcel};
431         *          return {@code false} otherwise.
432         * @throws ParcelException When capacity in this parcel is insufficient,
433         *         exception message: {@link ParcelException#NO_CAPACITY_ERROR}.
434         * @since 7
435         */
436        writeBooleanArray(booleanArray: boolean[]): boolean;
437
438        /**
439         * Writes a single character array into the {@link MessageParcel} object.
440         * Ensure that the data type and size comply with the interface definition.
441         * Otherwise,data may be truncated.
442         * @param charArray Indicates the single character array to write.
443         * @returns Return {@code true} if the array has been written into the {@link MessageParcel};
444         *          return {@code false} otherwise.
445         * @throws ParcelException When capacity in this parcel is insufficient,
446         *         exception message: {@link ParcelException#NO_CAPACITY_ERROR}.
447         * @since 7
448         */
449        writeCharArray(charArray: number[]): boolean;
450
451        /**
452         * Writes a string array into the {@link MessageParcel} object.
453         * Ensure that the data type and size comply with the interface definition.
454         * Otherwise,data may be truncated.
455         * @param stringArray Indicates the string array to write.
456         * @returns Return {@code true} if the array has been written into the {@link MessageParcel};
457         *          return {@code false} otherwise.
458         * @throws ParcelException When capacity in this parcel is insufficient,
459         *         exception message: {@link ParcelException#NO_CAPACITY_ERROR}.
460         * @since 7
461         */
462        writeStringArray(stringArray: string[]): boolean;
463
464        /**
465         * Writes a {@link Sequenceable} object array into the {@link MessageParcel} object.
466         * @param sequenceableArray Indicates the {@link Sequenceable} object array to write.
467         * @returns Return {@code true} if the array has been written into the {@link MessageParcel};
468         *          return {@code false} otherwise.
469         * @throws ParcelException When capacity in this parcel is insufficient,
470         *         exception message: {@link ParcelException#NO_CAPACITY_ERROR}.
471         * @since 7
472         */
473        writeSequenceableArray(sequenceableArray: Sequenceable[]): boolean;
474
475        /**
476         * Writes an array of {@link IRemoteObject} objects to this {@link MessageParcel} object.
477         * @param objectArray Array of {@link IRemoteObject} objects to write.
478         * @returns Return {@code true} if the {@link IRemoteObject} array is successfully written to the {@link MessageParcel};
479         *          return false if the {@link IRemoteObject} array is null or fails to be written to the {@link MessageParcel}.
480         * @since 8
481         */
482        writeRemoteObjectArray(objectArray: IRemoteObject[]): boolean;
483
484        /**
485         * Reads a byte value from the {@link MessageParcel} object.
486         * @returns Return a byte value.
487         * @since 7
488         */
489        readByte(): number;
490
491        /**
492         * Reads a short integer value from the {@link MessageParcel} object.
493         * @returns Return a short integer value.
494         * @since 7
495         */
496        readShort(): number;
497
498        /**
499         * Reads an integer value from the {@link MessageParcel} object.
500         * @returns Return an integer value.
501         * @since 7
502         */
503        readInt(): number;
504
505        /**
506         * Reads a long integer value from the {@link MessageParcel} object.
507         * @returns Return a long integer value.
508         * @since 7
509         */
510        readLong(): number;
511
512        /**
513         * Reads a floating point value from the {@link MessageParcel} object.
514         * @returns Return a floating point value.
515         * @since 7
516         */
517        readFloat(): number;
518
519        /**
520         * Reads a double-precision floating point value from the {@link MessageParcel} object.
521         * @returns Return a double-precision floating point value.
522         * @since 7
523         */
524        readDouble(): number;
525
526        /**
527         * Reads a boolean value from the {@link MessageParcel} object.
528         * @returns Return a boolean value.
529         * @since 7
530         */
531        readBoolean(): boolean;
532
533        /**
534         * Reads a single character value from the {@link MessageParcel} object.
535         * @returns Return a single character value.
536         * @since 7
537         */
538        readChar(): number;
539
540        /**
541         * Reads a string value from the {@link MessageParcel} object.
542         * @returns Return a string value.
543         * @since 7
544         */
545        readString(): string;
546
547        /**
548         * Reads a {@link Sequenceable} object from the {@link MessageParcel} instance.
549         * @param dataIn Indicates the {@link Sequenceable} object that needs to perform the {@code unmarshalling} operation
550         *        using the {@link MessageParcel}.
551         * @returns Return {@code true} if the unmarshalling is successful; return {@code false} otherwise.
552         * @since 7
553         */
554        readSequenceable(dataIn: Sequenceable) : boolean;
555
556        /**
557         * Writes a byte array into the {@link MessageParcel} object.
558         * @param dataIn Indicates the byte array read from MessageParcel.
559         * @returns Return {@code true} if the array has been written into the {@link MessageParcel};
560         *          return {@code false} otherwise.
561         * @throws ParcelException When capacity in this MessageParcel is insufficient,
562         *         exception message: {@link *MessageParcelException#NO_CAPACITY_ERROR}.
563         * @since 7
564         */
565        readByteArray(dataIn: number[]) : void;
566
567        /**
568         * Reads a byte array from the {@link MessageParcel} object.
569         * @returns Return a byte array.
570         * @since 7
571         */
572        readByteArray(): number[];
573
574        /**
575         * Reads a short integer array from the {@link MessageParcel} object.
576         * @param dataIn Indicates the short integer array read from MessageParcel.
577         * @since 7
578         */
579        readShortArray(dataIn: number[]) : void;
580
581        /**
582         * Reads a short integer array from the {@link MessageParcel} object.
583         * @returns Return a short integer array.
584         * @since 7
585         */
586        readShortArray(): number[];
587
588        /**
589         * Reads an integer array from the {@link MessageParcel} object.
590         * @param dataIn Indicates the integer array to read.
591         * @throws ParcelException Throws this exception if reading the integer array fails.
592         * @since 7
593         */
594        readIntArray(dataIn: number[]) : void;
595
596        /**
597         * Reads an integer array from the {@link MessageParcel} object.
598         * @returns Return an integer array.
599         * @since 7
600         */
601        readIntArray(): number[];
602
603        /**
604         * Reads a long integer array from the {@link MessageParcel} object.
605         * @param dataIn Indicates the long integer array to read.
606         * @throws ParcelException Throws this exception if reading the long array fails.
607         * @since 7
608         */
609        readLongArray(dataIn: number[]) : void;
610
611        /**
612         * Reads a long integer array from the {@link MessageParcel} object.
613         * @returns Return a long integer array.
614         * @since 7
615         */
616        readLongArray(): number[];
617
618        /**
619         * Reads a floating point array from the {@link MessageParcel} object.
620         * @param dataIn Indicates the floating point array to read.
621         * @throws ParcelException Throws this exception if reading the float array fails.
622         * @since 7
623         */
624        readFloatArray(dataIn: number[]) : void;
625
626        /**
627         * Reads a floating point array from the {@link MessageParcel} object.
628         * @returns Return a floating point array.
629         * @since 7
630         */
631        readFloatArray(): number[];
632
633        /**
634         * Reads a double-precision floating point array from the {@link MessageParcel} object.
635         * @param dataIn Indicates the double-precision floating point array to read.
636         * @throws ParcelException Throws this exception if reading the double array fails.
637         * @since 7
638         */
639        readDoubleArray(dataIn: number[]) : void;
640
641        /**
642         * Reads a double-precision floating point array from the {@link MessageParcel} object.
643         * @returns Return a double-precision floating point array.
644         * @since 7
645         */
646        readDoubleArray(): number[];
647
648        /**
649         * Reads a boolean array from the {@link MessageParcel} object.
650         * @param dataIn Indicates the boolean array to read.
651         * @throws ParcelException Throws this exception if reading the boolean array fails.
652         * @since 7
653         */
654        readBooleanArray(dataIn: boolean[]) : void;
655
656        /**
657         * Reads a boolean array from the {@link MessageParcel} object.
658         * @returns Return a boolean array.
659         * @since 7
660         */
661        readBooleanArray(): boolean[];
662
663        /**
664         * Reads a single character array from the {@link MessageParcel} object.
665         * @param dataIn Indicates the single character array to read.
666         * @throws ParcelException Throws this exception if reading the char array fails.
667         * @since 7
668         */
669        readCharArray(dataIn: number[]) : void;
670
671        /**
672         * Reads a single character array from the {@link MessageParcel} object.
673         * @returns Return a single character array.
674         * @since 7
675         */
676        readCharArray(): number[];
677
678        /**
679         * Reads a string array from the {@link MessageParcel} object.
680         * @param dataIn Indicates the string array to read.
681         * @throws ParcelException Throws this exception if reading the string array fails.
682         * @since 7
683         */
684        readStringArray(dataIn: string[]) : void;
685
686        /**
687         * Reads a string array from the {@link MessageParcel} object.
688         * @returns Return a string array.
689         * @since 7
690         */
691        readStringArray(): string[];
692
693        /**
694         * Reads the specified {@link Sequenceable} array from this {@link MessageParcel} object.
695         * @param sequenceableArray Sequenceable array to read.
696         * @since 8
697         */
698        readSequenceableArray(sequenceableArray: Sequenceable[]): void;
699
700        /**
701         * Reads the specified {@link IRemoteObject} array from this {@link MessageParcel} object.
702         * @param objects Reads data from this {@link MessageParcel} object to the specified {@link IRemoteObject} array.
703         * @since 8
704         */
705        readRemoteObjectArray(objects: IRemoteObject[]): void;
706
707        /**
708         * Reads {@link IRemoteObject} objects from this {@link MessageParcel} object.
709         * @returns An array of {@link IRemoteObject} objects obtained.
710         * @since 8
711         */
712        readRemoteObjectArray(): IRemoteObject[];
713
714        /**
715         * Closes the specified file descriptor.
716         * @param fd File descriptor to be closed.
717         * @since 8
718         */
719        static closeFileDescriptor(fd: number): void;
720
721        /**
722         * Duplicates the specified file descriptor.
723         * @param fd File descriptor to be duplicated.
724         * @returns A duplicated file descriptor.
725         * @since 8
726         */
727        static dupFileDescriptor(fd: number) :number;
728
729        /**
730         * Checks whether this {@link MessageParcel} object contains a file descriptor.
731         * @returns Return true if the {@link MessageParcel} object contains a file descriptor;
732         * return false otherwise.
733         * @since 8
734         */
735        containFileDescriptors(): boolean;
736
737        /**
738         * Writes a file descriptor to this {@link MessageParcel} object.
739         * @param fd File descriptor to wrote.
740         * @returns Return true if the operation is successful; return false otherwise.
741         * @since 8
742         */
743        writeFileDescriptor(fd: number): boolean;
744
745        /**
746         * Reads a file descriptor from this {@link MessageParcel} object.
747         * @returns File descriptor obtained.
748         * @since 8
749         */
750        readFileDescriptor(): number;
751
752        /**
753         * Writes an anonymous shared memory object to this {@link MessageParcel} object.
754         * @param ashmem Anonymous shared memory object to wrote.
755         * @returns Return true if the operation is successful; return false otherwise.
756         * @since 8
757         */
758        writeAshmem(ashmem: Ashmem): boolean;
759
760        /**
761         * Reads the anonymous shared memory object from this {@link MessageParcel} object.
762         * @returns Anonymous share object obtained.
763         * @since 8
764         */
765        readAshmem(): Ashmem;
766
767        /**
768         * Obtains the maximum amount of raw data that can be sent in a time.
769         * @returns 128 MB.
770         * @since 8
771         */
772        getRawDataCapacity(): number;
773
774        /**
775         * Writes raw data to this {@link MessageParcel} object.
776         * @param rawData Raw data to wrote.
777         * @param size Size of the raw data, in bytes.
778         * @returns Return true if the operation is successful; return false otherwise.
779         * @since 8
780         */
781        writeRawData(rawData: number[], size: number): boolean;
782
783        /**
784         * Reads raw data from this {@link MessageParcel} object.
785         * @param size Size of the raw data to read.
786         * @returns Raw data obtained, in bytes.
787         * @since 8
788         */
789        readRawData(size: number): number[];
790    }
791
792    /**
793     * A data object used for remote procedure call (RPC).
794     * <p>
795     * During RPC, the sender can use the write methods provided by {@link MessageSequence} to
796     * write the to-be-sent data into a {@link MessageSequence} object in a specific format, and the receiver can use the
797     * read methods provided by {@link MessageSequence} to read data of the specific format from the {@link MessageSequence} object.
798     * <p>
799     * <p>
800     * The default capacity of a {@link MessageSequence} instance is 200KB. If you want more or less, use {@link #setCapacity(int)}
801     * to change it.
802     * </p>
803     * <b>Note</b>: Only data of the following data types can be written into or read from a {@link MessageSequence}: byte,
804     * byteArray, short, shortArray, int, intArray, long, longArray, float, floatArray, double, doubleArray, boolean,
805     * booleanArray, char, charArray, String, StringArray, {@link IRemoteObject}, IRemoteObjectArray,
806     * {@link Parcelable}, and ParcelableArray.
807     *
808     * @since 9
809     * @syscap SystemCapability.Communication.IPC.Core
810     */
811    class MessageSequence {
812        /**
813         * Creates an empty {@link MessageSequence} object.
814         * @returns Return the object created.
815         * @since 9
816         */
817        static create(): MessageSequence;
818
819        /**
820         * Reclaim the {@link MessageSequence} object.
821         * @since 9
822         */
823        reclaim(): void;
824
825        /**
826         * Serialize a remote object and writes it to the {@link MessageSequence} object.
827         * @param object Remote object to serialize.
828         * @throws { BusinessError } 401 - check param failed
829         * @throws { BusinessError } 1900008 - proxy or remote object is invalid
830         * @throws { BusinessError } 1900009 - write data to message sequence failed
831         * @since 9
832         */
833        writeRemoteObject(object: IRemoteObject): void;
834
835        /**
836         * Reads a remote object from {@link MessageSequence} object.
837         * @returns Return the remote object.
838         * @throws { BusinessError } 1900008 - proxy or remote object is invalid
839         * @throws { BusinessError } 1900010 - read data from message sequence failed
840         * @since 9
841         */
842        readRemoteObject(): IRemoteObject;
843
844        /**
845         * Writes an interface token into the {@link MessageSequence} object.
846         * @param token Interface descriptor to write.
847         * @throws { BusinessError } 401 - check param failed
848         * @throws { BusinessError } 1900009 - write data to message sequence failed
849         * @since 9
850         */
851        writeInterfaceToken(token: string): void;
852
853        /**
854         * Reads an interface token from the {@link MessageSequence} object.
855         * @returns Return a string value.
856         * @throws { BusinessError } 1900010 - read data from message sequence failed
857         * @since 9
858         */
859        readInterfaceToken(): string;
860
861        /**
862         * Obtains the size of data (in bytes) contained in the {@link MessageSequence} object.
863         * @returns Return the size of data contained in the {@link MessageSequence} object.
864         * @since 9
865         */
866        getSize(): number;
867
868        /**
869         * Obtains the storage capacity (in bytes) of the {@link MessageSequence} object.
870         * @returns Return the storage capacity of the {@link MessageSequence} object.
871         * @since 9
872         */
873        getCapacity(): number;
874
875        /**
876         * Sets the size of data (in bytes) contained in the {@link MessageSequence} object.
877         * <p>{@code false} is returned if the data size set in this method is greater
878         * than the storage capacity of the {@link MessageSequence}.
879         *
880         * @param size Indicates the data size of the {@link MessageSequence} object.
881         * @throws { BusinessError } 401 - check param failed
882         * @since 9
883         */
884        setSize(size: number): void;
885
886        /**
887         * Sets the storage capacity (in bytes) of the {@link MessageSequence} object.
888         * <p>{@code false} is returned if the capacity set in this method is less than
889         * the size of data contained in the {@link MessageSequence}.
890         *
891         * @param size Indicates the storage capacity of the {@link MessageSequence} object.
892         * @throws { BusinessError } 401 - check param failed
893         * @throws { BusinessError } 1900011 - parcel memory alloc failed
894         * @since 9
895         */
896        setCapacity(size: number): void;
897
898        /**
899         * Obtains the writable data space (in bytes) in the {@link MessageSequence} object.
900         * <p>Writable data space = Storage capacity of the {@link MessageSequence} – Size of data contained in the {@link MessageSequence}.
901         *
902         * @returns Return the writable data space of the {@link MessageSequence} object.
903         * @since 9
904         */
905        getWritableBytes(): number;
906
907        /**
908         * Obtains the readable data space (in bytes) in the {@link MessageSequence} object.
909         * <p>Readable data space = Size of data contained in the {@link MessageSequence} – Size of data that has been read.
910         *
911         * @returns Return the readable data space of the {@link MessageSequence} object.
912         * @since 9
913         */
914        getReadableBytes(): number;
915
916        /**
917         * Obtains the current read position in the {@link MessageSequence} object.
918         * @returns Return the current read position in the {@link MessageSequence} object.
919         * @since 9
920         */
921        getReadPosition(): number;
922
923        /**
924         * Obtains the current write position in the {@link MessageSequence} object.
925         * @returns Return the current write position in the {@link MessageSequence} object.
926         * @since 9
927         */
928        getWritePosition(): number;
929
930        /**
931         * Changes the current read position in the {@link MessageSequence} object.
932         * <p>Generally, you are advised not to change the current read position. If you must
933         * change it, change it to an accurate position. Otherwise, the read data may be incorrect.
934         *
935         * @param pos Indicates the target position to start data reading.
936         * @throws { BusinessError } 401 - check param failed
937         * @since 9
938         */
939        rewindRead(pos: number): void;
940
941        /**
942         * Changes the current write position in the {@link MessageSequence} object.
943         * <p>Generally, you are advised not to change the current write position. If you must
944         * change it, change it to an accurate position. Otherwise, the data to be read may be incorrect.
945         *
946         * @param pos Indicates the target position to start data writing.
947         * @throws { BusinessError } 401 - check param failed
948         * @since 9
949         */
950        rewindWrite(pos: number): void;
951
952        /**
953         * Writes information to this MessageSequence object indicating that no exception occurred.
954         * <p>After handling requests, you should call this method before writing any data to reply {@link MessageSequence}.
955         * @throws { BusinessError } 1900009 - write data to message sequence failed
956         * @since 9
957         */
958        writeNoException(): void;
959
960        /**
961         * Reads the exception information from this MessageSequence object.
962         * <p>If exception was thrown in server side, it will be thrown here.
963         * This method should be called before reading any data from reply {@link MessageSequence}
964         * if {@link writeNoException} was invoked in server side.
965         * @throws { BusinessError } 1900010 - read data from message sequence failed
966         * @since 9
967         */
968        readException(): void;
969
970        /**
971         * Writes a byte value into the {@link MessageSequence} object.
972         * @param val Indicates the byte value to write.
973         * @throws { BusinessError } 401 - check param failed
974         * @throws { BusinessError } 1900009 - write data to message sequence failed
975         * @since 9
976         */
977        writeByte(val: number): void;
978
979        /**
980         * Writes a short integer value into the {@link MessageSequence} object.
981         * @param val Indicates the short integer value to write.
982         * @throws { BusinessError } 401 - check param failed
983         * @throws { BusinessError } 1900009 - write data to message sequence failed
984         * @since 9
985         */
986        writeShort(val: number): void;
987
988        /**
989         * Writes an integer value into the {@link MessageSequence} object.
990         * @param val Indicates the integer value to write.
991         * @throws { BusinessError } 401 - check param failed
992         * @throws { BusinessError } 1900009 - write data to message sequence failed
993         * @since 9
994         */
995        writeInt(val: number): void;
996
997        /**
998         * Writes a long integer value into the {@link MessageSequence} object.
999         * @param val Indicates the long integer value to write.
1000         * @throws { BusinessError } 401 - check param failed
1001         * @throws { BusinessError } 1900009 - write data to message sequence failed
1002         * @since 9
1003         */
1004        writeLong(val: number): void;
1005
1006        /**
1007         * Writes a floating point value into the {@link MessageSequence} object.
1008         * @param val Indicates the floating point value to write.
1009         * @throws { BusinessError } 401 - check param failed
1010         * @throws { BusinessError } 1900009 - write data to message sequence failed
1011         * @since 9
1012         */
1013        writeFloat(val: number): void;
1014
1015        /**
1016         * Writes a double-precision floating point value into the {@link MessageSequence} object.
1017         * @param val Indicates the double-precision floating point value to write.
1018         * @throws { BusinessError } 401 - check param failed
1019         * @throws { BusinessError } 1900009 - write data to message sequence failed
1020         * @since 9
1021         */
1022        writeDouble(val: number): void;
1023
1024        /**
1025         * Writes a boolean value into the {@link MessageSequence} object.
1026         * @param val Indicates the boolean value to write.
1027         * @throws { BusinessError } 401 - check param failed
1028         * @throws { BusinessError } 1900009 - write data to message sequence failed
1029         * @since 9
1030         */
1031        writeBoolean(val: boolean): void;
1032
1033        /**
1034         * Writes a single character value into the {@link MessageSequence} object.
1035         * @param val Indicates the single character value to write.
1036         * @throws { BusinessError } 401 - check param failed
1037         * @throws { BusinessError } 1900009 - write data to message sequence failed
1038         * @since 9
1039         */
1040        writeChar(val: number): void;
1041
1042        /**
1043         * Writes a string value into the {@link MessageSequence} object.
1044         * @param val Indicates the string value to write.
1045         * @throws { BusinessError } 401 - check param failed
1046         * @throws { BusinessError } 1900009 - write data to message sequence failed
1047         * @since 9
1048         */
1049        writeString(val: string): void;
1050
1051        /**
1052         * Writes a {@link Parcelable} object into the {@link MessageSequence} object.
1053         * @param val Indicates the {@link Parcelable} object to write.
1054         * @throws { BusinessError } 401 - check param failed
1055         * @throws { BusinessError } 1900009 - write data to message sequence failed
1056         * @since 9
1057         */
1058        writeParcelable(val: Parcelable): void;
1059
1060        /**
1061         * Writes a byte array into the {@link MessageSequence} object.
1062         * @param byteArray Indicates the byte array to write.
1063         * @throws { BusinessError } 401 - check param failed
1064         * @throws { BusinessError } 1900009 - write data to message sequence failed
1065         * @since 9
1066         */
1067        writeByteArray(byteArray: number[]): void;
1068
1069        /**
1070         * Writes a short integer array into the {@link MessageSequence} object.
1071         * Ensure that the data type and size comply with the interface definition.
1072         * Otherwise,data may be truncated.
1073         * @param shortArray Indicates the short integer array to write.
1074         * @throws { BusinessError } 401 - check param failed
1075         * @throws { BusinessError } 1900009 - write data to message sequence failed
1076         * @since 9
1077         */
1078        writeShortArray(shortArray: number[]): void;
1079
1080        /**
1081         * Writes an integer array into the {@link MessageSequence} object.
1082         * Ensure that the data type and size comply with the interface definition.
1083         * Otherwise,data may be truncated.
1084         * @param intArray Indicates the integer array to write.
1085         * @throws { BusinessError } 401 - check param failed
1086         * @throws { BusinessError } 1900009 - write data to message sequence failed
1087         * @since 9
1088         */
1089        writeIntArray(intArray: number[]): void;
1090
1091        /**
1092         * Writes a long integer array into the {@link MessageSequence} object.
1093         * Ensure that the data type and size comply with the interface definition.
1094         * Otherwise,data may be truncated.
1095         * @param longArray Indicates the long integer array to write.
1096         * @throws { BusinessError } 401 - check param failed
1097         * @throws { BusinessError } 1900009 - write data to message sequence failed
1098         * @since 9
1099         */
1100        writeLongArray(longArray: number[]): void;
1101
1102        /**
1103         * Writes a floating point array into the {@link MessageSequence} object.
1104         * Ensure that the data type and size comply with the interface definition.
1105         * Otherwise,data may be truncated.
1106         * @param floatArray Indicates the floating point array to write.
1107         * @throws { BusinessError } 401 - check param failed
1108         * @throws { BusinessError } 1900009 - write data to message sequence failed
1109         * @since 9
1110         */
1111        writeFloatArray(floatArray: number[]): void;
1112
1113        /**
1114         * Writes a double-precision floating point array into the {@link MessageSequence} object.
1115         * Ensure that the data type and size comply with the interface definition.
1116         * Otherwise,data may be truncated.
1117         * @param doubleArray Indicates the double-precision floating point array to write.
1118         * @throws { BusinessError } 401 - check param failed
1119         * @throws { BusinessError } 1900009 - write data to message sequence failed
1120         * @since 9
1121         */
1122        writeDoubleArray(doubleArray: number[]): void;
1123
1124        /**
1125         * Writes a boolean array into the {@link MessageSequence} object.
1126         * Ensure that the data type and size comply with the interface definition.
1127         * Otherwise,data may be truncated.
1128         * @param booleanArray Indicates the boolean array to write.
1129         * @throws { BusinessError } 401 - check param failed
1130         * @throws { BusinessError } 1900009 - write data to message sequence failed
1131         * @since 9
1132         */
1133        writeBooleanArray(booleanArray: boolean[]): void;
1134
1135        /**
1136         * Writes a single character array into the {@link MessageSequence} object.
1137         * Ensure that the data type and size comply with the interface definition.
1138         * Otherwise,data may be truncated.
1139         * @param charArray Indicates the single character array to write.
1140         * @throws { BusinessError } 401 - check param failed
1141         * @throws { BusinessError } 1900009 - write data to message sequence failed
1142         * @since 9
1143         */
1144        writeCharArray(charArray: number[]): void;
1145
1146        /**
1147         * Writes a string array into the {@link MessageSequence} object.
1148         * Ensure that the data type and size comply with the interface definition.
1149         * Otherwise,data may be truncated.
1150         * @param stringArray Indicates the string array to write.
1151         * @throws { BusinessError } 401 - check param failed
1152         * @throws { BusinessError } 1900009 - write data to message sequence failed
1153         * @since 9
1154         */
1155        writeStringArray(stringArray: string[]): void;
1156
1157        /**
1158         * Writes a {@link Parcelable} object array into the {@link MessageSequence} object.
1159         * @param parcelableArray Indicates the {@link Parcelable} object array to write.
1160         * @throws { BusinessError } 401 - check param failed
1161         * @throws { BusinessError } 1900009 - write data to message sequence failed
1162         * @since 9
1163         */
1164        writeParcelableArray(parcelableArray: Parcelable[]): void;
1165
1166        /**
1167         * Writes an array of {@link IRemoteObject} objects to this {@link MessageSequence} object.
1168         * @param objectArray Array of {@link IRemoteObject} objects to write.
1169         * @throws { BusinessError } 401 - check param failed
1170         * @throws { BusinessError } 1900009 - write data to message sequence failed
1171         * @since 9
1172         */
1173        writeRemoteObjectArray(objectArray: IRemoteObject[]): void;
1174
1175        /**
1176         * Reads a byte value from the {@link MessageParcel} object.
1177         * @returns Return a byte value.
1178         * @throws { BusinessError } 1900010 read data from message sequence failed
1179         * @since 9
1180         */
1181        readByte(): number;
1182
1183        /**
1184         * Reads a short integer value from the {@link MessageSequence} object.
1185         * @returns Return a short integer value.
1186         * @throws { BusinessError } 1900010 - read data from message sequence failed
1187         * @since 9
1188         */
1189        readShort(): number;
1190
1191        /**
1192         * Reads an integer value from the {@link MessageSequence} object.
1193         * @returns Return an integer value.
1194         * @throws { BusinessError } 1900010 - read data from message sequence failed
1195         * @since 9
1196         */
1197        readInt(): number;
1198
1199        /**
1200         * Reads a long integer value from the {@link MessageSequence} object.
1201         * @returns Return a long integer value.
1202         * @throws { BusinessError } 1900010 - read data from message sequence failed
1203         * @since 9
1204         */
1205        readLong(): number;
1206
1207        /**
1208         * Reads a floating point value from the {@link MessageSequence} object.
1209         * @returns Return a floating point value.
1210         * @throws { BusinessError } 1900010 - read data from message sequence failed
1211         * @since 9
1212         */
1213        readFloat(): number;
1214
1215        /**
1216         * Reads a double-precision floating point value from the {@link MessageSequence} object.
1217         * @returns Return a double-precision floating point value.
1218         * @throws { BusinessError } 1900010 - read data from message sequence failed
1219         * @since 9
1220         */
1221        readDouble(): number;
1222
1223        /**
1224         * Reads a boolean value from the {@link MessageSequence} object.
1225         * @returns Return a boolean value.
1226         * @throws { BusinessError } 1900010 - read data from message sequence failed
1227         * @since 9
1228         */
1229        readBoolean(): boolean;
1230
1231        /**
1232         * Reads a single character value from the {@link MessageSequence} object.
1233         * @returns Return a single character value.
1234         * @throws { BusinessError } 1900010 - read data from message sequence failed
1235         * @since 9
1236         */
1237        readChar(): number;
1238
1239        /**
1240         * Reads a string value from the {@link MessageSequence} object.
1241         * @returns Return a string value.
1242         * @throws { BusinessError } 1900010 - read data from message sequence failed
1243         * @since 9
1244         */
1245        readString(): string;
1246
1247        /**
1248         * Reads a {@link Parcelable} object from the {@link MessageSequence} instance.
1249         * @param dataIn Indicates the {@link Parcelable} object that needs to perform the {@code unmarshalling} operation
1250         *        using the {@link MessageSequence}.
1251         * @throws { BusinessError } 401 - check param failed
1252         * @throws { BusinessError } 1900010 - read data from message sequence failed
1253         * @throws { BusinessError } 1900012 - call js callback function failed
1254         * @since 9
1255         */
1256        readParcelable(dataIn: Parcelable) : void;
1257
1258        /**
1259         * Writes a byte array into the {@link MessageSequence} object.
1260         * @param dataIn Indicates the byte array read from MessageSequence.
1261         * @throws { BusinessError } 401 - check param failed
1262         * @throws { BusinessError } 1900010 - read data from message sequence failed
1263         * @since 9
1264         */
1265        readByteArray(dataIn: number[]) : void;
1266
1267        /**
1268         * Reads a byte array from the {@link MessageSequence} object.
1269         * @returns Return a byte array.
1270         * @throws { BusinessError } 401 - check param failed
1271         * @throws { BusinessError } 1900010 - read data from message sequence failed
1272         * @since 9
1273         */
1274        readByteArray(): number[];
1275
1276        /**
1277         * Reads a short integer array from the {@link MessageSequence} object.
1278         * @param dataIn Indicates the short integer array read from MessageSequence.
1279         * @throws { BusinessError } 401 - check param failed
1280         * @throws { BusinessError } 1900010 - read data from message sequence failed
1281         * @since 9
1282         */
1283        readShortArray(dataIn: number[]) : void;
1284
1285        /**
1286         * Reads a short integer array from the {@link MessageSequence} object.
1287         * @returns Return a short integer array.
1288         * @throws { BusinessError } 1900010 - read data from message sequence failed
1289         * @since 9
1290         */
1291        readShortArray(): number[];
1292
1293        /**
1294         * Reads an integer array from the {@link MessageSequence} object.
1295         * @param dataIn Indicates the integer array to read.
1296         * @throws { BusinessError } 401 - check param failed
1297         * @throws { BusinessError } 1900010 - read data from message sequence failed
1298         * @since 9
1299         */
1300        readIntArray(dataIn: number[]) : void;
1301
1302        /**
1303         * Reads an integer array from the {@link MessageSequence} object.
1304         * @returns Return an integer array.
1305         * @throws { BusinessError } 1900010 - read data from message sequence failed
1306         * @since 9
1307         */
1308        readIntArray(): number[];
1309
1310        /**
1311         * Reads a long integer array from the {@link MessageSequence} object.
1312         * @param dataIn Indicates the long integer array to read.
1313         * @throws { BusinessError } 401 - check param failed
1314         * @throws { BusinessError } 1900010 - read data from message sequence failed
1315         * @since 9
1316         */
1317        readLongArray(dataIn: number[]) : void;
1318
1319        /**
1320         * Reads a long integer array from the {@link MessageSequence} object.
1321         * @returns Return a long integer array.
1322         * @throws { BusinessError } 1900010 - read data from message sequence failed
1323         * @since 9
1324         */
1325        readLongArray(): number[];
1326
1327        /**
1328         * Reads a floating point array from the {@link MessageSequence} object.
1329         * @param dataIn Indicates the floating point array to read.
1330         * @throws { BusinessError } 401 - check param failed
1331         * @throws { BusinessError } 1900010 - read data from message sequence failed
1332         * @since 9
1333         */
1334        readFloatArray(dataIn: number[]) : void;
1335
1336        /**
1337         * Reads a floating point array from the {@link MessageSequence} object.
1338         * @returns Return a floating point array.
1339         * @throws { BusinessError } 1900010 - read data from message sequence failed
1340         * @since 9
1341         */
1342        readFloatArray(): number[];
1343
1344        /**
1345         * Reads a double-precision floating point array from the {@link MessageSequence} object.
1346         * @param dataIn Indicates the double-precision floating point array to read.
1347         * @throws { BusinessError } 401 - check param failed
1348         * @throws { BusinessError } 1900010 - read data from message sequence failed
1349         * @since 9
1350         */
1351        readDoubleArray(dataIn: number[]) : void;
1352
1353        /**
1354         * Reads a double-precision floating point array from the {@link MessageSequence} object.
1355         * @returns Return a double-precision floating point array.
1356         * @throws { BusinessError } 1900010 - read data from message sequence failed
1357         * @since 9
1358         */
1359        readDoubleArray(): number[];
1360
1361        /**
1362         * Reads a boolean array from the {@link MessageSequence} object.
1363         * @param dataIn Indicates the boolean array to read.
1364         * @throws { BusinessError } 401 - check param failed
1365         * @throws { BusinessError } 1900010 - read data from message sequence failed
1366         * @since 9
1367         */
1368        readBooleanArray(dataIn: boolean[]) : void;
1369
1370        /**
1371         * Reads a boolean array from the {@link MessageSequence} object.
1372         * @returns Return a boolean array.
1373         * @throws { BusinessError } 1900010 - read data from message sequence failed
1374         * @since 9
1375         */
1376        readBooleanArray(): boolean[];
1377
1378        /**
1379         * Reads a single character array from the {@link MessageSequence} object.
1380         * @param dataIn Indicates the single character array to read.
1381         * @throws { BusinessError } 401 - check param failed
1382         * @throws { BusinessError } 1900010 - read data from message sequence failed
1383         * @since 9
1384         */
1385        readCharArray(dataIn: number[]) : void;
1386
1387        /**
1388         * Reads a single character array from the {@link MessageSequence} object.
1389         * @returns Return a single character array.
1390         * @throws { BusinessError } 1900010 - read data from message sequence failed
1391         * @since 9
1392         */
1393        readCharArray(): number[];
1394
1395        /**
1396         * Reads a string array from the {@link MessageSequence} object.
1397         * @param dataIn Indicates the string array to read.
1398         * @throws ParcelException Throws this exception if reading the string array fails.
1399         * @throws { BusinessError } 401 - check param failed
1400         * @throws { BusinessError } 1900010 - read data from message sequence failed
1401         * @since 9
1402         */
1403        readStringArray(dataIn: string[]) : void;
1404
1405        /**
1406         * Reads a string array from the {@link MessageSequence} object.
1407         * @returns Return a string array.
1408         * @throws { BusinessError } 1900010 - read data from message sequence failed
1409         * @since 9
1410         */
1411        readStringArray(): string[];
1412
1413        /**
1414         * Reads the specified {@link Parcelable} array from this {@link MessageSequence} object.
1415         * @param parcelableArray Parcelable array to read.
1416         * @throws { BusinessError } 401 - check param failed
1417         * @throws { BusinessError } 1900010 - read data from message sequence failed
1418         * @throws { BusinessError } 1900012 - call js callback function failed
1419         * @since 9
1420         */
1421        readParcelableArray(parcelableArray: Parcelable[]): void;
1422
1423        /**
1424         * Reads the specified {@link IRemoteObject} array from this {@link MessageSequence} object.
1425         * @param objects Reads data from this {@link MessageSequence} object to the specified {@link IRemoteObject} array.
1426         * @throws { BusinessError } 401 - check param failed
1427         * @throws { BusinessError } 1900010 - read data from message sequence failed
1428         * @since 9
1429         */
1430        readRemoteObjectArray(objects: IRemoteObject[]): void;
1431
1432        /**
1433         * Reads {@link IRemoteObject} objects from this {@link MessageSequence} object.
1434         * @returns An array of {@link IRemoteObject} objects obtained.
1435         * @throws { BusinessError } 1900010 - read data from message sequence failed
1436         * @since 9
1437         */
1438        readRemoteObjectArray(): IRemoteObject[];
1439
1440        /**
1441         * Closes the specified file descriptor.
1442         * @param fd File descriptor to be closed.
1443         * @throws { BusinessError } 401 - check param failed
1444         * @since 9
1445         */
1446        static closeFileDescriptor(fd: number): void;
1447
1448        /**
1449         * Duplicates the specified file descriptor.
1450         * @param fd File descriptor to be duplicated.
1451         * @returns A duplicated file descriptor.
1452         * @throws { BusinessError } 401 - check param failed
1453         * @throws { BusinessError } 1900013 - call os dup function failed
1454         * @since 9
1455         */
1456        static dupFileDescriptor(fd: number) :number;
1457
1458        /**
1459         * Checks whether this {@link MessageSequence} object contains a file descriptor.
1460         * @returns Return true if the {@link MessageSequence} object contains a file descriptor;
1461         * return false otherwise.
1462         * @since 9
1463         */
1464        containFileDescriptors(): boolean;
1465
1466        /**
1467         * Writes a file descriptor to this {@link MessageSequence} object.
1468         * @param fd File descriptor to wrote.
1469         * @throws { BusinessError } 401 - check param failed
1470         * @throws { BusinessError } 1900009 - write data to message sequence failed
1471         * @since 9
1472         */
1473        writeFileDescriptor(fd: number): void;
1474
1475        /**
1476         * Reads a file descriptor from this {@link MessageSequence} object.
1477         * @returns File descriptor obtained.
1478         * @throws { BusinessError } 1900010 - read data from message sequence failed
1479         * @since 9
1480         */
1481        readFileDescriptor(): number;
1482
1483        /**
1484         * Writes an anonymous shared memory object to this {@link MessageSequence} object.
1485         * @param ashmem Anonymous shared memory object to wrote.
1486         * @throws { BusinessError } 401 - check param failed
1487         * @throws { BusinessError } 1900003 - write to ashmem failed
1488         * @since 9
1489         */
1490        writeAshmem(ashmem: Ashmem): void;
1491
1492        /**
1493         * Reads the anonymous shared memory object from this {@link MessageSequence} object.
1494         * @returns Anonymous share object obtained.
1495         * @throws { BusinessError } 401 - check param failed
1496         * @throws { BusinessError } 1900004 - read from ashmem failed
1497         * @since 9
1498         */
1499        readAshmem(): Ashmem;
1500
1501        /**
1502         * Obtains the maximum amount of raw data that can be sent in a time.
1503         * @returns 128 MB.
1504         * @since 9
1505         */
1506        getRawDataCapacity(): number;
1507
1508        /**
1509         * Writes raw data to this {@link MessageSequence} object.
1510         * @param rawData Raw data to wrote.
1511         * @param size Size of the raw data, in bytes.
1512         * @throws { BusinessError } 401 - check param failed
1513         * @throws { BusinessError } 1900009 - write data to message sequence failed
1514         * @since 9
1515         */
1516        writeRawData(rawData: number[], size: number): void;
1517
1518        /**
1519         * Reads raw data from this {@link MessageSequence} object.
1520         * @param size Size of the raw data to read.
1521         * @returns Raw data obtained, in bytes.
1522         * @throws { BusinessError } 401 - check param failed
1523         * @throws { BusinessError } 1900010 - read data from message sequence failed
1524         * @since 9
1525         */
1526        readRawData(size: number): number[];
1527    }
1528
1529    /**
1530     * @syscap SystemCapability.Communication.IPC.Core
1531     * @since 7
1532     * @deprecated since 9
1533     * @useinstead ohos.rpc.Parcelable
1534     */
1535    interface Sequenceable {
1536        /**
1537         * Marshal this {@code Sequenceable} object into a {@link MessageParcel}.
1538         *
1539         * @param dataOut Indicates the {@link MessageParcel} object to which the {@code Sequenceable}
1540         *        object will be marshalled..
1541         * @returns Return {@code true} if the marshalling is successful; return {@code false} otherwise.
1542         * @throws ParcelException Throws this exception if the operation fails.
1543         * @since 7
1544         */
1545        marshalling(dataOut: MessageParcel): boolean;
1546
1547        /**
1548         * Unmarshal this {@code Sequenceable} object from a {@link MessageParcel}.
1549         *
1550         * @param dataIn Indicates the {@link MessageParcel} object into which the {@code Sequenceable}
1551         *        object has been marshalled.
1552         * @returns Return {@code true} if the unmarshalling is successful; return {@code false} otherwise.
1553         * @throws ParcelException Throws this exception if the operation fails.
1554         * @since 7
1555         */
1556        unmarshalling(dataIn: MessageParcel) : boolean;
1557    }
1558
1559    /**
1560     * @syscap SystemCapability.Communication.IPC.Core
1561     * @since 9
1562     */
1563    interface Parcelable {
1564        /**
1565         * Marshal this {@code Parcelable} object into a {@link MessageSequence}.
1566         *
1567         * @param dataOut Indicates the {@link MessageSequence} object to which the {@code Parcelable}
1568         *        object will be marshalled..
1569         * @returns Return {@code true} if the marshalling is successful; return {@code false} otherwise.
1570         * @throws ParcelException Throws this exception if the operation fails.
1571         * @since 9
1572         */
1573        marshalling(dataOut: MessageSequence): boolean;
1574
1575        /**
1576         * Unmarshal this {@code Parcelable} object from a {@link MessageSequence}.
1577         *
1578         * @param dataIn Indicates the {@link MessageSequence} object into which the {@code Parcelable}
1579         *        object has been marshalled.
1580         * @returns Return {@code true} if the unmarshalling is successful; return {@code false} otherwise.
1581         * @throws ParcelException Throws this exception if the operation fails.
1582         * @since 9
1583         */
1584        unmarshalling(dataIn: MessageSequence) : boolean;
1585    }
1586
1587    /**
1588     * Defines the response to the request.
1589     * <p> SendRequestResult object contains four members,
1590     * namely error code of this operation, request code, data parcel
1591     * and reply parcel.
1592     * @syscap SystemCapability.Communication.IPC.Core
1593     * @since 8
1594     * @deprecated since 9
1595     * @useinstead ohos.rpc.RequestResult
1596     */
1597    interface SendRequestResult {
1598        /**
1599         * Error code. 0 indicates successful, otherwise it is failed.
1600         * @since 8
1601         */
1602        errCode: number;
1603
1604        /**
1605         * Message code. It is same as the code in {@link SendRequest} method.
1606         * @since 8
1607         */
1608        code: number;
1609
1610        /**
1611         * MessageParcel object sent to the peer process.
1612         * It is the same object in {@link SendRequest} method.
1613         * @since 8
1614         */
1615        data: MessageParcel;
1616
1617        /**
1618         * MessageParcel object returned by the peer process.
1619         * It is the same object in {@link SendRequest} method.
1620         * @since 8
1621         */
1622        reply: MessageParcel;
1623    }
1624
1625    /**
1626    * Defines the response to the request.
1627    * <p> SendRequestResult object contains four members,
1628    * namely error code of this operation, request code, data parcel
1629    * and reply parcel.
1630    * @syscap SystemCapability.Communication.IPC.Core
1631    * @since 9
1632    */
1633    interface RequestResult {
1634        /**
1635         * Error code. 0 indicates successful, otherwise it is failed.
1636         * @since 9
1637         */
1638        errCode: number;
1639
1640        /**
1641         * Message code. It is same as the code in {@link SendRequest} method.
1642         * @since 9
1643         */
1644        code: number;
1645
1646        /**
1647         * MessageSequence object sent to the peer process.
1648         * It is the same object in {@link SendRequest} method.
1649         * @since 9
1650         */
1651        data: MessageSequence;
1652
1653        /**
1654         * MessageSequence object returned by the peer process.
1655         * It is the same object in {@link SendRequest} method.
1656         * @since 9
1657         */
1658        reply: MessageSequence;
1659    }
1660
1661    /**
1662     * @syscap SystemCapability.Communication.IPC.Core
1663     * @since 7
1664     */
1665    abstract class IRemoteObject {
1666        /**
1667         * Queries the description of an interface.
1668         *
1669         * <p>A valid {@link IRemoteBroker} object is returned for an interface used by the service provider;
1670         * {@code null} is returned for an interface used by the service user,
1671         * indicating that the interface is not a local one.
1672         *
1673         * @param descriptor Indicates the interface descriptor.
1674         * @returns Return the {@link IRemoteBroker} object bound to the specified interface descriptor.
1675         * @since 7
1676         * @deprecated since 9
1677         * @useinstead ohos.rpc.IRemoteObject#getLocalInterface
1678         */
1679        queryLocalInterface(descriptor: string): IRemoteBroker;
1680
1681        /**
1682         * Queries the description of an interface.
1683         *
1684         * <p>A valid {@link IRemoteBroker} object is returned for an interface used by the service provider;
1685         * {@code null} is returned for an interface used by the service user,
1686         * indicating that the interface is not a local one.
1687         *
1688         * @param descriptor Indicates the interface descriptor.
1689         * @returns Return the {@link IRemoteBroker} object bound to the specified interface descriptor.
1690         * @throws { BusinessError } 401 - check param failed
1691         * @since 9
1692         */
1693        getLocalInterface(descriptor: string): IRemoteBroker;
1694
1695        /**
1696         * Sends a {@link MessageParcel} message to the peer process in synchronous or asynchronous mode.
1697         *
1698         * <p>If asynchronous mode is set for {@code option}, a response is returned immediately.
1699         * If synchronous mode is set for {@code option}, the interface will wait for a response from the peer process
1700         * until the request times out. The user must prepare {@code reply} for receiving the execution result
1701         * given by the peer process.
1702         *
1703         * @param code Indicates the message code, which is determined by both sides of the communication.
1704         * If the interface is generated by the IDL tool, the message code is automatically generated by IDL.
1705         * @param data Indicates the {@link MessageParcel} object sent to the peer process.
1706         * @param reply Indicates the {@link MessageParcel} object returned by the peer process.
1707         * @param options Indicates the synchronous or asynchronous mode to send messages.
1708         * @returns Return {@code true} if the method is called successfully; return {@code false} otherwise.
1709         * @throws RemoteException Throws this exception if the method fails to be called.
1710         * @since 7
1711         * @deprecated since 9
1712         */
1713        sendRequest(code: number, data: MessageParcel, reply: MessageParcel, options: MessageOption): boolean;
1714
1715        /**
1716         * Sends a {@link MessageParcel} message to the peer process in synchronous or asynchronous mode.
1717         *
1718         * <p>If options indicates the asynchronous mode, a promise will be fulfilled immediately
1719         * and the reply message does not contain any content. If options indicates the synchronous mode,
1720         * a promise will be fulfilled when the response to sendRequest is returned,
1721         * and the reply message contains the returned information.
1722         * param code Message code called by the request, which is determined by the client and server.
1723         * If the method is generated by an IDL tool, the message code is automatically generated by the IDL tool.
1724         * param data {@link MessageParcel} object holding the data to send.
1725         * param reply {@link MessageParcel} object that receives the response.
1726         * param operations Indicates the synchronous or asynchronous mode to send messages.
1727         * @returns Promise used to return the {@link SendRequestResult} instance.
1728         * @throws Throws an exception if the method fails to be called.
1729         * @since 8
1730         * @deprecated since 9
1731         * @useinstead ohos.rpc.IRemoteObject#sendMessageRequest
1732         */
1733        sendRequest(code: number, data: MessageParcel, reply: MessageParcel, options: MessageOption): Promise<SendRequestResult>;
1734
1735        /**
1736         * Sends a {@link MessageSequence} message to the peer process asynchronously.
1737         *
1738         * <p>If options indicates the asynchronous mode, a promise will be fulfilled immediately
1739         * and the reply message does not contain any content. If options indicates the synchronous mode,
1740         * a promise will be fulfilled when the response to sendMessageRequest is returned,
1741         * and the reply message contains the returned information.
1742         * param code Message code called by the request, which is determined by the client and server.
1743         * If the method is generated by an IDL tool, the message code is automatically generated by the IDL tool.
1744         * param data {@link MessageSequence} object holding the data to send.
1745         * param reply {@link MessageSequence} object that receives the response.
1746         * param operations Indicates the synchronous or asynchronous mode to send messages.
1747         * @returns Promise used to return the {@link RequestResult} instance.
1748         * @throws { BusinessError } 401 - check param failed
1749         * @since 9
1750         */
1751        sendMessageRequest(code: number, data: MessageSequence, reply: MessageSequence, options: MessageOption): Promise<RequestResult>;
1752
1753        /**
1754         * Sends a {@link MessageParcel} message to the peer process in synchronous or asynchronous mode.
1755         *
1756         * <p>If options indicates the asynchronous mode, a callback will be invoked immediately
1757         * and the reply message does not contain any content. If options indicates the synchronous mode,
1758         * a callback will be invoked when the response to sendRequest is returned,
1759         * and the reply message contains the returned information.
1760         * param code Message code called by the request, which is determined by the client and server.
1761         * If the method is generated by an IDL tool, the message code is automatically generated by the IDL tool.
1762         * param data {@link MessageParcel} object holding the data to send.
1763         * param reply {@link MessageParcel} object that receives the response.
1764         * param operations Indicates the synchronous or asynchronous mode to send messages.
1765         * param callback Callback for receiving the sending result.
1766         * @since 8
1767         * @deprecated since 9
1768         * @useinstead ohos.rpc.IRemoteObject#sendMessageRequest
1769         *
1770         */
1771        sendRequest(code: number, data: MessageParcel, reply: MessageParcel, options: MessageOption, callback: AsyncCallback<SendRequestResult>): void;
1772
1773        /**
1774         * Sends a {@link MessageSequence} message to the peer process in synchronous or asynchronous mode.
1775         *
1776         * <p>If options indicates the asynchronous mode, a callback will be invoked immediately
1777         * and the reply message does not contain any content. If options indicates the synchronous mode,
1778         * a callback will be invoked when the response to sendMessageRequest is returned,
1779         * and the reply message contains the returned information.
1780         * param code Message code called by the request, which is determined by the client and server.
1781         * If the method is generated by an IDL tool, the message code is automatically generated by the IDL tool.
1782         * param data {@link MessageSequence} object holding the data to send.
1783         * param reply {@link MessageSequence} object that receives the response.
1784         * param operations Indicates the synchronous or asynchronous mode to send messages.
1785         * param callback Callback for receiving the sending result.
1786         * @throws { BusinessError } 401 - check param failed
1787         * @since 9
1788         */
1789        sendMessageRequest(code: number, data: MessageSequence, reply: MessageSequence, options: MessageOption, callback: AsyncCallback<RequestResult>): void;
1790
1791        /**
1792         * Register a callback used to receive notifications of the death of a remote object.
1793         *
1794         * @param recipient Indicates the callback to be registered.
1795         * @param flags Indicates the flag of the death notification.
1796         * @returns Return {@code true} if the callback is registered successfully; return {@code false} otherwise.
1797         * @since 7
1798         * @deprecated since 9
1799         * @useinstead ohos.rpc.IRemoteObject#registerDeathRecipient
1800         */
1801        addDeathRecipient(recipient: DeathRecipient, flags: number): boolean;
1802
1803        /**
1804         * Register a callback used to receive notifications of the death of a remote object.
1805         *
1806         * @param recipient Indicates the callback to be registered.
1807         * @param flags Indicates the flag of the death notification.
1808         * @throws { BusinessError } 401 - check param failed
1809         * @throws { BusinessError } 1900008 - proxy or remote object is invalid
1810         * @since 9
1811         */
1812        registerDeathRecipient(recipient: DeathRecipient, flags: number): void;
1813
1814        /**
1815         * Unregister a callback used to receive notifications of the death of a remote object.
1816         *
1817         * @param recipient Indicates the callback to be unregister.
1818         * @param flags Indicates the flag of the death notification.
1819         * @returns Return {@code true} if the callback is unregister successfully; return {@code false} otherwise.
1820         * @since 7
1821         * @deprecated since 9
1822         * @useinstead ohos.rpc.IRemoteObject#unregisterDeathRecipient
1823         */
1824        removeDeathRecipient(recipient: DeathRecipient, flags: number): boolean;
1825
1826        /**
1827         * Unregister a callback used to receive notifications of the death of a remote object.
1828         *
1829         * @param recipient Indicates the callback to be unregister.
1830         * @param flags Indicates the flag of the death notification.
1831         * @throws { BusinessError } 401 - check param failed
1832         * @throws { BusinessError } 1900008 - proxy or remote object is invalid
1833         * @since 9
1834         */
1835        unregisterDeathRecipient(recipient: DeathRecipient, flags: number): void;
1836
1837        /**
1838         * Obtains the interface descriptor of an object.
1839         *
1840         * <p>The interface descriptor is a character string.
1841         *
1842         * @returns Return the interface descriptor.
1843         * @since 7
1844         * @deprecated since 9
1845         * @useinstead ohos.rpc.IRemoteObject#getDescriptor
1846         */
1847        getInterfaceDescriptor(): string;
1848
1849        /**
1850         * Obtains the interface descriptor of an object.
1851         *
1852         * <p>The interface descriptor is a character string.
1853         *
1854         * @returns Return the interface descriptor.
1855         * @throws { BusinessError } 1900008 - proxy or remote object is invalid
1856         * @since 9
1857         */
1858        getDescriptor(): string;
1859
1860        /**
1861         * Checks whether an object is dead.
1862         *
1863         * @returns Return {@code true} if the object is dead; return {@code false} otherwise.
1864         * @since 7
1865         */
1866        isObjectDead(): boolean;
1867    }
1868
1869    /**
1870     * @syscap SystemCapability.Communication.IPC.Core
1871     * @since 7
1872     */
1873    interface IRemoteBroker {
1874        /**
1875         * Obtains a proxy or remote object. This method must be implemented by its derived classes.
1876         *
1877         * @returns Return the RemoteObject if the caller is a RemoteObject; return the IRemoteObject,
1878         * that is, the holder of this RemoteProxy object, if the caller is a RemoteProxy object.
1879         * @since 7
1880         */
1881        asObject(): IRemoteObject;
1882    }
1883
1884    /**
1885     * @since 7
1886     * @syscap SystemCapability.Communication.IPC.Core
1887     */
1888    interface DeathRecipient {
1889        /**
1890         * Called to perform subsequent operations when a death notification of the remote object is received.
1891         *
1892         * @since 7
1893         */
1894        onRemoteDied(): void;
1895    }
1896
1897    /**
1898     * @syscap SystemCapability.Communication.IPC.Core
1899     * @since 7
1900     */
1901    class MessageOption {
1902        /**
1903         * Indicates synchronous call.
1904         *
1905         * @constant
1906         * @default 0
1907         * @since 7
1908         */
1909        TF_SYNC: number;
1910
1911        /**
1912         * Indicates asynchronous call.
1913         *
1914         * @constant
1915         * @default 1
1916         * @since 7
1917         */
1918        TF_ASYNC: number;
1919
1920        /**
1921         * Indicates the sendRequest API for returning the file descriptor.
1922         *
1923         * @constant
1924         * @default 16
1925         * @since 7
1926         */
1927        TF_ACCEPT_FDS: number;
1928
1929        /**
1930         * Indicates the wait time for RPC, in seconds. It is NOT used in IPC case.
1931         *
1932         * @constant
1933         * @default 4
1934         * @since 7
1935         */
1936        TF_WAIT_TIME: number;
1937
1938        /**
1939         * A constructor used to create a MessageOption instance.
1940         *
1941         * @param syncFlags Specifies whether the SendRequest is called synchronously (default) or asynchronously.
1942         * @param waitTime Maximum wait time for a RPC call. The default value is TF_WAIT_TIME.
1943         * @since 7
1944         */
1945        constructor(syncFlags?: number, waitTime?: number);
1946
1947        /**
1948         * A constructor used to create a MessageOption instance.
1949         *
1950         * @param async Specifies whether the SendRequest is called synchronously (default) or asynchronously.
1951         * @param waitTime Maximum wait time for a RPC call.
1952         * @since 9
1953         */
1954        constructor(async?: boolean);
1955
1956        /**
1957         * Obtains the SendRequest call flag, which can be synchronous or asynchronous.
1958         *
1959         * @returns Return whether the SendRequest is called synchronously or asynchronously.
1960         * @since 7
1961         */
1962        getFlags(): number;
1963
1964        /**
1965         * Sets the SendRequest call flag, which can be synchronous or asynchronous.
1966         *
1967         * @param flags Indicates the call flag, which can be synchronous or asynchronous.
1968         * @since 7
1969         */
1970        setFlags(flags: number): void;
1971
1972        /**
1973         * Obtains the SendRequest call flag, which can be synchronous or asynchronous.
1974         *
1975         * @returns Return whether the SendRequest is called synchronously or asynchronously.
1976         * @since 9
1977         */
1978        isAsync(): boolean;
1979
1980        /**
1981         * Sets the SendRequest call flag, which can be synchronous or asynchronous.
1982         *
1983         * @param flags Indicates the call flag, which can be synchronous or asynchronous.
1984         * @since 9
1985         */
1986        setAsync(async: boolean): void;
1987
1988        /**
1989         * Obtains the maximum wait time for this RPC call.
1990         *
1991         * @returns Return maximum wait time obtained.
1992         * @since 7
1993         */
1994        getWaitTime(): number;
1995
1996        /**
1997         * Sets the maximum wait time for this RPC call.
1998         *
1999         * @param waitTime Indicates maximum wait time to set.
2000         * @since 7
2001         */
2002        setWaitTime(waitTime: number): void;
2003    }
2004
2005    /**
2006     * @syscap SystemCapability.Communication.IPC.Core
2007     * @since 7
2008     */
2009    class RemoteObject extends IRemoteObject {
2010        /**
2011         * A constructor to create a RemoteObject instance.
2012         *
2013         * @param descriptor Specifies interface descriptor.
2014         * @since 7
2015         */
2016        constructor(descriptor: string);
2017
2018        /**
2019         * Queries a remote object using an interface descriptor.
2020         *
2021         * @param descriptor Indicates the interface descriptor used to query the remote object.
2022         * @returns Return the remote object matching the interface descriptor; return null
2023         * if no such remote object is found.
2024         * @since 7
2025         * @deprecated since 9
2026         * @useinstead ohos.rpc.RemoteObject#getLocalInterface
2027         */
2028        queryLocalInterface(descriptor: string): IRemoteBroker;
2029
2030        /**
2031         * Queries a remote object using an interface descriptor.
2032         *
2033         * @param descriptor Indicates the interface descriptor used to query the remote object.
2034         * @returns Return the remote object matching the interface descriptor; return null
2035         * if no such remote object is found.
2036         * @throws { BusinessError } 401 - check param failed
2037         * @since 9
2038         */
2039        getLocalInterface(descriptor: string): IRemoteBroker;
2040
2041        /**
2042         * Queries an interface descriptor.
2043         *
2044         * @returns Return the interface descriptor.
2045         * @since 7
2046         * @deprecated since 9
2047         * @useinstead ohos.rpc.RemoteObject#getDescriptor
2048         */
2049        getInterfaceDescriptor(): string;
2050
2051        /**
2052         * Queries an interface descriptor.
2053         *
2054         * @returns Return the interface descriptor.
2055         * @throws { BusinessError } 1900008 - proxy or remote object is invalid
2056         * @since 9
2057         */
2058        getDescriptor(): string;
2059
2060        /**
2061         * Sets an entry for receiving requests.
2062         *
2063         * <p>This method is implemented by the remote service provider. You need to override this method with
2064         * your own service logic when you are using IPC.
2065         *
2066         * @param code Indicates the service request code sent from the peer end.
2067         * @param data Indicates the {@link MessageParcel} object sent from the peer end.
2068         * @param reply Indicates the response message object sent from the remote service.
2069         * The local service writes the response data to the {@link MessageParcel} object.
2070         * @param options Indicates whether the operation is synchronous or asynchronous.
2071         * @returns
2072         * Return a simple boolean which is {@code true} if the operation succeeds; {{@code false} otherwise} when the function call is synchronous.
2073         * Return a promise object with a boolean when the function call is asynchronous.
2074         * @since 9
2075         */
2076        onRemoteMessageRequest(code: number, data: MessageSequence, reply: MessageSequence, options: MessageOption): boolean | Promise<boolean>;
2077
2078        /**
2079         * Sets an entry for receiving requests.
2080         *
2081         * <p>This method is implemented by the remote service provider. You need to override this method with
2082         * your own service logic when you are using IPC.
2083         *
2084         * @param code Indicates the service request code sent from the peer end.
2085         * @param data Indicates the {@link MessageParcel} object sent from the peer end.
2086         * @param reply Indicates the response message object sent from the remote service.
2087         * The local service writes the response data to the {@link MessageParcel} object.
2088         * @param options Indicates whether the operation is synchronous or asynchronous.
2089         * @returns Return {@code true} if the operation succeeds; return {@code false} otherwise.
2090         * @throws RemoteException Throws this exception if a remote service error occurs.
2091         * @since 7
2092         * @deprecated since 9
2093         * @useinstead ohos.rpc.RemoteObject#onRemoteMessageRequest
2094         */
2095        onRemoteRequest(code: number, data: MessageParcel, reply: MessageParcel, options: MessageOption): boolean;
2096
2097        /**
2098         * Sends a request to the peer object.
2099         *
2100         * <p>If the peer object and {@code RemoteObject} are on the same device, the request is sent by the IPC driver.
2101         * If they are on different devices, the request is sent by the socket driver.
2102         *
2103         * @param code Indicates the message code of the request.
2104         * @param data Indicates the {@link MessageParcel} object storing the data to be sent.
2105         * @param reply Indicates the {@link MessageParcel} object receiving the response data.
2106         * @param options Indicates a synchronous (default) or asynchronous request.
2107         * @returns Return {@code true} if the operation succeeds; return {@code false} otherwise.
2108         * @since 7
2109         * @deprecated since 8
2110         */
2111        sendRequest(code: number, data: MessageParcel, reply: MessageParcel, options: MessageOption): boolean;
2112
2113        /**
2114         * Sends a {@link MessageParcel} message to the peer process in synchronous or asynchronous mode.
2115         *
2116         * <p>If options indicates the asynchronous mode, a promise will be fulfilled immediately
2117         * and the reply message does not contain any content. If options indicates the synchronous mode,
2118         * a promise will be fulfilled when the response to sendRequest is returned,
2119         * and the reply message contains the returned information.
2120         * param code Message code called by the request, which is determined by the client and server.
2121         * If the method is generated by an IDL tool, the message code is automatically generated by the IDL tool.
2122         * param data {@link MessageParcel} object holding the data to send.
2123         * param reply {@link MessageParcel} object that receives the response.
2124         * param operations Indicates the synchronous or asynchronous mode to send messages.
2125         * @returns Promise used to return the {@link SendRequestResult} instance.
2126         * @throws Throws an exception if the method fails to be called.
2127         * @since 8
2128         * @deprecated since 9
2129         * @useinstead ohos.rpc.RemoteObject#sendMessageRequest
2130         */
2131        sendRequest(code: number, data: MessageParcel, reply: MessageParcel, options: MessageOption): Promise<SendRequestResult>;
2132
2133        /**
2134         * Sends a {@link MessageSequence} message to the peer process in synchronous or asynchronous mode.
2135         *
2136         * <p>If options indicates the asynchronous mode, a promise will be fulfilled immediately
2137         * and the reply message does not contain any content. If options indicates the synchronous mode,
2138         * a promise will be fulfilled when the response to sendMessageRequest is returned,
2139         * and the reply message contains the returned information.
2140         * param code Message code called by the request, which is determined by the client and server.
2141         * If the method is generated by an IDL tool, the message code is automatically generated by the IDL tool.
2142         * param data {@link MessageSequence} object holding the data to send.
2143         * param reply {@link MessageSequence} object that receives the response.
2144         * param operations Indicates the synchronous or asynchronous mode to send messages.
2145         * @returns Promise used to return the {@link RequestResult} instance.
2146         * @throws { BusinessError } 401 - check param failed
2147         * @since 9
2148         */
2149        sendMessageRequest(code: number, data: MessageSequence, reply: MessageSequence, options: MessageOption): Promise<RequestResult>;
2150
2151        /**
2152         * Sends a {@link MessageParcel} message to the peer process in synchronous or asynchronous mode.
2153         *
2154         * <p>If options indicates the asynchronous mode, a callback will be invoked immediately
2155         * and the reply message does not contain any content. If options indicates the synchronous mode,
2156         * a callback will be invoked when the response to sendRequest is returned,
2157         * and the reply message contains the returned information.
2158         * param code Message code called by the request, which is determined by the client and server.
2159         * If the method is generated by an IDL tool, the message code is automatically generated by the IDL tool.
2160         * param data {@link MessageParcel} object holding the data to send.
2161         * param reply {@link MessageParcel} object that receives the response.
2162         * param operations Indicates the synchronous or asynchronous mode to send messages.
2163         * param callback Callback for receiving the sending result.
2164         * @since 8
2165         * @deprecated since 9
2166         * @useinstead ohos.rpc.RemoteObject#sendMessageRequest
2167         */
2168        sendRequest(code: number, data: MessageParcel, reply: MessageParcel, options: MessageOption, callback: AsyncCallback<SendRequestResult>): void;
2169
2170        /**
2171         * Sends a {@link MessageSequence} message to the peer process in synchronous or asynchronous mode.
2172         *
2173         * <p>If options indicates the asynchronous mode, a callback will be invoked immediately
2174         * and the reply message does not contain any content. If options indicates the synchronous mode,
2175         * a callback will be invoked when the response to sendMessageRequest is returned,
2176         * and the reply message contains the returned information.
2177         * param code Message code called by the request, which is determined by the client and server.
2178         * If the method is generated by an IDL tool, the message code is automatically generated by the IDL tool.
2179         * param data {@link MessageSequence} object holding the data to send.
2180         * param reply {@link MessageSequence} object that receives the response.
2181         * param operations Indicates the synchronous or asynchronous mode to send messages.
2182         * param callback Callback for receiving the sending result.
2183         * @throws { BusinessError } 401 - check param failed
2184         * @since 9
2185         */
2186        sendMessageRequest(code: number, data: MessageSequence, reply: MessageSequence, options: MessageOption, callback: AsyncCallback<RequestResult>): void;
2187
2188        /**
2189         * Obtains the PID of the {@link RemoteProxy} object.
2190         *
2191         * @returns Return the PID of the {@link RemoteProxy} object.
2192         * @since 7
2193         */
2194        getCallingPid(): number;
2195
2196        /**
2197         * Obtains the UID of the {@link RemoteProxy} object.
2198         *
2199         * @returns Return the UID of the {@link RemoteProxy} object.
2200         * @since 7
2201         */
2202        getCallingUid(): number;
2203
2204        /**
2205         * Modifies the description of the current {@code RemoteObject}.
2206         *
2207         * <p>This method is used to change the default descriptor specified during the creation of {@code RemoteObject}.
2208         *
2209         * @param localInterface Indicates the {@code RemoteObject} whose descriptor is to be changed.
2210         * @param descriptor Indicates the new descriptor of the {@code RemoteObject}.
2211         * @since 7
2212         * @deprecated since 9
2213         * @useinstead ohos.rpc.RemoteObject#modifyLocalInterface
2214         */
2215        attachLocalInterface(localInterface: IRemoteBroker, descriptor: string): void;
2216
2217        /**
2218         * Modifies the description of the current {@code RemoteObject}.
2219         *
2220         * <p>This method is used to change the default descriptor specified during the creation of {@code RemoteObject}.
2221         *
2222         * @param localInterface Indicates the {@code RemoteObject} whose descriptor is to be changed.
2223         * @param descriptor Indicates the new descriptor of the {@code RemoteObject}.
2224         * @throws { BusinessError } 401 - check param failed
2225         * @since 9
2226         */
2227        modifyLocalInterface(localInterface: IRemoteBroker, descriptor: string): void;
2228    }
2229
2230    /**
2231     * @syscap SystemCapability.Communication.IPC.Core
2232     * @since 7
2233     */
2234    class RemoteProxy implements IRemoteObject {
2235        /**
2236         * Indicates the message code for a Ping operation.
2237         *
2238         * @constant
2239         * @default 1599098439
2240         * @since 7
2241         */
2242        PING_TRANSACTION: number;
2243
2244        /**
2245         * Indicates the message code for a dump operation.
2246         *
2247         * @constant
2248         * @default 1598311760
2249         * @since 7
2250         */
2251        DUMP_TRANSACTION: number;
2252
2253        /**
2254         * Indicates the message code for a transmission.
2255         *
2256         * @constant
2257         * @default 1598968902
2258         * @since 7
2259         */
2260        INTERFACE_TRANSACTION: number;
2261
2262        /**
2263         * Indicates the minimum value of a valid message code.
2264         *
2265         * <p>This constant is used to check the validity of an operation.
2266         *
2267         * @constant
2268         * @default 0x1
2269         * @since 7
2270         */
2271        MIN_TRANSACTION_ID: number;
2272
2273        /**
2274         * Indicates the maximum value of a valid message code.
2275         *
2276         * <p>This constant is used to check the validity of an operation.
2277         *
2278         * @constant
2279         * @default 0x00FFFFFF
2280         * @since 7
2281         */
2282        MAX_TRANSACTION_ID: number;
2283
2284        /**
2285         * Queries a local interface with a specified descriptor.
2286         *
2287         * @param descriptor Indicates the descriptor of the interface to query.
2288         * @returns Return null by default, indicating a proxy interface.
2289         * @since 7
2290         * @deprecated since 9
2291         * @useinstead ohos.rpc.RemoteProxy#getLocalInterface
2292         */
2293        queryLocalInterface(interface: string): IRemoteBroker;
2294
2295        /**
2296         * Queries a local interface with a specified descriptor.
2297         *
2298         * @param descriptor Indicates the descriptor of the interface to query.
2299         * @returns Return null by default, indicating a proxy interface.
2300         * @throws { BusinessError } 401 - check param failed
2301         * @throws { BusinessError } 1900006 - only remote object permitted
2302         * @since 9
2303         */
2304        getLocalInterface(interface: string): IRemoteBroker;
2305
2306        /**
2307         * Register a callback used to receive death notifications of a remote object.
2308         *
2309         * @param recipient Indicates the callback to be registered.
2310         * @param flags Indicates the flag of the death notification. This is a reserved parameter. Set it to {@code 0}.
2311         * @returns Return {@code true} if the callback is registered successfully; return {@code false} otherwise.
2312         * @since 7
2313         * @deprecated since 9
2314         * @useinstead ohos.rpc.RemoteProxy#registerDeathRecipient
2315         */
2316        addDeathRecipient(recipient: DeathRecipient, flags: number): boolean;
2317
2318        /**
2319         * Register a callback used to receive death notifications of a remote object.
2320         *
2321         * @param recipient Indicates the callback to be registered.
2322         * @param flags Indicates the flag of the death notification. This is a reserved parameter. Set it to {@code 0}.
2323         * @throws { BusinessError } 401 - check param failed
2324         * @throws { BusinessError } 1900008 - proxy or remote object is invalid
2325         * @since 9
2326         */
2327        registerDeathRecipient(recipient: DeathRecipient, flags: number): void;
2328
2329        /**
2330         * Unregister a callback used to receive death notifications of a remote object.
2331         *
2332         * @param recipient Indicates the callback to be unregister.
2333         * @param flags Indicates the flag of the death notification. This is a reserved parameter. Set it to {@code 0}.
2334         * @returns Return {@code true} if the callback is unregister successfully; return {@code false} otherwise.
2335         * @since 7
2336         * @deprecated since 9
2337         * @useinstead ohos.rpc.RemoteProxy#unregisterDeathRecipient
2338         */
2339        removeDeathRecipient(recipient: DeathRecipient, flags: number): boolean;
2340
2341        /**
2342         * Unregister a callback used to receive death notifications of a remote object.
2343         *
2344         * @param recipient Indicates the callback to be unregister.
2345         * @param flags Indicates the flag of the death notification. This is a reserved parameter. Set it to {@code 0}.
2346         * @throws { BusinessError } 401 - check param failed
2347         * @throws { BusinessError } 1900008 - proxy or remote object is invalid
2348         * @since 9
2349         */
2350        unregisterDeathRecipient(recipient: DeathRecipient, flags: number): void;
2351
2352        /**
2353         * Queries the interface descriptor of remote object.
2354         *
2355         * @returns Return the interface descriptor.
2356         * @since 7
2357         * @deprecated since 9
2358         * @useinstead ohos.rpc.RemoteProxy#getDescriptor
2359         */
2360        getInterfaceDescriptor(): string;
2361
2362        /**
2363         * Queries the interface descriptor of remote object.
2364         *
2365         * @returns Return the interface descriptor.
2366         * @throws { BusinessError } 1900007 - communication failed
2367         * @throws { BusinessError } 1900008 - proxy or remote object is invalid
2368         * @since 9
2369         */
2370        getDescriptor(): string;
2371
2372        /**
2373         * Sends a request to the peer object.
2374         *
2375         * <p>If the peer object and {@code RemoteProxy} are on the same device, the request is sent by the IPC driver.
2376         * If they are on different devices, the request is sent by the socket driver.
2377         *
2378         * @param code Indicates the message code of the request.
2379         * @param data Indicates the {@link MessageParcel} object storing the data to be sent.
2380         * @param reply Indicates the {@link MessageParcel} object receiving the response data.
2381         * @param options Indicates a synchronous (default) or asynchronous request.
2382         * @returns Return {@code true} if the operation succeeds; return {@code false} otherwise.
2383         * @throws RemoteException Throws this exception if a remote object exception occurs.
2384         * @since 7
2385         * @deprecated since 8
2386         */
2387        sendRequest(code: number, data: MessageParcel, reply: MessageParcel, options: MessageOption): boolean;
2388
2389        /**
2390         * Sends a {@link MessageParcel} message to the peer process in synchronous or asynchronous mode.
2391         *
2392         * <p>If options indicates the asynchronous mode, a promise will be fulfilled immediately
2393         * and the reply message does not contain any content. If options indicates the synchronous mode,
2394         * a promise will be fulfilled when the response to sendRequest is returned,
2395         * and the reply message contains the returned information.
2396         * param code Message code called by the request, which is determined by the client and server.
2397         * If the method is generated by an IDL tool, the message code is automatically generated by the IDL tool.
2398         * param data {@link MessageParcel} object holding the data to send.
2399         * param reply {@link MessageParcel} object that receives the response.
2400         * param operations Indicates the synchronous or asynchronous mode to send messages.
2401         * @returns Promise used to return the {@link sendRequestResult} instance.
2402         * @throws Throws an exception if the method fails to be called.
2403         * @since 8
2404         * @deprecated since 9
2405         * @useinstead ohos.rpc.RemoteProxy#sendMessageRequest
2406         */
2407        sendRequest(code: number, data: MessageParcel, reply: MessageParcel, options: MessageOption): Promise<SendRequestResult>;
2408
2409        /**
2410         * Sends a {@link MessageSequence} message to the peer process in synchronous or asynchronous mode.
2411         *
2412         * <p>If options indicates the asynchronous mode, a promise will be fulfilled immediately
2413         * and the reply message does not contain any content. If options indicates the synchronous mode,
2414         * a promise will be fulfilled when the response to sendMessageRequest is returned,
2415         * and the reply message contains the returned information.
2416         * param code Message code called by the request, which is determined by the client and server.
2417         * If the method is generated by an IDL tool, the message code is automatically generated by the IDL tool.
2418         * param data {@link MessageSequence} object holding the data to send.
2419         * param reply {@link MessageSequence} object that receives the response.
2420         * param operations Indicates the synchronous or asynchronous mode to send messages.
2421         * @returns Promise used to return the {@link RequestResult} instance.
2422         * @throws { BusinessError } 401 - check param failed
2423         * @since 9
2424         */
2425        sendMessageRequest(code: number, data: MessageSequence, reply: MessageSequence, options: MessageOption): Promise<RequestResult>;
2426
2427        /**
2428         * Sends a {@link MessageParcel} message to the peer process in synchronous or asynchronous mode.
2429         *
2430         * <p>If options indicates the asynchronous mode, a callback will be invoked immediately
2431         * and the reply message does not contain any content. If options indicates the synchronous mode,
2432         * a callback will be invoked when the response to sendRequest is returned,
2433         * and the reply message contains the returned information.
2434         * param code Message code called by the request, which is determined by the client and server.
2435         * If the method is generated by an IDL tool, the message code is automatically generated by the IDL tool.
2436         * param data {@link MessageParcel} object holding the data to send.
2437         * param reply {@link MessageParcel} object that receives the response.
2438         * param operations Indicates the synchronous or asynchronous mode to send messages.
2439         * param callback Callback for receiving the sending result.
2440         * @since 8
2441         * @deprecated since 9
2442         * @useinstead ohos.rpc.RemoteProxy#sendMessageRequest
2443         */
2444        sendRequest(code: number, data: MessageParcel, reply: MessageParcel, options: MessageOption, callback: AsyncCallback<SendRequestResult>): void;
2445
2446        /**
2447         * Sends a {@link MessageSequence} message to the peer process in synchronous or asynchronous mode.
2448         *
2449         * <p>If options indicates the asynchronous mode, a callback will be invoked immediately
2450         * and the reply message does not contain any content. If options indicates the synchronous mode,
2451         * a callback will be invoked when the response to sendRequest is returned,
2452         * and the reply message contains the returned information.
2453         * param code Message code called by the request, which is determined by the client and server.
2454         * If the method is generated by an IDL tool, the message code is automatically generated by the IDL tool.
2455         * param data {@link MessageSequence} object holding the data to send.
2456         * param reply {@link MessageSequence} object that receives the response.
2457         * param operations Indicates the synchronous or asynchronous mode to send messages.
2458         * param callback Callback for receiving the sending result.
2459         * @throws { BusinessError } 401 - check param failed
2460         * @since 9
2461         */
2462        sendMessageRequest(code: number, data: MessageSequence, reply: MessageSequence, options: MessageOption, callback: AsyncCallback<RequestResult>): void;
2463
2464        /**
2465         * Checks whether the {@code RemoteObject} corresponding to a {@code RemoteProxy} is dead.
2466         *
2467         * @returns Return {@code true} if the {@code RemoteObject} is dead; return {@code false} otherwise.
2468         * @since 7
2469         */
2470        isObjectDead(): boolean;
2471    }
2472
2473    /**
2474     * @syscap SystemCapability.Communication.IPC.Core
2475     * @since 7
2476     */
2477    class IPCSkeleton {
2478        /**
2479         * Obtains a local {@link IRemoteObject} reference of a registered service.
2480         *
2481         * <p>This method is static.
2482         *
2483         * @returns Return an {@link IRemoteObject} reference of the registered service.
2484         * @since 7
2485         */
2486        static getContextObject(): IRemoteObject;
2487
2488        /**
2489         * Obtains the PID of a proxy.
2490         *
2491         * <p>This method is static. The PID is a positive integer during the communication between
2492         * the {@link RemoteProxy} object and {@link RemoteObject} object, and resumes to {@code 0}
2493         * when the communication ends. If this method is called from the {@link RemoteProxy} object,
2494         * {@code 0} is returned; if this method is called from the {@link RemoteObject} object,
2495         * the PID of the corresponding {@link RemoteProxy} object is returned.
2496         *
2497         * @returns Return the PID of the proxy.
2498         * @since 7
2499         */
2500        static getCallingPid(): number;
2501
2502        /**
2503         * Obtains the UID of a proxy.
2504         *
2505         * <p>This method is static. The UID is a positive integer during the communication between
2506         * the {@link RemoteProxy} object and {@link RemoteObject} object, and resumes to {@code 0}
2507         * when the communication ends. If this method is called from the {@link RemoteProxy} object,
2508         * {@code 0} is returned; if this method is called from the {@link RemoteObject} object,
2509         * the UID of the corresponding {@link RemoteProxy} object is returned.
2510         *
2511         * @returns Return the UID of the proxy.
2512         * @since 7
2513         */
2514        static getCallingUid(): number;
2515
2516        /**
2517         * Obtains the TOKENID.
2518         *
2519         * <p>This method is static.
2520         *
2521         * @returns Return the TOKENID.
2522         * @since 8
2523         */
2524        static getCallingTokenId(): number;
2525
2526        /**
2527         * Obtains the ID of the device where the peer process resides.
2528         *
2529         * <p>This method is static.
2530         *
2531         * @returns Return the ID of the device where the peer process resides.
2532         * @since 7
2533         */
2534        static getCallingDeviceID(): string;
2535
2536        /**
2537         * Obtains the ID of the local device.
2538         *
2539         * <p>This method is static.
2540         *
2541         * @returns Return the ID of the local device.
2542         * @since 7
2543         */
2544        static getLocalDeviceID(): string;
2545
2546        /**
2547         * Checks whether a call is made on the same device.
2548         *
2549         * <p>This method is static.
2550         *
2551         * @returns Return {@code true} if the call is made on the same device; return {@code false} otherwise.
2552         * @since 7
2553         */
2554        static isLocalCalling(): boolean;
2555
2556        /**
2557         * Flush all pending commands from a specified {@link RemoteProxy} to the corresponding {@link RemoteObject}.
2558         *
2559         * <p>This method is static. You are advised to call this method before performing any time-sensitive operations.
2560         *
2561         * @param object Indicates the specified {@link RemoteProxy}.
2562         * @returns Return {@code 0} if the operation succeeds; return an error code if the input object is empty
2563         * or {@link RemoteObject}, or the operation fails.
2564         * @since 7
2565         * @deprecated since 9
2566         * @useinstead ohos.rpc.IPCSkeleton#flushCmdBuffer
2567         */
2568        static flushCommands(object: IRemoteObject): number;
2569
2570        /**
2571         * Flush all pending commands from a specified {@link RemoteProxy} to the corresponding {@link RemoteObject}.
2572         *
2573         * <p>This method is static. You are advised to call this method before performing any time-sensitive operations.
2574         *
2575         * @param object Indicates the specified {@link RemoteProxy}.
2576         * @throws { BusinessError } 401 - check param failed
2577         * @since 9
2578         */
2579        static flushCmdBuffer(object: IRemoteObject): void;
2580
2581        /**
2582         * Replaces the UID and PID of the remote user with those of the local user.
2583         *
2584         * <p>This method is static. It can be used in scenarios like authentication.
2585         *
2586         * @returns Return a string containing the UID and PID of the remote user.
2587         * @since 7
2588         */
2589        static resetCallingIdentity(): string;
2590
2591        /**
2592         * Restore the UID and PID to those of the remote user.
2593         *
2594         * <p>This method is static. It is usually called after {@code resetCallingIdentity} is used
2595         * and requires the UID and PID of the remote user returned by {@code resetCallingIdentity}.
2596         *
2597         * @param identity Indicates the string containing the UID and PID of the remote user,
2598         * which is returned by {@code resetCallingIdentity}.
2599         * @returns Return {@code true} if the operation succeeds; return {@code false} otherwise.
2600         * @since 7
2601         * @deprecated since 9
2602         * @useinstead ohos.rpc.IPCSkeleton#restoreCallingIdentity
2603         */
2604        static setCallingIdentity(identity: string): boolean;
2605
2606        /**
2607         * Restore the UID and PID to those of the remote user.
2608         *
2609         * <p>This method is static. It is usually called after {@code resetCallingIdentity} is used
2610         * and requires the UID and PID of the remote user returned by {@code resetCallingIdentity}.
2611         *
2612         * @param identity Indicates the string containing the UID and PID of the remote user,
2613         * which is returned by {@code resetCallingIdentity}.
2614         * @throws { BusinessError } 401 - check param failed
2615         * @since 9
2616         */
2617        static restoreCallingIdentity(identity: string): void;
2618    }
2619
2620    /**
2621     * Provides methods related to anonymous shared memory objects,
2622     * including creating, closing, mapping, and unmapping an Ashmem object,
2623     * reading data from and writing data to an Ashmem object,
2624     * obtaining the Ashmem size, and setting Ashmem protection.
2625     * @syscap SystemCapability.Communication.IPC.Core
2626     * @since 8
2627     */
2628    class Ashmem {
2629        /**
2630         * The mapped memory is executable.
2631         *
2632         * @constant
2633         * @default 4
2634         * @since 8
2635         */
2636        PROT_EXEC: number;
2637
2638        /**
2639         * The mapped memory is inaccessible.
2640         *
2641         * @constant
2642         * @default 0
2643         * @since 8
2644         */
2645        PROT_NONE: number;
2646
2647        /**
2648         * The mapped memory is readable.
2649         *
2650         * @constant
2651         * @default 1
2652         * @since 8
2653         */
2654        PROT_READ: number;
2655
2656        /**
2657         * The mapped memory is writable.
2658         *
2659         * @constant
2660         * @default 2
2661         * @since 8
2662         */
2663        PROT_WRITE: number;
2664
2665        /**
2666         * Creates an Ashmem object with the specified name and size.
2667         * @param name Name of the Ashmem object to create.
2668         * @param size Size (in bytes) of the Ashmem object to create.
2669         * @returns Return the Ashmem object if it is created successfully; return null otherwise.
2670         * @since 8
2671         * @deprecated since 9
2672         * @useinstead ohos.rpc.Ashmem#create
2673         */
2674        static createAshmem(name: string, size: number): Ashmem;
2675
2676        /**
2677         * Creates an Ashmem object with the specified name and size.
2678         * @param name Name of the Ashmem object to create.
2679         * @param size Size (in bytes) of the Ashmem object to create.
2680         * @returns Return the Ashmem object if it is created successfully; return null otherwise.
2681         * @throws { BusinessError } 401 - check param failed
2682         * @since 9
2683         */
2684        static create(name: string, size: number): Ashmem;
2685
2686        /**
2687         * Creates an Ashmem object by copying the file descriptor (FD) of an existing Ashmem object.
2688         * The two Ashmem objects point to the same shared memory region.
2689         * @param ashmem Existing Ashmem object.
2690         * @returns Ashmem object created.
2691         * @since 8
2692         * @deprecated since 9
2693         * @useinstead ohos.rpc.Ashmem#create
2694         */
2695        static createAshmemFromExisting(ashmem: Ashmem): Ashmem;
2696
2697        /**
2698         * Creates an Ashmem object by copying the file descriptor (FD) of an existing Ashmem object.
2699         * The two Ashmem objects point to the same shared memory region.
2700         * @param ashmem Existing Ashmem object.
2701         * @returns Ashmem object created.
2702         * @throws { BusinessError } 401 - check param failed
2703         * @since 9
2704         */
2705        static create(ashmem: Ashmem): Ashmem;
2706
2707        /**
2708         * Closes this Ashmem object.
2709         * @since 8
2710         */
2711        closeAshmem(): void;
2712
2713        /**
2714         * Deletes the mappings for the specified address range of this Ashmem object.
2715         * @since 8
2716         */
2717        unmapAshmem(): void;
2718
2719        /**
2720         * Obtains the mapped memory size of this Ashmem object.
2721         * @returns Memory size mapped.
2722         * @since 8
2723         */
2724        getAshmemSize(): number;
2725
2726        /**
2727         * Creates the shared file mapping on the virtual address space of this process.
2728         * The size of the mapping region is specified by this Ashmem object.
2729         * @param mapType Protection level of the memory region to which the shared file is mapped.
2730         * @returns Return true if the operation is successful; return false otherwise.
2731         * @since 8
2732         * @deprecated since 9
2733         * @useinstead ohos.rpc.Ashmem#mapTypedAshmem
2734         */
2735        mapAshmem(mapType: number): boolean;
2736
2737        /**
2738         * Creates the shared file mapping on the virtual address space of this process.
2739         * The size of the mapping region is specified by this Ashmem object.
2740         * @param mapType Protection level of the memory region to which the shared file is mapped.
2741         * @throws { BusinessError } 401 - check param failed
2742         * @throws { BusinessError } 1900001 - call mmap function failed
2743         * @since 9
2744         */
2745        mapTypedAshmem(mapType: number): void;
2746
2747        /**
2748         * Maps the shared file to the readable and writable virtual address space of the process.
2749         * @returns Return true if the operation is successful; return false otherwise.
2750         * @since 8
2751         * @deprecated since 9
2752         * @useinstead ohos.rpc.Ashmem#mapReadWriteAshmem
2753         */
2754        mapReadAndWriteAshmem(): boolean;
2755
2756        /**
2757         * Maps the shared file to the readable and writable virtual address space of the process.
2758         * @throws { BusinessError } 1900001 - call mmap function failed
2759         * @since 9
2760         */
2761        mapReadWriteAshmem(): void;
2762
2763        /**
2764         * Maps the shared file to the read-only virtual address space of the process.
2765         * @returns Return true if the operation is successful; return false otherwise.
2766         * @since 8
2767         * @deprecated since 9
2768         * @useinstead ohos.rpc.Ashmem#mapReadonlyAshmem
2769         */
2770        mapReadOnlyAshmem(): boolean;
2771
2772        /**
2773         * Maps the shared file to the read-only virtual address space of the process.
2774         * @throws { BusinessError } 1900001 - call mmap function failed
2775         * @since 9
2776         */
2777        mapReadonlyAshmem(): void;
2778
2779        /**
2780         * Sets the protection level of the memory region to which the shared file is mapped.
2781         * @param protectionType Protection type to set.
2782         * @returns Return true if the operation is successful; return false otherwise.
2783         * @since 8
2784         * @deprecated since 9
2785         * @useinstead ohos.rpc.Ashmem#setProtectionType
2786         */
2787        setProtection(protectionType: number): boolean;
2788
2789        /**
2790         * Sets the protection level of the memory region to which the shared file is mapped.
2791         * @param protectionType Protection type to set.
2792         * @throws { BusinessError } 401 - check param failed
2793         * @throws { BusinessError } 1900002 - os ioctl function failed
2794         * @since 9
2795         */
2796        setProtectionType(protectionType: number): void;
2797
2798        /**
2799         * Writes data to the shared file associated with this Ashmem object.
2800         * @param buf Data to write
2801         * @param size Size of the data to write
2802         * @param offset Start position of the data to write in the memory region associated with this Ashmem object.
2803         * @returns Return true is the data is written successfully; return false otherwise.
2804         * @since 8
2805         * @deprecated since 9
2806         * @useinstead ohos.rpc.Ashmem#writeAshmem
2807         */
2808        writeToAshmem(buf: number[], size: number, offset: number): boolean;
2809
2810        /**
2811         * Writes data to the shared file associated with this Ashmem object.
2812         * @param buf Data to write
2813         * @param size Size of the data to write
2814         * @param offset Start position of the data to write in the memory region associated with this Ashmem object.
2815         * @throws { BusinessError } 401 - check param failed
2816         * @throws { BusinessError } 1900003 - write to ashmem failed
2817         * @since 9
2818         */
2819        writeAshmem(buf: number[], size: number, offset: number): void;
2820
2821        /**
2822         * Reads data from the shared file associated with this Ashmem object.
2823         * @param size Size of the data to read.
2824         * @param offset Start position of the data to read in the memory region associated with this Ashmem object.
2825         * @returns Data read.
2826         * @since 8
2827         * @deprecated since 9
2828         * @useinstead ohos.rpc.Ashmem#readAshmem
2829         */
2830        readFromAshmem(size: number, offset: number): number[];
2831
2832        /**
2833         * Reads data from the shared file associated with this Ashmem object.
2834         * @param size Size of the data to read.
2835         * @param offset Start position of the data to read in the memory region associated with this Ashmem object.
2836         * @returns Data read.
2837         * @throws { BusinessError } 401 - check param failed
2838         * @throws { BusinessError } 1900004 - read from ashmem failed
2839         * @since 9
2840         */
2841        readAshmem(size: number, offset: number): number[];
2842    }
2843}
2844
2845export default rpc;