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 * @throws { BusinessError } 1900009 - Failed to write data to the message sequence. 1270 * @syscap SystemCapability.Communication.IPC.Core 1271 * @since 9 1272 */ 1273 setSize(size: number): void; 1274 1275 /** 1276 * Sets the storage capacity (in bytes) of the {@link MessageSequence} object. 1277 * <p>{@code false} is returned if the capacity set in this method is less than 1278 * the size of data contained in the {@link MessageSequence}. 1279 * 1280 * @param { number } size - Indicates the storage capacity of the {@link MessageSequence} object. 1281 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1282 * 1.The number of parameters is incorrect; 1283 * 2.The parameter type does not match. 1284 * @throws { BusinessError } 1900009 - Failed to write data to the message sequence. 1285 * @throws { BusinessError } 1900011 - Memory allocation failed. 1286 * @syscap SystemCapability.Communication.IPC.Core 1287 * @since 9 1288 */ 1289 setCapacity(size: number): void; 1290 1291 /** 1292 * Obtains the writable data space (in bytes) in the {@link MessageSequence} object. 1293 * <p>Writable data space = Storage capacity of the {@link MessageSequence} – Size of data contained in 1294 * the {@link MessageSequence}. 1295 * 1296 * @returns { number } Return the writable data space of the {@link MessageSequence} object. 1297 * @syscap SystemCapability.Communication.IPC.Core 1298 * @since 9 1299 */ 1300 getWritableBytes(): number; 1301 1302 /** 1303 * Obtains the readable data space (in bytes) in the {@link MessageSequence} object. 1304 * <p>Readable data space = Size of data contained in the {@link MessageSequence} – Size of data that has been read. 1305 * 1306 * @returns { number } Return the readable data space of the {@link MessageSequence} object. 1307 * @syscap SystemCapability.Communication.IPC.Core 1308 * @since 9 1309 */ 1310 getReadableBytes(): number; 1311 1312 /** 1313 * Obtains the current read position in the {@link MessageSequence} object. 1314 * 1315 * @returns { number } Return the current read position in the {@link MessageSequence} object. 1316 * @syscap SystemCapability.Communication.IPC.Core 1317 * @since 9 1318 */ 1319 getReadPosition(): number; 1320 1321 /** 1322 * Obtains the current write position in the {@link MessageSequence} object. 1323 * 1324 * @returns { number } Return the current write position in the {@link MessageSequence} object. 1325 * @syscap SystemCapability.Communication.IPC.Core 1326 * @since 9 1327 */ 1328 getWritePosition(): number; 1329 1330 /** 1331 * Changes the current read position in the {@link MessageSequence} object. 1332 * <p>Generally, you are advised not to change the current read position. If you must 1333 * change it, change it to an accurate position. Otherwise, the read data may be incorrect. 1334 * 1335 * @param { number } pos - Indicates the target position to start data reading. 1336 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1337 * 1.The number of parameters is incorrect; 1338 * 2.The parameter type does not match. 1339 * @throws { BusinessError } 1900010 - Failed to read data from the message sequence. 1340 * @syscap SystemCapability.Communication.IPC.Core 1341 * @since 9 1342 */ 1343 rewindRead(pos: number): void; 1344 1345 /** 1346 * Changes the current write position in the {@link MessageSequence} object. 1347 * <p>Generally, you are advised not to change the current write position. If you must 1348 * change it, change it to an accurate position. Otherwise, the data to be read may be incorrect. 1349 * 1350 * @param { number } pos - Indicates the target position to start data writing. 1351 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1352 * 1.The number of parameters is incorrect; 1353 * 2.The parameter type does not match. 1354 * @throws { BusinessError } 1900009 - Failed to write data to the message sequence. 1355 * @syscap SystemCapability.Communication.IPC.Core 1356 * @since 9 1357 */ 1358 rewindWrite(pos: number): void; 1359 1360 /** 1361 * Writes information to this MessageSequence object indicating that no exception occurred. 1362 * <p>After handling requests, you should call this method before writing any data to reply 1363 * {@link MessageSequence}. 1364 * 1365 * @throws { BusinessError } 1900009 - Failed to write data to the message sequence. 1366 * @syscap SystemCapability.Communication.IPC.Core 1367 * @since 9 1368 */ 1369 writeNoException(): void; 1370 1371 /** 1372 * Reads the exception information from this MessageSequence object. 1373 * <p>If exception was thrown in server side, it will be thrown here. 1374 * This method should be called before reading any data from reply {@link MessageSequence} 1375 * if {@link writeNoException} was invoked in server side. 1376 * 1377 * @throws { BusinessError } 1900010 - Failed to read data from the message sequence. 1378 * @syscap SystemCapability.Communication.IPC.Core 1379 * @since 9 1380 */ 1381 readException(): void; 1382 1383 /** 1384 * Writes a byte value into the {@link MessageSequence} object. 1385 * 1386 * @param { number } val - Indicates the byte value to write. 1387 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1388 * 1.The number of parameters is incorrect; 1389 * 2.The parameter type does not match. 1390 * @throws { BusinessError } 1900009 - Failed to write data to the message sequence. 1391 * @syscap SystemCapability.Communication.IPC.Core 1392 * @since 9 1393 */ 1394 writeByte(val: number): void; 1395 1396 /** 1397 * Writes a short integer value into the {@link MessageSequence} object. 1398 * 1399 * @param { number } val - Indicates the short integer value to write. 1400 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1401 * 1.The number of parameters is incorrect; 1402 * 2.The parameter type does not match. 1403 * @throws { BusinessError } 1900009 - Failed to write data to the message sequence. 1404 * @syscap SystemCapability.Communication.IPC.Core 1405 * @since 9 1406 */ 1407 writeShort(val: number): void; 1408 1409 /** 1410 * Writes an integer value into the {@link MessageSequence} object. 1411 * 1412 * @param { number } val - Indicates the integer value to write. 1413 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1414 * 1.The number of parameters is incorrect; 1415 * 2.The parameter type does not match. 1416 * @throws { BusinessError } 1900009 - Failed to write data to the message sequence. 1417 * @syscap SystemCapability.Communication.IPC.Core 1418 * @since 9 1419 */ 1420 writeInt(val: number): void; 1421 1422 /** 1423 * Writes a long integer value into the {@link MessageSequence} object. 1424 * 1425 * @param { number } val - Indicates the long integer value to write. 1426 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1427 * 1.The number of parameters is incorrect; 1428 * 2.The parameter type does not match. 1429 * @throws { BusinessError } 1900009 - Failed to write data to the message sequence. 1430 * @syscap SystemCapability.Communication.IPC.Core 1431 * @since 9 1432 */ 1433 writeLong(val: number): void; 1434 1435 /** 1436 * Writes a floating point value into the {@link MessageSequence} object. 1437 * 1438 * @param { number } val - Indicates the floating point value to write. 1439 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1440 * 1.The number of parameters is incorrect; 1441 * 2.The parameter type does not match. 1442 * @throws { BusinessError } 1900009 - Failed to write data to the message sequence. 1443 * @syscap SystemCapability.Communication.IPC.Core 1444 * @since 9 1445 */ 1446 writeFloat(val: number): void; 1447 1448 /** 1449 * Writes a double-precision floating point value into the {@link MessageSequence} object. 1450 * 1451 * @param { number } val - Indicates the double-precision floating point value to write. 1452 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1453 * 1.The number of parameters is incorrect; 1454 * 2.The parameter type does not match. 1455 * @throws { BusinessError } 1900009 - Failed to write data to the message sequence. 1456 * @syscap SystemCapability.Communication.IPC.Core 1457 * @since 9 1458 */ 1459 writeDouble(val: number): void; 1460 1461 /** 1462 * Writes a boolean value into the {@link MessageSequence} object. 1463 * 1464 * @param { boolean } val - Indicates the boolean value to write. 1465 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1466 * 1.The number of parameters is incorrect; 1467 * 2.The parameter type does not match. 1468 * @throws { BusinessError } 1900009 - Failed to write data to the message sequence. 1469 * @syscap SystemCapability.Communication.IPC.Core 1470 * @since 9 1471 */ 1472 writeBoolean(val: boolean): void; 1473 1474 /** 1475 * Writes a single character value into the {@link MessageSequence} object. 1476 * 1477 * @param { number } val - Indicates the single character value to write. 1478 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1479 * 1.The number of parameters is incorrect; 1480 * 2.The parameter type does not match. 1481 * @throws { BusinessError } 1900009 - Failed to write data to the message sequence. 1482 * @syscap SystemCapability.Communication.IPC.Core 1483 * @since 9 1484 */ 1485 writeChar(val: number): void; 1486 1487 /** 1488 * Writes a string value into the {@link MessageSequence} object. 1489 * 1490 * @param { string } val - Indicates the string value to write. 1491 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1492 * 1.The number of parameters is incorrect; 1493 * 2.The parameter type does not match; 1494 * 3.The string length exceeds 40960 bytes; 1495 * 4.The number of bytes copied to the buffer is different from the length of the obtained string. 1496 * @throws { BusinessError } 1900009 - Failed to write data to the message sequence. 1497 * @syscap SystemCapability.Communication.IPC.Core 1498 * @since 9 1499 */ 1500 writeString(val: string): void; 1501 1502 /** 1503 * Writes a {@link Parcelable} object into the {@link MessageSequence} object. 1504 * 1505 * @param { Parcelable } val - Indicates the {@link Parcelable} object to write. 1506 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1507 * 1.The number of parameters is incorrect; 1508 * 2.The parameter type does not match. 1509 * @throws { BusinessError } 1900009 - Failed to write data to the message sequence. 1510 * @syscap SystemCapability.Communication.IPC.Core 1511 * @since 9 1512 */ 1513 writeParcelable(val: Parcelable): void; 1514 1515 /** 1516 * Writes a byte array into the {@link MessageSequence} object. 1517 * 1518 * @param { number[] } byteArray - Indicates the byte array to write. 1519 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1520 * 1.The parameter is an empty array; 1521 * 2.The number of parameters is incorrect; 1522 * 3.The parameter type does not match; 1523 * 4.The element does not exist in the array. 1524 * 5.The type of the element in the array is incorrect. 1525 * @throws { BusinessError } 1900009 - Failed to write data to the message sequence. 1526 * @syscap SystemCapability.Communication.IPC.Core 1527 * @since 9 1528 */ 1529 writeByteArray(byteArray: number[]): void; 1530 1531 /** 1532 * Writes a short integer array into the {@link MessageSequence} object. 1533 * Ensure that the data type and size comply with the interface definition. 1534 * Otherwise,data may be truncated. 1535 * 1536 * @param { number[] } shortArray - Indicates the short integer array to write. 1537 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1538 * 1.The parameter is an empty array; 1539 * 2.The number of parameters is incorrect; 1540 * 3.The parameter type does not match; 1541 * 4.The element does not exist in the array; 1542 * 5.The type of the element in the array is incorrect. 1543 * @throws { BusinessError } 1900009 - Failed to write data to the message sequence. 1544 * @syscap SystemCapability.Communication.IPC.Core 1545 * @since 9 1546 */ 1547 writeShortArray(shortArray: number[]): void; 1548 1549 /** 1550 * Writes an integer array into the {@link MessageSequence} object. 1551 * Ensure that the data type and size comply with the interface definition. 1552 * Otherwise,data may be truncated. 1553 * 1554 * @param { number[] } intArray - Indicates the integer array to write. 1555 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1556 * 1.The parameter is an empty array; 1557 * 2.The number of parameters is incorrect; 1558 * 3.The parameter type does not match; 1559 * 4.The element does not exist in the array; 1560 * 5.The type of the element in the array is incorrect. 1561 * @throws { BusinessError } 1900009 - Failed to write data to the message sequence. 1562 * @syscap SystemCapability.Communication.IPC.Core 1563 * @since 9 1564 */ 1565 writeIntArray(intArray: number[]): void; 1566 1567 /** 1568 * Writes a long integer array into the {@link MessageSequence} object. 1569 * Ensure that the data type and size comply with the interface definition. 1570 * Otherwise,data may be truncated. 1571 * 1572 * @param { number[] } longArray - Indicates the long integer array to write. 1573 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1574 * 1.The parameter is an empty array; 1575 * 2.The number of parameters is incorrect; 1576 * 3.The parameter type does not match; 1577 * 4.The element does not exist in the array; 1578 * 5.The type of the element in the array is incorrect. 1579 * @throws { BusinessError } 1900009 - Failed to write data to the message sequence. 1580 * @syscap SystemCapability.Communication.IPC.Core 1581 * @since 9 1582 */ 1583 writeLongArray(longArray: number[]): void; 1584 1585 /** 1586 * Writes a floating point array into the {@link MessageSequence} object. 1587 * Ensure that the data type and size comply with the interface definition. 1588 * Otherwise,data may be truncated. 1589 * 1590 * @param { number[] } floatArray - Indicates the floating point array to write. 1591 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1592 * 1.The parameter is an empty array; 1593 * 2.The number of parameters is incorrect; 1594 * 3.The parameter type does not match; 1595 * 4.The element does not exist in the array; 1596 * 5.The type of the element in the array is incorrect. 1597 * @throws { BusinessError } 1900009 - Failed to write data to the message sequence. 1598 * @syscap SystemCapability.Communication.IPC.Core 1599 * @since 9 1600 */ 1601 writeFloatArray(floatArray: number[]): void; 1602 1603 /** 1604 * Writes a double-precision floating point array into the {@link MessageSequence} object. 1605 * Ensure that the data type and size comply with the interface definition. 1606 * Otherwise,data may be truncated. 1607 * 1608 * @param { number[] } doubleArray - Indicates the double-precision floating point array to write. 1609 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1610 * 1.The parameter is an empty array; 1611 * 2.The number of parameters is incorrect; 1612 * 3.The parameter type does not match; 1613 * 4.The element does not exist in the array; 1614 * 5.The type of the element in the array is incorrect. 1615 * @throws { BusinessError } 1900009 - Failed to write data to the message sequence. 1616 * @syscap SystemCapability.Communication.IPC.Core 1617 * @since 9 1618 */ 1619 writeDoubleArray(doubleArray: number[]): void; 1620 1621 /** 1622 * Writes a boolean array into the {@link MessageSequence} object. 1623 * Ensure that the data type and size comply with the interface definition. 1624 * Otherwise,data may be truncated. 1625 * 1626 * @param { boolean[] } booleanArray - Indicates the boolean array to write. 1627 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1628 * 1.The parameter is an empty array; 1629 * 2.The number of parameters is incorrect; 1630 * 3.The parameter type does not match; 1631 * 4.The element does not exist in the array. 1632 * @throws { BusinessError } 1900009 - Failed to write data to the message sequence. 1633 * @syscap SystemCapability.Communication.IPC.Core 1634 * @since 9 1635 */ 1636 writeBooleanArray(booleanArray: boolean[]): void; 1637 1638 /** 1639 * Writes a single character array into the {@link MessageSequence} object. 1640 * Ensure that the data type and size comply with the interface definition. 1641 * Otherwise,data may be truncated. 1642 * 1643 * @param { number[] } charArray - Indicates the single character array to write. 1644 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1645 * 1.The parameter is an empty array; 1646 * 2.The number of parameters is incorrect; 1647 * 3.The parameter type does not match; 1648 * 4.The element does not exist in the array. 1649 * @throws { BusinessError } 1900009 - Failed to write data to the message sequence. 1650 * @syscap SystemCapability.Communication.IPC.Core 1651 * @since 9 1652 */ 1653 writeCharArray(charArray: number[]): void; 1654 1655 /** 1656 * Writes a string array into the {@link MessageSequence} object. 1657 * Ensure that the data type and size comply with the interface definition. 1658 * Otherwise,data may be truncated. 1659 * 1660 * @param { string[] } stringArray - Indicates the string array to write. 1661 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1662 * 1.The parameter is an empty array; 1663 * 2.The number of parameters is incorrect; 1664 * 3.The parameter type does not match; 1665 * 4.The string length exceeds 40960 bytes; 1666 * 5.The number of bytes copied to the buffer is different from the length of the obtained string. 1667 * @throws { BusinessError } 1900009 - Failed to write data to the message sequence. 1668 * @syscap SystemCapability.Communication.IPC.Core 1669 * @since 9 1670 */ 1671 writeStringArray(stringArray: string[]): void; 1672 1673 /** 1674 * Writes a {@link Parcelable} object array into the {@link MessageSequence} object. 1675 * 1676 * @param { Parcelable[] } parcelableArray - Indicates the {@link Parcelable} object array to write. 1677 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1678 * 1.The parameter is an empty array; 1679 * 2.The number of parameters is incorrect; 1680 * 3.The parameter type does not match; 1681 * 4.The element does not exist in the array. 1682 * @throws { BusinessError } 1900009 - Failed to write data to the message sequence. 1683 * @syscap SystemCapability.Communication.IPC.Core 1684 * @since 9 1685 */ 1686 writeParcelableArray(parcelableArray: Parcelable[]): void; 1687 1688 /** 1689 * Writes an array of {@link IRemoteObject} objects to this {@link MessageSequence} object. 1690 * 1691 * @param { IRemoteObject[] } objectArray - Array of {@link IRemoteObject} objects to write. 1692 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1693 * 1.The parameter is an empty array; 1694 * 2.The number of parameters is incorrect; 1695 * 3.The parameter type does not match; 1696 * 4.The element does not exist in the array; 1697 * 5.The obtained remoteObject is null. 1698 * @throws { BusinessError } 1900009 - Failed to write data to the message sequence. 1699 * @syscap SystemCapability.Communication.IPC.Core 1700 * @since 9 1701 */ 1702 writeRemoteObjectArray(objectArray: IRemoteObject[]): void; 1703 1704 /** 1705 * Reads a byte value from the {@link MessageSequence} object. 1706 * 1707 * @returns { number } Return a byte value. 1708 * @throws { BusinessError } 1900010 - Failed to read data from the message sequence. 1709 * @syscap SystemCapability.Communication.IPC.Core 1710 * @since 9 1711 */ 1712 readByte(): number; 1713 1714 /** 1715 * Reads a short integer value from the {@link MessageSequence} object. 1716 * 1717 * @returns { number } Return a short integer value. 1718 * @throws { BusinessError } 1900010 - Failed to read data from the message sequence. 1719 * @syscap SystemCapability.Communication.IPC.Core 1720 * @since 9 1721 */ 1722 readShort(): number; 1723 1724 /** 1725 * Reads an integer value from the {@link MessageSequence} object. 1726 * 1727 * @returns { number } Return an integer value. 1728 * @throws { BusinessError } 1900010 - Failed to read data from the message sequence. 1729 * @syscap SystemCapability.Communication.IPC.Core 1730 * @since 9 1731 */ 1732 readInt(): number; 1733 1734 /** 1735 * Reads a long integer value from the {@link MessageSequence} object. 1736 * 1737 * @returns { number } Return a long integer value. 1738 * @throws { BusinessError } 1900010 - Failed to read data from the message sequence. 1739 * @syscap SystemCapability.Communication.IPC.Core 1740 * @since 9 1741 */ 1742 readLong(): number; 1743 1744 /** 1745 * Reads a floating point value from the {@link MessageSequence} object. 1746 * 1747 * @returns { number } Return a floating point value. 1748 * @throws { BusinessError } 1900010 - Failed to read data from the message sequence. 1749 * @syscap SystemCapability.Communication.IPC.Core 1750 * @since 9 1751 */ 1752 readFloat(): number; 1753 1754 /** 1755 * Reads a double-precision floating point value from the {@link MessageSequence} object. 1756 * 1757 * @returns { number } Return a double-precision floating point value. 1758 * @throws { BusinessError } 1900010 - Failed to read data from the message sequence. 1759 * @syscap SystemCapability.Communication.IPC.Core 1760 * @since 9 1761 */ 1762 readDouble(): number; 1763 1764 /** 1765 * Reads a boolean value from the {@link MessageSequence} object. 1766 * 1767 * @returns { boolean } Return a boolean value. 1768 * @throws { BusinessError } 1900010 - Failed to read data from the message sequence. 1769 * @syscap SystemCapability.Communication.IPC.Core 1770 * @since 9 1771 */ 1772 readBoolean(): boolean; 1773 1774 /** 1775 * Reads a single character value from the {@link MessageSequence} object. 1776 * 1777 * @returns { number } Return a single character value. 1778 * @throws { BusinessError } 1900010 - Failed to read data from the message sequence. 1779 * @syscap SystemCapability.Communication.IPC.Core 1780 * @since 9 1781 */ 1782 readChar(): number; 1783 1784 /** 1785 * Reads a string value from the {@link MessageSequence} object. 1786 * 1787 * @returns { string } Return a string value. 1788 * @throws { BusinessError } 1900010 - Failed to read data from the message sequence. 1789 * @syscap SystemCapability.Communication.IPC.Core 1790 * @since 9 1791 */ 1792 readString(): string; 1793 1794 /** 1795 * Reads a {@link Parcelable} object from the {@link MessageSequence} instance. 1796 * 1797 * @param { Parcelable } dataIn - Indicates the {@link Parcelable} object that needs to perform 1798 * the {@code unmarshalling} operation using the {@link MessageSequence}. 1799 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1800 * 1.The number of parameters is incorrect. 1801 * @throws { BusinessError } 1900010 - Failed to read data from the message sequence. 1802 * @throws { BusinessError } 1900012 - Failed to call the JS callback function. 1803 * @syscap SystemCapability.Communication.IPC.Core 1804 * @since 9 1805 */ 1806 readParcelable(dataIn: Parcelable): void; 1807 1808 /** 1809 * Writes a byte array into the {@link MessageSequence} object. 1810 * 1811 * @param { number[] } dataIn - Indicates the byte array read from MessageSequence. 1812 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1813 * 1.The parameter is an empty array; 1814 * 2.The number of parameters is incorrect; 1815 * 3.The parameter type does not match. 1816 * @throws { BusinessError } 1900010 - Failed to read data from the message sequence. 1817 * @syscap SystemCapability.Communication.IPC.Core 1818 * @since 9 1819 */ 1820 readByteArray(dataIn: number[]): void; 1821 1822 /** 1823 * Reads a byte array from the {@link MessageSequence} object. 1824 * 1825 * @returns { number[] } Return a byte array. 1826 * @throws { BusinessError } 1900010 - Failed to read data from the message sequence. 1827 * @syscap SystemCapability.Communication.IPC.Core 1828 * @since 9 1829 */ 1830 readByteArray(): number[]; 1831 1832 /** 1833 * Reads a short integer array from the {@link MessageSequence} object. 1834 * 1835 * @param { number[] } dataIn - Indicates the short integer array read from MessageSequence. 1836 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1837 * 1.The parameter is an empty array; 1838 * 2.The number of parameters is incorrect; 1839 * 3.The parameter type does not match. 1840 * @throws { BusinessError } 1900010 - Failed to read data from the message sequence. 1841 * @syscap SystemCapability.Communication.IPC.Core 1842 * @since 9 1843 */ 1844 readShortArray(dataIn: number[]): void; 1845 1846 /** 1847 * Reads a short integer array from the {@link MessageSequence} object. 1848 * 1849 * @returns { number[] } Return a short integer array. 1850 * @throws { BusinessError } 1900010 - Failed to read data from the message sequence. 1851 * @syscap SystemCapability.Communication.IPC.Core 1852 * @since 9 1853 */ 1854 readShortArray(): number[]; 1855 1856 /** 1857 * Reads an integer array from the {@link MessageSequence} object. 1858 * 1859 * @param { number[] } dataIn - Indicates the integer array to read. 1860 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1861 * 1.The parameter is an empty array; 1862 * 2.The number of parameters is incorrect; 1863 * 3.The parameter type does not match. 1864 * @throws { BusinessError } 1900010 - Failed to read data from the message sequence. 1865 * @syscap SystemCapability.Communication.IPC.Core 1866 * @since 9 1867 */ 1868 readIntArray(dataIn: number[]): void; 1869 1870 /** 1871 * Reads an integer array from the {@link MessageSequence} object. 1872 * 1873 * @returns { number[] } Return an integer array. 1874 * @throws { BusinessError } 1900010 - Failed to read data from the message sequence. 1875 * @syscap SystemCapability.Communication.IPC.Core 1876 * @since 9 1877 */ 1878 readIntArray(): number[]; 1879 1880 /** 1881 * Reads a long integer array from the {@link MessageSequence} object. 1882 * 1883 * @param { number[] } dataIn - Indicates the long integer array to read. 1884 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1885 * 1.The parameter is an empty array; 1886 * 2.The number of parameters is incorrect; 1887 * 3.The parameter type does not match. 1888 * @throws { BusinessError } 1900010 - Failed to read data from the message sequence. 1889 * @syscap SystemCapability.Communication.IPC.Core 1890 * @since 9 1891 */ 1892 readLongArray(dataIn: number[]): void; 1893 1894 /** 1895 * Reads a long integer array from the {@link MessageSequence} object. 1896 * 1897 * @returns { number[] } Return a long integer array. 1898 * @throws { BusinessError } 1900010 - Failed to read data from the message sequence. 1899 * @syscap SystemCapability.Communication.IPC.Core 1900 * @since 9 1901 */ 1902 readLongArray(): number[]; 1903 1904 /** 1905 * Reads a floating point array from the {@link MessageSequence} object. 1906 * 1907 * @param { number[] } dataIn - Indicates the floating point array to read. 1908 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1909 * 1.The parameter is an empty array; 1910 * 2.The number of parameters is incorrect; 1911 * 3.The parameter type does not match. 1912 * @throws { BusinessError } 1900010 - Failed to read data from the message sequence. 1913 * @syscap SystemCapability.Communication.IPC.Core 1914 * @since 9 1915 */ 1916 readFloatArray(dataIn: number[]): void; 1917 1918 /** 1919 * Reads a floating point array from the {@link MessageSequence} object. 1920 * 1921 * @returns { number[] } Return a floating point array. 1922 * @throws { BusinessError } 1900010 - Failed to read data from the message sequence. 1923 * @syscap SystemCapability.Communication.IPC.Core 1924 * @since 9 1925 */ 1926 readFloatArray(): number[]; 1927 1928 /** 1929 * Reads a double-precision floating point array from the {@link MessageSequence} object. 1930 * 1931 * @param { number[] } dataIn - Indicates the double-precision floating point array to read. 1932 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1933 * 1.The parameter is an empty array; 1934 * 2.The number of parameters is incorrect; 1935 * 3.The parameter type does not match. 1936 * @throws { BusinessError } 1900010 - Failed to read data from the message sequence. 1937 * @syscap SystemCapability.Communication.IPC.Core 1938 * @since 9 1939 */ 1940 readDoubleArray(dataIn: number[]): void; 1941 1942 /** 1943 * Reads a double-precision floating point array from the {@link MessageSequence} object. 1944 * 1945 * @returns { number[] } Return a double-precision floating point array. 1946 * @throws { BusinessError } 1900010 - Failed to read data from the message sequence. 1947 * @syscap SystemCapability.Communication.IPC.Core 1948 * @since 9 1949 */ 1950 readDoubleArray(): number[]; 1951 1952 /** 1953 * Reads a boolean array from the {@link MessageSequence} object. 1954 * 1955 * @param { boolean[] } dataIn - Indicates the boolean array to read. 1956 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1957 * 1.The parameter is an empty array; 1958 * 2.The number of parameters is incorrect; 1959 * 3.The parameter type does not match. 1960 * @throws { BusinessError } 1900010 - Failed to read data from the message sequence. 1961 * @syscap SystemCapability.Communication.IPC.Core 1962 * @since 9 1963 */ 1964 readBooleanArray(dataIn: boolean[]): void; 1965 1966 /** 1967 * Reads a boolean array from the {@link MessageSequence} object. 1968 * 1969 * @returns { boolean[] } Return a boolean array. 1970 * @throws { BusinessError } 1900010 - Failed to read data from the message sequence. 1971 * @syscap SystemCapability.Communication.IPC.Core 1972 * @since 9 1973 */ 1974 readBooleanArray(): boolean[]; 1975 1976 /** 1977 * Reads a single character array from the {@link MessageSequence} object. 1978 * 1979 * @param { number[] } dataIn - Indicates the single character array to read. 1980 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1981 * 1.The parameter is an empty array; 1982 * 2.The number of parameters is incorrect; 1983 * 3.The parameter type does not match. 1984 * @throws { BusinessError } 1900010 - Failed to read data from the message sequence. 1985 * @syscap SystemCapability.Communication.IPC.Core 1986 * @since 9 1987 */ 1988 readCharArray(dataIn: number[]): void; 1989 1990 /** 1991 * Reads a single character array from the {@link MessageSequence} object. 1992 * 1993 * @returns { number[] } Return a single character array. 1994 * @throws { BusinessError } 1900010 - Failed to read data from the message sequence. 1995 * @syscap SystemCapability.Communication.IPC.Core 1996 * @since 9 1997 */ 1998 readCharArray(): number[]; 1999 2000 /** 2001 * Reads a string array from the {@link MessageSequence} object. 2002 * 2003 * @param { string[] } dataIn - Indicates the string array to read. 2004 * @throws { BusinessError } 401 - Parameter error. Possible causes: 2005 * 1.The parameter is an empty array; 2006 * 2.The number of parameters is incorrect; 2007 * 3.The parameter type does not match. 2008 * @throws { BusinessError } 1900010 - Failed to read data from the message sequence. 2009 * @syscap SystemCapability.Communication.IPC.Core 2010 * @since 9 2011 */ 2012 readStringArray(dataIn: string[]): void; 2013 2014 /** 2015 * Reads a string array from the {@link MessageSequence} object. 2016 * 2017 * @returns { string[] } Return a string array. 2018 * @throws { BusinessError } 1900010 - Failed to read data from the message sequence. 2019 * @syscap SystemCapability.Communication.IPC.Core 2020 * @since 9 2021 */ 2022 readStringArray(): string[]; 2023 2024 /** 2025 * Reads the specified {@link Parcelable} array from this {@link MessageSequence} object. 2026 * 2027 * @param { Parcelable[] } parcelableArray - Parcelable array to read. 2028 * @throws { BusinessError } 401 - Parameter error. Possible causes: 2029 * 1.The parameter is an empty array; 2030 * 2.The number of parameters is incorrect; 2031 * 3.The parameter type does not match; 2032 * 4.The length of the array passed when reading is not equal to the length passed when writing to the array; 2033 * 5.The element does not exist in the array. 2034 * @throws { BusinessError } 1900010 - Failed to read data from the message sequence. 2035 * @throws { BusinessError } 1900012 - Failed to call the JS callback function. 2036 * @syscap SystemCapability.Communication.IPC.Core 2037 * @since 9 2038 */ 2039 readParcelableArray(parcelableArray: Parcelable[]): void; 2040 2041 /** 2042 * Reads the specified {@link IRemoteObject} array from this {@link MessageSequence} object. 2043 * 2044 * @param { IRemoteObject[] } objects - Reads data from this {@link MessageSequence} object to 2045 * the specified {@link IRemoteObject} array. 2046 * @throws { BusinessError } 401 - Parameter error. Possible causes: 2047 * 1.The parameter is an empty array; 2048 * 2.The number of parameters is incorrect; 2049 * 3.The parameter type does not match; 2050 * 4.The length of the array passed when reading is not equal to the length passed when writing to the array. 2051 * @throws { BusinessError } 1900010 - Failed to read data from the message sequence. 2052 * @syscap SystemCapability.Communication.IPC.Core 2053 * @since 9 2054 */ 2055 readRemoteObjectArray(objects: IRemoteObject[]): void; 2056 2057 /** 2058 * Reads {@link IRemoteObject} objects from this {@link MessageSequence} object. 2059 * 2060 * @returns { IRemoteObject[] } Return an array of {@link IRemoteObject} objects obtained. 2061 * @throws { BusinessError } 1900010 - Failed to read data from the message sequence. 2062 * @syscap SystemCapability.Communication.IPC.Core 2063 * @since 9 2064 */ 2065 readRemoteObjectArray(): IRemoteObject[]; 2066 2067 /** 2068 * Closes the specified file descriptor. 2069 * 2070 * @param { number } fd - File descriptor to be closed. 2071 * @throws { BusinessError } 401 - Parameter error. Possible causes: 2072 * 1.The number of parameters is incorrect; 2073 * 2.The parameter type does not match. 2074 * @syscap SystemCapability.Communication.IPC.Core 2075 * @since 9 2076 */ 2077 static closeFileDescriptor(fd: number): void; 2078 2079 /** 2080 * Duplicates the specified file descriptor. 2081 * 2082 * @param { number } fd - File descriptor to be duplicated. 2083 * @returns { number } Return a duplicated file descriptor. 2084 * @throws { BusinessError } 401 - Parameter error. Possible causes: 2085 * 1.The number of parameters is incorrect; 2086 * 2.The parameter type does not match. 2087 * @throws { BusinessError } 1900013 - Failed to call dup. 2088 * @syscap SystemCapability.Communication.IPC.Core 2089 * @since 9 2090 */ 2091 static dupFileDescriptor(fd: number): number; 2092 2093 /** 2094 * Checks whether this {@link MessageSequence} object contains a file descriptor. 2095 * 2096 * @returns { boolean } Return {@code true} if the {@link MessageSequence} object contains a file descriptor; 2097 * return {@code false} otherwise. 2098 * @syscap SystemCapability.Communication.IPC.Core 2099 * @since 9 2100 */ 2101 containFileDescriptors(): boolean; 2102 2103 /** 2104 * Writes a file descriptor to this {@link MessageSequence} object. 2105 * 2106 * @param { number } fd - File descriptor to wrote. 2107 * @throws { BusinessError } 401 - Parameter error. Possible causes: 2108 * 1.The number of parameters is incorrect; 2109 * 2.The parameter type does not match. 2110 * @throws { BusinessError } 1900009 - Failed to write data to the message sequence. 2111 * @syscap SystemCapability.Communication.IPC.Core 2112 * @since 9 2113 */ 2114 writeFileDescriptor(fd: number): void; 2115 2116 /** 2117 * Reads a file descriptor from this {@link MessageSequence} object. 2118 * 2119 * @returns { number } Return a file descriptor obtained. 2120 * @throws { BusinessError } 1900010 - Failed to read data from the message sequence. 2121 * @syscap SystemCapability.Communication.IPC.Core 2122 * @since 9 2123 */ 2124 readFileDescriptor(): number; 2125 2126 /** 2127 * Writes an anonymous shared memory object to this {@link MessageSequence} object. 2128 * 2129 * @param { Ashmem } ashmem - Anonymous shared memory object to wrote. 2130 * @throws { BusinessError } 401 - Parameter error. Possible causes: 2131 * 1.The number of parameters is incorrect; 2132 * 2.The parameter is not an instance of the Ashmem object. 2133 * @throws { BusinessError } 1900009 - Failed to write data to the message sequence. 2134 * @syscap SystemCapability.Communication.IPC.Core 2135 * @since 9 2136 */ 2137 writeAshmem(ashmem: Ashmem): void; 2138 2139 /** 2140 * Reads the anonymous shared memory object from this {@link MessageSequence} object. 2141 * 2142 * @returns { Ashmem } Return the anonymous share object obtained. 2143 * @throws { BusinessError } 1900010 - Failed to read data from the message sequence. 2144 * @syscap SystemCapability.Communication.IPC.Core 2145 * @since 9 2146 */ 2147 readAshmem(): Ashmem; 2148 2149 /** 2150 * Obtains the maximum amount of raw data that can be sent in a time. 2151 * 2152 * @returns { number } 128 MB. 2153 * @syscap SystemCapability.Communication.IPC.Core 2154 * @since 9 2155 */ 2156 getRawDataCapacity(): number; 2157 2158 /** 2159 * Writes raw data to this {@link MessageSequence} object. 2160 * 2161 * @param { number[] } rawData - Raw data to wrote. 2162 * @param { number } size - Size of the raw data, in bytes. 2163 * @throws { BusinessError } 401 - Parameter error. Possible causes: 2164 * 1.The parameter is an empty array; 2165 * 2.The number of parameters is incorrect; 2166 * 3.The parameter type does not match; 2167 * 4.The transferred size cannot be obtained; 2168 * 5.The transferred size is less than or equal to 0; 2169 * 6.The element does not exist in the array; 2170 * 7.Failed to obtain typedArray information; 2171 * 8.The array is not of type int32; 2172 * 9.The length of typedarray is smaller than the size of the original data sent. 2173 * @throws { BusinessError } 1900009 - Failed to write data to the message sequence. 2174 * @syscap SystemCapability.Communication.IPC.Core 2175 * @since 9 2176 * @deprecated since 11 2177 * @useinstead ohos.rpc.MessageSequence#writeRawDataBuffer 2178 */ 2179 writeRawData(rawData: number[], size: number): void; 2180 2181 /** 2182 * Writes raw data to this {@link MessageSequence} object. 2183 * 2184 * @param { ArrayBuffer } rawData - Raw data to wrote. 2185 * @param { number } size - Size of the raw data, in bytes. 2186 * @throws { BusinessError } 401 - Parameter error. Possible causes: 2187 * 1.The number of parameters is incorrect; 2188 * 2.The parameter type does not match; 2189 * 3.Failed to obtain arrayBuffer information; 2190 * 4.The transferred size cannot be obtained; 2191 * 5.The transferred size is less than or equal to 0; 2192 * 6.The transferred size is greater than the byte length of ArrayBuffer. 2193 * @throws { BusinessError } 1900009 - Failed to write data to the message sequence. 2194 * @syscap SystemCapability.Communication.IPC.Core 2195 * @since 11 2196 */ 2197 writeRawDataBuffer(rawData: ArrayBuffer, size: number): void; 2198 2199 /** 2200 * Reads raw data from this {@link MessageSequence} object. 2201 * 2202 * @param { number } size - Size of the raw data to read. 2203 * @returns { number[] } Return the raw data obtained, in bytes. 2204 * @throws { BusinessError } 401 - Parameter error. Possible causes: 2205 * 1.The number of parameters is incorrect; 2206 * 2.The parameter type does not match. 2207 * @throws { BusinessError } 1900010 - Failed to read data from the message sequence. 2208 * @syscap SystemCapability.Communication.IPC.Core 2209 * @since 9 2210 * @deprecated since 11 2211 * @useinstead ohos.rpc.MessageSequence#readRawDataBuffer 2212 */ 2213 readRawData(size: number): number[]; 2214 2215 /** 2216 * Reads raw data from this {@link MessageSequence} object. 2217 * 2218 * @param { number } size - Size of the raw data to read. 2219 * @returns { ArrayBuffer } Return the raw data obtained, in bytes. 2220 * @throws { BusinessError } 401 - Parameter error. Possible causes: 2221 * 1.The number of parameters is incorrect; 2222 * 2.The parameter type does not match. 2223 * @throws { BusinessError } 1900010 - Failed to read data from the message sequence. 2224 * @syscap SystemCapability.Communication.IPC.Core 2225 * @since 11 2226 */ 2227 readRawDataBuffer(size: number): ArrayBuffer; 2228 2229 /** 2230 * Writes the data in an ArrayBuffer object into this {@Link MessageSequence} object. 2231 * 2232 * @param { ArrayBuffer } buf - Data to write. 2233 * @param { TypeCode } typeCode - Type of the ArrayBuffer data to write. 2234 * @throws { BusinessError } 401 - Parameter error. Possible causes: 2235 * 1.The parameter is an empty array; 2236 * 2.The number of parameters is incorrect; 2237 * 3.The parameter type does not match; 2238 * 4.The obtained value of typeCode is incorrect; 2239 * 5.Failed to obtain arrayBuffer information. 2240 * @throws { BusinessError } 1900009 - Failed to write data to the message sequence. 2241 * @syscap SystemCapability.Communication.IPC.Core 2242 * @since 12 2243 */ 2244 writeArrayBuffer(buf: ArrayBuffer, typeCode: TypeCode): void; 2245 2246 /** 2247 * Reads raw data from this {@link MessageSequence} object. 2248 * 2249 * @param { TypeCode } typeCode - Type of the ArrayBuffer read. 2250 * @returns { ArrayBuffer } Returns the Arraybuffer obtained. 2251 * @throws { BusinessError } 401 - Parameter error. Possible causes: 2252 * 1.The number of parameters is incorrect; 2253 * 2.The parameter type does not match; 2254 * 3.The obtained value of typeCode is incorrect; 2255 * @throws { BusinessError } 1900010 - Failed to read data from the message sequence. 2256 * @syscap SystemCapability.Communication.IPC.Core 2257 * @since 12 2258 */ 2259 readArrayBuffer(typeCode: TypeCode): ArrayBuffer; 2260 } 2261 2262 /** 2263 * @typedef Sequenceable 2264 * @syscap SystemCapability.Communication.IPC.Core 2265 * @since 7 2266 * @deprecated since 9 2267 * @useinstead ohos.rpc.Parcelable 2268 */ 2269 interface Sequenceable { 2270 /** 2271 * Marshal this {@code Sequenceable} object into a {@link MessageParcel}. 2272 * 2273 * @param { MessageParcel } dataOut - Indicates the {@link MessageParcel} object to which the {@code Sequenceable} 2274 * object will be marshalled. 2275 * @returns { boolean } Return {@code true} if the marshalling is successful; return {@code false} otherwise. 2276 * @syscap SystemCapability.Communication.IPC.Core 2277 * @since 7 2278 * @deprecated since 9 2279 */ 2280 marshalling(dataOut: MessageParcel): boolean; 2281 2282 /** 2283 * Unmarshal this {@code Sequenceable} object from a {@link MessageParcel}. 2284 * 2285 * @param { MessageParcel } dataIn - Indicates the {@link MessageParcel} object into which the {@code Sequenceable} 2286 * object has been marshalled. 2287 * @returns { boolean } Return {@code true} if the unmarshalling is successful; return {@code false} otherwise. 2288 * @syscap SystemCapability.Communication.IPC.Core 2289 * @since 7 2290 * @deprecated since 9 2291 */ 2292 unmarshalling(dataIn: MessageParcel): boolean; 2293 } 2294 2295 /** 2296 * @typedef Parcelable 2297 * @syscap SystemCapability.Communication.IPC.Core 2298 * @since 9 2299 */ 2300 /** 2301 * During inter-process communication, objects of the class are written to the {@link MessageSequence} and 2302 * they are recovered from the {@link MessageSequence}. 2303 * 2304 * @typedef Parcelable 2305 * @syscap SystemCapability.Communication.IPC.Core 2306 * @since 11 2307 */ 2308 interface Parcelable { 2309 /** 2310 * Marshal this {@code Parcelable} object into a {@link MessageSequence}. 2311 * 2312 * @param { MessageSequence } dataOut - Indicates the {@link MessageSequence} object to which the {@code Parcelable} 2313 * object will be marshalled. 2314 * @returns { boolean } Return {@code true} if the marshalling is successful; return {@code false} otherwise. 2315 * @syscap SystemCapability.Communication.IPC.Core 2316 * @since 9 2317 */ 2318 marshalling(dataOut: MessageSequence): boolean; 2319 2320 /** 2321 * Unmarshal this {@code Parcelable} object from a {@link MessageSequence}. 2322 * 2323 * @param { MessageSequence } dataIn - Indicates the {@link MessageSequence} object into 2324 * which the {@code Parcelable} object has been marshalled. 2325 * @returns { boolean } Return {@code true} if the unmarshalling is successful; return {@code false} otherwise. 2326 * @syscap SystemCapability.Communication.IPC.Core 2327 * @since 9 2328 */ 2329 unmarshalling(dataIn: MessageSequence): boolean; 2330 } 2331 2332 /** 2333 * Defines the response to the request. 2334 * <p> SendRequestResult object contains four members, namely error code of this operation, request code, data parcel 2335 * and reply parcel. 2336 * 2337 * @typedef SendRequestResult 2338 * @syscap SystemCapability.Communication.IPC.Core 2339 * @since 8 2340 * @deprecated since 9 2341 * @useinstead ohos.rpc.RequestResult 2342 */ 2343 interface SendRequestResult { 2344 /** 2345 * Error code. 0 indicates successful, otherwise it is failed. 2346 * 2347 * @type { number } 2348 * @syscap SystemCapability.Communication.IPC.Core 2349 * @since 8 2350 * @deprecated since 9 2351 */ 2352 errCode: number; 2353 2354 /** 2355 * Message code. It is same as the code in {@link SendRequest} method. 2356 * 2357 * @type { number } 2358 * @syscap SystemCapability.Communication.IPC.Core 2359 * @since 8 2360 * @deprecated since 9 2361 */ 2362 code: number; 2363 2364 /** 2365 * MessageParcel object sent to the peer process. 2366 * It is the same object in {@link SendRequest} method. 2367 * 2368 * @type { MessageParcel } 2369 * @syscap SystemCapability.Communication.IPC.Core 2370 * @since 8 2371 * @deprecated since 9 2372 */ 2373 data: MessageParcel; 2374 2375 /** 2376 * MessageParcel object returned by the peer process. 2377 * It is the same object in {@link SendRequest} method. 2378 * 2379 * @type { MessageParcel } 2380 * @syscap SystemCapability.Communication.IPC.Core 2381 * @since 8 2382 * @deprecated since 9 2383 */ 2384 reply: MessageParcel; 2385 } 2386 2387 /** 2388 * Defines the response to the request. 2389 * <p> SendRequestResult object contains four members, namely error code of this operation, request code, data parcel 2390 * and reply parcel. 2391 * 2392 * @typedef RequestResult 2393 * @syscap SystemCapability.Communication.IPC.Core 2394 * @since 9 2395 */ 2396 interface RequestResult { 2397 /** 2398 * Error code. 0 indicates successful, otherwise it is failed. 2399 * 2400 * @type { number } 2401 * @syscap SystemCapability.Communication.IPC.Core 2402 * @since 9 2403 */ 2404 errCode: number; 2405 2406 /** 2407 * Message code. It is same as the code in {@link SendRequest} method. 2408 * 2409 * @type { number } 2410 * @syscap SystemCapability.Communication.IPC.Core 2411 * @since 9 2412 */ 2413 code: number; 2414 2415 /** 2416 * MessageSequence object sent to the peer process. 2417 * It is the same object in {@link SendRequest} method. 2418 * 2419 * @type { MessageSequence } 2420 * @syscap SystemCapability.Communication.IPC.Core 2421 * @since 9 2422 */ 2423 data: MessageSequence; 2424 2425 /** 2426 * MessageSequence object returned by the peer process. 2427 * It is the same object in {@link SendRequest} method. 2428 * 2429 * @type { MessageSequence } 2430 * @syscap SystemCapability.Communication.IPC.Core 2431 * @since 9 2432 */ 2433 reply: MessageSequence; 2434 } 2435 2436 /** 2437 * @syscap SystemCapability.Communication.IPC.Core 2438 * @since 7 2439 */ 2440 /** 2441 * Used to query or get interface descriptors, add or remove death notifications, dump object status to 2442 * a specific file, and send messages. 2443 * 2444 * @syscap SystemCapability.Communication.IPC.Core 2445 * @since 11 2446 */ 2447 abstract class IRemoteObject { 2448 /** 2449 * Queries the description of an interface. 2450 * <p>A valid {@link IRemoteBroker} object is returned for an interface used by the service provider; 2451 * {@code null} is returned for an interface used by the service user, 2452 * indicating that the interface is not a local one. 2453 * 2454 * @param { string } descriptor - Indicates the interface descriptor. 2455 * @returns { IRemoteBroker } Return the {@link IRemoteBroker} object bound to the specified interface descriptor. 2456 * @syscap SystemCapability.Communication.IPC.Core 2457 * @since 7 2458 * @deprecated since 9 2459 * @useinstead ohos.rpc.IRemoteObject#getLocalInterface 2460 */ 2461 queryLocalInterface(descriptor: string): IRemoteBroker; 2462 2463 /** 2464 * Queries the description of an interface. 2465 * <p>A valid {@link IRemoteBroker} object is returned for an interface used by the service provider; 2466 * {@code null} is returned for an interface used by the service user, 2467 * indicating that the interface is not a local one. 2468 * 2469 * @param { string } descriptor - Indicates the interface descriptor. 2470 * @returns { IRemoteBroker } Return the {@link IRemoteBroker} object bound to the specified interface descriptor. 2471 * @throws { BusinessError } 401 - Parameter error. Possible causes: 2472 * 1.The number of parameters is incorrect; 2473 * 2.The parameter type does not match; 2474 * 3.The string length exceeds 40960 bytes; 2475 * 4.The number of bytes copied to the buffer is different from the length of the obtained string. 2476 * @syscap SystemCapability.Communication.IPC.Core 2477 * @since 9 2478 */ 2479 getLocalInterface(descriptor: string): IRemoteBroker; 2480 2481 /** 2482 * Sends a {@link MessageParcel} message to the peer process in synchronous or asynchronous mode. 2483 * <p>If asynchronous mode is set for {@code option}, a response is returned immediately. 2484 * If synchronous mode is set for {@code option}, the interface will wait for a response from the peer process 2485 * until the request times out. The user must prepare {@code reply} for receiving the execution result 2486 * given by the peer process. 2487 * 2488 * @param { number } code - Indicates the message code, which is determined by both sides of the communication. 2489 * If the interface is generated by the IDL tool, the message code is automatically generated by IDL. 2490 * @param { MessageParcel } data - Indicates the {@link MessageParcel} object sent to the peer process. 2491 * @param { MessageParcel } reply - Indicates the {@link MessageParcel} object returned by the peer process. 2492 * @param { MessageOption } options - Indicates the synchronous or asynchronous mode to send messages. 2493 * @returns { boolean } Return {@code true} if the method is called successfully; return {@code false} otherwise. 2494 * @syscap SystemCapability.Communication.IPC.Core 2495 * @since 7 2496 * @deprecated since 9 2497 */ 2498 sendRequest(code: number, data: MessageParcel, reply: MessageParcel, options: MessageOption): boolean; 2499 2500 /** 2501 * Sends a {@link MessageParcel} message to the peer process in synchronous or asynchronous mode. 2502 * <p>If options indicates the asynchronous mode, a promise will be fulfilled immediately 2503 * and the reply message does not contain any content. If options indicates the synchronous mode, 2504 * a promise will be fulfilled when the response to sendRequest is returned, 2505 * and the reply message contains the returned information. 2506 * 2507 * @param { number } code - Message code called by the request, which is determined by the client and server. 2508 * If the method is generated by an IDL tool, the message code is automatically generated by the IDL tool. 2509 * @param { MessageParcel } data - {@link MessageParcel} object holding the data to send. 2510 * @param { MessageParcel } reply - {@link MessageParcel} object that receives the response. 2511 * @param { MessageOption } options - Indicates the synchronous or asynchronous mode to send messages. 2512 * @returns { Promise<SendRequestResult> } Promise used to return the {@link SendRequestResult} instance. 2513 * @syscap SystemCapability.Communication.IPC.Core 2514 * @since 8 2515 * @deprecated since 9 2516 * @useinstead ohos.rpc.IRemoteObject#sendMessageRequest 2517 */ 2518 sendRequest( 2519 code: number, 2520 data: MessageParcel, 2521 reply: MessageParcel, 2522 options: MessageOption 2523 ): Promise<SendRequestResult>; 2524 2525 /** 2526 * Sends a {@link MessageSequence} message to the peer process asynchronously. 2527 * <p>If options indicates the asynchronous mode, a promise will be fulfilled immediately 2528 * and the reply message does not contain any content. If options indicates the synchronous mode, 2529 * a promise will be fulfilled when the response to sendMessageRequest is returned, 2530 * and the reply message contains the returned information. 2531 * 2532 * @param { number } code - Message code called by the request, which is determined by the client and server. 2533 * If the method is generated by an IDL tool, the message code is automatically generated by the IDL tool. 2534 * @param {MessageSequence } data - {@link MessageSequence} object holding the data to send. 2535 * @param {MessageSequence } reply - {@link MessageSequence} object that receives the response. 2536 * @param { MessageOption } options - Indicates the synchronous or asynchronous mode to send messages. 2537 * @returns { Promise<RequestResult> } Promise used to return the {@link RequestResult} instance. 2538 * @throws { BusinessError } 401 - Parameter error. Possible causes: 2539 * 1.The number of parameters is incorrect; 2540 * 2.The parameter type does not match; 2541 * 3.Failed to obtain the passed object instance. 2542 * @syscap SystemCapability.Communication.IPC.Core 2543 * @since 9 2544 */ 2545 sendMessageRequest( 2546 code: number, 2547 data: MessageSequence, 2548 reply: MessageSequence, 2549 options: MessageOption 2550 ): Promise<RequestResult>; 2551 2552 /** 2553 * Sends a {@link MessageParcel} message to the peer process in synchronous or asynchronous mode. 2554 * <p>If options indicates the asynchronous mode, a callback will be invoked immediately 2555 * and the reply message does not contain any content. If options indicates the synchronous mode, 2556 * a callback will be invoked when the response to sendRequest is returned, 2557 * and the reply message contains the returned information. 2558 * 2559 * @param { number } code - Message code called by the request, which is determined by the client and server. 2560 * If the method is generated by an IDL tool, the message code is automatically generated by the IDL tool. 2561 * @param { MessageParcel } data - {@link MessageParcel} object holding the data to send. 2562 * @param { MessageParcel } reply - {@link MessageParcel} object that receives the response. 2563 * @param { MessageOption } options - Indicates the synchronous or asynchronous mode to send messages. 2564 * @param { AsyncCallback<SendRequestResult> } callback - Callback for receiving the sending result. 2565 * @syscap SystemCapability.Communication.IPC.Core 2566 * @since 8 2567 * @deprecated since 9 2568 * @useinstead ohos.rpc.IRemoteObject#sendMessageRequest 2569 */ 2570 sendRequest( 2571 code: number, 2572 data: MessageParcel, 2573 reply: MessageParcel, 2574 options: MessageOption, 2575 callback: AsyncCallback<SendRequestResult> 2576 ): void; 2577 2578 /** 2579 * Sends a {@link MessageSequence} message to the peer process in synchronous or asynchronous mode. 2580 * <p>If options indicates the asynchronous mode, a callback will be invoked immediately 2581 * and the reply message does not contain any content. If options indicates the synchronous mode, 2582 * a callback will be invoked when the response to sendMessageRequest is returned, 2583 * and the reply message contains the returned information. 2584 * 2585 * @param {number } code - Message code called by the request, which is determined by the client and server. 2586 * If the method is generated by an IDL tool, the message code is automatically generated by the IDL tool. 2587 * @param { MessageSequence } data - {@link MessageSequence} object holding the data to send. 2588 * @param { MessageSequence } reply - {@link MessageSequence} object that receives the response. 2589 * @param { MessageOption } options - Indicates the synchronous or asynchronous mode to send messages. 2590 * @param { AsyncCallback<RequestResult> } callback - Callback for receiving the sending result. 2591 * @throws { BusinessError } 401 - Parameter error. Possible causes: 2592 * 1.The number of parameters is incorrect; 2593 * 2.The parameter type does not match; 2594 * 3.Failed to obtain the passed object instance. 2595 * @syscap SystemCapability.Communication.IPC.Core 2596 * @since 9 2597 */ 2598 sendMessageRequest( 2599 code: number, 2600 data: MessageSequence, 2601 reply: MessageSequence, 2602 options: MessageOption, 2603 callback: AsyncCallback<RequestResult> 2604 ): void; 2605 2606 /** 2607 * Register a callback used to receive notifications of the death of a remote object. 2608 * 2609 * @param { DeathRecipient } recipient - Indicates the callback to be registered. 2610 * @param { number } flags - Indicates the flag of the death notification. 2611 * @returns { boolean } Return {@code true} if the callback is registered successfully; 2612 * return {@code false} otherwise. 2613 * @syscap SystemCapability.Communication.IPC.Core 2614 * @since 7 2615 * @deprecated since 9 2616 * @useinstead ohos.rpc.IRemoteObject#registerDeathRecipient 2617 */ 2618 addDeathRecipient(recipient: DeathRecipient, flags: number): boolean; 2619 2620 /** 2621 * Register a callback used to receive notifications of the death of a remote object. 2622 * 2623 * @param { DeathRecipient } recipient - Indicates the callback to be registered. 2624 * @param { number } flags - Indicates the flag of the death notification. 2625 * @throws { BusinessError } 401 - Parameter error. Possible causes: 2626 * 1.The number of parameters is incorrect; 2627 * 2.The parameter type does not match; 2628 * 3.The callback used to receive remote object death notifications is empty. 2629 * @throws { BusinessError } 1900005 - Operation allowed only for the proxy object. 2630 * @throws { BusinessError } 1900008 - The proxy or remote object is invalid. 2631 * @syscap SystemCapability.Communication.IPC.Core 2632 * @since 9 2633 */ 2634 registerDeathRecipient(recipient: DeathRecipient, flags: number): void; 2635 2636 /** 2637 * Unregister a callback used to receive notifications of the death of a remote object. 2638 * 2639 * @param { DeathRecipient } recipient - Indicates the callback to be unregister. 2640 * @param { number } flags - Indicates the flag of the death notification. 2641 * @returns { boolean } Return {@code true} if the callback is unregister successfully; 2642 * return {@code false} otherwise. 2643 * @syscap SystemCapability.Communication.IPC.Core 2644 * @since 7 2645 * @deprecated since 9 2646 * @useinstead ohos.rpc.IRemoteObject#unregisterDeathRecipient 2647 */ 2648 removeDeathRecipient(recipient: DeathRecipient, flags: number): boolean; 2649 2650 /** 2651 * Unregister a callback used to receive notifications of the death of a remote object. 2652 * 2653 * @param { DeathRecipient } recipient - Indicates the callback to be unregister. 2654 * @param { number } flags - Indicates the flag of the death notification. 2655 * @throws { BusinessError } 401 - Parameter error. Possible causes: 2656 * 1.The number of parameters is incorrect; 2657 * 2.The parameter type does not match; 2658 * 3.The callback used to receive remote object death notifications is empty. 2659 * @throws { BusinessError } 1900005 - Operation allowed only for the proxy object. 2660 * @throws { BusinessError } 1900008 - The proxy or remote object is invalid. 2661 * @syscap SystemCapability.Communication.IPC.Core 2662 * @since 9 2663 */ 2664 unregisterDeathRecipient(recipient: DeathRecipient, flags: number): void; 2665 2666 /** 2667 * Obtains the interface descriptor of an object. 2668 * <p>The interface descriptor is a character string. 2669 * 2670 * @returns { string } Return the interface descriptor. 2671 * @syscap SystemCapability.Communication.IPC.Core 2672 * @since 7 2673 * @deprecated since 9 2674 * @useinstead ohos.rpc.IRemoteObject#getDescriptor 2675 */ 2676 getInterfaceDescriptor(): string; 2677 2678 /** 2679 * Obtains the interface descriptor of an object. 2680 * <p>The interface descriptor is a character string. 2681 * 2682 * @returns { string } Return the interface descriptor. 2683 * @throws { BusinessError } 1900008 - The proxy or remote object is invalid. 2684 * @syscap SystemCapability.Communication.IPC.Core 2685 * @since 9 2686 */ 2687 getDescriptor(): string; 2688 2689 /** 2690 * Checks whether an object is dead. 2691 * 2692 * @returns { boolean } Return {@code true} if the object is dead; return {@code false} otherwise. 2693 * @syscap SystemCapability.Communication.IPC.Core 2694 * @since 7 2695 */ 2696 isObjectDead(): boolean; 2697 } 2698 2699 /** 2700 * @typedef IRemoteBroker 2701 * @syscap SystemCapability.Communication.IPC.Core 2702 * @since 7 2703 */ 2704 /** 2705 * Used to define the communication interface of the IPC communication objects. 2706 * 2707 * @typedef IRemoteBroker 2708 * @syscap SystemCapability.Communication.IPC.Core 2709 * @since 11 2710 */ 2711 interface IRemoteBroker { 2712 /** 2713 * Obtains a proxy or remote object. This method must be implemented by its derived classes. 2714 * 2715 * @returns { IRemoteObject } Return the RemoteObject if the caller is a RemoteObject; return the IRemoteObject, 2716 * that is, the holder of this RemoteProxy object, if the caller is a RemoteProxy object. 2717 * @syscap SystemCapability.Communication.IPC.Core 2718 * @since 7 2719 */ 2720 asObject(): IRemoteObject; 2721 } 2722 2723 /** 2724 * @typedef DeathRecipient 2725 * @syscap SystemCapability.Communication.IPC.Core 2726 * @since 7 2727 */ 2728 /** 2729 * Used to subscribe to death notifications for remote objects. 2730 * <p> 2731 * When a remote object subscribed to the notification dies, the local end can receive a message and call 2732 * the onRemoteDied operation. The death of a remote object can be caused by the death of the process to which the 2733 * remote object belongs, the shutdown or restart of the device to which the remote object belongs, 2734 * or the death of the remote object when the remote object and the local object belong to different devices, 2735 * and when the remote object leaves the network. 2736 * </p> 2737 * 2738 * @typedef DeathRecipient 2739 * @syscap SystemCapability.Communication.IPC.Core 2740 * @since 11 2741 */ 2742 interface DeathRecipient { 2743 /** 2744 * Called to perform subsequent operations when a death notification of the remote object is received. 2745 * 2746 * @syscap SystemCapability.Communication.IPC.Core 2747 * @since 7 2748 */ 2749 onRemoteDied(): void; 2750 } 2751 2752 /** 2753 * @syscap SystemCapability.Communication.IPC.Core 2754 * @since 7 2755 */ 2756 /** 2757 * Public Message Option, using the specified flag type, constructs the specified MessageOption object. 2758 * 2759 * @syscap SystemCapability.Communication.IPC.Core 2760 * @since 11 2761 */ 2762 class MessageOption { 2763 /** 2764 * Indicates synchronous call. 2765 * 2766 * @type { number } 2767 * @default 0 2768 * @static 2769 * @syscap SystemCapability.Communication.IPC.Core 2770 * @since 7 2771 */ 2772 static TF_SYNC: number; 2773 2774 /** 2775 * Indicates asynchronous call. 2776 * 2777 * @type { number } 2778 * @default 1 2779 * @static 2780 * @syscap SystemCapability.Communication.IPC.Core 2781 * @since 7 2782 */ 2783 static TF_ASYNC: number; 2784 2785 /** 2786 * Indicates the sendRequest API for returning the file descriptor. 2787 * 2788 * @type { number } 2789 * @default 16 2790 * @static 2791 * @syscap SystemCapability.Communication.IPC.Core 2792 * @since 7 2793 */ 2794 static TF_ACCEPT_FDS: number; 2795 2796 /** 2797 * Indicates the wait time for RPC, in seconds. It is NOT used in IPC case. 2798 * 2799 * @default 4 2800 * @static 2801 * @syscap SystemCapability.Communication.IPC.Core 2802 * @since 7 2803 */ 2804 /** 2805 * Indicates the wait time for RPC, in seconds. It is NOT used in IPC case. 2806 * 2807 * @type { number } 2808 * @default 8 2809 * @static 2810 * @syscap SystemCapability.Communication.IPC.Core 2811 * @since 11 2812 */ 2813 static TF_WAIT_TIME: number; 2814 2815 /** 2816 * A constructor used to create a MessageOption instance. 2817 * 2818 * @param { number } syncFlags - Specifies whether the SendRequest is called synchronously (default) or asynchronously. 2819 * @param { number } waitTime - Maximum wait time for a RPC call. The default value is TF_WAIT_TIME. 2820 * @syscap SystemCapability.Communication.IPC.Core 2821 * @since 7 2822 */ 2823 constructor(syncFlags?: number, waitTime?: number); 2824 2825 /** 2826 * A constructor used to create a MessageOption instance. 2827 * 2828 * @param { boolean } async - Specifies whether the SendRequest is called synchronously (default) or asynchronously. 2829 * @syscap SystemCapability.Communication.IPC.Core 2830 * @since 9 2831 */ 2832 constructor(async?: boolean); 2833 2834 /** 2835 * Obtains the SendRequest call flag, which can be synchronous or asynchronous. 2836 * 2837 * @returns { number } Return whether the SendRequest is called synchronously or asynchronously. 2838 * @syscap SystemCapability.Communication.IPC.Core 2839 * @since 7 2840 */ 2841 getFlags(): number; 2842 2843 /** 2844 * Sets the SendRequest call flag, which can be synchronous or asynchronous. 2845 * 2846 * @param { number } flags - Indicates the call flag, which can be synchronous or asynchronous. 2847 * @syscap SystemCapability.Communication.IPC.Core 2848 * @since 7 2849 */ 2850 setFlags(flags: number): void; 2851 2852 /** 2853 * Obtains the SendRequest call flag, which can be synchronous or asynchronous. 2854 * 2855 * @returns { boolean } Return {@code true} if the asynchronous call succeeds; 2856 * return {@code false} if the synchronous call succeeds. 2857 * @syscap SystemCapability.Communication.IPC.Core 2858 * @since 9 2859 */ 2860 isAsync(): boolean; 2861 2862 /** 2863 * Sets the SendRequest call flag, which can be synchronous or asynchronous. 2864 * 2865 * @param { boolean } async - Indicates the call flag, which can be synchronous or asynchronous. 2866 * @syscap SystemCapability.Communication.IPC.Core 2867 * @since 9 2868 */ 2869 setAsync(async: boolean): void; 2870 2871 /** 2872 * Obtains the maximum wait time for this RPC call. 2873 * 2874 * @returns { number } Return maximum wait time obtained. 2875 * @syscap SystemCapability.Communication.IPC.Core 2876 * @since 7 2877 */ 2878 getWaitTime(): number; 2879 2880 /** 2881 * Sets the maximum wait time for this RPC call. 2882 * 2883 * @param { number } waitTime - Indicates maximum wait time to set. 2884 * @syscap SystemCapability.Communication.IPC.Core 2885 * @since 7 2886 */ 2887 setWaitTime(waitTime: number): void; 2888 } 2889 2890 /** 2891 * @extends IRemoteObject 2892 * @syscap SystemCapability.Communication.IPC.Core 2893 * @since 7 2894 */ 2895 /** 2896 * Implement remote objects. The service provider must inherit this class. 2897 * 2898 * @extends IRemoteObject 2899 * @syscap SystemCapability.Communication.IPC.Core 2900 * @since 11 2901 */ 2902 class RemoteObject extends IRemoteObject { 2903 /** 2904 * A constructor to create a RemoteObject instance. 2905 * 2906 * @param { string } descriptor - Specifies interface descriptor. 2907 * @syscap SystemCapability.Communication.IPC.Core 2908 * @since 7 2909 */ 2910 constructor(descriptor: string); 2911 2912 /** 2913 * Queries a remote object using an interface descriptor. 2914 * 2915 * @param { string } descriptor - Indicates the interface descriptor used to query the remote object. 2916 * @returns { IRemoteBroker } Return the remote object matching the interface descriptor; 2917 * return null if no such remote object is found. 2918 * @syscap SystemCapability.Communication.IPC.Core 2919 * @since 7 2920 * @deprecated since 9 2921 * @useinstead ohos.rpc.RemoteObject#getLocalInterface 2922 */ 2923 queryLocalInterface(descriptor: string): IRemoteBroker; 2924 2925 /** 2926 * Queries a remote object using an interface descriptor. 2927 * 2928 * @param { string } descriptor - Indicates the interface descriptor used to query the remote object. 2929 * @returns { IRemoteBroker } Return the remote object matching the interface descriptor; 2930 * return null if no such remote object is found. 2931 * @throws { BusinessError } 401 - Parameter error. Possible causes: 2932 * 1.The number of parameters is incorrect; 2933 * 2.The parameter type does not match; 2934 * 3.The string length exceeds 40960 bytes; 2935 * 4.The number of bytes copied to the buffer is different from the length of the obtained string. 2936 * @syscap SystemCapability.Communication.IPC.Core 2937 * @since 9 2938 */ 2939 getLocalInterface(descriptor: string): IRemoteBroker; 2940 2941 /** 2942 * Queries an interface descriptor. 2943 * 2944 * @returns { string } Return the interface descriptor. 2945 * @syscap SystemCapability.Communication.IPC.Core 2946 * @since 7 2947 * @deprecated since 9 2948 * @useinstead ohos.rpc.RemoteObject#getDescriptor 2949 */ 2950 getInterfaceDescriptor(): string; 2951 2952 /** 2953 * Queries an interface descriptor. 2954 * 2955 * @returns { string } Return the interface descriptor. 2956 * @throws { BusinessError } 1900008 - The proxy or remote object is invalid. 2957 * @syscap SystemCapability.Communication.IPC.Core 2958 * @since 9 2959 */ 2960 getDescriptor(): string; 2961 2962 /** 2963 * Sets an entry for receiving requests. 2964 * <p>This method is implemented by the remote service provider. You need to override this method with 2965 * your own service logic when you are using IPC. 2966 * 2967 * @param { number } code - Indicates the service request code sent from the peer end. 2968 * @param { MessageSequence } data - Indicates the {@link MessageSequence} object sent from the peer end. 2969 * @param { MessageSequence } reply - Indicates the response message object sent from the remote service. 2970 * The local service writes the response data to the {@link MessageSequence} object. 2971 * @param { MessageOption } options - Indicates whether the operation is synchronous or asynchronous. 2972 * @returns { boolean | Promise<boolean> } 2973 * Return a simple boolean which is {@code true} if the operation succeeds; 2974 * {{@code false} otherwise} when the function call is synchronous. 2975 * Return a promise object with a boolean when the function call is asynchronous. 2976 * @syscap SystemCapability.Communication.IPC.Core 2977 * @since 9 2978 */ 2979 onRemoteMessageRequest( 2980 code: number, 2981 data: MessageSequence, 2982 reply: MessageSequence, 2983 options: MessageOption 2984 ): boolean | Promise<boolean>; 2985 2986 /** 2987 * Sets an entry for receiving requests. 2988 * <p>This method is implemented by the remote service provider. You need to override this method with 2989 * your own service logic when you are using IPC. 2990 * 2991 * @param { number } code - Indicates the service request code sent from the peer end. 2992 * @param { MessageParcel } data - Indicates the {@link MessageParcel} object sent from the peer end. 2993 * @param { MessageParcel } reply - Indicates the response message object sent from the remote service. 2994 * The local service writes the response data to the {@link MessageParcel} object. 2995 * @param { MessageOption } options - Indicates whether the operation is synchronous or asynchronous. 2996 * @returns { boolean } Return {@code true} if the operation succeeds; return {@code false} otherwise. 2997 * @syscap SystemCapability.Communication.IPC.Core 2998 * @since 7 2999 * @deprecated since 9 3000 * @useinstead ohos.rpc.RemoteObject#onRemoteMessageRequest 3001 */ 3002 onRemoteRequest(code: number, data: MessageParcel, reply: MessageParcel, options: MessageOption): boolean; 3003 3004 /** 3005 * Sends a request to the peer object. 3006 * <p>If the peer object and {@code RemoteObject} are on the same device, the request is sent by the IPC driver. 3007 * If they are on different devices, the request is sent by the socket driver. 3008 * 3009 * @param { number } code - Indicates the message code of the request. 3010 * @param { MessageParcel } data - Indicates the {@link MessageParcel} object storing the data to be sent. 3011 * @param { MessageParcel } reply - Indicates the {@link MessageParcel} object receiving the response data. 3012 * @param { MessageOption } options - Indicates a synchronous (default) or asynchronous request. 3013 * @returns { boolean } Return {@code true} if the operation succeeds; return {@code false} otherwise. 3014 * @syscap SystemCapability.Communication.IPC.Core 3015 * @since 7 3016 * @deprecated since 8 3017 */ 3018 sendRequest(code: number, data: MessageParcel, reply: MessageParcel, options: MessageOption): boolean; 3019 3020 /** 3021 * Sends a {@link MessageParcel} message to the peer process in synchronous or asynchronous mode. 3022 * <p>If options indicates the asynchronous mode, a promise will be fulfilled immediately 3023 * and the reply message does not contain any content. If options indicates the synchronous mode, 3024 * a promise will be fulfilled when the response to sendRequest is returned, 3025 * and the reply message contains the returned information. 3026 * 3027 * @param { number } code - Message code called by the request, which is determined by the client and server. 3028 * If the method is generated by an IDL tool, the message code is automatically generated by the IDL tool. 3029 * @param { MessageParcel } data - {@link MessageParcel} object holding the data to send. 3030 * @param { MessageParcel } reply - {@link MessageParcel} object that receives the response. 3031 * @param { MessageOption } options - Indicates the synchronous or asynchronous mode to send messages. 3032 * @returns { Promise<SendRequestResult> } Promise used to return the {@link SendRequestResult} instance. 3033 * @syscap SystemCapability.Communication.IPC.Core 3034 * @since 8 3035 * @deprecated since 9 3036 * @useinstead ohos.rpc.RemoteObject#sendMessageRequest 3037 */ 3038 sendRequest( 3039 code: number, 3040 data: MessageParcel, 3041 reply: MessageParcel, 3042 options: MessageOption 3043 ): Promise<SendRequestResult>; 3044 3045 /** 3046 * Sends a {@link MessageSequence} message to the peer process in synchronous or asynchronous mode. 3047 * <p>If options indicates the asynchronous mode, a promise will be fulfilled immediately 3048 * and the reply message does not contain any content. If options indicates the synchronous mode, 3049 * a promise will be fulfilled when the response to sendMessageRequest is returned, 3050 * and the reply message contains the returned information. 3051 * 3052 * @param { number } code - Message code called by the request, which is determined by the client and server. 3053 * If the method is generated by an IDL tool, the message code is automatically generated by the IDL tool. 3054 * @param { MessageSequence } data - {@link MessageSequence} object holding the data to send. 3055 * @param { MessageSequence } reply - {@link MessageSequence} object that receives the response. 3056 * @param { MessageOption } options - Indicates the synchronous or asynchronous mode to send messages. 3057 * @returns { Promise<RequestResult> } Promise used to return the {@link RequestResult} instance. 3058 * @throws { BusinessError } 401 - Parameter error. Possible causes: 3059 * 1.The number of parameters is incorrect; 3060 * 2.The parameter type does not match; 3061 * 3.Failed to obtain the passed object instance. 3062 * @syscap SystemCapability.Communication.IPC.Core 3063 * @since 9 3064 */ 3065 sendMessageRequest( 3066 code: number, 3067 data: MessageSequence, 3068 reply: MessageSequence, 3069 options: MessageOption 3070 ): Promise<RequestResult>; 3071 3072 /** 3073 * Sends a {@link MessageParcel} message to the peer process in synchronous or asynchronous mode. 3074 * <p>If options indicates the asynchronous mode, a callback will be invoked immediately 3075 * and the reply message does not contain any content. If options indicates the synchronous mode, 3076 * a callback will be invoked when the response to sendRequest is returned, 3077 * and the reply message contains the returned information. 3078 * 3079 * @param { number } code - Message code called by the request, which is determined by the client and server. 3080 * If the method is generated by an IDL tool, the message code is automatically generated by the IDL tool. 3081 * @param { MessageParcel } data - {@link MessageParcel} object holding the data to send. 3082 * @param { MessageParcel} reply - {@link MessageParcel} object that receives the response. 3083 * @param { MessageOption } options - Indicates the synchronous or asynchronous mode to send messages. 3084 * @param { AsyncCallback<SendRequestResult> } callback - Callback for receiving the sending result. 3085 * @syscap SystemCapability.Communication.IPC.Core 3086 * @since 8 3087 * @deprecated since 9 3088 * @useinstead ohos.rpc.RemoteObject#sendMessageRequest 3089 */ 3090 sendRequest( 3091 code: number, 3092 data: MessageParcel, 3093 reply: MessageParcel, 3094 options: MessageOption, 3095 callback: AsyncCallback<SendRequestResult> 3096 ): void; 3097 3098 /** 3099 * Sends a {@link MessageSequence} message to the peer process in synchronous or asynchronous mode. 3100 * <p>If options indicates the asynchronous mode, a callback will be invoked immediately 3101 * and the reply message does not contain any content. If options indicates the synchronous mode, 3102 * a callback will be invoked when the response to sendMessageRequest is returned, 3103 * and the reply message contains the returned information. 3104 * 3105 * @param { number } code - Message code called by the request, which is determined by the client and server. 3106 * If the method is generated by an IDL tool, the message code is automatically generated by the IDL tool. 3107 * @param { MessageSequence } data - {@link MessageSequence} object holding the data to send. 3108 * @param { MessageSequence } reply - {@link MessageSequence} object that receives the response. 3109 * @param { MessageOption } options - Indicates the synchronous or asynchronous mode to send messages. 3110 * @param { AsyncCallback<RequestResult> } callback - Callback for receiving the sending result. 3111 * @throws { BusinessError } 401 - Parameter error. Possible causes: 3112 * 1.The number of parameters is incorrect; 3113 * 2.The parameter type does not match; 3114 * 3.Failed to obtain the passed object instance. 3115 * @syscap SystemCapability.Communication.IPC.Core 3116 * @since 9 3117 */ 3118 sendMessageRequest( 3119 code: number, 3120 data: MessageSequence, 3121 reply: MessageSequence, 3122 options: MessageOption, 3123 callback: AsyncCallback<RequestResult> 3124 ): void; 3125 3126 /** 3127 * Obtains the PID of the {@link RemoteProxy} object. 3128 * 3129 * @returns { number } Return the PID of the {@link RemoteProxy} object. 3130 * @syscap SystemCapability.Communication.IPC.Core 3131 * @since 7 3132 */ 3133 getCallingPid(): number; 3134 3135 /** 3136 * Obtains the UID of the {@link RemoteProxy} object. 3137 * 3138 * @returns { number } Return the UID of the {@link RemoteProxy} object. 3139 * @syscap SystemCapability.Communication.IPC.Core 3140 * @since 7 3141 */ 3142 getCallingUid(): number; 3143 3144 /** 3145 * Modifies the description of the current {@code RemoteObject}. 3146 * <p>This method is used to change the default descriptor specified during the creation of {@code RemoteObject}. 3147 * 3148 * @param { IRemoteBroker } localInterface - Indicates the {@code RemoteObject} whose descriptor is to be changed. 3149 * @param { string } descriptor - Indicates the new descriptor of the {@code RemoteObject}. 3150 * @syscap SystemCapability.Communication.IPC.Core 3151 * @since 7 3152 * @deprecated since 9 3153 * @useinstead ohos.rpc.RemoteObject#modifyLocalInterface 3154 */ 3155 attachLocalInterface(localInterface: IRemoteBroker, descriptor: string): void; 3156 3157 /** 3158 * Modifies the description of the current {@code RemoteObject}. 3159 * <p>This method is used to change the default descriptor specified during the creation of {@code RemoteObject}. 3160 * 3161 * @param { IRemoteBroker } localInterface - Indicates the {@code RemoteObject} whose descriptor is to be changed. 3162 * @param { string } descriptor - Indicates the new descriptor of the {@code RemoteObject}. 3163 * @throws { BusinessError } 401 - Parameter error. Possible causes: 3164 * 1.The number of parameters is incorrect; 3165 * 2.The parameter type does not match; 3166 * 3.The string length exceeds 40960 bytes; 3167 * 4.The number of bytes copied to the buffer is different from the length of the obtained string. 3168 * @syscap SystemCapability.Communication.IPC.Core 3169 * @since 9 3170 */ 3171 modifyLocalInterface(localInterface: IRemoteBroker, descriptor: string): void; 3172 } 3173 3174 /** 3175 * @syscap SystemCapability.Communication.IPC.Core 3176 * @since 7 3177 */ 3178 /** 3179 * Implement the IRemoteObject proxy object. 3180 * 3181 * @extends IRemoteObject 3182 * @syscap SystemCapability.Communication.IPC.Core 3183 * @since 11 3184 */ 3185 class RemoteProxy extends IRemoteObject { 3186 /** 3187 * Indicates the message code for a Ping operation. 3188 * 3189 * @type { number } 3190 * @default 1599098439 3191 * @static 3192 * @syscap SystemCapability.Communication.IPC.Core 3193 * @since 7 3194 */ 3195 static PING_TRANSACTION: number; 3196 3197 /** 3198 * Indicates the message code for a dump operation. 3199 * 3200 * @type { number } 3201 * @default 1598311760 3202 * @static 3203 * @syscap SystemCapability.Communication.IPC.Core 3204 * @since 7 3205 */ 3206 static DUMP_TRANSACTION: number; 3207 3208 /** 3209 * Indicates the message code for a transmission. 3210 * 3211 * @type { number } 3212 * @default 1598968902 3213 * @static 3214 * @syscap SystemCapability.Communication.IPC.Core 3215 * @since 7 3216 */ 3217 static INTERFACE_TRANSACTION: number; 3218 3219 /** 3220 * Indicates the minimum value of a valid message code. 3221 * <p>This constant is used to check the validity of an operation. 3222 * 3223 * @type { number } 3224 * @default 0x1 3225 * @static 3226 * @syscap SystemCapability.Communication.IPC.Core 3227 * @since 7 3228 */ 3229 static MIN_TRANSACTION_ID: number; 3230 3231 /** 3232 * Indicates the maximum value of a valid message code. 3233 * <p>This constant is used to check the validity of an operation. 3234 * 3235 * @type { number } 3236 * @default 0x00FFFFFF 3237 * @static 3238 * @syscap SystemCapability.Communication.IPC.Core 3239 * @since 7 3240 */ 3241 static MAX_TRANSACTION_ID: number; 3242 3243 /** 3244 * Queries a local interface with a specified descriptor. 3245 * 3246 * @param { string } interface - Indicates the descriptor of the interface to query. 3247 * @returns { IRemoteBroker } Return null by default, indicating a proxy interface. 3248 * @syscap SystemCapability.Communication.IPC.Core 3249 * @since 7 3250 * @deprecated since 9 3251 * @useinstead ohos.rpc.RemoteProxy#getLocalInterface 3252 */ 3253 queryLocalInterface(interface: string): IRemoteBroker; 3254 3255 /** 3256 * Queries a local interface with a specified descriptor. 3257 * 3258 * @param { string } interface - Indicates the descriptor of the interface to query. 3259 * @returns { IRemoteBroker } Return null by default, indicating a proxy interface. 3260 * @throws { BusinessError } 401 - check param failed 3261 * @throws { BusinessError } 1900006 - Operation allowed only for the remote object. 3262 * @syscap SystemCapability.Communication.IPC.Core 3263 * @since 9 3264 */ 3265 getLocalInterface(interface: string): IRemoteBroker; 3266 3267 /** 3268 * Register a callback used to receive death notifications of a remote object. 3269 * 3270 * @param { DeathRecipient } recipient - Indicates the callback to be registered. 3271 * @param { number } flags - Indicates the flag of the death notification. This is a reserved parameter. 3272 * Set it to {@code 0}. 3273 * @returns { boolean } Return {@code true} if the callback is registered successfully; 3274 * return {@code false} otherwise. 3275 * @syscap SystemCapability.Communication.IPC.Core 3276 * @since 7 3277 * @deprecated since 9 3278 * @useinstead ohos.rpc.RemoteProxy#registerDeathRecipient 3279 */ 3280 addDeathRecipient(recipient: DeathRecipient, flags: number): boolean; 3281 3282 /** 3283 * Register a callback used to receive death notifications of a remote object. 3284 * 3285 * @param { DeathRecipient } recipient - Indicates the callback to be registered. 3286 * @param { number } flags - Indicates the flag of the death notification. This is a reserved parameter. 3287 * Set it to {@code 0}. 3288 * @throws { BusinessError } 401 - Parameter error. Possible causes: 3289 * 1.The number of parameters is incorrect; 3290 * 2.The parameter type does not match; 3291 * 3.The callback used to receive remote object death notifications is empty. 3292 * @throws { BusinessError } 1900008 - The proxy or remote object is invalid. 3293 * @syscap SystemCapability.Communication.IPC.Core 3294 * @since 9 3295 */ 3296 registerDeathRecipient(recipient: DeathRecipient, flags: number): void; 3297 3298 /** 3299 * Unregister a callback used to receive death notifications of a remote object. 3300 * 3301 * @param { DeathRecipient } recipient - Indicates the callback to be unregister. 3302 * @param { number } flags - Indicates the flag of the death notification. This is a reserved parameter. 3303 * Set it to {@code 0}. 3304 * @returns { boolean } Return {@code true} if the callback is unregister successfully; 3305 * return {@code false} otherwise. 3306 * @syscap SystemCapability.Communication.IPC.Core 3307 * @since 7 3308 * @deprecated since 9 3309 * @useinstead ohos.rpc.RemoteProxy#unregisterDeathRecipient 3310 */ 3311 removeDeathRecipient(recipient: DeathRecipient, flags: number): boolean; 3312 3313 /** 3314 * Unregister a callback used to receive death notifications of a remote object. 3315 * 3316 * @param { DeathRecipient } recipient - Indicates the callback to be unregister. 3317 * @param { number } flags - Indicates the flag of the death notification. This is a reserved parameter. 3318 * Set it to {@code 0}. 3319 * @throws { BusinessError } 401 - Parameter error. Possible causes: 3320 * 1.The number of parameters is incorrect; 3321 * 2.The parameter type does not match; 3322 * 3.The callback used to receive remote object death notifications is empty. 3323 * @throws { BusinessError } 1900008 - The proxy or remote object is invalid. 3324 * @syscap SystemCapability.Communication.IPC.Core 3325 * @since 9 3326 */ 3327 unregisterDeathRecipient(recipient: DeathRecipient, flags: number): void; 3328 3329 /** 3330 * Queries the interface descriptor of remote object. 3331 * 3332 * @returns { string } Return the interface descriptor. 3333 * @syscap SystemCapability.Communication.IPC.Core 3334 * @since 7 3335 * @deprecated since 9 3336 * @useinstead ohos.rpc.RemoteProxy#getDescriptor 3337 */ 3338 getInterfaceDescriptor(): string; 3339 3340 /** 3341 * Queries the interface descriptor of remote object. 3342 * 3343 * @returns { string } Return the interface descriptor. 3344 * @throws { BusinessError } 1900007 - communication failed. 3345 * @throws { BusinessError } 1900008 - The proxy or remote object is invalid. 3346 * @syscap SystemCapability.Communication.IPC.Core 3347 * @since 9 3348 */ 3349 getDescriptor(): string; 3350 3351 /** 3352 * Sends a request to the peer object. 3353 * <p>If the peer object and {@code RemoteProxy} are on the same device, the request is sent by the IPC driver. 3354 * If they are on different devices, the request is sent by the socket driver. 3355 * 3356 * @param { number } code - Indicates the message code of the request. 3357 * @param { MessageParcel } data - Indicates the {@link MessageParcel} object storing the data to be sent. 3358 * @param { MessageParcel } reply - Indicates the {@link MessageParcel} object receiving the response data. 3359 * @param { MessageOption } options - Indicates a synchronous (default) or asynchronous request. 3360 * @returns { boolean } Return {@code true} if the operation succeeds; return {@code false} otherwise. 3361 * @syscap SystemCapability.Communication.IPC.Core 3362 * @since 7 3363 * @deprecated since 8 3364 */ 3365 sendRequest(code: number, data: MessageParcel, reply: MessageParcel, options: MessageOption): boolean; 3366 3367 /** 3368 * Sends a {@link MessageParcel} message to the peer process in synchronous or asynchronous mode. 3369 * <p>If options indicates the asynchronous mode, a promise will be fulfilled immediately 3370 * and the reply message does not contain any content. If options indicates the synchronous mode, 3371 * a promise will be fulfilled when the response to sendRequest is returned, 3372 * and the reply message contains the returned information. 3373 * 3374 * @param { number } code - Message code called by the request, which is determined by the client and server. 3375 * If the method is generated by an IDL tool, the message code is automatically generated by the IDL tool. 3376 * @param { MessageParcel } data - {@link MessageParcel} object holding the data to send. 3377 * @param { MessageParcel} reply - {@link MessageParcel} object that receives the response. 3378 * @param { MessageOption } options - Indicates the synchronous or asynchronous mode to send messages. 3379 * @returns { Promise<SendRequestResult> } Promise used to return the {@link sendRequestResult} instance. 3380 * @syscap SystemCapability.Communication.IPC.Core 3381 * @since 8 3382 * @deprecated since 9 3383 * @useinstead ohos.rpc.RemoteProxy#sendMessageRequest 3384 */ 3385 sendRequest( 3386 code: number, 3387 data: MessageParcel, 3388 reply: MessageParcel, 3389 options: MessageOption 3390 ): Promise<SendRequestResult>; 3391 3392 /** 3393 * Sends a {@link MessageSequence} message to the peer process in synchronous or asynchronous mode. 3394 * <p>If options indicates the asynchronous mode, a promise will be fulfilled immediately 3395 * and the reply message does not contain any content. If options indicates the synchronous mode, 3396 * a promise will be fulfilled when the response to sendMessageRequest is returned, 3397 * and the reply message contains the returned information. 3398 * 3399 * @param { number } code - Message code called by the request, which is determined by the client and server. 3400 * If the method is generated by an IDL tool, the message code is automatically generated by the IDL tool. 3401 * @param { MessageSequence } data - {@link MessageSequence} object holding the data to send. 3402 * @param { MessageSequence } reply - {@link MessageSequence} object that receives the response. 3403 * @param { MessageOption } options - Indicates the synchronous or asynchronous mode to send messages. 3404 * @returns { Promise<RequestResult> } Promise used to return the {@link RequestResult} instance. 3405 * @throws { BusinessError } 401 - Parameter error. Possible causes: 3406 * 1.The number of parameters is incorrect; 3407 * 2.The parameter type does not match; 3408 * 3.Failed to obtain the passed object instance. 3409 * @syscap SystemCapability.Communication.IPC.Core 3410 * @since 9 3411 */ 3412 sendMessageRequest( 3413 code: number, 3414 data: MessageSequence, 3415 reply: MessageSequence, 3416 options: MessageOption 3417 ): Promise<RequestResult>; 3418 3419 /** 3420 * Sends a {@link MessageParcel} message to the peer process in synchronous or asynchronous mode. 3421 * <p>If options indicates the asynchronous mode, a callback will be invoked immediately 3422 * and the reply message does not contain any content. If options indicates the synchronous mode, 3423 * a callback will be invoked when the response to sendRequest is returned, 3424 * and the reply message contains the returned information. 3425 * 3426 * @param { number } code - Message code called by the request, which is determined by the client and server. 3427 * If the method is generated by an IDL tool, the message code is automatically generated by the IDL tool. 3428 * @param { MessageParcel } data - {@link MessageParcel} object holding the data to send. 3429 * @param { MessageParcel } reply - {@link MessageParcel} object that receives the response. 3430 * @param { MessageOption } options - Indicates the synchronous or asynchronous mode to send messages. 3431 * @param { AsyncCallback<SendRequestResult> } callback - Callback for receiving the sending result. 3432 * @syscap SystemCapability.Communication.IPC.Core 3433 * @since 8 3434 * @deprecated since 9 3435 * @useinstead ohos.rpc.RemoteProxy#sendMessageRequest 3436 */ 3437 sendRequest( 3438 code: number, 3439 data: MessageParcel, 3440 reply: MessageParcel, 3441 options: MessageOption, 3442 callback: AsyncCallback<SendRequestResult> 3443 ): void; 3444 3445 /** 3446 * Sends a {@link MessageSequence} message to the peer process in synchronous or asynchronous mode. 3447 * <p>If options indicates the asynchronous mode, a callback will be invoked immediately 3448 * and the reply message does not contain any content. If options indicates the synchronous mode, 3449 * a callback will be invoked when the response to sendRequest is returned, 3450 * and the reply message contains the returned information. 3451 * 3452 * @param { number } code - Message code called by the request, which is determined by the client and server. 3453 * If the method is generated by an IDL tool, the message code is automatically generated by the IDL tool. 3454 * @param { MessageSequence } data - {@link MessageSequence} object holding the data to send. 3455 * @param { MessageSequence } reply - {@link MessageSequence} object that receives the response. 3456 * @param { MessageOption } options - Indicates the synchronous or asynchronous mode to send messages. 3457 * @param { AsyncCallback<RequestResult> } callback - Callback for receiving the sending result. 3458 * @throws { BusinessError } 401 - Parameter error. Possible causes: 3459 * 1.The number of parameters is incorrect; 3460 * 2.The parameter type does not match; 3461 * 3.Failed to obtain the passed object instance. 3462 * @syscap SystemCapability.Communication.IPC.Core 3463 * @since 9 3464 */ 3465 sendMessageRequest( 3466 code: number, 3467 data: MessageSequence, 3468 reply: MessageSequence, 3469 options: MessageOption, 3470 callback: AsyncCallback<RequestResult> 3471 ): void; 3472 3473 /** 3474 * Checks whether the {@code RemoteObject} corresponding to a {@code RemoteProxy} is dead. 3475 * 3476 * @returns { boolean } Return {@code true} if the {@code RemoteObject} is dead; return {@code false} otherwise. 3477 * @syscap SystemCapability.Communication.IPC.Core 3478 * @since 7 3479 */ 3480 isObjectDead(): boolean; 3481 } 3482 3483 /** 3484 * @syscap SystemCapability.Communication.IPC.Core 3485 * @since 7 3486 */ 3487 /** 3488 * Used to obtain IPC context information, including obtaining the UID and PID, obtaining the local and 3489 * peer device IDs, and checking whether the API call is on the same device. 3490 * 3491 * @syscap SystemCapability.Communication.IPC.Core 3492 * @since 11 3493 */ 3494 class IPCSkeleton { 3495 /** 3496 * Obtains a local {@link IRemoteObject} reference of a registered service. 3497 * <p>This method is static. 3498 * 3499 * @returns { IRemoteObject } Return an {@link IRemoteObject} reference of the registered service. 3500 * @syscap SystemCapability.Communication.IPC.Core 3501 * @since 7 3502 */ 3503 static getContextObject(): IRemoteObject; 3504 3505 /** 3506 * Obtains the PID of a proxy. 3507 * <p>This method is static. The PID 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 PID of the corresponding {@link RemoteProxy} object is returned. 3512 * 3513 * @returns { number } Return the PID of the proxy. 3514 * @syscap SystemCapability.Communication.IPC.Core 3515 * @since 7 3516 */ 3517 static getCallingPid(): number; 3518 3519 /** 3520 * Obtains the UID of a proxy. 3521 * <p>This method is static. The UID is a positive integer during the communication between 3522 * the {@link RemoteProxy} object and {@link RemoteObject} object, and resumes to {@code 0} 3523 * when the communication ends. If this method is called from the {@link RemoteProxy} object, 3524 * {@code 0} is returned; if this method is called from the {@link RemoteObject} object, 3525 * the UID of the corresponding {@link RemoteProxy} object is returned. 3526 * 3527 * @returns { number } Return the UID of the proxy. 3528 * @syscap SystemCapability.Communication.IPC.Core 3529 * @since 7 3530 */ 3531 static getCallingUid(): number; 3532 3533 /** 3534 * Obtains the TOKENID. 3535 * <p>This method is static. 3536 * 3537 * @returns { number } Return the TOKENID. 3538 * @syscap SystemCapability.Communication.IPC.Core 3539 * @since 8 3540 */ 3541 static getCallingTokenId(): number; 3542 3543 /** 3544 * Obtains the ID of the device where the peer process resides. 3545 * <p>This method is static. 3546 * 3547 * @returns { string } Return the ID of the device where the peer process resides. 3548 * @syscap SystemCapability.Communication.IPC.Core 3549 * @since 7 3550 */ 3551 static getCallingDeviceID(): string; 3552 3553 /** 3554 * Obtains the ID of the local device. 3555 * <p>This method is static. 3556 * 3557 * @returns { string } Return the ID of the local device. 3558 * @syscap SystemCapability.Communication.IPC.Core 3559 * @since 7 3560 */ 3561 static getLocalDeviceID(): string; 3562 3563 /** 3564 * Checks whether a call is made on the same device. 3565 * <p>This method is static. 3566 * 3567 * @returns { boolean } Return {@code true} if the call is made on the same device; return {@code false} otherwise. 3568 * @syscap SystemCapability.Communication.IPC.Core 3569 * @since 7 3570 */ 3571 static isLocalCalling(): boolean; 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 * @returns { number } Return {@code 0} if the operation succeeds; return an error code if the input object 3579 * is empty or {@link RemoteObject}, or the operation fails. 3580 * @syscap SystemCapability.Communication.IPC.Core 3581 * @since 7 3582 * @deprecated since 9 3583 * @useinstead ohos.rpc.IPCSkeleton#flushCmdBuffer 3584 */ 3585 static flushCommands(object: IRemoteObject): number; 3586 3587 /** 3588 * Flush all pending commands from a specified {@link RemoteProxy} to the corresponding {@link RemoteObject}. 3589 * <p>This method is static. You are advised to call this method before performing any time-sensitive operations. 3590 * 3591 * @param { IRemoteObject } object - Indicates the specified {@link RemoteProxy}. 3592 * @throws { BusinessError } 401 - Parameter error. Possible causes: 3593 * 1.The number of parameters is incorrect; 3594 * 2.The parameter type does not match. 3595 * @syscap SystemCapability.Communication.IPC.Core 3596 * @since 9 3597 */ 3598 static flushCmdBuffer(object: IRemoteObject): void; 3599 3600 /** 3601 * Replaces the UID and PID of the remote user with those of the local user. 3602 * <p>This method is static. It can be used in scenarios like authentication. 3603 * 3604 * @returns { string } Return a string containing the UID and PID of the remote user. 3605 * @syscap SystemCapability.Communication.IPC.Core 3606 * @since 7 3607 */ 3608 static resetCallingIdentity(): string; 3609 3610 /** 3611 * Restore the UID and PID to those of the remote user. 3612 * <p>This method is static. It is usually called after {@code resetCallingIdentity} is used 3613 * and requires the UID and PID of the remote user returned by {@code resetCallingIdentity}. 3614 * 3615 * @param { string } identity - Indicates the string containing the UID and PID of the remote user, 3616 * which is returned by {@code resetCallingIdentity}. 3617 * @returns { boolean } Return {@code true} if the operation succeeds; return {@code false} otherwise. 3618 * @syscap SystemCapability.Communication.IPC.Core 3619 * @since 7 3620 * @deprecated since 9 3621 * @useinstead ohos.rpc.IPCSkeleton#restoreCallingIdentity 3622 */ 3623 static setCallingIdentity(identity: string): boolean; 3624 3625 /** 3626 * Restore the UID and PID to those of the remote user. 3627 * <p>This method is static. It is usually called after {@code resetCallingIdentity} is used 3628 * and requires the UID and PID of the remote user returned by {@code resetCallingIdentity}. 3629 * 3630 * @param { string } identity - Indicates the string containing the UID and PID of the remote user, 3631 * which is returned by {@code resetCallingIdentity}. 3632 * @throws { BusinessError } 401 - Parameter error. Possible causes: 3633 * 1.The number of parameters is incorrect; 3634 * 2.The parameter type does not match; 3635 * 3.The string length exceeds 40960 bytes; 3636 * 4.The number of bytes copied to the buffer is different from the length of the obtained string. 3637 * @syscap SystemCapability.Communication.IPC.Core 3638 * @since 9 3639 */ 3640 static restoreCallingIdentity(identity: string): void; 3641 } 3642 3643 /** 3644 * Provides methods related to anonymous shared memory objects, 3645 * including creating, closing, mapping, and unmapping an Ashmem object, 3646 * reading data from and writing data to an Ashmem object, 3647 * obtaining the Ashmem size, and setting Ashmem protection. 3648 * 3649 * @syscap SystemCapability.Communication.IPC.Core 3650 * @since 8 3651 */ 3652 class Ashmem { 3653 /** 3654 * The mapped memory is executable. 3655 * 3656 * @type { number } 3657 * @default 4 3658 * @static 3659 * @syscap SystemCapability.Communication.IPC.Core 3660 * @since 8 3661 */ 3662 static PROT_EXEC: number; 3663 3664 /** 3665 * The mapped memory is inaccessible. 3666 * 3667 * @type { number } 3668 * @default 0 3669 * @static 3670 * @syscap SystemCapability.Communication.IPC.Core 3671 * @since 8 3672 */ 3673 static PROT_NONE: number; 3674 3675 /** 3676 * The mapped memory is readable. 3677 * 3678 * @type { number } 3679 * @default 1 3680 * @static 3681 * @syscap SystemCapability.Communication.IPC.Core 3682 * @since 8 3683 */ 3684 static PROT_READ: number; 3685 3686 /** 3687 * The mapped memory is writable. 3688 * 3689 * @type { number } 3690 * @default 2 3691 * @static 3692 * @syscap SystemCapability.Communication.IPC.Core 3693 * @since 8 3694 */ 3695 static PROT_WRITE: number; 3696 3697 /** 3698 * Creates an Ashmem object with the specified name and size. 3699 * 3700 * @param { string } name - Name of the Ashmem object to create. 3701 * @param { number } size - Size (in bytes) of the Ashmem object to create. 3702 * @returns { Ashmem } Return the Ashmem object if it is created successfully; return null otherwise. 3703 * @syscap SystemCapability.Communication.IPC.Core 3704 * @since 8 3705 * @deprecated since 9 3706 * @useinstead ohos.rpc.Ashmem#create 3707 */ 3708 static createAshmem(name: string, size: number): Ashmem; 3709 3710 /** 3711 * Creates an Ashmem object with the specified name and size. 3712 * 3713 * @param { string } name - Name of the Ashmem object to create. 3714 * @param { number } size - Size (in bytes) of the Ashmem object to create. 3715 * @returns { Ashmem } Return the Ashmem object if it is created successfully; return null otherwise. 3716 * @throws { BusinessError } 401 - Parameter error. Possible causes: 3717 * 1.The number of parameters is incorrect; 3718 * 2.The parameter type does not match; 3719 * 3.The Ashmem name passed is empty; 3720 * 4.The Ashmem size passed is less than or equal to 0. 3721 * @syscap SystemCapability.Communication.IPC.Core 3722 * @since 9 3723 */ 3724 static create(name: string, size: number): Ashmem; 3725 3726 /** 3727 * Creates an Ashmem object by copying the file descriptor (FD) of an existing Ashmem object. 3728 * The two Ashmem objects point to the same shared memory region. 3729 * 3730 * @param { Ashmem } ashmem - Existing Ashmem object. 3731 * @returns { Ashmem } Ashmem object created. 3732 * @syscap SystemCapability.Communication.IPC.Core 3733 * @since 8 3734 * @deprecated since 9 3735 * @useinstead ohos.rpc.Ashmem#create 3736 */ 3737 static createAshmemFromExisting(ashmem: Ashmem): Ashmem; 3738 3739 /** 3740 * Creates an Ashmem object by copying the file descriptor (FD) of an existing Ashmem object. 3741 * The two Ashmem objects point to the same shared memory region. 3742 * 3743 * @param { Ashmem } ashmem - Existing Ashmem object. 3744 * @returns { Ashmem } Ashmem object created. 3745 * @throws { BusinessError } 401 - Parameter error. Possible causes: 3746 * 1.The number of parameters is incorrect; 3747 * 2.The passed parameter is not an Ahmem object; 3748 * 3.The ashmem instance for obtaining packaging is empty. 3749 * @syscap SystemCapability.Communication.IPC.Core 3750 * @since 9 3751 */ 3752 static create(ashmem: Ashmem): Ashmem; 3753 3754 /** 3755 * Closes this Ashmem object. 3756 * 3757 * @syscap SystemCapability.Communication.IPC.Core 3758 * @since 8 3759 */ 3760 closeAshmem(): void; 3761 3762 /** 3763 * Deletes the mappings for the specified address range of this Ashmem object. 3764 * 3765 * @syscap SystemCapability.Communication.IPC.Core 3766 * @since 8 3767 */ 3768 unmapAshmem(): void; 3769 3770 /** 3771 * Obtains the mapped memory size of this Ashmem object. 3772 * 3773 * @returns { number } Memory size mapped. 3774 * @syscap SystemCapability.Communication.IPC.Core 3775 * @since 8 3776 */ 3777 getAshmemSize(): number; 3778 3779 /** 3780 * Creates the shared file mapping on the virtual address space of this process. 3781 * The size of the mapping region is specified by this Ashmem object. 3782 * 3783 * @param { number } mapType - Protection level of the memory region to which the shared file is mapped. 3784 * @returns { boolean } Return {@code true} if the operation is successful; return {@code false} otherwise. 3785 * @syscap SystemCapability.Communication.IPC.Core 3786 * @since 8 3787 * @deprecated since 9 3788 * @useinstead ohos.rpc.Ashmem#mapTypedAshmem 3789 */ 3790 mapAshmem(mapType: number): boolean; 3791 3792 /** 3793 * Creates the shared file mapping on the virtual address space of this process. 3794 * The size of the mapping region is specified by this Ashmem object. 3795 * 3796 * @param { number } mapType - Protection level of the memory region to which the shared file is mapped. 3797 * @throws { BusinessError } 401 - Parameter error. Possible causes: 3798 * 1.The number of parameters is incorrect; 3799 * 2.The parameter type does not match; 3800 * 3.The passed mapType exceeds the maximum protection level. 3801 * @throws { BusinessError } 1900001 - Failed to call mmap. 3802 * @syscap SystemCapability.Communication.IPC.Core 3803 * @since 9 3804 */ 3805 mapTypedAshmem(mapType: number): void; 3806 3807 /** 3808 * Maps the shared file to the readable and writable virtual address space of the process. 3809 * 3810 * @returns { boolean } Return {@code true} if the operation is successful; return {@code false} otherwise. 3811 * @syscap SystemCapability.Communication.IPC.Core 3812 * @since 8 3813 * @deprecated since 9 3814 * @useinstead ohos.rpc.Ashmem#mapReadWriteAshmem 3815 */ 3816 mapReadAndWriteAshmem(): boolean; 3817 3818 /** 3819 * Maps the shared file to the readable and writable virtual address space of the process. 3820 * 3821 * @throws { BusinessError } 1900001 - Failed to call mmap. 3822 * @syscap SystemCapability.Communication.IPC.Core 3823 * @since 9 3824 */ 3825 mapReadWriteAshmem(): void; 3826 3827 /** 3828 * Maps the shared file to the read-only virtual address space of the process. 3829 * 3830 * @returns { boolean } Return {@code true} if the operation is successful; return {@code false} otherwise. 3831 * @syscap SystemCapability.Communication.IPC.Core 3832 * @since 8 3833 * @deprecated since 9 3834 * @useinstead ohos.rpc.Ashmem#mapReadonlyAshmem 3835 */ 3836 mapReadOnlyAshmem(): boolean; 3837 3838 /** 3839 * Maps the shared file to the read-only virtual address space of the process. 3840 * 3841 * @throws { BusinessError } 1900001 - Failed to call mmap. 3842 * @syscap SystemCapability.Communication.IPC.Core 3843 * @since 9 3844 */ 3845 mapReadonlyAshmem(): void; 3846 3847 /** 3848 * Sets the protection level of the memory region to which the shared file is mapped. 3849 * 3850 * @param { number } protectionType - Protection type to set. 3851 * @returns { boolean } Return true if the operation is successful; return false otherwise. 3852 * @syscap SystemCapability.Communication.IPC.Core 3853 * @since 8 3854 * @deprecated since 9 3855 * @useinstead ohos.rpc.Ashmem#setProtectionType 3856 */ 3857 setProtection(protectionType: number): boolean; 3858 3859 /** 3860 * Sets the protection level of the memory region to which the shared file is mapped. 3861 * 3862 * @param { number } protectionType - Protection type to set. 3863 * @throws { BusinessError } 401 - Parameter error. Possible causes: 3864 * 1.The number of parameters is incorrect; 3865 * 2.The parameter type does not match. 3866 * @throws { BusinessError } 1900002 - Failed to call ioctl. 3867 * @syscap SystemCapability.Communication.IPC.Core 3868 * @since 9 3869 */ 3870 setProtectionType(protectionType: number): void; 3871 3872 /** 3873 * Writes data to the shared file associated with this Ashmem object. 3874 * 3875 * @param { number[] } buf - Data to write. 3876 * @param { number } size - Size of the data to write. 3877 * @param { number } offset - Start position of the data to write in the memory region associated 3878 * with this Ashmem object. 3879 * @returns { boolean } Return {@code true} is the data is written successfully; return {@code false} otherwise. 3880 * @syscap SystemCapability.Communication.IPC.Core 3881 * @since 8 3882 * @deprecated since 9 3883 * @useinstead ohos.rpc.Ashmem#writeAshmem 3884 */ 3885 writeToAshmem(buf: number[], size: number, offset: number): boolean; 3886 3887 /** 3888 * Writes data to the shared file associated with this Ashmem object. 3889 * 3890 * @param { number[] } buf - Data to write 3891 * @param { number } size - Size of the data to write 3892 * @param { number } offset - Start position of the data to write in the memory region associated 3893 * with this Ashmem object. 3894 * @throws { BusinessError } 401 - Parameter error. Possible causes: 3895 * 1.The number of parameters is incorrect; 3896 * 2.The parameter type does not match; 3897 * 3.The element does not exist in the array. 3898 * @throws { BusinessError } 1900003 - Failed to write data to the shared memory. 3899 * @syscap SystemCapability.Communication.IPC.Core 3900 * @since 9 3901 * @deprecated since 11 3902 * @useinstead ohos.rpc.Ashmem#writeDataToAshmem 3903 */ 3904 writeAshmem(buf: number[], size: number, offset: number): void; 3905 3906 /** 3907 * Writes data to the shared file associated with this Ashmem object. 3908 * 3909 * @param { ArrayBuffer } buf - Data to write 3910 * @param { number } size - Size of the data to write 3911 * @param { number } offset - Start position of the data to write in the memory region associated 3912 * with this Ashmem object. 3913 * @throws { BusinessError } 401 - Parameter error. Possible causes: 3914 * 1.The number of parameters is incorrect; 3915 * 2.The parameter type does not match; 3916 * 3.Failed to obtain arrayBuffer information. 3917 * @throws { BusinessError } 1900003 - Failed to write data to the shared memory. 3918 * @syscap SystemCapability.Communication.IPC.Core 3919 * @since 11 3920 */ 3921 writeDataToAshmem(buf: ArrayBuffer, size: number, offset: number): void; 3922 3923 /** 3924 * Reads data from the shared file associated with this Ashmem object. 3925 * 3926 * @param { number } size - Size of the data to read. 3927 * @param { number } offset - Start position of the data to read in the memory region associated 3928 * with this Ashmem object. 3929 * @returns { number[] } Data read. 3930 * @syscap SystemCapability.Communication.IPC.Core 3931 * @since 8 3932 * @deprecated since 9 3933 * @useinstead ohos.rpc.Ashmem#readAshmem 3934 */ 3935 readFromAshmem(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 { number[] } 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 9 3950 * @deprecated since 11 3951 * @useinstead ohos.rpc.Ashmem#readDataFromAshmem 3952 */ 3953 readAshmem(size: number, offset: number): number[]; 3954 3955 /** 3956 * Reads data from the shared file associated with this Ashmem object. 3957 * 3958 * @param { number } size - Size of the data to read. 3959 * @param { number } offset - Start position of the data to read in the memory region associated 3960 * with this Ashmem object. 3961 * @returns { ArrayBuffer } Data read. 3962 * @throws { BusinessError } 401 - Parameter error. Possible causes: 3963 * 1.The number of parameters is incorrect; 3964 * 2.The parameter type does not match. 3965 * @throws { BusinessError } 1900004 - Failed to read data from the shared memory. 3966 * @syscap SystemCapability.Communication.IPC.Core 3967 * @since 11 3968 */ 3969 readDataFromAshmem(size: number, offset: number): ArrayBuffer; 3970 } 3971} 3972 3973export default rpc;