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 16 #ifndef NET_POLICY_EVENT_HANDLER_H 17 #define NET_POLICY_EVENT_HANDLER_H 18 19 #include <iostream> 20 21 #include "event_handler.h" 22 #include "event_runner.h" 23 #include "singleton.h" 24 25 namespace OHOS { 26 namespace NetManagerStandard { 27 class NetPolicyCore; 28 class NetPolicyEventHandler : public AppExecFwk::EventHandler { 29 public: 30 static constexpr int32_t MSG_DEVICE_IDLE_LIST_UPDATED = 1; 31 static constexpr int32_t MSG_DEVICE_IDLE_MODE_CHANGED = 2; 32 static constexpr int32_t MSG_POWER_SAVE_MODE_CHANGED = 3; 33 static constexpr int32_t MSG_UID_REMOVED = 4; 34 35 NetPolicyEventHandler(const std::shared_ptr<AppExecFwk::EventRunner> &runner, 36 const std::shared_ptr<NetPolicyCore> &core); 37 virtual ~NetPolicyEventHandler() override; 38 39 /** 40 * Process the event from EventHandler 41 * 42 * @param eventId The event id 43 * @param policyEvent The informations passed from other core 44 */ 45 void ProcessEvent(const AppExecFwk::InnerEvent::Pointer &event) override; 46 47 private: 48 std::shared_ptr<NetPolicyCore> core_; 49 }; 50 } // namespace NetManagerStandard 51 } // namespace OHOS 52 #endif // NET_POLICY_EVENT_HANDLER_H