From 7fdd0e9ef9a86c0036900688177bf94743784069 Mon Sep 17 00:00:00 2001 From: ykhung Date: Thu, 11 May 2023 19:13:38 +0800 Subject: [PATCH] Avoid showing "0 minute" in the charge time label Remove the charge to full time label if its value is invalid https://screenshot.googleplex.com/5psbvFpcm2CFdRB Test: make test RunSettingsRoboTests ROBOTEST_FILTER=com.android.settings.fuelgauge.* Fix: 278740808 Change-Id: I765cdcdee8525adb2583d5950bc646c604c744de --- src/com/android/settings/fuelgauge/BatteryInfo.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/com/android/settings/fuelgauge/BatteryInfo.java b/src/com/android/settings/fuelgauge/BatteryInfo.java index d164e931a21..98240447aeb 100644 --- a/src/com/android/settings/fuelgauge/BatteryInfo.java +++ b/src/com/android/settings/fuelgauge/BatteryInfo.java @@ -299,9 +299,10 @@ public class BatteryInfo { (double) PowerUtil.convertUsToMs(info.remainingTimeUs), false /* withSeconds */, true /* collapseTimeUnit */); int resId = R.string.power_charging_duration; - info.remainingLabel = context.getString(R.string.power_remaining_charging_duration_only, - timeString); - info.chargeLabel = context.getString(resId, info.batteryPercentString, timeString); + info.remainingLabel = chargeTimeMs <= 0 ? null : context.getString( + R.string.power_remaining_charging_duration_only, timeString); + info.chargeLabel = chargeTimeMs <= 0 ? info.batteryPercentString + : context.getString(resId, info.batteryPercentString, timeString); } else if (dockDefenderMode == BatteryUtils.DockDefenderMode.FUTURE_BYPASS) { // Dock defender will be triggered in the future, charging will be optimized. info.chargeLabel = context.getString(R.string.power_charging_future_paused,