Connected devices page did not show correct summary when member device connect

Root Cause: CsipDeviceManager only refreshes UI when switching member device content.

Solution:
* CsipDeviceManager needs to call refresh() on main device when it's new
  member device added.
* UI widget Settings/BluetoothDevice also need to monitor it's member device status to refresh UI.

Bug: 344947362
Test: atest BluetoothDevicePreferenceTest
Flag: EXEMPT bugfix
Change-Id: I58f9e2fc209d4e87631784d0538b1647228f4c1a
This commit is contained in:
jasonwshsu
2024-07-19 19:16:11 +08:00
parent 93b093033a
commit 15c6533ef9
5 changed files with 204 additions and 74 deletions

View File

@@ -89,7 +89,7 @@ public class BluetoothDetailsProfilesController extends BluetoothDetailsControll
private LocalBluetoothManager mManager;
private LocalBluetoothProfileManager mProfileManager;
private CachedBluetoothDevice mCachedDevice;
private List<CachedBluetoothDevice> mAllOfCachedDevices;
private Set<CachedBluetoothDevice> mCachedDeviceGroup;
private Map<String, List<CachedBluetoothDevice>> mProfileDeviceMap =
new HashMap<String, List<CachedBluetoothDevice>>();
private boolean mIsLeContactSharingEnabled = false;
@@ -105,7 +105,7 @@ public class BluetoothDetailsProfilesController extends BluetoothDetailsControll
mManager = manager;
mProfileManager = mManager.getProfileManager();
mCachedDevice = device;
mAllOfCachedDevices = Utils.getAllOfCachedBluetoothDevices(mManager, mCachedDevice);
mCachedDeviceGroup = Utils.findAllCachedBluetoothDevicesByGroupId(mManager, mCachedDevice);
}
@Override
@@ -310,10 +310,10 @@ public class BluetoothDetailsProfilesController extends BluetoothDetailsControll
private List<LocalBluetoothProfile> getProfiles() {
List<LocalBluetoothProfile> result = new ArrayList<>();
mProfileDeviceMap.clear();
if (mAllOfCachedDevices == null || mAllOfCachedDevices.isEmpty()) {
if (mCachedDeviceGroup == null || mCachedDeviceGroup.isEmpty()) {
return result;
}
for (CachedBluetoothDevice cachedItem : mAllOfCachedDevices) {
for (CachedBluetoothDevice cachedItem : mCachedDeviceGroup) {
List<LocalBluetoothProfile> tmpResult = cachedItem.getUiAccessibleProfiles();
for (LocalBluetoothProfile profile : tmpResult) {
if (mProfileDeviceMap.containsKey(profile.toString())) {
@@ -514,7 +514,7 @@ public class BluetoothDetailsProfilesController extends BluetoothDetailsControll
@Override
public void onPause() {
for (CachedBluetoothDevice item : mAllOfCachedDevices) {
for (CachedBluetoothDevice item : mCachedDeviceGroup) {
item.unregisterCallback(this);
}
mProfileManager.removeServiceListener(this);
@@ -523,7 +523,7 @@ public class BluetoothDetailsProfilesController extends BluetoothDetailsControll
@Override
public void onResume() {
updateLeAudioConfig();
for (CachedBluetoothDevice item : mAllOfCachedDevices) {
for (CachedBluetoothDevice item : mCachedDeviceGroup) {
item.registerCallback(this);
}
mProfileManager.addServiceListener(this);
@@ -545,11 +545,11 @@ public class BluetoothDetailsProfilesController extends BluetoothDetailsControll
@Override
public void onDeviceAttributesChanged() {
for (CachedBluetoothDevice item : mAllOfCachedDevices) {
for (CachedBluetoothDevice item : mCachedDeviceGroup) {
item.unregisterCallback(this);
}
mAllOfCachedDevices = Utils.getAllOfCachedBluetoothDevices(mManager, mCachedDevice);
for (CachedBluetoothDevice item : mAllOfCachedDevices) {
mCachedDeviceGroup = Utils.findAllCachedBluetoothDevicesByGroupId(mManager, mCachedDevice);
for (CachedBluetoothDevice item : mCachedDeviceGroup) {
item.registerCallback(this);
}