From b5dbe8af2b0e0435a2158fc2826ecdaada601f54 Mon Sep 17 00:00:00 2001 From: Angela Wang Date: Fri, 22 Nov 2024 06:21:10 +0000 Subject: [PATCH] Show battery info for mono audio location device 1. Show mono battery info in LeAudioBluetoothDetailsHeaderController without side text in front of the battery icon 2. Show mono side device on Settings > Accessibility > Hearing devices's summary without side information Flag: EXEMPT bugfix Bug: 379616650 Test: atest AccessibilityHearingAidPreferenceControllerTest Test: manually check UI with real device Change-Id: I4a1a3357e2cef51df505923e38da33767c78e8f3 --- res/layout/le_audio_bt_entity_header.xml | 18 ++++++++++++++++++ ...ibilityHearingAidPreferenceController.java | 7 +------ ...AudioBluetoothDetailsHeaderController.java | 11 ++++++----- ...ityHearingAidPreferenceControllerTest.java | 19 ++++++++++++++++++- 4 files changed, 43 insertions(+), 12 deletions(-) diff --git a/res/layout/le_audio_bt_entity_header.xml b/res/layout/le_audio_bt_entity_header.xml index 81911e9c946..421ee393fea 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"/> + + + diff --git a/src/com/android/settings/accessibility/AccessibilityHearingAidPreferenceController.java b/src/com/android/settings/accessibility/AccessibilityHearingAidPreferenceController.java index 2546d44d8a6..52560c98eb4 100644 --- a/src/com/android/settings/accessibility/AccessibilityHearingAidPreferenceController.java +++ b/src/com/android/settings/accessibility/AccessibilityHearingAidPreferenceController.java @@ -162,18 +162,13 @@ public class AccessibilityHearingAidPreferenceController extends BasePreferenceC } 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 25248942be7..4c7c98eb48f 100644 --- a/src/com/android/settings/bluetooth/LeAudioBluetoothDetailsHeaderController.java +++ b/src/com/android/settings/bluetooth/LeAudioBluetoothDetailsHeaderController.java @@ -225,6 +225,8 @@ public class LeAudioBluetoothDetailsHeaderController extends BasePreferenceContr 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 @@ public class LeAudioBluetoothDetailsHeaderController extends BasePreferenceContr 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 @@ public class LeAudioBluetoothDetailsHeaderController extends BasePreferenceContr 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 @@ public class LeAudioBluetoothDetailsHeaderController extends BasePreferenceContr 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 97faa63400e..b8b0699e8c7 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 @@ public class AccessibilityHearingAidPreferenceControllerTest { 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