blob: ff1ea1ed3517eda29c2fd86e2e68076f937e8b77 [file] [log] [blame]
Todd Poynor752faf22013-06-12 13:25:59 -07001/*
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
24#include "BatteryPropertiesRegistrar.h"
25
26namespace android {
27
28class BatteryPropertiesRegistrar;
29
30class BatteryMonitor {
31 public:
32
33 enum PowerSupplyType {
34 ANDROID_POWER_SUPPLY_TYPE_UNKNOWN = 0,
35 ANDROID_POWER_SUPPLY_TYPE_AC,
36 ANDROID_POWER_SUPPLY_TYPE_USB,
37 ANDROID_POWER_SUPPLY_TYPE_WIRELESS,
38 ANDROID_POWER_SUPPLY_TYPE_BATTERY
39 };
40
41 void init(bool nosvcmgr);
42 bool update(void);
43
44 private:
45 String8 mBatteryStatusPath;
46 String8 mBatteryHealthPath;
47 String8 mBatteryPresentPath;
48 String8 mBatteryCapacityPath;
49 String8 mBatteryVoltagePath;
50 String8 mBatteryTemperaturePath;
51 String8 mBatteryTechnologyPath;
Todd Poynorb45f1f52013-07-30 18:57:16 -070052 String8 mBatteryCurrentNowPath;
53 String8 mBatteryChargeCounterPath;
Todd Poynor752faf22013-06-12 13:25:59 -070054
55 Vector<String8> mChargerNames;
56
57 sp<BatteryPropertiesRegistrar> mBatteryPropertiesRegistrar;
58
59 int getBatteryStatus(const char* status);
60 int getBatteryHealth(const char* status);
61 int readFromFile(const String8& path, char* buf, size_t size);
62 PowerSupplyType readPowerSupplyType(const String8& path);
63 bool getBooleanField(const String8& path);
64 int getIntField(const String8& path);
65};
66
67}; // namespace android
68
69#endif // HEALTHD_BATTERY_MONTIOR_H