1 /* 2 * Copyright (C) 2022 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_BATTERYHEALTHREPORTER_H 18 #define HARDWARE_GOOGLE_PIXEL_PIXELSTATS_BATTERYHEALTHREPORTER_H 19 20 #include <aidl/android/frameworks/stats/IStats.h> 21 22 namespace android { 23 namespace hardware { 24 namespace google { 25 namespace pixel { 26 27 using aidl::android::frameworks::stats::IStats; 28 29 /** 30 * A class to upload battery capacity metrics 31 */ 32 class BatteryHealthReporter { 33 public: 34 BatteryHealthReporter(); 35 void checkAndReportStatus(const std::shared_ptr<IStats> &stats_client); 36 37 private: 38 bool reportBatteryHealthStatus(const std::shared_ptr<IStats> &stats_client); 39 void reportBatteryHealthStatusEvent(const std::shared_ptr<IStats> &stats_client, 40 const char *line); 41 bool reportBatteryHealthUsage(const std::shared_ptr<IStats> &stats_client); 42 void reportBatteryHealthUsageEvent(const std::shared_ptr<IStats> &stats_client, 43 const char *line); 44 45 int64_t report_time_ = 0; 46 int64_t getTimeSecs(); 47 48 // Proto messages are 1-indexed and VendorAtom field numbers start at 2, so 49 // store everything in the values array at the index of the field number 50 // -2. 51 const int kVendorAtomOffset = 2; 52 53 const std::string kBatteryHealthStatusPath = 54 "/sys/class/power_supply/battery/health_index_stats"; 55 const std::string kBatteryHealthUsagePath = "/sys/class/power_supply/battery/swelling_data"; 56 }; 57 58 } // namespace pixel 59 } // namespace google 60 } // namespace hardware 61 } // namespace android 62 63 #endif // HARDWARE_GOOGLE_PIXEL_PIXELSTATS_BATTERYHEALTHREPORTER_H 64