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 * Sends a MMS message. 340 * 341 * @param mmsParam Indicates the parameters of the MMS message. 342 * @param callback Indicates the execution result. For error code, see MmsFailCode. 343 * @permission ohos.permission.SEND_MESSAGES 344 * @since 9 345 */ 346 function sendMms(mmsParam: MmsParam, callback: AsyncCallback<void>): void; 347 function sendMms(mmsParam: MmsParam): Promise<void>; 348 349 /** 350 * Downloads a MMS message. 351 * 352 * @param mmsParam Indicates the parameters of the MMS message. 353 * @param callback Indicates the execution result. For error code, see MmsFailCode. 354 * @permission ohos.permission.RECEIVE_MMS 355 * @since 9 356 */ 357 function downloadMms(mmsParam: MmsParam, callback: AsyncCallback<void>): void; 358 function downloadMms(mmsParam: MmsParam): Promise<void>; 359 360 /** 361 * @since 9 362 */ 363 export interface MmsParam { 364 /** Indicates the ID of the SIM card slot used for sending the Mms message. */ 365 slotId: number; 366 /** Indicates the Mmsc used for sending the Mms message. */ 367 mmsc: string; 368 /** Indicates the Mms pdu url used for sending the Mms message. */ 369 data: string; 370 /** Indicates the Mms UA and Mms UaProf used for sending the Mms message. */ 371 mmsConfig?: MmsConfig; 372 } 373 374 /** 375 * @since 9 376 */ 377 export interface MmsConfig { 378 /** Indicates the User Agent used for the Mms message. */ 379 userAgent: string; 380 /** Indicates the User Agent Profile for the Mms message. */ 381 userAgentProfile: string; 382 } 383 384 /** 385 * @systemapi Hide this for inner system use. 386 * @since 8 387 */ 388 export interface MmsSendReq { 389 from: MmsAddress; 390 transactionId: string; 391 contentType: string; 392 version: MmsVersionType; 393 to?: Array<MmsAddress>; 394 date?: number; 395 cc?: Array<MmsAddress>; 396 bcc?: Array<MmsAddress>; 397 subject?: string; 398 messageClass?: number; 399 expiry?: number; 400 priority?: MmsPriorityType; 401 senderVisibility?: number; 402 deliveryReport?: number; 403 readReport?: number; 404 } 405 406 /** 407 * @systemapi Hide this for inner system use. 408 * @since 8 409 */ 410 export interface MmsSendConf { 411 responseState: number; 412 transactionId: string; 413 version: MmsVersionType; 414 messageId?: string; 415 } 416 417 /** 418 * @systemapi Hide this for inner system use. 419 * @since 8 420 */ 421 export interface MmsNotificationInd { 422 transactionId: string; 423 messageClass: number; 424 messageSize: number; 425 expiry: number; 426 contentLocation: string; 427 version: MmsVersionType; 428 from?: MmsAddress; 429 subject?: string; 430 deliveryReport?: number; 431 contentClass?: number; 432 } 433 434 /** 435 * @systemapi Hide this for inner system use. 436 * @since 8 437 */ 438 export interface MmsRespInd { 439 transactionId: string; 440 status: number; 441 version: MmsVersionType; 442 reportAllowed?: ReportType; 443 } 444 445 /** 446 * @systemapi Hide this for inner system use. 447 * @since 8 448 */ 449 export interface MmsRetrieveConf { 450 transactionId: string; 451 messageId: string; 452 date: number; 453 contentType: string; 454 to: Array<MmsAddress>; 455 version: MmsVersionType; 456 from?: MmsAddress; 457 cc?: Array<MmsAddress>; 458 subject?: string; 459 priority?: MmsPriorityType; 460 deliveryReport?: number; 461 readReport?: number; 462 retrieveStatus?: number; 463 retrieveText?: string; 464 } 465 466 /** 467 * @systemapi Hide this for inner system use. 468 * @since 8 469 */ 470 export interface MmsAcknowledgeInd { 471 transactionId: string; 472 version: MmsVersionType; 473 reportAllowed?: ReportType; 474 } 475 476 /** 477 * @systemapi Hide this for inner system use. 478 * @since 8 479 */ 480 export interface MmsDeliveryInd { 481 messageId: string; 482 date: number; 483 to: Array<MmsAddress>; 484 status: number; 485 version: MmsVersionType; 486 } 487 488 /** 489 * @systemapi Hide this for inner system use. 490 * @since 8 491 */ 492 export interface MmsReadOrigInd { 493 version: MmsVersionType; 494 messageId: string; 495 to: Array<MmsAddress>; 496 from: MmsAddress; 497 date: number; 498 readStatus: number; 499 } 500 501 /** 502 * @systemapi Hide this for inner system use. 503 * @since 8 504 */ 505 export interface MmsReadRecInd { 506 version: MmsVersionType; 507 messageId: string; 508 to: Array<MmsAddress>; 509 from: MmsAddress; 510 readStatus: number; 511 date?: number; 512 } 513 514 /** 515 * @systemapi Hide this for inner system use. 516 * @since 8 517 */ 518 export interface MmsAttachment { 519 contentId: string; 520 contentLocation: string; 521 contentDisposition: DispositionType; 522 contentTransferEncoding: string; 523 contentType: string; 524 isSmil: boolean; 525 path?: string; 526 inBuff?: Array<number>; 527 fileName?: string; 528 charset?: MmsCharSets; 529 } 530 531 /** 532 * @systemapi Hide this for inner system use. 533 * @since 8 534 */ 535 export interface MmsAddress { 536 address: string; 537 charset: MmsCharSets; 538 } 539 540 /** 541 * @systemapi Hide this for inner system use. 542 * @since 8 543 */ 544 export enum MessageType { 545 TYPE_MMS_SEND_REQ = 128, 546 TYPE_MMS_SEND_CONF, 547 TYPE_MMS_NOTIFICATION_IND, 548 TYPE_MMS_RESP_IND, 549 TYPE_MMS_RETRIEVE_CONF, 550 TYPE_MMS_ACKNOWLEDGE_IND, 551 TYPE_MMS_DELIVERY_IND, 552 TYPE_MMS_READ_REC_IND, 553 TYPE_MMS_READ_ORIG_IND, 554 } 555 556 /** 557 * @since 9 558 */ 559 export enum MmsFailCode { 560 MMS_FAIL_NONE_ERROR = 0, 561 MMS_FAIL_UNKNOWN_ERROR, 562 MMS_FAIL_APN_INVALID, 563 MMS_FAIL_CONNECT_MMS_ERROR, 564 MMS_FAIL_HTTP_ERROR, 565 MMS_FAIL_IO_ERROR, 566 MMS_FAIL_RETRY_ERROR, 567 MMS_FAIL_CONFIGURATION_ERROR, 568 MMS_FAIL_DATA_NETWORK_ERROR, 569 } 570 571 /** 572 * @systemapi Hide this for inner system use. 573 * @since 8 574 */ 575 export enum MmsPriorityType { 576 MMS_LOW = 128, 577 MMS_NORMAL, 578 MMS_HIGH, 579 } 580 581 /** 582 * @systemapi Hide this for inner system use. 583 * @since 8 584 */ 585 export enum MmsVersionType { 586 MMS_VERSION_1_0 = 0x10, 587 MMS_VERSION_1_1, 588 MMS_VERSION_1_2, 589 MMS_VERSION_1_3, 590 } 591 592 /** 593 * @systemapi Hide this for inner system use. 594 * @since 8 595 */ 596 export enum MmsCharSets { 597 BIG5 = 0X07EA, 598 ISO_10646_UCS_2 = 0X03E8, 599 ISO_8859_1 = 0X04, 600 ISO_8859_2, 601 ISO_8859_3, 602 ISO_8859_4, 603 ISO_8859_5, 604 ISO_8859_6, 605 ISO_8859_7, 606 ISO_8859_8, 607 ISO_8859_9, 608 SHIFT_JIS = 0X11, 609 US_ASCII = 0X03, 610 UTF_8 = 0X6A, 611 } 612 613 /** 614 * @systemapi Hide this for inner system use. 615 * @since 8 616 */ 617 export enum DispositionType { 618 FROM_DATA = 0, 619 ATTACHMENT, 620 INLINE, 621 } 622 623 /** 624 * @systemapi Hide this for inner system use. 625 * @since 8 626 */ 627 export enum ReportType { 628 MMS_YES = 128, 629 MMS_NO, 630 } 631 632 /** 633 * @systemapi Hide this for inner system use. 634 * @since 7 635 */ 636 export interface CBConfigOptions { 637 slotId: number; 638 enable: boolean; 639 startMessageId: number; 640 endMessageId: number; 641 ranType: RanType; 642 } 643 644 /** 645 * @systemapi Hide this for inner system use. 646 * @since 7 647 */ 648 export interface SimMessageOptions { 649 slotId: number; 650 smsc: string; 651 pdu: string; 652 status: SimMessageStatus; 653 } 654 655 /** 656 * @systemapi Hide this for inner system use. 657 * @since 7 658 */ 659 export interface UpdateSimMessageOptions { 660 slotId: number; 661 msgIndex: number; 662 newStatus: SimMessageStatus; 663 pdu: string; 664 smsc: string; 665 } 666 667 export interface ShortMessage { 668 /** Indicates the SMS message body. */ 669 visibleMessageBody: string; 670 /** Indicates the address of the sender, which is to be displayed on the UI. */ 671 visibleRawAddress: string; 672 /** Indicates the SMS type. */ 673 messageClass: ShortMessageClass; 674 /** Indicates the protocol identifier. */ 675 protocolId: number; 676 /** Indicates the short message service center (SMSC) address. */ 677 scAddress: string; 678 /** Indicates the SMSC timestamp. */ 679 scTimestamp: number; 680 /** Indicates whether the received SMS is a "replace short message". */ 681 isReplaceMessage: boolean; 682 /** Indicates whether the received SMS contains "TP-Reply-Path". */ 683 hasReplyPath: boolean; 684 /** Indicates Protocol Data Units (PDUs) from an SMS message. */ 685 pdu: Array<number>; 686 /** 687 * Indicates the SMS message status from the SMS-STATUS-REPORT message sent by the 688 * Short Message Service Center (SMSC). 689 */ 690 status: number; 691 /** Indicates whether the current message is SMS-STATUS-REPORT. */ 692 isSmsStatusReportMessage: boolean; 693 } 694 695 /** 696 * @systemapi Hide this for inner system use. 697 * @since 7 698 */ 699 export interface SimShortMessage { 700 shortMessage: ShortMessage; 701 702 /** Indicates the storage status of SMS messages in the SIM */ 703 simMessageStatus: SimMessageStatus; 704 /** Indicates the index of SMS messages in the SIM */ 705 indexOnSim: number; 706 } 707 708 /** 709 * @systemapi Hide this for inner system use. 710 * @since 7 711 */ 712 export enum SimMessageStatus { 713 /** status free space ON SIM */ 714 SIM_MESSAGE_STATUS_FREE = 0, 715 /** REC READ received read message */ 716 SIM_MESSAGE_STATUS_READ = 1, 717 /** REC UNREAD received unread message */ 718 SIM_MESSAGE_STATUS_UNREAD = 3, 719 /** STO SENT stored sent message (only applicable to SMs) */ 720 SIM_MESSAGE_STATUS_SENT = 5, 721 /** STO UNSENT stored unsent message (only applicable to SMs) */ 722 SIM_MESSAGE_STATUS_UNSENT = 7, 723 } 724 725 export enum ShortMessageClass { 726 /** Indicates an unknown type. */ 727 UNKNOWN, 728 /** Indicates an instant message, which is displayed immediately after being received. */ 729 INSTANT_MESSAGE, 730 /** Indicates an SMS message that can be stored on the device or SIM card based on the storage status. */ 731 OPTIONAL_MESSAGE, 732 /** Indicates an SMS message containing SIM card information, which is to be stored in a SIM card. */ 733 SIM_MESSAGE, 734 /** Indicates an SMS message to be forwarded to another device. */ 735 FORWARD_MESSAGE 736 } 737 738 export interface SendMessageOptions { 739 /** Indicates the ID of the SIM card slot used for sending the SMS message. */ 740 slotId: number; 741 /** Indicates the address to which the SMS message is sent. */ 742 destinationHost: string; 743 /** Indicates the SMSC address. If the value is {@code null}, the default SMSC address of the SIM card*/ 744 serviceCenter?: string; 745 /** If the content is a string, this is a short message. If the content is a byte array, this is a data message. */ 746 content: string | Array<number>; 747 /** If send data message, destinationPort is mandatory. Otherwise is optional. */ 748 destinationPort?: number; 749 /** Indicates the callback invoked after the SMS message is sent. */ 750 sendCallback?: AsyncCallback<ISendShortMessageCallback>; 751 /** Indicates the callback invoked after the SMS message is delivered. */ 752 deliveryCallback?: AsyncCallback<IDeliveryShortMessageCallback>; 753 } 754 755 export interface ISendShortMessageCallback { 756 /** Indicates the SMS message sending result. */ 757 result: SendSmsResult; 758 /** Indicates the URI to store the sent SMS message. */ 759 url: string; 760 /** Specifies whether this is the last part of a multi-part SMS message. */ 761 isLastPart: boolean; 762 } 763 764 export interface IDeliveryShortMessageCallback { 765 /** Indicates the SMS delivery report. */ 766 pdu: Array<number>; 767 } 768 769 export enum SendSmsResult { 770 /** 771 * Indicates that the SMS message is successfully sent. 772 */ 773 SEND_SMS_SUCCESS = 0, 774 775 /** 776 * Indicates that sending the SMS message fails due to an unknown reason. 777 */ 778 SEND_SMS_FAILURE_UNKNOWN = 1, 779 780 /** 781 * Indicates that sending the SMS fails because the modem is powered off. 782 */ 783 SEND_SMS_FAILURE_RADIO_OFF = 2, 784 785 /** 786 * Indicates that sending the SMS message fails because the network is unavailable 787 * or does not support sending or reception of SMS messages. 788 */ 789 SEND_SMS_FAILURE_SERVICE_UNAVAILABLE = 3 790 } 791 792 /** 793 * @systemapi Hide this for inner system use. 794 * @since 7 795 */ 796 export enum RanType { 797 TYPE_GSM = 1, // GSM 798 TYPE_CDMA = 2, // CDMA 799 } 800 801 /** 802 * @systemapi Hide this for inner system use. 803 * @since 8 804 */ 805 export interface SmsSegmentsInfo { 806 splitCount: number; 807 encodeCount: number; 808 encodeCountRemaining: number; 809 scheme: SmsEncodingScheme; 810 } 811 812 /** 813 * @systemapi Hide this for inner system use. 814 * @since 8 815 */ 816 export enum SmsEncodingScheme { 817 SMS_ENCODING_UNKNOWN = 0, 818 SMS_ENCODING_7BIT, 819 SMS_ENCODING_8BIT, 820 SMS_ENCODING_16BIT, 821 } 822} 823 824export default sms;