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

Commit 82d5103f authored by ykhung's avatar ykhung
Browse files

Hide BatteryManagerPreference if there is no adaptive charging

Fix: 271387663
Test: presubmit
Change-Id: I12c511f17f23b21f6a584d86e854683fba037047
parent b25a824f
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -51,6 +51,7 @@ public class BatteryManagerPreferenceController extends BasePreferenceController
    @Override
    public int getAvailabilityStatus() {
        return mPowerUsageFeatureProvider.isBatteryManagerSupported()
                    && mPowerUsageFeatureProvider.isAdaptiveChargingSupported()
                ? AVAILABLE_UNSEARCHABLE : UNSUPPORTED_ON_DEVICE;
    }

+1 −7
Original line number Diff line number Diff line
@@ -61,12 +61,6 @@ public class TopLevelBatteryPreferenceControllerTest {
        assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE);
    }

    @Test
    @Config(qualifiers = "mcc999")
    public void getAvailabilityStatus_unsupportedWhenSet() {
        assertThat(mController.getAvailabilityStatus()).isEqualTo(UNSUPPORTED_ON_DEVICE);
    }

    @Test
    public void convertClassPathToComponentName_nullInput_returnsNull() {
        assertThat(mController.convertClassPathToComponentName(null)).isNull();
+10 −0
Original line number Diff line number Diff line
@@ -86,6 +86,7 @@ public class BatteryManagerPreferenceControllerTest {
    @Test
    public void getAvailabilityStatus_supportBatteryManager_showPrefPage() {
        when(mPowerUsageFeatureProvider.isBatteryManagerSupported()).thenReturn(true);
        when(mPowerUsageFeatureProvider.isAdaptiveChargingSupported()).thenReturn(true);

        assertThat(mController.getAvailabilityStatus()).isEqualTo(
                BatteryManagerPreferenceController.AVAILABLE_UNSEARCHABLE);
@@ -98,4 +99,13 @@ public class BatteryManagerPreferenceControllerTest {
        assertThat(mController.getAvailabilityStatus()).isEqualTo(
                BatteryManagerPreferenceController.UNSUPPORTED_ON_DEVICE);
    }

    @Test
    public void getAvailabilityStatus_supportBatteryManagerWithoutAC_notShowPrefPage() {
        when(mPowerUsageFeatureProvider.isBatteryManagerSupported()).thenReturn(true);
        when(mPowerUsageFeatureProvider.isAdaptiveChargingSupported()).thenReturn(false);

        assertThat(mController.getAvailabilityStatus()).isEqualTo(
                BatteryManagerPreferenceController.UNSUPPORTED_ON_DEVICE);
    }
}