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

@@ -27,7 +27,6 @@ import android.sysprop.BluetoothProperties;
import android.text.TextUtils;
import android.util.Log;
import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;
import androidx.preference.Preference;
import androidx.preference.PreferenceCategory;
@@ -109,28 +108,34 @@ public class BluetoothDetailsProfilesController extends BluetoothDetailsControll
PreferenceFragmentCompat fragment,
LocalBluetoothManager manager,
CachedBluetoothDevice device,
Lifecycle lifecycle,
@Nullable List<String> invisibleProfiles,
boolean hasExtraSpace) {
Lifecycle lifecycle) {
super(context, fragment, device, lifecycle);
mManager = manager;
mProfileManager = mManager.getProfileManager();
mCachedDevice = device;
mCachedDeviceGroup = Utils.findAllCachedBluetoothDevicesByGroupId(mManager, mCachedDevice);
}
/** Sets the profiles to be hidden. */
public void setInvisibleProfiles(List<String> invisibleProfiles) {
if (invisibleProfiles != null) {
mInvisibleProfiles = Set.copyOf(invisibleProfiles);
}
mHasExtraSpace = hasExtraSpace;
}
@Override
protected void init(PreferenceScreen screen) {
mProfilesContainer = (PreferenceCategory)screen.findPreference(getPreferenceKey());
if (mHasExtraSpace) {
/** Sets whether it should show an extra padding on top of the preference. */
public void setHasExtraSpace(boolean hasExtraSpace) {
if (hasExtraSpace) {
mProfilesContainer.setLayoutResource(R.layout.preference_bluetooth_profile_category);
} else {
mProfilesContainer.setLayoutResource(R.layout.preference_category_bluetooth_no_padding);
}
}
@Override
protected void init(PreferenceScreen screen) {
mProfilesContainer = (PreferenceCategory) screen.findPreference(getPreferenceKey());
mProfilesContainer.setLayoutResource(R.layout.preference_bluetooth_profile_category);
// Call refresh here even though it will get called later in onResume, to avoid the
// list of switches appearing to "pop" into the page.
refresh();