diff --git a/app/src/main/java/com/mogo/launcher/lancet/ANRFix.kt b/app/src/main/java/com/mogo/launcher/lancet/ANRFix.kt index 24e9815327..746a875ee0 100644 --- a/app/src/main/java/com/mogo/launcher/lancet/ANRFix.kt +++ b/app/src/main/java/com/mogo/launcher/lancet/ANRFix.kt @@ -24,6 +24,9 @@ class ANRFix { @TargetMethod(methodName = "post") @ReplaceInvoke fun handlerPostProxy(handler: Handler, action: Runnable): Boolean { + if (Looper.getMainLooper() != handler.looper) { + return handler.post(action) + } val what = ObjectHashCodeUtils.getHashCodeIfNeed(action) handler.removeMessages(what) val msg = Message.obtain(handler, action) @@ -36,6 +39,9 @@ class ANRFix { @TargetMethod(methodName = "postDelayed") @ReplaceInvoke fun handlerPostDelayProxy(handler: Handler, action: Runnable, delayMillis: Long): Boolean { + if (Looper.getMainLooper() != handler.looper) { + return handler.postDelayed(action, delayMillis) + } val what = ObjectHashCodeUtils.getHashCodeIfNeed(action) handler.removeMessages(what) val msg = Message.obtain(handler, action)