2013-06-12 22:25:59 +02:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2013 The Android Open Source Project
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef HEALTHD_BATTERYMONITOR_H
|
|
|
|
#define HEALTHD_BATTERYMONITOR_H
|
|
|
|
|
2013-08-15 02:39:13 +02:00
|
|
|
#include <batteryservice/BatteryService.h>
|
2013-06-12 22:25:59 +02:00
|
|
|
#include <binder/IInterface.h>
|
|
|
|
#include <utils/String8.h>
|
|
|
|
#include <utils/Vector.h>
|
|
|
|
|
2013-08-13 02:03:35 +02:00
|
|
|
#include "healthd.h"
|
2013-06-12 22:25:59 +02:00
|
|
|
|
|
|
|
namespace android {
|
|
|
|
|
|
|
|
class BatteryMonitor {
|
|
|
|
public:
|
|
|
|
|
|
|
|
enum PowerSupplyType {
|
|
|
|
ANDROID_POWER_SUPPLY_TYPE_UNKNOWN = 0,
|
|
|
|
ANDROID_POWER_SUPPLY_TYPE_AC,
|
|
|
|
ANDROID_POWER_SUPPLY_TYPE_USB,
|
|
|
|
ANDROID_POWER_SUPPLY_TYPE_WIRELESS,
|
|
|
|
ANDROID_POWER_SUPPLY_TYPE_BATTERY
|
|
|
|
};
|
|
|
|
|
2013-09-10 21:40:00 +02:00
|
|
|
void init(struct healthd_config *hc);
|
2013-06-12 22:25:59 +02:00
|
|
|
bool update(void);
|
2013-08-15 02:39:13 +02:00
|
|
|
status_t getProperty(int id, struct BatteryProperty *val);
|
2013-09-19 05:09:33 +02:00
|
|
|
void dumpState(int fd);
|
2013-06-12 22:25:59 +02:00
|
|
|
|
|
|
|
private:
|
2013-08-13 02:03:35 +02:00
|
|
|
struct healthd_config *mHealthdConfig;
|
2013-06-12 22:25:59 +02:00
|
|
|
Vector<String8> mChargerNames;
|
2013-10-22 05:26:25 +02:00
|
|
|
bool mBatteryDevicePresent;
|
2014-05-22 01:28:13 +02:00
|
|
|
int mBatteryFixedCapacity;
|
|
|
|
int mBatteryFixedTemperature;
|
2013-09-19 05:09:33 +02:00
|
|
|
struct BatteryProperties props;
|
2013-06-12 22:25:59 +02:00
|
|
|
|
|
|
|
int getBatteryStatus(const char* status);
|
|
|
|
int getBatteryHealth(const char* status);
|
|
|
|
int readFromFile(const String8& path, char* buf, size_t size);
|
|
|
|
PowerSupplyType readPowerSupplyType(const String8& path);
|
|
|
|
bool getBooleanField(const String8& path);
|
|
|
|
int getIntField(const String8& path);
|
|
|
|
};
|
|
|
|
|
|
|
|
}; // namespace android
|
|
|
|
|
|
|
|
#endif // HEALTHD_BATTERY_MONTIOR_H
|