• 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_broadcast_subscriber_receiver.h"
17 
18 #include "telephony_log_wrapper.h"
19 #include "want.h"
20 
21 namespace OHOS {
22 namespace Telephony {
23 using namespace EventFwk;
24 
SmsBroadcastSubscriberReceiver(const CommonEventSubscribeInfo & subscriberInfo,std::shared_ptr<SmsReceiveReliabilityHandler> handler,uint16_t refId,uint16_t dataBaseId)25 SmsBroadcastSubscriberReceiver::SmsBroadcastSubscriberReceiver(const CommonEventSubscribeInfo &subscriberInfo,
26     std::shared_ptr<SmsReceiveReliabilityHandler> handler, uint16_t refId, uint16_t dataBaseId)
27     : CommonEventSubscriber(subscriberInfo)
28 {
29     handler_ = handler;
30     refId_ = refId;
31     dataBaseId_ = dataBaseId;
32 }
33 
OnReceiveEvent(const OHOS::EventFwk::CommonEventData & data)34 void SmsBroadcastSubscriberReceiver::OnReceiveEvent(const OHOS::EventFwk::CommonEventData &data)
35 {
36     std::string action = data.GetWant().GetAction();
37     if (action == CommonEventSupport::COMMON_EVENT_SMS_RECEIVE_COMPLETED ||
38         action == CommonEventSupport::COMMON_EVENT_SMS_WAPPUSH_RECEIVE_COMPLETED) {
39         TELEPHONY_LOGI("OnReceiveEvent refId_ =%{public}d, dataBaseId_ =%{public}d", refId_, dataBaseId_);
40         if (handler_ == nullptr) {
41             TELEPHONY_LOGE("handler_ is nullptr");
42             return;
43         }
44 
45         handler_->DeleteMessageFormDb(refId_, dataBaseId_);
46     }
47 }
48 } // namespace Telephony
49 } // namespace OHOS