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 | |
| 20 | #include <binder/IInterface.h> |
| 21 | #include <utils/String8.h> |
| 22 | #include <utils/Vector.h> |
| 23 | |
Todd Poynor | f5d3012 | 2013-08-12 17:03:35 -0700 | [diff] [blame] | 24 | #include "healthd.h" |
Todd Poynor | 752faf2 | 2013-06-12 13:25:59 -0700 | [diff] [blame] | 25 | #include "BatteryPropertiesRegistrar.h" |
| 26 | |
| 27 | namespace android { |
| 28 | |
| 29 | class BatteryPropertiesRegistrar; |
| 30 | |
| 31 | class BatteryMonitor { |
| 32 | public: |
| 33 | |
| 34 | enum PowerSupplyType { |
| 35 | ANDROID_POWER_SUPPLY_TYPE_UNKNOWN = 0, |
| 36 | ANDROID_POWER_SUPPLY_TYPE_AC, |
| 37 | ANDROID_POWER_SUPPLY_TYPE_USB, |
| 38 | ANDROID_POWER_SUPPLY_TYPE_WIRELESS, |
| 39 | ANDROID_POWER_SUPPLY_TYPE_BATTERY |
| 40 | }; |
| 41 | |
Todd Poynor | f5d3012 | 2013-08-12 17:03:35 -0700 | [diff] [blame] | 42 | void init(struct healthd_config *hc, bool nosvcmgr); |
Todd Poynor | 752faf2 | 2013-06-12 13:25:59 -0700 | [diff] [blame] | 43 | bool update(void); |
| 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; |
| 48 | |
| 49 | sp<BatteryPropertiesRegistrar> mBatteryPropertiesRegistrar; |
| 50 | |
| 51 | int getBatteryStatus(const char* status); |
| 52 | int getBatteryHealth(const char* status); |
| 53 | int readFromFile(const String8& path, char* buf, size_t size); |
| 54 | PowerSupplyType readPowerSupplyType(const String8& path); |
| 55 | bool getBooleanField(const String8& path); |
| 56 | int getIntField(const String8& path); |
| 57 | }; |
| 58 | |
| 59 | }; // namespace android |
| 60 | |
| 61 | #endif // HEALTHD_BATTERY_MONTIOR_H |