only include jni.h for android

This commit is contained in:
Benjamin Reis 2017-10-19 11:07:35 +02:00
parent ef94fd5090
commit 47dab4f437
2 changed files with 12 additions and 19 deletions

View file

@ -17,16 +17,13 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "private.h"
#include "platform-helpers.h"
#include <jni.h>
#ifdef __ANDROID__
#include <jni.h>
namespace LinphonePrivate{
class AndroidPlatformHelpers : public PlatformHelpers{
@ -52,7 +49,7 @@ private:
jmethodID mCpuLockReleaseId;
jmethodID mGetDnsServersId;
jmethodID mGetPowerManagerId;
};
jmethodID AndroidPlatformHelpers::getMethodId(JNIEnv *env, jclass klass, const char *method, const char *signature){
@ -77,7 +74,7 @@ AndroidPlatformHelpers::AndroidPlatformHelpers(LinphoneCore *lc, void *system_co
return;
}
mJavaHelper = (jobject) env->NewGlobalRef(mJavaHelper);
mWifiLockAcquireId = getMethodId(env, klass, "acquireWifiLock", "()V");
mWifiLockReleaseId = getMethodId(env, klass, "releaseWifiLock", "()V");
mMcastLockAcquireId = getMethodId(env, klass, "acquireMcastLock", "()V");
@ -86,10 +83,10 @@ AndroidPlatformHelpers::AndroidPlatformHelpers(LinphoneCore *lc, void *system_co
mCpuLockReleaseId = getMethodId(env, klass, "releaseCpuLock", "()V");
mGetDnsServersId = getMethodId(env, klass, "getDnsServers", "()[Ljava/lang/String;");
mGetPowerManagerId = getMethodId(env, klass, "getPowerManager", "()Ljava/lang/Object;");
jobject pm = env->CallObjectMethod(mJavaHelper,mGetPowerManagerId);
belle_sip_wake_lock_init(env, pm);
ms_message("AndroidPlatformHelpers is fully initialised");
}

View file

@ -108,11 +108,9 @@ void CallSessionPrivate::setState(LinphoneCallState newState, const string &mess
switch (newState) {
case LinphoneCallOutgoingInit:
case LinphoneCallIncomingReceived:
#ifdef __ANDROID__
lInfo() << "CallSession [" << q << "] acquires both wifi and multicast lock";
linphone_core_wifi_lock_acquire(core);
linphone_core_multicast_lock_acquire(core); /* Does no affect battery more than regular rtp traffic */
#endif
getPlatformHelpers(core)->acquireWifiLock();
getPlatformHelpers(core)->acquireMcastLock();
getPlatformHelpers(core)->acquireCpuLock();
break;
case LinphoneCallEnd:
case LinphoneCallError:
@ -152,11 +150,9 @@ void CallSessionPrivate::setState(LinphoneCallState newState, const string &mess
log->connected_date_time = ms_time(nullptr);
break;
case LinphoneCallReleased:
#ifdef __ANDROID__
lInfo() << "CallSession [" << q << "] releases wifi/multicast lock";
linphone_core_wifi_lock_release(core);
linphone_core_multicast_lock_release(core);
#endif
getPlatformHelpers(core)->acquireWifiLock();
getPlatformHelpers(core)->acquireMcastLock();
getPlatformHelpers(core)->acquireCpuLock();
break;
default:
break;