• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2023 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 #include "sms_receive_reliability_handler.h"
17 
18 #include "common_event.h"
19 #include "common_event_support.h"
20 #include "gsm_sms_message.h"
21 #include "parameter.h"
22 #include "radio_event.h"
23 #include "sms_broadcast_subscriber_receiver.h"
24 #include "sms_hisysevent.h"
25 #include "sms_persist_helper.h"
26 #include "telephony_common_utils.h"
27 #include "telephony_log_wrapper.h"
28 #include "telephony_permission.h"
29 
30 namespace OHOS {
31 namespace Telephony {
32 using namespace std;
33 using namespace EventFwk;
34 static constexpr uint16_t PDU_POS_OFFSET = 1;
35 static constexpr uint16_t PDU_START_POS = 0;
36 static constexpr uint16_t SMS_INVALID_PAGE_COUNT = 0;
37 static constexpr uint16_t SMS_SINGLE_PAGE_COUNT = 1;
38 static constexpr uint16_t SMS_PAGE_INITIAL = 1;
39 static constexpr uint16_t SMS_PAGE_INCREMENT = 1;
40 static constexpr int16_t WAP_PUSH_PORT = 2948;
41 static constexpr int16_t SMS_TEXT_PORT = -1;
42 static constexpr int32_t TEXT_MSG_RECEIVE_CODE = 0;
43 static constexpr int32_t DATA_MSG_RECEIVE_CODE = 1;
44 static constexpr int64_t ONE_DAY_TOTAL_SECONDS = 86400;
45 static constexpr uint16_t MAX_TPDU_DATA_LEN = 255;
46 static constexpr int32_t EXPIRE_DAYS_PARA_SIZE = 128;
47 static constexpr const char *SMS_EXPIRE_DAYS = "const.telephony.sms.expire.days";
48 static constexpr const char *DEFAULT_EXPIRE_DAYS = "7";
49 static constexpr const char *SMS_PAGE_COUNT_INVALID = "0";
50 static constexpr const char *SMS_BROADCAST_SLOTID_KEY = "slotId";
51 static constexpr const char *SMS_BROADCAST_PDU_KEY = "pdus";
52 static constexpr const char *SMS_BROADCAST_SMS_TYPE_KEY = "isCdma";
53 static constexpr const char *SMS_BROADCAST_SMS_TEXT_TYPE_KEY = "TEXT_SMS_RECEIVE";
54 static constexpr const char *SMS_BROADCAST_SMS_DATA_TYPE_KEY = "DATA_SMS_RECEIVE";
55 static constexpr const char *SMS_BROADCAST_SMS_PORT_KEY = "port";
56 const std::string CT_SMSC = "10659401";
57 const std::string CT_SMSC_86 = "8610659401";
58 const std::string CT_SMSC_INTERNATION_86 = "+8610659401";
59 const std::string CT_AUTO_REG_SMS_ACTION = "ct_auto_reg_sms_receive_completed";
60 
__anon984c407b0102() 61 std::shared_ptr<SmsBroadcastSubscriberReceiver> SmsReceiveReliabilityHandler::g_receiver = []() {
62     MatchingSkills smsSkills;
63     smsSkills.AddEvent(CommonEventSupport::COMMON_EVENT_SMS_RECEIVE_COMPLETED);
64     CommonEventSubscribeInfo smsSubscriberInfo(smsSkills);
65     smsSubscriberInfo.SetThreadMode(EventFwk::CommonEventSubscribeInfo::COMMON);
66     return std::make_shared<SmsBroadcastSubscriberReceiver>(smsSubscriberInfo);
67 }();
68 
SmsReceiveReliabilityHandler(int32_t slotId)69 SmsReceiveReliabilityHandler::SmsReceiveReliabilityHandler(int32_t slotId) : slotId_(slotId)
70 {
71     smsWapPushHandler_ = std::make_unique<SmsWapPushHandler>(slotId);
72     if (smsWapPushHandler_ == nullptr) {
73         TELEPHONY_LOGE("make sms wapPush Hander error.");
74     }
75 }
76 
~SmsReceiveReliabilityHandler()77 SmsReceiveReliabilityHandler::~SmsReceiveReliabilityHandler() {}
78 
DeleteExpireSmsFromDB()79 bool SmsReceiveReliabilityHandler::DeleteExpireSmsFromDB()
80 {
81     DataShare::DataSharePredicates predicates;
82     std::time_t timep;
83     int64_t currentTime = time(&timep);
84 
85     std::string smsExpire = GetSmsExpire();
86     if (!IsValidDecValue(smsExpire)) {
87         TELEPHONY_LOGE("system property telephony.sms.expire.days not decimal");
88         smsExpire = DEFAULT_EXPIRE_DAYS;
89     }
90     int64_t validityDuration = std::stoi(smsExpire) * ONE_DAY_TOTAL_SECONDS;
91     int64_t deadlineTime = currentTime - validityDuration;
92     if (deadlineTime <= 0) {
93         TELEPHONY_LOGE("deadlineTime is negative");
94         return false;
95     }
96 
97     predicates.EqualTo(SmsSubsection::SLOT_ID, std::to_string(slotId_))
98         ->BeginWrap()
99         ->LessThan(SmsSubsection::START_TIME, std::to_string(deadlineTime))
100         ->Or()
101         ->EqualTo(SmsSubsection::REW_PUD, "")
102         ->Or()
103         ->LessThan(SmsSubsection::SIZE, SMS_PAGE_COUNT_INVALID)
104         ->EndWrap();
105     return DelayedSingleton<SmsPersistHelper>::GetInstance()->Delete(predicates);
106 }
107 
GetSmsExpire()108 std::string SmsReceiveReliabilityHandler::GetSmsExpire()
109 {
110     char smsExpireDays[EXPIRE_DAYS_PARA_SIZE] = { 0 };
111     GetParameter(SMS_EXPIRE_DAYS, DEFAULT_EXPIRE_DAYS, smsExpireDays, EXPIRE_DAYS_PARA_SIZE);
112     return smsExpireDays;
113 }
114 
RemoveBlockedSms(std::vector<SmsReceiveIndexer> & dbIndexers)115 void SmsReceiveReliabilityHandler::RemoveBlockedSms(std::vector<SmsReceiveIndexer> &dbIndexers)
116 {
117     DataShare::DataSharePredicates predicates;
118     predicates.EqualTo(SmsSubsection::SLOT_ID, std::to_string(slotId_));
119     DelayedSingleton<SmsPersistHelper>::GetInstance()->Query(predicates, dbIndexers);
120 
121     for (auto smsPage = dbIndexers.begin(); smsPage != dbIndexers.end();) {
122         if (CheckBlockedPhoneNumber(smsPage->GetOriginatingAddress())) {
123             TELEPHONY_LOGI("indexer display address is block");
124             smsPage = dbIndexers.erase(smsPage);
125         } else if (smsPage->GetPdu().size() == 0 || smsPage->GetPdu().size() > MAX_TPDU_DATA_LEN) {
126             smsPage = dbIndexers.erase(smsPage);
127         } else {
128             smsPage++;
129         }
130     }
131 }
132 
CheckUnReceiveWapPush(std::vector<SmsReceiveIndexer> & dbIndexers)133 void SmsReceiveReliabilityHandler::CheckUnReceiveWapPush(std::vector<SmsReceiveIndexer> &dbIndexers)
134 {
135     for (auto place = dbIndexers.begin(); place != dbIndexers.end();) {
136         std::shared_ptr<vector<string>> userDataRaws = make_shared<vector<string>>();
137         userDataRaws->assign(MAX_SEGMENT_NUM, "");
138         if (place->GetDestPort() != WAP_PUSH_PORT) {
139             place++;
140             continue;
141         }
142         if (place->GetMsgCount() == SMS_SINGLE_PAGE_COUNT) {
143             GetWapPushUserDataSinglePage(*place, userDataRaws);
144         } else {
145             int32_t smsPagesCount = SMS_PAGE_INITIAL;
146             int32_t pos = static_cast<int32_t>(std::distance(dbIndexers.begin(), place));
147             GetWapPushUserDataMultipage(smsPagesCount, dbIndexers, pos, userDataRaws);
148             if (place->GetMsgCount() != smsPagesCount) {
149                 place = dbIndexers.erase(place);
150                 continue;
151             }
152         }
153 
154         if (!userDataRaws->at(PDU_START_POS).empty()) {
155             ReadyDecodeWapPushUserData(*place, userDataRaws);
156         }
157         place = dbIndexers.erase(place);
158     }
159 }
160 
GetWapPushUserDataSinglePage(SmsReceiveIndexer & indexer,std::shared_ptr<vector<string>> userDataRaws)161 void SmsReceiveReliabilityHandler::GetWapPushUserDataSinglePage(
162     SmsReceiveIndexer &indexer, std::shared_ptr<vector<string>> userDataRaws)
163 {
164     string pdu = StringUtils::StringToHex(indexer.GetPdu());
165     std::shared_ptr<SmsBaseMessage> baseMessage = GsmSmsMessage::CreateMessage(pdu);
166     if (baseMessage == nullptr) {
167         TELEPHONY_LOGE("baseMessage nullptr");
168         return;
169     }
170     userDataRaws->at(PDU_START_POS) = baseMessage->GetRawWapPushUserData();
171 }
172 
GetWapPushUserDataMultipage(int32_t & smsPagesCount,std::vector<SmsReceiveIndexer> & dbIndexers,int32_t place,std::shared_ptr<vector<string>> userDataRaws)173 void SmsReceiveReliabilityHandler::GetWapPushUserDataMultipage(int32_t &smsPagesCount,
174     std::vector<SmsReceiveIndexer> &dbIndexers, int32_t place, std::shared_ptr<vector<string>> userDataRaws)
175 {
176     if (place < 0 || place >= static_cast<int32_t>(dbIndexers.size())) {
177         TELEPHONY_LOGE("place invalid");
178         return;
179     }
180     string pdu = StringUtils::StringToHex(dbIndexers[place].GetPdu());
181     std::shared_ptr<SmsBaseMessage> baseMessage = GsmSmsMessage::CreateMessage(pdu);
182     if (baseMessage == nullptr) {
183         TELEPHONY_LOGE("baseMessage nullptr");
184         return;
185     }
186     if (dbIndexers[place].GetMsgSeqId() < PDU_POS_OFFSET || dbIndexers[place].GetMsgSeqId() > MAX_SEGMENT_NUM) {
187         TELEPHONY_LOGE("seqId invalid");
188         return;
189     }
190     userDataRaws->at(dbIndexers[place].GetMsgSeqId() - PDU_POS_OFFSET) = baseMessage->GetRawUserData();
191 
192     for (auto locate = dbIndexers.begin() + place + SMS_PAGE_INCREMENT; locate != dbIndexers.end();) {
193         if (dbIndexers[place].GetMsgRefId() != locate->GetMsgRefId()) {
194             locate++;
195             continue;
196         }
197         if (locate->GetPdu().size() > 0) {
198             smsPagesCount++;
199         }
200         pdu = StringUtils::StringToHex(locate->GetPdu());
201         baseMessage = GsmSmsMessage::CreateMessage(pdu);
202         if (baseMessage == nullptr) {
203             TELEPHONY_LOGE("baseMessage nullptr");
204             locate = dbIndexers.erase(locate);
205             return;
206         }
207         if (locate->GetMsgSeqId() < PDU_POS_OFFSET || locate->GetMsgSeqId() > MAX_SEGMENT_NUM) {
208             TELEPHONY_LOGE("seqId invalid");
209             locate = dbIndexers.erase(locate);
210             return;
211         }
212         userDataRaws->at(locate->GetMsgSeqId() - PDU_POS_OFFSET) = baseMessage->GetRawUserData();
213         locate = dbIndexers.erase(locate);
214     }
215 }
216 
ReadyDecodeWapPushUserData(SmsReceiveIndexer & indexerObj,std::shared_ptr<vector<string>> userDataRaws)217 void SmsReceiveReliabilityHandler::ReadyDecodeWapPushUserData(
218     SmsReceiveIndexer &indexerObj, std::shared_ptr<vector<string>> userDataRaws)
219 {
220     string userDataWapPush;
221     for (auto userDataRaw : *userDataRaws) {
222         userDataWapPush.append(userDataRaw);
223     }
224     shared_ptr<SmsReceiveIndexer> indexer = std::make_shared<SmsReceiveIndexer>(indexerObj.GetPdu(),
225         indexerObj.GetTimestamp(), indexerObj.GetDestPort(), indexerObj.GetIsCdma(), indexerObj.GetOriginatingAddress(),
226         indexerObj.GetVisibleAddress(), indexerObj.GetMsgRefId(), indexerObj.GetMsgSeqId(), indexerObj.GetMsgCount(),
227         false, StringUtils::StringToHex(indexerObj.GetPdu()));
228     indexer->SetDataBaseId(indexerObj.GetDataBaseId());
229 
230     if (smsWapPushHandler_ == nullptr) {
231         TELEPHONY_LOGI("smsWapPushHandler_ nullptr");
232         return;
233     }
234     if (!smsWapPushHandler_->DecodeWapPushPdu(indexer, userDataWapPush)) {
235         SmsHiSysEvent::WriteSmsReceiveFaultEvent(slotId_, SmsMmsMessageType::WAP_PUSH,
236             SmsMmsErrorCode::SMS_ERROR_PDU_DECODE_FAIL, "Wap push decode wap push fail");
237     }
238 }
239 
SmsReceiveReliabilityProcessing()240 void SmsReceiveReliabilityHandler::SmsReceiveReliabilityProcessing()
241 {
242     std::vector<SmsReceiveIndexer> dbIndexers;
243     RemoveBlockedSms(dbIndexers);
244     CheckUnReceiveWapPush(dbIndexers);
245 
246     for (auto position = dbIndexers.begin(); position != dbIndexers.end();) {
247         auto msgCount = position->GetMsgCount();
248         std::shared_ptr<vector<string>> pdus = make_shared<vector<string>>();
249         if (msgCount == SMS_INVALID_PAGE_COUNT) {
250             position++;
251             continue;
252         } else if (msgCount == SMS_SINGLE_PAGE_COUNT) {
253             pdus->push_back(StringUtils::StringToHex(position->GetPdu()));
254         } else {
255             int32_t smsPagesCount = SMS_PAGE_INITIAL;
256             int32_t pos = static_cast<int32_t>(std::distance(dbIndexers.begin(), position));
257             GetSmsUserDataMultipage(smsPagesCount, msgCount, dbIndexers, pos, pdus);
258             if (msgCount != smsPagesCount) {
259                 position = dbIndexers.erase(position);
260                 continue;
261             }
262         }
263         if (!pdus->at(PDU_START_POS).empty()) {
264             ReadySendSmsBroadcast(*position, pdus);
265         }
266         position = dbIndexers.erase(position);
267     }
268 }
269 
GetSmsUserDataMultipage(int32_t & smsPagesCount,uint16_t msgCount,std::vector<SmsReceiveIndexer> & dbIndexers,int32_t position,std::shared_ptr<std::vector<std::string>> pdus)270 void SmsReceiveReliabilityHandler::GetSmsUserDataMultipage(int32_t &smsPagesCount, uint16_t msgCount,
271     std::vector<SmsReceiveIndexer> &dbIndexers, int32_t position, std::shared_ptr<std::vector<std::string>> pdus)
272 {
273     if (position < 0 || position >= static_cast<int32_t>(dbIndexers.size())) {
274         TELEPHONY_LOGE("position over max");
275         return;
276     }
277     pdus->assign(msgCount, "");
278     if (dbIndexers[position].GetMsgSeqId() < PDU_POS_OFFSET || dbIndexers[position].GetMsgSeqId() > msgCount) {
279         TELEPHONY_LOGE("seqId invalid");
280         return;
281     }
282     pdus->at(dbIndexers[position].GetMsgSeqId() - PDU_POS_OFFSET) =
283         StringUtils::StringToHex(dbIndexers[position].GetPdu());
284     for (auto locate = dbIndexers.begin() + position + SMS_PAGE_INCREMENT; locate != dbIndexers.end();) {
285         if (dbIndexers[position].GetMsgRefId() != locate->GetMsgRefId()) {
286             locate++;
287             continue;
288         }
289         if (locate->GetMsgSeqId() < PDU_POS_OFFSET || locate->GetMsgSeqId() > msgCount) {
290             TELEPHONY_LOGE("seqId invalid");
291             locate = dbIndexers.erase(locate);
292             return;
293         }
294         pdus->at(locate->GetMsgSeqId() - PDU_POS_OFFSET) = StringUtils::StringToHex(locate->GetPdu());
295         locate = dbIndexers.erase(locate);
296         smsPagesCount++;
297     }
298 }
299 
ReadySendSmsBroadcast(SmsReceiveIndexer & indexerObj,std::shared_ptr<vector<string>> pdus)300 void SmsReceiveReliabilityHandler::ReadySendSmsBroadcast(
301     SmsReceiveIndexer &indexerObj, std::shared_ptr<vector<string>> pdus)
302 {
303     shared_ptr<SmsReceiveIndexer> indexer = std::make_shared<SmsReceiveIndexer>(indexerObj.GetPdu(),
304         indexerObj.GetTimestamp(), indexerObj.GetDestPort(), indexerObj.GetIsCdma(), indexerObj.GetOriginatingAddress(),
305         indexerObj.GetVisibleAddress(), indexerObj.GetMsgRefId(), indexerObj.GetMsgSeqId(), indexerObj.GetMsgCount(),
306         false, StringUtils::StringToHex(indexerObj.GetPdu()));
307     indexer->SetDataBaseId(indexerObj.GetDataBaseId());
308     TELEPHONY_LOGI("send sms from db for reliability");
309     SendBroadcast(indexer, pdus);
310 }
311 
DeleteMessageFormDb(const uint16_t refId,const uint16_t dataBaseId)312 void SmsReceiveReliabilityHandler::DeleteMessageFormDb(const uint16_t refId, const uint16_t dataBaseId)
313 {
314     if (refId == 0 && dataBaseId == 0) {
315         TELEPHONY_LOGE("DeleteMessageFormDb fail by refId error");
316         return;
317     }
318     if (refId == 0) {
319         DataShare::DataSharePredicates predicates;
320         predicates.EqualTo(SmsSubsection::ID, std::to_string(dataBaseId));
321         DelayedSingleton<SmsPersistHelper>::GetInstance()->Delete(predicates);
322     } else {
323         DataShare::DataSharePredicates predicates;
324         predicates.EqualTo(SmsSubsection::SMS_SUBSECTION_ID, std::to_string(refId));
325         DelayedSingleton<SmsPersistHelper>::GetInstance()->Delete(predicates);
326     }
327 }
328 
SendBroadcast(const std::shared_ptr<SmsReceiveIndexer> indexer,const shared_ptr<vector<string>> pdus)329 void SmsReceiveReliabilityHandler::SendBroadcast(
330     const std::shared_ptr<SmsReceiveIndexer> indexer, const shared_ptr<vector<string>> pdus)
331 {
332     if (indexer == nullptr || pdus == nullptr) {
333         TELEPHONY_LOGE("indexer or pdus is nullptr");
334         return;
335     }
336     std::vector<std::string> newPdus;
337     for (const auto &it : *pdus) {
338         if (!it.empty()) {
339             newPdus.emplace_back(it);
340         }
341     }
342     Want want;
343     CommonEventData data;
344     CommonEventPublishInfo publishInfo;
345     PacketSmsData(want, indexer, data, publishInfo);
346     want.SetParam(SMS_BROADCAST_PDU_KEY, newPdus);
347     want.SetParam(SmsBroadcastSubscriberReceiver::SMS_BROADCAST_DATABASE_ID_KEY, indexer->GetDataBaseId());
348     want.SetParam(SmsBroadcastSubscriberReceiver::SMS_BROADCAST_MSG_REF_ID_KEY, indexer->GetMsgRefId());
349     std::string addr = indexer->GetOriginatingAddress();
350     want.SetParam(SmsBroadcastSubscriberReceiver::SMS_BROADCAST_ADDRESS_KEY, addr);
351     data.SetWant(want);
352 
353     bool cbResult = false;
354     if (CT_SMSC.compare(addr) != 0 && CT_SMSC_86.compare(addr) != 0 && CT_SMSC_INTERNATION_86.compare(addr) != 0) {
355         TELEPHONY_LOGI("Sms Broadcast");
356         cbResult = CommonEventManager::PublishCommonEvent(data, publishInfo, g_receiver);
357     } else {
358         TELEPHONY_LOGI("CT AutoReg Broadcast");
359         cbResult = CommonEventManager::PublishCommonEvent(data, publishInfo, nullptr);
360     }
361     HiSysEventCBResult(cbResult);
362     if (CT_SMSC.compare(addr) == 0 || CT_SMSC_86.compare(addr) == 0 || CT_SMSC_INTERNATION_86.compare(addr) == 0) {
363         TELEPHONY_LOGI("del ct auto sms from db");
364         DeleteAutoSmsFromDB(shared_from_this(), indexer->GetMsgRefId(), indexer->GetDataBaseId());
365     }
366 }
367 
PacketSmsData(EventFwk::Want & want,const std::shared_ptr<SmsReceiveIndexer> indexer,EventFwk::CommonEventData & data,EventFwk::CommonEventPublishInfo & publishInfo)368 void SmsReceiveReliabilityHandler::PacketSmsData(EventFwk::Want &want, const std::shared_ptr<SmsReceiveIndexer> indexer,
369     EventFwk::CommonEventData &data, EventFwk::CommonEventPublishInfo &publishInfo)
370 {
371     if (CT_SMSC.compare(indexer->GetOriginatingAddress()) != 0 &&
372         CT_SMSC_86.compare(indexer->GetOriginatingAddress()) != 0 &&
373         CT_SMSC_INTERNATION_86.compare(indexer->GetOriginatingAddress()) != 0) {
374         want.SetAction(CommonEventSupport::COMMON_EVENT_SMS_RECEIVE_COMPLETED);
375     } else {
376         want.SetAction(CT_AUTO_REG_SMS_ACTION);
377     }
378     TELEPHONY_LOGI("Sms slotId_:%{public}d", slotId_);
379     want.SetParam(SMS_BROADCAST_SLOTID_KEY, static_cast<int>(slotId_));
380     want.SetParam(SMS_BROADCAST_SMS_TYPE_KEY, indexer->GetIsCdma());
381     if (indexer->GetIsText() || indexer->GetDestPort() == SMS_TEXT_PORT) {
382         data.SetData(SMS_BROADCAST_SMS_TEXT_TYPE_KEY);
383         data.SetCode(TEXT_MSG_RECEIVE_CODE);
384     } else {
385         data.SetData(SMS_BROADCAST_SMS_DATA_TYPE_KEY);
386         data.SetCode(DATA_MSG_RECEIVE_CODE);
387         want.SetParam(SMS_BROADCAST_SMS_PORT_KEY, static_cast<short>(indexer->GetDestPort()));
388     }
389 
390     publishInfo.SetOrdered(true);
391     std::vector<std::string> smsPermissions;
392     smsPermissions.emplace_back(Permission::RECEIVE_MESSAGES);
393     publishInfo.SetSubscriberPermissions(smsPermissions);
394 }
395 
HiSysEventCBResult(bool publishResult)396 void SmsReceiveReliabilityHandler::HiSysEventCBResult(bool publishResult)
397 {
398     if (!publishResult) {
399         TELEPHONY_LOGE("SendBroadcast PublishBroadcastEvent result fail");
400         SmsHiSysEvent::WriteSmsReceiveFaultEvent(slotId_, SmsMmsMessageType::SMS_SHORT_MESSAGE,
401             SmsMmsErrorCode::SMS_ERROR_PUBLISH_COMMON_EVENT_FAIL, "publish short message broadcast event fail");
402         return;
403     }
404     DelayedSingleton<SmsHiSysEvent>::GetInstance()->SetSmsBroadcastStartTime();
405 }
406 
DeleteAutoSmsFromDB(std::shared_ptr<SmsReceiveReliabilityHandler> handler,uint16_t refId,uint16_t dataBaseId)407 void SmsReceiveReliabilityHandler::DeleteAutoSmsFromDB(
408     std::shared_ptr<SmsReceiveReliabilityHandler> handler, uint16_t refId, uint16_t dataBaseId)
409 {
410     handler->DeleteMessageFormDb(refId, dataBaseId);
411 }
412 
CheckBlockedPhoneNumber(std::string originatingAddress)413 bool SmsReceiveReliabilityHandler::CheckBlockedPhoneNumber(std::string originatingAddress)
414 {
415     return DelayedSingleton<SmsPersistHelper>::GetInstance()->QueryBlockPhoneNumber(originatingAddress);
416 }
417 
CheckSmsCapable()418 bool SmsReceiveReliabilityHandler::CheckSmsCapable()
419 {
420     auto helperPtr = DelayedSingleton<SmsPersistHelper>::GetInstance();
421     if (helperPtr == nullptr) {
422         return true;
423     }
424     return helperPtr->QueryParamBoolean(SmsPersistHelper::SMS_CAPABLE_PARAM_KEY, true);
425 }
426 } // namespace Telephony
427 } // namespace OHOS