diff --git a/jni/Application.mk b/jni/Application.mk index 9340fe30..2ed814f6 100644 --- a/jni/Application.mk +++ b/jni/Application.mk @@ -37,7 +37,7 @@ APP_ABI := x86 armeabi armeabi-v7a-hard # ARMv6 and ARMv5 xash3d builds use softfp only and compatible only with softfp mods # Build both armeabi-v7a-hard and armeabi-v7a supported only for mods, not for engine -APP_MODULES := xash menu client server NanoGL +APP_MODULES := xash menu client server NanoGL jnisetenv ifeq ($(XASH_SDL),1) APP_MODULES += SDL2 endif diff --git a/jni/src/jnisetenv/Android.mk b/jni/src/jnisetenv/Android.mk new file mode 100644 index 00000000..78628f38 --- /dev/null +++ b/jni/src/jnisetenv/Android.mk @@ -0,0 +1,13 @@ +LOCAL_PATH := $(call my-dir) + +include $(CLEAR_VARS) + +LOCAL_MODULE := jnisetenv + +APP_PLATFORM := android-12 + +include $(XASH3D_CONFIG) + +LOCAL_SRC_FILES := setenv.c + +include $(BUILD_SHARED_LIBRARY) diff --git a/jni/src/jnisetenv/setenv.c b/jni/src/jnisetenv/setenv.c new file mode 100644 index 00000000..b2aeef2c --- /dev/null +++ b/jni/src/jnisetenv/setenv.c @@ -0,0 +1,26 @@ +/* +setenv.c -- a jni wrapper for setenv() call for XashActivity +Copyright (C) 2016 a1batross + +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. +*/ + +#include + +JAVA_EXPORT int Java_in_celest_xash3d_XashActivity_setenv( JNIEnv* env, jclass clazz, jstring key, jstring value, jboolean overwrite ) +{ + char* k = (char *) (*env)->GetStringUTFChars(env, key, NULL); + char* v = (char *) (*env)->GetStringUTFChars(env, value, NULL); + int err = setenv(k, v, overwrite); + (*env)->ReleaseStringUTFChars(env, key, k); + (*env)->ReleaseStringUTFChars(env, value, v); + return err; +} diff --git a/src/in/celest/xash3d/XashActivity.java b/src/in/celest/xash3d/XashActivity.java index 4550b5c0..719e5ed9 100644 --- a/src/in/celest/xash3d/XashActivity.java +++ b/src/in/celest/xash3d/XashActivity.java @@ -75,6 +75,11 @@ public class XashActivity extends Activity { private static String SIG = "DMsE8f5hlR7211D8uehbFpbA0n8="; private static String SIG_TEST = ""; // a1ba: mittorn, add your signature later + // Load the .so + static { + System.loadLibrary("jnisetenv"); + } + // Shared between this activity and LauncherActivity public static boolean dumbAntiPDALifeCheck( Context context ) {