Revert "Revert "healthd: don't report fake data for battery-less devices""
This reverts commit 1bc572dfe8ed82d6774a0c7e057ae56c53b3ee20.
The presubmit test that (incorrectly) fails on the original commit
has been marked @FlakyTest and a bug is failed on Assistant.
Bug: 34507420
Test: manual: gce_x6_phone (no battery or charger),
boots and stays booted, inspect properties,
presubmit tests on gce_x86
Change-Id: I5509bf5de9fceffdd5fd8abc3f1f4f6101119248
diff --git a/healthd/BatteryMonitor.cpp b/healthd/BatteryMonitor.cpp
index 561948c..de48adb 100644
--- a/healthd/BatteryMonitor.cpp
+++ b/healthd/BatteryMonitor.cpp
@@ -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 @@
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);
}
@@ -227,15 +229,6 @@
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)
@@ -409,11 +402,7 @@
break;
case BATTERY_PROP_BATTERY_STATUS:
- if (mAlwaysPluggedDevice) {
- val->valueInt64 = BATTERY_STATUS_CHARGING;
- } else {
- val->valueInt64 = getChargeStatus();
- }
+ val->valueInt64 = getChargeStatus();
ret = NO_ERROR;
break;
@@ -632,9 +621,6 @@
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");
diff --git a/healthd/include/healthd/BatteryMonitor.h b/healthd/include/healthd/BatteryMonitor.h
index b6a1b66..4d1d53f 100644
--- a/healthd/include/healthd/BatteryMonitor.h
+++ b/healthd/include/healthd/BatteryMonitor.h
@@ -48,7 +48,6 @@
struct healthd_config *mHealthdConfig;
Vector<String8> mChargerNames;
bool mBatteryDevicePresent;
- bool mAlwaysPluggedDevice;
int mBatteryFixedCapacity;
int mBatteryFixedTemperature;
struct BatteryProperties props;