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 POWERMGR_WAKEUP_ACTION_CONTROLLER_H 17 #define POWERMGR_WAKEUP_ACTION_CONTROLLER_H 18 19 #include <functional> 20 #include <memory> 21 #include <map> 22 23 #include "event_handler.h" 24 #include "power_state_machine.h" 25 #include "shutdown_controller.h" 26 #include "wakeup_action_source_parser.h" 27 #include "wakeup_action_sources.h" 28 29 namespace OHOS { 30 namespace PowerMgr { 31 32 class WakeupActionController : public std::enable_shared_from_this<WakeupActionController> { 33 public: 34 WakeupActionController( 35 std::shared_ptr<ShutdownController>& shutdownController, std::shared_ptr<PowerStateMachine>& stateMachine); 36 ~WakeupActionController(); 37 void Init(); 38 bool ExecuteByGetReason(); 39 bool IsLowCapacityWakeup(); 40 41 private: 42 void HandleAction(const std::string& reason); 43 void HandleHibernate(SuspendDeviceType reason); 44 void HandleShutdown(const std::string& scene); 45 46 std::map<std::string, std::shared_ptr<WakeupActionSource>> sourceMap_; 47 std::shared_ptr<ShutdownController> shutdownController_; 48 std::shared_ptr<PowerStateMachine> stateMachine_; 49 std::mutex mutex_; 50 }; 51 52 } // namespace PowerMgr 53 } // namespace OHOS 54 55 #endif // POWERMGR_WAKEUP_ACTION_CONTROLLER_H 56