1 /* 2 * Copyright (c) 2022-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 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 static constexpr int32_t MSG_POWER_SAVE_LIST_UPDATED = 5; 35 static constexpr int32_t MSG_UID_STATE_FOREGROUND = 6; 36 static constexpr int32_t MSG_UID_STATE_BACKGROUND = 7; 37 38 NetPolicyEventHandler(const std::shared_ptr<AppExecFwk::EventRunner> &runner, 39 const std::shared_ptr<NetPolicyCore> &core); 40 virtual ~NetPolicyEventHandler() override; 41 42 /** 43 * Process the event from EventHandler 44 * 45 * @param eventId The event id 46 * @param policyEvent The informations passed from other core 47 */ 48 void ProcessEvent(const AppExecFwk::InnerEvent::Pointer &event) override; 49 50 private: 51 std::shared_ptr<NetPolicyCore> core_; 52 }; 53 } // namespace NetManagerStandard 54 } // namespace OHOS 55 #endif // NET_POLICY_EVENT_HANDLER_H