• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2021 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 { paramMock } from "../utils"
17export const SimShortMessage = {
18  shortMessage: ShortMessage,
19  simMessageStatus: SimMessageStatus,
20  indexOnSim: "[PC Preview] unknow indexOnSim"
21}
22export const ShortMessage = {
23  visibleMessageBody: "[PC Preview] unknow visibleMessageBody",
24  visibleRawAddress: "[PC Preview] unknow visibleRawAddress",
25  messageClass: ShortMessageClass,
26  protocolId: "[PC Preview] unknow protocolId",
27  scAddress: "[PC Preview] unknow scAddress",
28  scTimestamp: "[PC Preview] unknow scTimestamp",
29  isReplaceMessage: "[PC Preview] unknow isReplaceMessage",
30  hasReplyPath: "[PC Preview] unknow hasReplyPath",
31  pdu: ["[PC Preview] unknow pdu"],
32  status: "[PC Preview] unknow status",
33  isSmsStatusReportMessage: "[PC Preview] unknow isSmsStatusReportMessage",
34  emailAddress: "[PC Preview] unknow emailAddress",
35  emailMessageBody: "[PC Preview] unknow emailMessageBody",
36  userRawData: ["[PC Preview] unknow userRawData"],
37  isEmailMessage: "[PC Preview] unknow isEmailMessage",
38}
39export const SimMessageStatus = {
40  SIM_MESSAGE_STATUS_FREE: 0,
41  SIM_MESSAGE_STATUS_READ: 1,
42  SIM_MESSAGE_STATUS_UNREAD: 3,
43  SIM_MESSAGE_STATUS_SENT: 5,
44  SIM_MESSAGE_STATUS_UNSENT: 7,
45}
46export const MmsInformation = {
47  messageType: MessageType,
48  mmsType: MmsSendReq,
49  attachment: [MmsAttachment]
50}
51export const MessageType = {
52  TYPE_MMS_SEND_REQ: 128,
53  TYPE_MMS_SEND_CONF: 129,
54  TYPE_MMS_NOTIFICATION_IND: 130,
55  TYPE_MMS_RESP_IND: 131,
56  TYPE_MMS_RETRIEVE_CONF: 132,
57  TYPE_MMS_ACKNOWLEDGE_IND: 133,
58  TYPE_MMS_DELIVERY_IND: 134,
59  TYPE_MMS_READ_REC_IND: 135,
60  TYPE_MMS_READ_ORIG_IND: 136,
61};
62export const MmsAttachment = {
63  contentId: "[PC Preview] unknow contentId",
64  contentLocation: "[PC Preview] unknow contentLocation",
65  contentDisposition: DispositionType,
66  contentTransferEncoding: "[PC Preview] unknow contentTransferEncoding",
67  contentType: "[PC Preview] unknow contentType",
68  isSmil: "[PC Preview] unknow isSmil",
69  path: "[PC Preview] unknow path",
70  inBuff: "[PC Preview] unknow inBuff",
71  fileName: "[PC Preview] unknow fileName",
72  charset: MmsCharSets,
73}
74export const DispositionType = {
75  FROM_DATA: 0,
76  ATTACHMENT: 1,
77  INLINE: 2,
78}
79export const MmsCharSets = {
80  BIG5: 0X07EA,
81  ISO_10646_UCS_2: 0X03E8,
82  ISO_8859_1: 0X04,
83  ISO_8859_2: 0X05,
84  ISO_8859_3: 0X06,
85  ISO_8859_4: 0X07,
86  ISO_8859_5: 0X08,
87  ISO_8859_6: 0X09,
88  ISO_8859_7: 0X10,
89  ISO_8859_8: 0X11,
90  ISO_8859_9: 0X12,
91  SHIFT_JIS: 0X11,
92  US_ASCII: 0X03,
93  UTF_8: 0X6A,
94}
95export const MmsRetrieveConf = {
96  transactionId: "[PC Preview] unknow transactionId",
97  messageId: "[PC Preview] unknow messageId",
98  date: "[PC Preview] unknow date",
99  contentType: "[PC Preview] unknow contentType",
100  to: [MmsAddress],
101  version: MmsVersionType,
102  from: MmsAddress,
103  cc: [MmsAddress],
104  subject: ["[PC Preview] unknow subject"],
105  priority: MmsPriorityType,
106  deliveryReport: "[PC Preview] unknow deliveryReport",
107  readReport: "[PC Preview] unknow readReport",
108  retrieveStatus: "[PC Preview] unknow retrieveStatus",
109  retrieveText: ["[PC Preview] unknow retrieveText"],
110}
111export const MmsAcknowledgeInd = {
112  transactionId: "[PC Preview] unknow transactionId",
113  version: MmsVersionType,
114  reportAllowed: ReportType,
115}
116export const MmsDeliveryInd = {
117  transactionId: "[PC Preview] unknow transactionId",
118  date: "[PC Preview] unknow date",
119  to: [MmsAddress],
120  status: "[PC Preview] unknow status",
121  version: MmsVersionType,
122  messageId: "[PC Preview] unknow messageId",
123}
124export const MmsReadRecInd = {
125  version: MmsVersionType,
126  messageId: "[PC Preview] unknow messageId",
127  to: [MmsAddress],
128  from: MmsAddress,
129  readStatus: "[PC Preview] unknow readStatus",
130  date: "[PC Preview] unknow date",
131}
132export const MmsReadOrigInd = {
133  version: MmsVersionType,
134  messageId: "[PC Preview] unknow messageId",
135  to: [MmsAddress],
136  from: MmsAddress,
137  date: "[PC Preview] unknow date",
138  readStatus: "[PC Preview] unknow readStatus",
139}
140export const MmsRespInd = {
141  transactionId: "[PC Preview] unknow transactionId",
142  status: "[PC Preview] unknow transactionId",
143  version: MmsVersionType,
144  reportAllowed: ReportType,
145}
146export const CBConfigOptions = {
147  slotId: "[PC Preview] unknow slotId",
148  enable: "[PC Preview] unknow enable",
149  startMessageId: "[PC Preview] unknow startMessageId",
150  endMessageId: "[PC Preview] unknow endMessageId",
151  ranType: RanType
152}
153export const SimMessageOptions = {
154  slotId: "[PC Preview] unknow slotId",
155  smsc: "[PC Preview] unknow smsc",
156  pdu: "[PC Preview] unknow pdu",
157  status: SimMessageStatus,
158}
159export const UpdateSimMessageOptions = {
160  slotId: "[PC Preview] unknow slotId",
161  msgIndex: "[PC Preview] unknow msgIndex",
162  newStatus: SimMessageStatus,
163  pdu: "[PC Preview] unknow pdu",
164  smsc: "[PC Preview] unknow smsc",
165}
166export const SendMessageOptions = {
167  slotId: "[PC Preview] unknow slotId",
168  destinationHost: "[PC Preview] unknow destinationHost",
169  serviceCenter: "[PC Preview] unknow serviceCenter",
170  content: "[PC Preview] unknow content",
171  destinationPort: "[PC Preview] unknow destinationPort",
172  sendCallback: ISendShortMessageCallback,
173  deliveryCallback: IDeliveryShortMessageCallback,
174}
175export const IDeliveryShortMessageCallback = {
176  pdu: "[PC Preview] unknow pdu",
177}
178export const ISendShortMessageCallback = {
179  result: SendSmsResult,
180  url: "[PC Preview] unknow url",
181  isLastPart: "[PC Preview] unknow isLastPart",
182}
183export const SendSmsResult = {
184  SEND_SMS_SUCCESS: 0,
185  SEND_SMS_FAILURE_UNKNOWN: 1,
186  SEND_SMS_FAILURE_RADIO_OFF: 2,
187  SEND_SMS_FAILURE_SERVICE_UNAVAILABLE: 3
188}
189export const ShortMessageClass = {
190  UNKNOWN: "[PC Preview] unknow UNKNOWN",
191  INSTANT_MESSAGE: "[PC Preview] unknow INSTANT_MESSAGE",
192  OPTIONAL_MESSAGE: "[PC Preview] unknow OPTIONAL_MESSAGE",
193  SIM_MESSAGE: "[PC Preview] unknow SIM_MESSAGE",
194  FORWARD_MESSAGE: "[PC Preview] unknow FORWARD_MESSAGE",
195}
196export const RanType = {
197  TYPE_GSM: 1,
198  TYPE_CDMA: 2,
199}
200export const ReportType = {
201  MMS_YES: 128,
202  MMS_NO: 129,
203}
204export const MmsNotificationInd = {
205  transactionId: "[PC Preview] unknow transactionId",
206  messageClass: "[PC Preview] unknow messageClass",
207  messageSize: "[PC Preview] unknow messageSize",
208  expiry: "[PC Preview] unknow expiry",
209  contentLocation: "[PC Preview] unknow contentLocation",
210  version: MmsVersionType,
211  from: MmsAddress,
212  subject: "[PC Preview] unknow subject",
213  deliveryReport: ["[PC Preview] unknow deliveryReport"],
214  contentClass: "[PC Preview] unknow contentClass",
215}
216export const MmsAddress = {
217  address: "[PC Preview] unknow address",
218  charset: MmsCharSets,
219}
220export const MmsVersionType = {
221  MMS_VERSION_1_0: 0x10,
222  MMS_VERSION_1_1: 0x11,
223  MMS_VERSION_1_2: 0x12,
224  MMS_VERSION_1_3: 0x13,
225}
226export const MmsPriorityType = {
227  MMS_LOW: 128,
228  MMS_NORMAL: 129,
229  MMS_HIGH: 130,
230}
231export const MmsSendReq = {
232  from: MmsAddress,
233  transactionId: "[PC Preview] unknow transactionId",
234  contentType: "[PC Preview] unknow contentType",
235  version: MmsVersionType,
236  to: [MmsAddress],
237  date: "[PC Preview] unknow date",
238  cc: [MmsAddress],
239  bcc: [MmsAddress],
240  subject: ["[PC Preview] unknow subject"],
241  messageClass: "[PC Preview] unknow messageClass",
242  expiry: "[PC Preview] unknow expiry",
243  priority: MmsPriorityType,
244  senderVisibility: "[PC Preview] unknow senderVisibility",
245  deliveryReport: ["[PC Preview] unknow deliveryReport"],
246  readReport: "[PC Preview] unknow readReport",
247  responseState: "[PC Preview] unknow responseState",
248  transactionId: "[PC Preview] unknow transactionId",
249  version: "[PC Preview] unknow version",
250  messageId: "[PC Preview] unknow messageId",
251}
252export const MmsSendConf = {
253  responseState: "[PC Preview] unknow responseState",
254  transactionId: "[PC Preview] unknow transactionId",
255  version: MmsVersionType,
256  messageId: "[PC Preview] unknow messageId",
257}
258export const SmsSegmentsInfo = {
259  splitCount: "[PC Preview] unknow splitCount",
260  encodeCount: "[PC Preview] unknow encodeCount",
261  encodeCountRemaining: "[PC Preview] unknow encodeCountRemaining",
262  scheme: SmsEncodingScheme,
263}
264export const SmsEncodingScheme = {
265  SMS_ENCODING_UNKNOWN: 0,
266  SMS_ENCODING_7BIT: 1,
267  SMS_ENCODING_8BIT: 2,
268  SMS_ENCODING_16BIT: 3,
269}
270export function mockSMS() {
271  const sms = {
272    SimMessageStatus,
273    SmsEncodingScheme,
274    DispositionType,
275    SendSmsResult,
276    MessageType,
277    ShortMessage,
278    MmsCharSets,
279    MmsPriorityType,
280    MmsVersionType,
281    ReportType,
282    SimShortMessage,
283    RanType,
284    ShortMessageClass,
285    splitMessage: function (...args) {
286      console.warn("telephony.sms.splitMessage interface mocked in the Previewer. How this interface works on the Previewer may" +
287        " be different from that on a real device.")
288      const len = args.length
289      if (typeof args[len - 1] === 'function') {
290        args[len - 1].call(this, paramMock.businessErrorMock, [paramMock.paramStringMock]);
291      } else {
292        return new Promise((resolve, reject) => {
293          resolve([paramMock.paramStringMock]);
294        })
295      }
296    },
297    createMessage: function (...args) {
298      console.warn("telephony.sms.createMessage interface mocked in the Previewer. How this interface works on the Previewer may" +
299        " be different from that on a real device.")
300      const len = args.length
301      if (typeof args[len - 1] === 'function') {
302        args[len - 1].call(this, paramMock.businessErrorMock, ShortMessage);
303      } else {
304        return new Promise((resolve, reject) => {
305          resolve(ShortMessage);
306        })
307      }
308    },
309    getSmsSegmentsInfo: function (...args) {
310      console.warn("telephony.sms.getSmsSegmentsInfo interface mocked in the Previewer. How this interface works on the Previewer may" +
311        " be different from that on a real device.")
312      const len = args.length
313      if (typeof args[len - 1] === 'function') {
314        args[len - 1].call(this, SmsSegmentsInfo);
315      } else {
316        return new Promise((resolve, reject) => {
317          resolve(SmsSegmentsInfo);
318        })
319      }
320    },
321    isImsSmsSupported: function (...args) {
322      console.warn("telephony.sms.isImsSmsSupported interface mocked in the Previewer. How this interface works on the Previewer may" +
323        " be different from that on a real device.")
324      const len = args.length
325      if (typeof args[len - 1] === 'function') {
326        args[len - 1].call(this, paramMock.paramBooleanMock);
327      } else {
328        return new Promise((resolve, reject) => {
329          resolve(paramMock.paramBooleanMock);
330        })
331      }
332    },
333    getImsShortMessageFormat: function (...args) {
334      console.warn("telephony.sms.getImsShortMessageFormat interface mocked in the Previewer. How this interface works on the Previewer may" +
335        " be different from that on a real device.")
336      const len = args.length
337      if (typeof args[len - 1] === 'function') {
338        args[len - 1].call(this, paramMock.paramStringMock);
339      } else {
340        return new Promise((resolve, reject) => {
341          resolve(paramMock.paramStringMock);
342        })
343      }
344    },
345    decodeMms: function (...args) {
346      console.warn("telephony.sms.decodeMms interface mocked in the Previewer. How this interface works on the Previewer may" +
347        " be different from that on a real device.")
348      const len = args.length
349      if (typeof args[len - 1] === 'function') {
350        args[len - 1].call(this, MmsInformation);
351      } else {
352        return new Promise((resolve, reject) => {
353          resolve(MmsInformation);
354        })
355      }
356    },
357    encodeMms: function (...args) {
358      console.warn("telephony.sms.encodeMms interface mocked in the Previewer. How this interface works on the Previewer may" +
359        " be different from that on a real device.")
360      const len = args.length
361      if (typeof args[len - 1] === 'function') {
362        args[len - 1].call(this, paramMock.paramArrayMock);
363      } else {
364        return new Promise((resolve, reject) => {
365          resolve(paramMock.paramArrayMock);
366        })
367      }
368    },
369    isImsSmsSuppo: function (...args) {
370      console.warn("telephony.sms.isImsSmsSuppo interface mocked in the Previewer. How this interface works on the Previewer may" +
371        " be different from that on a real device.")
372      const len = args.length
373      if (typeof args[len - 1] === 'function') {
374        args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramBooleanMock);
375      } else {
376        return new Promise((resolve, reject) => {
377          resolve(paramMock.paramBooleanMock);
378        })
379      }
380    },
381    sendMessage: function (...args) {
382      console.warn("telephony.sms.sendMessage interface mocked in the Previewer. How this interface works on the Previewer may" +
383        " be different from that on a real device.")
384    },
385    setDefaultSmsSlotId: function (...args) {
386      console.warn("telephony.sms.setDefaultSmsSlotId interface mocked in the Previewer. How this interface works on the Previewer may" +
387        " be different from that on a real device.")
388      const len = args.length
389      if (typeof args[len - 1] === 'function') {
390        args[len - 1].call(this, paramMock.businessErrorMock);
391      } else {
392        return new Promise((resolve, reject) => {
393          resolve();
394        })
395      }
396    },
397    getDefaultSmsSlotId: function (...args) {
398      console.warn("telephony.sms.getDefaultSmsSlotId interface mocked in the Previewer. How this interface works on the Previewer may" +
399        " be different from that on a real device.")
400      const len = args.length
401      if (typeof args[len - 1] === 'function') {
402        args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramNumberMock);
403      } else {
404        return new Promise((resolve, reject) => {
405          resolve(paramMock.paramNumberMock);
406        })
407      }
408    },
409    setSmscAddr: function (...args) {
410      console.warn("telephony.sms.setSmscAddr interface mocked in the Previewer. How this interface works on the Previewer may" +
411        " be different from that on a real device.")
412      const len = args.length
413      if (typeof args[len - 1] === 'function') {
414        args[len - 1].call(this, paramMock.businessErrorMock);
415      } else {
416        return new Promise((resolve, reject) => {
417          resolve();
418        })
419      }
420    },
421    getSmscAddr: function (...args) {
422      console.warn("telephony.sms.getSmscAddr interface mocked in the Previewer. How this interface works on the Previewer may" +
423        " be different from that on a real device.")
424      const len = args.length
425      if (typeof args[len - 1] === 'function') {
426        args[len - 1].call(this, paramMock.businessErrorMock, paramMock.paramStringMock);
427      } else {
428        return new Promise((resolve, reject) => {
429          resolve(paramMock.paramStringMock);
430        })
431      }
432    },
433    hasSmsCapability: function () {
434      console.warn("telephony.sms.hasSmsCapability interface mocked in the Previewer. How this interface works on the Previewer may" +
435        " be different from that on a real device.")
436      return paramMock.paramBooleanMock;
437    },
438    addSimMessage: function (...args) {
439      console.warn("telephony.sms.addSimMessage interface mocked in the Previewer. How this interface works on the Previewer may" +
440        " be different from that on a real device.")
441      const len = args.length
442      if (typeof args[len - 1] === 'function') {
443        args[len - 1].call(this, paramMock.businessErrorMock);
444      } else {
445        return new Promise((resolve, reject) => {
446          resolve();
447        })
448      }
449    },
450    delSimMessage: function (...args) {
451      console.warn("telephony.sms.delSimMessage interface mocked in the Previewer. How this interface works on the Previewer may" +
452        " be different from that on a real device.")
453      const len = args.length
454      if (typeof args[len - 1] === 'function') {
455        args[len - 1].call(this, paramMock.businessErrorMock);
456      } else {
457        return new Promise((resolve, reject) => {
458          resolve();
459        })
460      }
461    },
462    updateSimMessage: function (...args) {
463      console.warn("telephony.sms.updateSimMessage interface mocked in the Previewer. How this interface works on the Previewer may" +
464        " be different from that on a real device.")
465      const len = args.length
466      if (typeof args[len - 1] === 'function') {
467        args[len - 1].call(this, paramMock.businessErrorMock);
468      } else {
469        return new Promise((resolve, reject) => {
470          resolve();
471        })
472      }
473    },
474    getAllSimMessages: function (...args) {
475      console.warn("telephony.sms.getAllSimMessages interface mocked in the Previewer. How this interface works on the Previewer may" +
476        " be different from that on a real device.")
477      const len = args.length
478      if (typeof args[len - 1] === 'function') {
479        args[len - 1].call(this, paramMock.businessErrorMock, [SimShortMessage]);
480      } else {
481        return new Promise((resolve, reject) => {
482          resolve([SimShortMessage]);
483        })
484      }
485    },
486    setCBConfig: function (...args) {
487      console.warn("telephony.sms.setCBConfig interface mocked in the Previewer. How this interface works on the Previewer may" +
488        " be different from that on a real device.")
489      const len = args.length
490      if (typeof args[len - 1] === 'function') {
491        args[len - 1].call(this, paramMock.businessErrorMock);
492      } else {
493        return new Promise((resolve, reject) => {
494          resolve();
495        })
496      }
497    }
498  }
499  return sms
500}