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
This commit is contained in:
@@ -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 =
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user