• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (C) 2021-2023 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
16/**
17 * @file
18 * @kit IPCKit
19 */
20
21import type { AsyncCallback } from './@ohos.base';
22
23/**
24 * This module provides inter process communication capability.
25 *
26 * @namespace rpc
27 * @syscap SystemCapability.Communication.IPC.Core
28 * @since 7
29 */
30declare namespace rpc {
31  /**
32   * The error code of rpc.
33   *
34   * @enum { number }
35   * @syscap SystemCapability.Communication.IPC.Core
36   * @since 9
37   */
38  enum ErrorCode {
39    /**
40     * Parameter error.
41     *
42     * @syscap SystemCapability.Communication.IPC.Core
43     * @since 9
44     */
45    CHECK_PARAM_ERROR = 401,
46
47    /**
48     * Failed to call mmap.
49     *
50     * @syscap SystemCapability.Communication.IPC.Core
51     * @since 9
52     */
53    OS_MMAP_ERROR = 1900001,
54
55    /**
56     * Failed to call ioctl.
57     *
58     * @syscap SystemCapability.Communication.IPC.Core
59     * @since 9
60     */
61    OS_IOCTL_ERROR = 1900002,
62
63    /**
64     * Failed to write data to the shared memory.
65     *
66     * @syscap SystemCapability.Communication.IPC.Core
67     * @since 9
68     */
69    WRITE_TO_ASHMEM_ERROR = 1900003,
70
71    /**
72     * Failed to read data from the shared memory.
73     *
74     * @syscap SystemCapability.Communication.IPC.Core
75     * @since 9
76     */
77    READ_FROM_ASHMEM_ERROR = 1900004,
78
79    /**
80     * Operation allowed only for the proxy object.
81     *
82     * @syscap SystemCapability.Communication.IPC.Core
83     * @since 9
84     */
85    ONLY_PROXY_OBJECT_PERMITTED_ERROR = 1900005,
86
87    /**
88     * Operation allowed only for the remote object.
89     *
90     * @syscap SystemCapability.Communication.IPC.Core
91     * @since 9
92     */
93    ONLY_REMOTE_OBJECT_PERMITTED_ERROR = 1900006,
94
95    /**
96     * Communication failed.
97     *
98     * @syscap SystemCapability.Communication.IPC.Core
99     * @since 9
100     */
101    COMMUNICATION_ERROR = 1900007,
102
103    /**
104     * The proxy or remote object is invalid.
105     *
106     * @syscap SystemCapability.Communication.IPC.Core
107     * @since 9
108     */
109    PROXY_OR_REMOTE_OBJECT_INVALID_ERROR = 1900008,
110
111    /**
112     * Failed to write data to the message sequence.
113     *
114     * @syscap SystemCapability.Communication.IPC.Core
115     * @since 9
116     */
117    WRITE_DATA_TO_MESSAGE_SEQUENCE_ERROR = 1900009,
118
119    /**
120     * Failed to read data from the message sequence.
121     *
122     * @syscap SystemCapability.Communication.IPC.Core
123     * @since 9
124     */
125    READ_DATA_FROM_MESSAGE_SEQUENCE_ERROR = 1900010,
126
127    /**
128     * Memory allocation failed.
129     *
130     * @syscap SystemCapability.Communication.IPC.Core
131     * @since 9
132     */
133    PARCEL_MEMORY_ALLOC_ERROR = 1900011,
134
135    /**
136     * Call js method failed
137     *
138     * @syscap SystemCapability.Communication.IPC.Core
139     * @since 9
140     */
141    CALL_JS_METHOD_ERROR = 1900012,
142
143    /**
144     * Os dup function failed
145     *
146     * @syscap SystemCapability.Communication.IPC.Core
147     * @since 9
148     */
149    OS_DUP_ERROR = 1900013
150  }
151
152  /**
153   * Enumerates the types of the TypedArray object converted from an ArrayBuffer object.
154   *
155   * @enum { number }
156   * @syscap SystemCapability.Communication.IPC.Core
157   * @since 12
158   */
159  enum TypeCode {
160    /**
161     * The TypedArray type is Int8Array.
162     *
163     * @syscap SystemCapability.Communication.IPC.Core
164     * @since 12
165     */
166    INT8_ARRAY = 0,
167
168    /**
169     * The TypedArray type is Uint8Array.
170     *
171     * @syscap SystemCapability.Communication.IPC.Core
172     * @since 12
173     */
174    UINT8_ARRAY = 1,
175
176    /**
177     * The TypedArray type is Int16Array.
178     *
179     * @syscap SystemCapability.Communication.IPC.Core
180     * @since 12
181     */
182    INT16_ARRAY = 2,
183
184    /**
185     * The TypedArray type is Uint16Array.
186     *
187     * @syscap SystemCapability.Communication.IPC.Core
188     * @since 12
189     */
190    UINT16_ARRAY = 3,
191
192    /**
193     * The TypedArray type is Int32Array.
194     *
195     * @syscap SystemCapability.Communication.IPC.Core
196     * @since 12
197     */
198    INT32_ARRAY = 4,
199
200    /**
201     * The TypedArray type is Uint32Array.
202     *
203     * @syscap SystemCapability.Communication.IPC.Core
204     * @since 12
205     */
206    UINT32_ARRAY = 5,
207
208    /**
209     * The TypedArray type is Float32Array.
210     *
211     * @syscap SystemCapability.Communication.IPC.Core
212     * @since 12
213     */
214    FLOAT32_ARRAY = 6,
215
216    /**
217     * The TypedArray type is Float64Array.
218     *
219     * @syscap SystemCapability.Communication.IPC.Core
220     * @since 12
221     */
222    FLOAT64_ARRAY = 7,
223
224    /**
225     * The TypedArray type is BigInt64Array.
226     *
227     * @syscap SystemCapability.Communication.IPC.Core
228     * @since 12
229     */
230    BIGINT64_ARRAY = 8,
231
232    /**
233     * The TypedArray type is BigUint64Array.
234     *
235     * @syscap SystemCapability.Communication.IPC.Core
236     * @since 12
237     */
238    BIGUINT64_ARRAY = 9
239  }
240
241  /**
242   * A data object used for remote procedure call (RPC).
243   * <p>
244   * During RPC, the sender can use the write methods provided by {@link MessageParcel} to
245   * write the to-be-sent data into a {@link MessageParcel} object in a specific format, and the receiver can use the
246   * read methods provided by {@link MessageParcel} to read data of the specific format from the
247   * {@link MessageParcel} object.
248   * <p>
249   * <p>
250   * The default capacity of a {@link MessageParcel} instance is 200KB. If you want more or less,
251   * use {@link #setCapacity(int)} to change it.
252   * </p>
253   * <b>Note</b>: Only data of the following data types can be written into or read from a {@link MessageParcel}: byte,
254   * byteArray, short, shortArray, int, intArray, long, longArray, float, floatArray, double, doubleArray, boolean,
255   * booleanArray, char, charArray, String, StringArray, {@link IRemoteObject}, IRemoteObjectArray,
256   * {@link Sequenceable}, and SequenceableArray.
257   *
258   * @syscap SystemCapability.Communication.IPC.Core
259   * @since 7
260   * @deprecated since 9
261   * @useinstead ohos.rpc.MessageSequence
262   */
263  class MessageParcel {
264    /**
265     * Creates an empty {@link MessageParcel} object.
266     *
267     * @returns { MessageParcel } Return the object created.
268     * @syscap SystemCapability.Communication.IPC.Core
269     * @since 7
270     * @deprecated since 9
271     */
272    static create(): MessageParcel;
273
274    /**
275     * Reclaim the {@link MessageParcel} object.
276     *
277     * @syscap SystemCapability.Communication.IPC.Core
278     * @since 7
279     * @deprecated since 9
280     */
281    reclaim(): void;
282
283    /**
284     * Serialize a remote object and writes it to the {@link MessageParcel} object.
285     *
286     * @param { IRemoteObject } object - Remote object to serialize.
287     * @returns { boolean } Return {@code true} if it is successful; return {@code false} otherwise.
288     * @syscap SystemCapability.Communication.IPC.Core
289     * @since 7
290     * @deprecated since 9
291     */
292    writeRemoteObject(object: IRemoteObject): boolean;
293
294    /**
295     * Reads a remote object from {@link MessageParcel} object.
296     *
297     * @returns { IRemoteObject } Return the remote object.
298     * @syscap SystemCapability.Communication.IPC.Core
299     * @since 7
300     * @deprecated since 9
301     */
302    readRemoteObject(): IRemoteObject;
303
304    /**
305     * Writes an interface token into the {@link MessageParcel} object.
306     *
307     * @param { string } token - Interface descriptor to write.
308     * @returns { boolean } Return {@code true} if the interface token has been written into the {@link MessageParcel};
309     *                      return {@code false} otherwise.
310     * @syscap SystemCapability.Communication.IPC.Core
311     * @since 7
312     * @deprecated since 9
313     */
314    writeInterfaceToken(token: string): boolean;
315
316    /**
317     * Reads an interface token from the {@link MessageParcel} object.
318     *
319     * @returns { string } Return a string value.
320     * @syscap SystemCapability.Communication.IPC.Core
321     * @since 7
322     * @deprecated since 9
323     */
324    readInterfaceToken(): string;
325
326    /**
327     * Obtains the size of data (in bytes) contained in the {@link MessageParcel} object.
328     *
329     * @returns { number } Return the size of data contained in the {@link MessageParcel} object.
330     * @syscap SystemCapability.Communication.IPC.Core
331     * @since 7
332     * @deprecated since 9
333     */
334    getSize(): number;
335
336    /**
337     * Obtains the storage capacity (in bytes) of the {@link MessageParcel} object.
338     *
339     * @returns { number } Return the storage capacity of the {@link MessageParcel} object.
340     * @syscap SystemCapability.Communication.IPC.Core
341     * @since 7
342     * @deprecated since 9
343     */
344    getCapacity(): number;
345
346    /**
347     * Sets the size of data (in bytes) contained in the {@link MessageParcel} object.
348     * <p>{@code false} is returned if the data size set in this method is greater
349     * than the storage capacity of the {@link MessageParcel}.
350     *
351     * @param { number } size - Indicates the data size of the {@link MessageParcel} object.
352     * @returns { boolean } Return {@code true} if the setting is successful; return {@code false} otherwise.
353     * @syscap SystemCapability.Communication.IPC.Core
354     * @since 7
355     * @deprecated since 9
356     */
357    setSize(size: number): boolean;
358
359    /**
360     * Sets the storage capacity (in bytes) of the {@link MessageParcel} object.
361     * <p>{@code false} is returned if the capacity set in this method is less than
362     * the size of data contained in the {@link MessageParcel}.
363     *
364     * @param { number } size - Indicates the storage capacity of the {@link MessageParcel} object.
365     * @returns { boolean } Return {@code true} if the setting is successful; return {@code false} otherwise.
366     * @syscap SystemCapability.Communication.IPC.Core
367     * @since 7
368     * @deprecated since 9
369     */
370    setCapacity(size: number): boolean;
371
372    /**
373     * Obtains the writable data space (in bytes) in the {@link MessageParcel} object.
374     * <p>Writable data space = Storage capacity of the {@link MessageParcel} – Size of data contained
375     * in the {@link MessageParcel}.
376     *
377     * @returns { number } Return the writable data space of the {@link MessageParcel} object.
378     * @syscap SystemCapability.Communication.IPC.Core
379     * @since 7
380     * @deprecated since 9
381     */
382    getWritableBytes(): number;
383
384    /**
385     * Obtains the readable data space (in bytes) in the {@link MessageParcel} object.
386     * <p>Readable data space = Size of data contained in the {@link MessageParcel} – Size of data that has been read.
387     *
388     * @returns { number } Return the readable data space of the {@link MessageParcel} object.
389     * @syscap SystemCapability.Communication.IPC.Core
390     * @since 7
391     * @deprecated since 9
392     */
393    getReadableBytes(): number;
394
395    /**
396     * Obtains the current read position in the {@link MessageParcel} object.
397     *
398     * @returns { number } Return the current read position in the {@link MessageParcel} object.
399     * @syscap SystemCapability.Communication.IPC.Core
400     * @since 7
401     * @deprecated since 9
402     */
403    getReadPosition(): number;
404
405    /**
406     * Obtains the current write position in the {@link MessageParcel} object.
407     *
408     * @returns { number } Return the current write position in the {@link MessageParcel} object.
409     * @syscap SystemCapability.Communication.IPC.Core
410     * @since 7
411     * @deprecated since 9
412     */
413    getWritePosition(): number;
414
415    /**
416     * Changes the current read position in the {@link MessageParcel} object.
417     * <p>Generally, you are advised not to change the current read position. If you must
418     * change it, change it to an accurate position. Otherwise, the read data may be incorrect.
419     *
420     * @param { number } pos - Indicates the target position to start data reading.
421     * @returns { boolean } Return {@code true} if the read position is changed; return {@code false} otherwise.
422     * @syscap SystemCapability.Communication.IPC.Core
423     * @since 7
424     * @deprecated since 9
425     */
426    rewindRead(pos: number): boolean;
427
428    /**
429     * Changes the current write position in the {@link MessageParcel} object.
430     * <p>Generally, you are advised not to change the current write position. If you must
431     * change it, change it to an accurate position. Otherwise, the data to be read may be incorrect.
432     *
433     * @param { number } pos - Indicates the target position to start data writing.
434     * @returns { boolean } Return {@code true} if the write position is changed; return {@code false} otherwise.
435     * @syscap SystemCapability.Communication.IPC.Core
436     * @since 7
437     * @deprecated since 9
438     */
439    rewindWrite(pos: number): boolean;
440
441    /**
442     * Writes information to this MessageParcel object indicating that no exception occurred.
443     * <p>After handling requests, you should call this method before writing any data to reply {@link MessageParcel}.
444     *
445     * @syscap SystemCapability.Communication.IPC.Core
446     * @since 8
447     * @deprecated since 9
448     */
449    writeNoException(): void;
450
451    /**
452     * Reads the exception information from this MessageParcel object.
453     * <p>If exception was thrown in server side, it will be thrown here.
454     * This method should be called before reading any data from reply {@link MessageParcel}
455     * if {@link writeNoException} was invoked in server side.
456     *
457     * @syscap SystemCapability.Communication.IPC.Core
458     * @since 8
459     * @deprecated since 9
460     */
461    readException(): void;
462
463    /**
464     * Writes a byte value into the {@link MessageParcel} object.
465     *
466     * @param { number } val - Indicates the byte value to write.
467     * @returns { boolean } Return {@code true} if the value has been written into the {@link MessageParcel};
468     *                      return {@code false} otherwise.
469     * @syscap SystemCapability.Communication.IPC.Core
470     * @since 7
471     * @deprecated since 9
472     */
473    writeByte(val: number): boolean;
474
475    /**
476     * Writes a short integer value into the {@link MessageParcel} object.
477     *
478     * @param { number } val - Indicates the short integer value to write.
479     * @returns { boolean } Return {@code true} if the value has been written into the {@link MessageParcel};
480     *                      return {@code false} otherwise.
481     * @syscap SystemCapability.Communication.IPC.Core
482     * @since 7
483     * @deprecated since 9
484     */
485    writeShort(val: number): boolean;
486
487    /**
488     * Writes an integer value into the {@link MessageParcel} object.
489     *
490     * @param { number } val - Indicates the integer value to write.
491     * @returns { boolean } Return {@code true} if the value has been written into the {@link MessageParcel};
492     *                      return {@code false} otherwise.
493     * @syscap SystemCapability.Communication.IPC.Core
494     * @since 7
495     * @deprecated since 9
496     */
497    writeInt(val: number): boolean;
498
499    /**
500     * Writes a long integer value into the {@link MessageParcel} object.
501     *
502     * @param { number } val - Indicates the long integer value to write.
503     * @returns { boolean } Return {@code true} if the value has been written into the {@link MessageParcel};
504     *                      return {@code false} otherwise.
505     * @syscap SystemCapability.Communication.IPC.Core
506     * @since 7
507     * @deprecated since 9
508     */
509    writeLong(val: number): boolean;
510
511    /**
512     * Writes a floating point value into the {@link MessageParcel} object.
513     *
514     * @param { number } val - Indicates the floating point value to write.
515     * @returns { boolean } Return {@code true} if the value has been written into the {@link MessageParcel};
516     *                      return {@code false} otherwise.
517     * @syscap SystemCapability.Communication.IPC.Core
518     * @since 7
519     * @deprecated since 9
520     */
521    writeFloat(val: number): boolean;
522
523    /**
524     * Writes a double-precision floating point value into the {@link MessageParcel} object.
525     *
526     * @param { number } val - Indicates the double-precision floating point value to write.
527     * @returns { boolean } Return {@code true} if the value has been written into the {@link MessageParcel};
528     *                      return {@code false} otherwise.
529     * @syscap SystemCapability.Communication.IPC.Core
530     * @since 7
531     * @deprecated since 9
532     */
533    writeDouble(val: number): boolean;
534
535    /**
536     * Writes a boolean value into the {@link MessageParcel} object.
537     *
538     * @param { boolean } val - Indicates the boolean value to write.
539     * @returns { boolean } Return {@code true} if the value has been written into the {@link MessageParcel};
540     *                      return {@code false} otherwise.
541     * @syscap SystemCapability.Communication.IPC.Core
542     * @since 7
543     * @deprecated since 9
544     */
545    writeBoolean(val: boolean): boolean;
546
547    /**
548     * Writes a single character value into the {@link MessageParcel} object.
549     *
550     * @param { number } val - Indicates the single character value to write.
551     * @returns { boolean } Return {@code true} if the value has been written into the {@link MessageParcel};
552     *                      return {@code false} otherwise.
553     * @syscap SystemCapability.Communication.IPC.Core
554     * @since 7
555     * @deprecated since 9
556     */
557    writeChar(val: number): boolean;
558
559    /**
560     * Writes a string value into the {@link MessageParcel} object.
561     *
562     * @param { string } val - Indicates the string value to write.
563     * @returns { boolean } Return {@code true} if the value has been written into the {@link MessageParcel};
564     *                      return {@code false} otherwise.
565     * @syscap SystemCapability.Communication.IPC.Core
566     * @since 7
567     * @deprecated since 9
568     */
569    writeString(val: string): boolean;
570
571    /**
572     * Writes a {@link Sequenceable} object into the {@link MessageParcel} object.
573     *
574     * @param { Sequenceable } val - Indicates the {@link Sequenceable} object to write.
575     * @returns { boolean } Return {@code true} if the {@link Sequenceable} object has been written into
576     *                      the {@link MessageParcel}; return {@code false} otherwise.
577     * @syscap SystemCapability.Communication.IPC.Core
578     * @since 7
579     * @deprecated since 9
580     */
581    writeSequenceable(val: Sequenceable): boolean;
582
583    /**
584     * Writes a byte array into the {@link MessageParcel} object.
585     *
586     * @param { number[] } byteArray - Indicates the byte array to write.
587     * @returns { boolean } Return {@code true} if the array has been written into the {@link MessageParcel};
588     *                      return {@code false} otherwise.
589     * @syscap SystemCapability.Communication.IPC.Core
590     * @since 7
591     * @deprecated since 9
592     */
593    writeByteArray(byteArray: number[]): boolean;
594
595    /**
596     * Writes a short integer array into the {@link MessageParcel} object.
597     * Ensure that the data type and size comply with the interface definition.
598     * Otherwise,data may be truncated.
599     *
600     * @param { number[] } shortArray - Indicates the short integer array to write.
601     * @returns { boolean } Return {@code true} if the array has been written into the {@link MessageParcel};
602     *                      return {@code false} otherwise.
603     * @syscap SystemCapability.Communication.IPC.Core
604     * @since 7
605     * @deprecated since 9
606     */
607    writeShortArray(shortArray: number[]): boolean;
608
609    /**
610     * Writes an integer array into the {@link MessageParcel} object.
611     * Ensure that the data type and size comply with the interface definition.
612     * Otherwise,data may be truncated.
613     *
614     * @param { number[] } intArray - Indicates the integer array to write.
615     * @returns { boolean } Return {@code true} if the array has been written into the {@link MessageParcel};
616     *                      return {@code false} otherwise.
617     * @syscap SystemCapability.Communication.IPC.Core
618     * @since 7
619     * @deprecated since 9
620     */
621    writeIntArray(intArray: number[]): boolean;
622
623    /**
624     * Writes a long integer array into the {@link MessageParcel} object.
625     * Ensure that the data type and size comply with the interface definition.
626     * Otherwise,data may be truncated.
627     *
628     * @param { number[] } longArray - Indicates the long integer array to write.
629     * @returns { boolean } Return {@code true} if the array has been written into the {@link MessageParcel};
630     *                      return {@code false} otherwise.
631     * @syscap SystemCapability.Communication.IPC.Core
632     * @since 7
633     * @deprecated since 9
634     */
635    writeLongArray(longArray: number[]): boolean;
636
637    /**
638     * Writes a floating point array into the {@link MessageParcel} object.
639     * Ensure that the data type and size comply with the interface definition.
640     * Otherwise,data may be truncated.
641     *
642     * @param { number[] } floatArray - Indicates the floating point array to write.
643     * @returns { boolean } Return {@code true} if the array has been written into the {@link MessageParcel};
644     *                      return {@code false} otherwise.
645     * @syscap SystemCapability.Communication.IPC.Core
646     * @since 7
647     * @deprecated since 9
648     */
649    writeFloatArray(floatArray: number[]): boolean;
650
651    /**
652     * Writes a double-precision floating point array into the {@link MessageParcel} object.
653     * Ensure that the data type and size comply with the interface definition.
654     * Otherwise,data may be truncated.
655     *
656     * @param { number[] } doubleArray - Indicates the double-precision floating point array to write.
657     * @returns { boolean } Return {@code true} if the array has been written into the {@link MessageParcel};
658     *                      return {@code false} otherwise.
659     * @syscap SystemCapability.Communication.IPC.Core
660     * @since 7
661     * @deprecated since 9
662     */
663    writeDoubleArray(doubleArray: number[]): boolean;
664
665    /**
666     * Writes a boolean array into the {@link MessageParcel} object.
667     * Ensure that the data type and size comply with the interface definition.
668     * Otherwise,data may be truncated.
669     *
670     * @param { boolean[] } booleanArray - Indicates the boolean array to write.
671     * @returns { boolean } Return {@code true} if the array has been written into the {@link MessageParcel};
672     *                      return {@code false} otherwise.
673     * @syscap SystemCapability.Communication.IPC.Core
674     * @since 7
675     * @deprecated since 9
676     */
677    writeBooleanArray(booleanArray: boolean[]): boolean;
678
679    /**
680     * Writes a single character array into the {@link MessageParcel} object.
681     * Ensure that the data type and size comply with the interface definition.
682     * Otherwise,data may be truncated.
683     *
684     * @param { number[] } charArray - Indicates the single character array to write.
685     * @returns { boolean } Return {@code true} if the array has been written into the {@link MessageParcel};
686     *                      return {@code false} otherwise.
687     * @syscap SystemCapability.Communication.IPC.Core
688     * @since 7
689     * @deprecated since 9
690     */
691    writeCharArray(charArray: number[]): boolean;
692
693    /**
694     * Writes a string array into the {@link MessageParcel} object.
695     * Ensure that the data type and size comply with the interface definition.
696     * Otherwise,data may be truncated.
697     *
698     * @param { string[] } stringArray - Indicates the string array to write.
699     * @returns { boolean } Return {@code true} if the array has been written into the {@link MessageParcel};
700     *                      return {@code false} otherwise.
701     * @syscap SystemCapability.Communication.IPC.Core
702     * @since 7
703     * @deprecated since 9
704     */
705    writeStringArray(stringArray: string[]): boolean;
706
707    /**
708     * Writes a {@link Sequenceable} object array into the {@link MessageParcel} object.
709     *
710     * @param { Sequenceable[] } sequenceableArray - Indicates the {@link Sequenceable} object array to write.
711     * @returns { boolean } Return {@code true} if the array has been written into the {@link MessageParcel};
712     *                      return {@code false} otherwise.
713     * @syscap SystemCapability.Communication.IPC.Core
714     * @since 7
715     * @deprecated since 9
716     */
717    writeSequenceableArray(sequenceableArray: Sequenceable[]): boolean;
718
719    /**
720     * Writes an array of {@link IRemoteObject} objects to this {@link MessageParcel} object.
721     *
722     * @param { IRemoteObject[] } objectArray - Array of {@link IRemoteObject} objects to write.
723     * @returns { boolean } Return {@code true} if the {@link IRemoteObject} array is successfully written
724     *                      to the {@link MessageParcel};
725     *                      return {@code false} if the {@link IRemoteObject} array is null or fails to be written
726     *                      to the {@link MessageParcel}.
727     * @syscap SystemCapability.Communication.IPC.Core
728     * @since 8
729     * @deprecated since 9
730     */
731    writeRemoteObjectArray(objectArray: IRemoteObject[]): boolean;
732
733    /**
734     * Reads a byte value from the {@link MessageParcel} object.
735     *
736     * @returns { number } Return a byte value.
737     * @syscap SystemCapability.Communication.IPC.Core
738     * @since 7
739     * @deprecated since 9
740     */
741    readByte(): number;
742
743    /**
744     * Reads a short integer value from the {@link MessageParcel} object.
745     *
746     * @returns { number } Return a short integer value.
747     * @syscap SystemCapability.Communication.IPC.Core
748     * @since 7
749     * @deprecated since 9
750     */
751    readShort(): number;
752
753    /**
754     * Reads an integer value from the {@link MessageParcel} object.
755     *
756     * @returns { number } Return an integer value.
757     * @syscap SystemCapability.Communication.IPC.Core
758     * @since 7
759     * @deprecated since 9
760     */
761    readInt(): number;
762
763    /**
764     * Reads a long integer value from the {@link MessageParcel} object.
765     *
766     * @returns { number } Return a long integer value.
767     * @syscap SystemCapability.Communication.IPC.Core
768     * @since 7
769     * @deprecated since 9
770     */
771    readLong(): number;
772
773    /**
774     * Reads a floating point value from the {@link MessageParcel} object.
775     *
776     * @returns { number } Return a floating point value.
777     * @syscap SystemCapability.Communication.IPC.Core
778     * @since 7
779     * @deprecated since 9
780     */
781    readFloat(): number;
782
783    /**
784     * Reads a double-precision floating point value from the {@link MessageParcel} object.
785     *
786     * @returns { number } Return a double-precision floating point value.
787     * @syscap SystemCapability.Communication.IPC.Core
788     * @since 7
789     * @deprecated since 9
790     */
791    readDouble(): number;
792
793    /**
794     * Reads a boolean value from the {@link MessageParcel} object.
795     *
796     * @returns { boolean } Return a boolean value.
797     * @syscap SystemCapability.Communication.IPC.Core
798     * @since 7
799     * @deprecated since 9
800     */
801    readBoolean(): boolean;
802
803    /**
804     * Reads a single character value from the {@link MessageParcel} object.
805     *
806     * @returns { number } Return a single character value.
807     * @syscap SystemCapability.Communication.IPC.Core
808     * @since 7
809     * @deprecated since 9
810     */
811    readChar(): number;
812
813    /**
814     * Reads a string value from the {@link MessageParcel} object.
815     *
816     * @returns { string } Return a string value.
817     * @syscap SystemCapability.Communication.IPC.Core
818     * @since 7
819     * @deprecated since 9
820     */
821    readString(): string;
822
823    /**
824     * Reads a {@link Sequenceable} object from the {@link MessageParcel} instance.
825     *
826     * @param { Sequenceable } dataIn - Indicates the {@link Sequenceable} object that needs to perform
827     *                         the {@code unmarshalling} operation using the {@link MessageParcel}.
828     * @returns { boolean } Return {@code true} if the unmarshalling is successful; return {@code false} otherwise.
829     * @syscap SystemCapability.Communication.IPC.Core
830     * @since 7
831     * @deprecated since 9
832     */
833    readSequenceable(dataIn: Sequenceable): boolean;
834
835    /**
836     * Writes a byte array into the {@link MessageParcel} object.
837     *
838     * @param { number[] } dataIn - Indicates the byte array read from MessageParcel.
839     * @syscap SystemCapability.Communication.IPC.Core
840     * @since 7
841     * @deprecated since 9
842     */
843    readByteArray(dataIn: number[]): void;
844
845    /**
846     * Reads a byte array from the {@link MessageParcel} object.
847     *
848     * @returns { number[] } Return a byte array.
849     * @syscap SystemCapability.Communication.IPC.Core
850     * @since 7
851     * @deprecated since 9
852     */
853    readByteArray(): number[];
854
855    /**
856     * Reads a short integer array from the {@link MessageParcel} object.
857     *
858     * @param { number[] } dataIn - Indicates the short integer array read from MessageParcel.
859     * @syscap SystemCapability.Communication.IPC.Core
860     * @since 7
861     * @deprecated since 9
862     */
863    readShortArray(dataIn: number[]): void;
864
865    /**
866     * Reads a short integer array from the {@link MessageParcel} object.
867     *
868     * @returns { number[] } Return a short integer array.
869     * @syscap SystemCapability.Communication.IPC.Core
870     * @since 7
871     * @deprecated since 9
872     */
873    readShortArray(): number[];
874
875    /**
876     * Reads an integer array from the {@link MessageParcel} object.
877     *
878     * @param { number[] } dataIn - Indicates the integer array to read.
879     * @syscap SystemCapability.Communication.IPC.Core
880     * @since 7
881     * @deprecated since 9
882     */
883    readIntArray(dataIn: number[]): void;
884
885    /**
886     * Reads an integer array from the {@link MessageParcel} object.
887     *
888     * @returns { number[] } Return an integer array.
889     * @syscap SystemCapability.Communication.IPC.Core
890     * @since 7
891     * @deprecated since 9
892     */
893    readIntArray(): number[];
894
895    /**
896     * Reads a long integer array from the {@link MessageParcel} object.
897     *
898     * @param { number[] } dataIn - Indicates the long integer array to read.
899     * @syscap SystemCapability.Communication.IPC.Core
900     * @since 7
901     * @deprecated since 9
902     */
903    readLongArray(dataIn: number[]): void;
904
905    /**
906     * Reads a long integer array from the {@link MessageParcel} object.
907     *
908     * @returns { number[] } Return a long integer array.
909     * @syscap SystemCapability.Communication.IPC.Core
910     * @since 7
911     * @deprecated since 9
912     */
913    readLongArray(): number[];
914
915    /**
916     * Reads a floating point array from the {@link MessageParcel} object.
917     *
918     * @param { number[] } dataIn - Indicates the floating point array to read.
919     * @syscap SystemCapability.Communication.IPC.Core
920     * @since 7
921     * @deprecated since 9
922     */
923    readFloatArray(dataIn: number[]): void;
924
925    /**
926     * Reads a floating point array from the {@link MessageParcel} object.
927     *
928     * @returns { number[] } Return a floating point array.
929     * @syscap SystemCapability.Communication.IPC.Core
930     * @since 7
931     * @deprecated since 9
932     */
933    readFloatArray(): number[];
934
935    /**
936     * Reads a double-precision floating point array from the {@link MessageParcel} object.
937     *
938     * @param { number[] } dataIn - Indicates the double-precision floating point array to read.
939     * @syscap SystemCapability.Communication.IPC.Core
940     * @since 7
941     * @deprecated since 9
942     */
943    readDoubleArray(dataIn: number[]): void;
944
945    /**
946     * Reads a double-precision floating point array from the {@link MessageParcel} object.
947     *
948     * @returns { number[] } Return a double-precision floating point array.
949     * @syscap SystemCapability.Communication.IPC.Core
950     * @since 7
951     * @deprecated since 9
952     */
953    readDoubleArray(): number[];
954
955    /**
956     * Reads a boolean array from the {@link MessageParcel} object.
957     *
958     * @param { boolean[] } dataIn - Indicates the boolean array to read.
959     * @syscap SystemCapability.Communication.IPC.Core
960     * @since 7
961     * @deprecated since 9
962     */
963    readBooleanArray(dataIn: boolean[]): void;
964
965    /**
966     * Reads a boolean array from the {@link MessageParcel} object.
967     *
968     * @returns { boolean[] } Return a boolean array.
969     * @syscap SystemCapability.Communication.IPC.Core
970     * @since 7
971     * @deprecated since 9
972     */
973    readBooleanArray(): boolean[];
974
975    /**
976     * Reads a single character array from the {@link MessageParcel} object.
977     *
978     * @param { number[] } dataIn - Indicates the single character array to read.
979     * @syscap SystemCapability.Communication.IPC.Core
980     * @since 7
981     * @deprecated since 9
982     */
983    readCharArray(dataIn: number[]): void;
984
985    /**
986     * Reads a single character array from the {@link MessageParcel} object.
987     *
988     * @returns { number[] } Return a single character array.
989     * @syscap SystemCapability.Communication.IPC.Core
990     * @since 7
991     * @deprecated since 9
992     */
993    readCharArray(): number[];
994
995    /**
996     * Reads a string array from the {@link MessageParcel} object.
997     *
998     * @param { string[] } dataIn - Indicates the string array to read.
999     * @syscap SystemCapability.Communication.IPC.Core
1000     * @since 7
1001     * @deprecated since 9
1002     */
1003    readStringArray(dataIn: string[]): void;
1004
1005    /**
1006     * Reads a string array from the {@link MessageParcel} object.
1007     *
1008     * @returns { string[] } Return a string array.
1009     * @syscap SystemCapability.Communication.IPC.Core
1010     * @since 7
1011     * @deprecated since 9
1012     */
1013    readStringArray(): string[];
1014
1015    /**
1016     * Reads the specified {@link Sequenceable} array from this {@link MessageParcel} object.
1017     *
1018     * @param { Sequenceable[] } sequenceableArray - Sequenceable array to read.
1019     * @syscap SystemCapability.Communication.IPC.Core
1020     * @since 8
1021     * @deprecated since 9
1022     */
1023    readSequenceableArray(sequenceableArray: Sequenceable[]): void;
1024
1025    /**
1026     * Reads the specified {@link IRemoteObject} array from this {@link MessageParcel} object.
1027     *
1028     * @param { IRemoteObject[] } objects - Reads data from this {@link MessageParcel} object to the specified
1029     *                            {@link IRemoteObject} array.
1030     * @syscap SystemCapability.Communication.IPC.Core
1031     * @since 8
1032     * @deprecated since 9
1033     */
1034    readRemoteObjectArray(objects: IRemoteObject[]): void;
1035
1036    /**
1037     * Reads {@link IRemoteObject} objects from this {@link MessageParcel} object.
1038     *
1039     * @returns { IRemoteObject[] } An array of {@link IRemoteObject} objects obtained.
1040     * @syscap SystemCapability.Communication.IPC.Core
1041     * @since 8
1042     * @deprecated since 9
1043     */
1044    readRemoteObjectArray(): IRemoteObject[];
1045
1046    /**
1047     * Closes the specified file descriptor.
1048     *
1049     * @param { number } fd - File descriptor to be closed.
1050     * @syscap SystemCapability.Communication.IPC.Core
1051     * @since 8
1052     * @deprecated since 9
1053     */
1054    static closeFileDescriptor(fd: number): void;
1055
1056    /**
1057     * Duplicates the specified file descriptor.
1058     *
1059     * @param { number } fd - File descriptor to be duplicated.
1060     * @returns { number } Return a duplicated file descriptor.
1061     * @syscap SystemCapability.Communication.IPC.Core
1062     * @since 8
1063     * @deprecated since 9
1064     */
1065    static dupFileDescriptor(fd: number): number;
1066
1067    /**
1068     * Checks whether this {@link MessageParcel} object contains a file descriptor.
1069     *
1070     * @returns { boolean } Return {@code true} if the {@link MessageParcel} object contains a file descriptor;
1071     *                      return {@code false} otherwise.
1072     * @syscap SystemCapability.Communication.IPC.Core
1073     * @since 8
1074     * @deprecated since 9
1075     */
1076    containFileDescriptors(): boolean;
1077
1078    /**
1079     * Writes a file descriptor to this {@link MessageParcel} object.
1080     *
1081     * @param { number } fd - File descriptor to wrote.
1082     * @returns { boolean } Return {@code true} if the operation is successful; return {@code false} otherwise.
1083     * @syscap SystemCapability.Communication.IPC.Core
1084     * @since 8
1085     * @deprecated since 9
1086     */
1087    writeFileDescriptor(fd: number): boolean;
1088
1089    /**
1090     * Reads a file descriptor from this {@link MessageParcel} object.
1091     *
1092     * @returns { number } Return a file descriptor obtained.
1093     * @syscap SystemCapability.Communication.IPC.Core
1094     * @since 8
1095     * @deprecated since 9
1096     */
1097    readFileDescriptor(): number;
1098
1099    /**
1100     * Writes an anonymous shared memory object to this {@link MessageParcel} object.
1101     *
1102     * @param { Ashmem } ashmem - Anonymous shared memory object to wrote.
1103     * @returns { boolean } Return {@code true} if the operation is successful; return {@code false} otherwise.
1104     * @syscap SystemCapability.Communication.IPC.Core
1105     * @since 8
1106     * @deprecated since 9
1107     */
1108    writeAshmem(ashmem: Ashmem): boolean;
1109
1110    /**
1111     * Reads the anonymous shared memory object from this {@link MessageParcel} object.
1112     *
1113     * @returns { Ashmem } Anonymous share object obtained.
1114     * @syscap SystemCapability.Communication.IPC.Core
1115     * @since 8
1116     * @deprecated since 9
1117     */
1118    readAshmem(): Ashmem;
1119
1120    /**
1121     * Obtains the maximum amount of raw data that can be sent in a time.
1122     *
1123     * @returns { number } 128 MB.
1124     * @syscap SystemCapability.Communication.IPC.Core
1125     * @since 8
1126     * @deprecated since 9
1127     */
1128    getRawDataCapacity(): number;
1129
1130    /**
1131     * Writes raw data to this {@link MessageParcel} object.
1132     *
1133     * @param { number[] } rawData - Raw data to wrote.
1134     * @param { number } size - Size of the raw data, in bytes.
1135     * @returns { boolean } Return {@code true} if the operation is successful; return {@code false} otherwise.
1136     * @syscap SystemCapability.Communication.IPC.Core
1137     * @since 8
1138     * @deprecated since 9
1139     */
1140    writeRawData(rawData: number[], size: number): boolean;
1141
1142    /**
1143     * Reads raw data from this {@link MessageParcel} object.
1144     *
1145     * @param { number } size - Size of the raw data to read.
1146     * @returns { number[] } Return the raw data obtained, in bytes.
1147     * @syscap SystemCapability.Communication.IPC.Core
1148     * @since 8
1149     * @deprecated since 9
1150     */
1151    readRawData(size: number): number[];
1152  }
1153
1154  /**
1155   * A data object used for remote procedure call (RPC).
1156   * <p>
1157   * During RPC, the sender can use the write methods provided by {@link MessageSequence} to
1158   * write the to-be-sent data into a {@link MessageSequence} object in a specific format, and the receiver can use the
1159   * read methods provided by {@link MessageSequence} to read data of the specific format from
1160   * the {@link MessageSequence} object.
1161   * <p>
1162   * <p>
1163   * The default capacity of a {@link MessageSequence} instance is 200KB. If you want more or less,
1164   * use {@link #setCapacity(int)} to change it.
1165   * </p>
1166   * <b>Note</b>: Only data of the following data types can be written into or read from a {@link MessageSequence}:
1167   * byte, byteArray, short, shortArray, int, intArray, long, longArray, float, floatArray, double, doubleArray,
1168   * boolean, booleanArray, char, charArray, String, StringArray, {@link IRemoteObject}, IRemoteObjectArray,
1169   * {@link Parcelable}, and ParcelableArray.
1170   *
1171   * @syscap SystemCapability.Communication.IPC.Core
1172   * @since 9
1173   */
1174  class MessageSequence {
1175    /**
1176     * Creates an empty {@link MessageSequence} object.
1177     *
1178     * @returns { MessageSequence } Return the object created.
1179     * @syscap SystemCapability.Communication.IPC.Core
1180     * @since 9
1181     */
1182    static create(): MessageSequence;
1183
1184    /**
1185     * Reclaim the {@link MessageSequence} object.
1186     *
1187     * @syscap SystemCapability.Communication.IPC.Core
1188     * @since 9
1189     */
1190    reclaim(): void;
1191
1192    /**
1193     * Serialize a remote object and writes it to the {@link MessageSequence} object.
1194     *
1195     * @param { IRemoteObject } object - Remote object to serialize.
1196     * @throws { BusinessError } 401 - Parameter error. Possible causes:
1197     *     1.The number of parameters is incorrect;
1198     *     2.The parameter type does not match.
1199     * @throws { BusinessError } 1900008 - The proxy or remote object is invalid.
1200     * @throws { BusinessError } 1900009 - Failed to write data to the message sequence.
1201     * @syscap SystemCapability.Communication.IPC.Core
1202     * @since 9
1203     */
1204    writeRemoteObject(object: IRemoteObject): void;
1205
1206    /**
1207     * Reads a remote object from {@link MessageSequence} object.
1208     *
1209     * @returns { IRemoteObject } Return the remote object.
1210     * @throws { BusinessError } 1900008 - The proxy or remote object is invalid.
1211     * @throws { BusinessError } 1900010 - Failed to read data from the message sequence.
1212     * @syscap SystemCapability.Communication.IPC.Core
1213     * @since 9
1214     */
1215    readRemoteObject(): IRemoteObject;
1216
1217    /**
1218     * Writes an interface token into the {@link MessageSequence} object.
1219     *
1220     * @param { string } token - Interface descriptor to write.
1221     * @throws { BusinessError } 401 - Parameter error. Possible causes:
1222     *     1.The number of parameters is incorrect;
1223     *     2.The parameter type does not match;
1224     *     3.The string length exceeds 40960 bytes;
1225     *     4.The number of bytes copied to the buffer is different from the length of the obtained string.
1226     * @throws { BusinessError } 1900009 - Failed to write data to the message sequence.
1227     * @syscap SystemCapability.Communication.IPC.Core
1228     * @since 9
1229     */
1230    writeInterfaceToken(token: string): void;
1231
1232    /**
1233     * Reads an interface token from the {@link MessageSequence} object.
1234     *
1235     * @returns { string } Return a string value.
1236     * @throws { BusinessError } 1900010 - Failed to read data from the message sequence.
1237     * @syscap SystemCapability.Communication.IPC.Core
1238     * @since 9
1239     */
1240    readInterfaceToken(): string;
1241
1242    /**
1243     * Obtains the size of data (in bytes) contained in the {@link MessageSequence} object.
1244     *
1245     * @returns { number } Return the size of data contained in the {@link MessageSequence} object.
1246     * @syscap SystemCapability.Communication.IPC.Core
1247     * @since 9
1248     */
1249    getSize(): number;
1250
1251    /**
1252     * Obtains the storage capacity (in bytes) of the {@link MessageSequence} object.
1253     *
1254     * @returns { number } Return the storage capacity of the {@link MessageSequence} object.
1255     * @syscap SystemCapability.Communication.IPC.Core
1256     * @since 9
1257     */
1258    getCapacity(): number;
1259
1260    /**
1261     * Sets the size of data (in bytes) contained in the {@link MessageSequence} object.
1262     * <p>{@code false} is returned if the data size set in this method is greater
1263     * than the storage capacity of the {@link MessageSequence}.
1264     *
1265     * @param { number } size - Indicates the data size of the {@link MessageSequence} object.
1266     * @throws { BusinessError } 401 - Parameter error. Possible causes:
1267     *     1.The number of parameters is incorrect;
1268     *     2.The parameter type does not match.
1269     * @syscap SystemCapability.Communication.IPC.Core
1270     * @since 9
1271     */
1272    setSize(size: number): void;
1273
1274    /**
1275     * Sets the storage capacity (in bytes) of the {@link MessageSequence} object.
1276     * <p>{@code false} is returned if the capacity set in this method is less than
1277     * the size of data contained in the {@link MessageSequence}.
1278     *
1279     * @param { number } size - Indicates the storage capacity of the {@link MessageSequence} object.
1280     * @throws { BusinessError } 401 - Parameter error. Possible causes:
1281     *     1.The number of parameters is incorrect;
1282     *     2.The parameter type does not match.
1283     * @throws { BusinessError } 1900011 - Memory allocation failed.
1284     * @syscap SystemCapability.Communication.IPC.Core
1285     * @since 9
1286     */
1287    setCapacity(size: number): void;
1288
1289    /**
1290     * Obtains the writable data space (in bytes) in the {@link MessageSequence} object.
1291     * <p>Writable data space = Storage capacity of the {@link MessageSequence} – Size of data contained in
1292     * the {@link MessageSequence}.
1293     *
1294     * @returns { number } Return the writable data space of the {@link MessageSequence} object.
1295     * @syscap SystemCapability.Communication.IPC.Core
1296     * @since 9
1297     */
1298    getWritableBytes(): number;
1299
1300    /**
1301     * Obtains the readable data space (in bytes) in the {@link MessageSequence} object.
1302     * <p>Readable data space = Size of data contained in the {@link MessageSequence} – Size of data that has been read.
1303     *
1304     * @returns { number } Return the readable data space of the {@link MessageSequence} object.
1305     * @syscap SystemCapability.Communication.IPC.Core
1306     * @since 9
1307     */
1308    getReadableBytes(): number;
1309
1310    /**
1311     * Obtains the current read position in the {@link MessageSequence} object.
1312     *
1313     * @returns { number } Return the current read position in the {@link MessageSequence} object.
1314     * @syscap SystemCapability.Communication.IPC.Core
1315     * @since 9
1316     */
1317    getReadPosition(): number;
1318
1319    /**
1320     * Obtains the current write position in the {@link MessageSequence} object.
1321     *
1322     * @returns { number } Return the current write position in the {@link MessageSequence} object.
1323     * @syscap SystemCapability.Communication.IPC.Core
1324     * @since 9
1325     */
1326    getWritePosition(): number;
1327
1328    /**
1329     * Changes the current read position in the {@link MessageSequence} object.
1330     * <p>Generally, you are advised not to change the current read position. If you must
1331     * change it, change it to an accurate position. Otherwise, the read data may be incorrect.
1332     *
1333     * @param { number } pos - Indicates the target position to start data reading.
1334     * @throws { BusinessError } 401 - Parameter error. Possible causes:
1335     *     1.The number of parameters is incorrect;
1336     *     2.The parameter type does not match.
1337     * @syscap SystemCapability.Communication.IPC.Core
1338     * @since 9
1339     */
1340    rewindRead(pos: number): void;
1341
1342    /**
1343     * Changes the current write position in the {@link MessageSequence} object.
1344     * <p>Generally, you are advised not to change the current write position. If you must
1345     * change it, change it to an accurate position. Otherwise, the data to be read may be incorrect.
1346     *
1347     * @param { number } pos - Indicates the target position to start data writing.
1348     * @throws { BusinessError } 401 - Parameter error. Possible causes:
1349     *     1.The number of parameters is incorrect;
1350     *     2.The parameter type does not match.
1351     * @syscap SystemCapability.Communication.IPC.Core
1352     * @since 9
1353     */
1354    rewindWrite(pos: number): void;
1355
1356    /**
1357     * Writes information to this MessageSequence object indicating that no exception occurred.
1358     * <p>After handling requests, you should call this method before writing any data to reply
1359     * {@link MessageSequence}.
1360     *
1361     * @throws { BusinessError } 1900009 - Failed to write data to the message sequence.
1362     * @syscap SystemCapability.Communication.IPC.Core
1363     * @since 9
1364     */
1365    writeNoException(): void;
1366
1367    /**
1368     * Reads the exception information from this MessageSequence object.
1369     * <p>If exception was thrown in server side, it will be thrown here.
1370     * This method should be called before reading any data from reply {@link MessageSequence}
1371     * if {@link writeNoException} was invoked in server side.
1372     *
1373     * @throws { BusinessError } 1900010 - Failed to read data from the message sequence.
1374     * @syscap SystemCapability.Communication.IPC.Core
1375     * @since 9
1376     */
1377    readException(): void;
1378
1379    /**
1380     * Writes a byte value into the {@link MessageSequence} object.
1381     *
1382     * @param { number } val - Indicates the byte value to write.
1383     * @throws { BusinessError } 401 - Parameter error. Possible causes:
1384     *     1.The number of parameters is incorrect;
1385     *     2.The parameter type does not match.
1386     * @throws { BusinessError } 1900009 - Failed to write data to the message sequence.
1387     * @syscap SystemCapability.Communication.IPC.Core
1388     * @since 9
1389     */
1390    writeByte(val: number): void;
1391
1392    /**
1393     * Writes a short integer value into the {@link MessageSequence} object.
1394     *
1395     * @param { number } val - Indicates the short integer value to write.
1396     * @throws { BusinessError } 401 - Parameter error. Possible causes:
1397     *     1.The number of parameters is incorrect;
1398     *     2.The parameter type does not match.
1399     * @throws { BusinessError } 1900009 - Failed to write data to the message sequence.
1400     * @syscap SystemCapability.Communication.IPC.Core
1401     * @since 9
1402     */
1403    writeShort(val: number): void;
1404
1405    /**
1406     * Writes an integer value into the {@link MessageSequence} object.
1407     *
1408     * @param { number } val - Indicates the integer value to write.
1409     * @throws { BusinessError } 401 - Parameter error. Possible causes:
1410     *     1.The number of parameters is incorrect;
1411     *     2.The parameter type does not match.
1412     * @throws { BusinessError } 1900009 - Failed to write data to the message sequence.
1413     * @syscap SystemCapability.Communication.IPC.Core
1414     * @since 9
1415     */
1416    writeInt(val: number): void;
1417
1418    /**
1419     * Writes a long integer value into the {@link MessageSequence} object.
1420     *
1421     * @param { number } val - Indicates the long integer value to write.
1422     * @throws { BusinessError } 401 - Parameter error. Possible causes:
1423     *     1.The number of parameters is incorrect;
1424     *     2.The parameter type does not match.
1425     * @throws { BusinessError } 1900009 - Failed to write data to the message sequence.
1426     * @syscap SystemCapability.Communication.IPC.Core
1427     * @since 9
1428     */
1429    writeLong(val: number): void;
1430
1431    /**
1432     * Writes a floating point value into the {@link MessageSequence} object.
1433     *
1434     * @param { number } val - Indicates the floating point value to write.
1435     * @throws { BusinessError } 401 - Parameter error. Possible causes:
1436     *     1.The number of parameters is incorrect;
1437     *     2.The parameter type does not match.
1438     * @throws { BusinessError } 1900009 - Failed to write data to the message sequence.
1439     * @syscap SystemCapability.Communication.IPC.Core
1440     * @since 9
1441     */
1442    writeFloat(val: number): void;
1443
1444    /**
1445     * Writes a double-precision floating point value into the {@link MessageSequence} object.
1446     *
1447     * @param { number } val - Indicates the double-precision floating point value to write.
1448     * @throws { BusinessError } 401 - Parameter error. Possible causes:
1449     *     1.The number of parameters is incorrect;
1450     *     2.The parameter type does not match.
1451     * @throws { BusinessError } 1900009 - Failed to write data to the message sequence.
1452     * @syscap SystemCapability.Communication.IPC.Core
1453     * @since 9
1454     */
1455    writeDouble(val: number): void;
1456
1457    /**
1458     * Writes a boolean value into the {@link MessageSequence} object.
1459     *
1460     * @param { boolean } val - Indicates the boolean value to write.
1461     * @throws { BusinessError } 401 - Parameter error. Possible causes:
1462     *     1.The number of parameters is incorrect;
1463     *     2.The parameter type does not match.
1464     * @throws { BusinessError } 1900009 - Failed to write data to the message sequence.
1465     * @syscap SystemCapability.Communication.IPC.Core
1466     * @since 9
1467     */
1468    writeBoolean(val: boolean): void;
1469
1470    /**
1471     * Writes a single character value into the {@link MessageSequence} object.
1472     *
1473     * @param { number } val - Indicates the single character value to write.
1474     * @throws { BusinessError } 401 - Parameter error. Possible causes:
1475     *     1.The number of parameters is incorrect;
1476     *     2.The parameter type does not match.
1477     * @throws { BusinessError } 1900009 - Failed to write data to the message sequence.
1478     * @syscap SystemCapability.Communication.IPC.Core
1479     * @since 9
1480     */
1481    writeChar(val: number): void;
1482
1483    /**
1484     * Writes a string value into the {@link MessageSequence} object.
1485     *
1486     * @param { string } val - Indicates the string value to write.
1487     * @throws { BusinessError } 401 - Parameter error. Possible causes:
1488     *     1.The number of parameters is incorrect;
1489     *     2.The parameter type does not match;
1490     *     3.The string length exceeds 40960 bytes;
1491     *     4.The number of bytes copied to the buffer is different from the length of the obtained string.
1492     * @throws { BusinessError } 1900009 - Failed to write data to the message sequence.
1493     * @syscap SystemCapability.Communication.IPC.Core
1494     * @since 9
1495     */
1496    writeString(val: string): void;
1497
1498    /**
1499     * Writes a {@link Parcelable} object into the {@link MessageSequence} object.
1500     *
1501     * @param { Parcelable } val - Indicates the {@link Parcelable} object to write.
1502     * @throws { BusinessError } 401 - Parameter error. Possible causes:
1503     *     1.The number of parameters is incorrect;
1504     *     2.The parameter type does not match.
1505     * @throws { BusinessError } 1900009 - Failed to write data to the message sequence.
1506     * @syscap SystemCapability.Communication.IPC.Core
1507     * @since 9
1508     */
1509    writeParcelable(val: Parcelable): void;
1510
1511    /**
1512     * Writes a byte array into the {@link MessageSequence} object.
1513     *
1514     * @param { number[] } byteArray - Indicates the byte array to write.
1515     * @throws { BusinessError } 401 - Parameter error. Possible causes:
1516     *     1.The parameter is an empty array;
1517     *     2.The number of parameters is incorrect;
1518     *     3.The parameter type does not match;
1519     *     4.The element does not exist in the array.
1520     *     5.The type of the element in the array is incorrect.
1521     * @throws { BusinessError } 1900009 - Failed to write data to the message sequence.
1522     * @syscap SystemCapability.Communication.IPC.Core
1523     * @since 9
1524     */
1525    writeByteArray(byteArray: number[]): void;
1526
1527    /**
1528     * Writes a short integer array into the {@link MessageSequence} object.
1529     * Ensure that the data type and size comply with the interface definition.
1530     * Otherwise,data may be truncated.
1531     *
1532     * @param { number[] } shortArray - Indicates the short integer array to write.
1533     * @throws { BusinessError } 401 - Parameter error. Possible causes:
1534     *     1.The parameter is an empty array;
1535     *     2.The number of parameters is incorrect;
1536     *     3.The parameter type does not match;
1537     *     4.The element does not exist in the array;
1538     *     5.The type of the element in the array is incorrect.
1539     * @throws { BusinessError } 1900009 - Failed to write data to the message sequence.
1540     * @syscap SystemCapability.Communication.IPC.Core
1541     * @since 9
1542     */
1543    writeShortArray(shortArray: number[]): void;
1544
1545    /**
1546     * Writes an integer array into the {@link MessageSequence} object.
1547     * Ensure that the data type and size comply with the interface definition.
1548     * Otherwise,data may be truncated.
1549     *
1550     * @param { number[] } intArray - Indicates the integer array to write.
1551     * @throws { BusinessError } 401 - Parameter error. Possible causes:
1552     *     1.The parameter is an empty array;
1553     *     2.The number of parameters is incorrect;
1554     *     3.The parameter type does not match;
1555     *     4.The element does not exist in the array;
1556     *     5.The type of the element in the array is incorrect.
1557     * @throws { BusinessError } 1900009 - Failed to write data to the message sequence.
1558     * @syscap SystemCapability.Communication.IPC.Core
1559     * @since 9
1560     */
1561    writeIntArray(intArray: number[]): void;
1562
1563    /**
1564     * Writes a long integer array into the {@link MessageSequence} object.
1565     * Ensure that the data type and size comply with the interface definition.
1566     * Otherwise,data may be truncated.
1567     *
1568     * @param { number[] } longArray - Indicates the long integer array to write.
1569     * @throws { BusinessError } 401 - Parameter error. Possible causes:
1570     *     1.The parameter is an empty array;
1571     *     2.The number of parameters is incorrect;
1572     *     3.The parameter type does not match;
1573     *     4.The element does not exist in the array;
1574     *     5.The type of the element in the array is incorrect.
1575     * @throws { BusinessError } 1900009 - Failed to write data to the message sequence.
1576     * @syscap SystemCapability.Communication.IPC.Core
1577     * @since 9
1578     */
1579    writeLongArray(longArray: number[]): void;
1580
1581    /**
1582     * Writes a floating point array into the {@link MessageSequence} object.
1583     * Ensure that the data type and size comply with the interface definition.
1584     * Otherwise,data may be truncated.
1585     *
1586     * @param { number[] } floatArray - Indicates the floating point array to write.
1587     * @throws { BusinessError } 401 - Parameter error. Possible causes:
1588     *     1.The parameter is an empty array;
1589     *     2.The number of parameters is incorrect;
1590     *     3.The parameter type does not match;
1591     *     4.The element does not exist in the array;
1592     *     5.The type of the element in the array is incorrect.
1593     * @throws { BusinessError } 1900009 - Failed to write data to the message sequence.
1594     * @syscap SystemCapability.Communication.IPC.Core
1595     * @since 9
1596     */
1597    writeFloatArray(floatArray: number[]): void;
1598
1599    /**
1600     * Writes a double-precision floating point array into the {@link MessageSequence} object.
1601     * Ensure that the data type and size comply with the interface definition.
1602     * Otherwise,data may be truncated.
1603     *
1604     * @param { number[] } doubleArray - Indicates the double-precision floating point array to write.
1605     * @throws { BusinessError } 401 - Parameter error. Possible causes:
1606     *     1.The parameter is an empty array;
1607     *     2.The number of parameters is incorrect;
1608     *     3.The parameter type does not match;
1609     *     4.The element does not exist in the array;
1610     *     5.The type of the element in the array is incorrect.
1611     * @throws { BusinessError } 1900009 - Failed to write data to the message sequence.
1612     * @syscap SystemCapability.Communication.IPC.Core
1613     * @since 9
1614     */
1615    writeDoubleArray(doubleArray: number[]): void;
1616
1617    /**
1618     * Writes a boolean array into the {@link MessageSequence} object.
1619     * Ensure that the data type and size comply with the interface definition.
1620     * Otherwise,data may be truncated.
1621     *
1622     * @param { boolean[] } booleanArray - Indicates the boolean array to write.
1623     * @throws { BusinessError } 401 - Parameter error. Possible causes:
1624     *     1.The parameter is an empty array;
1625     *     2.The number of parameters is incorrect;
1626     *     3.The parameter type does not match;
1627     *     4.The element does not exist in the array.
1628     * @throws { BusinessError } 1900009 - Failed to write data to the message sequence.
1629     * @syscap SystemCapability.Communication.IPC.Core
1630     * @since 9
1631     */
1632    writeBooleanArray(booleanArray: boolean[]): void;
1633
1634    /**
1635     * Writes a single character array into the {@link MessageSequence} object.
1636     * Ensure that the data type and size comply with the interface definition.
1637     * Otherwise,data may be truncated.
1638     *
1639     * @param { number[] } charArray - Indicates the single character array to write.
1640     * @throws { BusinessError } 401 - Parameter error. Possible causes:
1641     *     1.The parameter is an empty array;
1642     *     2.The number of parameters is incorrect;
1643     *     3.The parameter type does not match;
1644     *     4.The element does not exist in the array.
1645     * @throws { BusinessError } 1900009 - Failed to write data to the message sequence.
1646     * @syscap SystemCapability.Communication.IPC.Core
1647     * @since 9
1648     */
1649    writeCharArray(charArray: number[]): void;
1650
1651    /**
1652     * Writes a string array into the {@link MessageSequence} object.
1653     * Ensure that the data type and size comply with the interface definition.
1654     * Otherwise,data may be truncated.
1655     *
1656     * @param { string[] } stringArray - Indicates the string array to write.
1657     * @throws { BusinessError } 401 - Parameter error. Possible causes:
1658     *     1.The parameter is an empty array;
1659     *     2.The number of parameters is incorrect;
1660     *     3.The parameter type does not match;
1661     *     4.The string length exceeds 40960 bytes;
1662     *     5.The number of bytes copied to the buffer is different from the length of the obtained string.
1663     * @throws { BusinessError } 1900009 - Failed to write data to the message sequence.
1664     * @syscap SystemCapability.Communication.IPC.Core
1665     * @since 9
1666     */
1667    writeStringArray(stringArray: string[]): void;
1668
1669    /**
1670     * Writes a {@link Parcelable} object array into the {@link MessageSequence} object.
1671     *
1672     * @param { Parcelable[] } parcelableArray - Indicates the {@link Parcelable} object array to write.
1673     * @throws { BusinessError } 401 - Parameter error. Possible causes:
1674     *     1.The parameter is an empty array;
1675     *     2.The number of parameters is incorrect;
1676     *     3.The parameter type does not match;
1677     *     4.The element does not exist in the array.
1678     * @throws { BusinessError } 1900009 - Failed to write data to the message sequence.
1679     * @syscap SystemCapability.Communication.IPC.Core
1680     * @since 9
1681     */
1682    writeParcelableArray(parcelableArray: Parcelable[]): void;
1683
1684    /**
1685     * Writes an array of {@link IRemoteObject} objects to this {@link MessageSequence} object.
1686     *
1687     * @param { IRemoteObject[] } objectArray - Array of {@link IRemoteObject} objects to write.
1688     * @throws { BusinessError } 401 - Parameter error. Possible causes:
1689     *     1.The parameter is an empty array;
1690     *     2.The number of parameters is incorrect;
1691     *     3.The parameter type does not match;
1692     *     4.The element does not exist in the array;
1693     *     5.The obtained remoteObject is null.
1694     * @throws { BusinessError } 1900009 - Failed to write data to the message sequence.
1695     * @syscap SystemCapability.Communication.IPC.Core
1696     * @since 9
1697     */
1698    writeRemoteObjectArray(objectArray: IRemoteObject[]): void;
1699
1700    /**
1701     * Reads a byte value from the {@link MessageParcel} object.
1702     *
1703     * @returns { number } Return a byte value.
1704     * @throws { BusinessError } 1900010 - Failed to read data from the message sequence.
1705     * @syscap SystemCapability.Communication.IPC.Core
1706     * @since 9
1707     */
1708    readByte(): number;
1709
1710    /**
1711     * Reads a short integer value from the {@link MessageSequence} object.
1712     *
1713     * @returns { number } Return a short integer value.
1714     * @throws { BusinessError } 1900010 - Failed to read data from the message sequence.
1715     * @syscap SystemCapability.Communication.IPC.Core
1716     * @since 9
1717     */
1718    readShort(): number;
1719
1720    /**
1721     * Reads an integer value from the {@link MessageSequence} object.
1722     *
1723     * @returns { number } Return an integer value.
1724     * @throws { BusinessError } 1900010 - Failed to read data from the message sequence.
1725     * @syscap SystemCapability.Communication.IPC.Core
1726     * @since 9
1727     */
1728    readInt(): number;
1729
1730    /**
1731     * Reads a long integer value from the {@link MessageSequence} object.
1732     *
1733     * @returns { number } Return a long integer value.
1734     * @throws { BusinessError } 1900010 - Failed to read data from the message sequence.
1735     * @syscap SystemCapability.Communication.IPC.Core
1736     * @since 9
1737     */
1738    readLong(): number;
1739
1740    /**
1741     * Reads a floating point value from the {@link MessageSequence} object.
1742     *
1743     * @returns { number } Return a floating point value.
1744     * @throws { BusinessError } 1900010 - Failed to read data from the message sequence.
1745     * @syscap SystemCapability.Communication.IPC.Core
1746     * @since 9
1747     */
1748    readFloat(): number;
1749
1750    /**
1751     * Reads a double-precision floating point value from the {@link MessageSequence} object.
1752     *
1753     * @returns { number } Return a double-precision floating point value.
1754     * @throws { BusinessError } 1900010 - Failed to read data from the message sequence.
1755     * @syscap SystemCapability.Communication.IPC.Core
1756     * @since 9
1757     */
1758    readDouble(): number;
1759
1760    /**
1761     * Reads a boolean value from the {@link MessageSequence} object.
1762     *
1763     * @returns { boolean } Return a boolean value.
1764     * @throws { BusinessError } 1900010 - Failed to read data from the message sequence.
1765     * @syscap SystemCapability.Communication.IPC.Core
1766     * @since 9
1767     */
1768    readBoolean(): boolean;
1769
1770    /**
1771     * Reads a single character value from the {@link MessageSequence} object.
1772     *
1773     * @returns { number } Return a single character value.
1774     * @throws { BusinessError } 1900010 - Failed to read data from the message sequence.
1775     * @syscap SystemCapability.Communication.IPC.Core
1776     * @since 9
1777     */
1778    readChar(): number;
1779
1780    /**
1781     * Reads a string value from the {@link MessageSequence} object.
1782     *
1783     * @returns { string } Return a string value.
1784     * @throws { BusinessError } 1900010 - Failed to read data from the message sequence.
1785     * @syscap SystemCapability.Communication.IPC.Core
1786     * @since 9
1787     */
1788    readString(): string;
1789
1790    /**
1791     * Reads a {@link Parcelable} object from the {@link MessageSequence} instance.
1792     *
1793     * @param { Parcelable } dataIn - Indicates the {@link Parcelable} object that needs to perform
1794     *                       the {@code unmarshalling} operation using the {@link MessageSequence}.
1795     * @throws { BusinessError } 401 - Parameter error. Possible causes:
1796     *     1.The number of parameters is incorrect.
1797     * @throws { BusinessError } 1900010 - Failed to read data from the message sequence.
1798     * @throws { BusinessError } 1900012 - Failed to call the JS callback function.
1799     * @syscap SystemCapability.Communication.IPC.Core
1800     * @since 9
1801     */
1802    readParcelable(dataIn: Parcelable): void;
1803
1804    /**
1805     * Writes a byte array into the {@link MessageSequence} object.
1806     *
1807     * @param { number[] } dataIn - Indicates the byte array read from MessageSequence.
1808     * @throws { BusinessError } 401 - Parameter error. Possible causes:
1809     *     1.The parameter is an empty array;
1810     *     2.The number of parameters is incorrect;
1811     *     3.The parameter type does not match.
1812     * @throws { BusinessError } 1900010 - Failed to read data from the message sequence.
1813     * @syscap SystemCapability.Communication.IPC.Core
1814     * @since 9
1815     */
1816    readByteArray(dataIn: number[]): void;
1817
1818    /**
1819     * Reads a byte array from the {@link MessageSequence} object.
1820     *
1821     * @returns { number[] } Return a byte array.
1822     * @throws { BusinessError } 401 - check param failed
1823     * @throws { BusinessError } 1900010 - Failed to read data from the message sequence.
1824     * @syscap SystemCapability.Communication.IPC.Core
1825     * @since 9
1826     */
1827    readByteArray(): number[];
1828
1829    /**
1830     * Reads a short integer array from the {@link MessageSequence} object.
1831     *
1832     * @param { number[] } dataIn - Indicates the short integer array read from MessageSequence.
1833     * @throws { BusinessError } 401 - Parameter error. Possible causes:
1834     *     1.The parameter is an empty array;
1835     *     2.The number of parameters is incorrect;
1836     *     3.The parameter type does not match.
1837     * @throws { BusinessError } 1900010 - Failed to read data from the message sequence.
1838     * @syscap SystemCapability.Communication.IPC.Core
1839     * @since 9
1840     */
1841    readShortArray(dataIn: number[]): void;
1842
1843    /**
1844     * Reads a short integer array from the {@link MessageSequence} object.
1845     *
1846     * @returns { number[] } Return a short integer array.
1847     * @throws { BusinessError } 1900010 - Failed to read data from the message sequence.
1848     * @syscap SystemCapability.Communication.IPC.Core
1849     * @since 9
1850     */
1851    readShortArray(): number[];
1852
1853    /**
1854     * Reads an integer array from the {@link MessageSequence} object.
1855     *
1856     * @param { number[] } dataIn - Indicates the integer array to read.
1857     * @throws { BusinessError } 401 - Parameter error. Possible causes:
1858     *     1.The parameter is an empty array;
1859     *     2.The number of parameters is incorrect;
1860     *     3.The parameter type does not match.
1861     * @throws { BusinessError } 1900010 - Failed to read data from the message sequence.
1862     * @syscap SystemCapability.Communication.IPC.Core
1863     * @since 9
1864     */
1865    readIntArray(dataIn: number[]): void;
1866
1867    /**
1868     * Reads an integer array from the {@link MessageSequence} object.
1869     *
1870     * @returns { number[] } Return an integer array.
1871     * @throws { BusinessError } 1900010 - Failed to read data from the message sequence.
1872     * @syscap SystemCapability.Communication.IPC.Core
1873     * @since 9
1874     */
1875    readIntArray(): number[];
1876
1877    /**
1878     * Reads a long integer array from the {@link MessageSequence} object.
1879     *
1880     * @param { number[] } dataIn - Indicates the long integer array to read.
1881     * @throws { BusinessError } 401 - Parameter error. Possible causes:
1882     *     1.The parameter is an empty array;
1883     *     2.The number of parameters is incorrect;
1884     *     3.The parameter type does not match.
1885     * @throws { BusinessError } 1900010 - Failed to read data from the message sequence.
1886     * @syscap SystemCapability.Communication.IPC.Core
1887     * @since 9
1888     */
1889    readLongArray(dataIn: number[]): void;
1890
1891    /**
1892     * Reads a long integer array from the {@link MessageSequence} object.
1893     *
1894     * @returns { number[] } Return a long integer array.
1895     * @throws { BusinessError } 1900010 - Failed to read data from the message sequence.
1896     * @syscap SystemCapability.Communication.IPC.Core
1897     * @since 9
1898     */
1899    readLongArray(): number[];
1900
1901    /**
1902     * Reads a floating point array from the {@link MessageSequence} object.
1903     *
1904     * @param { number[] } dataIn - Indicates the floating point array to read.
1905     * @throws { BusinessError } 401 - Parameter error. Possible causes:
1906     *     1.The parameter is an empty array;
1907     *     2.The number of parameters is incorrect;
1908     *     3.The parameter type does not match.
1909     * @throws { BusinessError } 1900010 - Failed to read data from the message sequence.
1910     * @syscap SystemCapability.Communication.IPC.Core
1911     * @since 9
1912     */
1913    readFloatArray(dataIn: number[]): void;
1914
1915    /**
1916     * Reads a floating point array from the {@link MessageSequence} object.
1917     *
1918     * @returns { number[] } Return a floating point array.
1919     * @throws { BusinessError } 1900010 - Failed to read data from the message sequence.
1920     * @syscap SystemCapability.Communication.IPC.Core
1921     * @since 9
1922     */
1923    readFloatArray(): number[];
1924
1925    /**
1926     * Reads a double-precision floating point array from the {@link MessageSequence} object.
1927     *
1928     * @param { number[] } dataIn - Indicates the double-precision floating point array to read.
1929     * @throws { BusinessError } 401 - Parameter error. Possible causes:
1930     *     1.The parameter is an empty array;
1931     *     2.The number of parameters is incorrect;
1932     *     3.The parameter type does not match.
1933     * @throws { BusinessError } 1900010 - Failed to read data from the message sequence.
1934     * @syscap SystemCapability.Communication.IPC.Core
1935     * @since 9
1936     */
1937    readDoubleArray(dataIn: number[]): void;
1938
1939    /**
1940     * Reads a double-precision floating point array from the {@link MessageSequence} object.
1941     *
1942     * @returns { number[] } Return a double-precision floating point array.
1943     * @throws { BusinessError } 1900010 - Failed to read data from the message sequence.
1944     * @syscap SystemCapability.Communication.IPC.Core
1945     * @since 9
1946     */
1947    readDoubleArray(): number[];
1948
1949    /**
1950     * Reads a boolean array from the {@link MessageSequence} object.
1951     *
1952     * @param { boolean[] } dataIn - Indicates the boolean array to read.
1953     * @throws { BusinessError } 401 - Parameter error. Possible causes:
1954     *     1.The parameter is an empty array;
1955     *     2.The number of parameters is incorrect;
1956     *     3.The parameter type does not match.
1957     * @throws { BusinessError } 1900010 - Failed to read data from the message sequence.
1958     * @syscap SystemCapability.Communication.IPC.Core
1959     * @since 9
1960     */
1961    readBooleanArray(dataIn: boolean[]): void;
1962
1963    /**
1964     * Reads a boolean array from the {@link MessageSequence} object.
1965     *
1966     * @returns { boolean[] } Return a boolean array.
1967     * @throws { BusinessError } 1900010 - Failed to read data from the message sequence.
1968     * @syscap SystemCapability.Communication.IPC.Core
1969     * @since 9
1970     */
1971    readBooleanArray(): boolean[];
1972
1973    /**
1974     * Reads a single character array from the {@link MessageSequence} object.
1975     *
1976     * @param { number[] } dataIn - Indicates the single character array to read.
1977     * @throws { BusinessError } 401 - Parameter error. Possible causes:
1978     *     1.The parameter is an empty array;
1979     *     2.The number of parameters is incorrect;
1980     *     3.The parameter type does not match.
1981     * @throws { BusinessError } 1900010 - Failed to read data from the message sequence.
1982     * @syscap SystemCapability.Communication.IPC.Core
1983     * @since 9
1984     */
1985    readCharArray(dataIn: number[]): void;
1986
1987    /**
1988     * Reads a single character array from the {@link MessageSequence} object.
1989     *
1990     * @returns { number[] } Return a single character array.
1991     * @throws { BusinessError } 1900010 - Failed to read data from the message sequence.
1992     * @syscap SystemCapability.Communication.IPC.Core
1993     * @since 9
1994     */
1995    readCharArray(): number[];
1996
1997    /**
1998     * Reads a string array from the {@link MessageSequence} object.
1999     *
2000     * @param { string[] } dataIn - Indicates the string array to read.
2001     * @throws { BusinessError } 401 - Parameter error. Possible causes:
2002     *     1.The parameter is an empty array;
2003     *     2.The number of parameters is incorrect;
2004     *     3.The parameter type does not match.
2005     * @throws { BusinessError } 1900010 - Failed to read data from the message sequence.
2006     * @syscap SystemCapability.Communication.IPC.Core
2007     * @since 9
2008     */
2009    readStringArray(dataIn: string[]): void;
2010
2011    /**
2012     * Reads a string array from the {@link MessageSequence} object.
2013     *
2014     * @returns { string[] } Return a string array.
2015     * @throws { BusinessError } 1900010 - Failed to read data from the message sequence.
2016     * @syscap SystemCapability.Communication.IPC.Core
2017     * @since 9
2018     */
2019    readStringArray(): string[];
2020
2021    /**
2022     * Reads the specified {@link Parcelable} array from this {@link MessageSequence} object.
2023     *
2024     * @param { Parcelable[] } parcelableArray - Parcelable array to read.
2025     * @throws { BusinessError } 401 - Parameter error. Possible causes:
2026     *     1.The parameter is an empty array;
2027     *     2.The number of parameters is incorrect;
2028     *     3.The parameter type does not match;
2029     *     4.The length of the array passed when reading is not equal to the length passed when writing to the array;
2030     *     5.The element does not exist in the array.
2031     * @throws { BusinessError } 1900010 - Failed to read data from the message sequence.
2032     * @throws { BusinessError } 1900012 - Failed to call the JS callback function.
2033     * @syscap SystemCapability.Communication.IPC.Core
2034     * @since 9
2035     */
2036    readParcelableArray(parcelableArray: Parcelable[]): void;
2037
2038    /**
2039     * Reads the specified {@link IRemoteObject} array from this {@link MessageSequence} object.
2040     *
2041     * @param { IRemoteObject[] } objects - Reads data from this {@link MessageSequence} object to
2042     *                            the specified {@link IRemoteObject} array.
2043     * @throws { BusinessError } 401 - Parameter error. Possible causes:
2044     *     1.The parameter is an empty array;
2045     *     2.The number of parameters is incorrect;
2046     *     3.The parameter type does not match;
2047     *     4.The length of the array passed when reading is not equal to the length passed when writing to the array.
2048     * @throws { BusinessError } 1900010 - Failed to read data from the message sequence.
2049     * @syscap SystemCapability.Communication.IPC.Core
2050     * @since 9
2051     */
2052    readRemoteObjectArray(objects: IRemoteObject[]): void;
2053
2054    /**
2055     * Reads {@link IRemoteObject} objects from this {@link MessageSequence} object.
2056     *
2057     * @returns { IRemoteObject[] } Return an array of {@link IRemoteObject} objects obtained.
2058     * @throws { BusinessError } 1900010 - Failed to read data from the message sequence.
2059     * @syscap SystemCapability.Communication.IPC.Core
2060     * @since 9
2061     */
2062    readRemoteObjectArray(): IRemoteObject[];
2063
2064    /**
2065     * Closes the specified file descriptor.
2066     *
2067     * @param { number } fd - File descriptor to be closed.
2068     * @throws { BusinessError } 401 - Parameter error. Possible causes:
2069     *     1.The number of parameters is incorrect;
2070     *     2.The parameter type does not match.
2071     * @syscap SystemCapability.Communication.IPC.Core
2072     * @since 9
2073     */
2074    static closeFileDescriptor(fd: number): void;
2075
2076    /**
2077     * Duplicates the specified file descriptor.
2078     *
2079     * @param { number } fd - File descriptor to be duplicated.
2080     * @returns { number } Return a duplicated file descriptor.
2081     * @throws { BusinessError } 401 - Parameter error. Possible causes:
2082     *     1.The number of parameters is incorrect;
2083     *     2.The parameter type does not match.
2084     * @throws { BusinessError } 1900013 - Failed to call dup.
2085     * @syscap SystemCapability.Communication.IPC.Core
2086     * @since 9
2087     */
2088    static dupFileDescriptor(fd: number): number;
2089
2090    /**
2091     * Checks whether this {@link MessageSequence} object contains a file descriptor.
2092     *
2093     * @returns { boolean } Return {@code true} if the {@link MessageSequence} object contains a file descriptor;
2094     *                      return {@code false} otherwise.
2095     * @syscap SystemCapability.Communication.IPC.Core
2096     * @since 9
2097     */
2098    containFileDescriptors(): boolean;
2099
2100    /**
2101     * Writes a file descriptor to this {@link MessageSequence} object.
2102     *
2103     * @param { number } fd - File descriptor to wrote.
2104     * @throws { BusinessError } 401 - Parameter error. Possible causes:
2105     *     1.The number of parameters is incorrect;
2106     *     2.The parameter type does not match.
2107     * @throws { BusinessError } 1900009 - Failed to write data to the message sequence.
2108     * @syscap SystemCapability.Communication.IPC.Core
2109     * @since 9
2110     */
2111    writeFileDescriptor(fd: number): void;
2112
2113    /**
2114     * Reads a file descriptor from this {@link MessageSequence} object.
2115     *
2116     * @returns { number } Return a file descriptor obtained.
2117     * @throws { BusinessError } 1900010 - Failed to read data from the message sequence.
2118     * @syscap SystemCapability.Communication.IPC.Core
2119     * @since 9
2120     */
2121    readFileDescriptor(): number;
2122
2123    /**
2124     * Writes an anonymous shared memory object to this {@link MessageSequence} object.
2125     *
2126     * @param { Ashmem } ashmem - Anonymous shared memory object to wrote.
2127     * @throws { BusinessError } 401 - Parameter error. Possible causes:
2128     *     1.The number of parameters is incorrect;
2129     *     2.The parameter is not an instance of the Ashmem object.
2130     * @throws { BusinessError } 1900003 - Failed to write data to the shared memory.
2131     * @syscap SystemCapability.Communication.IPC.Core
2132     * @since 9
2133     */
2134    writeAshmem(ashmem: Ashmem): void;
2135
2136    /**
2137     * Reads the anonymous shared memory object from this {@link MessageSequence} object.
2138     *
2139     * @returns { Ashmem } Return the anonymous share object obtained.
2140     * @throws { BusinessError } 401 - check param failed
2141     * @throws { BusinessError } 1900004 - Failed to read data from the shared memory.
2142     * @syscap SystemCapability.Communication.IPC.Core
2143     * @since 9
2144     */
2145    readAshmem(): Ashmem;
2146
2147    /**
2148     * Obtains the maximum amount of raw data that can be sent in a time.
2149     *
2150     * @returns { number } 128 MB.
2151     * @syscap SystemCapability.Communication.IPC.Core
2152     * @since 9
2153     */
2154    getRawDataCapacity(): number;
2155
2156    /**
2157     * Writes raw data to this {@link MessageSequence} object.
2158     *
2159     * @param { number[] } rawData - Raw data to wrote.
2160     * @param { number } size - Size of the raw data, in bytes.
2161     * @throws { BusinessError } 401 - Parameter error. Possible causes:
2162     *     1.The parameter is an empty array;
2163     *     2.The number of parameters is incorrect;
2164     *     3.The parameter type does not match;
2165     *     4.The transferred size cannot be obtained;
2166     *     5.The transferred size is less than or equal to 0;
2167     *     6.The element does not exist in the array;
2168     *     7.Failed to obtain typedArray information;
2169     *     8.The array is not of type int32;
2170     *     9.The length of typedarray is smaller than the size of the original data sent.
2171     * @throws { BusinessError } 1900009 - Failed to write data to the message sequence.
2172     * @syscap SystemCapability.Communication.IPC.Core
2173     * @since 9
2174     * @deprecated since 11
2175     * @useinstead ohos.rpc.MessageSequence#writeRawDataBuffer
2176     */
2177    writeRawData(rawData: number[], size: number): void;
2178
2179    /**
2180     * Writes raw data to this {@link MessageSequence} object.
2181     *
2182     * @param { ArrayBuffer } rawData - Raw data to wrote.
2183     * @param { number } size - Size of the raw data, in bytes.
2184     * @throws { BusinessError } 401 - Parameter error. Possible causes:
2185     *     1.The number of parameters is incorrect;
2186     *     2.The parameter type does not match;
2187     *     3.Failed to obtain arrayBuffer information;
2188     *     4.The transferred size cannot be obtained;
2189     *     5.The transferred size is less than or equal to 0;
2190     *     6.The transferred size is greater than the byte length of ArrayBuffer.
2191     * @throws { BusinessError } 1900009 - Failed to write data to the message sequence.
2192     * @syscap SystemCapability.Communication.IPC.Core
2193     * @since 11
2194     */
2195    writeRawDataBuffer(rawData: ArrayBuffer, size: number): void;
2196
2197    /**
2198     * Reads raw data from this {@link MessageSequence} object.
2199     *
2200     * @param { number } size - Size of the raw data to read.
2201     * @returns { number[] } Return the raw data obtained, in bytes.
2202     * @throws { BusinessError } 401 - Parameter error. Possible causes:
2203     *     1.The number of parameters is incorrect;
2204     *     2.The parameter type does not match.
2205     * @throws { BusinessError } 1900010 - Failed to read data from the message sequence.
2206     * @syscap SystemCapability.Communication.IPC.Core
2207     * @since 9
2208     * @deprecated since 11
2209     * @useinstead ohos.rpc.MessageSequence#readRawDataBuffer
2210     */
2211    readRawData(size: number): number[];
2212
2213    /**
2214     * Reads raw data from this {@link MessageSequence} object.
2215     *
2216     * @param { number } size - Size of the raw data to read.
2217     * @returns { ArrayBuffer } Return the raw data obtained, in bytes.
2218     * @throws { BusinessError } 401 - Parameter error. Possible causes:
2219     *     1.The number of parameters is incorrect;
2220     *     2.The parameter type does not match.
2221     * @throws { BusinessError } 1900010 - Failed to read data from the message sequence.
2222     * @syscap SystemCapability.Communication.IPC.Core
2223     * @since 11
2224     */
2225    readRawDataBuffer(size: number): ArrayBuffer;
2226
2227    /**
2228     * Writes the data in an ArrayBuffer object into this {@Link MessageSequence} object.
2229     *
2230     * @param { ArrayBuffer } buf - Data to write.
2231     * @param { TypeCode } typeCode - Type of the ArrayBuffer data to write.
2232     * @throws { BusinessError } 401 - Parameter error. Possible causes:
2233     *     1.The parameter is an empty array;
2234     *     2.The number of parameters is incorrect;
2235     *     3.The parameter type does not match;
2236     *     4.The obtained value of typeCode is incorrect;
2237     *     5.Failed to obtain arrayBuffer information.
2238     * @throws { BusinessError } 1900009 - Failed to write data to the message sequence.
2239     * @syscap SystemCapability.Communication.IPC.Core
2240     * @since 12
2241     */
2242    writeArrayBuffer(buf: ArrayBuffer, typeCode: TypeCode): void;
2243
2244    /**
2245     * Reads raw data from this {@link MessageSequence} object.
2246     *
2247     * @param { TypeCode } typeCode - Type of the ArrayBuffer read.
2248     * @returns { ArrayBuffer } Returns the Arraybuffer obtained.
2249     * @throws { BusinessError } 401 - Parameter error. Possible causes:
2250     *     1.The number of parameters is incorrect;
2251     *     2.The parameter type does not match;
2252     *     3.The obtained value of typeCode is incorrect;
2253     * @throws { BusinessError } 1900010 - Failed to read data from the message sequence.
2254     * @syscap SystemCapability.Communication.IPC.Core
2255     * @since 12
2256     */
2257    readArrayBuffer(typeCode: TypeCode): ArrayBuffer;
2258  }
2259
2260  /**
2261   * @typedef Sequenceable
2262   * @syscap SystemCapability.Communication.IPC.Core
2263   * @since 7
2264   * @deprecated since 9
2265   * @useinstead ohos.rpc.Parcelable
2266   */
2267  interface Sequenceable {
2268    /**
2269     * Marshal this {@code Sequenceable} object into a {@link MessageParcel}.
2270     *
2271     * @param { MessageParcel } dataOut - Indicates the {@link MessageParcel} object to which the {@code Sequenceable}
2272     *                          object will be marshalled.
2273     * @returns { boolean } Return {@code true} if the marshalling is successful; return {@code false} otherwise.
2274     * @syscap SystemCapability.Communication.IPC.Core
2275     * @since 7
2276     * @deprecated since 9
2277     */
2278    marshalling(dataOut: MessageParcel): boolean;
2279
2280    /**
2281     * Unmarshal this {@code Sequenceable} object from a {@link MessageParcel}.
2282     *
2283     * @param { MessageParcel } dataIn - Indicates the {@link MessageParcel} object into which the {@code Sequenceable}
2284     *                          object has been marshalled.
2285     * @returns { boolean } Return {@code true} if the unmarshalling is successful; return {@code false} otherwise.
2286     * @syscap SystemCapability.Communication.IPC.Core
2287     * @since 7
2288     * @deprecated since 9
2289     */
2290    unmarshalling(dataIn: MessageParcel): boolean;
2291  }
2292
2293  /**
2294   * @typedef Parcelable
2295   * @syscap SystemCapability.Communication.IPC.Core
2296   * @since 9
2297   */
2298  /**
2299   * During inter-process communication, objects of the class are written to the {@link MessageSequence} and
2300   * they are recovered from the {@link MessageSequence}.
2301   *
2302   * @typedef Parcelable
2303   * @syscap SystemCapability.Communication.IPC.Core
2304   * @since 11
2305   */
2306  interface Parcelable {
2307    /**
2308     * Marshal this {@code Parcelable} object into a {@link MessageSequence}.
2309     *
2310     * @param { MessageSequence } dataOut - Indicates the {@link MessageSequence} object to which the {@code Parcelable}
2311     *                            object will be marshalled.
2312     * @returns { boolean } Return {@code true} if the marshalling is successful; return {@code false} otherwise.
2313     * @syscap SystemCapability.Communication.IPC.Core
2314     * @since 9
2315     */
2316    marshalling(dataOut: MessageSequence): boolean;
2317
2318    /**
2319     * Unmarshal this {@code Parcelable} object from a {@link MessageSequence}.
2320     *
2321     * @param { MessageSequence } dataIn - Indicates the {@link MessageSequence} object into
2322     *                            which the {@code Parcelable} object has been marshalled.
2323     * @returns { boolean } Return {@code true} if the unmarshalling is successful; return {@code false} otherwise.
2324     * @syscap SystemCapability.Communication.IPC.Core
2325     * @since 9
2326     */
2327    unmarshalling(dataIn: MessageSequence): boolean;
2328  }
2329
2330  /**
2331   * Defines the response to the request.
2332   * <p> SendRequestResult object contains four members, namely error code of this operation, request code, data parcel
2333   * and reply parcel.
2334   *
2335   * @typedef SendRequestResult
2336   * @syscap SystemCapability.Communication.IPC.Core
2337   * @since 8
2338   * @deprecated since 9
2339   * @useinstead ohos.rpc.RequestResult
2340   */
2341  interface SendRequestResult {
2342    /**
2343     * Error code. 0 indicates successful, otherwise it is failed.
2344     *
2345     * @type { number }
2346     * @syscap SystemCapability.Communication.IPC.Core
2347     * @since 8
2348     * @deprecated since 9
2349     */
2350    errCode: number;
2351
2352    /**
2353     * Message code. It is same as the code in {@link SendRequest} method.
2354     *
2355     * @type { number }
2356     * @syscap SystemCapability.Communication.IPC.Core
2357     * @since 8
2358     * @deprecated since 9
2359     */
2360    code: number;
2361
2362    /**
2363     * MessageParcel object sent to the peer process.
2364     * It is the same object in {@link SendRequest} method.
2365     *
2366     * @type { MessageParcel }
2367     * @syscap SystemCapability.Communication.IPC.Core
2368     * @since 8
2369     * @deprecated since 9
2370     */
2371    data: MessageParcel;
2372
2373    /**
2374     * MessageParcel object returned by the peer process.
2375     * It is the same object in {@link SendRequest} method.
2376     *
2377     * @type { MessageParcel }
2378     * @syscap SystemCapability.Communication.IPC.Core
2379     * @since 8
2380     * @deprecated since 9
2381     */
2382    reply: MessageParcel;
2383  }
2384
2385  /**
2386   * Defines the response to the request.
2387   * <p> SendRequestResult object contains four members, namely error code of this operation, request code, data parcel
2388   * and reply parcel.
2389   *
2390   * @typedef RequestResult
2391   * @syscap SystemCapability.Communication.IPC.Core
2392   * @since 9
2393   */
2394  interface RequestResult {
2395    /**
2396     * Error code. 0 indicates successful, otherwise it is failed.
2397     *
2398     * @type { number }
2399     * @syscap SystemCapability.Communication.IPC.Core
2400     * @since 9
2401     */
2402    errCode: number;
2403
2404    /**
2405     * Message code. It is same as the code in {@link SendRequest} method.
2406     *
2407     * @type { number }
2408     * @syscap SystemCapability.Communication.IPC.Core
2409     * @since 9
2410     */
2411    code: number;
2412
2413    /**
2414     * MessageSequence object sent to the peer process.
2415     * It is the same object in {@link SendRequest} method.
2416     *
2417     * @type { MessageSequence }
2418     * @syscap SystemCapability.Communication.IPC.Core
2419     * @since 9
2420     */
2421    data: MessageSequence;
2422
2423    /**
2424     * MessageSequence object returned by the peer process.
2425     * It is the same object in {@link SendRequest} method.
2426     *
2427     * @type { MessageSequence }
2428     * @syscap SystemCapability.Communication.IPC.Core
2429     * @since 9
2430     */
2431    reply: MessageSequence;
2432  }
2433
2434  /**
2435   * @syscap SystemCapability.Communication.IPC.Core
2436   * @since 7
2437   */
2438  /**
2439   * Used to query or get interface descriptors, add or remove death notifications, dump object status to
2440   * a specific file, and send messages.
2441   *
2442   * @syscap SystemCapability.Communication.IPC.Core
2443   * @since 11
2444   */
2445  abstract class IRemoteObject {
2446    /**
2447     * Queries the description of an interface.
2448     * <p>A valid {@link IRemoteBroker} object is returned for an interface used by the service provider;
2449     * {@code null} is returned for an interface used by the service user,
2450     * indicating that the interface is not a local one.
2451     *
2452     * @param { string } descriptor - Indicates the interface descriptor.
2453     * @returns { IRemoteBroker } Return the {@link IRemoteBroker} object bound to the specified interface descriptor.
2454     * @syscap SystemCapability.Communication.IPC.Core
2455     * @since 7
2456     * @deprecated since 9
2457     * @useinstead ohos.rpc.IRemoteObject#getLocalInterface
2458     */
2459    queryLocalInterface(descriptor: string): IRemoteBroker;
2460
2461    /**
2462     * Queries the description of an interface.
2463     * <p>A valid {@link IRemoteBroker} object is returned for an interface used by the service provider;
2464     * {@code null} is returned for an interface used by the service user,
2465     * indicating that the interface is not a local one.
2466     *
2467     * @param { string } descriptor - Indicates the interface descriptor.
2468     * @returns { IRemoteBroker } Return the {@link IRemoteBroker} object bound to the specified interface descriptor.
2469     * @throws { BusinessError } 401 - Parameter error. Possible causes:
2470     *     1.The number of parameters is incorrect;
2471     *     2.The parameter type does not match;
2472     *     3.The string length exceeds 40960 bytes;
2473     *     4.The number of bytes copied to the buffer is different from the length of the obtained string.
2474     * @syscap SystemCapability.Communication.IPC.Core
2475     * @since 9
2476     */
2477    getLocalInterface(descriptor: string): IRemoteBroker;
2478
2479    /**
2480     * Sends a {@link MessageParcel} message to the peer process in synchronous or asynchronous mode.
2481     * <p>If asynchronous mode is set for {@code option}, a response is returned immediately.
2482     * If synchronous mode is set for {@code option}, the interface will wait for a response from the peer process
2483     * until the request times out. The user must prepare {@code reply} for receiving the execution result
2484     * given by the peer process.
2485     *
2486     * @param { number } code - Indicates the message code, which is determined by both sides of the communication.
2487     * If the interface is generated by the IDL tool, the message code is automatically generated by IDL.
2488     * @param { MessageParcel } data - Indicates the {@link MessageParcel} object sent to the peer process.
2489     * @param { MessageParcel } reply - Indicates the {@link MessageParcel} object returned by the peer process.
2490     * @param { MessageOption } options - Indicates the synchronous or asynchronous mode to send messages.
2491     * @returns { boolean } Return {@code true} if the method is called successfully; return {@code false} otherwise.
2492     * @syscap SystemCapability.Communication.IPC.Core
2493     * @since 7
2494     * @deprecated since 9
2495     */
2496    sendRequest(code: number, data: MessageParcel, reply: MessageParcel, options: MessageOption): boolean;
2497
2498    /**
2499     * Sends a {@link MessageParcel} message to the peer process in synchronous or asynchronous mode.
2500     * <p>If options indicates the asynchronous mode, a promise will be fulfilled immediately
2501     * and the reply message does not contain any content. If options indicates the synchronous mode,
2502     * a promise will be fulfilled when the response to sendRequest is returned,
2503     * and the reply message contains the returned information.
2504     *
2505     * @param { number } code - Message code called by the request, which is determined by the client and server.
2506     * If the method is generated by an IDL tool, the message code is automatically generated by the IDL tool.
2507     * @param { MessageParcel } data - {@link MessageParcel} object holding the data to send.
2508     * @param { MessageParcel } reply - {@link MessageParcel} object that receives the response.
2509     * @param { MessageOption } options - Indicates the synchronous or asynchronous mode to send messages.
2510     * @returns { Promise<SendRequestResult> } Promise used to return the {@link SendRequestResult} instance.
2511     * @syscap SystemCapability.Communication.IPC.Core
2512     * @since 8
2513     * @deprecated since 9
2514     * @useinstead ohos.rpc.IRemoteObject#sendMessageRequest
2515     */
2516    sendRequest(
2517      code: number,
2518      data: MessageParcel,
2519      reply: MessageParcel,
2520      options: MessageOption
2521    ): Promise<SendRequestResult>;
2522
2523    /**
2524     * Sends a {@link MessageSequence} message to the peer process asynchronously.
2525     * <p>If options indicates the asynchronous mode, a promise will be fulfilled immediately
2526     * and the reply message does not contain any content. If options indicates the synchronous mode,
2527     * a promise will be fulfilled when the response to sendMessageRequest is returned,
2528     * and the reply message contains the returned information.
2529     *
2530     * @param { number } code - Message code called by the request, which is determined by the client and server.
2531     * If the method is generated by an IDL tool, the message code is automatically generated by the IDL tool.
2532     * @param {MessageSequence } data - {@link MessageSequence} object holding the data to send.
2533     * @param {MessageSequence } reply - {@link MessageSequence} object that receives the response.
2534     * @param { MessageOption } options - Indicates the synchronous or asynchronous mode to send messages.
2535     * @returns { Promise<RequestResult> } Promise used to return the {@link RequestResult} instance.
2536     * @throws { BusinessError } 401 - Parameter error. Possible causes:
2537     *     1.The number of parameters is incorrect;
2538     *     2.The parameter type does not match;
2539     *     3.Failed to obtain the passed object instance.
2540     * @syscap SystemCapability.Communication.IPC.Core
2541     * @since 9
2542     */
2543    sendMessageRequest(
2544      code: number,
2545      data: MessageSequence,
2546      reply: MessageSequence,
2547      options: MessageOption
2548    ): Promise<RequestResult>;
2549
2550    /**
2551     * Sends a {@link MessageParcel} message to the peer process in synchronous or asynchronous mode.
2552     * <p>If options indicates the asynchronous mode, a callback will be invoked immediately
2553     * and the reply message does not contain any content. If options indicates the synchronous mode,
2554     * a callback will be invoked when the response to sendRequest is returned,
2555     * and the reply message contains the returned information.
2556     *
2557     * @param { number } code - Message code called by the request, which is determined by the client and server.
2558     * If the method is generated by an IDL tool, the message code is automatically generated by the IDL tool.
2559     * @param { MessageParcel } data - {@link MessageParcel} object holding the data to send.
2560     * @param { MessageParcel } reply - {@link MessageParcel} object that receives the response.
2561     * @param { MessageOption } options - Indicates the synchronous or asynchronous mode to send messages.
2562     * @param { AsyncCallback<SendRequestResult> } callback - Callback for receiving the sending result.
2563     * @syscap SystemCapability.Communication.IPC.Core
2564     * @since 8
2565     * @deprecated since 9
2566     * @useinstead ohos.rpc.IRemoteObject#sendMessageRequest
2567     */
2568    sendRequest(
2569      code: number,
2570      data: MessageParcel,
2571      reply: MessageParcel,
2572      options: MessageOption,
2573      callback: AsyncCallback<SendRequestResult>
2574    ): void;
2575
2576    /**
2577     * Sends a {@link MessageSequence} message to the peer process in synchronous or asynchronous mode.
2578     * <p>If options indicates the asynchronous mode, a callback will be invoked immediately
2579     * and the reply message does not contain any content. If options indicates the synchronous mode,
2580     * a callback will be invoked when the response to sendMessageRequest is returned,
2581     * and the reply message contains the returned information.
2582     *
2583     * @param {number } code - Message code called by the request, which is determined by the client and server.
2584     * If the method is generated by an IDL tool, the message code is automatically generated by the IDL tool.
2585     * @param { MessageSequence } data - {@link MessageSequence} object holding the data to send.
2586     * @param { MessageSequence } reply - {@link MessageSequence} object that receives the response.
2587     * @param { MessageOption } options - Indicates the synchronous or asynchronous mode to send messages.
2588     * @param { AsyncCallback<RequestResult> } callback - Callback for receiving the sending result.
2589     * @throws { BusinessError } 401 - Parameter error. Possible causes:
2590     *     1.The number of parameters is incorrect;
2591     *     2.The parameter type does not match;
2592     *     3.Failed to obtain the passed object instance.
2593     * @syscap SystemCapability.Communication.IPC.Core
2594     * @since 9
2595     */
2596    sendMessageRequest(
2597      code: number,
2598      data: MessageSequence,
2599      reply: MessageSequence,
2600      options: MessageOption,
2601      callback: AsyncCallback<RequestResult>
2602    ): void;
2603
2604    /**
2605     * Register a callback used to receive notifications of the death of a remote object.
2606     *
2607     * @param { DeathRecipient } recipient - Indicates the callback to be registered.
2608     * @param { number } flags - Indicates the flag of the death notification.
2609     * @returns { boolean } Return {@code true} if the callback is registered successfully;
2610     *                      return {@code false} otherwise.
2611     * @syscap SystemCapability.Communication.IPC.Core
2612     * @since 7
2613     * @deprecated since 9
2614     * @useinstead ohos.rpc.IRemoteObject#registerDeathRecipient
2615     */
2616    addDeathRecipient(recipient: DeathRecipient, flags: number): boolean;
2617
2618    /**
2619     * Register a callback used to receive notifications of the death of a remote object.
2620     *
2621     * @param { DeathRecipient } recipient - Indicates the callback to be registered.
2622     * @param { number } flags - Indicates the flag of the death notification.
2623     * @throws { BusinessError } 401 - Parameter error. Possible causes:
2624     *     1.The number of parameters is incorrect;
2625     *     2.The parameter type does not match;
2626     *     3.The callback used to receive remote object death notifications is empty.
2627     * @throws { BusinessError } 1900008 - The proxy or remote object is invalid.
2628     * @syscap SystemCapability.Communication.IPC.Core
2629     * @since 9
2630     */
2631    registerDeathRecipient(recipient: DeathRecipient, flags: number): void;
2632
2633    /**
2634     * Unregister a callback used to receive notifications of the death of a remote object.
2635     *
2636     * @param { DeathRecipient } recipient - Indicates the callback to be unregister.
2637     * @param { number } flags - Indicates the flag of the death notification.
2638     * @returns { boolean } Return {@code true} if the callback is unregister successfully;
2639     *                      return {@code false} otherwise.
2640     * @syscap SystemCapability.Communication.IPC.Core
2641     * @since 7
2642     * @deprecated since 9
2643     * @useinstead ohos.rpc.IRemoteObject#unregisterDeathRecipient
2644     */
2645    removeDeathRecipient(recipient: DeathRecipient, flags: number): boolean;
2646
2647    /**
2648     * Unregister a callback used to receive notifications of the death of a remote object.
2649     *
2650     * @param { DeathRecipient } recipient - Indicates the callback to be unregister.
2651     * @param { number } flags - Indicates the flag of the death notification.
2652     * @throws { BusinessError } 401 - Parameter error. Possible causes:
2653     *     1.The number of parameters is incorrect;
2654     *     2.The parameter type does not match;
2655     *     3.The callback used to receive remote object death notifications is empty.
2656     * @throws { BusinessError } 1900008 - The proxy or remote object is invalid.
2657     * @syscap SystemCapability.Communication.IPC.Core
2658     * @since 9
2659     */
2660    unregisterDeathRecipient(recipient: DeathRecipient, flags: number): void;
2661
2662    /**
2663     * Obtains the interface descriptor of an object.
2664     * <p>The interface descriptor is a character string.
2665     *
2666     * @returns { string } Return the interface descriptor.
2667     * @syscap SystemCapability.Communication.IPC.Core
2668     * @since 7
2669     * @deprecated since 9
2670     * @useinstead ohos.rpc.IRemoteObject#getDescriptor
2671     */
2672    getInterfaceDescriptor(): string;
2673
2674    /**
2675     * Obtains the interface descriptor of an object.
2676     * <p>The interface descriptor is a character string.
2677     *
2678     * @returns { string } Return the interface descriptor.
2679     * @throws { BusinessError } 1900008 - The proxy or remote object is invalid.
2680     * @syscap SystemCapability.Communication.IPC.Core
2681     * @since 9
2682     */
2683    getDescriptor(): string;
2684
2685    /**
2686     * Checks whether an object is dead.
2687     *
2688     * @returns { boolean } Return {@code true} if the object is dead; return {@code false} otherwise.
2689     * @syscap SystemCapability.Communication.IPC.Core
2690     * @since 7
2691     */
2692    isObjectDead(): boolean;
2693  }
2694
2695  /**
2696   * @typedef IRemoteBroker
2697   * @syscap SystemCapability.Communication.IPC.Core
2698   * @since 7
2699   */
2700  /**
2701   * Used to define the communication interface of the IPC communication objects.
2702   *
2703   * @typedef IRemoteBroker
2704   * @syscap SystemCapability.Communication.IPC.Core
2705   * @since 11
2706   */
2707  interface IRemoteBroker {
2708    /**
2709     * Obtains a proxy or remote object. This method must be implemented by its derived classes.
2710     *
2711     * @returns { IRemoteObject } Return the RemoteObject if the caller is a RemoteObject; return the IRemoteObject,
2712     * that is, the holder of this RemoteProxy object, if the caller is a RemoteProxy object.
2713     * @syscap SystemCapability.Communication.IPC.Core
2714     * @since 7
2715     */
2716    asObject(): IRemoteObject;
2717  }
2718
2719  /**
2720   * @typedef DeathRecipient
2721   * @syscap SystemCapability.Communication.IPC.Core
2722   * @since 7
2723   */
2724  /**
2725   * Used to subscribe to death notifications for remote objects.
2726   * <p>
2727   * When a remote object subscribed to the notification dies, the local end can receive a message and call
2728   * the onRemoteDied operation. The death of a remote object can be caused by the death of the process to which the
2729   * remote object belongs, the shutdown or restart of the device to which the remote object belongs,
2730   * or the death of the remote object when the remote object and the local object belong to different devices,
2731   * and when the remote object leaves the network.
2732   * </p>
2733   *
2734   * @typedef DeathRecipient
2735   * @syscap SystemCapability.Communication.IPC.Core
2736   * @since 11
2737   */
2738  interface DeathRecipient {
2739    /**
2740     * Called to perform subsequent operations when a death notification of the remote object is received.
2741     *
2742     * @syscap SystemCapability.Communication.IPC.Core
2743     * @since 7
2744     */
2745    onRemoteDied(): void;
2746  }
2747
2748  /**
2749   * @syscap SystemCapability.Communication.IPC.Core
2750   * @since 7
2751   */
2752  /**
2753   * Public Message Option, using the specified flag type, constructs the specified MessageOption object.
2754   *
2755   * @syscap SystemCapability.Communication.IPC.Core
2756   * @since 11
2757   */
2758  class MessageOption {
2759    /**
2760     * Indicates synchronous call.
2761     *
2762     * @type { number }
2763     * @default 0
2764     * @syscap SystemCapability.Communication.IPC.Core
2765     * @since 7
2766     */
2767    TF_SYNC: number;
2768
2769    /**
2770     * Indicates asynchronous call.
2771     *
2772     * @type { number }
2773     * @default 1
2774     * @syscap SystemCapability.Communication.IPC.Core
2775     * @since 7
2776     */
2777    TF_ASYNC: number;
2778
2779    /**
2780     * Indicates the sendRequest API for returning the file descriptor.
2781     *
2782     * @type { number }
2783     * @default 16
2784     * @syscap SystemCapability.Communication.IPC.Core
2785     * @since 7
2786     */
2787    TF_ACCEPT_FDS: number;
2788
2789    /**
2790     * Indicates the wait time for RPC, in seconds. It is NOT used in IPC case.
2791     *
2792     * @default 4
2793     * @syscap SystemCapability.Communication.IPC.Core
2794     * @since 7
2795     */
2796    /**
2797     * Indicates the wait time for RPC, in seconds. It is NOT used in IPC case.
2798     *
2799     * @type { number }
2800     * @default 8
2801     * @syscap SystemCapability.Communication.IPC.Core
2802     * @since 11
2803     */
2804    TF_WAIT_TIME: number;
2805
2806    /**
2807     * A constructor used to create a MessageOption instance.
2808     *
2809     * @param { number } syncFlags - Specifies whether the SendRequest is called synchronously (default) or asynchronously.
2810     * @param { number } waitTime - Maximum wait time for a RPC call. The default value is TF_WAIT_TIME.
2811     * @syscap SystemCapability.Communication.IPC.Core
2812     * @since 7
2813     */
2814    constructor(syncFlags?: number, waitTime?: number);
2815
2816    /**
2817     * A constructor used to create a MessageOption instance.
2818     *
2819     * @param { boolean } async - Specifies whether the SendRequest is called synchronously (default) or asynchronously.
2820     * @syscap SystemCapability.Communication.IPC.Core
2821     * @since 9
2822     */
2823    constructor(async?: boolean);
2824
2825    /**
2826     * Obtains the SendRequest call flag, which can be synchronous or asynchronous.
2827     *
2828     * @returns { number } Return whether the SendRequest is called synchronously or asynchronously.
2829     * @syscap SystemCapability.Communication.IPC.Core
2830     * @since 7
2831     */
2832    getFlags(): number;
2833
2834    /**
2835     * Sets the SendRequest call flag, which can be synchronous or asynchronous.
2836     *
2837     * @param { number } flags - Indicates the call flag, which can be synchronous or asynchronous.
2838     * @syscap SystemCapability.Communication.IPC.Core
2839     * @since 7
2840     */
2841    setFlags(flags: number): void;
2842
2843    /**
2844     * Obtains the SendRequest call flag, which can be synchronous or asynchronous.
2845     *
2846     * @returns { boolean } Return {@code true} if the asynchronous call succeeds;
2847     *                      return {@code false} if the synchronous call succeeds.
2848     * @syscap SystemCapability.Communication.IPC.Core
2849     * @since 9
2850     */
2851    isAsync(): boolean;
2852
2853    /**
2854     * Sets the SendRequest call flag, which can be synchronous or asynchronous.
2855     *
2856     * @param { boolean } async - Indicates the call flag, which can be synchronous or asynchronous.
2857     * @syscap SystemCapability.Communication.IPC.Core
2858     * @since 9
2859     */
2860    setAsync(async: boolean): void;
2861
2862    /**
2863     * Obtains the maximum wait time for this RPC call.
2864     *
2865     * @returns { number } Return maximum wait time obtained.
2866     * @syscap SystemCapability.Communication.IPC.Core
2867     * @since 7
2868     */
2869    getWaitTime(): number;
2870
2871    /**
2872     * Sets the maximum wait time for this RPC call.
2873     *
2874     * @param { number } waitTime - Indicates maximum wait time to set.
2875     * @syscap SystemCapability.Communication.IPC.Core
2876     * @since 7
2877     */
2878    setWaitTime(waitTime: number): void;
2879  }
2880
2881  /**
2882   * @extends IRemoteObject
2883   * @syscap SystemCapability.Communication.IPC.Core
2884   * @since 7
2885   */
2886  /**
2887   * Implement remote objects. The service provider must inherit this class.
2888   *
2889   * @extends IRemoteObject
2890   * @syscap SystemCapability.Communication.IPC.Core
2891   * @since 11
2892   */
2893  class RemoteObject extends IRemoteObject {
2894    /**
2895     * A constructor to create a RemoteObject instance.
2896     *
2897     * @param { string } descriptor - Specifies interface descriptor.
2898     * @syscap SystemCapability.Communication.IPC.Core
2899     * @since 7
2900     */
2901    constructor(descriptor: string);
2902
2903    /**
2904     * Queries a remote object using an interface descriptor.
2905     *
2906     * @param { string } descriptor - Indicates the interface descriptor used to query the remote object.
2907     * @returns { IRemoteBroker } Return the remote object matching the interface descriptor;
2908     *                            return null if no such remote object is found.
2909     * @syscap SystemCapability.Communication.IPC.Core
2910     * @since 7
2911     * @deprecated since 9
2912     * @useinstead ohos.rpc.RemoteObject#getLocalInterface
2913     */
2914    queryLocalInterface(descriptor: string): IRemoteBroker;
2915
2916    /**
2917     * Queries a remote object using an interface descriptor.
2918     *
2919     * @param { string } descriptor - Indicates the interface descriptor used to query the remote object.
2920     * @returns { IRemoteBroker } Return the remote object matching the interface descriptor;
2921     *                            return null if no such remote object is found.
2922     * @throws { BusinessError } 401 - Parameter error. Possible causes:
2923     *     1.The number of parameters is incorrect;
2924     *     2.The parameter type does not match;
2925     *     3.The string length exceeds 40960 bytes;
2926     *     4.The number of bytes copied to the buffer is different from the length of the obtained string.
2927     * @syscap SystemCapability.Communication.IPC.Core
2928     * @since 9
2929     */
2930    getLocalInterface(descriptor: string): IRemoteBroker;
2931
2932    /**
2933     * Queries an interface descriptor.
2934     *
2935     * @returns { string } Return the interface descriptor.
2936     * @syscap SystemCapability.Communication.IPC.Core
2937     * @since 7
2938     * @deprecated since 9
2939     * @useinstead ohos.rpc.RemoteObject#getDescriptor
2940     */
2941    getInterfaceDescriptor(): string;
2942
2943    /**
2944     * Queries an interface descriptor.
2945     *
2946     * @returns { string } Return the interface descriptor.
2947     * @throws { BusinessError } 1900008 - The proxy or remote object is invalid.
2948     * @syscap SystemCapability.Communication.IPC.Core
2949     * @since 9
2950     */
2951    getDescriptor(): string;
2952
2953    /**
2954     * Sets an entry for receiving requests.
2955     * <p>This method is implemented by the remote service provider. You need to override this method with
2956     * your own service logic when you are using IPC.
2957     *
2958     * @param { number } code - Indicates the service request code sent from the peer end.
2959     * @param { MessageSequence } data - Indicates the {@link MessageParcel} object sent from the peer end.
2960     * @param { MessageSequence } reply - Indicates the response message object sent from the remote service.
2961     * The local service writes the response data to the {@link MessageParcel} object.
2962     * @param { MessageOption } options - Indicates whether the operation is synchronous or asynchronous.
2963     * @returns { boolean | Promise<boolean> }
2964     * Return a simple boolean which is {@code true} if the operation succeeds;
2965     * {{@code false} otherwise} when the function call is synchronous.
2966     * Return a promise object with a boolean when the function call is asynchronous.
2967     * @syscap SystemCapability.Communication.IPC.Core
2968     * @since 9
2969     */
2970    onRemoteMessageRequest(
2971      code: number,
2972      data: MessageSequence,
2973      reply: MessageSequence,
2974      options: MessageOption
2975    ): boolean | Promise<boolean>;
2976
2977    /**
2978     * Sets an entry for receiving requests.
2979     * <p>This method is implemented by the remote service provider. You need to override this method with
2980     * your own service logic when you are using IPC.
2981     *
2982     * @param { number } code - Indicates the service request code sent from the peer end.
2983     * @param { MessageParcel } data - Indicates the {@link MessageParcel} object sent from the peer end.
2984     * @param { MessageParcel } reply - Indicates the response message object sent from the remote service.
2985     * The local service writes the response data to the {@link MessageParcel} object.
2986     * @param { MessageOption } options - Indicates whether the operation is synchronous or asynchronous.
2987     * @returns { boolean } Return {@code true} if the operation succeeds; return {@code false} otherwise.
2988     * @syscap SystemCapability.Communication.IPC.Core
2989     * @since 7
2990     * @deprecated since 9
2991     * @useinstead ohos.rpc.RemoteObject#onRemoteMessageRequest
2992     */
2993    onRemoteRequest(code: number, data: MessageParcel, reply: MessageParcel, options: MessageOption): boolean;
2994
2995    /**
2996     * Sends a request to the peer object.
2997     * <p>If the peer object and {@code RemoteObject} are on the same device, the request is sent by the IPC driver.
2998     * If they are on different devices, the request is sent by the socket driver.
2999     *
3000     * @param { number } code - Indicates the message code of the request.
3001     * @param { MessageParcel } data - Indicates the {@link MessageParcel} object storing the data to be sent.
3002     * @param { MessageParcel } reply - Indicates the {@link MessageParcel} object receiving the response data.
3003     * @param { MessageOption } options - Indicates a synchronous (default) or asynchronous request.
3004     * @returns { boolean } Return {@code true} if the operation succeeds; return {@code false} otherwise.
3005     * @syscap SystemCapability.Communication.IPC.Core
3006     * @since 7
3007     * @deprecated since 8
3008     */
3009    sendRequest(code: number, data: MessageParcel, reply: MessageParcel, options: MessageOption): boolean;
3010
3011    /**
3012     * Sends a {@link MessageParcel} message to the peer process in synchronous or asynchronous mode.
3013     * <p>If options indicates the asynchronous mode, a promise will be fulfilled immediately
3014     * and the reply message does not contain any content. If options indicates the synchronous mode,
3015     * a promise will be fulfilled when the response to sendRequest is returned,
3016     * and the reply message contains the returned information.
3017     *
3018     * @param { number } code - Message code called by the request, which is determined by the client and server.
3019     * If the method is generated by an IDL tool, the message code is automatically generated by the IDL tool.
3020     * @param { MessageParcel } data - {@link MessageParcel} object holding the data to send.
3021     * @param { MessageParcel } reply - {@link MessageParcel} object that receives the response.
3022     * @param { MessageOption } options - Indicates the synchronous or asynchronous mode to send messages.
3023     * @returns { Promise<SendRequestResult> } Promise used to return the {@link SendRequestResult} instance.
3024     * @syscap SystemCapability.Communication.IPC.Core
3025     * @since 8
3026     * @deprecated since 9
3027     * @useinstead ohos.rpc.RemoteObject#sendMessageRequest
3028     */
3029    sendRequest(
3030      code: number,
3031      data: MessageParcel,
3032      reply: MessageParcel,
3033      options: MessageOption
3034    ): Promise<SendRequestResult>;
3035
3036    /**
3037     * Sends a {@link MessageSequence} message to the peer process in synchronous or asynchronous mode.
3038     * <p>If options indicates the asynchronous mode, a promise will be fulfilled immediately
3039     * and the reply message does not contain any content. If options indicates the synchronous mode,
3040     * a promise will be fulfilled when the response to sendMessageRequest is returned,
3041     * and the reply message contains the returned information.
3042     *
3043     * @param { number } code - Message code called by the request, which is determined by the client and server.
3044     * If the method is generated by an IDL tool, the message code is automatically generated by the IDL tool.
3045     * @param { MessageSequence } data - {@link MessageSequence} object holding the data to send.
3046     * @param { MessageSequence } reply - {@link MessageSequence} object that receives the response.
3047     * @param { MessageOption } options - Indicates the synchronous or asynchronous mode to send messages.
3048     * @returns { Promise<RequestResult> } Promise used to return the {@link RequestResult} instance.
3049     * @throws { BusinessError } 401 - Parameter error. Possible causes:
3050     *     1.The number of parameters is incorrect;
3051     *     2.The parameter type does not match;
3052     *     3.Failed to obtain the passed object instance.
3053     * @syscap SystemCapability.Communication.IPC.Core
3054     * @since 9
3055     */
3056    sendMessageRequest(
3057      code: number,
3058      data: MessageSequence,
3059      reply: MessageSequence,
3060      options: MessageOption
3061    ): Promise<RequestResult>;
3062
3063    /**
3064     * Sends a {@link MessageParcel} message to the peer process in synchronous or asynchronous mode.
3065     * <p>If options indicates the asynchronous mode, a callback will be invoked immediately
3066     * and the reply message does not contain any content. If options indicates the synchronous mode,
3067     * a callback will be invoked when the response to sendRequest is returned,
3068     * and the reply message contains the returned information.
3069     *
3070     * @param { number } code - Message code called by the request, which is determined by the client and server.
3071     * If the method is generated by an IDL tool, the message code is automatically generated by the IDL tool.
3072     * @param { MessageParcel } data - {@link MessageParcel} object holding the data to send.
3073     * @param { MessageParcel} reply - {@link MessageParcel} object that receives the response.
3074     * @param { MessageOption } options - Indicates the synchronous or asynchronous mode to send messages.
3075     * @param { AsyncCallback<SendRequestResult> } callback - Callback for receiving the sending result.
3076     * @syscap SystemCapability.Communication.IPC.Core
3077     * @since 8
3078     * @deprecated since 9
3079     * @useinstead ohos.rpc.RemoteObject#sendMessageRequest
3080     */
3081    sendRequest(
3082      code: number,
3083      data: MessageParcel,
3084      reply: MessageParcel,
3085      options: MessageOption,
3086      callback: AsyncCallback<SendRequestResult>
3087    ): void;
3088
3089    /**
3090     * Sends a {@link MessageSequence} message to the peer process in synchronous or asynchronous mode.
3091     * <p>If options indicates the asynchronous mode, a callback will be invoked immediately
3092     * and the reply message does not contain any content. If options indicates the synchronous mode,
3093     * a callback will be invoked when the response to sendMessageRequest is returned,
3094     * and the reply message contains the returned information.
3095     *
3096     * @param { number } code - Message code called by the request, which is determined by the client and server.
3097     * If the method is generated by an IDL tool, the message code is automatically generated by the IDL tool.
3098     * @param { MessageSequence } data - {@link MessageSequence} object holding the data to send.
3099     * @param { MessageSequence } reply - {@link MessageSequence} object that receives the response.
3100     * @param { MessageOption } options - Indicates the synchronous or asynchronous mode to send messages.
3101     * @param { AsyncCallback<RequestResult> } callback - Callback for receiving the sending result.
3102     * @throws { BusinessError } 401 - Parameter error. Possible causes:
3103     *     1.The number of parameters is incorrect;
3104     *     2.The parameter type does not match;
3105     *     3.Failed to obtain the passed object instance.
3106     * @syscap SystemCapability.Communication.IPC.Core
3107     * @since 9
3108     */
3109    sendMessageRequest(
3110      code: number,
3111      data: MessageSequence,
3112      reply: MessageSequence,
3113      options: MessageOption,
3114      callback: AsyncCallback<RequestResult>
3115    ): void;
3116
3117    /**
3118     * Obtains the PID of the {@link RemoteProxy} object.
3119     *
3120     * @returns { number } Return the PID of the {@link RemoteProxy} object.
3121     * @syscap SystemCapability.Communication.IPC.Core
3122     * @since 7
3123     */
3124    getCallingPid(): number;
3125
3126    /**
3127     * Obtains the UID of the {@link RemoteProxy} object.
3128     *
3129     * @returns { number } Return the UID of the {@link RemoteProxy} object.
3130     * @syscap SystemCapability.Communication.IPC.Core
3131     * @since 7
3132     */
3133    getCallingUid(): number;
3134
3135    /**
3136     * Modifies the description of the current {@code RemoteObject}.
3137     * <p>This method is used to change the default descriptor specified during the creation of {@code RemoteObject}.
3138     *
3139     * @param { IRemoteBroker } localInterface - Indicates the {@code RemoteObject} whose descriptor is to be changed.
3140     * @param { string } descriptor - Indicates the new descriptor of the {@code RemoteObject}.
3141     * @syscap SystemCapability.Communication.IPC.Core
3142     * @since 7
3143     * @deprecated since 9
3144     * @useinstead ohos.rpc.RemoteObject#modifyLocalInterface
3145     */
3146    attachLocalInterface(localInterface: IRemoteBroker, descriptor: string): void;
3147
3148    /**
3149     * Modifies the description of the current {@code RemoteObject}.
3150     * <p>This method is used to change the default descriptor specified during the creation of {@code RemoteObject}.
3151     *
3152     * @param { IRemoteBroker } localInterface - Indicates the {@code RemoteObject} whose descriptor is to be changed.
3153     * @param { string } descriptor - Indicates the new descriptor of the {@code RemoteObject}.
3154     * @throws { BusinessError } 401 - Parameter error. Possible causes:
3155     *     1.The number of parameters is incorrect;
3156     *     2.The parameter type does not match;
3157     *     3.The string length exceeds 40960 bytes;
3158     *     4.The number of bytes copied to the buffer is different from the length of the obtained string.
3159     * @syscap SystemCapability.Communication.IPC.Core
3160     * @since 9
3161     */
3162    modifyLocalInterface(localInterface: IRemoteBroker, descriptor: string): void;
3163  }
3164
3165  /**
3166   * @syscap SystemCapability.Communication.IPC.Core
3167   * @since 7
3168   */
3169  /**
3170   * Implement the IRemoteObject proxy object.
3171   *
3172   * @extends IRemoteObject
3173   * @syscap SystemCapability.Communication.IPC.Core
3174   * @since 11
3175   */
3176  class RemoteProxy extends IRemoteObject {
3177    /**
3178     * Indicates the message code for a Ping operation.
3179     *
3180     * @type { number }
3181     * @default 1599098439
3182     * @syscap SystemCapability.Communication.IPC.Core
3183     * @since 7
3184     */
3185    PING_TRANSACTION: number;
3186
3187    /**
3188     * Indicates the message code for a dump operation.
3189     *
3190     * @type { number }
3191     * @default 1598311760
3192     * @syscap SystemCapability.Communication.IPC.Core
3193     * @since 7
3194     */
3195    DUMP_TRANSACTION: number;
3196
3197    /**
3198     * Indicates the message code for a transmission.
3199     *
3200     * @type { number }
3201     * @default 1598968902
3202     * @syscap SystemCapability.Communication.IPC.Core
3203     * @since 7
3204     */
3205    INTERFACE_TRANSACTION: number;
3206
3207    /**
3208     * Indicates the minimum value of a valid message code.
3209     * <p>This constant is used to check the validity of an operation.
3210     *
3211     * @type { number }
3212     * @default 0x1
3213     * @syscap SystemCapability.Communication.IPC.Core
3214     * @since 7
3215     */
3216    MIN_TRANSACTION_ID: number;
3217
3218    /**
3219     * Indicates the maximum value of a valid message code.
3220     * <p>This constant is used to check the validity of an operation.
3221     *
3222     * @type { number }
3223     * @default 0x00FFFFFF
3224     * @syscap SystemCapability.Communication.IPC.Core
3225     * @since 7
3226     */
3227    MAX_TRANSACTION_ID: number;
3228
3229    /**
3230     * Queries a local interface with a specified descriptor.
3231     *
3232     * @param { string } interface - Indicates the descriptor of the interface to query.
3233     * @returns { IRemoteBroker } Return null by default, indicating a proxy interface.
3234     * @syscap SystemCapability.Communication.IPC.Core
3235     * @since 7
3236     * @deprecated since 9
3237     * @useinstead ohos.rpc.RemoteProxy#getLocalInterface
3238     */
3239    queryLocalInterface(interface: string): IRemoteBroker;
3240
3241    /**
3242     * Queries a local interface with a specified descriptor.
3243     *
3244     * @param { string } interface - Indicates the descriptor of the interface to query.
3245     * @returns { IRemoteBroker } Return null by default, indicating a proxy interface.
3246     * @throws { BusinessError } 401 - check param failed
3247     * @throws { BusinessError } 1900006 - Operation allowed only for the remote object.
3248     * @syscap SystemCapability.Communication.IPC.Core
3249     * @since 9
3250     */
3251    getLocalInterface(interface: string): IRemoteBroker;
3252
3253    /**
3254     * Register a callback used to receive death notifications of a remote object.
3255     *
3256     * @param { DeathRecipient } recipient - Indicates the callback to be registered.
3257     * @param { number } flags - Indicates the flag of the death notification. This is a reserved parameter.
3258     *                   Set it to {@code 0}.
3259     * @returns { boolean } Return {@code true} if the callback is registered successfully;
3260     *                      return {@code false} otherwise.
3261     * @syscap SystemCapability.Communication.IPC.Core
3262     * @since 7
3263     * @deprecated since 9
3264     * @useinstead ohos.rpc.RemoteProxy#registerDeathRecipient
3265     */
3266    addDeathRecipient(recipient: DeathRecipient, flags: number): boolean;
3267
3268    /**
3269     * Register a callback used to receive death notifications of a remote object.
3270     *
3271     * @param { DeathRecipient } recipient - Indicates the callback to be registered.
3272     * @param { number } flags - Indicates the flag of the death notification. This is a reserved parameter.
3273     *                   Set it to {@code 0}.
3274     * @throws { BusinessError } 401 - Parameter error. Possible causes:
3275     *     1.The number of parameters is incorrect;
3276     *     2.The parameter type does not match;
3277     *     3.The callback used to receive remote object death notifications is empty.
3278     * @throws { BusinessError } 1900008 - The proxy or remote object is invalid.
3279     * @syscap SystemCapability.Communication.IPC.Core
3280     * @since 9
3281     */
3282    registerDeathRecipient(recipient: DeathRecipient, flags: number): void;
3283
3284    /**
3285     * Unregister a callback used to receive death notifications of a remote object.
3286     *
3287     * @param { DeathRecipient } recipient - Indicates the callback to be unregister.
3288     * @param { number } flags - Indicates the flag of the death notification. This is a reserved parameter.
3289     *                   Set it to {@code 0}.
3290     * @returns { boolean } Return {@code true} if the callback is unregister successfully;
3291     *                      return {@code false} otherwise.
3292     * @syscap SystemCapability.Communication.IPC.Core
3293     * @since 7
3294     * @deprecated since 9
3295     * @useinstead ohos.rpc.RemoteProxy#unregisterDeathRecipient
3296     */
3297    removeDeathRecipient(recipient: DeathRecipient, flags: number): boolean;
3298
3299    /**
3300     * Unregister a callback used to receive death notifications of a remote object.
3301     *
3302     * @param { DeathRecipient } recipient - Indicates the callback to be unregister.
3303     * @param { number } flags - Indicates the flag of the death notification. This is a reserved parameter.
3304     *                   Set it to {@code 0}.
3305     * @throws { BusinessError } 401 - Parameter error. Possible causes:
3306     *     1.The number of parameters is incorrect;
3307     *     2.The parameter type does not match;
3308     *     3.The callback used to receive remote object death notifications is empty.
3309     * @throws { BusinessError } 1900008 - The proxy or remote object is invalid.
3310     * @syscap SystemCapability.Communication.IPC.Core
3311     * @since 9
3312     */
3313    unregisterDeathRecipient(recipient: DeathRecipient, flags: number): void;
3314
3315    /**
3316     * Queries the interface descriptor of remote object.
3317     *
3318     * @returns { string } Return the interface descriptor.
3319     * @syscap SystemCapability.Communication.IPC.Core
3320     * @since 7
3321     * @deprecated since 9
3322     * @useinstead ohos.rpc.RemoteProxy#getDescriptor
3323     */
3324    getInterfaceDescriptor(): string;
3325
3326    /**
3327     * Queries the interface descriptor of remote object.
3328     *
3329     * @returns { string } Return the interface descriptor.
3330     * @throws { BusinessError } 1900007 - communication failed.
3331     * @throws { BusinessError } 1900008 - The proxy or remote object is invalid.
3332     * @syscap SystemCapability.Communication.IPC.Core
3333     * @since 9
3334     */
3335    getDescriptor(): string;
3336
3337    /**
3338     * Sends a request to the peer object.
3339     * <p>If the peer object and {@code RemoteProxy} are on the same device, the request is sent by the IPC driver.
3340     * If they are on different devices, the request is sent by the socket driver.
3341     *
3342     * @param { number } code - Indicates the message code of the request.
3343     * @param { MessageParcel } data - Indicates the {@link MessageParcel} object storing the data to be sent.
3344     * @param { MessageParcel } reply - Indicates the {@link MessageParcel} object receiving the response data.
3345     * @param { MessageOption } options - Indicates a synchronous (default) or asynchronous request.
3346     * @returns { boolean } Return {@code true} if the operation succeeds; return {@code false} otherwise.
3347     * @syscap SystemCapability.Communication.IPC.Core
3348     * @since 7
3349     * @deprecated since 8
3350     */
3351    sendRequest(code: number, data: MessageParcel, reply: MessageParcel, options: MessageOption): boolean;
3352
3353    /**
3354     * Sends a {@link MessageParcel} message to the peer process in synchronous or asynchronous mode.
3355     * <p>If options indicates the asynchronous mode, a promise will be fulfilled immediately
3356     * and the reply message does not contain any content. If options indicates the synchronous mode,
3357     * a promise will be fulfilled when the response to sendRequest is returned,
3358     * and the reply message contains the returned information.
3359     *
3360     * @param { number } code - Message code called by the request, which is determined by the client and server.
3361     * If the method is generated by an IDL tool, the message code is automatically generated by the IDL tool.
3362     * @param { MessageParcel } data - {@link MessageParcel} object holding the data to send.
3363     * @param { MessageParcel} reply - {@link MessageParcel} object that receives the response.
3364     * @param { MessageOption } options - Indicates the synchronous or asynchronous mode to send messages.
3365     * @returns { Promise<SendRequestResult> } Promise used to return the {@link sendRequestResult} instance.
3366     * @syscap SystemCapability.Communication.IPC.Core
3367     * @since 8
3368     * @deprecated since 9
3369     * @useinstead ohos.rpc.RemoteProxy#sendMessageRequest
3370     */
3371    sendRequest(
3372      code: number,
3373      data: MessageParcel,
3374      reply: MessageParcel,
3375      options: MessageOption
3376    ): Promise<SendRequestResult>;
3377
3378    /**
3379     * Sends a {@link MessageSequence} message to the peer process in synchronous or asynchronous mode.
3380     * <p>If options indicates the asynchronous mode, a promise will be fulfilled immediately
3381     * and the reply message does not contain any content. If options indicates the synchronous mode,
3382     * a promise will be fulfilled when the response to sendMessageRequest is returned,
3383     * and the reply message contains the returned information.
3384     *
3385     * @param { number } code - Message code called by the request, which is determined by the client and server.
3386     * If the method is generated by an IDL tool, the message code is automatically generated by the IDL tool.
3387     * @param { MessageSequence } data - {@link MessageSequence} object holding the data to send.
3388     * @param { MessageSequence } reply - {@link MessageSequence} object that receives the response.
3389     * @param { MessageOption } options - Indicates the synchronous or asynchronous mode to send messages.
3390     * @returns { Promise<RequestResult> } Promise used to return the {@link RequestResult} instance.
3391     * @throws { BusinessError } 401 - Parameter error. Possible causes:
3392     *     1.The number of parameters is incorrect;
3393     *     2.The parameter type does not match;
3394     *     3.Failed to obtain the passed object instance.
3395     * @syscap SystemCapability.Communication.IPC.Core
3396     * @since 9
3397     */
3398    sendMessageRequest(
3399      code: number,
3400      data: MessageSequence,
3401      reply: MessageSequence,
3402      options: MessageOption
3403    ): Promise<RequestResult>;
3404
3405    /**
3406     * Sends a {@link MessageParcel} message to the peer process in synchronous or asynchronous mode.
3407     * <p>If options indicates the asynchronous mode, a callback will be invoked immediately
3408     * and the reply message does not contain any content. If options indicates the synchronous mode,
3409     * a callback will be invoked when the response to sendRequest is returned,
3410     * and the reply message contains the returned information.
3411     *
3412     * @param { number } code - Message code called by the request, which is determined by the client and server.
3413     * If the method is generated by an IDL tool, the message code is automatically generated by the IDL tool.
3414     * @param { MessageParcel } data - {@link MessageParcel} object holding the data to send.
3415     * @param { MessageParcel } reply - {@link MessageParcel} object that receives the response.
3416     * @param { MessageOption } options - Indicates the synchronous or asynchronous mode to send messages.
3417     * @param { AsyncCallback<SendRequestResult> } callback - Callback for receiving the sending result.
3418     * @syscap SystemCapability.Communication.IPC.Core
3419     * @since 8
3420     * @deprecated since 9
3421     * @useinstead ohos.rpc.RemoteProxy#sendMessageRequest
3422     */
3423    sendRequest(
3424      code: number,
3425      data: MessageParcel,
3426      reply: MessageParcel,
3427      options: MessageOption,
3428      callback: AsyncCallback<SendRequestResult>
3429    ): void;
3430
3431    /**
3432     * Sends a {@link MessageSequence} message to the peer process in synchronous or asynchronous mode.
3433     * <p>If options indicates the asynchronous mode, a callback will be invoked immediately
3434     * and the reply message does not contain any content. If options indicates the synchronous mode,
3435     * a callback will be invoked when the response to sendRequest is returned,
3436     * and the reply message contains the returned information.
3437     *
3438     * @param { number } code - Message code called by the request, which is determined by the client and server.
3439     * If the method is generated by an IDL tool, the message code is automatically generated by the IDL tool.
3440     * @param { MessageSequence } data - {@link MessageSequence} object holding the data to send.
3441     * @param { MessageSequence } reply - {@link MessageSequence} object that receives the response.
3442     * @param { MessageOption } options - Indicates the synchronous or asynchronous mode to send messages.
3443     * @param { AsyncCallback<RequestResult> } callback - Callback for receiving the sending result.
3444     * @throws { BusinessError } 401 - Parameter error. Possible causes:
3445     *     1.The number of parameters is incorrect;
3446     *     2.The parameter type does not match;
3447     *     3.Failed to obtain the passed object instance.
3448     * @syscap SystemCapability.Communication.IPC.Core
3449     * @since 9
3450     */
3451    sendMessageRequest(
3452      code: number,
3453      data: MessageSequence,
3454      reply: MessageSequence,
3455      options: MessageOption,
3456      callback: AsyncCallback<RequestResult>
3457    ): void;
3458
3459    /**
3460     * Checks whether the {@code RemoteObject} corresponding to a {@code RemoteProxy} is dead.
3461     *
3462     * @returns { boolean } Return {@code true} if the {@code RemoteObject} is dead; return {@code false} otherwise.
3463     * @syscap SystemCapability.Communication.IPC.Core
3464     * @since 7
3465     */
3466    isObjectDead(): boolean;
3467  }
3468
3469  /**
3470   * @syscap SystemCapability.Communication.IPC.Core
3471   * @since 7
3472   */
3473  /**
3474   * Used to obtain IPC context information, including obtaining the UID and PID, obtaining the local and
3475   * peer device IDs, and checking whether the API call is on the same device.
3476   *
3477   * @syscap SystemCapability.Communication.IPC.Core
3478   * @since 11
3479   */
3480  class IPCSkeleton {
3481    /**
3482     * Obtains a local {@link IRemoteObject} reference of a registered service.
3483     * <p>This method is static.
3484     *
3485     * @returns { IRemoteObject } Return an {@link IRemoteObject} reference of the registered service.
3486     * @syscap SystemCapability.Communication.IPC.Core
3487     * @since 7
3488     */
3489    static getContextObject(): IRemoteObject;
3490
3491    /**
3492     * Obtains the PID of a proxy.
3493     * <p>This method is static. The PID is a positive integer during the communication between
3494     * the {@link RemoteProxy} object and {@link RemoteObject} object, and resumes to {@code 0}
3495     * when the communication ends. If this method is called from the {@link RemoteProxy} object,
3496     * {@code 0} is returned; if this method is called from the {@link RemoteObject} object,
3497     * the PID of the corresponding {@link RemoteProxy} object is returned.
3498     *
3499     * @returns { number } Return the PID of the proxy.
3500     * @syscap SystemCapability.Communication.IPC.Core
3501     * @since 7
3502     */
3503    static getCallingPid(): number;
3504
3505    /**
3506     * Obtains the UID of a proxy.
3507     * <p>This method is static. The UID is a positive integer during the communication between
3508     * the {@link RemoteProxy} object and {@link RemoteObject} object, and resumes to {@code 0}
3509     * when the communication ends. If this method is called from the {@link RemoteProxy} object,
3510     * {@code 0} is returned; if this method is called from the {@link RemoteObject} object,
3511     * the UID of the corresponding {@link RemoteProxy} object is returned.
3512     *
3513     * @returns { number } Return the UID of the proxy.
3514     * @syscap SystemCapability.Communication.IPC.Core
3515     * @since 7
3516     */
3517    static getCallingUid(): number;
3518
3519    /**
3520     * Obtains the TOKENID.
3521     * <p>This method is static.
3522     *
3523     * @returns { number } Return the TOKENID.
3524     * @syscap SystemCapability.Communication.IPC.Core
3525     * @since 8
3526     */
3527    static getCallingTokenId(): number;
3528
3529    /**
3530     * Obtains the ID of the device where the peer process resides.
3531     * <p>This method is static.
3532     *
3533     * @returns { string } Return the ID of the device where the peer process resides.
3534     * @syscap SystemCapability.Communication.IPC.Core
3535     * @since 7
3536     */
3537    static getCallingDeviceID(): string;
3538
3539    /**
3540     * Obtains the ID of the local device.
3541     * <p>This method is static.
3542     *
3543     * @returns { string } Return the ID of the local device.
3544     * @syscap SystemCapability.Communication.IPC.Core
3545     * @since 7
3546     */
3547    static getLocalDeviceID(): string;
3548
3549    /**
3550     * Checks whether a call is made on the same device.
3551     * <p>This method is static.
3552     *
3553     * @returns { boolean } Return {@code true} if the call is made on the same device; return {@code false} otherwise.
3554     * @syscap SystemCapability.Communication.IPC.Core
3555     * @since 7
3556     */
3557    static isLocalCalling(): boolean;
3558
3559    /**
3560     * Flush all pending commands from a specified {@link RemoteProxy} to the corresponding {@link RemoteObject}.
3561     * <p>This method is static. You are advised to call this method before performing any time-sensitive operations.
3562     *
3563     * @param { IRemoteObject } object - Indicates the specified {@link RemoteProxy}.
3564     * @returns { number } Return {@code 0} if the operation succeeds; return an error code if the input object
3565     *                     is empty or {@link RemoteObject}, or the operation fails.
3566     * @syscap SystemCapability.Communication.IPC.Core
3567     * @since 7
3568     * @deprecated since 9
3569     * @useinstead ohos.rpc.IPCSkeleton#flushCmdBuffer
3570     */
3571    static flushCommands(object: IRemoteObject): number;
3572
3573    /**
3574     * Flush all pending commands from a specified {@link RemoteProxy} to the corresponding {@link RemoteObject}.
3575     * <p>This method is static. You are advised to call this method before performing any time-sensitive operations.
3576     *
3577     * @param { IRemoteObject } object - Indicates the specified {@link RemoteProxy}.
3578     * @throws { BusinessError } 401 - Parameter error. Possible causes:
3579     *     1.The number of parameters is incorrect;
3580     *     2.The parameter type does not match.
3581     * @syscap SystemCapability.Communication.IPC.Core
3582     * @since 9
3583     */
3584    static flushCmdBuffer(object: IRemoteObject): void;
3585
3586    /**
3587     * Replaces the UID and PID of the remote user with those of the local user.
3588     * <p>This method is static. It can be used in scenarios like authentication.
3589     *
3590     * @returns { string } Return a string containing the UID and PID of the remote user.
3591     * @syscap SystemCapability.Communication.IPC.Core
3592     * @since 7
3593     */
3594    static resetCallingIdentity(): string;
3595
3596    /**
3597     * Restore the UID and PID to those of the remote user.
3598     * <p>This method is static. It is usually called after {@code resetCallingIdentity} is used
3599     * and requires the UID and PID of the remote user returned by {@code resetCallingIdentity}.
3600     *
3601     * @param { string } identity - Indicates the string containing the UID and PID of the remote user,
3602     *                   which is returned by {@code resetCallingIdentity}.
3603     * @returns { boolean } Return {@code true} if the operation succeeds; return {@code false} otherwise.
3604     * @syscap SystemCapability.Communication.IPC.Core
3605     * @since 7
3606     * @deprecated since 9
3607     * @useinstead ohos.rpc.IPCSkeleton#restoreCallingIdentity
3608     */
3609    static setCallingIdentity(identity: string): boolean;
3610
3611    /**
3612     * Restore the UID and PID to those of the remote user.
3613     * <p>This method is static. It is usually called after {@code resetCallingIdentity} is used
3614     * and requires the UID and PID of the remote user returned by {@code resetCallingIdentity}.
3615     *
3616     * @param { string } identity - Indicates the string containing the UID and PID of the remote user,
3617     *                   which is returned by {@code resetCallingIdentity}.
3618     * @throws { BusinessError } 401 - Parameter error. Possible causes:
3619     *     1.The number of parameters is incorrect;
3620     *     2.The parameter type does not match;
3621     *     3.The string length exceeds 40960 bytes;
3622     *     4.The number of bytes copied to the buffer is different from the length of the obtained string.
3623     * @syscap SystemCapability.Communication.IPC.Core
3624     * @since 9
3625     */
3626    static restoreCallingIdentity(identity: string): void;
3627  }
3628
3629  /**
3630   * Provides methods related to anonymous shared memory objects,
3631   * including creating, closing, mapping, and unmapping an Ashmem object,
3632   * reading data from and writing data to an Ashmem object,
3633   * obtaining the Ashmem size, and setting Ashmem protection.
3634   *
3635   * @syscap SystemCapability.Communication.IPC.Core
3636   * @since 8
3637   */
3638  class Ashmem {
3639    /**
3640     * The mapped memory is executable.
3641     *
3642     * @type { number }
3643     * @default 4
3644     * @syscap SystemCapability.Communication.IPC.Core
3645     * @since 8
3646     */
3647    PROT_EXEC: number;
3648
3649    /**
3650     * The mapped memory is inaccessible.
3651     *
3652     * @type { number }
3653     * @default 0
3654     * @syscap SystemCapability.Communication.IPC.Core
3655     * @since 8
3656     */
3657    PROT_NONE: number;
3658
3659    /**
3660     * The mapped memory is readable.
3661     *
3662     * @type { number }
3663     * @default 1
3664     * @syscap SystemCapability.Communication.IPC.Core
3665     * @since 8
3666     */
3667    PROT_READ: number;
3668
3669    /**
3670     * The mapped memory is writable.
3671     *
3672     * @type { number }
3673     * @default 2
3674     * @syscap SystemCapability.Communication.IPC.Core
3675     * @since 8
3676     */
3677    PROT_WRITE: number;
3678
3679    /**
3680     * Creates an Ashmem object with the specified name and size.
3681     *
3682     * @param { string } name - Name of the Ashmem object to create.
3683     * @param { number } size - Size (in bytes) of the Ashmem object to create.
3684     * @returns { Ashmem } Return the Ashmem object if it is created successfully; return null otherwise.
3685     * @syscap SystemCapability.Communication.IPC.Core
3686     * @since 8
3687     * @deprecated since 9
3688     * @useinstead ohos.rpc.Ashmem#create
3689     */
3690    static createAshmem(name: string, size: number): Ashmem;
3691
3692    /**
3693     * Creates an Ashmem object with the specified name and size.
3694     *
3695     * @param { string } name - Name of the Ashmem object to create.
3696     * @param { number } size - Size (in bytes) of the Ashmem object to create.
3697     * @returns { Ashmem } Return the Ashmem object if it is created successfully; return null otherwise.
3698     * @throws { BusinessError } 401 - Parameter error. Possible causes:
3699     *     1.The number of parameters is incorrect;
3700     *     2.The parameter type does not match;
3701     *     3.The Ashmem name passed is empty;
3702     *     4.The Ashmem size passed is less than or equal to 0.
3703     * @syscap SystemCapability.Communication.IPC.Core
3704     * @since 9
3705     */
3706    static create(name: string, size: number): Ashmem;
3707
3708    /**
3709     * Creates an Ashmem object by copying the file descriptor (FD) of an existing Ashmem object.
3710     * The two Ashmem objects point to the same shared memory region.
3711     *
3712     * @param { Ashmem } ashmem - Existing Ashmem object.
3713     * @returns { Ashmem } Ashmem object created.
3714     * @syscap SystemCapability.Communication.IPC.Core
3715     * @since 8
3716     * @deprecated since 9
3717     * @useinstead ohos.rpc.Ashmem#create
3718     */
3719    static createAshmemFromExisting(ashmem: Ashmem): Ashmem;
3720
3721    /**
3722     * Creates an Ashmem object by copying the file descriptor (FD) of an existing Ashmem object.
3723     * The two Ashmem objects point to the same shared memory region.
3724     *
3725     * @param { Ashmem } ashmem - Existing Ashmem object.
3726     * @returns { Ashmem } Ashmem object created.
3727     * @throws { BusinessError } 401 - Parameter error. Possible causes:
3728     *     1.The number of parameters is incorrect;
3729     *     2.The passed parameter is not an Ahmem object;
3730     *     3.The ashmem instance for obtaining packaging is empty.
3731     * @syscap SystemCapability.Communication.IPC.Core
3732     * @since 9
3733     */
3734    static create(ashmem: Ashmem): Ashmem;
3735
3736    /**
3737     * Closes this Ashmem object.
3738     *
3739     * @syscap SystemCapability.Communication.IPC.Core
3740     * @since 8
3741     */
3742    closeAshmem(): void;
3743
3744    /**
3745     * Deletes the mappings for the specified address range of this Ashmem object.
3746     *
3747     * @syscap SystemCapability.Communication.IPC.Core
3748     * @since 8
3749     */
3750    unmapAshmem(): void;
3751
3752    /**
3753     * Obtains the mapped memory size of this Ashmem object.
3754     *
3755     * @returns { number } Memory size mapped.
3756     * @syscap SystemCapability.Communication.IPC.Core
3757     * @since 8
3758     */
3759    getAshmemSize(): number;
3760
3761    /**
3762     * Creates the shared file mapping on the virtual address space of this process.
3763     * The size of the mapping region is specified by this Ashmem object.
3764     *
3765     * @param { number } mapType - Protection level of the memory region to which the shared file is mapped.
3766     * @returns { boolean } Return {@code true} if the operation is successful; return {@code false} otherwise.
3767     * @syscap SystemCapability.Communication.IPC.Core
3768     * @since 8
3769     * @deprecated since 9
3770     * @useinstead ohos.rpc.Ashmem#mapTypedAshmem
3771     */
3772    mapAshmem(mapType: number): boolean;
3773
3774    /**
3775     * Creates the shared file mapping on the virtual address space of this process.
3776     * The size of the mapping region is specified by this Ashmem object.
3777     *
3778     * @param { number } mapType - Protection level of the memory region to which the shared file is mapped.
3779     * @throws { BusinessError } 401 - Parameter error. Possible causes:
3780     *     1.The number of parameters is incorrect;
3781     *     2.The parameter type does not match;
3782     *     3.The passed mapType exceeds the maximum protection level.
3783     * @throws { BusinessError } 1900001 - Failed to call mmap.
3784     * @syscap SystemCapability.Communication.IPC.Core
3785     * @since 9
3786     */
3787    mapTypedAshmem(mapType: number): void;
3788
3789    /**
3790     * Maps the shared file to the readable and writable virtual address space of the process.
3791     *
3792     * @returns { boolean } Return {@code true} if the operation is successful; return {@code false} otherwise.
3793     * @syscap SystemCapability.Communication.IPC.Core
3794     * @since 8
3795     * @deprecated since 9
3796     * @useinstead ohos.rpc.Ashmem#mapReadWriteAshmem
3797     */
3798    mapReadAndWriteAshmem(): boolean;
3799
3800    /**
3801     * Maps the shared file to the readable and writable virtual address space of the process.
3802     *
3803     * @throws { BusinessError } 1900001 - Failed to call mmap.
3804     * @syscap SystemCapability.Communication.IPC.Core
3805     * @since 9
3806     */
3807    mapReadWriteAshmem(): void;
3808
3809    /**
3810     * Maps the shared file to the read-only virtual address space of the process.
3811     *
3812     * @returns { boolean } Return {@code true} if the operation is successful; return {@code false} otherwise.
3813     * @syscap SystemCapability.Communication.IPC.Core
3814     * @since 8
3815     * @deprecated since 9
3816     * @useinstead ohos.rpc.Ashmem#mapReadonlyAshmem
3817     */
3818    mapReadOnlyAshmem(): boolean;
3819
3820    /**
3821     * Maps the shared file to the read-only virtual address space of the process.
3822     *
3823     * @throws { BusinessError } 1900001 - Failed to call mmap.
3824     * @syscap SystemCapability.Communication.IPC.Core
3825     * @since 9
3826     */
3827    mapReadonlyAshmem(): void;
3828
3829    /**
3830     * Sets the protection level of the memory region to which the shared file is mapped.
3831     *
3832     * @param { number } protectionType - Protection type to set.
3833     * @returns { boolean } Return true if the operation is successful; return false otherwise.
3834     * @syscap SystemCapability.Communication.IPC.Core
3835     * @since 8
3836     * @deprecated since 9
3837     * @useinstead ohos.rpc.Ashmem#setProtectionType
3838     */
3839    setProtection(protectionType: number): boolean;
3840
3841    /**
3842     * Sets the protection level of the memory region to which the shared file is mapped.
3843     *
3844     * @param { number } protectionType - Protection type to set.
3845     * @throws { BusinessError } 401 - Parameter error. Possible causes:
3846     *     1.The number of parameters is incorrect;
3847     *     2.The parameter type does not match.
3848     * @throws { BusinessError } 1900002 - Failed to call ioctl.
3849     * @syscap SystemCapability.Communication.IPC.Core
3850     * @since 9
3851     */
3852    setProtectionType(protectionType: number): void;
3853
3854    /**
3855     * Writes data to the shared file associated with this Ashmem object.
3856     *
3857     * @param { number[] } buf - Data to write.
3858     * @param { number } size - Size of the data to write.
3859     * @param { number } offset - Start position of the data to write in the memory region associated
3860     *                   with this Ashmem object.
3861     * @returns { boolean } Return {@code true} is the data is written successfully; return {@code false} otherwise.
3862     * @syscap SystemCapability.Communication.IPC.Core
3863     * @since 8
3864     * @deprecated since 9
3865     * @useinstead ohos.rpc.Ashmem#writeAshmem
3866     */
3867    writeToAshmem(buf: number[], size: number, offset: number): boolean;
3868
3869    /**
3870     * Writes data to the shared file associated with this Ashmem object.
3871     *
3872     * @param { number[] } buf - Data to write
3873     * @param { number } size - Size of the data to write
3874     * @param { number } offset - Start position of the data to write in the memory region associated
3875     *                   with this Ashmem object.
3876     * @throws { BusinessError } 401 - Parameter error. Possible causes:
3877     *     1.The number of parameters is incorrect;
3878     *     2.The parameter type does not match;
3879     *     3.The element does not exist in the array.
3880     * @throws { BusinessError } 1900003 - Failed to write data to the shared memory.
3881     * @syscap SystemCapability.Communication.IPC.Core
3882     * @since 9
3883     * @deprecated since 11
3884     * @useinstead ohos.rpc.Ashmem#writeDataToAshmem
3885     */
3886    writeAshmem(buf: number[], size: number, offset: number): void;
3887
3888    /**
3889     * Writes data to the shared file associated with this Ashmem object.
3890     *
3891     * @param { ArrayBuffer } buf - Data to write
3892     * @param { number } size - Size of the data to write
3893     * @param { number } offset - Start position of the data to write in the memory region associated
3894     *                   with this Ashmem object.
3895     * @throws { BusinessError } 401 - Parameter error. Possible causes:
3896     *     1.The number of parameters is incorrect;
3897     *     2.The parameter type does not match;
3898     *     3.Failed to obtain arrayBuffer information.
3899     * @throws { BusinessError } 1900003 - Failed to write data to the shared memory.
3900     * @syscap SystemCapability.Communication.IPC.Core
3901     * @since 11
3902     */
3903    writeDataToAshmem(buf: ArrayBuffer, size: number, offset: number): void;
3904
3905    /**
3906     * Reads data from the shared file associated with this Ashmem object.
3907     *
3908     * @param { number } size - Size of the data to read.
3909     * @param { number } offset - Start position of the data to read in the memory region associated
3910     *                   with this Ashmem object.
3911     * @returns { number[] } Data read.
3912     * @syscap SystemCapability.Communication.IPC.Core
3913     * @since 8
3914     * @deprecated since 9
3915     * @useinstead ohos.rpc.Ashmem#readAshmem
3916     */
3917    readFromAshmem(size: number, offset: number): number[];
3918
3919    /**
3920     * Reads data from the shared file associated with this Ashmem object.
3921     *
3922     * @param { number } size - Size of the data to read.
3923     * @param { number } offset - Start position of the data to read in the memory region associated
3924     *                   with this Ashmem object.
3925     * @returns { number[] } Data read.
3926     * @throws { BusinessError } 401 - Parameter error. Possible causes:
3927     *     1.The number of parameters is incorrect;
3928     *     2.The parameter type does not match.
3929     * @throws { BusinessError } 1900004 - Failed to read data from the shared memory.
3930     * @syscap SystemCapability.Communication.IPC.Core
3931     * @since 9
3932     * @deprecated since 11
3933     * @useinstead ohos.rpc.Ashmem#readDataFromAshmem
3934     */
3935    readAshmem(size: number, offset: number): number[];
3936
3937    /**
3938     * Reads data from the shared file associated with this Ashmem object.
3939     *
3940     * @param { number } size - Size of the data to read.
3941     * @param { number } offset - Start position of the data to read in the memory region associated
3942     *                   with this Ashmem object.
3943     * @returns { ArrayBuffer } Data read.
3944     * @throws { BusinessError } 401 - Parameter error. Possible causes:
3945     *     1.The number of parameters is incorrect;
3946     *     2.The parameter type does not match.
3947     * @throws { BusinessError } 1900004 - Failed to read data from the shared memory.
3948     * @syscap SystemCapability.Communication.IPC.Core
3949     * @since 11
3950     */
3951    readDataFromAshmem(size: number, offset: number): ArrayBuffer;
3952  }
3953}
3954
3955export default rpc;