From: Marcus Comstedt Date: Fri, 18 Jul 2014 14:17:37 +0000 (+0200) Subject: Android: Use environment setup from library instead X-Git-Tag: pulseview-0.3.0~566 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=aff5174622cf79c6d42c0adbcb9ddbafdf1b96d1;p=pulseview.git Android: Use environment setup from library instead --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 733bfe1f..069ccd89 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -64,6 +64,10 @@ if(ENABLE_DECODE) list(APPEND PKGDEPS libsigrokdecode>=0.3.0) endif() +if(ANDROID) + list(APPEND PKGDEPS libsigrokandroidutils>=0.1.0) +endif() + find_package(PkgConfig) pkg_check_modules(PKGDEPS REQUIRED ${PKGDEPS}) @@ -243,12 +247,6 @@ if(ENABLE_DECODE) pv/widgets/decodergroupbox.h pv/widgets/decodermenu.h ) - - if(ANDROID) - list(APPEND pulseview_SOURCES - android/envsetup.cpp - ) - endif() endif() if(WIN32) diff --git a/android/envsetup.cpp b/android/envsetup.cpp deleted file mode 100644 index d41201ff..00000000 --- a/android/envsetup.cpp +++ /dev/null @@ -1,60 +0,0 @@ -/* - * This file is part of the PulseView project. - * - * Copyright (C) 2014 Marcus Comstedt - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include -#include - -jint JNI_OnLoad(JavaVM *vm, void *reserved) -{ - JNIEnv* env; - - (void)reserved; - - if (vm->GetEnv((void **)&env, JNI_VERSION_1_6) != JNI_OK) { - return -1; - } - - jclass envc = env->FindClass("org/sigrok/androidutils/Environment"); - jmethodID getEnv = env->GetStaticMethodID(envc, "getEnvironment", - "()[Ljava/lang/String;"); - jobjectArray envs = - (jobjectArray)env->CallStaticObjectMethod(envc, getEnv); - jsize i, envn = env->GetArrayLength(envs); - for (i=0; iGetObjectArrayElement(envs, i); - jstring value = (jstring)env->GetObjectArrayElement(envs, i+1); - const char *utfkey = env->GetStringUTFChars(key, 0); - const char *utfvalue = env->GetStringUTFChars(value, 0); - setenv(utfkey, utfvalue, 1); - env->ReleaseStringUTFChars(value, utfvalue); - env->ReleaseStringUTFChars(key, utfkey); - env->DeleteLocalRef(value); - env->DeleteLocalRef(key); - } - env->DeleteLocalRef(envs); - env->DeleteLocalRef(envc); - - return JNI_VERSION_1_6; -} - -void JNI_OnUnload(JavaVM *vm, void *reserved) -{ - (void)vm; - (void)reserved; -} diff --git a/main.cpp b/main.cpp index 0d59baef..07d6dc3f 100644 --- a/main.cpp +++ b/main.cpp @@ -37,6 +37,7 @@ #include "pv/devicemanager.h" #include "pv/mainwindow.h" #ifdef ANDROID +#include #include "android/loghandler.h" #endif @@ -75,6 +76,7 @@ int main(int argc, char *argv[]) QApplication::setOrganizationDomain("sigrok.org"); #ifdef ANDROID + srau_init_environment(); pv::AndroidLogHandler::install_callbacks(); #endif