From 979cb2b1698f129a6624ff0bcac9119bad10846b Mon Sep 17 00:00:00 2001 From: topjohnwu Date: Thu, 2 Jun 2022 00:58:31 -0700 Subject: [PATCH] More efficient main thread detection --- core/src/main/java/com/topjohnwu/superuser/ShellUtils.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/main/java/com/topjohnwu/superuser/ShellUtils.java b/core/src/main/java/com/topjohnwu/superuser/ShellUtils.java index 08bc8a45..4ce6cc24 100644 --- a/core/src/main/java/com/topjohnwu/superuser/ShellUtils.java +++ b/core/src/main/java/com/topjohnwu/superuser/ShellUtils.java @@ -100,7 +100,7 @@ public static boolean fastCmdResult(Shell shell, String... cmds) { * @return {@code true} if the current thread is the main thread. */ public static boolean onMainThread() { - return ((Looper.myLooper() != null) && (Looper.myLooper() == Looper.getMainLooper())); + return Looper.getMainLooper().getThread() == Thread.currentThread(); } /**