blob: 6001073082caf7992ced798043765662033694f9 [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
27namespace android {
28
Todd Poynor752faf22013-06-12 13:25:59 -070029class BatteryMonitor {
30 public:
31
32 enum PowerSupplyType {
33 ANDROID_POWER_SUPPLY_TYPE_UNKNOWN = 0,
34 ANDROID_POWER_SUPPLY_TYPE_AC,
35 ANDROID_POWER_SUPPLY_TYPE_USB,
36 ANDROID_POWER_SUPPLY_TYPE_WIRELESS,
37 ANDROID_POWER_SUPPLY_TYPE_BATTERY
38 };
39
Yabin Cuidb04a492016-02-16 17:19:23 -080040 BatteryMonitor();
Todd Poynorc7464c92013-09-10 12:40:00 -070041 void init(struct healthd_config *hc);
Todd Poynor752faf22013-06-12 13:25:59 -070042 bool update(void);
Todd Poynorc133b712013-08-14 17:39:13 -070043 status_t getProperty(int id, struct BatteryProperty *val);
Todd Poynor020369d2013-09-18 20:09:33 -070044 void dumpState(int fd);
Todd Poynor752faf22013-06-12 13:25:59 -070045
46 private:
Todd Poynorf5d30122013-08-12 17:03:35 -070047 struct healthd_config *mHealthdConfig;
Todd Poynor752faf22013-06-12 13:25:59 -070048 Vector<String8> mChargerNames;
Todd Poynor6dcc45e2013-10-21 20:26:25 -070049 bool mBatteryDevicePresent;
Ruchi Kandoi42a981d2015-09-28 13:35:59 -070050 bool mAlwaysPluggedDevice;
Todd Poynor3db03a52014-05-21 16:28:13 -070051 int mBatteryFixedCapacity;
52 int mBatteryFixedTemperature;
Todd Poynor020369d2013-09-18 20:09:33 -070053 struct BatteryProperties props;
Todd Poynor752faf22013-06-12 13:25:59 -070054
Todd Poynor752faf22013-06-12 13:25:59 -070055 int getBatteryStatus(const char* status);
56 int getBatteryHealth(const char* status);
57 int readFromFile(const String8& path, char* buf, size_t size);
58 PowerSupplyType readPowerSupplyType(const String8& path);
59 bool getBooleanField(const String8& path);
60 int getIntField(const String8& path);
61};
62
63}; // namespace android
64
65#endif // HEALTHD_BATTERY_MONTIOR_H