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 #ifndef SMS_BROADCAST_SUBSCRIBER_RECEIVER_H 17 #define SMS_BROADCAST_SUBSCRIBER_RECEIVER_H 18 19 #include <memory> 20 #include <queue> 21 #include "common_event_manager.h" 22 #include "common_event_subscriber.h" 23 #include "common_event_support.h" 24 #include "sms_receive_reliability_handler.h" 25 26 namespace OHOS { 27 namespace Telephony { 28 29 class SmsBroadcastSubscriberReceiver : public EventFwk::CommonEventSubscriber { 30 public: 31 /* 32 * callback function used to unsubscribe the 'SMS_RECEIVE_COMPLETED' event for object 'smsReceive' transfered in 33 * code 'CommonEventManager::PublishCommonEvent(data, publishInfo, smsReceiver)' in CES. If don't unsubscribe, the 34 * object will be saved in CES and the number will increase. When the number is over 200, the event will not be 35 * allowed to publish. 36 */ 37 static void UnsubscribeInCes(); 38 SmsBroadcastSubscriberReceiver(const OHOS::EventFwk::CommonEventSubscribeInfo &subscriberInfo, 39 std::shared_ptr<SmsReceiveReliabilityHandler> handler, uint16_t refId, uint16_t dataBaseId, 40 const std::string &address); 41 ~SmsBroadcastSubscriberReceiver() = default; 42 virtual void OnReceiveEvent(const OHOS::EventFwk::CommonEventData &data); 43 44 private: 45 std::shared_ptr<SmsReceiveReliabilityHandler> handler_ = nullptr; 46 uint16_t refId_ = 0; 47 uint16_t dataBaseId_ = 0; 48 std::string address_; 49 }; 50 extern std::queue<std::shared_ptr<SmsBroadcastSubscriberReceiver>> sptrQueue; 51 } // namespace Telephony 52 } // namespace OHOS 53 #endif