diff --git a/src/com/android/settings/bluetooth/BluetoothDevicePreference.java b/src/com/android/settings/bluetooth/BluetoothDevicePreference.java index d927121e931..f8950325904 100644 --- a/src/com/android/settings/bluetooth/BluetoothDevicePreference.java +++ b/src/com/android/settings/bluetooth/BluetoothDevicePreference.java @@ -44,6 +44,7 @@ import com.android.settings.widget.GearPreference; import com.android.settingslib.bluetooth.BluetoothUtils; import com.android.settingslib.bluetooth.CachedBluetoothDevice; import com.android.settingslib.core.instrumentation.MetricsFeatureProvider; +import com.android.settingslib.utils.ThreadUtils; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; @@ -175,6 +176,18 @@ public final class BluetoothDevicePreference extends GearPreference { } private void onPreferenceAttributesChanged() { + ThreadUtils.postOnBackgroundThread(() -> { + final Pair pair = + BluetoothUtils.getBtRainbowDrawableWithDescription(getContext(), mCachedDevice); + + ThreadUtils.postOnMainThread(() -> { + if (pair.first != null) { + setIcon(pair.first); + contentDescription = pair.second; + } + }); + }); + /* * The preference framework takes care of making sure the value has * changed before proceeding. It will also call notifyChanged() if @@ -184,13 +197,6 @@ public final class BluetoothDevicePreference extends GearPreference { // Null check is done at the framework setSummary(mCachedDevice.getConnectionSummary()); - final Pair pair = - BluetoothUtils.getBtRainbowDrawableWithDescription(getContext(), mCachedDevice); - if (pair.first != null) { - setIcon(pair.first); - contentDescription = pair.second; - } - // Used to gray out the item setEnabled(!mCachedDevice.isBusy());