• 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 
16 #ifndef SMS_SERVICE_INTERFACE_H
17 #define SMS_SERVICE_INTERFACE_H
18 
19 #include "i_delivery_short_message_callback.h"
20 #include "i_send_short_message_callback.h"
21 #include "iremote_broker.h"
22 #include "short_message.h"
23 
24 namespace OHOS {
25 namespace Telephony {
26 class ISmsServiceInterface : public IRemoteBroker {
27 public:
28     using MessageID = enum {
29         TEXT_BASED_SMS_DELIVERY = 0,
30         SEND_SMS_TEXT_WITHOUT_SAVE,
31         DATA_BASED_SMS_DELIVERY,
32         SET_SMSC_ADDRESS,
33         GET_SMSC_ADDRESS,
34         ADD_SIM_MESSAGE,
35         DEL_SIM_MESSAGE,
36         UPDATE_SIM_MESSAGE,
37         GET_ALL_SIM_MESSAGE,
38         SET_CB_CONFIG,
39         SET_IMS_SMS_CONFIG,
40         SET_DEFAULT_SMS_SLOT_ID,
41         GET_DEFAULT_SMS_SLOT_ID,
42         SPLIT_MESSAGE,
43         GET_SMS_SEGMENTS_INFO,
44         GET_IMS_SHORT_MESSAGE_FORMAT,
45         IS_IMS_SMS_SUPPORTED,
46         HAS_SMS_CAPABILITY,
47         SEND_MMS,
48         DOWNLOAD_MMS,
49         CREATE_MESSAGE,
50         MMS_BASE64_ENCODE,
51         MMS_BASE64_DECODE,
52         GET_ENCODE_STRING,
53     };
54 
55     /**
56      * @brief SimMessageStatus
57      * from 3GPP TS 27.005 V4.1.0 (2001-09) section 3 Parameter Definitions
58      */
59     using SimMessageStatus = enum {
60         SIM_MESSAGE_STATUS_UNREAD = 0, // 0 REC UNREAD received unread message
61         SIM_MESSAGE_STATUS_READ = 1, // 1 REC READ received read message
62         SIM_MESSAGE_STATUS_UNSENT = 2, // 2 "STO UNSENT" stored unsent message (only applicable to SMs)
63         SIM_MESSAGE_STATUS_SENT = 3, // 3 "STO SENT" stored sent message (only applicable to SMs)
64     };
65 
66     /**
67      * @brief SmsEncodingScheme
68      * from  3GPP TS 23.038 [9] DCS
69      */
70     enum class SmsEncodingScheme {
71         SMS_ENCODING_UNKNOWN = 0,
72         SMS_ENCODING_7BIT,
73         SMS_ENCODING_8BIT,
74         SMS_ENCODING_16BIT,
75     };
76 
77     struct SmsSegmentsInfo {
78         int32_t msgSegCount = 0;
79         int32_t msgEncodingCount = 0;
80         int32_t msgRemainCount = 0;
81         enum class SmsSegmentCodeScheme {
82             SMS_ENCODING_UNKNOWN = 0,
83             SMS_ENCODING_7BIT,
84             SMS_ENCODING_8BIT,
85             SMS_ENCODING_16BIT,
86         } msgCodeScheme = SmsSegmentCodeScheme::SMS_ENCODING_UNKNOWN;
87     };
88 
89     virtual ~ISmsServiceInterface() = default;
90 
91     /**
92      * @brief SendMessage
93      * Sends a text or data SMS message.
94      * @param slotId [in]
95      * @param desAddr [in]
96      * @param scAddr [in]
97      * @param text [in]
98      * @param sendCallback [in]
99      * @param deliverCallback [in]
100      * @return int32_t
101      */
102     virtual int32_t SendMessage(int32_t slotId, const std::u16string desAddr, const std::u16string scAddr,
103         const std::u16string text, const sptr<ISendShortMessageCallback> &sendCallback,
104         const sptr<IDeliveryShortMessageCallback> &deliverCallback) = 0;
105 
106     /**
107      * @brief SendMessage
108      * Sends a text or data SMS message.
109      * @param slotId [in]
110      * @param desAddr [in]
111      * @param scAddr [in]
112      * @param port [in]
113      * @param data [in]
114      * @param dataLen [in]
115      * @param sendCallback [in]
116      * @param deliverCallback [in]
117      * @return int32_t
118      */
119     virtual int32_t SendMessage(int32_t slotId, const std::u16string desAddr, const std::u16string scAddr,
120         uint16_t port, const uint8_t *data, uint16_t dataLen, const sptr<ISendShortMessageCallback> &sendCallback,
121         const sptr<IDeliveryShortMessageCallback> &deliverCallback) = 0;
122 
123     /**
124      * @brief SetSmscAddr
125      * Sets the address for the Short Message Service Center (SMSC) based on a specified slot ID.
126      * @param slotId [in]
127      * @param scAddr [in]
128      * @return int32_t
129      */
130     virtual int32_t SetSmscAddr(int32_t slotId, const std::u16string &scAddr) = 0;
131 
132     /**
133      * @brief GetSmscAddr
134      * Obtains the SMSC address based on a specified slot ID.
135      * @param slotId [in]
136      * @param smscAddress [out]
137      * @return int32_t.
138      */
139     virtual int32_t GetSmscAddr(int32_t slotId, std::u16string &smscAddress) = 0;
140 
141     /**
142      * @brief AddSimMessage
143      * Add a sms to sim card.
144      * @param slotId [in]
145      * @param smsc [in]
146      * @param pdu [in]
147      * @param status [in]
148      * @return int32_t
149      */
150     virtual int32_t AddSimMessage(
151         int32_t slotId, const std::u16string &smsc, const std::u16string &pdu, SimMessageStatus status) = 0;
152 
153     /**
154      * @brief DelSimMessage
155      * Delete a sms in the sim card.
156      * @param slotId [in]
157      * @param msgIndex [in]
158      * @return int32_t
159      */
160     virtual int32_t DelSimMessage(int32_t slotId, uint32_t msgIndex) = 0;
161 
162     /**
163      * @brief UpdateSimMessage
164      * Update a sms in the sim card.
165      * @param slotId [in]
166      * @param msgIndex [in]
167      * @param newStatus [in]
168      * @param pdu [in]
169      * @param smsc [in]
170      * @return int32_t
171      */
172     virtual int32_t UpdateSimMessage(int32_t slotId, uint32_t msgIndex, SimMessageStatus newStatus,
173         const std::u16string &pdu, const std::u16string &smsc) = 0;
174 
175     /**
176      * @brief GetAllSimMessages
177      * Get sim card all the sms.
178      * @param slotId [in]
179      * @param message [out]
180      * @return int32_t
181      */
182     virtual int32_t GetAllSimMessages(int32_t slotId, std::vector<ShortMessage> &message) = 0;
183 
184     /**
185      * @brief SetCBConfig
186      * Configure a cell broadcast in a certain band range.
187      * @param slotId [in]
188      * @param enable [in]
189      * @param fromMsgId [in]
190      * @param toMsgId [in]
191      * @param netType [in]
192      * @return int32_t
193      */
194     virtual int32_t SetCBConfig(
195         int32_t slotId, bool enable, uint32_t fromMsgId, uint32_t toMsgId, uint8_t netType) = 0;
196 
197     /**
198      * @brief SetImsSmsConfig enable or disable IMS SMS.
199      * @param slotId Indicates the card slot index number,
200      * ranging from {@code 0} to the maximum card slot index number supported by the device.
201      * @param enable Indicates enable or disable Ims sms
202      * ranging {@code 0} disable Ims sms {@code 1} enable Ims sms
203      * @return Returns {@code true} if enable or disable Ims Sms success; returns {@code false} otherwise.
204      */
205     virtual bool SetImsSmsConfig(int32_t slotId, int32_t enable) = 0;
206 
207     /**
208      * @brief SetDefaultSmsSlotId
209      * Set the Default Sms Slot Id To SmsService
210      * @param slotId [in]
211      * @return int32_t
212      */
213     virtual int32_t SetDefaultSmsSlotId(int32_t slotId) = 0;
214 
215     /**
216      * @brief GetDefaultSmsSlotId
217      * Get the Default Sms Slot Id From SmsService
218      * @return int32_t
219      */
220     virtual int32_t GetDefaultSmsSlotId() = 0;
221 
222     /**
223      * @brief SplitMessage
224      * calculate Sms Message Split Segment count
225      * @param message [in]
226      * @param splitMessage [out]
227      * @return int32_t
228      */
229     virtual int32_t SplitMessage(const std::u16string &message, std::vector<std::u16string> &splitMessage) = 0;
230 
231     /**
232      * @brief GetSmsSegmentsInfo
233      * calculate the Sms Message Segments Info
234      * @param slotId [in]
235      * @param message [in]
236      * @param force7BitCode [in]
237      * @param info [out]
238      * @return int32_t
239      */
240     virtual int32_t GetSmsSegmentsInfo(
241         int32_t slotId, const std::u16string &message, bool force7BitCode, SmsSegmentsInfo &info) = 0;
242 
243     /**
244      * Check Sms Is supported Ims newtwork
245      * @param slotId Indicates the card slot index number, ranging from {@code 0} to the maximum card slot index number
246      * supported by the device.
247      * @param isSupported Whether ims SMS is supported.
248      * @return nterface execution results.
249      */
250     virtual int32_t IsImsSmsSupported(int32_t slotId, bool &isSupported) = 0;
251 
252     /**
253      * @brief GetImsShortMessageFormat
254      * Get the Ims Short Message Format 3gpp/3gpp2
255      * Hide this for inner system use
256      * @param format Ims short message format
257      * @return int32_t
258      */
259     virtual int32_t GetImsShortMessageFormat(std::u16string &format) = 0;
260 
261     /**
262      * @brief HasSmsCapability
263      * Check whether it is supported Sms Capability
264      * Hide this for inner system use
265      * @return true
266      * @return false
267      */
268     virtual bool HasSmsCapability() = 0;
269 
270     /**
271      * create a short message
272      * @param pdu Indicates pdu code,
273      * @param specification Indicates 3gpp or 3gpp2
274      * @param ShortMessage Indicates a short message object
275      * @return Returns {@code 0} if CreateMessage success
276      */
277     virtual int32_t CreateMessage(std::string pdu, std::string specification, ShortMessage &message) = 0;
278 
279     /**
280      * mms base64 encode
281      * @param src Indicates source string,
282      * @param dest Indicates destination string
283      * @return Returns {@code true} if encode success; returns {@code false} otherwise
284      */
285     virtual bool GetBase64Encode(std::string src, std::string &dest) = 0;
286 
287     /**
288      * mms base64 decode
289      * @param src Indicates source string,
290      * @param dest Indicates destination string
291      * @return Returns {@code true} if decode success; returns {@code false} otherwise
292      */
293     virtual bool GetBase64Decode(std::string src, std::string &dest) = 0;
294 
295     /**
296      * Get Encode String
297      * @param encodeString Indicates output string,
298      * @param charset Indicates character set,
299      * @param valLength Indicates input string length,
300      * @param strEncodeString Indicates input string
301      * @return Returns {@code true} if decode success; returns {@code false} otherwise
302      */
303     virtual bool GetEncodeStringFunc(
304         std::string &encodeString, uint32_t charset, uint32_t valLength, std::string strEncodeString) = 0;
305 
306 public:
307     DECLARE_INTERFACE_DESCRIPTOR(u"OHOS.Telephony.ISmsServiceInterface");
308 };
309 } // namespace Telephony
310 } // namespace OHOS
311 #endif
312