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

Commit 88f4ccfb authored by Evan Laird's avatar Evan Laird
Browse files

[battery] add battery saver accessibility string

Test: manual
Test: BatteryViewModelBasedOnSettingTest
Fixes: 417148392
Flag: EXEMPT bugfix
Change-Id: I1f8e5a92b7298297c48423cd963ff4f3d72a5bf8
parent 847e7766
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -643,6 +643,9 @@
    <!-- Content description of the battery level icon for accessibility, including the estimated time remaining before the phone runs out of battery *and* information that the device charging is paused in order to protect the lifetime of the battery (not shown on screen). [CHAR LIMIT=NONE] -->
    <string name="accessibility_battery_level_charging_paused_with_estimate">Battery <xliff:g id="percentage" example="90%">%1$d</xliff:g> percent, <xliff:g id="time" example="Until 3:15pm">%2$s</xliff:g>, charging paused for battery protection.</string>

    <!-- Content description of the battery level icon for accessibility (not shown on the screen). [CHAR LIMIT=NONE] -->
    <string name="accessibility_battery_level_battery_saver_with_percent">Battery <xliff:g id="number">%d</xliff:g> percent. Battery saver is on.</string>

    <!-- Content description of overflow icon container of the notifications for accessibility (not shown on the screen)[CHAR LIMIT=NONE] -->
    <string name="accessibility_overflow_action">See all notifications</string>

+9 −0
Original line number Diff line number Diff line
@@ -198,6 +198,15 @@ sealed class BatteryViewModel(
                            ContentDescription.Loaded(descr)
                        }

                        attr == PowerSave -> {
                            val descr =
                                context.getString(
                                    R.string.accessibility_battery_level_battery_saver_with_percent,
                                    level,
                                )
                            ContentDescription.Loaded(descr)
                        }

                        else -> {
                            val descr =
                                context.getString(R.string.accessibility_battery_level, level)
+63 −0
Original line number Diff line number Diff line
@@ -20,11 +20,13 @@ import android.provider.Settings
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.systemui.SysuiTestCase
import com.android.systemui.common.shared.model.ContentDescription
import com.android.systemui.kosmos.Kosmos
import com.android.systemui.kosmos.runTest
import com.android.systemui.kosmos.testScope
import com.android.systemui.kosmos.useUnconfinedTestDispatcher
import com.android.systemui.lifecycle.activateIn
import com.android.systemui.res.R
import com.android.systemui.shared.settings.data.repository.fakeSystemSettingsRepository
import com.android.systemui.statusbar.pipeline.battery.shared.ui.BatteryGlyph
import com.android.systemui.statusbar.policy.batteryController
@@ -141,4 +143,65 @@ class BatteryViewModelBasedOnSettingTest : SysuiTestCase() {

            assertThat(underTest.attribution).isEqualTo(BatteryGlyph.Bolt)
        }

    @Test
    fun contentDescription_default() =
        kosmos.runTest {
            batteryController.fake._isPluggedIn = false
            batteryController.fake._isPowerSave = false
            batteryController.fake._isDefender = false
            batteryController.fake._level = 39

            val expected =
                ContentDescription.Loaded(
                    context.getString(R.string.accessibility_battery_level, 39)
                )

            assertThat(underTest.contentDescription).isEqualTo(expected)
        }

    @Test
    fun contentDescription_defendEnabled() =
        kosmos.runTest {
            batteryController.fake._isDefender = true
            batteryController.fake._level = 39

            val expected =
                ContentDescription.Loaded(
                    context.getString(R.string.accessibility_battery_level_charging_paused, 39)
                )

            assertThat(underTest.contentDescription).isEqualTo(expected)
        }

    @Test
    fun contentDescription_charging() =
        kosmos.runTest {
            batteryController.fake._isPluggedIn = true
            batteryController.fake._level = 39

            val expected =
                ContentDescription.Loaded(
                    context.getString(R.string.accessibility_battery_level_charging, 39)
                )

            assertThat(underTest.contentDescription).isEqualTo(expected)
        }

    @Test
    fun contentDescription_batterySaver() =
        kosmos.runTest {
            batteryController.fake._isPowerSave = true
            batteryController.fake._level = 39

            val expected =
                ContentDescription.Loaded(
                    context.getString(
                        R.string.accessibility_battery_level_battery_saver_with_percent,
                        39,
                    )
                )

            assertThat(underTest.contentDescription).isEqualTo(expected)
        }
}