1 /* 2 * Copyright (C) 2022 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 #ifndef COMMON_EVENT_HANDLER_H 16 #define COMMON_EVENT_HANDLER_H 17 18 #include "common_event_manager.h" 19 #include "event_handler.h" 20 #include "infcc_host.h" 21 #include "nfc_service.h" 22 #include "tag_dispatcher.h" 23 24 namespace OHOS { 25 namespace NFC { 26 class CommonEventHandler final : public AppExecFwk::EventHandler { 27 public: 28 explicit CommonEventHandler(const std::shared_ptr<AppExecFwk::EventRunner>& runner, 29 std::weak_ptr<NfcService> servcie); 30 ~CommonEventHandler(); 31 CommonEventHandler& operator=(const CommonEventHandler&) = delete; 32 CommonEventHandler(const CommonEventHandler&) = delete; 33 34 void Intialize(std::weak_ptr<TAG::TagDispatcher> tagDispatcher); 35 void ProcessEvent(const AppExecFwk::InnerEvent::Pointer& event) override; 36 37 void SubscribeScreenChangedEvent(); 38 void SubscribePackageChangedEvent(); 39 40 protected: 41 // Screen Changed Receiver 42 class ScreenChangedReceiver; 43 // Package Changed Receiver; 44 class PackageChangedReceiver; 45 46 private: 47 std::shared_ptr<EventFwk::CommonEventSubscriber> screenSubscriber_ {}; 48 std::shared_ptr<EventFwk::CommonEventSubscriber> pkgSubscriber_ {}; 49 50 std::weak_ptr<NfcService> nfcService_ {}; 51 std::weak_ptr<TAG::TagDispatcher> tagDispatcher_ {}; 52 }; 53 } // namespace NFC 54 } // namespace OHOS 55 #endif // COMMON_EVENT_HANDLER_H 56