android: bugfix. changed battery level plausibility. 0 percent does not imply the divice is off.

This commit is contained in:
Joachim Fritzsch 2014-05-25 15:08:32 +02:00
parent 3560d3a400
commit a0e9925e35
1 changed files with 1 additions and 1 deletions

View File

@ -190,7 +190,7 @@ public class DeviceStatus {
int scale = batteryStatus.getIntExtra(BatteryManager.EXTRA_SCALE, -1);
if(level == -1 || scale == -1) throw new Exception("battery level parsing error");
int batteryPct = (int) ((level / (float) scale) * 100); // always rounds down
if(batteryPct < 1 || batteryPct > 100) throw new Exception("battery level parsing error");
if(batteryPct < 0 || batteryPct > 100) throw new Exception("battery level parsing error");
if(batteryPct != status.battery_charge_pct) {
status.battery_charge_pct = batteryPct;
change = true;