一.adb查询电池信息
adb shell dumpsys battery
二.状态栏 电池图标
2.1.布局
frameworks\base\packages\SystemUI\res\layout\system_icons.xml
2.2.SystemUI
diff --git a/frameworks/base/packages/SystemUI/src/com/android/systemui/BatteryMeterView.java b/frameworks/base/packages/SystemUI/src/com/android/systemui/BatteryMeterView.java index 5047b78..c06abca 100755 --- a/frameworks/base/packages/SystemUI/src/com/android/systemui/BatteryMeterView.java +++ b/frameworks/base/packages/SystemUI/src/com/android/systemui/BatteryMeterView.java @@ -54,7 +54,7 @@ public class BatteryMeterView extends ImageView implements mSlotBattery = context.getString( com.android.internal.R.string.status_bar_battery); - //setImageDrawable(mDrawable); + setImageDrawable(mDrawable); }
2.3.healthd 强制100
diff --git a/system/core/healthd/BatteryMonitor.cpp b/system/core/healthd/BatteryMonitor.cpp index 2ad37c1..10f81c5 100755 --- a/system/core/healthd/BatteryMonitor.cpp +++ b/system/core/healthd/BatteryMonitor.cpp @@ -240,9 +240,11 @@ bool BatteryMonitor::update(void) { else props.batteryPresent = mBatteryDevicePresent; - props.batteryLevel = mBatteryFixedCapacity ? - mBatteryFixedCapacity : - getIntField(mHealthdConfig->batteryCapacityPath); + //props.batteryLevel = mBatteryFixedCapacity ? + //mBatteryFixedCapacity : + //getIntField(mHealthdConfig->batteryCapacityPath); + props.batteryLevel = 100; + props.batteryVoltage = getIntField(mHealthdConfig->batteryVoltagePath) / 1000; if (!mHealthdConfig->batteryCurrentNowPath.isEmpty())
原文:https://www.cnblogs.com/crushgirl/p/14699406.html