1 #ifndef HARDWARE_GOOGLE_PIXEL_POWERSTATS_GENERICSTATERESIDENCYDATAPROVIDER_H 2 #define HARDWARE_GOOGLE_PIXEL_POWERSTATS_GENERICSTATERESIDENCYDATAPROVIDER_H 3 4 #include <pixelpowerstats/PowerStats.h> 5 6 namespace android { 7 namespace hardware { 8 namespace google { 9 namespace pixel { 10 namespace powerstats { 11 12 class StateResidencyConfig { 13 public: 14 std::string name; 15 std::string header; 16 17 bool entryCountSupported; 18 std::string entryCountPrefix; 19 std::function<uint64_t(uint64_t)> entryCountTransform; 20 21 bool totalTimeSupported; 22 std::string totalTimePrefix; 23 std::function<uint64_t(uint64_t)> totalTimeTransform; 24 25 bool lastEntrySupported; 26 std::string lastEntryPrefix; 27 std::function<uint64_t(uint64_t)> lastEntryTransform; 28 }; 29 30 class PowerEntityConfig { 31 public: 32 PowerEntityConfig(const std::vector<StateResidencyConfig> &stateResidencyConfigs); 33 PowerEntityConfig(const std::string &header, 34 const std::vector<StateResidencyConfig> &stateResidencyConfigs); 35 std::string mHeader; 36 std::vector<std::pair<uint32_t, StateResidencyConfig>> mStateResidencyConfigs; 37 }; 38 39 class GenericStateResidencyDataProvider : public IStateResidencyDataProvider { 40 public: GenericStateResidencyDataProvider(std::string path)41 GenericStateResidencyDataProvider(std::string path) : mPath(std::move(path)){}; 42 ~GenericStateResidencyDataProvider() = default; 43 void addEntity(uint32_t id, const PowerEntityConfig &config); 44 bool getResults(std::unordered_map<uint32_t, PowerEntityStateResidencyResult> 45 &results) override; 46 std::vector<PowerEntityStateSpace> getStateSpaces() override; 47 48 private: 49 const std::string mPath; 50 std::vector<std::pair<uint32_t, PowerEntityConfig>> mPowerEntityConfigs; 51 }; 52 53 std::vector<StateResidencyConfig> generateGenericStateResidencyConfigs( 54 const StateResidencyConfig &stateConfig, 55 const std::vector<std::pair<std::string, std::string>> &stateHeaders); 56 57 } // namespace powerstats 58 } // namespace pixel 59 } // namespace google 60 } // namespace hardware 61 } // namespace android 62 63 #endif // HARDWARE_GOOGLE_PIXEL_POWERSTATS_GENERICSTATERESIDENCYDATAPROVIDER_H