Show toggle summary for LE audio toggle only when the device is not in the allowlist.

Test: make RunSettingsRoboTests ROBOTEST_FILTER=BluetoothDetailsProfilesControllerTest
Change-Id: I68040e7e92630f6efac0e1fb0f35a39ebca3cfad
This commit is contained in:
chelseahao
2023-10-12 17:20:57 +08:00
committed by Chelsea Hao
parent e16afdb73a
commit 74b85e4247
2 changed files with 38 additions and 1 deletions

View File

@@ -28,6 +28,7 @@ import android.bluetooth.BluetoothClass;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothProfile;
import android.content.Context;
import android.sysprop.BluetoothProperties;
import androidx.preference.Preference;
import androidx.preference.PreferenceCategory;
@@ -41,6 +42,8 @@ import com.android.settingslib.bluetooth.LocalBluetoothProfileManager;
import com.android.settingslib.bluetooth.MapProfile;
import com.android.settingslib.bluetooth.PbapServerProfile;
import com.google.common.collect.Lists;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -60,6 +63,8 @@ import java.util.Set;
@Config(shadows = ShadowBluetoothDevice.class)
public class BluetoothDetailsProfilesControllerTest extends BluetoothDetailsControllerTestBase {
private static final String LE_DEVICE_MODEL = "le_audio_headset";
private static final String NON_LE_DEVICE_MODEL = "non_le_audio_headset";
private BluetoothDetailsProfilesController mController;
private List<LocalBluetoothProfile> mConnectableProfiles;
private PreferenceCategory mProfiles;
@@ -88,6 +93,7 @@ public class BluetoothDetailsProfilesControllerTest extends BluetoothDetailsCont
mProfiles.setKey(mController.getPreferenceKey());
mController.mProfilesContainer = mProfiles;
mScreen.addPreference(mProfiles);
BluetoothProperties.le_audio_allow_list(Lists.newArrayList(LE_DEVICE_MODEL));
}
static class FakeBluetoothProfile implements LocalBluetoothProfile {
@@ -472,4 +478,15 @@ public class BluetoothDetailsProfilesControllerTest extends BluetoothDetailsCont
verify(mProfileManager).removeServiceListener(mController);
}
@Test
public void isDeviceInAllowList_returnTrue() {
assertThat(mController.isModelNameInAllowList(LE_DEVICE_MODEL)).isTrue();
}
@Test
public void isDeviceInAllowList_returnFalse() {
assertThat(mController.isModelNameInAllowList(null)).isFalse();
assertThat(mController.isModelNameInAllowList(NON_LE_DEVICE_MODEL)).isFalse();
}
}