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

Commit 4f98350b authored by YK Hung's avatar YK Hung Committed by Android (Google) Code Review
Browse files

Merge "Hide BatteryManagerPreference if there is no adaptive charging" into udc-dev

parents 5da8894d 82d5103f
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);
    }
}