Add loading screen for Device details fragment to avoid ANR

BUG: 343317785
Test: local tested
Flag: com.android.settings.flags.enable_bluetooth_device_details_polish
Change-Id: Iad57fc2fe4cb0a3f90e8d01310b9c7ad20d02233
This commit is contained in:
Haijie Hong
2024-11-28 23:25:00 +08:00
parent 9e3f075c3a
commit 67ac0faf3d
9 changed files with 186 additions and 197 deletions

View File

@@ -120,7 +120,12 @@ public class BluetoothDetailsProfilesControllerTest extends BluetoothDetailsCont
.thenAnswer(invocation -> ImmutableList.of(mConnectableProfiles));
setupDevice(mDeviceConfig);
initController(List.of());
mController = new BluetoothDetailsProfilesController(mContext, mFragment, mLocalManager,
mCachedDevice, mLifecycle);
mProfiles.setKey(mController.getPreferenceKey());
mController.mProfilesContainer = mProfiles;
mScreen.removeAll();
mScreen.addPreference(mProfiles);
BluetoothProperties.le_audio_allow_list(Lists.newArrayList(LE_DEVICE_MODEL));
}
@@ -550,7 +555,8 @@ public class BluetoothDetailsProfilesControllerTest extends BluetoothDetailsCont
@Test
public void prefKeyInBlockingList_hideToggle() {
initController(List.of("A2DP"));
mController.setInvisibleProfiles(List.of("A2DP"));
mController.setHasExtraSpace(true);
setupDevice(makeDefaultDeviceConfig());
addA2dpProfileToDevice(true, true, true);
@@ -565,7 +571,6 @@ public class BluetoothDetailsProfilesControllerTest extends BluetoothDetailsCont
@Test
public void prefKeyNotInBlockingList_showToggle() {
initController(List.of());
setupDevice(makeDefaultDeviceConfig());
addA2dpProfileToDevice(true, true, true);
@@ -653,13 +658,4 @@ public class BluetoothDetailsProfilesControllerTest extends BluetoothDetailsCont
assertThat(switches.getFirst().getTitle()).isEqualTo(
mContext.getString(mLeAudioProfile.getNameResource(mDevice)));
}
private void initController(List<String> invisibleProfiles) {
mController = new BluetoothDetailsProfilesController(mContext, mFragment, mLocalManager,
mCachedDevice, mLifecycle, invisibleProfiles, true);
mProfiles.setKey(mController.getPreferenceKey());
mController.mProfilesContainer = mProfiles;
mScreen.removeAll();
mScreen.addPreference(mProfiles);
}
}