android: Log some information about the Android version and the device

This commit is contained in:
Tobias Brunner
2017-07-03 10:27:51 +02:00
parent e5ec18009f
commit c5ba381757
4 changed files with 59 additions and 6 deletions
@@ -939,6 +939,23 @@ public class CharonVpnService extends VpnService implements Runnable, VpnStateSe
} }
} }
/**
* Function called via JNI to determine information about the Android version.
*/
private static String getAndroidVersion()
{
return "Android " + Build.VERSION.RELEASE + " - " + Build.DISPLAY +
"/" + Build.VERSION.SECURITY_PATCH;
}
/**
* Function called via JNI to determine information about the device.
*/
private static String getDeviceString()
{
return Build.MODEL + " - " + Build.BRAND + "/" + Build.PRODUCT + "/" + Build.MANUFACTURER;
}
/* /*
* The libraries are extracted to /data/data/org.strongswan.android/... * The libraries are extracted to /data/data/org.strongswan.android/...
* during installation. On newer releases most are loaded in JNI_OnLoad. * during installation. On newer releases most are loaded in JNI_OnLoad.
@@ -1,8 +1,8 @@
/* /*
* Copyright (C) 2012-2015 Tobias Brunner * Copyright (C) 2012-2017 Tobias Brunner
* Copyright (C) 2012 Giuliano Grassi * Copyright (C) 2012 Giuliano Grassi
* Copyright (C) 2012 Ralf Sager * Copyright (C) 2012 Ralf Sager
* Hochschule fuer Technik Rapperswil * HSR Hochschule fuer Technik Rapperswil
* *
* This program is free software; you can redistribute it and/or modify it * 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 * under the terms of the GNU General Public License as published by the
@@ -46,6 +46,8 @@ jclass *android_charonvpnservice_class;
jclass *android_charonvpnservice_builder_class; jclass *android_charonvpnservice_builder_class;
jclass *android_simple_fetcher_class; jclass *android_simple_fetcher_class;
android_sdk_version_t android_sdk_version; android_sdk_version_t android_sdk_version;
char *android_version_string;
char *android_device_string;
/** /**
* Thread-local variable. Only used because of the destructor * Thread-local variable. Only used because of the destructor
@@ -97,6 +99,8 @@ jint JNI_OnLoad(JavaVM *vm, void *reserved)
JNIEnv *env; JNIEnv *env;
jclass jversion; jclass jversion;
jfieldID jsdk_int; jfieldID jsdk_int;
jmethodID method_id;
jstring jstr;
int i; int i;
android_jvm = vm; android_jvm = vm;
@@ -131,6 +135,22 @@ jint JNI_OnLoad(JavaVM *vm, void *reserved)
jsdk_int = (*env)->GetStaticFieldID(env, jversion, "SDK_INT", "I"); jsdk_int = (*env)->GetStaticFieldID(env, jversion, "SDK_INT", "I");
android_sdk_version = (*env)->GetStaticIntField(env, jversion, jsdk_int); android_sdk_version = (*env)->GetStaticIntField(env, jversion, jsdk_int);
method_id = (*env)->GetStaticMethodID(env, android_charonvpnservice_class,
"getAndroidVersion", "()Ljava/lang/String;");
jstr = (*env)->CallStaticObjectMethod(env,
android_charonvpnservice_class, method_id);
if (jstr)
{
android_version_string = androidjni_convert_jstring(env, jstr);
}
method_id = (*env)->GetStaticMethodID(env, android_charonvpnservice_class,
"getDeviceString", "()Ljava/lang/String;");
jstr = (*env)->CallStaticObjectMethod(env,
android_charonvpnservice_class, method_id);
if (jstr)
{
android_device_string = androidjni_convert_jstring(env, jstr);
}
return JNI_VERSION_1_6; return JNI_VERSION_1_6;
} }
@@ -151,5 +171,6 @@ void JNI_OnUnload(JavaVM *vm, void *reserved)
dlclose(libs[i].handle); dlclose(libs[i].handle);
} }
} }
free(android_version_string);
free(android_device_string);
} }
@@ -1,8 +1,8 @@
/* /*
* Copyright (C) 2012 Tobias Brunner * Copyright (C) 2012-2017 Tobias Brunner
* Copyright (C) 2012 Giuliano Grassi * Copyright (C) 2012 Giuliano Grassi
* Copyright (C) 2012 Ralf Sager * Copyright (C) 2012 Ralf Sager
* Hochschule fuer Technik Rapperswil * HSR Hochschule fuer Technik Rapperswil
* *
* This program is free software; you can redistribute it and/or modify it * 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 * under the terms of the GNU General Public License as published by the
@@ -66,6 +66,20 @@ typedef enum {
*/ */
extern android_sdk_version_t android_sdk_version; extern android_sdk_version_t android_sdk_version;
/**
* A description of the current Android release
*
* see android.os.Build
*/
extern char *android_version_string;
/**
* A description of the current device
*
* see android.os.Build
*/
extern char *android_device_string;
/** /**
* Attach the current thread to the JVM * Attach the current thread to the JVM
* *
@@ -644,7 +644,8 @@ JNI_METHOD(CharonVpnService, initializeCharon, jboolean,
{ {
memset(&utsname, 0, sizeof(utsname)); memset(&utsname, 0, sizeof(utsname));
} }
DBG1(DBG_DMN, "Starting IKE charon daemon (strongSwan "VERSION", %s %s, %s)", DBG1(DBG_DMN, "Starting IKE charon daemon (strongSwan "VERSION", %s, %s, "
"%s %s, %s)", android_version_string, android_device_string,
utsname.sysname, utsname.release, utsname.machine); utsname.sysname, utsname.release, utsname.machine);
#ifdef PLUGINS_BYOD #ifdef PLUGINS_BYOD