diff --git a/src/com/android/settings/bluetooth/BluetoothDetailsProfilesController.java b/src/com/android/settings/bluetooth/BluetoothDetailsProfilesController.java index 3472e3940ce..fb2c95966e2 100644 --- a/src/com/android/settings/bluetooth/BluetoothDetailsProfilesController.java +++ b/src/com/android/settings/bluetooth/BluetoothDetailsProfilesController.java @@ -89,7 +89,7 @@ public class BluetoothDetailsProfilesController extends BluetoothDetailsControll mManager = manager; mProfileManager = mManager.getProfileManager(); mCachedDevice = device; - mAllOfCachedDevices = Utils.getAllOfCachedBluetoothDevices(mContext, mCachedDevice); + mAllOfCachedDevices = Utils.getAllOfCachedBluetoothDevices(mManager, mCachedDevice); lifecycle.addObserver(this); } @@ -460,7 +460,7 @@ public class BluetoothDetailsProfilesController extends BluetoothDetailsControll for (CachedBluetoothDevice item : mAllOfCachedDevices) { item.unregisterCallback(this); } - mAllOfCachedDevices = Utils.getAllOfCachedBluetoothDevices(mContext, mCachedDevice); + mAllOfCachedDevices = Utils.getAllOfCachedBluetoothDevices(mManager, mCachedDevice); for (CachedBluetoothDevice item : mAllOfCachedDevices) { item.registerCallback(this); } diff --git a/src/com/android/settings/bluetooth/LeAudioBluetoothDetailsHeaderController.java b/src/com/android/settings/bluetooth/LeAudioBluetoothDetailsHeaderController.java index e30bbfb398a..f72494f271c 100644 --- a/src/com/android/settings/bluetooth/LeAudioBluetoothDetailsHeaderController.java +++ b/src/com/android/settings/bluetooth/LeAudioBluetoothDetailsHeaderController.java @@ -88,6 +88,7 @@ public class LeAudioBluetoothDetailsHeaderController extends BasePreferenceContr @VisibleForTesting LayoutPreference mLayoutPreference; + LocalBluetoothManager mManager; private CachedBluetoothDevice mCachedDevice; private List mAllOfCachedDevices; @VisibleForTesting @@ -152,8 +153,9 @@ public class LeAudioBluetoothDetailsHeaderController extends BasePreferenceContr public void init(CachedBluetoothDevice cachedBluetoothDevice, LocalBluetoothManager bluetoothManager) { mCachedDevice = cachedBluetoothDevice; + mManager = bluetoothManager; mProfileManager = bluetoothManager.getProfileManager(); - mAllOfCachedDevices = Utils.getAllOfCachedBluetoothDevices(mContext, mCachedDevice); + mAllOfCachedDevices = Utils.getAllOfCachedBluetoothDevices(mManager, mCachedDevice); } @VisibleForTesting @@ -300,7 +302,7 @@ public class LeAudioBluetoothDetailsHeaderController extends BasePreferenceContr for (CachedBluetoothDevice item : mAllOfCachedDevices) { item.unregisterCallback(this); } - mAllOfCachedDevices = Utils.getAllOfCachedBluetoothDevices(mContext, mCachedDevice); + mAllOfCachedDevices = Utils.getAllOfCachedBluetoothDevices(mManager, mCachedDevice); for (CachedBluetoothDevice item : mAllOfCachedDevices) { item.registerCallback(this); } diff --git a/src/com/android/settings/bluetooth/Utils.java b/src/com/android/settings/bluetooth/Utils.java index 79a2de0b38a..f1d6b20b519 100644 --- a/src/com/android/settings/bluetooth/Utils.java +++ b/src/com/android/settings/bluetooth/Utils.java @@ -235,7 +235,8 @@ public final class Utils { * @param cachedBluetoothDevice The main cachedBluetoothDevice. * @return all cachedBluetoothDevices with the same groupId. */ - public static List getAllOfCachedBluetoothDevices(Context context, + public static List getAllOfCachedBluetoothDevices( + LocalBluetoothManager localBtMgr, CachedBluetoothDevice cachedBluetoothDevice) { List cachedBluetoothDevices = new ArrayList<>(); if (cachedBluetoothDevice == null) { @@ -248,7 +249,6 @@ public final class Utils { return cachedBluetoothDevices; } - final LocalBluetoothManager localBtMgr = Utils.getLocalBtManager(context); if (localBtMgr == null) { Log.e(TAG, "getAllOfCachedBluetoothDevices: no LocalBluetoothManager"); return cachedBluetoothDevices;