• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 HARDWARE_GOOGLE_PIXEL_HEALTH_LOWBATTERYSHUTDOWNMETRICS_H
18 #define HARDWARE_GOOGLE_PIXEL_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 namespace hardware {
31 namespace google {
32 namespace pixel {
33 namespace health {
34 
35 class LowBatteryShutdownMetrics {
36   public:
37     LowBatteryShutdownMetrics(
38             const char *const voltage_avg,
39             const char *const persist_prop = "persist.vendor.shutdown.voltage_avg");
40     void logShutdownVoltage(struct android::BatteryProperties *props);
41 
42   private:
43     const char *const kVoltageAvg;
44     const char *const kPersistProp;
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 pixel
58 }  // namespace google
59 }  // namespace hardware
60 
61 #endif
62