默认情况下 没有电池 电量会显示 0%
修改为100%
diff --git a/system/core/healthd/BatteryMonitor.cpp b/system/core/healthd/BatteryMonitor.cpp
index 80c5afe..f72c28b 100644
--- a/system/core/healthd/BatteryMonitor.cpp
+++ b/system/core/healthd/BatteryMonitor.cpp
@@ -42,6 +42,7 @@
#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
@@ -83,6 +84,7 @@ static void initBatteryProperties(BatteryProperties* props) {
BatteryMonitor::BatteryMonitor()
: mHealthdConfig(nullptr),
mBatteryDevicePresent(false),
+ mAlwaysPluggedDevice(false),
mBatteryFixedCapacity(0),
mBatteryFixedTemperature(0) {
initBatteryProperties(&props);
@@ -229,6 +231,16 @@ bool BatteryMonitor::update(void) {
mBatteryFixedTemperature :
getIntField(mHealthdConfig->batteryTemperaturePath);
+ // zhangwei
+ // 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)
@@ -609,6 +621,9 @@ 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 {
: