Show message when no preset info is obtained from the remote device

Display message when hearing aid has no presets configured. Previously, the preset item was grayed out with no explanation, causing confusion. Now, a clear message informs users that presets are not available on their device.

Bug: 345112286
Test: atest BluetoothDetailsHearingAidsPresetsControllerTest
Flag: EXEMPT bugfix
Change-Id: Ie1ece8f08933eb28a5947e2a030888a6bc49bc9f
This commit is contained in:
Angela Wang
2024-06-19 06:56:52 +00:00
parent a6c54bc98f
commit 9a8b50baea
3 changed files with 13 additions and 5 deletions

View File

@@ -159,19 +159,22 @@ public class BluetoothDetailsHearingAidsPresetsController extends
mPreference.setEnabled(mCachedDevice.isConnectedHapClientDevice());
loadAllPresetInfo();
mPreference.setSummary(null);
if (mPreference.getEntries().length == 0) {
if (DEBUG) {
Log.w(TAG, "Disable the preference since preset info size = 0");
if (mPreference.isEnabled()) {
if (DEBUG) {
Log.w(TAG, "Disable the preference since preset info size = 0");
}
mPreference.setEnabled(false);
mPreference.setSummary(mContext.getString(
R.string.bluetooth_hearing_aids_presets_empty_list_message));
}
mPreference.setEnabled(false);
} else {
int activePresetIndex = mHapClientProfile.getActivePresetIndex(
mCachedDevice.getDevice());
if (activePresetIndex != BluetoothHapClient.PRESET_INDEX_UNAVAILABLE) {
mPreference.setValue(Integer.toString(activePresetIndex));
mPreference.setSummary(mPreference.getEntry());
} else {
mPreference.setSummary(null);
}
}
}