1/* 2 * Copyright (C) 2021-2022 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16import {AsyncCallback} from "./basic"; 17 18/** 19 * Provides the capabilities and methods for obtaining Short Message Service (SMS) management objects. 20 * 21 * @since 6 22 * @syscap SystemCapability.Telephony.SmsMms 23 */ 24declare namespace sms { 25 /** 26 * Splits a long SMS message into multiple fragments. 27 * 28 * <p>If the length of an SMS message exceeds the maximum length allowed (140 bytes), 29 * the SMS message is split into multiple segments for processing. 30 * 31 * @param content Indicates the short message content, which cannot be {@code null}. 32 * @param callback Returns a list of split segments, which can be combined into a complete SMS message; 33 * returns an empty string if no permission is granted or the short message content is {@code null}. 34 * @permission ohos.permission.SEND_MESSAGES 35 * @throws {BusinessError} 201 - Permission denied. 36 * @throws {BusinessError} 401 - Parameter error. 37 * @throws {BusinessError} 8300001 - Invalid parameter value. 38 * @throws {BusinessError} 8300002 - Operation failed. Cannot connect to service. 39 * @throws {BusinessError} 8300003 - System internal error. 40 * @throws {BusinessError} 8300999 - Unknown error code. 41 * @systemapi Hide this for inner system use. 42 * @since 8 43 */ 44 function splitMessage(content: string, callback: AsyncCallback<Array<string>>): void; 45 function splitMessage(content: string): Promise<Array<string>>; 46 47 /** 48 * Creates an SMS message instance based on the protocol data unit (PDU) and the specified SMS protocol. 49 * 50 * <p>After receiving the original PDU data, the system creates an SMS message instance according to the specified 51 * SMS protocol. 52 * 53 * @param pdu Indicates the original data, which is obtained from the received SMS. 54 * @param specification Indicates the SMS protocol type. The value {@code 3gpp} indicates GSM/UMTS/LTE SMS, 55 * and the value {@code 3gpp2} indicates CDMA/LTE SMS. 56 * @param callback Returns an SMS message instance; returns {@code null} if {@code pdu} is empty or 57 * {@code specification} is not supported. 58 * @throws {BusinessError} 401 - Parameter error. 59 * @throws {BusinessError} 8300001 - Invalid parameter value. 60 * @throws {BusinessError} 8300002 - Operation failed. Cannot connect to service. 61 * @throws {BusinessError} 8300003 - System internal error. 62 * @throws {BusinessError} 8300999 - Unknown error code. 63 */ 64 function createMessage(pdu: Array<number>, specification: string, callback: AsyncCallback<ShortMessage>): void; 65 function createMessage(pdu: Array<number>, specification: string): Promise<ShortMessage>; 66 67 /** 68 * Sends a text or data SMS message. 69 * 70 * <p>This method checks whether the length of an SMS message exceeds the maximum length. If the 71 * maximum length is exceeded, the SMS message is split into multiple parts and sent separately. 72 * 73 * @param options Indicates the parameters and callback for sending the SMS message. 74 * @permission ohos.permission.SEND_MESSAGES 75 * @throws {BusinessError} 201 - Permission denied. 76 * @throws {BusinessError} 401 - Parameter error. 77 * @throws {BusinessError} 8300001 - Invalid parameter value. 78 * @throws {BusinessError} 8300002 - Operation failed. Cannot connect to service. 79 * @throws {BusinessError} 8300003 - System internal error. 80 * @throws {BusinessError} 8300999 - Unknown error code. 81 */ 82 function sendMessage(options: SendMessageOptions): void; 83 84 /** 85 * Sets the default SIM card for sending SMS messages. You can obtain the default SIM card by 86 * using {@code getDefaultSmsSlotId}. 87 * 88 * @param slotId Indicates the default SIM card for sending SMS messages. The value {@code 0} indicates card slot 1, 89 * and the value {@code 1} indicates card slot 2. 90 * @permission ohos.permission.SET_TELEPHONY_STATE 91 * @throws {BusinessError} 201 - Permission denied. 92 * @throws {BusinessError} 401 - Parameter error. 93 * @throws {BusinessError} 8300001 - Invalid parameter value. 94 * @throws {BusinessError} 8300002 - Operation failed. Cannot connect to service. 95 * @throws {BusinessError} 8300003 - System internal error. 96 * @throws {BusinessError} 8300004 - Do not have sim card. 97 * @throws {BusinessError} 8300999 - Unknown error code. 98 * @systemapi Hide this for inner system use. 99 * @since 7 100 */ 101 function setDefaultSmsSlotId(slotId: number, callback: AsyncCallback<void>): void; 102 function setDefaultSmsSlotId(slotId: number): Promise<void>; 103 104 /** 105 * Obtains the default SIM card for sending SMS messages. 106 * 107 * @param callback Returns {@code 0} if the default SIM card for sending SMS messages is in card slot 1; 108 * returns {@code 1} if the default SIM card for sending SMS messages is in card slot 2. 109 * @since 7 110 */ 111 function getDefaultSmsSlotId(callback: AsyncCallback<number>): void; 112 function getDefaultSmsSlotId(): Promise<number>; 113 114 /** 115 * Sets the address for the Short Message Service Center (SMSC) based on a specified slot ID. 116 * 117 * @param slotId Indicates the ID of the slot holding the SIM card for sending SMS messages. 118 * @param smscAddr Indicates the SMSC address. 119 * @permission ohos.permission.SET_TELEPHONY_STATE 120 * @throws {BusinessError} 201 - Permission denied. 121 * @throws {BusinessError} 401 - Parameter error. 122 * @throws {BusinessError} 8300001 - Invalid parameter value. 123 * @throws {BusinessError} 8300002 - Operation failed. Cannot connect to service. 124 * @throws {BusinessError} 8300003 - System internal error. 125 * @throws {BusinessError} 8300999 - Unknown error code. 126 * @systemapi Hide this for inner system use. 127 * @since 7 128 */ 129 function setSmscAddr(slotId: number, smscAddr: string, callback: AsyncCallback<void>): void; 130 function setSmscAddr(slotId: number, smscAddr: string): Promise<void>; 131 132 /** 133 * Obtains the SMSC address based on a specified slot ID. 134 * 135 * @param slotId Indicates the ID of the slot holding the SIM card for sending SMS messages. 136 * @param callback Returns the SMSC address. 137 * @permission ohos.permission.GET_TELEPHONY_STATE 138 * @throws {BusinessError} 201 - Permission denied. 139 * @throws {BusinessError} 401 - Parameter error. 140 * @throws {BusinessError} 8300001 - Invalid parameter value. 141 * @throws {BusinessError} 8300002 - Operation failed. Cannot connect to service. 142 * @throws {BusinessError} 8300003 - System internal error. 143 * @throws {BusinessError} 8300999 - Unknown error code. 144 * @systemapi Hide this for inner system use. 145 * @since 7 146 */ 147 function getSmscAddr(slotId: number, callback: AsyncCallback<string>): void; 148 function getSmscAddr(slotId: number): Promise<string>; 149 150 /** 151 * Returns whether a device is capable of sending and receiving SMS messages. 152 * 153 * @returns Returns {@code true} if the device is capable of sending and receiving SMS messages; 154 * returns {@code false} otherwise. 155 * @since 7 156 */ 157 function hasSmsCapability(): boolean; 158 159 /** 160 * Add a SMS Message to SIM card. 161 * 162 * @param options Indicates SIM message options. 163 * @permission ohos.permission.RECEIVE_SMS and ohos.permission.SEND_MESSAGES 164 * @throws {BusinessError} 201 - Permission denied. 165 * @throws {BusinessError} 401 - Parameter error. 166 * @throws {BusinessError} 8300001 - Invalid parameter value. 167 * @throws {BusinessError} 8300002 - Operation failed. Cannot connect to service. 168 * @throws {BusinessError} 8300003 - System internal error. 169 * @throws {BusinessError} 8300999 - Unknown error code. 170 * @systemapi Hide this for inner system use. 171 * @since 7 172 */ 173 function addSimMessage(options: SimMessageOptions, callback: AsyncCallback<void>): void; 174 function addSimMessage(options: SimMessageOptions): Promise<void>; 175 176 /** 177 * Delete a SMS Message from the SIM card. 178 * 179 * @param slotId Indicates the card slot index number, ranging from 0 to the maximum card slot index number supported by the device. 180 * @param msgIndex Indicates the message index. 181 * @permission ohos.permission.RECEIVE_SMS and ohos.permission.SEND_MESSAGES 182 * @throws {BusinessError} 201 - Permission denied. 183 * @throws {BusinessError} 401 - Parameter error. 184 * @throws {BusinessError} 8300001 - Invalid parameter value. 185 * @throws {BusinessError} 8300002 - Operation failed. Cannot connect to service. 186 * @throws {BusinessError} 8300003 - System internal error. 187 * @throws {BusinessError} 8300999 - Unknown error code. 188 * @systemapi Hide this for inner system use. 189 * @since 7 190 */ 191 function delSimMessage(slotId: number, msgIndex: number, callback: AsyncCallback<void>): void; 192 function delSimMessage(slotId: number, msgIndex: number): Promise<void>; 193 194 /** 195 * Update a SIM SMS of SIM card. 196 * 197 * @param options Update SIM message options. 198 * @permission ohos.permission.RECEIVE_SMS and ohos.permission.SEND_MESSAGES 199 * @throws {BusinessError} 201 - Permission denied. 200 * @throws {BusinessError} 401 - Parameter error. 201 * @throws {BusinessError} 8300001 - Invalid parameter value. 202 * @throws {BusinessError} 8300002 - Operation failed. Cannot connect to service. 203 * @throws {BusinessError} 8300003 - System internal error. 204 * @throws {BusinessError} 8300999 - Unknown error code. 205 * @systemapi Hide this for inner system use. 206 * @since 7 207 */ 208 function updateSimMessage(options: UpdateSimMessageOptions, callback: AsyncCallback<void>): void; 209 function updateSimMessage(options: UpdateSimMessageOptions): Promise<void>; 210 211 /** 212 * Get all SMS records in SIM. 213 * 214 * @param slotId Indicates the card slot index number, ranging from 0 to the maximum card slot index number supported by the device. 215 * @param callback Returns a {@code SimShortMessage} object. 216 * @permission ohos.permission.RECEIVE_SMS 217 * @throws {BusinessError} 201 - Permission denied. 218 * @throws {BusinessError} 401 - Parameter error. 219 * @throws {BusinessError} 8300001 - Invalid parameter value. 220 * @throws {BusinessError} 8300002 - Operation failed. Cannot connect to service. 221 * @throws {BusinessError} 8300003 - System internal error. 222 * @throws {BusinessError} 8300999 - Unknown error code. 223 * @systemapi Hide this for inner system use. 224 * @since 7 225 */ 226 function getAllSimMessages(slotId: number, callback: AsyncCallback<Array<SimShortMessage>>): void; 227 function getAllSimMessages(slotId: number): Promise<Array<SimShortMessage>>; 228 229 /** 230 * Turn on or off Cell BroadCast. 231 * 232 * @param options Cell broadcast configuration options. 233 * @permission ohos.permission.RECEIVE_SMS 234 * @throws {BusinessError} 201 - Permission denied. 235 * @throws {BusinessError} 401 - Parameter error. 236 * @throws {BusinessError} 8300001 - Invalid parameter value. 237 * @throws {BusinessError} 8300002 - Operation failed. Cannot connect to service. 238 * @throws {BusinessError} 8300003 - System internal error. 239 * @throws {BusinessError} 8300999 - Unknown error code. 240 * @systemapi Hide this for inner system use. 241 * @since 7 242 */ 243 function setCBConfig(options: CBConfigOptions, callback: AsyncCallback<void>): void; 244 function setCBConfig(options: CBConfigOptions): Promise<void>; 245 246 /** 247 * Get a SMS segment encode relation information. 248 * 249 * @param slotId Indicates the card slot index number, ranging from 0 to the maximum card slot index number supported by the device. 250 * @param message Indicates short message. 251 * @param force7bit Whether to use 7 bit encoding. 252 * @param callback Returns a {@code SmsSegmentsInfo} object. 253 * @throws {BusinessError} 401 - Parameter error. 254 * @throws {BusinessError} 8300001 - Invalid parameter value. 255 * @throws {BusinessError} 8300002 - Operation failed. Cannot connect to service. 256 * @throws {BusinessError} 8300003 - System internal error. 257 * @throws {BusinessError} 8300999 - Unknown error code. 258 * @systemapi Hide this for inner system use. 259 * @since 8 260 */ 261 function getSmsSegmentsInfo(slotId: number, message: string, force7bit: boolean, callback: AsyncCallback<SmsSegmentsInfo>): void; 262 function getSmsSegmentsInfo(slotId: number, message: string, force7bit: boolean): Promise<SmsSegmentsInfo>; 263 264 /** 265 * SMS over IMS is supported if IMS is registered and SMS is supported on IMS. 266 * 267 * @param slotId Indicates the default SIM card for Ims Sms. The value {@code 0} indicates card slot 1, 268 * and the value {@code 1} indicates card slot 2. 269 * @param callback Returns true if SMS over IMS is supported, false otherwise. 270 * @throws {BusinessError} 401 - Parameter error. 271 * @throws {BusinessError} 8300001 - Invalid parameter value. 272 * @throws {BusinessError} 8300002 - Operation failed. Cannot connect to service. 273 * @throws {BusinessError} 8300003 - System internal error. 274 * @throws {BusinessError} 8300999 - Unknown error code. 275 * @systemapi Hide this for inner system use. 276 * @since 8 277 */ 278 function isImsSmsSupported(slotId: number, callback: AsyncCallback<boolean>): void; 279 function isImsSmsSupported(slotId: number): Promise<boolean>; 280 281 /** 282 * Gets SMS format supported on IMS. SMS over IMS format is either 3GPP or 3GPP2. 283 * 284 * @param callback Returns format, 3gpp, 3gpp2 or unknown. 285 * @throws {BusinessError} 401 - Parameter error. 286 * @throws {BusinessError} 8300001 - Invalid parameter value. 287 * @throws {BusinessError} 8300002 - Operation failed. Cannot connect to service. 288 * @throws {BusinessError} 8300003 - System internal error. 289 * @throws {BusinessError} 8300999 - Unknown error code. 290 * @systemapi Hide this for inner system use. 291 * @since 8 292 */ 293 function getImsShortMessageFormat(callback: AsyncCallback<string>): void; 294 function getImsShortMessageFormat(): Promise<string>; 295 296 /** 297 * Decode the message content. 298 * 299 * @param mmsFilePathName Indicates the path name of the multimedia message file. 300 * @param callback Returns a {@code MmsInformation} object. 301 * @throws {BusinessError} 401 - Parameter error. 302 * @throws {BusinessError} 8300001 - Invalid parameter value. 303 * @throws {BusinessError} 8300002 - Operation failed. Cannot connect to service. 304 * @throws {BusinessError} 8300003 - System internal error. 305 * @throws {BusinessError} 8300999 - Unknown error code. 306 * @systemapi Hide this for inner system use. 307 * @since 8 308 */ 309 function decodeMms(mmsFilePathName: string | Array<number>, callback: AsyncCallback<MmsInformation>): void; 310 function decodeMms(mmsFilePathName: string | Array<number>): Promise<MmsInformation>; 311 312 /** 313 * Encode the message content. 314 * 315 * @param mms MMS messages. 316 * @param callback Returns the result of MMS encoding. 317 * @throws {BusinessError} 401 - Parameter error. 318 * @throws {BusinessError} 8300001 - Invalid parameter value. 319 * @throws {BusinessError} 8300002 - Operation failed. Cannot connect to service. 320 * @throws {BusinessError} 8300003 - System internal error. 321 * @throws {BusinessError} 8300999 - Unknown error code. 322 * @systemapi Hide this for inner system use. 323 * @since 8 324 */ 325 function encodeMms(mms: MmsInformation, callback: AsyncCallback<Array<number>>): void; 326 function encodeMms(mms: MmsInformation): Promise<Array<number>>; 327 328 /** 329 * @systemapi Hide this for inner system use. 330 * @since 8 331 */ 332 export interface MmsInformation { 333 messageType: MessageType; 334 mmsType: MmsSendReq | MmsSendConf | MmsNotificationInd | MmsRespInd | MmsRetrieveConf | MmsAcknowledgeInd | MmsDeliveryInd | MmsReadOrigInd | MmsReadRecInd; 335 attachment?: Array<MmsAttachment>; 336 } 337 338 /** 339 * @systemapi Hide this for inner system use. 340 * @since 8 341 */ 342 export interface MmsSendReq { 343 from: MmsAddress; 344 transactionId: string; 345 contentType: string; 346 version: MmsVersionType; 347 to?: Array<MmsAddress>; 348 date?: number; 349 cc?: Array<MmsAddress>; 350 bcc?: Array<MmsAddress>; 351 subject?: string; 352 messageClass?: number; 353 expiry?: number; 354 priority?: MmsPriorityType; 355 senderVisibility?: number; 356 deliveryReport?: number; 357 readReport?: number; 358 } 359 360 /** 361 * @systemapi Hide this for inner system use. 362 * @since 8 363 */ 364 export interface MmsSendConf { 365 responseState: number; 366 transactionId: string; 367 version: MmsVersionType; 368 messageId?: string; 369 } 370 371 /** 372 * @systemapi Hide this for inner system use. 373 * @since 8 374 */ 375 export interface MmsNotificationInd { 376 transactionId: string; 377 messageClass: number; 378 messageSize: number; 379 expiry: number; 380 contentLocation: string; 381 version: MmsVersionType; 382 from?: MmsAddress; 383 subject?: string; 384 deliveryReport?: number; 385 contentClass?: number; 386 } 387 388 /** 389 * @systemapi Hide this for inner system use. 390 * @since 8 391 */ 392 export interface MmsRespInd { 393 transactionId: string; 394 status: number; 395 version: MmsVersionType; 396 reportAllowed?: ReportType; 397 } 398 399 /** 400 * @systemapi Hide this for inner system use. 401 * @since 8 402 */ 403 export interface MmsRetrieveConf { 404 transactionId: string; 405 messageId: string; 406 date: number; 407 contentType: string; 408 to: Array<MmsAddress>; 409 version: MmsVersionType; 410 from?: MmsAddress; 411 cc?: Array<MmsAddress>; 412 subject?: string; 413 priority?: MmsPriorityType; 414 deliveryReport?: number; 415 readReport?: number; 416 retrieveStatus?: number; 417 retrieveText?: string; 418 } 419 420 /** 421 * @systemapi Hide this for inner system use. 422 * @since 8 423 */ 424 export interface MmsAcknowledgeInd { 425 transactionId: string; 426 version: MmsVersionType; 427 reportAllowed?: ReportType; 428 } 429 430 /** 431 * @systemapi Hide this for inner system use. 432 * @since 8 433 */ 434 export interface MmsDeliveryInd { 435 messageId: string; 436 date: number; 437 to: Array<MmsAddress>; 438 status: number; 439 version: MmsVersionType; 440 } 441 442 /** 443 * @systemapi Hide this for inner system use. 444 * @since 8 445 */ 446 export interface MmsReadOrigInd { 447 version: MmsVersionType; 448 messageId: string; 449 to: Array<MmsAddress>; 450 from: MmsAddress; 451 date: number; 452 readStatus: number; 453 } 454 455 /** 456 * @systemapi Hide this for inner system use. 457 * @since 8 458 */ 459 export interface MmsReadRecInd { 460 version: MmsVersionType; 461 messageId: string; 462 to: Array<MmsAddress>; 463 from: MmsAddress; 464 readStatus: number; 465 date?: number; 466 } 467 468 /** 469 * @systemapi Hide this for inner system use. 470 * @since 8 471 */ 472 export interface MmsAttachment { 473 contentId: string; 474 contentLocation: string; 475 contentDisposition: DispositionType; 476 contentTransferEncoding: string; 477 contentType: string; 478 isSmil: boolean; 479 path?: string; 480 inBuff?: Array<number>; 481 fileName?: string; 482 charset?: MmsCharSets; 483 } 484 485 /** 486 * @systemapi Hide this for inner system use. 487 * @since 8 488 */ 489 export interface MmsAddress { 490 address: string; 491 charset: MmsCharSets; 492 } 493 494 /** 495 * @systemapi Hide this for inner system use. 496 * @since 8 497 */ 498 export enum MessageType { 499 TYPE_MMS_SEND_REQ = 128, 500 TYPE_MMS_SEND_CONF, 501 TYPE_MMS_NOTIFICATION_IND, 502 TYPE_MMS_RESP_IND, 503 TYPE_MMS_RETRIEVE_CONF, 504 TYPE_MMS_ACKNOWLEDGE_IND, 505 TYPE_MMS_DELIVERY_IND, 506 TYPE_MMS_READ_REC_IND, 507 TYPE_MMS_READ_ORIG_IND, 508 } 509 510 /** 511 * @systemapi Hide this for inner system use. 512 * @since 8 513 */ 514 export enum MmsPriorityType { 515 MMS_LOW = 128, 516 MMS_NORMAL, 517 MMS_HIGH, 518 } 519 520 /** 521 * @systemapi Hide this for inner system use. 522 * @since 8 523 */ 524 export enum MmsVersionType { 525 MMS_VERSION_1_0 = 0x10, 526 MMS_VERSION_1_1, 527 MMS_VERSION_1_2, 528 MMS_VERSION_1_3, 529 } 530 531 /** 532 * @systemapi Hide this for inner system use. 533 * @since 8 534 */ 535 export enum MmsCharSets { 536 BIG5 = 0X07EA, 537 ISO_10646_UCS_2 = 0X03E8, 538 ISO_8859_1 = 0X04, 539 ISO_8859_2, 540 ISO_8859_3, 541 ISO_8859_4, 542 ISO_8859_5, 543 ISO_8859_6, 544 ISO_8859_7, 545 ISO_8859_8, 546 ISO_8859_9, 547 SHIFT_JIS = 0X11, 548 US_ASCII = 0X03, 549 UTF_8 = 0X6A, 550 } 551 552 /** 553 * @systemapi Hide this for inner system use. 554 * @since 8 555 */ 556 export enum DispositionType { 557 FROM_DATA = 0, 558 ATTACHMENT, 559 INLINE, 560 } 561 562 /** 563 * @systemapi Hide this for inner system use. 564 * @since 8 565 */ 566 export enum ReportType { 567 MMS_YES = 128, 568 MMS_NO, 569 } 570 571 /** 572 * @systemapi Hide this for inner system use. 573 * @since 7 574 */ 575 export interface CBConfigOptions { 576 slotId: number; 577 enable: boolean; 578 startMessageId: number; 579 endMessageId: number; 580 ranType: RanType; 581 } 582 583 /** 584 * @systemapi Hide this for inner system use. 585 * @since 7 586 */ 587 export interface SimMessageOptions { 588 slotId: number; 589 smsc: string; 590 pdu: string; 591 status: SimMessageStatus; 592 } 593 594 /** 595 * @systemapi Hide this for inner system use. 596 * @since 7 597 */ 598 export interface UpdateSimMessageOptions { 599 slotId: number; 600 msgIndex: number; 601 newStatus: SimMessageStatus; 602 pdu: string; 603 smsc: string; 604 } 605 606 export interface ShortMessage { 607 /** Indicates the SMS message body. */ 608 visibleMessageBody: string; 609 /** Indicates the address of the sender, which is to be displayed on the UI. */ 610 visibleRawAddress: string; 611 /** Indicates the SMS type. */ 612 messageClass: ShortMessageClass; 613 /** Indicates the protocol identifier. */ 614 protocolId: number; 615 /** Indicates the short message service center (SMSC) address. */ 616 scAddress: string; 617 /** Indicates the SMSC timestamp. */ 618 scTimestamp: number; 619 /** Indicates whether the received SMS is a "replace short message". */ 620 isReplaceMessage: boolean; 621 /** Indicates whether the received SMS contains "TP-Reply-Path". */ 622 hasReplyPath: boolean; 623 /** Indicates Protocol Data Units (PDUs) from an SMS message. */ 624 pdu: Array<number>; 625 /** 626 * Indicates the SMS message status from the SMS-STATUS-REPORT message sent by the 627 * Short Message Service Center (SMSC). 628 */ 629 status: number; 630 /** Indicates whether the current message is SMS-STATUS-REPORT. */ 631 isSmsStatusReportMessage: boolean; 632 } 633 634 /** 635 * @systemapi Hide this for inner system use. 636 * @since 7 637 */ 638 export interface SimShortMessage { 639 shortMessage: ShortMessage; 640 641 /** Indicates the storage status of SMS messages in the SIM */ 642 simMessageStatus: SimMessageStatus; 643 /** Indicates the index of SMS messages in the SIM */ 644 indexOnSim: number; 645 } 646 647 /** 648 * @systemapi Hide this for inner system use. 649 * @since 7 650 */ 651 export enum SimMessageStatus { 652 /** status free space ON SIM */ 653 SIM_MESSAGE_STATUS_FREE = 0, 654 /** REC READ received read message */ 655 SIM_MESSAGE_STATUS_READ = 1, 656 /** REC UNREAD received unread message */ 657 SIM_MESSAGE_STATUS_UNREAD = 3, 658 /** STO SENT stored sent message (only applicable to SMs) */ 659 SIM_MESSAGE_STATUS_SENT = 5, 660 /** STO UNSENT stored unsent message (only applicable to SMs) */ 661 SIM_MESSAGE_STATUS_UNSENT = 7, 662 } 663 664 export enum ShortMessageClass { 665 /** Indicates an unknown type. */ 666 UNKNOWN, 667 /** Indicates an instant message, which is displayed immediately after being received. */ 668 INSTANT_MESSAGE, 669 /** Indicates an SMS message that can be stored on the device or SIM card based on the storage status. */ 670 OPTIONAL_MESSAGE, 671 /** Indicates an SMS message containing SIM card information, which is to be stored in a SIM card. */ 672 SIM_MESSAGE, 673 /** Indicates an SMS message to be forwarded to another device. */ 674 FORWARD_MESSAGE 675 } 676 677 export interface SendMessageOptions { 678 /** Indicates the ID of the SIM card slot used for sending the SMS message. */ 679 slotId: number; 680 /** Indicates the address to which the SMS message is sent. */ 681 destinationHost: string; 682 /** Indicates the SMSC address. If the value is {@code null}, the default SMSC address of the SIM card*/ 683 serviceCenter?: string; 684 /** If the content is a string, this is a short message. If the content is a byte array, this is a data message. */ 685 content: string | Array<number>; 686 /** If send data message, destinationPort is mandatory. Otherwise is optional. */ 687 destinationPort?: number; 688 /** Indicates the callback invoked after the SMS message is sent. */ 689 sendCallback?: AsyncCallback<ISendShortMessageCallback>; 690 /** Indicates the callback invoked after the SMS message is delivered. */ 691 deliveryCallback?: AsyncCallback<IDeliveryShortMessageCallback>; 692 } 693 694 export interface ISendShortMessageCallback { 695 /** Indicates the SMS message sending result. */ 696 result: SendSmsResult; 697 /** Indicates the URI to store the sent SMS message. */ 698 url: string; 699 /** Specifies whether this is the last part of a multi-part SMS message. */ 700 isLastPart: boolean; 701 } 702 703 export interface IDeliveryShortMessageCallback { 704 /** Indicates the SMS delivery report. */ 705 pdu: Array<number>; 706 } 707 708 export enum SendSmsResult { 709 /** 710 * Indicates that the SMS message is successfully sent. 711 */ 712 SEND_SMS_SUCCESS = 0, 713 714 /** 715 * Indicates that sending the SMS message fails due to an unknown reason. 716 */ 717 SEND_SMS_FAILURE_UNKNOWN = 1, 718 719 /** 720 * Indicates that sending the SMS fails because the modem is powered off. 721 */ 722 SEND_SMS_FAILURE_RADIO_OFF = 2, 723 724 /** 725 * Indicates that sending the SMS message fails because the network is unavailable 726 * or does not support sending or reception of SMS messages. 727 */ 728 SEND_SMS_FAILURE_SERVICE_UNAVAILABLE = 3 729 } 730 731 /** 732 * @systemapi Hide this for inner system use. 733 * @since 7 734 */ 735 export enum RanType { 736 TYPE_GSM = 1, // GSM 737 TYPE_CDMA = 2, // CDMA 738 } 739 740 /** 741 * @systemapi Hide this for inner system use. 742 * @since 8 743 */ 744 export interface SmsSegmentsInfo { 745 splitCount: number; 746 encodeCount: number; 747 encodeCountRemaining: number; 748 scheme: SmsEncodingScheme; 749 } 750 751 /** 752 * @systemapi Hide this for inner system use. 753 * @since 8 754 */ 755 export enum SmsEncodingScheme { 756 SMS_ENCODING_UNKNOWN = 0, 757 SMS_ENCODING_7BIT, 758 SMS_ENCODING_8BIT, 759 SMS_ENCODING_16BIT, 760 } 761} 762 763export default sms;