Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Unverified Commit a5c0346e authored by Michael Bestas's avatar Michael Bestas
Browse files

Hide unavailable battery info

Some devices wrongly report 0 for battery info.

Change-Id: Icee022c7d37c79cdd72c607cb43c9827c871e4da
parent 4c2027bf
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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);
    }
+1 −1
Original line number Diff line number Diff line
@@ -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);
        }
+1 −1
Original line number Diff line number Diff line
@@ -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;
+1 −1
Original line number Diff line number Diff line
@@ -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)
+1 −1
Original line number Diff line number Diff line
@@ -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)
Loading