diff --git a/src/core/platform-helpers/android-platform-helpers.cpp b/src/core/platform-helpers/android-platform-helpers.cpp index 66d203a91dcc7898188673a675b7d3c85b38d3f9..346c1f8802b22ccd652da4ec1b0f5a326f6d091c 100644 --- a/src/core/platform-helpers/android-platform-helpers.cpp +++ b/src/core/platform-helpers/android-platform-helpers.cpp @@ -428,14 +428,22 @@ extern "C" JNIEXPORT void JNICALL Java_org_linphone_core_tools_AndroidPlatformHe extern "C" JNIEXPORT void JNICALL Java_org_linphone_core_tools_AndroidPlatformHelper_setNetworkReachable(JNIEnv* env, jobject thiz, jlong ptr, jboolean reachable) { AndroidPlatformHelpers *androidPlatformHelper = static_cast<AndroidPlatformHelpers *>((void *)ptr); - androidPlatformHelper->setNetworkReachable(reachable); + belle_sip_main_loop_t *loop = belle_sip_stack_get_main_loop(static_cast<belle_sip_stack_t*>(androidPlatformHelper->getCore()->sal->getStackImpl())); + std::function<void(void)> fun = [androidPlatformHelper, reachable]() { + androidPlatformHelper->setNetworkReachable(reachable); + }; + belle_sip_main_loop_cpp_do_later(loop, fun); } extern "C" JNIEXPORT void JNICALL Java_org_linphone_core_tools_AndroidPlatformHelper_setHttpProxy(JNIEnv* env, jobject thiz, jlong ptr, jstring host, jint port) { AndroidPlatformHelpers *androidPlatformHelper = static_cast<AndroidPlatformHelpers *>((void *)ptr); - const char *hostC = GetStringUTFChars(env, host); - androidPlatformHelper->setHttpProxy(hostC, port); - ReleaseStringUTFChars(env, host, hostC); + belle_sip_main_loop_t *loop = belle_sip_stack_get_main_loop(static_cast<belle_sip_stack_t*>(androidPlatformHelper->getCore()->sal->getStackImpl())); + std::function<void(void)> fun = [androidPlatformHelper, env, host, port]() { + const char *hostC = GetStringUTFChars(env, host); + androidPlatformHelper->setHttpProxy(hostC, port); + ReleaseStringUTFChars(env, host, hostC); + }; + belle_sip_main_loop_cpp_do_later(loop, fun); } LINPHONE_END_NAMESPACE