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:
@@ -156,6 +156,8 @@
|
|||||||
<string name="bluetooth_hearing_device_settings_summary">Shortcut, hearing aid compatibility</string>
|
<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] -->
|
<!-- 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>
|
<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] -->
|
<!-- Message when selecting hearing aids presets failed. [CHAR LIMIT=NONE] -->
|
||||||
<string name="bluetooth_hearing_aids_presets_error">Couldn\u2019t update preset</string>
|
<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] -->
|
<!-- 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] -->
|
||||||
|
|||||||
@@ -159,19 +159,22 @@ public class BluetoothDetailsHearingAidsPresetsController extends
|
|||||||
mPreference.setEnabled(mCachedDevice.isConnectedHapClientDevice());
|
mPreference.setEnabled(mCachedDevice.isConnectedHapClientDevice());
|
||||||
|
|
||||||
loadAllPresetInfo();
|
loadAllPresetInfo();
|
||||||
|
mPreference.setSummary(null);
|
||||||
if (mPreference.getEntries().length == 0) {
|
if (mPreference.getEntries().length == 0) {
|
||||||
if (DEBUG) {
|
if (mPreference.isEnabled()) {
|
||||||
Log.w(TAG, "Disable the preference since preset info size = 0");
|
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 {
|
} else {
|
||||||
int activePresetIndex = mHapClientProfile.getActivePresetIndex(
|
int activePresetIndex = mHapClientProfile.getActivePresetIndex(
|
||||||
mCachedDevice.getDevice());
|
mCachedDevice.getDevice());
|
||||||
if (activePresetIndex != BluetoothHapClient.PRESET_INDEX_UNAVAILABLE) {
|
if (activePresetIndex != BluetoothHapClient.PRESET_INDEX_UNAVAILABLE) {
|
||||||
mPreference.setValue(Integer.toString(activePresetIndex));
|
mPreference.setValue(Integer.toString(activePresetIndex));
|
||||||
mPreference.setSummary(mPreference.getEntry());
|
mPreference.setSummary(mPreference.getEntry());
|
||||||
} else {
|
|
||||||
mPreference.setSummary(null);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ import android.bluetooth.BluetoothHapPresetInfo;
|
|||||||
import androidx.preference.ListPreference;
|
import androidx.preference.ListPreference;
|
||||||
import androidx.preference.PreferenceCategory;
|
import androidx.preference.PreferenceCategory;
|
||||||
|
|
||||||
|
import com.android.settings.R;
|
||||||
import com.android.settingslib.bluetooth.CachedBluetoothDevice;
|
import com.android.settingslib.bluetooth.CachedBluetoothDevice;
|
||||||
import com.android.settingslib.bluetooth.HapClientProfile;
|
import com.android.settingslib.bluetooth.HapClientProfile;
|
||||||
import com.android.settingslib.bluetooth.LocalBluetoothManager;
|
import com.android.settingslib.bluetooth.LocalBluetoothManager;
|
||||||
@@ -215,6 +216,8 @@ public class BluetoothDetailsHearingAidsPresetsControllerTest extends
|
|||||||
|
|
||||||
assertThat(mController.getPreference()).isNotNull();
|
assertThat(mController.getPreference()).isNotNull();
|
||||||
assertThat(mController.getPreference().isEnabled()).isFalse();
|
assertThat(mController.getPreference().isEnabled()).isFalse();
|
||||||
|
assertThat(String.valueOf(mController.getPreference().getSummary())).isEqualTo(
|
||||||
|
mContext.getString(R.string.bluetooth_hearing_aids_presets_empty_list_message));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
Reference in New Issue
Block a user