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

Commit 3faf6ec6 authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Revert "Show battery percentage in QS header"" into udc-dev am: fe41ea83

parents d21ff0ee fe41ea83
Loading
Loading
Loading
Loading
+10 −3
Original line number Diff line number Diff line
@@ -39,12 +39,19 @@ constructor(
     * [cutout]. We don't show battery estimation in qqs header on the devices with center cutout.
     * The result might be null when the battery icon is invisible during the qs-qqs transition
     * animation.
     *
     * Note: short-circuiting this value until a comprehensive fix for b/282044659 is finished.
     */
    @BatteryMeterView.BatteryPercentMode
    fun getBatteryMode(cutout: DisplayCutout?, qsExpandedFraction: Float): Int? =
        when {
            qsExpandedFraction > fadeInStartFraction -> BatteryMeterView.MODE_ESTIMATE
            qsExpandedFraction < fadeOutCompleteFraction ->
                if (hasCenterCutout(cutout)) {
                    BatteryMeterView.MODE_ON
                } else {
                    BatteryMeterView.MODE_ESTIMATE
                }
            else -> null
        }

    fun updateResources() {
        fadeInStartFraction =
+5 −9
Original line number Diff line number Diff line
@@ -63,40 +63,36 @@ class QsBatteryModeControllerTest : SysuiTestCase() {

    @Test
    fun returnsMODE_ESTIMATEforQsWithCenterCutout() {
        // TODO (b/282044659): revert this test to previous behavior
        assertThat(controller.getBatteryMode(CENTER_TOP_CUTOUT, QS_END_FRAME.nextFrameToFraction()))
            .isEqualTo(BatteryMeterView.MODE_ON)
            .isEqualTo(BatteryMeterView.MODE_ESTIMATE)
    }

    @Test
    fun returnsMODE_ONforQqsWithCornerCutout() {
        whenever(insetsProvider.currentRotationHasCornerCutout()).thenReturn(true)

        // TODO (b/282044659): revert this test to previous behavior
        assertThat(
                controller.getBatteryMode(CENTER_TOP_CUTOUT, QQS_START_FRAME.prevFrameToFraction())
            )
            .isEqualTo(BatteryMeterView.MODE_ON)
            .isEqualTo(BatteryMeterView.MODE_ESTIMATE)
    }

    @Test
    fun returnsMODE_ESTIMATEforQsWithCornerCutout() {
        whenever(insetsProvider.currentRotationHasCornerCutout()).thenReturn(true)

        // TODO (b/282044659): revert this test to previous behavior
        assertThat(controller.getBatteryMode(CENTER_TOP_CUTOUT, QS_END_FRAME.nextFrameToFraction()))
            .isEqualTo(BatteryMeterView.MODE_ON)
            .isEqualTo(BatteryMeterView.MODE_ESTIMATE)
    }

    @Test
    fun returnsNullInBetween() {
        // TODO (b/282044659): revert this test to previous behavior
        assertThat(
                controller.getBatteryMode(CENTER_TOP_CUTOUT, QQS_START_FRAME.nextFrameToFraction())
            )
            .isEqualTo(BatteryMeterView.MODE_ON)
            .isNull()
        assertThat(controller.getBatteryMode(CENTER_TOP_CUTOUT, QS_END_FRAME.prevFrameToFraction()))
            .isEqualTo(BatteryMeterView.MODE_ON)
            .isNull()
    }

    private fun Int.prevFrameToFraction(): Float = (this - 1) / MOTION_LAYOUT_MAX_FRAME.toFloat()