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

Commit 0c019b42 authored by Shawn Lee's avatar Shawn Lee Committed by Automerger Merge Worker
Browse files

Merge "Show battery percentage in QS header" into udc-dev am: a9ab5cc7 am:...

Merge "Show battery percentage in QS header" into udc-dev am: a9ab5cc7 am: 7bc96de8 am: a12de783

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/23681798



Change-Id: I19c5db513aa698d638f52a6e4ea6a5bc8cc1c01d
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents aaa36ac8 a12de783
Loading
Loading
Loading
Loading
+3 −10
Original line number Diff line number Diff line
@@ -39,19 +39,12 @@ 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 =
+9 −5
Original line number Diff line number Diff line
@@ -63,36 +63,40 @@ 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_ESTIMATE)
            .isEqualTo(BatteryMeterView.MODE_ON)
    }

    @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_ESTIMATE)
            .isEqualTo(BatteryMeterView.MODE_ON)
    }

    @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_ESTIMATE)
            .isEqualTo(BatteryMeterView.MODE_ON)
    }

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

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