/* * Copyright (C) 2022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef NFC_EVENT_HANDLER_H #define NFC_EVENT_HANDLER_H #include "common_event_manager.h" #include "event_handler.h" #include "nfc_service.h" #include "tag_dispatcher.h" namespace OHOS { namespace NFC { class NfcService; class CeService; class NfcPollingManager; class NfcRoutingManager; class NfcEventHandler final : public AppExecFwk::EventHandler { public: explicit NfcEventHandler(const std::shared_ptr& runner, std::weak_ptr service); ~NfcEventHandler(); NfcEventHandler& operator=(const NfcEventHandler&) = delete; NfcEventHandler(const NfcEventHandler&) = delete; void Intialize(std::weak_ptr tagDispatcher, std::weak_ptr ceService, std::weak_ptr nfcPollingManager, std::weak_ptr nfcRoutingManager, std::weak_ptr nciNfccProxy); void ProcessEvent(const AppExecFwk::InnerEvent::Pointer& event) override; void SubscribeScreenChangedEvent(); void SubscribePackageChangedEvent(); void SubscribeShutdownEvent(); void SubscribeDataShareChangedEvent(); bool IsScreenOn(); bool IsScreenLocked(); ScreenState CheckScreenState(); protected: // Screen Changed Receiver class ScreenChangedReceiver; // Package Changed Receiver class PackageChangedReceiver; // Shutdown Event Receiver class ShutdownEventReceiver; // DataShare changed Receiver class DataShareChangedReceiver; private: std::shared_ptr screenSubscriber_ {}; std::shared_ptr pkgSubscriber_ {}; std::shared_ptr shutdownSubscriber_ {}; std::shared_ptr dataShareSubscriber_ {}; std::weak_ptr nfcService_ {}; std::weak_ptr tagDispatcher_ {}; std::weak_ptr ceService_ {}; std::weak_ptr nfcPollingManager_ {}; std::weak_ptr nfcRoutingManager_ {}; std::weak_ptr nciNfccProxy_ {}; std::mutex commonEventMutex_ {}; static constexpr const int WAIT_PROCESS_EVENT_TIMES = 60 * 1000; }; } // namespace NFC } // namespace OHOS #endif // NFC_EVENT_HANDLER_H