CMF Buds: Fix ANC modes list update

- Fix the wrong flag being checked for some modes
- Remove unnecessary outer check that prevented the list update in some
  cases
This commit is contained in:
Dominik Riebeling
2026-05-02 19:50:44 +02:00
committed by José Rebelo
parent aae925febb
commit 24d1a40e39
@@ -59,37 +59,34 @@ public class EarSettingsCustomizer implements DeviceSpecificSettingsCustomizer {
} }
} }
if (!earCoordinator.supportsLightAnc() || !earCoordinator.supportsTransparency()) { // Remove unsupported anc modes from the preference
// If light anc and transparency is not supported, remove the values from the preference final Preference audioModePref = handler.findPreference(DeviceSettingsPreferenceConst.PREF_NOTHING_EAR1_AUDIOMODE);
final Preference audioModePref = handler.findPreference(DeviceSettingsPreferenceConst.PREF_NOTHING_EAR1_AUDIOMODE); if (audioModePref != null) {
final CharSequence[] originalEntries = ((ListPreference) audioModePref).getEntries();
final CharSequence[] originalEntryValues = ((ListPreference) audioModePref).getEntryValues();
if (audioModePref != null) { final List<CharSequence> entries = new ArrayList<>();
final CharSequence[] originalEntries = ((ListPreference) audioModePref).getEntries(); final List<CharSequence> entryValues = new ArrayList<>();
final CharSequence[] originalEntryValues = ((ListPreference) audioModePref).getEntryValues();
final List<CharSequence> entries = new ArrayList<>(); for (int i = 0; i < originalEntries.length; i++) {
final List<CharSequence> entryValues = new ArrayList<>(); if ("anclight".equals(originalEntryValues[i].toString()) && !earCoordinator.supportsLightAnc()) {
continue;
for (int i = 0; i < originalEntries.length; i++) {
if ("anclight".equals(originalEntryValues[i].toString()) && !earCoordinator.supportsLightAnc()) {
continue;
}
if ("ancmedium".equals(originalEntryValues[i].toString()) && !earCoordinator.supportsTransparency()) {
continue;
}
if ("ancadaptive".equals(originalEntryValues[i].toString()) && !earCoordinator.supportsTransparency()) {
continue;
}
if ("transparency".equals(originalEntryValues[i].toString()) && !earCoordinator.supportsTransparency()) {
continue;
}
entries.add(originalEntries[i]);
entryValues.add(originalEntryValues[i]);
} }
if ("ancmedium".equals(originalEntryValues[i].toString()) && !earCoordinator.supportsMediumAnc()) {
((ListPreference) audioModePref).setEntries(entries.toArray(new CharSequence[0])); continue;
((ListPreference) audioModePref).setEntryValues(entryValues.toArray(new CharSequence[0])); }
if ("ancadaptive".equals(originalEntryValues[i].toString()) && !earCoordinator.supportsAdaptiveAnc()) {
continue;
}
if ("transparency".equals(originalEntryValues[i].toString()) && !earCoordinator.supportsTransparency()) {
continue;
}
entries.add(originalEntries[i]);
entryValues.add(originalEntryValues[i]);
} }
((ListPreference) audioModePref).setEntries(entries.toArray(new CharSequence[0]));
((ListPreference) audioModePref).setEntryValues(entryValues.toArray(new CharSequence[0]));
} }
} }