Skip to content
Snippets Groups Projects
Commit 42a981dd authored by Ruchi Kandoi's avatar Ruchi Kandoi
Browse files

healthd: Adds fake battery properties for devices with no battery.


Devices which have no battery and are always plugged in will not have
any battery property initialized. This causes the 'stable power' to
never be switched which is required for updating apps.

This change recognizes such a device and manually sets the battery to
100% and charger status to connected to AC mains. It will also fake the
battery temperature.

Bug: 24258855
Change-Id: I98e5ed0dbeb7f2ab6d3802cd7e0f3a269bd8f31f
Signed-off-by: default avatarRuchi Kandoi <kandoiruchi@google.com>
parent 805ef688
No related branches found
No related tags found
No related merge requests found
...@@ -39,6 +39,7 @@ ...@@ -39,6 +39,7 @@
#define POWER_SUPPLY_SYSFS_PATH "/sys/class/" POWER_SUPPLY_SUBSYSTEM #define POWER_SUPPLY_SYSFS_PATH "/sys/class/" POWER_SUPPLY_SUBSYSTEM
#define FAKE_BATTERY_CAPACITY 42 #define FAKE_BATTERY_CAPACITY 42
#define FAKE_BATTERY_TEMPERATURE 424 #define FAKE_BATTERY_TEMPERATURE 424
#define ALWAYS_PLUGGED_CAPACITY 100
namespace android { namespace android {
...@@ -199,6 +200,15 @@ bool BatteryMonitor::update(void) { ...@@ -199,6 +200,15 @@ bool BatteryMonitor::update(void) {
mBatteryFixedTemperature : mBatteryFixedTemperature :
getIntField(mHealthdConfig->batteryTemperaturePath); 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;
}
const int SIZE = 128; const int SIZE = 128;
char buf[SIZE]; char buf[SIZE];
String8 btech; String8 btech;
...@@ -542,8 +552,15 @@ void BatteryMonitor::init(struct healthd_config *hc) { ...@@ -542,8 +552,15 @@ void BatteryMonitor::init(struct healthd_config *hc) {
closedir(dir); closedir(dir);
} }
if (!mChargerNames.size()) // This indicates that there is no charger driver registered.
// Typically the case for devices which do not have a battery and
// and are always plugged into AC mains.
if (!mChargerNames.size()) {
KLOG_ERROR(LOG_TAG, "No charger supplies found\n"); KLOG_ERROR(LOG_TAG, "No charger supplies found\n");
mBatteryFixedCapacity = ALWAYS_PLUGGED_CAPACITY;
mBatteryFixedTemperature = FAKE_BATTERY_TEMPERATURE;
mAlwaysPluggedDevice = true;
}
if (!mBatteryDevicePresent) { if (!mBatteryDevicePresent) {
KLOG_WARNING(LOG_TAG, "No battery devices found\n"); KLOG_WARNING(LOG_TAG, "No battery devices found\n");
hc->periodic_chores_interval_fast = -1; hc->periodic_chores_interval_fast = -1;
......
...@@ -46,6 +46,7 @@ class BatteryMonitor { ...@@ -46,6 +46,7 @@ class BatteryMonitor {
struct healthd_config *mHealthdConfig; struct healthd_config *mHealthdConfig;
Vector<String8> mChargerNames; Vector<String8> mChargerNames;
bool mBatteryDevicePresent; bool mBatteryDevicePresent;
bool mAlwaysPluggedDevice;
int mBatteryFixedCapacity; int mBatteryFixedCapacity;
int mBatteryFixedTemperature; int mBatteryFixedTemperature;
struct BatteryProperties props; struct BatteryProperties props;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment