• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 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 <system_ability.h>
24 #include "sp_singleton.h"
25 #include "ipc_object_stub.h"
26 
27 #define RETURN_FLAG_FALSE (-1)
28 #define SLEEP_FILTER_VALUE 124
29 
30 namespace OHOS {
31 namespace PowerMgr {
32 struct ModePolicy {
33     int32_t id;
34     int32_t value;
35     int32_t recover_flag;
36 };
37 enum ValueProp {
38     value,
39     recover
40 };
41 
42 class PowerSaveMode : public RefBase {
43 public:
44     PowerSaveMode();
45     ~PowerSaveMode()=default;
46     bool GetValuePolicy(std::list<ModePolicy> &openPolicy, int32_t mode);
47     bool GetRecoverPolicy(std::list<ModePolicy> &recoverPolicy, int32_t mode);
48     bool GetFilterPolicy(std::list<ModePolicy> &policy, int32_t mode, int32_t value);
49     int32_t GetSleepTime(int32_t mode);
50     std::list<ModePolicy> GetLastMode();
51     std::list<ModePolicy> SetLastMode(std::list<ModePolicy> &policy);
52 
53 private:
54     std::map<int32_t, std::list<ModePolicy>> policyCache_;
55     bool StartXMlParse(std::string path);
56 };
57 } // namespace PowerMgr
58 } // namespace OHOS
59 #endif // POWERMGR_POWER_MGR_PowerSaveMode_H
60