Merge "Remove hidden Bluetooth dependencies" am: 2e6f2dcfff am: 19d5264723

Original change: https://android-review.googlesource.com/c/platform/packages/apps/Settings/+/1989146

Change-Id: I59f5ddaa559331d6efd974e7abd719db3d05aafb
This commit is contained in:
Rahul Sabnis
2022-02-16 23:18:32 +00:00
committed by Automerger Merge Worker
6 changed files with 17 additions and 6 deletions

View File

@@ -193,7 +193,7 @@ public class AccessibilityHearingAidPreferenceControllerTest {
private void setupBluetoothEnvironment() {
ShadowBluetoothUtils.sLocalBluetoothManager = mLocalBluetoothManager;
mLocalBluetoothManager = Utils.getLocalBtManager(mContext);
mBluetoothManager = new BluetoothManager(mContext);
mBluetoothManager = mContext.getSystemService(BluetoothManager.class);
mBluetoothAdapter = mBluetoothManager.getAdapter();
when(mLocalBluetoothManager.getCachedDeviceManager()).thenReturn(mCachedDeviceManager);
when(mLocalBluetoothManager.getProfileManager()).thenReturn(mLocalBluetoothProfileManager);

View File

@@ -76,7 +76,7 @@ public abstract class BluetoothDetailsControllerTestBase {
when(mFragment.getPreferenceScreen()).thenReturn(mScreen);
mLifecycleOwner = () -> mLifecycle;
mLifecycle = spy(new Lifecycle(mLifecycleOwner));
mBluetoothManager = new BluetoothManager(mContext);
mBluetoothManager = mContext.getSystemService(BluetoothManager.class);
mBluetoothAdapter = mBluetoothManager.getAdapter();
}

View File

@@ -24,6 +24,7 @@ import android.bluetooth.BluetoothClass;
import android.bluetooth.BluetoothDevice;
import android.content.Context;
import android.content.Intent;
import android.os.Parcel;
import com.android.settings.testutils.shadow.ShadowBluetoothAdapter;
@@ -40,12 +41,22 @@ import org.robolectric.annotation.Config;
@Config(shadows = {ShadowBluetoothAdapter.class})
public class BluetoothPairingControllerTest {
private final BluetoothClass mBluetoothClass =
new BluetoothClass(BluetoothClass.Device.AUDIO_VIDEO_HANDSFREE);
createBtClass(BluetoothClass.Device.AUDIO_VIDEO_HANDSFREE);
@Mock
private BluetoothDevice mBluetoothDevice;
private Context mContext;
private BluetoothPairingController mBluetoothPairingController;
private BluetoothClass createBtClass(int deviceClass) {
Parcel p = Parcel.obtain();
p.writeInt(deviceClass);
p.setDataPosition(0); // reset position of parcel before passing to constructor
BluetoothClass bluetoothClass = BluetoothClass.CREATOR.createFromParcel(p);
p.recycle();
return bluetoothClass;
}
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);

View File

@@ -137,7 +137,7 @@ public class AudioOutputSwitchPreferenceControllerTest {
mPackageManager = Shadow.extract(mContext.getPackageManager());
mPackageManager.setSystemFeature(PackageManager.FEATURE_BLUETOOTH, true);
mBluetoothManager = new BluetoothManager(mContext);
mBluetoothManager = mContext.getSystemService(BluetoothManager.class);
mBluetoothAdapter = mBluetoothManager.getAdapter();
mBluetoothDevice = spy(mBluetoothAdapter.getRemoteDevice(TEST_DEVICE_ADDRESS_1));

View File

@@ -129,7 +129,7 @@ public class HandsFreeProfileOutputPreferenceControllerTest {
when(mLocalBluetoothProfileManager.getHeadsetProfile()).thenReturn(mHeadsetProfile);
when(mLocalBluetoothProfileManager.getHearingAidProfile()).thenReturn(mHearingAidProfile);
mBluetoothManager = new BluetoothManager(mContext);
mBluetoothManager = mContext.getSystemService(BluetoothManager.class);
mBluetoothAdapter = mBluetoothManager.getAdapter();
mBluetoothDevice = spy(mBluetoothAdapter.getRemoteDevice(TEST_DEVICE_ADDRESS_1));

View File

@@ -170,7 +170,7 @@ public class MediaOutputPreferenceControllerTest {
when(mLocalBluetoothProfileManager.getA2dpProfile()).thenReturn(mA2dpProfile);
when(mLocalBluetoothProfileManager.getHearingAidProfile()).thenReturn(mHearingAidProfile);
mBluetoothManager = new BluetoothManager(mContext);
mBluetoothManager = mContext.getSystemService(BluetoothManager.class);
mBluetoothAdapter = mBluetoothManager.getAdapter();
mBluetoothDevice = spy(mBluetoothAdapter.getRemoteDevice(TEST_DEVICE_ADDRESS_1));