blob: ba291af1eefec38aef542fcd3e8225c038894163 [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
Todd Poynorf5d30122013-08-12 17:03:35 -070024#include "healthd.h"
Todd Poynor752faf22013-06-12 13:25:59 -070025#include "BatteryPropertiesRegistrar.h"
26
27namespace android {
28
29class BatteryPropertiesRegistrar;
30
31class 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 Poynorf5d30122013-08-12 17:03:35 -070042 void init(struct healthd_config *hc, bool nosvcmgr);
Todd Poynor752faf22013-06-12 13:25:59 -070043 bool update(void);
44
45 private:
Todd Poynorf5d30122013-08-12 17:03:35 -070046 struct healthd_config *mHealthdConfig;
Todd Poynor752faf22013-06-12 13:25:59 -070047 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