Merge changes from topic "ha-preset-unavailable" into main

* changes:
  Remove unavailable preset info option
  Show message when no preset info is obtained from the remote device
This commit is contained in:
Angela Wang
2024-06-26 02:48:19 +00:00
committed by Android (Google) Code Review
3 changed files with 39 additions and 10 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);
}
}
}
@@ -273,7 +276,8 @@ public class BluetoothDetailsHearingAidsPresetsController extends
return;
}
List<BluetoothHapPresetInfo> infoList = mHapClientProfile.getAllPresetInfo(
mCachedDevice.getDevice());
mCachedDevice.getDevice()).stream().filter(
BluetoothHapPresetInfo::isAvailable).toList();
CharSequence[] presetNames = new CharSequence[infoList.size()];
CharSequence[] presetIndexes = new CharSequence[infoList.size()];
for (int i = 0; i < infoList.size(); i++) {