Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9a8b50ba authored by Angela Wang's avatar Angela Wang
Browse files

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
parent a6c54bc9
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -156,6 +156,8 @@
    <string name="bluetooth_hearing_device_settings_summary">Shortcut, hearing aid compatibility</string>
    <!-- Connected devices settings. Title for hearing aids presets. A preset is a set of hearing aid settings. User can apply different settings in different environments (e.g. Outdoor, Restaurant, Home) [CHAR LIMIT=60] [BACKUP_MESSAGE_ID=5429761844739722885] -->
    <string name="bluetooth_hearing_aids_presets">Preset</string>
    <!-- Connected devices settings. Summary of the preference when no preset info is obtained from the remote device [CHAR LIMIT=60] -->
    <string name="bluetooth_hearing_aids_presets_empty_list_message">There are no presets programmed by your audiologist</string>
    <!-- Message when selecting hearing aids presets failed. [CHAR LIMIT=NONE] -->
    <string name="bluetooth_hearing_aids_presets_error">Couldn\u2019t update preset</string>
    <!-- Connected devices settings. Title of the preference to show the entrance of the audio output page. It can change different types of audio are played on phone or other bluetooth devices. [CHAR LIMIT=35] -->
+8 −5
Original line number Diff line number Diff line
@@ -159,19 +159,22 @@ public class BluetoothDetailsHearingAidsPresetsController extends
        mPreference.setEnabled(mCachedDevice.isConnectedHapClientDevice());

        loadAllPresetInfo();
        mPreference.setSummary(null);
        if (mPreference.getEntries().length == 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));
            }
        } 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);
            }
        }
    }
+3 −0
Original line number Diff line number Diff line
@@ -38,6 +38,7 @@ import android.bluetooth.BluetoothHapPresetInfo;
import androidx.preference.ListPreference;
import androidx.preference.PreferenceCategory;

import com.android.settings.R;
import com.android.settingslib.bluetooth.CachedBluetoothDevice;
import com.android.settingslib.bluetooth.HapClientProfile;
import com.android.settingslib.bluetooth.LocalBluetoothManager;
@@ -215,6 +216,8 @@ public class BluetoothDetailsHearingAidsPresetsControllerTest extends

        assertThat(mController.getPreference()).isNotNull();
        assertThat(mController.getPreference().isEnabled()).isFalse();
        assertThat(String.valueOf(mController.getPreference().getSummary())).isEqualTo(
                mContext.getString(R.string.bluetooth_hearing_aids_presets_empty_list_message));
    }

    @Test