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

Commit 170a632a authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Align main thread checking by calling ThreadUtils" am: 48c386e5

parents 27217b87 48c386e5
Loading
Loading
Loading
Loading
+2 −8
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ import androidx.lifecycle.Lifecycle;
import androidx.lifecycle.OnLifecycleEvent;

import com.android.internal.annotations.VisibleForTesting;
import com.android.settingslib.utils.ThreadUtils;

import java.util.HashSet;

@@ -74,7 +75,7 @@ public final class EthernetTetherPreferenceController extends TetherBasePreferen

    @Override
    public boolean shouldEnable() {
        ensureRunningOnMainLoopThread();
        ThreadUtils.ensureMainThread();
        String[] available = mTm.getTetherableIfaces();
        for (String s : available) {
            if (mAvailableInterfaces.contains(s)) {
@@ -94,11 +95,4 @@ public final class EthernetTetherPreferenceController extends TetherBasePreferen
        return TetheringManager.TETHERING_ETHERNET;
    }

    private void ensureRunningOnMainLoopThread() {
        if (Looper.getMainLooper().getThread() != Thread.currentThread()) {
            throw new IllegalStateException(
                    "Not running on main loop thread: "
                            + Thread.currentThread().getName());
        }
    }
}