Merge "Make bluetooth profile toggles configurable" into main
This commit is contained in:
@@ -120,11 +120,7 @@ public class BluetoothDetailsProfilesControllerTest extends BluetoothDetailsCont
|
||||
.thenAnswer(invocation -> ImmutableList.of(mConnectableProfiles));
|
||||
|
||||
setupDevice(mDeviceConfig);
|
||||
mController = new BluetoothDetailsProfilesController(mContext, mFragment, mLocalManager,
|
||||
mCachedDevice, mLifecycle);
|
||||
mProfiles.setKey(mController.getPreferenceKey());
|
||||
mController.mProfilesContainer = mProfiles;
|
||||
mScreen.addPreference(mProfiles);
|
||||
initController(List.of());
|
||||
BluetoothProperties.le_audio_allow_list(Lists.newArrayList(LE_DEVICE_MODEL));
|
||||
}
|
||||
|
||||
@@ -554,6 +550,36 @@ public class BluetoothDetailsProfilesControllerTest extends BluetoothDetailsCont
|
||||
|
||||
@Test
|
||||
public void prefKeyInBlockingList_hideToggle() {
|
||||
initController(List.of("A2DP"));
|
||||
setupDevice(makeDefaultDeviceConfig());
|
||||
|
||||
addA2dpProfileToDevice(true, true, true);
|
||||
when(mFeatureProvider.getInvisibleProfilePreferenceKeys(any(), any()))
|
||||
.thenReturn(ImmutableSet.of());
|
||||
|
||||
showScreen(mController);
|
||||
|
||||
List<SwitchPreferenceCompat> switches = getProfileSwitches(false);
|
||||
assertThat(switches.get(0).isVisible()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void prefKeyNotInBlockingList_showToggle() {
|
||||
initController(List.of());
|
||||
setupDevice(makeDefaultDeviceConfig());
|
||||
|
||||
addA2dpProfileToDevice(true, true, true);
|
||||
when(mFeatureProvider.getInvisibleProfilePreferenceKeys(any(), any()))
|
||||
.thenReturn(ImmutableSet.of());
|
||||
|
||||
showScreen(mController);
|
||||
|
||||
List<SwitchPreferenceCompat> switches = getProfileSwitches(false);
|
||||
assertThat(switches.get(0).isVisible()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void prefKeyInFeatureProviderBlockingList_hideToggle() {
|
||||
setupDevice(makeDefaultDeviceConfig());
|
||||
|
||||
addA2dpProfileToDevice(true, true, true);
|
||||
@@ -567,7 +593,7 @@ public class BluetoothDetailsProfilesControllerTest extends BluetoothDetailsCont
|
||||
}
|
||||
|
||||
@Test
|
||||
public void prefKeyNotInBlockingList_showToggle() {
|
||||
public void prefKeyNotInFeatureProviderBlockingList_showToggle() {
|
||||
setupDevice(makeDefaultDeviceConfig());
|
||||
|
||||
addA2dpProfileToDevice(true, true, true);
|
||||
@@ -627,4 +653,13 @@ public class BluetoothDetailsProfilesControllerTest extends BluetoothDetailsCont
|
||||
assertThat(switches.getFirst().getTitle()).isEqualTo(
|
||||
mContext.getString(mLeAudioProfile.getNameResource(mDevice)));
|
||||
}
|
||||
|
||||
private void initController(List<String> invisibleProfiles) {
|
||||
mController = new BluetoothDetailsProfilesController(mContext, mFragment, mLocalManager,
|
||||
mCachedDevice, mLifecycle, invisibleProfiles);
|
||||
mProfiles.setKey(mController.getPreferenceKey());
|
||||
mController.mProfilesContainer = mProfiles;
|
||||
mScreen.removeAll();
|
||||
mScreen.addPreference(mProfiles);
|
||||
}
|
||||
}
|
||||
|
@@ -122,10 +122,11 @@ class DeviceDetailsFragmentFormatterTest {
|
||||
.thenReturn(
|
||||
DeviceSettingConfigModel(
|
||||
listOf(
|
||||
DeviceSettingConfigItemModel.BuiltinItem(
|
||||
DeviceSettingConfigItemModel.BuiltinItem.CommonBuiltinItem(
|
||||
DeviceSettingId.DEVICE_SETTING_ID_HEADER,
|
||||
"bluetooth_device_header"),
|
||||
DeviceSettingConfigItemModel.BuiltinItem(
|
||||
"bluetooth_device_header"
|
||||
),
|
||||
DeviceSettingConfigItemModel.BuiltinItem.CommonBuiltinItem(
|
||||
DeviceSettingId.DEVICE_SETTING_ID_ACTION_BUTTONS, "action_buttons"),
|
||||
),
|
||||
listOf(),
|
||||
@@ -203,10 +204,10 @@ class DeviceDetailsFragmentFormatterTest {
|
||||
.thenReturn(
|
||||
DeviceSettingConfigModel(
|
||||
listOf(
|
||||
DeviceSettingConfigItemModel.BuiltinItem(
|
||||
DeviceSettingConfigItemModel.BuiltinItem.CommonBuiltinItem(
|
||||
DeviceSettingId.DEVICE_SETTING_ID_HEADER,
|
||||
"bluetooth_device_header"),
|
||||
DeviceSettingConfigItemModel.BuiltinItem(
|
||||
DeviceSettingConfigItemModel.BuiltinItem.CommonBuiltinItem(
|
||||
DeviceSettingId.DEVICE_SETTING_ID_KEYBOARD_SETTINGS,
|
||||
"keyboard_settings"),
|
||||
),
|
||||
@@ -227,12 +228,12 @@ class DeviceDetailsFragmentFormatterTest {
|
||||
.thenReturn(
|
||||
DeviceSettingConfigModel(
|
||||
listOf(
|
||||
DeviceSettingConfigItemModel.BuiltinItem(
|
||||
DeviceSettingConfigItemModel.BuiltinItem.CommonBuiltinItem(
|
||||
DeviceSettingId.DEVICE_SETTING_ID_HEADER,
|
||||
"bluetooth_device_header"),
|
||||
DeviceSettingConfigItemModel.AppProvidedItem(
|
||||
DeviceSettingId.DEVICE_SETTING_ID_ANC),
|
||||
DeviceSettingConfigItemModel.BuiltinItem(
|
||||
DeviceSettingConfigItemModel.BuiltinItem.CommonBuiltinItem(
|
||||
DeviceSettingId.DEVICE_SETTING_ID_KEYBOARD_SETTINGS,
|
||||
"keyboard_settings"),
|
||||
),
|
||||
|
@@ -282,10 +282,10 @@ class BluetoothDeviceDetailsViewModelTest {
|
||||
|
||||
private companion object {
|
||||
val BUILTIN_SETTING_ITEM_1 =
|
||||
DeviceSettingConfigItemModel.BuiltinItem(
|
||||
DeviceSettingConfigItemModel.BuiltinItem.CommonBuiltinItem(
|
||||
DeviceSettingId.DEVICE_SETTING_ID_HEADER, "bluetooth_device_header")
|
||||
val BUILDIN_SETTING_ITEM_2 =
|
||||
DeviceSettingConfigItemModel.BuiltinItem(
|
||||
DeviceSettingConfigItemModel.BuiltinItem.CommonBuiltinItem(
|
||||
DeviceSettingId.DEVICE_SETTING_ID_ACTION_BUTTONS, "action_buttons")
|
||||
val SETTING_ITEM_HELP = DeviceSettingConfigItemModel.AppProvidedItem(12345)
|
||||
}
|
||||
|
Reference in New Issue
Block a user