lin
2025-02-18 579f327609a9782026d9f48e771971ffc11d8a59
android/system/core/healthd/BatteryMonitor.cpp
....@@ -72,7 +72,7 @@
7272 props->batteryStatus = BATTERY_STATUS_UNKNOWN;
7373 props->batteryHealth = BATTERY_HEALTH_UNKNOWN;
7474 props->batteryPresent = false;
75
- props->batteryLevel = 100;
75
+ props->batteryLevel = 0;
7676 props->batteryVoltage = 0;
7777 props->batteryTemperature = 0;
7878 props->batteryCurrent = 0;
....@@ -210,10 +210,14 @@
210210 else
211211 props.batteryPresent = mBatteryDevicePresent;
212212
213
- //props.batteryLevel = mBatteryFixedCapacity ?
214
- // mBatteryFixedCapacity :
215
- // getIntField(mHealthdConfig->batteryCapacityPath);
216
- props.batteryLevel = 100;
213
+ if (!props.batteryPresent) {
214
+ props.batteryLevel = 100;}
215
+ else {
216
+ props.batteryLevel = mBatteryFixedCapacity ?
217
+ mBatteryFixedCapacity :
218
+ getIntField(mHealthdConfig->batteryCapacityPath);
219
+ }
220
+
217221 props.batteryVoltage = getIntField(mHealthdConfig->batteryVoltagePath) / 1000;
218222
219223 if (!mHealthdConfig->batteryCurrentNowPath.isEmpty())