Maggie White | 5229b4d | 2018-06-28 00:01:01 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2018 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 DEVICE_GOOGLE_CROSSHATCH_HEALTH_LOWBATTERYSHUTDOWNMETRICS_H |
| 18 | #define DEVICE_GOOGLE_CROSSHATCH_HEALTH_LOWBATTERYSHUTDOWNMETRICS_H |
| 19 | |
| 20 | #include <android-base/file.h> |
| 21 | #include <android-base/logging.h> |
| 22 | #include <android-base/properties.h> |
| 23 | #include <android-base/strings.h> |
| 24 | #include <batteryservice/BatteryService.h> |
| 25 | #include <math.h> |
| 26 | #include <time.h> |
| 27 | #include <utils/Timers.h> |
| 28 | #include <string> |
| 29 | |
| 30 | #include <hardware/google/pixelstats/1.0/IPixelStats.h> |
| 31 | |
| 32 | namespace device { |
| 33 | namespace google { |
| 34 | namespace crosshatch { |
| 35 | namespace health { |
| 36 | |
| 37 | class LowBatteryShutdownMetrics { |
| 38 | public: |
| 39 | LowBatteryShutdownMetrics(); |
| 40 | void logShutdownVoltage(struct android::BatteryProperties *props); |
| 41 | |
| 42 | private: |
| 43 | const char *kVoltageAvg = "/sys/class/power_supply/maxfg/voltage_avg"; |
| 44 | const char *kPersistProp = "persist.vendor.shutdown.voltage_avg"; |
| 45 | |
| 46 | // Helps enforce that we only record kVoltageAvg once per boot cycle |
| 47 | bool prop_written_; |
| 48 | // Help us avoid polling kPersistProp if it's empty |
| 49 | bool prop_empty_; |
| 50 | |
| 51 | bool saveVoltageAvg(); |
| 52 | void readStatus(); |
| 53 | bool uploadVoltageAvg(); |
| 54 | }; |
| 55 | |
| 56 | } // namespace health |
| 57 | } // namespace crosshatch |
| 58 | } // namespace google |
| 59 | } // namespace device |
| 60 | |
| 61 | #endif |