Could we change implementation of method HandlerContext.isDispatchNeeded() to be more flexible:
public class HandlerContext(
private val handler: Handler,
private val name: String? = null,
val alwaysDispatch: Boolean = true
) : CoroutineDispatcher(), Delay {
override fun isDispatchNeeded(context: CoroutineContext): Boolean {
return alwaysDispatch || Looper.myLooper() == handler.looper
}
}