Loading src/com/android/settings/fuelgauge/TopLevelBatteryPreferenceController.java +5 −1 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package com.android.settings.fuelgauge; import android.content.ComponentName; import android.content.Context; import android.os.BatteryManager; import android.util.Log; import androidx.annotation.VisibleForTesting; Loading Loading @@ -139,7 +140,10 @@ public class TopLevelBatteryPreferenceController extends BasePreferenceControlle if (Utils.containsIncompatibleChargers(mContext, TAG)) { return mContext.getString(R.string.battery_info_status_not_charging); } if (!info.discharging && info.chargeLabel != null) { if (info.batteryStatus == BatteryManager.BATTERY_STATUS_NOT_CHARGING) { // Present status only if no remaining time or status anomalous return info.statusLabel; } else if (!info.discharging && info.chargeLabel != null) { return info.chargeLabel; } else if (info.remainingLabel == null) { return info.batteryPercentString; Loading tests/robotests/src/com/android/settings/fuelgauge/TopLevelBatteryPreferenceControllerTest.java +12 −0 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ import android.content.Intent; import android.hardware.usb.UsbManager; import android.hardware.usb.UsbPort; import android.hardware.usb.UsbPortStatus; import android.os.BatteryManager; import androidx.preference.Preference; import androidx.test.core.app.ApplicationProvider; Loading Loading @@ -145,6 +146,17 @@ public class TopLevelBatteryPreferenceControllerTest { .isEqualTo(mContext.getString(R.string.battery_info_status_not_charging)); } @Test public void getDashboardLabel_notChargingState_returnsCorrectLabel() { mController.mPreference = new Preference(mContext); BatteryInfo info = new BatteryInfo(); info.batteryStatus = BatteryManager.BATTERY_STATUS_NOT_CHARGING; info.statusLabel = "expected returned label"; assertThat(mController.getDashboardLabel(mContext, info, true)) .isEqualTo(info.statusLabel); } @Test public void getSummary_batteryNotPresent_shouldShowWarningMessage() { mController.mIsBatteryPresent = false; Loading Loading
src/com/android/settings/fuelgauge/TopLevelBatteryPreferenceController.java +5 −1 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package com.android.settings.fuelgauge; import android.content.ComponentName; import android.content.Context; import android.os.BatteryManager; import android.util.Log; import androidx.annotation.VisibleForTesting; Loading Loading @@ -139,7 +140,10 @@ public class TopLevelBatteryPreferenceController extends BasePreferenceControlle if (Utils.containsIncompatibleChargers(mContext, TAG)) { return mContext.getString(R.string.battery_info_status_not_charging); } if (!info.discharging && info.chargeLabel != null) { if (info.batteryStatus == BatteryManager.BATTERY_STATUS_NOT_CHARGING) { // Present status only if no remaining time or status anomalous return info.statusLabel; } else if (!info.discharging && info.chargeLabel != null) { return info.chargeLabel; } else if (info.remainingLabel == null) { return info.batteryPercentString; Loading
tests/robotests/src/com/android/settings/fuelgauge/TopLevelBatteryPreferenceControllerTest.java +12 −0 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ import android.content.Intent; import android.hardware.usb.UsbManager; import android.hardware.usb.UsbPort; import android.hardware.usb.UsbPortStatus; import android.os.BatteryManager; import androidx.preference.Preference; import androidx.test.core.app.ApplicationProvider; Loading Loading @@ -145,6 +146,17 @@ public class TopLevelBatteryPreferenceControllerTest { .isEqualTo(mContext.getString(R.string.battery_info_status_not_charging)); } @Test public void getDashboardLabel_notChargingState_returnsCorrectLabel() { mController.mPreference = new Preference(mContext); BatteryInfo info = new BatteryInfo(); info.batteryStatus = BatteryManager.BATTERY_STATUS_NOT_CHARGING; info.statusLabel = "expected returned label"; assertThat(mController.getDashboardLabel(mContext, info, true)) .isEqualTo(info.statusLabel); } @Test public void getSummary_batteryNotPresent_shouldShowWarningMessage() { mController.mIsBatteryPresent = false; Loading