Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a78fc234 authored by Ruchi Kandoi's avatar Ruchi Kandoi
Browse files

healthd: Reports arbitrary numbers for capacity and temperature when

connected to fake battery.

Detects if the device is attached to a fake battery if yes, healthd
reports 42% battery charge and 42.2 degrees temperature.

Change-Id: I2508fd91c8d3848ea64f57ab59d20be1c2817913
parent 212e9798
Loading
Loading
Loading
Loading
+7 −5
Original line number Diff line number Diff line
@@ -35,6 +35,8 @@

#define POWER_SUPPLY_SUBSYSTEM "power_supply"
#define POWER_SUPPLY_SYSFS_PATH "/sys/class/" POWER_SUPPLY_SUBSYSTEM
#define FAKE_BATTERY_CAPACITY 42
#define FAKE_BATTERY_TEMPERATURE 424

namespace android {

@@ -530,11 +532,11 @@ void BatteryMonitor::init(struct healthd_config *hc) {
            KLOG_WARNING(LOG_TAG, "BatteryTechnologyPath not found\n");
    }

    if (property_get("persist.sys.battery.capacity", pval, NULL) > 0)
        mBatteryFixedCapacity = (int) strtol(pval, NULL, 10);

    if (property_get("persist.sys.battery.temperature", pval, NULL) > 0)
        mBatteryFixedTemperature = (int) strtol(pval, NULL, 10);
    if (property_get("ro.boot.fake_battery", pval, NULL) > 0
                                               && strtol(pval, NULL, 10) != 0) {
        mBatteryFixedCapacity = FAKE_BATTERY_CAPACITY;
        mBatteryFixedTemperature = FAKE_BATTERY_TEMPERATURE;
    }
}

}; // namespace android