blob: 34b423dd424ddd4ccabb3ab8d7485bd80da71035 [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
Todd Poynorc133b712013-08-14 17:39:13 -070020#include <batteryservice/BatteryService.h>
Todd Poynor752faf22013-06-12 13:25:59 -070021#include <binder/IInterface.h>
22#include <utils/String8.h>
23#include <utils/Vector.h>
24
Todd Poynorf5d30122013-08-12 17:03:35 -070025#include "healthd.h"
Todd Poynor752faf22013-06-12 13:25:59 -070026#include "BatteryPropertiesRegistrar.h"
27
28namespace android {
29
30class BatteryPropertiesRegistrar;
31
32class BatteryMonitor {
33 public:
34
35 enum PowerSupplyType {
36 ANDROID_POWER_SUPPLY_TYPE_UNKNOWN = 0,
37 ANDROID_POWER_SUPPLY_TYPE_AC,
38 ANDROID_POWER_SUPPLY_TYPE_USB,
39 ANDROID_POWER_SUPPLY_TYPE_WIRELESS,
40 ANDROID_POWER_SUPPLY_TYPE_BATTERY
41 };
42
Todd Poynorf5d30122013-08-12 17:03:35 -070043 void init(struct healthd_config *hc, bool nosvcmgr);
Todd Poynor752faf22013-06-12 13:25:59 -070044 bool update(void);
Todd Poynorc133b712013-08-14 17:39:13 -070045 status_t getProperty(int id, struct BatteryProperty *val);
Todd Poynor752faf22013-06-12 13:25:59 -070046
47 private:
Todd Poynorf5d30122013-08-12 17:03:35 -070048 struct healthd_config *mHealthdConfig;
Todd Poynor752faf22013-06-12 13:25:59 -070049 Vector<String8> mChargerNames;
50
51 sp<BatteryPropertiesRegistrar> mBatteryPropertiesRegistrar;
52
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