• 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_PROXY_H
17 #define SMS_SERVICE_PROXY_H
18 
19 #include "i_sms_service_interface.h"
20 #include "iremote_object.h"
21 #include "iremote_proxy.h"
22 
23 namespace OHOS {
24 namespace Telephony {
25 class SmsServiceProxy : public IRemoteProxy<ISmsServiceInterface> {
26 public:
27     explicit SmsServiceProxy(const sptr<IRemoteObject> &impl);
28     virtual ~SmsServiceProxy() = default;
29 
30     /**
31      * @brief SendMessage
32      * Sends a text or data SMS message.
33      * @param slotId [in]
34      * @param desAddr [in]
35      * @param scAddr [in]
36      * @param text [in]
37      * @param sendCallback [in]
38      * @param deliverCallback [in]
39      * @return int32_t
40      */
41     int32_t SendMessage(int32_t slotId, const std::u16string desAddr, const std::u16string scAddr,
42         const std::u16string text, const sptr<ISendShortMessageCallback> &sendCallback,
43         const sptr<IDeliveryShortMessageCallback> &deliverCallback) override;
44 
45     /**
46      * @brief SendMessage
47      * Sends a text or data SMS message.
48      * @param slotId [in]
49      * @param desAddr [in]
50      * @param scAddr [in]
51      * @param port [in]
52      * @param data [in]
53      * @param dataLen [in]
54      * @param sendCallback [in]
55      * @param deliverCallback [in].
56      * @return int32_t
57      */
58     int32_t SendMessage(int32_t slotId, const std::u16string desAddr, const std::u16string scAddr, uint16_t port,
59         const uint8_t *data, uint16_t dataLen, const sptr<ISendShortMessageCallback> &sendCallback,
60         const sptr<IDeliveryShortMessageCallback> &deliverCallback) override;
61 
62     /**
63      * @brief SetSmscAddr
64      * Sets the address for the Short Message Service Center (SMSC) based on a specified slot ID.
65      * @param slotId [in]
66      * @param scAddr [in]
67      * @return int32_t
68      */
69     int32_t SetSmscAddr(int32_t slotId, const std::u16string &scAddr) override;
70 
71     /**
72      * @brief GetSmscAddr
73      * Obtains the SMSC address based on a specified slot ID.
74      * @param slotId [in]
75      * @param smscAddress [out]
76      * @return Interface execution results.
77      */
78     int32_t GetSmscAddr(int32_t slotId, std::u16string &smscAddress) override;
79 
80     /**
81      * @brief AddSimMessage
82      * Add a sms to sim card.
83      * @param slotId [in]
84      * @param smsc [in]
85      * @param pdu [in]
86      * @param status [in]
87      * @return int32_t
88      */
89     int32_t AddSimMessage(
90         int32_t slotId, const std::u16string &smsc, const std::u16string &pdu, SimMessageStatus status) override;
91 
92     /**
93      * @brief DelSimMessage
94      * Delete a sms in the sim card.
95      * @param slotId [in]
96      * @param msgIndex [in]
97      * @return int32_t
98      */
99     int32_t DelSimMessage(int32_t slotId, uint32_t msgIndex) override;
100 
101     /**
102      * @brief UpdateSimMessage
103      * Update a sms in the sim card.
104      * @param slotId [in]
105      * @param msgIndex [in]
106      * @param newStatus [in]
107      * @param pdu [in]
108      * @param smsc [in]
109      * @return int32_t
110      */
111     int32_t UpdateSimMessage(int32_t slotId, uint32_t msgIndex, SimMessageStatus newStatus, const std::u16string &pdu,
112         const std::u16string &smsc) override;
113 
114     /**
115      * @brief GetAllSimMessages
116      * Get sim card all the sms.
117      * @param slotId [in]
118      * @return int32_t
119      */
120     int32_t GetAllSimMessages(int32_t slotId, std::vector<ShortMessage> &message) override;
121 
122     /**
123      * @brief SetCBConfig
124      * Configure a cell broadcast in a certain band range.
125      * @param slotId [in]
126      * @param enable [in]
127      * @param fromMsgId [in]
128      * @param toMsgId [in]
129      * @param netType [in]
130      * @return true
131      * @return false
132      */
133     int32_t SetCBConfig(int32_t slotId, bool enable, uint32_t fromMsgId, uint32_t toMsgId, uint8_t netType) override;
134 
135     /**
136      * @brief SetImsSmsConfig enable or disable IMS SMS.
137      * @param slotId Indicates the card slot index number,
138      * ranging from {@code 0} to the maximum card slot index number supported by the device.
139      * @param enable Indicates enable or disable Ims sms
140      * ranging {@code 0} disable Ims sms {@code 1} enable Ims sms
141      * @return Returns {@code true} if enable or disable Ims Sms success; returns {@code false} otherwise.
142      */
143     bool SetImsSmsConfig(int32_t slotId, int32_t enable) override;
144 
145     /**
146      * @brief SetDefaultSmsSlotId
147      * Set the Default Sms Slot Id To SmsService
148      * @param slotId [in]
149      * @return int32_t
150      */
151     int32_t SetDefaultSmsSlotId(int32_t slotId) override;
152 
153     /**
154      * @brief GetDefaultSmsSlotId
155      * Get the Default Sms Slot Id From SmsService
156      * @return int32_t
157      */
158     int32_t GetDefaultSmsSlotId() override;
159 
160     /**
161      * @brief SplitMessage
162      * calculate Sms Message Split Segment count
163      * @param message [in]
164      * @return int32_t
165      */
166     int32_t SplitMessage(const std::u16string &message, std::vector<std::u16string> &splitMessage) override;
167 
168     /**
169      * @brief GetSmsSegmentsInfo
170      * calculate the Sms Message Segments Info
171      * @param slotId [in]
172      * @param message [in]
173      * @param force7BitCode [in]
174      * @param info [out]
175      * @return Returns {@code 0} if get sms segments info
176      */
177     int32_t GetSmsSegmentsInfo(int32_t slotId, const std::u16string &message, bool force7BitCode,
178         ISmsServiceInterface::SmsSegmentsInfo &segInfo) override;
179 
180     /**
181      * Check Sms Is supported Ims newtwork
182      * Hide this for inner system use
183      * @param slotId Indicates the card slot index number, ranging from {@code 0} to the maximum card slot index number
184      * supported by the device.
185      * @param isSupported Whether ims SMS is supported.
186      * @return Interface execution results.
187      */
188     int32_t IsImsSmsSupported(int32_t slotId, bool &isSupported) override;
189 
190     /**
191      * @brief GetImsShortMessageFormat
192      * Get the Ims Short Message Format 3gpp/3gpp2
193      * Hide this for inner system use
194      * @return int32_t
195      */
196     int32_t GetImsShortMessageFormat(std::u16string &format) override;
197 
198     /**
199      * @brief HasSmsCapability
200      * Check whether it is supported Sms Capability
201      * @return true
202      * @return false
203      */
204     bool HasSmsCapability() override;
205 
206     /**
207      * create a short message
208      * @param pdu Indicates pdu code,
209      * @param specification Indicates 3gpp or 3gpp2
210      * @param ShortMessage Indicates a short message object
211      * @return Returns {@code 0} if CreateMessage success
212      */
213     int32_t CreateMessage(std::string pdu, std::string specification, ShortMessage &message) override;
214 
215     /**
216      * mms base64 encode
217      * @param src Indicates source string,
218      * @param dest Indicates destination string
219      * @return Returns {@code true} if encode success; returns {@code false} otherwise
220      */
221     bool GetBase64Encode(std::string src, std::string &dest) override;
222 
223     /**
224      * mms base64 decode
225      * @param src Indicates source string,
226      * @param dest Indicates destination string
227      * @return Returns {@code true} if decode success; returns {@code false} otherwise
228      */
229     bool GetBase64Decode(std::string src, std::string &dest) override;
230 
231     /**
232      * Get Encode String
233      * @param encodeString Indicates output string,
234      * @param charset Indicates character set,
235      * @param valLength Indicates input string length,
236      * @param strEncodeString Indicates input string
237      * @return Returns {@code true} if decode success; returns {@code false} otherwise
238      */
239     bool GetEncodeStringFunc(
240         std::string &encodeString, uint32_t charset, uint32_t valLength, std::string strEncodeString) override;
241 
242 private:
243     static inline BrokerDelegator<SmsServiceProxy> delegator_;
244 };
245 
246 class SmsServiceDeathRecipient : public IRemoteObject::DeathRecipient {
247 public:
248     virtual void OnRemoteDied(const wptr<IRemoteObject> &remote);
249     SmsServiceDeathRecipient();
250     virtual ~SmsServiceDeathRecipient();
251     static bool GotDeathRecipient();
252     static bool gotDeathRecipient_;
253 };
254 } // namespace Telephony
255 } // namespace OHOS
256 #endif // SMS_SERVICE_PROXY_H
257