From 8ffa29b34a14a2f445c7f2d3e7b6bcdfe1a467e6 Mon Sep 17 00:00:00 2001 From: doitux Date: Sat, 22 Dec 2012 00:18:54 +0100 Subject: [PATCH] fix android test --- pokerth_game.pro | 1 + src/gui/qt/aboutpokerth/aboutpokerthimpl.cpp | 22 +++++++++++--------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/pokerth_game.pro b/pokerth_game.pro index ea2aa7ea..59199d5e 100644 --- a/pokerth_game.pro +++ b/pokerth_game.pro @@ -656,4 +656,5 @@ maemo{ android_test{ DEFINES += ANDROID + DEFINES += ANDROID_TEST } diff --git a/src/gui/qt/aboutpokerth/aboutpokerthimpl.cpp b/src/gui/qt/aboutpokerth/aboutpokerthimpl.cpp index b3aa78a1..b63c3d47 100755 --- a/src/gui/qt/aboutpokerth/aboutpokerthimpl.cpp +++ b/src/gui/qt/aboutpokerth/aboutpokerthimpl.cpp @@ -74,18 +74,20 @@ aboutPokerthImpl::aboutPokerthImpl(QWidget *parent, ConfigFile *c) #endif #ifdef ANDROID - JavaVM *currVM = (JavaVM *)QApplication::platformNativeInterface()->nativeResourceForWidget("JavaVM", 0); - JNIEnv* env; int api = -2; - if (currVM->AttachCurrentThread(&env, NULL)<0) { - qCritical()<<"AttachCurrentThread failed"; - } else { - jclass jclassApplicationClass = env->FindClass("android/os/Build$VERSION"); - if (jclassApplicationClass) { - api = env->GetStaticIntField(jclassApplicationClass, env->GetStaticFieldID(jclassApplicationClass,"SDK_INT", "I")); + #ifndef ANDROID_TEST + JavaVM *currVM = (JavaVM *)QApplication::platformNativeInterface()->nativeResourceForWidget("JavaVM", 0); + JNIEnv* env; + if (currVM->AttachCurrentThread(&env, NULL)<0) { + qCritical()<<"AttachCurrentThread failed"; + } else { + jclass jclassApplicationClass = env->FindClass("android/os/Build$VERSION"); + if (jclassApplicationClass) { + api = env->GetStaticIntField(jclassApplicationClass, env->GetStaticFieldID(jclassApplicationClass,"SDK_INT", "I")); + } + currVM->DetachCurrentThread(); } - currVM->DetachCurrentThread(); - } + #endif label_pokerthVersion->setText(QString(tr("PokerTH %1 for Android (API%2)").arg(POKERTH_BETA_RELEASE_STRING).arg(api))); #else label_pokerthVersion->setText(QString(tr("PokerTH %1").arg(POKERTH_BETA_RELEASE_STRING)));