• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2020 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #pragma once
18 
19 #include <list>
20 #include <string>
21 #include <unordered_map>
22 #include <vector>
23 
24 namespace aidl {
25 namespace android {
26 namespace hardware {
27 namespace power {
28 namespace stats {
29 
30 /**
31  * This class provides the necessary functionality for selection of energy meter
32  * based on file configurations.
33  */
34 class IioEnergyMeterDataSelector {
35   public:
36     IioEnergyMeterDataSelector(const std::unordered_map<std::string, std::string> &devicePaths);
37 
38   private:
39     void parseConfigData(const std::string data,
40                          std::unordered_map<std::string, std::list<std::string>> *deviceConfigs);
41     void applyConfigToDevices(
42             const std::unordered_map<std::string, std::list<std::string>> &deviceConfigs);
43     void applyConfigsByAscendingPriority();
44     void sendConfigurationComplete();
45 
46     const std::unordered_map<std::string, std::string> kDevicePaths;
47     const std::string kSelectionNode = "/enabled_rails";
48     const std::string kSelectionComplete = "CONFIG_COMPLETE";
49 
50     /* Order matters (ascending priority), see applyConfigsByAscendingPriority() */
51     const std::vector<const std::string> kConfigPaths = {
52             "/data/vendor/powerstats/odpm_config",
53     };
54 };
55 
56 }  // namespace stats
57 }  // namespace power
58 }  // namespace hardware
59 }  // namespace android
60 }  // namespace aidl
61