Add content description for battery charging status icon

BUG: 372622360
Test: atest AdvancedBluetoothDetailsHeaderControllerTest
Flag: EXEMPT minor fix
Change-Id: I23a889e1576c0625cefb91386987df8826c1935f
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 54b6fbc..c707365 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -2002,6 +2002,11 @@
     <string name="bluetooth_companion_app_body"><xliff:g id="app_name" example="App Name">%1$s</xliff:g> app will no longer connect to your <xliff:g id="device_name" example="Device Name">%2$s</xliff:g></string>
     <!-- Summary of Bluetooth LE Audio toggle in Device Details. [CHAR LIMIT=40] -->
     <string name="device_details_leaudio_toggle_summary">Experimental. Improves audio quality.</string>
+    <!-- Content Description for battery icon in device details screen [CHAR LIMIT=NONE]-->
+    <string name="device_details_battery">Battery</string>
+    <!-- Content Description for battery charging icon in device details screen [CHAR LIMIT=NONE]-->
+    <string name="device_details_battery_charging">Battery, charging</string>
+
 
     <!--  Bluetooth device details. In the confirmation dialog for unpairing a paired device, this is the label on the button that will complete the unpairing action. -->
     <string name="bluetooth_unpair_dialog_forget_confirm_button">Forget device</string>
diff --git a/src/com/android/settings/bluetooth/AdvancedBluetoothDetailsHeaderController.java b/src/com/android/settings/bluetooth/AdvancedBluetoothDetailsHeaderController.java
index 02b8813..d8e834d 100644
--- a/src/com/android/settings/bluetooth/AdvancedBluetoothDetailsHeaderController.java
+++ b/src/com/android/settings/bluetooth/AdvancedBluetoothDetailsHeaderController.java
@@ -626,6 +626,11 @@
             imageView.setLayoutParams(layoutParams);
         } else {
             imageView.setImageDrawable(createBtBatteryIcon(mContext, level, charging));
+            imageView.setContentDescription(
+                    mContext.getString(
+                            charging
+                                    ? R.string.device_details_battery_charging
+                                    : R.string.device_details_battery));
             LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(
                     ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
             imageView.setLayoutParams(layoutParams);
diff --git a/tests/robotests/src/com/android/settings/bluetooth/AdvancedBluetoothDetailsHeaderControllerTest.java b/tests/robotests/src/com/android/settings/bluetooth/AdvancedBluetoothDetailsHeaderControllerTest.java
index db8c862..fc1df5a 100644
--- a/tests/robotests/src/com/android/settings/bluetooth/AdvancedBluetoothDetailsHeaderControllerTest.java
+++ b/tests/robotests/src/com/android/settings/bluetooth/AdvancedBluetoothDetailsHeaderControllerTest.java
@@ -329,11 +329,16 @@
 
         mController.refresh();
 
-        assertBatteryIcon(mLayoutPreference.findViewById(R.id.layout_left),
-                R.drawable.ic_battery_alert_24dp);
-        assertBatteryIcon(mLayoutPreference.findViewById(R.id.layout_right), /* resId= */-1);
-        assertBatteryIcon(mLayoutPreference.findViewById(R.id.layout_middle),
-                R.drawable.ic_battery_alert_24dp);
+        assertBatteryIcon(
+                mLayoutPreference.findViewById(R.id.layout_left),
+                R.drawable.ic_battery_alert_24dp,
+                false);
+        assertBatteryIcon(
+                mLayoutPreference.findViewById(R.id.layout_right), /* resId= */ -1, true);
+        assertBatteryIcon(
+                mLayoutPreference.findViewById(R.id.layout_middle),
+                R.drawable.ic_battery_alert_24dp,
+                false);
     }
 
     @Test
@@ -546,10 +551,15 @@
         }
     }
 
-    private void assertBatteryIcon(LinearLayout linearLayout, int resId) {
+    private void assertBatteryIcon(LinearLayout linearLayout, int resId, boolean charging) {
         final ImageView imageView = linearLayout.findViewById(R.id.bt_battery_icon);
-        assertThat(shadowOf(imageView.getDrawable()).getCreatedFromResId())
-                .isEqualTo(resId);
+        if (charging) {
+            assertThat(imageView.getContentDescription().toString())
+                    .isEqualTo(mContext.getString(R.string.device_details_battery_charging));
+        } else {
+            assertThat(imageView.getContentDescription().toString())
+                    .isEqualTo(mContext.getString(R.string.device_details_battery));
+        }
+        assertThat(shadowOf(imageView.getDrawable()).getCreatedFromResId()).isEqualTo(resId);
     }
-
 }