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

Commit 09c3a245 authored by Yiyi Shen's avatar Yiyi Shen Committed by Android (Google) Code Review
Browse files

Merge "Quick fix: Move blocking code to background thread" into main

parents adf47156 c897cccf
Loading
Loading
Loading
Loading
+13 −7
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ import androidx.preference.PreferenceScreen;

import com.android.settingslib.R;
import com.android.settingslib.core.lifecycle.Lifecycle;
import com.android.settingslib.utils.ThreadUtils;

/**
 * Preference controller for bluetooth address
@@ -74,13 +75,18 @@ public abstract class AbstractBluetoothAddressPreferenceController
    protected void updateConnectivity() {
        BluetoothAdapter bluetooth = BluetoothAdapter.getDefaultAdapter();
        if (bluetooth != null && mBtAddress != null) {
            ThreadUtils.postOnBackgroundThread(() -> {
                String address = bluetooth.isEnabled() ? bluetooth.getAddress() : null;
                ThreadUtils.postOnMainThread(() -> {
                    if (!TextUtils.isEmpty(address)) {
                // Convert the address to lowercase for consistency with the wifi MAC address.
                        // Convert the address to lowercase for consistency with the wifi MAC
                        // address.
                        mBtAddress.setSummary(address.toLowerCase());
                    } else {
                        mBtAddress.setSummary(R.string.status_unavailable);
                    }
                });
            });
        }
    }
}