From 46d894caf617b1f134920d0220082b24876a0d50 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Wed, 8 Mar 2017 13:12:02 +0100 Subject: [PATCH] Use correct macro to detect Android build. --- CMakeLists.txt | 3 --- coreapi/TunnelManager.cc | 8 ++++---- coreapi/call_log.c | 2 +- coreapi/friend.c | 2 +- coreapi/linphonecall.c | 4 ++-- coreapi/linphonecore.c | 12 ++++++------ coreapi/linphonecore_jni.cc | 20 +++++++++----------- coreapi/lpconfig.c | 2 +- coreapi/message_storage.c | 5 +++-- coreapi/private.h | 6 +++--- coreapi/sqlite3_bctbx_vfs.c | 4 ++-- tester/call_single_tester.c | 12 ++++++------ tester/liblinphone_tester.c | 8 ++++---- tester/log_collection_tester.c | 2 +- tester/remote_provisioning_tester.c | 2 +- 15 files changed, 44 insertions(+), 48 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 85d54419d..33c4745c5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -241,9 +241,6 @@ endif() if(ENABLE_DEBUG_LOGS) add_definitions("-DDEBUG") endif() -if(ANDROID) - add_definitions("-DANDROID") -endif() set(STRICT_OPTIONS_CPP ) set(STRICT_OPTIONS_C ) diff --git a/coreapi/TunnelManager.cc b/coreapi/TunnelManager.cc index ede8ca7e7..dd55a45d4 100644 --- a/coreapi/TunnelManager.cc +++ b/coreapi/TunnelManager.cc @@ -18,7 +18,7 @@ #include "linphone/core_utils.h" #include "private.h" -#ifdef ANDROID +#ifdef __ANDROID__ #include #endif @@ -429,7 +429,7 @@ void TunnelManager::sOnIterate(TunnelManager *zis){ zis->onIterate(); } -#ifdef ANDROID +#ifdef __ANDROID__ extern void linphone_android_log_handler(int prio, char *str); static void linphone_android_tunnel_log_handler(int lev, const char *fmt, va_list args) { char str[4096]; @@ -447,7 +447,7 @@ static void linphone_android_tunnel_log_handler(int lev, const char *fmt, va_lis } linphone_android_log_handler(prio, str); } -#endif /*ANDROID*/ +#endif /* __ANDROID__ */ void TunnelManager::enableLogs(bool value) { enableLogs(value,NULL); @@ -455,7 +455,7 @@ void TunnelManager::enableLogs(bool value) { void TunnelManager::enableLogs(bool isEnabled,LogHandler logHandler) { if (logHandler != NULL) SetLogHandler(logHandler); -#ifdef ANDROID +#ifdef __ANDROID__ else SetLogHandler(linphone_android_tunnel_log_handler); #else else SetLogHandler(tunnel_default_log_handler); diff --git a/coreapi/call_log.c b/coreapi/call_log.c index 86b85c712..71b232679 100644 --- a/coreapi/call_log.c +++ b/coreapi/call_log.c @@ -24,7 +24,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #ifdef SQLITE_STORAGE_ENABLED #ifndef _WIN32 -#if !defined(ANDROID) && !defined(__QNXNTO__) +#if !defined(__ANDROID__) && !defined(__QNXNTO__) # include # include # include diff --git a/coreapi/friend.c b/coreapi/friend.c index 40867f364..a80f97872 100644 --- a/coreapi/friend.c +++ b/coreapi/friend.c @@ -28,7 +28,7 @@ #ifdef SQLITE_STORAGE_ENABLED #ifndef _WIN32 -#if !defined(ANDROID) && !defined(__QNXNTO__) +#if !defined(__ANDROID__) && !defined(__QNXNTO__) # include # include # include diff --git a/coreapi/linphonecall.c b/coreapi/linphonecall.c index 47e35e6b6..66d1b8196 100644 --- a/coreapi/linphonecall.c +++ b/coreapi/linphonecall.c @@ -1719,7 +1719,7 @@ void linphone_call_set_state(LinphoneCall *call, LinphoneCallState cstate, const switch (cstate) { case LinphoneCallOutgoingInit: case LinphoneCallIncomingReceived: -#ifdef ANDROID +#ifdef __ANDROID__ ms_message("Call [%p] acquires both wifi and multicast lock",call); linphone_core_wifi_lock_acquire(call->core); linphone_core_multicast_lock_acquire(call->core); /*does no affect battery more than regular rtp traffic*/ @@ -1744,7 +1744,7 @@ void linphone_call_set_state(LinphoneCall *call, LinphoneCallState cstate, const call->log->connected_date_time = ms_time(NULL); break; case LinphoneCallReleased: -#ifdef ANDROID +#ifdef __ANDROID__ ms_message("Call [%p] releases wifi/multicast lock",call); linphone_core_wifi_lock_release(call->core); linphone_core_multicast_lock_release(call->core); diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index 9b7ae3ae6..2df55e0a0 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -1576,7 +1576,7 @@ static void video_config_read(LinphoneCore *lc){ linphone_core_set_preferred_framerate(lc,lp_config_get_float(lc->config,"video","framerate",0)); -#if defined(ANDROID) || defined(__ios) +#if defined(__ANDROID__) || defined(__ios) automatic_video=0; #endif capture=lp_config_get_int(lc->config,"video","capture",1); @@ -4846,18 +4846,18 @@ int linphone_core_get_camera_sensor_rotation(LinphoneCore *lc) { } static MSVideoSizeDef supported_resolutions[]={ -#if !ANDROID && !TARGET_OS_IPHONE +#if !defined(__ANDROID__) && !TARGET_OS_IPHONE { { MS_VIDEO_SIZE_1080P_W, MS_VIDEO_SIZE_1080P_H } , "1080p" }, #endif -#if !ANDROID && !TARGET_OS_MAC /*limit to most common sizes because mac video API cannot list supported resolutions*/ +#if !defined(__ANDROID__) && !TARGET_OS_MAC /*limit to most common sizes because mac video API cannot list supported resolutions*/ { { MS_VIDEO_SIZE_UXGA_W, MS_VIDEO_SIZE_UXGA_H } , "uxga" }, { { MS_VIDEO_SIZE_SXGA_MINUS_W, MS_VIDEO_SIZE_SXGA_MINUS_H } , "sxga-" }, #endif { { MS_VIDEO_SIZE_720P_W, MS_VIDEO_SIZE_720P_H } , "720p" }, -#if !ANDROID && !TARGET_OS_MAC +#if !defined(__ANDROID__) && !TARGET_OS_MAC { { MS_VIDEO_SIZE_XGA_W, MS_VIDEO_SIZE_XGA_H } , "xga" }, #endif -#if !ANDROID && !TARGET_OS_IPHONE +#if !defined(__ANDROID__) && !TARGET_OS_IPHONE { { MS_VIDEO_SIZE_SVGA_W, MS_VIDEO_SIZE_SVGA_H } , "svga" }, { { MS_VIDEO_SIZE_4CIF_W, MS_VIDEO_SIZE_4CIF_H } , "4cif" }, #endif @@ -6330,7 +6330,7 @@ const char * linphone_core_get_video_preset(const LinphoneCore *lc) { return lp_config_get_string(lc->config, "video", "preset", NULL); } -#ifdef ANDROID +#ifdef __ANDROID__ static int linphone_core_call_void_method(jobject obj, jmethodID id) { JNIEnv *env=ms_get_jni_env(); if (env && obj) { diff --git a/coreapi/linphonecore_jni.cc b/coreapi/linphonecore_jni.cc index 2e458282f..d8214e4d6 100644 --- a/coreapi/linphonecore_jni.cc +++ b/coreapi/linphonecore_jni.cc @@ -41,11 +41,10 @@ extern "C" { #include "linphone/lpconfig.h" -#ifdef ANDROID +#ifdef __ANDROID__ #include - #include -#endif /*ANDROID*/ +#endif /* __ANDROID__ */ #define RETURN_USER_DATA_OBJECT(javaclass, funcprefix, cobj) \ { \ @@ -75,7 +74,7 @@ static jobject create_java_linphone_buffer(JNIEnv *env, const LinphoneBuffer *bu static LinphoneBuffer* create_c_linphone_buffer_from_java_linphone_buffer(JNIEnv *env, jobject jbuffer); static jobject getTunnelConfig(JNIEnv *env, LinphoneTunnelConfig *cfg); -#ifdef ANDROID +#ifdef __ANDROID__ void linphone_android_log_handler(int prio, char *str) { char *current; char *next; @@ -159,15 +158,14 @@ extern "C" void setMediastreamerAndroidContext(JNIEnv *env, void *context) { jmethodID set_context = env->GetStaticMethodID(ms_class, "setContext", "(Ljava/lang/Object;)V"); env->CallStaticVoidMethod(ms_class, set_context, (jobject)context); } -#endif /*ANDROID*/ +#endif /* __ANDROID__ */ JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *ajvm, void *reserved) { -#ifdef ANDROID +#ifdef __ANDROID__ ms_set_jvm(ajvm); - -#endif /*ANDROID*/ +#endif /* __ANDROID__ */ jvm=ajvm; return JNI_VERSION_1_2; } @@ -5750,7 +5748,7 @@ extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setAudioDscp(JNIEnv* env } extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setAndroidPowerManager(JNIEnv *env, jclass cls, jobject pm) { -#ifdef ANDROID +#ifdef __ANDROID__ if(pm != NULL) belle_sip_wake_lock_init(env, pm); else belle_sip_wake_lock_uninit(env); #endif @@ -5758,7 +5756,7 @@ extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setAndroidPowerManager(J /*released in Java_org_linphone_core_LinphoneCoreImpl_delete*/ extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setAndroidWifiLock(JNIEnv *env, jobject thiz, jlong ptr, jobject wifi_lock) { -#ifdef ANDROID +#ifdef __ANDROID__ LinphoneCore *lc=(LinphoneCore*)ptr; if (lc->wifi_lock) { env->DeleteGlobalRef(lc->wifi_lock); @@ -5778,7 +5776,7 @@ extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setAndroidWifiLock(JNIEn } /*released in Java_org_linphone_core_LinphoneCoreImpl_delete*/ extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setAndroidMulticastLock(JNIEnv *env, jobject thiz, jlong ptr, jobject multicast_lock) { -#ifdef ANDROID +#ifdef __ANDROID__ LinphoneCore *lc=(LinphoneCore*)ptr; if (lc->multicast_lock) { env->DeleteGlobalRef(lc->multicast_lock); diff --git a/coreapi/lpconfig.c b/coreapi/lpconfig.c index 91788c2b5..c16b827ac 100644 --- a/coreapi/lpconfig.c +++ b/coreapi/lpconfig.c @@ -97,7 +97,7 @@ BELLE_SIP_DECLARE_VPTR_NO_EXPORT(LinphoneConfig); char* lp_realpath(const char* file, char* name) { -#if defined(_WIN32) || defined(__QNX__) || defined(ANDROID) +#if defined(_WIN32) || defined(__QNX__) || defined(__ANDROID__) return ms_strdup(file); #else char * output = realpath(file, name); diff --git a/coreapi/message_storage.c b/coreapi/message_storage.c index dd62ec625..2c2b11b2e 100644 --- a/coreapi/message_storage.c +++ b/coreapi/message_storage.c @@ -28,7 +28,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #endif #ifndef _WIN32 -#if !defined(__QNXNTO__) +#if !defined(__QNXNTO__) && !(defined(__ANDROID__) && defined(__LP64__)) +#include #include #include #include @@ -50,7 +51,7 @@ static char *utf8_convert(const char *filename){ wchar_t db_file_utf16[MAX_PATH_SIZE]={0}; MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, filename, -1, db_file_utf16, MAX_PATH_SIZE); WideCharToMultiByte(CP_UTF8, 0, db_file_utf16, -1, db_file_utf8, sizeof(db_file_utf8), NULL, NULL); -#elif defined(__QNXNTO__) || (defined(ANDROID) && defined(__LP64__)) +#elif defined(__QNXNTO__) || (defined(__ANDROID__) && defined(__LP64__)) strncpy(db_file_utf8, filename, MAX_PATH_SIZE - 1); #else char db_file_locale[MAX_PATH_SIZE] = {'\0'}; diff --git a/coreapi/private.h b/coreapi/private.h index 5a5b4734e..5a90689eb 100644 --- a/coreapi/private.h +++ b/coreapi/private.h @@ -88,7 +88,7 @@ #define ngettext(singular, plural, number) (((number)==1)?(singular):(plural)) #endif #endif -#ifdef ANDROID +#ifdef __ANDROID__ #include #endif @@ -1074,7 +1074,7 @@ struct _LinphoneCore LinphoneContent *log_collection_upload_information; LinphoneCoreCbs *current_cbs; // the latest LinphoneCoreCbs object to call a callback, see linphone_core_get_current_cbs() LinphoneRingtonePlayer *ringtoneplayer; -#ifdef ANDROID +#ifdef __ANDROID__ jobject wifi_lock; jclass wifi_lock_class; jmethodID wifi_lock_acquire_id; @@ -1692,7 +1692,7 @@ void linphone_content_set_key(LinphoneContent *content, const char *key, const s */ void ** linphone_content_get_cryptoContext_address(LinphoneContent *content); -#ifdef ANDROID +#ifdef __ANDROID__ void linphone_core_wifi_lock_acquire(LinphoneCore *lc); void linphone_core_wifi_lock_release(LinphoneCore *lc); void linphone_core_multicast_lock_acquire(LinphoneCore *lc); diff --git a/coreapi/sqlite3_bctbx_vfs.c b/coreapi/sqlite3_bctbx_vfs.c index 9d48b1c0d..9b8b1b452 100755 --- a/coreapi/sqlite3_bctbx_vfs.c +++ b/coreapi/sqlite3_bctbx_vfs.c @@ -29,7 +29,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #ifndef _WIN32 -#if !defined(__QNXNTO__) +#if !defined(__QNXNTO__) && !(defined(__ANDROID__) && defined(__LP64__)) # include # include # include @@ -281,7 +281,7 @@ static char* ConvertFromUtf8Filename(const char* fName){ } bctbx_free(wideFilename); return convertedFilename; -#elif defined(__QNXNTO__) || (defined(ANDROID) && defined(__LP64__)) +#elif defined(__QNXNTO__) || (defined(__ANDROID__) && defined(__LP64__)) return bctbx_strdup(fName); #else #define MAX_PATH_SIZE 1024 diff --git a/tester/call_single_tester.c b/tester/call_single_tester.c index 964b5a078..54b167402 100644 --- a/tester/call_single_tester.c +++ b/tester/call_single_tester.c @@ -36,7 +36,7 @@ static void srtp_call(void); // prototype definition for call_recording() -#ifdef ANDROID +#ifdef __ANDROID__ #ifdef HAVE_OPENH264 extern void libmsopenh264_init(MSFactory *factory); #endif @@ -829,7 +829,7 @@ static void call_with_specified_codec_bitrate(void) { #ifdef __arm__ if (ms_factory_get_cpu_count(marie->lc->factory) <2) { /*2 opus codec channel + resampler is too much for a single core*/ -#ifndef ANDROID +#ifndef __ANDROID__ codec = "speex"; rate = 8000; min_bw=20; @@ -2151,7 +2151,7 @@ static void call_with_mkv_file_player(void) { char *hellowav; char *recordpath; bool_t call_ok; -#if !defined(__arm__) && !defined(__arm64__) && !TARGET_IPHONE_SIMULATOR && !defined(ANDROID) +#if !defined(__arm__) && !defined(__arm64__) && !TARGET_IPHONE_SIMULATOR && !defined(__ANDROID__) double similar=0.0; const double threshold = 0.9; #define DO_AUDIO_CMP @@ -3039,7 +3039,7 @@ void record_call(const char *filename, bool_t enableVideo, const char *video_cod disable_all_video_codecs_except_one(marie->lc,"h264"); } -#if defined(HAVE_OPENH264) && defined(ANDROID) +#if defined(HAVE_OPENH264) && defined(__ANDROID__) libmsopenh264_init(linphone_core_get_ms_factory(marie->lc)); linphone_core_reload_ms_plugins(marie->lc, NULL); libmsopenh264_init(linphone_core_get_ms_factory(pauline->lc)); @@ -3558,7 +3558,7 @@ static void unsucessfull_call_with_transport_change_after_released(void) { call_with_transport_change_base(FALSE); } -#if !defined(__arm__) && !defined(__arm64__) && !TARGET_IPHONE_SIMULATOR && !defined(ANDROID) +#if !defined(__arm__) && !defined(__arm64__) && !TARGET_IPHONE_SIMULATOR && !defined(__ANDROID__) static void completion_cb(void *user_data, int percentage){ fprintf(stdout,"%i %% completed\r",percentage); fflush(stdout); @@ -3610,7 +3610,7 @@ static void simple_stereo_call(const char *codec_name, int clock_rate, int bitra if (clock_rate!=48000) { ms_warning("Similarity checking not implemented for files not having the same sampling rate"); }else{ -#if !defined(__arm__) && !defined(__arm64__) && !TARGET_IPHONE_SIMULATOR && !defined(ANDROID) +#if !defined(__arm__) && !defined(__arm64__) && !TARGET_IPHONE_SIMULATOR && !defined(__ANDROID__) double similar; double min_threshold = .75f; /*should be above 0.8 in best conditions*/ double max_threshold = 1.f; diff --git a/tester/liblinphone_tester.c b/tester/liblinphone_tester.c index b77c2ff43..3626150a4 100644 --- a/tester/liblinphone_tester.c +++ b/tester/liblinphone_tester.c @@ -42,7 +42,7 @@ static FILE * log_file = NULL; -#ifdef ANDROID +#ifdef __ANDROID__ #include #include @@ -148,7 +148,7 @@ JNIEXPORT void JNICALL Java_org_linphone_tester_Tester_keepAccounts(JNIEnv *env, JNIEXPORT void JNICALL Java_org_linphone_tester_Tester_clearAccounts(JNIEnv *env, jclass c) { liblinphone_tester_clear_accounts(); } -#endif /* ANDROID */ +#endif /* __ANDROID__ */ static void log_handler(int lev, const char *fmt, va_list args) { #ifdef _WIN32 @@ -157,7 +157,7 @@ static void log_handler(int lev, const char *fmt, va_list args) { #else va_list cap; va_copy(cap,args); -#ifdef ANDROID +#ifdef __ANDROID__ /* IMPORTANT: needed by liblinphone tester to retrieve suite list...*/ bcunit_android_trace_handler(lev == ORTP_ERROR, fmt, cap); #else @@ -174,7 +174,7 @@ static void log_handler(int lev, const char *fmt, va_list args) { void liblinphone_tester_init(void(*ftester_printf)(int level, const char *fmt, va_list args)) { if (! log_file) { -#if defined(ANDROID) +#if defined(__ANDROID__) linphone_core_set_log_handler(liblinphone_android_ortp_log_handler); bctbx_set_log_handler(liblinphone_android_bctbx_log_handler); #endif diff --git a/tester/log_collection_tester.c b/tester/log_collection_tester.c index 5a43c46d0..e821dc54d 100644 --- a/tester/log_collection_tester.c +++ b/tester/log_collection_tester.c @@ -30,7 +30,7 @@ /*getline is POSIX 2008, not available on many systems.*/ -#if (defined(ANDROID) && !defined(__LP64__)) || defined(_WIN32) || defined(__QNX__) +#if (defined(__ANDROID__) && !defined(__LP64__)) || defined(_WIN32) || defined(__QNX__) /* This code is public domain -- Will Hartung 4/9/09 */ static ssize_t getline(char **lineptr, size_t *n, FILE *stream) { char *bufptr = NULL; diff --git a/tester/remote_provisioning_tester.c b/tester/remote_provisioning_tester.c index 98d6b02b9..967533780 100644 --- a/tester/remote_provisioning_tester.c +++ b/tester/remote_provisioning_tester.c @@ -108,7 +108,7 @@ static void remote_provisioning_file(void) { #if TARGET_OS_IPHONE ms_message("Skipping remote provisioning from file on iOS"); return; -#elif defined(ANDROID) +#elif defined(__ANDROID__) marie = linphone_core_manager_new2("marie_remote_localfile_android_rc", FALSE); #elif defined(LINPHONE_WINDOWS_UNIVERSAL) marie = linphone_core_manager_new2("marie_remote_localfile_win10_rc", FALSE);