• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-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 THERMAL_ACTION_MANAGER_H
17 #define THERMAL_ACTION_MANAGER_H
18 
19 #include <string>
20 #include <vector>
21 #include <map>
22 #include <list>
23 
24 #include "ithermal_action.h"
25 #include "action_thermal_level.h"
26 
27 namespace OHOS {
28 namespace PowerMgr {
29 struct ActionItem {
30     std::string name;
31     std::string params;
32     std::string uid;
33     std::string protocol;
34     bool strict = false;
35     bool enableEvent = false;
36 };
37 
38 class ThermalActionManager {
39 public:
40     using ThermalActionMap = std::map<std::string, std::shared_ptr<IThermalAction>>;
41     bool Init();
42     void SubscribeThermalLevelCallback(const sptr<IThermalLevelCallback>& callback);
43     void UnSubscribeThermalLevelCallback(const sptr<IThermalLevelCallback>& callback);
44     uint32_t GetThermalLevel();
SetActionItem(std::vector<ActionItem> vActionItem)45     void SetActionItem(std::vector<ActionItem> vActionItem)
46     {
47         vActionItem_ = vActionItem;
48     }
GetActionItem()49     std::vector<ActionItem> GetActionItem()
50     {
51         return vActionItem_;
52     }
GetActionMap()53     ThermalActionMap GetActionMap()
54     {
55         return actionMap_;
56     }
GetActionThermalLevelObj()57     std::shared_ptr<ActionThermalLevel> GetActionThermalLevelObj()
58     {
59         return actionThermalLevel_;
60     }
61 
62     int32_t CreateActionMockFile();
63     void DumpAction(std::string& result);
64 private:
65     void InsertActionMap(const std::string& actionName, const std::string& protocol, bool strict, bool enableEvent);
66     ThermalActionMap actionMap_;
67     std::vector<std::string> actionNameList_;
68     std::shared_ptr<ActionThermalLevel> actionThermalLevel_;
69     std::vector<ActionItem> vActionItem_;
70 };
71 } // namespace PowerMgr
72 } // namespace OHOS
73 #endif // THERMAL_ACTION_MANAGER_H
74