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 17 #ifndef HARDWARE_GOOGLE_PIXEL_PIXELSTATS_THERMALSTATSREPORTER_H 18 #define HARDWARE_GOOGLE_PIXEL_PIXELSTATS_THERMALSTATSREPORTER_H 19 20 #include <aidl/android/frameworks/stats/IStats.h> 21 #include <hardware/google/pixel/pixelstats/pixelatoms.pb.h> 22 23 #include <string> 24 25 namespace android { 26 namespace hardware { 27 namespace google { 28 namespace pixel { 29 30 using aidl::android::frameworks::stats::IStats; 31 using aidl::android::frameworks::stats::VendorAtomValue; 32 33 /** 34 * A class to upload Pixel Thermal Stats metrics 35 */ 36 class ThermalStatsReporter { 37 public: 38 ThermalStatsReporter(); 39 void logThermalStats(const std::shared_ptr<IStats> &stats_client, 40 const std::vector<std::string> &thermal_stats_paths); 41 42 private: 43 struct ThermalDfsCounts { 44 int64_t big_count; 45 int64_t mid_count; 46 int64_t little_count; 47 int64_t gpu_count; 48 int64_t tpu_count; 49 int64_t aur_count; 50 }; 51 52 // Proto messages are 1-indexed and VendorAtom field numbers start at 2, so 53 // store everything in the values array at the index of the field number 54 // -2. 55 const int kVendorAtomOffset = 2; 56 const int kNumOfThermalDfsStats = 6; 57 struct ThermalDfsCounts prev_data; 58 59 void logThermalDfsStats(const std::shared_ptr<IStats> &stats_client, 60 const std::vector<std::string> &thermal_stats_paths); 61 bool captureThermalDfsStats(const std::vector<std::string> &thermal_stats_paths, 62 struct ThermalDfsCounts *cur_data); 63 bool readDfsCount(const std::string &path, int64_t *val); 64 }; 65 66 } // namespace pixel 67 } // namespace google 68 } // namespace hardware 69 } // namespace android 70 71 #endif // HARDWARE_GOOGLE_PIXEL_PIXELSTATS_THERMALSTATSREPORTER_H 72