Hide unavailable battery info
Some devices wrongly report 0 for battery info. Change-Id: Icee022c7d37c79cdd72c607cb43c9827c871e4da
This commit is contained in:
parent
7d6af248bf
commit
ff000afcad
6 changed files with 6 additions and 6 deletions
|
|
@ -44,7 +44,7 @@ public class BatteryCycleCountPreferenceController extends BasePreferenceControl
|
|||
final Intent batteryIntent = BatteryUtils.getBatteryIntent(mContext);
|
||||
final int cycleCount = batteryIntent.getIntExtra(BatteryManager.EXTRA_CYCLE_COUNT, -1);
|
||||
|
||||
return cycleCount == -1
|
||||
return cycleCount <= 0
|
||||
? mContext.getText(R.string.battery_cycle_count_not_available)
|
||||
: Integer.toString(cycleCount);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ public class BatteryDesignCapacityPreferenceController extends BasePreferenceCon
|
|||
final int designCapacityUah =
|
||||
batteryIntent.getIntExtra(BatteryManager.EXTRA_DESIGN_CAPACITY, -1);
|
||||
|
||||
if (designCapacityUah != -1) {
|
||||
if (designCapacityUah > 0) {
|
||||
int designCapacity = designCapacityUah / 1_000;
|
||||
return mContext.getString(R.string.battery_design_capacity_summary, designCapacity);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ public class BatteryMaximumCapacityPreferenceController extends BasePreferenceCo
|
|||
final int designCapacityUah =
|
||||
batteryIntent.getIntExtra(BatteryManager.EXTRA_DESIGN_CAPACITY, -1);
|
||||
|
||||
if (maxCapacityUah != -1 && designCapacityUah != -1) {
|
||||
if (maxCapacityUah > 0 && designCapacityUah > 0) {
|
||||
int maxCapacity = maxCapacityUah / 1_000;
|
||||
int designCapacity = designCapacityUah / 1_000;
|
||||
int percentage = (maxCapacity * 100) / designCapacity;
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ public class BatteryTemperaturePreferenceController extends BasePreferenceContro
|
|||
final int temperatureTenths =
|
||||
batteryIntent.getIntExtra(BatteryManager.EXTRA_TEMPERATURE, -1);
|
||||
|
||||
if (temperatureTenths != -1) {
|
||||
if (temperatureTenths > 0) {
|
||||
float temperature = temperatureTenths / 10f;
|
||||
|
||||
return MeasureFormat.getInstance(Locale.getDefault(), MeasureFormat.FormatWidth.SHORT)
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ public class BatteryVoltagePreferenceController extends BasePreferenceController
|
|||
final Intent batteryIntent = BatteryUtils.getBatteryIntent(mContext);
|
||||
final int voltageMillivolts = batteryIntent.getIntExtra(BatteryManager.EXTRA_VOLTAGE, -1);
|
||||
|
||||
if (voltageMillivolts != -1) {
|
||||
if (voltageMillivolts > 0) {
|
||||
float voltage = voltageMillivolts / 1_000f;
|
||||
|
||||
return MeasureFormat.getInstance(Locale.getDefault(), MeasureFormat.FormatWidth.SHORT)
|
||||
|
|
|
|||
|
|
@ -161,7 +161,7 @@ public class BatteryHeaderPreferenceController extends BasePreferenceController
|
|||
mBatteryUsageProgressBarPref.setUsageSummary(formatBatteryPercentageText(batteryLevel));
|
||||
mBatteryUsageProgressBarPref.setPercent(batteryLevel, BATTERY_MAX_LEVEL);
|
||||
|
||||
if (chargeCounterUah != -1) {
|
||||
if (chargeCounterUah > 0) {
|
||||
int chargeCounter = chargeCounterUah / 1_000;
|
||||
mBatteryUsageProgressBarPref.setTotalSummary(
|
||||
formatBatteryChargeCounterText(chargeCounter));
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue