blob: df0920b88b74242ef196f4e3a3004f1be038e2da [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;
52
53 Vector<String8> mChargerNames;
54
55 sp<BatteryPropertiesRegistrar> mBatteryPropertiesRegistrar;
56
57 int getBatteryStatus(const char* status);
58 int getBatteryHealth(const char* status);
59 int readFromFile(const String8& path, char* buf, size_t size);
60 PowerSupplyType readPowerSupplyType(const String8& path);
61 bool getBooleanField(const String8& path);
62 int getIntField(const String8& path);
63};
64
65}; // namespace android
66
67#endif // HEALTHD_BATTERY_MONTIOR_H