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

Commit 48c386e5 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Align main thread checking by calling ThreadUtils"

parents 08d03390 ce0e8b9a
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());
        }
    }
}