diff options
| author | 2024-12-19 11:40:43 +0800 | |
|---|---|---|
| committer | 2024-12-19 13:45:43 +0800 | |
| commit | 66425034815f19e9966d16b4bb1f916ac353ee22 (patch) | |
| tree | 2e4acae24d29cb78077d59be297ca7721b3c7ec1 | |
| parent | 6ee3b28ed550d2c94015c377c29c4b57ed4db5cb (diff) | |
Fix BluetoothUtilsTest
Test: atest
Bug: 308368124
Flag: EXEMPT fix test
Change-Id: I4acf69664e9af3ddd2f5c84e94add6ef2b556bd9
2 files changed, 13 insertions, 1 deletions
diff --git a/packages/SettingsLib/src/com/android/settingslib/bluetooth/BluetoothUtils.java b/packages/SettingsLib/src/com/android/settingslib/bluetooth/BluetoothUtils.java index 429e4c958f05..0c642d7b8f98 100644 --- a/packages/SettingsLib/src/com/android/settingslib/bluetooth/BluetoothUtils.java +++ b/packages/SettingsLib/src/com/android/settingslib/bluetooth/BluetoothUtils.java @@ -656,7 +656,8 @@ public class BluetoothUtils { @WorkerThread public static boolean isAudioSharingHysteresisModeFixAvailable(@Nullable Context context) { return (audioSharingHysteresisModeFix() && Flags.enableLeAudioSharing()) - || (context != null && isAudioSharingPreviewEnabled(context.getContentResolver())); + || (context != null && Flags.audioSharingDeveloperOption() + && getAudioSharingPreviewValue(context.getContentResolver())); } /** Returns if the le audio sharing is enabled. */ diff --git a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/bluetooth/BluetoothUtilsTest.java b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/bluetooth/BluetoothUtilsTest.java index fa5d54283a17..ab9f871444b4 100644 --- a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/bluetooth/BluetoothUtilsTest.java +++ b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/bluetooth/BluetoothUtilsTest.java @@ -970,8 +970,10 @@ public class BluetoothUtilsTest { when(cachedBluetoothDevice2.getGroupId()).thenReturn(2); BluetoothDevice device1 = mock(BluetoothDevice.class); + when(mCachedBluetoothDevice.getDevice()).thenReturn(device1); when(mDeviceManager.findDevice(device1)).thenReturn(mCachedBluetoothDevice); BluetoothDevice device2 = mock(BluetoothDevice.class); + when(cachedBluetoothDevice2.getDevice()).thenReturn(device2); when(mDeviceManager.findDevice(device2)).thenReturn(cachedBluetoothDevice2); when(mAssistant.getAllConnectedDevices()).thenReturn(ImmutableList.of(device1, device2)); @@ -991,8 +993,10 @@ public class BluetoothUtilsTest { when(cachedBluetoothDevice2.getGroupId()).thenReturn(2); BluetoothDevice device1 = mock(BluetoothDevice.class); + when(mCachedBluetoothDevice.getDevice()).thenReturn(device1); when(mDeviceManager.findDevice(device1)).thenReturn(mCachedBluetoothDevice); BluetoothDevice device2 = mock(BluetoothDevice.class); + when(cachedBluetoothDevice2.getDevice()).thenReturn(device2); when(mDeviceManager.findDevice(device2)).thenReturn(cachedBluetoothDevice2); when(mAssistant.getAllConnectedDevices()).thenReturn(ImmutableList.of(device1, device2)); @@ -1012,8 +1016,10 @@ public class BluetoothUtilsTest { when(cachedBluetoothDevice2.getGroupId()).thenReturn(2); BluetoothDevice device1 = mock(BluetoothDevice.class); + when(mCachedBluetoothDevice.getDevice()).thenReturn(device1); when(mDeviceManager.findDevice(device1)).thenReturn(mCachedBluetoothDevice); BluetoothDevice device2 = mock(BluetoothDevice.class); + when(cachedBluetoothDevice2.getDevice()).thenReturn(device2); when(mDeviceManager.findDevice(device2)).thenReturn(cachedBluetoothDevice2); when(mAssistant.getAllConnectedDevices()).thenReturn(ImmutableList.of(device2)); @@ -1035,10 +1041,13 @@ public class BluetoothUtilsTest { when(cachedBluetoothDevice3.getGroupId()).thenReturn(3); BluetoothDevice device1 = mock(BluetoothDevice.class); + when(mCachedBluetoothDevice.getDevice()).thenReturn(device1); when(mDeviceManager.findDevice(device1)).thenReturn(mCachedBluetoothDevice); BluetoothDevice device2 = mock(BluetoothDevice.class); + when(cachedBluetoothDevice2.getDevice()).thenReturn(device2); when(mDeviceManager.findDevice(device2)).thenReturn(cachedBluetoothDevice2); BluetoothDevice device3 = mock(BluetoothDevice.class); + when(cachedBluetoothDevice3.getDevice()).thenReturn(device3); when(mDeviceManager.findDevice(device3)).thenReturn(cachedBluetoothDevice3); when(mAssistant.getAllConnectedDevices()) @@ -1280,6 +1289,8 @@ public class BluetoothUtilsTest { mSetFlagsRule.disableFlags(Flags.FLAG_ENABLE_LE_AUDIO_SHARING); mSetFlagsRule.disableFlags(Flags.FLAG_AUDIO_SHARING_HYSTERESIS_MODE_FIX); mSetFlagsRule.enableFlags(Flags.FLAG_AUDIO_SHARING_DEVELOPER_OPTION); + Settings.Global.putInt(mContext.getContentResolver(), + BluetoothUtils.DEVELOPER_OPTION_PREVIEW_KEY, 1); assertThat(BluetoothUtils.isAudioSharingHysteresisModeFixAvailable(mContext)).isTrue(); } |