1 /* 2 * Copyright (c) 2021-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_POWER_MGR_PowerSaveMode_H 17 #define POWERMGR_POWER_MGR_PowerSaveMode_H 18 19 #include <string> 20 #include <list> 21 #include <map> 22 23 #include "ipc_object_stub.h" 24 #include "libxml/tree.h" 25 #include "sp_singleton.h" 26 #include "system_ability.h" 27 28 #define RETURN_FLAG_FALSE (-1) 29 #define SLEEP_FILTER_VALUE 102 30 31 namespace OHOS { 32 namespace PowerMgr { 33 struct ModePolicy { 34 uint32_t id; 35 int32_t value; 36 int32_t recover_flag; 37 }; 38 enum ValueProp { 39 value, 40 recover 41 }; 42 43 class PowerSaveMode : public RefBase { 44 public: 45 PowerSaveMode(); 46 ~PowerSaveMode()=default; 47 int32_t GetSleepTime(int32_t mode); GetPolicyCache()48 std::map<int32_t, std::list<ModePolicy>> GetPolicyCache() 49 { 50 return policyCache_; 51 } 52 53 private: 54 std::map<int32_t, std::list<ModePolicy>> policyCache_; 55 bool StartXMlParse(std::string path); 56 std::string GetProp(const xmlNodePtr& nodePtr, const std::string& key); 57 }; 58 } // namespace PowerMgr 59 } // namespace OHOS 60 #endif // POWERMGR_POWER_MGR_PowerSaveMode_H 61