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