Fixing android test

This commit is contained in:
Erwan Croze 2018-04-15 17:31:26 +02:00
parent 451f75275c
commit 6638137dcb
2 changed files with 15 additions and 3 deletions

View file

@ -31,6 +31,7 @@ static FILE * log_file = NULL;
static JNIEnv *current_env = NULL;
static jobject current_obj = 0;
jobject system_context = 0; // Application context
static const char* LogDomain = "liblinphone_tester";
int main(int argc, char** argv);
@ -98,6 +99,17 @@ void bcunit_android_trace_handler(int level, const char *fmt, va_list args) {
(*env)->DeleteLocalRef(env,cls);
}
JNIEXPORT void JNICALL Java_org_linphone_tester_Tester_setApplicationContext(JNIEnv *env, jclass obj, jobject context) {
system_context = (jobject)(*env)->NewGlobalRef(env, context);
}
JNIEXPORT void JNICALL Java_org_linphone_tester_Tester_removeApplicationContext(JNIEnv *env, jclass obj) {
if (system_context) {
(*env)->DeleteGlobalRef(env, system_context);
system_context = 0;
}
}
JNIEXPORT jint JNICALL Java_org_linphone_tester_Tester_run(JNIEnv *env, jobject obj, jobjectArray stringArray) {
int i, ret;
int argc = (*env)->GetArrayLength(env, stringArray);

View file

@ -29,7 +29,7 @@
#define unlink _unlink
#endif
extern jobject system_context;
static int liblinphone_tester_keep_accounts_flag = 0;
static bool_t liblinphone_tester_keep_record_files = FALSE;
static bool_t liblinphone_tester_leak_detector_disabled = FALSE;
@ -143,9 +143,9 @@ LinphoneCore *configure_lc_from(LinphoneCoreCbs *cbs, const char *path, const ch
lp_config_set_string(config, "sound", "remote_ring", ringbackpath);
lp_config_set_string(config, "sound", "local_ring" , ringpath);
lp_config_set_string(config, "sip", "root_ca" , rootcapath);
lc = linphone_factory_create_core_with_config_3(linphone_factory_get(), config, NULL);
lc = linphone_factory_create_core_with_config_3(linphone_factory_get(), config, system_context);
} else {
lc = linphone_factory_create_core_3(linphone_factory_get(), NULL, (filepath && (filepath[0] != '\0')) ? filepath : NULL, NULL);
lc = linphone_factory_create_core_3(linphone_factory_get(), NULL, (filepath && (filepath[0] != '\0')) ? filepath : NULL, system_context);
linphone_core_set_ring(lc, ringpath);
linphone_core_set_ringback(lc, ringbackpath);
linphone_core_set_root_ca(lc,rootcapath);