开发平台基本信息
芯片: MSM8953
版本: Android 10
kernel: msm-4.9
问题描述
最近开发了一款设备是不带电池的,然后在OTA升级的时候,检测到电量过低于是弹框提示不允许进行OTA升级;所以需要将默认电量修改为100%。
解决方法
--- a/system/core/healthd/BatteryMonitor.cpp
+++ b/system/core/healthd/BatteryMonitor.cpp
@@ -73,6 +73,9 @@ static void initBatteryProperties(BatteryProperties* props) {
props->batteryHealth = BATTERY_HEALTH_UNKNOWN;
props->batteryPresent = false;
props->batteryLevel = 0;
+ if (property_get_bool("persist.sys.nobattery", false)) {
+ props->batteryLevel = 100;
+ }
props->batteryVoltage = 0;
props->batteryTemperature = 0;
props->batteryCurrent = 0;
@@ -213,6 +216,10 @@ bool BatteryMonitor::update(void) {
props.batteryLevel = mBatteryFixedCapacity ?
mBatteryFixedCapacity :
getIntField(mHealthdConfig->batteryCapacityPath);
+ if (property_get_bool("persist.sys.nobattery", false)) {
+ props.batteryLevel = 100;
+ }
+
props.batteryVoltage = getIntField(mHealthdConfig->batteryVoltagePath) / 1000;
if (!mHealthdConfig->batteryCurrentNowPath.isEmpty())