Skip to content

Commit

Permalink
Merge "healthd: don't report fake data for battery-less devices"
Browse files Browse the repository at this point in the history
am: ab26cc4

Change-Id: I2597154b24428ca806d628ad567c5742722caeac
  • Loading branch information
toddpoynor authored and android-build-merger committed Feb 7, 2018
2 parents 7d362f1 + ab26cc4 commit d9960d8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 21 deletions.
26 changes: 6 additions & 20 deletions healthd/BatteryMonitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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");
Expand Down
1 change: 0 additions & 1 deletion healthd/include/healthd/BatteryMonitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ class BatteryMonitor {
struct healthd_config *mHealthdConfig;
Vector<String8> mChargerNames;
bool mBatteryDevicePresent;
bool mAlwaysPluggedDevice;
int mBatteryFixedCapacity;
int mBatteryFixedTemperature;
struct BatteryProperties props;
Expand Down

0 comments on commit d9960d8

Please sign in to comment.