Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d30f5d1a authored by Tim Peng's avatar Tim Peng Committed by Android (Google) Code Review
Browse files

Merge "AID_SYSTEM_USER - Main thread blocked at getConnectionSummary()"

parents 0f6f2222 830cb485
Loading
Loading
Loading
Loading
+12 −4
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ import android.graphics.drawable.Drawable;
import android.os.UserManager;
import android.text.Html;
import android.text.TextUtils;
import android.util.Log;
import android.util.Pair;
import android.util.TypedValue;
import android.view.View;
@@ -41,13 +42,13 @@ import androidx.preference.PreferenceViewHolder;
import com.android.settings.R;
import com.android.settings.overlay.FeatureFactory;
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;
import java.util.concurrent.RejectedExecutionException;

/**
 * BluetoothDevicePreference is the preference type used to display each remote
@@ -175,6 +176,7 @@ public final class BluetoothDevicePreference extends GearPreference {
        mHideSecondTarget = hideSecondTarget;
    }

    @SuppressWarnings("FutureReturnValueIgnored")
    void onPreferenceAttributesChanged() {
        Pair<Drawable, String> pair = mCachedDevice.getDrawableWithDescription();
        setIcon(pair.first);
@@ -186,9 +188,15 @@ public final class BluetoothDevicePreference extends GearPreference {
         * any preference info has changed from the previous value.
         */
        setTitle(mCachedDevice.getName());
        try {
            ThreadUtils.postOnBackgroundThread(() -> {
                String summary = mCachedDevice.getConnectionSummary();
                // Null check is done at the framework
        setSummary(mCachedDevice.getConnectionSummary());

                ThreadUtils.postOnMainThread(() -> setSummary(summary));
            });
        } catch (RejectedExecutionException e) {
            Log.w(TAG, "Handler thread unavailable, skipping getConnectionSummary!");
        }
        // Used to gray out the item
        setEnabled(!mCachedDevice.isBusy());