Merge "Show battery info for mono audio location device" into main
diff --git a/res/layout/le_audio_bt_entity_header.xml b/res/layout/le_audio_bt_entity_header.xml
index 81911e9..421ee39 100644
--- a/res/layout/le_audio_bt_entity_header.xml
+++ b/res/layout/le_audio_bt_entity_header.xml
@@ -176,5 +176,23 @@
                 android:padding="@dimen/le_bluetooth_summary_padding"
                 android:drawablePadding="@dimen/le_bluetooth_summary_drawable_padding"/>
         </LinearLayout>
+        <LinearLayout
+            android:id="@+id/bt_battery_mono"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:layout_marginStart="@dimen/le_bluetooth_battery_start_margin"
+            android:layout_marginTop="@dimen/le_bluetooth_battery_top_margin"
+            android:gravity="center_horizontal"
+            android:orientation="horizontal"
+            android:visibility="gone"
+            android:focusable="true">
+            <TextView
+                android:id="@+id/bt_battery_mono_summary"
+                style="@style/TextAppearance.EntityHeaderSummary"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:padding="@dimen/le_bluetooth_summary_padding"
+                android:drawablePadding="@dimen/le_bluetooth_summary_drawable_padding"/>
+        </LinearLayout>
     </LinearLayout>
 </LinearLayout>
diff --git a/src/com/android/settings/accessibility/AccessibilityHearingAidPreferenceController.java b/src/com/android/settings/accessibility/AccessibilityHearingAidPreferenceController.java
index 2546d44..52560c9 100644
--- a/src/com/android/settings/accessibility/AccessibilityHearingAidPreferenceController.java
+++ b/src/com/android/settings/accessibility/AccessibilityHearingAidPreferenceController.java
@@ -162,18 +162,13 @@
         }
 
         final int side = device.getDeviceSide();
-        if (side == HearingAidInfo.DeviceSide.SIDE_LEFT_AND_RIGHT) {
-            return mContext.getString(
-                    R.string.accessibility_hearingaid_left_and_right_side_device_summary, name);
-        } else if (side == HearingAidInfo.DeviceSide.SIDE_LEFT) {
+        if (side == HearingAidInfo.DeviceSide.SIDE_LEFT) {
             return mContext.getString(
                     R.string.accessibility_hearingaid_left_side_device_summary, name);
         } else if (side == HearingAidInfo.DeviceSide.SIDE_RIGHT) {
             return mContext.getString(
                     R.string.accessibility_hearingaid_right_side_device_summary, name);
         }
-
-        // Invalid side
         return mContext.getString(
                 R.string.accessibility_hearingaid_active_device_summary, name);
     }
diff --git a/src/com/android/settings/bluetooth/LeAudioBluetoothDetailsHeaderController.java b/src/com/android/settings/bluetooth/LeAudioBluetoothDetailsHeaderController.java
index 2524894..4c7c98e 100644
--- a/src/com/android/settings/bluetooth/LeAudioBluetoothDetailsHeaderController.java
+++ b/src/com/android/settings/bluetooth/LeAudioBluetoothDetailsHeaderController.java
@@ -225,6 +225,8 @@
             return R.id.bt_battery_left_summary;
         } else if (containerId == R.id.bt_battery_right) {
             return R.id.bt_battery_right_summary;
+        } else if (containerId == R.id.bt_battery_mono) {
+            return R.id.bt_battery_mono_summary;
         }
         Log.d(TAG, "No summary resource id. The containerId is " + containerId);
         return INVALID_RESOURCE_ID;
@@ -237,6 +239,8 @@
         updateBatteryLayout(R.id.bt_battery_left, BluetoothUtils.META_INT_ERROR);
         // hide the right
         updateBatteryLayout(R.id.bt_battery_right, BluetoothUtils.META_INT_ERROR);
+        // hide the mono
+        updateBatteryLayout(R.id.bt_battery_mono, BluetoothUtils.META_INT_ERROR);
     }
 
     private void updateBatteryLayout() {
@@ -261,11 +265,6 @@
             int deviceId = leAudioProfile.getAudioLocation(cachedDevice.getDevice());
             Log.d(TAG, "LeAudioDevices:" + cachedDevice.getDevice().getAnonymizedAddress()
                     + ", deviceId:" + deviceId);
-
-            if (deviceId == BluetoothLeAudio.AUDIO_LOCATION_INVALID) {
-                Log.d(TAG, "The device does not support the AUDIO_LOCATION.");
-                return;
-            }
             boolean isLeft = (deviceId & LEFT_DEVICE_ID) != 0;
             boolean isRight = (deviceId & RIGHT_DEVICE_ID) != 0;
             boolean isLeftRight = isLeft && isRight;
@@ -280,6 +279,8 @@
                 updateBatteryLayout(R.id.bt_battery_left, cachedDevice.getBatteryLevel());
             } else if (isRight) {
                 updateBatteryLayout(R.id.bt_battery_right, cachedDevice.getBatteryLevel());
+            } else if (deviceId == BluetoothLeAudio.AUDIO_LOCATION_MONO) {
+                updateBatteryLayout(R.id.bt_battery_mono, cachedDevice.getBatteryLevel());
             } else {
                 Log.d(TAG, "The device id is other Audio Location. Do nothing.");
             }
diff --git a/tests/robotests/src/com/android/settings/accessibility/AccessibilityHearingAidPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/accessibility/AccessibilityHearingAidPreferenceControllerTest.java
index 97faa63..b8b0699 100644
--- a/tests/robotests/src/com/android/settings/accessibility/AccessibilityHearingAidPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/accessibility/AccessibilityHearingAidPreferenceControllerTest.java
@@ -208,7 +208,24 @@
         ShadowLooper.idleMainLooper();
 
         assertThat(mHearingAidPreference.getSummary().toString().contentEquals(
-                "TEST_HEARING_AID_BT_DEVICE_NAME / Left and right")).isTrue();
+                "TEST_HEARING_AID_BT_DEVICE_NAME active")).isTrue();
+    }
+
+    @Test
+    public void getSummary_connectedLeAudioHearingAidMonoSide_connectedSummary() {
+        when(mCachedBluetoothDevice.getDeviceSide()).thenReturn(
+                HearingAidInfo.DeviceSide.SIDE_MONO);
+        when(mCachedBluetoothDevice.getMemberDevice()).thenReturn(new HashSet<>());
+        when(mHapClientProfile.getConnectedDevices()).thenReturn(generateHearingAidDeviceList());
+
+        mPreferenceController.onStart();
+        Intent intent = new Intent(BluetoothHapClient.ACTION_HAP_CONNECTION_STATE_CHANGED);
+        intent.putExtra(BluetoothHearingAid.EXTRA_STATE, BluetoothHapClient.STATE_CONNECTED);
+        sendIntent(intent);
+        ShadowLooper.idleMainLooper();
+
+        assertThat(mHearingAidPreference.getSummary().toString().contentEquals(
+                "TEST_HEARING_AID_BT_DEVICE_NAME active")).isTrue();
     }
 
     @Test