summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Shawn Lee <syeonlee@google.com> 2023-06-13 17:28:06 -0700
committer Shawn Lee <syeonlee@google.com> 2023-06-14 12:58:21 -0700
commitd15925a963e4effaf6fd1a6104316186bddee169 (patch)
tree28914316a13c23cf1f4af149682f14772389df1c
parentb3ea50636a8c0429f67b64aec383d0da06889a1a (diff)
Show battery percentage in QS header
This change temporarily short-circuits the logic to show battery percentage instead of estimate in the QS header. This is in order to avoid exposing visibly broken behavior to users while a more comprehensive solution for the underlying issue is worked on. Bug: 282044659 Test: manual Change-Id: I2fde71ea940be38fbf85028c1f9cc1b993712c02
-rw-r--r--packages/SystemUI/src/com/android/systemui/shade/QsBatteryModeController.kt13
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/shade/QsBatteryModeControllerTest.kt14
2 files changed, 12 insertions, 15 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/shade/QsBatteryModeController.kt b/packages/SystemUI/src/com/android/systemui/shade/QsBatteryModeController.kt
index 3eec7fa0e84a..ff57a73a8d6d 100644
--- a/packages/SystemUI/src/com/android/systemui/shade/QsBatteryModeController.kt
+++ b/packages/SystemUI/src/com/android/systemui/shade/QsBatteryModeController.kt
@@ -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
- }
+ BatteryMeterView.MODE_ON
fun updateResources() {
fadeInStartFraction =
diff --git a/packages/SystemUI/tests/src/com/android/systemui/shade/QsBatteryModeControllerTest.kt b/packages/SystemUI/tests/src/com/android/systemui/shade/QsBatteryModeControllerTest.kt
index d421acac2daa..b028f1fd3664 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/shade/QsBatteryModeControllerTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/shade/QsBatteryModeControllerTest.kt
@@ -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()