• 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 
21 #include "iremote_object.h"
22 #include "iremote_proxy.h"
23 
24 namespace OHOS {
25 namespace Telephony {
26 class SmsServiceProxy : public IRemoteProxy<ISmsServiceInterface> {
27 public:
28     explicit SmsServiceProxy(const sptr<IRemoteObject> &impl);
29     virtual ~SmsServiceProxy() = default;
30 
31     /**
32      * @brief SendMessage
33      * Sends a text or data SMS message.
34      * @param slotId [in]
35      * @param desAddr [in]
36      * @param scAddr [in]
37      * @param text [in]
38      * @param sendCallback [in]
39      * @param deliverCallback [in]
40      */
41     void 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      */
57     void SendMessage(int32_t slotId, const std::u16string desAddr, const std::u16string scAddr, uint16_t port,
58         const uint8_t *data, uint16_t dataLen, const sptr<ISendShortMessageCallback> &sendCallback,
59         const sptr<IDeliveryShortMessageCallback> &deliverCallback) override;
60 
61     /**
62      * @brief SetSmscAddr
63      * Sets the address for the Short Message Service Center (SMSC) based on a specified slot ID.
64      * @param slotId [in]
65      * @param scAddr [in]
66      * @return true
67      * @return false
68      */
69     bool 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      * @return std::u16string
76      */
77     std::u16string GetSmscAddr(int32_t slotId) override;
78 
79     /**
80      * @brief AddSimMessage
81      * Add a sms to sim card.
82      * @param slotId [in]
83      * @param smsc [in]
84      * @param pdu [in]
85      * @param status [in]
86      * @return true
87      * @return false
88      */
89     bool 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 true
98      * @return false
99      */
100     bool DelSimMessage(int32_t slotId, uint32_t msgIndex) override;
101 
102     /**
103      * @brief UpdateSimMessage
104      * Update a sms in the sim card.
105      * @param slotId [in]
106      * @param msgIndex [in]
107      * @param newStatus [in]
108      * @param pdu [in]
109      * @param smsc [in]
110      * @return true
111      * @return false
112      */
113     bool UpdateSimMessage(int32_t slotId, uint32_t msgIndex, SimMessageStatus newStatus, const std::u16string &pdu,
114         const std::u16string &smsc) override;
115 
116     /**
117      * @brief GetAllSimMessages
118      * Get sim card all the sms.
119      * @param slotId [in]
120      * @return std::vector<ShortMessage>
121      */
122     std::vector<ShortMessage> GetAllSimMessages(int32_t slotId) override;
123 
124     /**
125      * @brief SetCBConfig
126      * Configure a cell broadcast in a certain band range.
127      * @param slotId [in]
128      * @param enable [in]
129      * @param fromMsgId [in]
130      * @param toMsgId [in]
131      * @param netType [in]
132      * @return true
133      * @return false
134      */
135     bool SetCBConfig(int32_t slotId, bool enable, uint32_t fromMsgId, uint32_t toMsgId, uint8_t netType) override;
136 
137     /**
138      * @brief SetDefaultSmsSlotId
139      * Set the Default Sms Slot Id To SmsService
140      * @param slotId [in]
141      * @return true
142      * @return false
143      */
144     bool SetDefaultSmsSlotId(int32_t slotId) override;
145 
146     /**
147      * @brief GetDefaultSmsSlotId
148      * Get the Default Sms Slot Id From SmsService
149      * @return int32_t
150      */
151     int32_t GetDefaultSmsSlotId() override;
152 
153     /**
154      * @brief SplitMessage
155      * calculate Sms Message Split Segment count
156      * @param message [in]
157      * @return std::vector<std::u16string>
158      */
159     std::vector<std::u16string> SplitMessage(const std::u16string &message) override;
160 
161     /**
162      * @brief GetSmsSegmentsInfo
163      * calculate the Sms Message Segments Info
164      * @param slotId [in]
165      * @param message [in]
166      * @param force7BitCode [in]
167      * @param info [out]
168      * @return true
169      * @return false
170      */
171     bool GetSmsSegmentsInfo(int32_t slotId, const std::u16string &message, bool force7BitCode,
172         ISmsServiceInterface::SmsSegmentsInfo &segInfo) override;
173 
174     /**
175      * @brief IsImsSmsSupported
176      * Check Sms Is supported Ims newtwork
177      * Hide this for inner system use
178      * @return true
179      * @return false
180      */
181     bool IsImsSmsSupported() override;
182 
183     /**
184      * @brief GetImsShortMessageFormat
185      * Get the Ims Short Message Format 3gpp/3gpp2
186      * Hide this for inner system use
187      * @return std::u16string
188      */
189     std::u16string GetImsShortMessageFormat() override;
190 
191     /**
192      * @brief HasSmsCapability
193      * Check whether it is supported Sms Capability
194      * @return true
195      * @return false
196      */
197     bool HasSmsCapability() override;
198 
199 private:
200     static inline BrokerDelegator<SmsServiceProxy> delegator_;
201 };
202 
203 class SmsServiceDeathRecipient : public IRemoteObject::DeathRecipient {
204 public:
205     virtual void OnRemoteDied(const wptr<IRemoteObject> &remote);
206     SmsServiceDeathRecipient();
207     virtual ~SmsServiceDeathRecipient();
208     static bool GotDeathRecipient();
209     static bool gotDeathRecipient_;
210 };
211 } // namespace Telephony
212 } // namespace OHOS
213 #endif // SMS_SERVICE_PROXY_H
214