• 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 "short_message.h"
22 
23 #include "iremote_broker.h"
24 
25 namespace OHOS {
26 namespace Telephony {
27 class ISmsServiceInterface : public IRemoteBroker {
28 public:
29     using MessageID = enum {
30         TEXT_BASED_SMS_DELIVERY = 0,
31         SEND_SMS_TEXT_WITHOUT_SAVE,
32         DATA_BASED_SMS_DELIVERY,
33         SET_SMSC_ADDRESS,
34         GET_SMSC_ADDRESS,
35         ADD_SIM_MESSAGE,
36         DEL_SIM_MESSAGE,
37         UPDATE_SIM_MESSAGE,
38         GET_ALL_SIM_MESSAGE,
39         SET_CB_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     };
48 
49     /**
50      * @brief SimMessageStatus
51      * from 3GPP TS 27.005 V4.1.0 (2001-09) section 3 Parameter Definitions
52      */
53     using SimMessageStatus = enum {
54         SIM_MESSAGE_STATUS_UNREAD = 0, // 0 REC UNREAD received unread message
55         SIM_MESSAGE_STATUS_READ = 1, // 1 REC READ received read message
56         SIM_MESSAGE_STATUS_UNSENT = 2, // 2 "STO UNSENT" stored unsent message (only applicable to SMs)
57         SIM_MESSAGE_STATUS_SENT = 3, // 3 "STO SENT" stored sent message (only applicable to SMs)
58     };
59 
60     /**
61      * @brief SmsEncodingScheme
62      * from  3GPP TS 23.038 [9] DCS
63      */
64     enum class SmsEncodingScheme {
65         SMS_ENCODING_UNKNOWN = 0,
66         SMS_ENCODING_7BIT,
67         SMS_ENCODING_8BIT,
68         SMS_ENCODING_16BIT,
69     };
70 
71     using SmsSegmentsInfo = struct {
72         int32_t msgSegCount = 0;
73         int32_t msgEncodingCount = 0;
74         int32_t msgRemainCount = 0;
75         enum class SmsSegmentCodeScheme {
76             SMS_ENCODING_UNKNOWN = 0,
77             SMS_ENCODING_7BIT,
78             SMS_ENCODING_8BIT,
79             SMS_ENCODING_16BIT,
80         } msgCodeScheme = SmsSegmentCodeScheme::SMS_ENCODING_UNKNOWN;
81     };
82 
83     virtual ~ISmsServiceInterface() = default;
84 
85     /**
86      * @brief SendMessage
87      * Sends a text or data SMS message.
88      * @param slotId [in]
89      * @param desAddr [in]
90      * @param scAddr [in]
91      * @param text [in]
92      * @param sendCallback [in]
93      * @param deliverCallback [in]
94      */
95     virtual void SendMessage(int32_t slotId, const std::u16string desAddr, const std::u16string scAddr,
96         const std::u16string text, const sptr<ISendShortMessageCallback> &sendCallback,
97         const sptr<IDeliveryShortMessageCallback> &deliverCallback) = 0;
98 
99     /**
100      * @brief SendMessage
101      * Sends a text or data SMS message.
102      * @param slotId [in]
103      * @param desAddr [in]
104      * @param scAddr [in]
105      * @param port [in]
106      * @param data [in]
107      * @param dataLen [in]
108      * @param sendCallback [in]
109      * @param deliverCallback [in]
110      */
111     virtual void SendMessage(int32_t slotId, const std::u16string desAddr, const std::u16string scAddr,
112         uint16_t port, const uint8_t *data, uint16_t dataLen, const sptr<ISendShortMessageCallback> &sendCallback,
113         const sptr<IDeliveryShortMessageCallback> &deliverCallback) = 0;
114 
115     /**
116      * @brief SetSmscAddr
117      * Sets the address for the Short Message Service Center (SMSC) based on a specified slot ID.
118      * @param slotId [in]
119      * @param scAddr [in]
120      * @return true
121      * @return false
122      */
123     virtual bool SetSmscAddr(int32_t slotId, const std::u16string &scAddr) = 0;
124 
125     /**
126      * @brief GetSmscAddr
127      * Obtains the SMSC address based on a specified slot ID.
128      * @param slotId [in]
129      * @return std::u16string
130      */
131     virtual std::u16string GetSmscAddr(int32_t slotId) = 0;
132 
133     /**
134      * @brief AddSimMessage
135      * Add a sms to sim card.
136      * @param slotId [in]
137      * @param smsc [in]
138      * @param pdu [in]
139      * @param status [in]
140      * @return true
141      * @return false
142      */
143     virtual bool AddSimMessage(
144         int32_t slotId, const std::u16string &smsc, const std::u16string &pdu, SimMessageStatus status) = 0;
145 
146     /**
147      * @brief DelSimMessage
148      * Delete a sms in the sim card.
149      * @param slotId [in]
150      * @param msgIndex [in]
151      * @return true
152      * @return false
153      */
154     virtual bool DelSimMessage(int32_t slotId, uint32_t msgIndex) = 0;
155 
156     /**
157      * @brief UpdateSimMessage
158      * Update a sms in the sim card.
159      * @param slotId [in]
160      * @param msgIndex [in]
161      * @param newStatus [in]
162      * @param pdu [in]
163      * @param smsc [in]
164      * @return true
165      * @return false
166      */
167     virtual bool UpdateSimMessage(int32_t slotId, uint32_t msgIndex, SimMessageStatus newStatus,
168         const std::u16string &pdu, const std::u16string &smsc) = 0;
169 
170     /**
171      * @brief GetAllSimMessages
172      * Get sim card all the sms.
173      * @param slotId [in]
174      * @return std::vector<ShortMessage>
175      */
176     virtual std::vector<ShortMessage> GetAllSimMessages(int32_t slotId) = 0;
177 
178     /**
179      * @brief SetCBConfig
180      * Configure a cell broadcast in a certain band range.
181      * @param slotId [in]
182      * @param enable [in]
183      * @param fromMsgId [in]
184      * @param toMsgId [in]
185      * @param netType [in]
186      * @return true
187      * @return false
188      */
189     virtual bool SetCBConfig(
190         int32_t slotId, bool enable, uint32_t fromMsgId, uint32_t toMsgId, uint8_t netType) = 0;
191 
192     /**
193      * @brief SetDefaultSmsSlotId
194      * Set the Default Sms Slot Id To SmsService
195      * @param slotId [in]
196      * @return true
197      * @return false
198      */
199     virtual bool SetDefaultSmsSlotId(int32_t slotId) = 0;
200 
201     /**
202      * @brief GetDefaultSmsSlotId
203      * Get the Default Sms Slot Id From SmsService
204      * @return int32_t
205      */
206     virtual int32_t GetDefaultSmsSlotId() = 0;
207 
208     /**
209      * @brief SplitMessage
210      * calculate Sms Message Split Segment count
211      * @param message [in]
212      * @return std::vector<std::u16string>
213      */
214     virtual std::vector<std::u16string> SplitMessage(const std::u16string &message) = 0;
215 
216     /**
217      * @brief GetSmsSegmentsInfo
218      * calculate the Sms Message Segments Info
219      * @param slotId [in]
220      * @param message [in]
221      * @param force7BitCode [in]
222      * @param info [out]
223      * @return true
224      * @return false
225      */
226     virtual bool GetSmsSegmentsInfo(
227         int32_t slotId, const std::u16string &message, bool force7BitCode, SmsSegmentsInfo &info) = 0;
228 
229     /**
230      * @brief IsImsSmsSupported
231      * Check Sms Is supported Ims newtwork
232      * Hide this for inner system use
233      * @return true
234      * @return false
235      */
236     virtual bool IsImsSmsSupported() = 0;
237 
238     /**
239      * @brief GetImsShortMessageFormat
240      * Get the Ims Short Message Format 3gpp/3gpp2
241      * Hide this for inner system use
242      * @return std::u16string
243      */
244     virtual std::u16string GetImsShortMessageFormat() = 0;
245 
246     /**
247      * @brief HasSmsCapability
248      * Check whether it is supported Sms Capability
249      * Hide this for inner system use
250      * @return true
251      * @return false
252      */
253     virtual bool HasSmsCapability() = 0;
254 
255 public:
256     DECLARE_INTERFACE_DESCRIPTOR(u"OHOS.Telephony.ISmsServiceInterface");
257 };
258 } // namespace Telephony
259 } // namespace OHOS
260 #endif
261