Todd Poynor | 752faf2 | 2013-06-12 13:25:59 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2013 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 HEALTHD_BATTERYMONITOR_H |
| 18 | #define HEALTHD_BATTERYMONITOR_H |
| 19 | |
Todd Poynor | c133b71 | 2013-08-14 17:39:13 -0700 | [diff] [blame] | 20 | #include <batteryservice/BatteryService.h> |
Todd Poynor | 752faf2 | 2013-06-12 13:25:59 -0700 | [diff] [blame] | 21 | #include <binder/IInterface.h> |
| 22 | #include <utils/String8.h> |
| 23 | #include <utils/Vector.h> |
| 24 | |
Todd Poynor | f5d3012 | 2013-08-12 17:03:35 -0700 | [diff] [blame] | 25 | #include "healthd.h" |
Todd Poynor | 752faf2 | 2013-06-12 13:25:59 -0700 | [diff] [blame] | 26 | |
| 27 | namespace android { |
| 28 | |
Todd Poynor | 752faf2 | 2013-06-12 13:25:59 -0700 | [diff] [blame] | 29 | class BatteryMonitor { |
| 30 | public: |
| 31 | |
| 32 | enum PowerSupplyType { |
| 33 | ANDROID_POWER_SUPPLY_TYPE_UNKNOWN = 0, |
| 34 | ANDROID_POWER_SUPPLY_TYPE_AC, |
| 35 | ANDROID_POWER_SUPPLY_TYPE_USB, |
| 36 | ANDROID_POWER_SUPPLY_TYPE_WIRELESS, |
| 37 | ANDROID_POWER_SUPPLY_TYPE_BATTERY |
| 38 | }; |
| 39 | |
Todd Poynor | c7464c9 | 2013-09-10 12:40:00 -0700 | [diff] [blame] | 40 | void init(struct healthd_config *hc); |
Todd Poynor | 752faf2 | 2013-06-12 13:25:59 -0700 | [diff] [blame] | 41 | bool update(void); |
Todd Poynor | c133b71 | 2013-08-14 17:39:13 -0700 | [diff] [blame] | 42 | status_t getProperty(int id, struct BatteryProperty *val); |
Todd Poynor | 020369d | 2013-09-18 20:09:33 -0700 | [diff] [blame] | 43 | void dumpState(int fd); |
Todd Poynor | 752faf2 | 2013-06-12 13:25:59 -0700 | [diff] [blame] | 44 | |
| 45 | private: |
Todd Poynor | f5d3012 | 2013-08-12 17:03:35 -0700 | [diff] [blame] | 46 | struct healthd_config *mHealthdConfig; |
Todd Poynor | 752faf2 | 2013-06-12 13:25:59 -0700 | [diff] [blame] | 47 | Vector<String8> mChargerNames; |
Todd Poynor | 6dcc45e | 2013-10-21 20:26:25 -0700 | [diff] [blame] | 48 | bool mBatteryDevicePresent; |
Todd Poynor | 3db03a5 | 2014-05-21 16:28:13 -0700 | [diff] [blame] | 49 | int mBatteryFixedCapacity; |
| 50 | int mBatteryFixedTemperature; |
Todd Poynor | 020369d | 2013-09-18 20:09:33 -0700 | [diff] [blame] | 51 | struct BatteryProperties props; |
Todd Poynor | 752faf2 | 2013-06-12 13:25:59 -0700 | [diff] [blame] | 52 | |
Todd Poynor | 752faf2 | 2013-06-12 13:25:59 -0700 | [diff] [blame] | 53 | int getBatteryStatus(const char* status); |
| 54 | int getBatteryHealth(const char* status); |
| 55 | int readFromFile(const String8& path, char* buf, size_t size); |
| 56 | PowerSupplyType readPowerSupplyType(const String8& path); |
| 57 | bool getBooleanField(const String8& path); |
| 58 | int getIntField(const String8& path); |
| 59 | }; |
| 60 | |
| 61 | }; // namespace android |
| 62 | |
| 63 | #endif // HEALTHD_BATTERY_MONTIOR_H |