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 #ifndef HARDWARE_GOOGLE_PIXEL_POWERSTATS_GENERICSTATERESIDENCYDATAPROVIDER_H 18 #define HARDWARE_GOOGLE_PIXEL_POWERSTATS_GENERICSTATERESIDENCYDATAPROVIDER_H 19 // TODO(b/167628903): Delete this file 20 #include <pixelpowerstats/PowerStats.h> 21 22 namespace android { 23 namespace hardware { 24 namespace google { 25 namespace pixel { 26 namespace powerstats { 27 28 class StateResidencyConfig { 29 public: 30 std::string name; 31 std::string header; 32 33 bool entryCountSupported; 34 std::string entryCountPrefix; 35 std::function<uint64_t(uint64_t)> entryCountTransform; 36 37 bool totalTimeSupported; 38 std::string totalTimePrefix; 39 std::function<uint64_t(uint64_t)> totalTimeTransform; 40 41 bool lastEntrySupported; 42 std::string lastEntryPrefix; 43 std::function<uint64_t(uint64_t)> lastEntryTransform; 44 }; 45 46 class PowerEntityConfig { 47 public: 48 PowerEntityConfig(const std::vector<StateResidencyConfig> &stateResidencyConfigs); 49 PowerEntityConfig(const std::string &header, 50 const std::vector<StateResidencyConfig> &stateResidencyConfigs); 51 PowerEntityConfig(const uint32_t start_id, const std::string &header, 52 const std::vector<StateResidencyConfig> &stateResidencyConfigs); 53 std::string mHeader; 54 std::vector<std::pair<uint32_t, StateResidencyConfig>> mStateResidencyConfigs; 55 }; 56 57 class GenericStateResidencyDataProvider : public IStateResidencyDataProvider { 58 public: GenericStateResidencyDataProvider(std::string path)59 GenericStateResidencyDataProvider(std::string path) : mPath(std::move(path)) {} 60 ~GenericStateResidencyDataProvider() = default; 61 void addEntity(uint32_t id, const PowerEntityConfig &config); 62 bool getResults( 63 std::unordered_map<uint32_t, PowerEntityStateResidencyResult> &results) override; 64 std::vector<PowerEntityStateSpace> getStateSpaces() override; 65 66 private: 67 const std::string mPath; 68 std::vector<std::pair<uint32_t, PowerEntityConfig>> mPowerEntityConfigs; 69 }; 70 71 std::vector<StateResidencyConfig> generateGenericStateResidencyConfigs( 72 const StateResidencyConfig &stateConfig, 73 const std::vector<std::pair<std::string, std::string>> &stateHeaders); 74 75 } // namespace powerstats 76 } // namespace pixel 77 } // namespace google 78 } // namespace hardware 79 } // namespace android 80 81 #endif // HARDWARE_GOOGLE_PIXEL_POWERSTATS_GENERICSTATERESIDENCYDATAPROVIDER_H 82