1 /* 2 * Copyright (C) 2021 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 #pragma once 17 18 #include <PowerStatsAidl.h> 19 20 namespace aidl { 21 namespace android { 22 namespace hardware { 23 namespace power { 24 namespace stats { 25 26 class DevfreqStateResidencyDataProvider : public PowerStats::IStateResidencyDataProvider { 27 public: 28 DevfreqStateResidencyDataProvider(const std::string& name, const std::string& path); 29 ~DevfreqStateResidencyDataProvider() = default; 30 31 /* 32 * See IStateResidencyDataProvider::getStateResidencies 33 */ 34 bool getStateResidencies( 35 std::unordered_map<std::string, std::vector<StateResidency>> *residencies) override; 36 37 /* 38 * See IStateResidencyDataProvider::getInfo 39 */ 40 std::unordered_map<std::string, std::vector<State>> getInfo() override; 41 42 private: 43 bool extractNum(const char *str, char **str_end, int base, int64_t* num); 44 std::vector<std::pair<int64_t, int64_t>> parseTimeInState(); 45 const std::string mName; 46 const std::string mPath; 47 }; 48 49 } // namespace stats 50 } // namespace power 51 } // namespace hardware 52 } // namespace android 53 } // namespace aidl 54