Replace the getBatteryLevel() method from SettingsLib API

Bug: 260524172
Test: presubmit
Change-Id: Icb56abd3dc258dde142a956124dc12bbfd9ae889
This commit is contained in:
ykhung
2022-11-29 17:36:12 +08:00
parent 20f6b1faaa
commit e77b5bbecb
3 changed files with 3 additions and 10 deletions

View File

@@ -602,15 +602,6 @@ public class BatteryUtils {
/*receiver=*/ null, new IntentFilter(Intent.ACTION_BATTERY_CHANGED));
}
/** Gets the battery level from the intent. */
public static int getBatteryLevel(Intent intent) {
final int level = intent.getIntExtra(BatteryManager.EXTRA_LEVEL, -1);
final int scale = intent.getIntExtra(BatteryManager.EXTRA_SCALE, 0);
return scale == 0
? -1 /*invalid battery level*/
: Math.round((level / (float) scale) * 100f);
}
/** Gets the current dock defender mode */
public static int getCurrentDockDefenderMode(Context context, BatteryInfo batteryInfo) {
if (batteryInfo.pluggedStatus == BatteryManager.BATTERY_PLUGGED_DOCK) {