healthd: don't report fake data for battery-less devices
If the kernel does not implement a power_supply class device of type battery, do not report fake data, instead report the following by default: * batteryPresent = false (instead of true), * charging status = unknown (instead of charging), * capacity = 0 (instead of 100%), * health = unknown (instead of good), * AC charger online not modified (instead of forcing true) If no charger and no battery devices are supplied by the kernel, the AC charger online property will no longer be forced to true. Devices that are always plugged into AC power should either implement a power_supply class charger device or implement a Health HAL that sets properties appropriately. Bug: 34507420 Test: manual: gce_x6_phone (no battery or charger), boots and stays booted, inspect properties Merged-In: I14cb3b685e8130428e417e7d08c4246f7415210a Change-Id: I64bd4431af10f3d232f36fcf8d356b6d88b08013
This commit is contained in:
parent
94e9305511
commit
4d7ee2ebbb
2 changed files with 6 additions and 21 deletions
|
@ -42,7 +42,6 @@
|
|||
#define POWER_SUPPLY_SYSFS_PATH "/sys/class/" POWER_SUPPLY_SUBSYSTEM
|
||||
#define FAKE_BATTERY_CAPACITY 42
|
||||
#define FAKE_BATTERY_TEMPERATURE 424
|
||||
#define ALWAYS_PLUGGED_CAPACITY 100
|
||||
#define MILLION 1.0e6
|
||||
#define DEFAULT_VBUS_VOLTAGE 5000000
|
||||
|
||||
|
@ -81,8 +80,11 @@ static void initBatteryProperties(BatteryProperties* props) {
|
|||
props->batteryTechnology.clear();
|
||||
}
|
||||
|
||||
BatteryMonitor::BatteryMonitor() : mHealthdConfig(nullptr), mBatteryDevicePresent(false),
|
||||
mAlwaysPluggedDevice(false), mBatteryFixedCapacity(0), mBatteryFixedTemperature(0) {
|
||||
BatteryMonitor::BatteryMonitor()
|
||||
: mHealthdConfig(nullptr),
|
||||
mBatteryDevicePresent(false),
|
||||
mBatteryFixedCapacity(0),
|
||||
mBatteryFixedTemperature(0) {
|
||||
initBatteryProperties(&props);
|
||||
}
|
||||
|
||||
|
@ -223,15 +225,6 @@ bool BatteryMonitor::update(void) {
|
|||
mBatteryFixedTemperature :
|
||||
getIntField(mHealthdConfig->batteryTemperaturePath);
|
||||
|
||||
// For devices which do not have battery and are always plugged
|
||||
// into power souce.
|
||||
if (mAlwaysPluggedDevice) {
|
||||
props.chargerAcOnline = true;
|
||||
props.batteryPresent = true;
|
||||
props.batteryStatus = BATTERY_STATUS_CHARGING;
|
||||
props.batteryHealth = BATTERY_HEALTH_GOOD;
|
||||
}
|
||||
|
||||
std::string buf;
|
||||
|
||||
if (readFromFile(mHealthdConfig->batteryStatusPath, &buf) > 0)
|
||||
|
@ -405,11 +398,7 @@ status_t BatteryMonitor::getProperty(int id, struct BatteryProperty *val) {
|
|||
break;
|
||||
|
||||
case BATTERY_PROP_BATTERY_STATUS:
|
||||
if (mAlwaysPluggedDevice) {
|
||||
val->valueInt64 = BATTERY_STATUS_CHARGING;
|
||||
} else {
|
||||
val->valueInt64 = getChargeStatus();
|
||||
}
|
||||
val->valueInt64 = getChargeStatus();
|
||||
ret = NO_ERROR;
|
||||
break;
|
||||
|
||||
|
@ -628,9 +617,6 @@ void BatteryMonitor::init(struct healthd_config *hc) {
|
|||
KLOG_WARNING(LOG_TAG, "No battery devices found\n");
|
||||
hc->periodic_chores_interval_fast = -1;
|
||||
hc->periodic_chores_interval_slow = -1;
|
||||
mBatteryFixedCapacity = ALWAYS_PLUGGED_CAPACITY;
|
||||
mBatteryFixedTemperature = FAKE_BATTERY_TEMPERATURE;
|
||||
mAlwaysPluggedDevice = true;
|
||||
} else {
|
||||
if (mHealthdConfig->batteryStatusPath.isEmpty())
|
||||
KLOG_WARNING(LOG_TAG, "BatteryStatusPath not found\n");
|
||||
|
|
|
@ -48,7 +48,6 @@ class BatteryMonitor {
|
|||
struct healthd_config *mHealthdConfig;
|
||||
Vector<String8> mChargerNames;
|
||||
bool mBatteryDevicePresent;
|
||||
bool mAlwaysPluggedDevice;
|
||||
int mBatteryFixedCapacity;
|
||||
int mBatteryFixedTemperature;
|
||||
struct BatteryProperties props;
|
||||
|
|
Loading…
Reference in a new issue