From 2f97587d53020be683a98a4b6404f76f9a8e24a5 Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Thu, 26 Oct 2017 18:04:43 +0200 Subject: [PATCH] Fixed issue with android platform helper and DNS servers + added logs into android platform helper --- coreapi/linphonecore.c | 13 +++++++++---- .../platform-helpers/android-platform-helpers.cpp | 9 ++++++++- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index 2221eef8b..92b84d072 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -2176,7 +2176,7 @@ static void _linphone_core_init_account_creator_service(LinphoneCore *lc) { linphone_core_set_account_creator_service(lc, service); } -static void linphone_core_init(LinphoneCore * lc, LinphoneCoreCbs *cbs, LpConfig *config, void * userdata){ +static void linphone_core_init(LinphoneCore * lc, LinphoneCoreCbs *cbs, LpConfig *config, void * userdata, void *system_context){ const char *remote_provisioning_uri = NULL; LinphoneFactory *lfactory = linphone_factory_get(); LinphoneCoreCbs *internal_cbs = _linphone_core_cbs_new(); @@ -2192,7 +2192,13 @@ static void linphone_core_init(LinphoneCore * lc, LinphoneCoreCbs *cbs, LpConfig lc->config=lp_config_ref(config); lc->data=userdata; lc->ringstream_autorelease=TRUE; - lc->platform_helper = new LinphonePrivate::StubbedPlatformHelpers(lc); + +#ifdef __ANDROID__ + if (system_context) + lc->platform_helper = LinphonePrivate::createAndroidPlatformHelpers(lc, system_context); +#endif + if (lc->platform_helper == NULL) + lc->platform_helper = new LinphonePrivate::StubbedPlatformHelpers(lc); linphone_task_list_init(&lc->hooks); @@ -2287,8 +2293,7 @@ static void _linphone_core_set_system_context(LinphoneCore *lc, void *system_con LinphoneCore *_linphone_core_new_with_config(LinphoneCoreCbs *cbs, struct _LpConfig *config, void *userdata, void *system_context) { LinphoneCore *core = belle_sip_object_new(LinphoneCore); - linphone_core_init(core, cbs, config, userdata); - _linphone_core_set_system_context(core, system_context); + linphone_core_init(core, cbs, config, userdata, system_context); return core; } diff --git a/src/core/platform-helpers/android-platform-helpers.cpp b/src/core/platform-helpers/android-platform-helpers.cpp index 4aee2bf64..e7eb9f346 100644 --- a/src/core/platform-helpers/android-platform-helpers.cpp +++ b/src/core/platform-helpers/android-platform-helpers.cpp @@ -116,10 +116,14 @@ AndroidPlatformHelpers::~AndroidPlatformHelpers () { env->DeleteGlobalRef(mJavaHelper); mJavaHelper = nullptr; } + lInfo() << "AndroidPlatformHelpers has been destroyed."; } void AndroidPlatformHelpers::setDnsServers () { - if (!mJavaHelper) return; + if (!mJavaHelper) { + lError() << "AndroidPlatformHelpers' mJavaHelper is null."; + return; + } JNIEnv *env = ms_get_jni_env(); if (env && mJavaHelper) { jobjectArray jservers = (jobjectArray)env->CallObjectMethod(mJavaHelper, mGetDnsServersId); @@ -136,10 +140,13 @@ void AndroidPlatformHelpers::setDnsServers () { jstring jserver = (jstring)env->GetObjectArrayElement(jservers, i); const char *str = env->GetStringUTFChars(jserver, nullptr); if (str) { + lInfo() << "AndroidPlatformHelpers found DNS server " << str; l = bctbx_list_append(l, ms_strdup(str)); env->ReleaseStringUTFChars(jserver, str); } } + } else { + lError() << "AndroidPlatformHelpers::setDnsServers() failed to get DNS servers list"; } linphone_core_set_dns_servers(mCore, l); bctbx_list_free_with_data(l, ms_free);