From 1b65e52344090a324e2f7472da25f5e5320ac235 Mon Sep 17 00:00:00 2001 From: Caitlin Shkuratov Date: Mon, 31 Oct 2022 20:01:52 +0000 Subject: [PATCH] [Dock Defend] Add an optional shield to the status bar battery drawable. The shield will be displayed when the battery is marked as overheated. Bug: 255625888 Test: manual: issue `adb shell am broadcast -a com.android.systemui.demo -e command battery -e overheated true` and verify the battery icon displays a shield Test: See bug for manual demo video Test: statusbar.battery tests Change-Id: I6b3036ae47ad7b5ae8dc78f83d019130935c9b50 --- .../graph/ThemedBatteryDrawable.kt | 7 +- packages/SystemUI/res/values/config.xml | 6 + .../battery/AccessorizedBatteryDrawable.kt | 202 ++++++++++++++++++ .../systemui/battery/BatteryMeterView.java | 44 +++- .../battery/BatteryMeterViewController.java | 9 + .../android/systemui/battery/BatterySpecs.kt | 109 ++++++++++ .../src/com/android/systemui/flags/Flags.kt | 3 + .../phone/dagger/StatusBarViewModule.java | 2 + .../statusbar/policy/BatteryController.java | 3 + .../policy/BatteryControllerImpl.java | 30 +++ .../AccessorizedBatteryDrawableTest.kt | 52 +++++ .../BatteryMeterViewControllerTest.java | 50 ++++- .../systemui/battery/BatteryMeterViewTest.kt | 42 +++- .../systemui/battery/BatterySpecsTest.kt | 101 +++++++++ .../policy/BatteryControllerTest.java | 29 +++ 15 files changed, 669 insertions(+), 20 deletions(-) create mode 100644 packages/SystemUI/src/com/android/systemui/battery/AccessorizedBatteryDrawable.kt create mode 100644 packages/SystemUI/src/com/android/systemui/battery/BatterySpecs.kt create mode 100644 packages/SystemUI/tests/src/com/android/systemui/battery/AccessorizedBatteryDrawableTest.kt create mode 100644 packages/SystemUI/tests/src/com/android/systemui/battery/BatterySpecsTest.kt diff --git a/packages/SettingsLib/src/com/android/settingslib/graph/ThemedBatteryDrawable.kt b/packages/SettingsLib/src/com/android/settingslib/graph/ThemedBatteryDrawable.kt index 5fa04f93e993a..faea5b2c3e715 100644 --- a/packages/SettingsLib/src/com/android/settingslib/graph/ThemedBatteryDrawable.kt +++ b/packages/SettingsLib/src/com/android/settingslib/graph/ThemedBatteryDrawable.kt @@ -412,14 +412,13 @@ open class ThemedBatteryDrawable(private val context: Context, frameColor: Int) } companion object { - private const val TAG = "ThemedBatteryDrawable" - private const val WIDTH = 12f - private const val HEIGHT = 20f + const val WIDTH = 12f + const val HEIGHT = 20f private const val CRITICAL_LEVEL = 15 // On a 12x20 grid, how wide to make the fill protection stroke. // Scales when our size changes private const val PROTECTION_STROKE_WIDTH = 3f // Arbitrarily chosen for visibility at small sizes - private const val PROTECTION_MIN_STROKE_WIDTH = 6f + const val PROTECTION_MIN_STROKE_WIDTH = 6f } } diff --git a/packages/SystemUI/res/values/config.xml b/packages/SystemUI/res/values/config.xml index ce9829b318cd7..55d637916d0cd 100644 --- a/packages/SystemUI/res/values/config.xml +++ b/packages/SystemUI/res/values/config.xml @@ -485,6 +485,12 @@ false + + + M5 0L0 1.88V6.19C0 9.35 2.13 12.29 5 13.01C7.87 12.29 10 9.35 10 6.19V1.88L5 0Z + +