diff --git a/pythonforandroid/bootstraps/common/build/jni/application/src/start.c b/pythonforandroid/bootstraps/common/build/jni/application/src/start.c index cc4e5db603..afc8c3ad1d 100644 --- a/pythonforandroid/bootstraps/common/build/jni/application/src/start.c +++ b/pythonforandroid/bootstraps/common/build/jni/application/src/start.c @@ -458,19 +458,20 @@ JNIEXPORT void JNICALL Java_org_kivy_android_PythonService_nativeStart( #if defined(BOOTSTRAP_NAME_WEBVIEW) || defined(BOOTSTRAP_NAME_SERVICEONLY) // Webview and service_only uses some more functions: -void Java_org_kivy_android_PythonActivity_nativeSetEnv( - JNIEnv* env, jclass jcls, - jstring j_name, jstring j_value) -/* JNIEXPORT void JNICALL Java_org_libsdl_app_SDLActivity_nativeSetEnv( */ -/* JNIEnv* env, jclass jcls, */ -/* jstring j_name, jstring j_value) */ +void Java_org_kivy_android_PythonActivity_nativeSetenv( + JNIEnv* env, jclass cls, + jstring name, jstring value) +//JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeSetenv)( +// JNIEnv* env, jclass cls, +// jstring name, jstring value) { - jboolean iscopy; - const char *name = (*env)->GetStringUTFChars(env, j_name, &iscopy); - const char *value = (*env)->GetStringUTFChars(env, j_value, &iscopy); - setenv(name, value, 1); - (*env)->ReleaseStringUTFChars(env, j_name, name); - (*env)->ReleaseStringUTFChars(env, j_value, value); + const char *utfname = (*env)->GetStringUTFChars(env, name, NULL); + const char *utfvalue = (*env)->GetStringUTFChars(env, value, NULL); + + SDL_setenv(utfname, utfvalue, 1); + + (*env)->ReleaseStringUTFChars(env, name, utfname); + (*env)->ReleaseStringUTFChars(env, value, utfvalue); } diff --git a/pythonforandroid/bootstraps/sdl2/build/src/main/java/org/kivy/android/PythonActivity.java b/pythonforandroid/bootstraps/sdl2/build/src/main/java/org/kivy/android/PythonActivity.java index c3db253092..327ae18f4f 100644 --- a/pythonforandroid/bootstraps/sdl2/build/src/main/java/org/kivy/android/PythonActivity.java +++ b/pythonforandroid/bootstraps/sdl2/build/src/main/java/org/kivy/android/PythonActivity.java @@ -151,9 +151,9 @@ protected void onPostExecute(String result) { Project p = Project.scanDirectory(path); String entry_point = getEntryPoint(p.dir); - SDLActivity.nativeSetEnv("ANDROID_ENTRYPOINT", p.dir + "/" + entry_point); - SDLActivity.nativeSetEnv("ANDROID_ARGUMENT", p.dir); - SDLActivity.nativeSetEnv("ANDROID_APP_PATH", p.dir); + SDLActivity.nativeSetenv("ANDROID_ENTRYPOINT", p.dir + "/" + entry_point); + SDLActivity.nativeSetenv("ANDROID_ARGUMENT", p.dir); + SDLActivity.nativeSetenv("ANDROID_APP_PATH", p.dir); if (p != null) { if (p.landscape) { @@ -173,18 +173,18 @@ protected void onPostExecute(String result) { } } else { String entry_point = getEntryPoint(app_root_dir); - SDLActivity.nativeSetEnv("ANDROID_ENTRYPOINT", entry_point); - SDLActivity.nativeSetEnv("ANDROID_ARGUMENT", app_root_dir); - SDLActivity.nativeSetEnv("ANDROID_APP_PATH", app_root_dir); + SDLActivity.nativeSetenv("ANDROID_ENTRYPOINT", entry_point); + SDLActivity.nativeSetenv("ANDROID_ARGUMENT", app_root_dir); + SDLActivity.nativeSetenv("ANDROID_APP_PATH", app_root_dir); } String mFilesDirectory = mActivity.getFilesDir().getAbsolutePath(); Log.v(TAG, "Setting env vars for start.c and Python to use"); - SDLActivity.nativeSetEnv("ANDROID_PRIVATE", mFilesDirectory); - SDLActivity.nativeSetEnv("ANDROID_UNPACK", app_root_dir); - SDLActivity.nativeSetEnv("PYTHONHOME", app_root_dir); - SDLActivity.nativeSetEnv("PYTHONPATH", app_root_dir + ":" + app_root_dir + "/lib"); - SDLActivity.nativeSetEnv("PYTHONOPTIMIZE", "2"); + SDLActivity.nativeSetenv("ANDROID_PRIVATE", mFilesDirectory); + SDLActivity.nativeSetenv("ANDROID_UNPACK", app_root_dir); + SDLActivity.nativeSetenv("PYTHONHOME", app_root_dir); + SDLActivity.nativeSetenv("PYTHONPATH", app_root_dir + ":" + app_root_dir + "/lib"); + SDLActivity.nativeSetenv("PYTHONOPTIMIZE", "2"); try { Log.v(TAG, "Access to our meta-data..."); diff --git a/pythonforandroid/bootstraps/sdl2/build/src/patches/SDLActivity.java.patch b/pythonforandroid/bootstraps/sdl2/build/src/patches/SDLActivity.java.patch index 23b21e25b4..27b97a7fbb 100644 --- a/pythonforandroid/bootstraps/sdl2/build/src/patches/SDLActivity.java.patch +++ b/pythonforandroid/bootstraps/sdl2/build/src/patches/SDLActivity.java.patch @@ -25,14 +25,6 @@ Message msg = commandHandler.obtainMessage(); msg.arg1 = command; msg.obj = data; -@@ -709,6 +718,7 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh - public static native void nativeResume(); - public static native void onNativeDropFile(String filename); - public static native void onNativeResize(int surfaceWidth, int surfaceHeight, int deviceWidth, int deviceHeight, int format, float rate); -+ public static native void nativeSetEnv(String j_name, String j_value); - public static native void onNativeKeyDown(int keycode); - public static native void onNativeKeyUp(int keycode); - public static native void onNativeKeyboardFocusLost(); @@ -1051,6 +1061,21 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh return Arrays.copyOf(filtered, used); } diff --git a/pythonforandroid/bootstraps/service_only/build/src/main/java/org/kivy/android/PythonActivity.java b/pythonforandroid/bootstraps/service_only/build/src/main/java/org/kivy/android/PythonActivity.java index 4ed1b4e10a..3390806041 100644 --- a/pythonforandroid/bootstraps/service_only/build/src/main/java/org/kivy/android/PythonActivity.java +++ b/pythonforandroid/bootstraps/service_only/build/src/main/java/org/kivy/android/PythonActivity.java @@ -161,14 +161,14 @@ public void onClick(DialogInterface dialog,int id) { String entry_point = getEntryPoint(app_root_dir); Log.v(TAG, "Setting env vars for start.c and Python to use"); - PythonActivity.nativeSetEnv("ANDROID_ENTRYPOINT", entry_point); - PythonActivity.nativeSetEnv("ANDROID_ARGUMENT", app_root_dir); - PythonActivity.nativeSetEnv("ANDROID_APP_PATH", app_root_dir); - PythonActivity.nativeSetEnv("ANDROID_PRIVATE", mFilesDirectory); - PythonActivity.nativeSetEnv("ANDROID_UNPACK", app_root_dir); - PythonActivity.nativeSetEnv("PYTHONHOME", app_root_dir); - PythonActivity.nativeSetEnv("PYTHONPATH", app_root_dir + ":" + app_root_dir + "/lib"); - PythonActivity.nativeSetEnv("PYTHONOPTIMIZE", "2"); + PythonActivity.nativeSetenv("ANDROID_ENTRYPOINT", entry_point); + PythonActivity.nativeSetenv("ANDROID_ARGUMENT", app_root_dir); + PythonActivity.nativeSetenv("ANDROID_APP_PATH", app_root_dir); + PythonActivity.nativeSetenv("ANDROID_PRIVATE", mFilesDirectory); + PythonActivity.nativeSetenv("ANDROID_UNPACK", app_root_dir); + PythonActivity.nativeSetenv("PYTHONHOME", app_root_dir); + PythonActivity.nativeSetenv("PYTHONPATH", app_root_dir + ":" + app_root_dir + "/lib"); + PythonActivity.nativeSetenv("PYTHONOPTIMIZE", "2"); try { Log.v(TAG, "Access to our meta-data..."); @@ -404,7 +404,7 @@ public static void stop_service() { } - public static native void nativeSetEnv(String j_name, String j_value); + public static native void nativeSetenv(String name, String value); public static native int nativeInit(Object arguments); } diff --git a/pythonforandroid/bootstraps/webview/build/src/main/java/org/kivy/android/PythonActivity.java b/pythonforandroid/bootstraps/webview/build/src/main/java/org/kivy/android/PythonActivity.java index 62e677d5b9..1a37bc672f 100644 --- a/pythonforandroid/bootstraps/webview/build/src/main/java/org/kivy/android/PythonActivity.java +++ b/pythonforandroid/bootstraps/webview/build/src/main/java/org/kivy/android/PythonActivity.java @@ -189,14 +189,14 @@ public boolean shouldOverrideUrlLoading(WebView view, String url) { String entry_point = getEntryPoint(app_root_dir); Log.v(TAG, "Setting env vars for start.c and Python to use"); - PythonActivity.nativeSetEnv("ANDROID_ENTRYPOINT", entry_point); - PythonActivity.nativeSetEnv("ANDROID_ARGUMENT", app_root_dir); - PythonActivity.nativeSetEnv("ANDROID_APP_PATH", app_root_dir); - PythonActivity.nativeSetEnv("ANDROID_PRIVATE", mFilesDirectory); - PythonActivity.nativeSetEnv("ANDROID_UNPACK", app_root_dir); - PythonActivity.nativeSetEnv("PYTHONHOME", app_root_dir); - PythonActivity.nativeSetEnv("PYTHONPATH", app_root_dir + ":" + app_root_dir + "/lib"); - PythonActivity.nativeSetEnv("PYTHONOPTIMIZE", "2"); + PythonActivity.nativeSetenv("ANDROID_ENTRYPOINT", entry_point); + PythonActivity.nativeSetenv("ANDROID_ARGUMENT", app_root_dir); + PythonActivity.nativeSetenv("ANDROID_APP_PATH", app_root_dir); + PythonActivity.nativeSetenv("ANDROID_PRIVATE", mFilesDirectory); + PythonActivity.nativeSetenv("ANDROID_UNPACK", app_root_dir); + PythonActivity.nativeSetenv("PYTHONHOME", app_root_dir); + PythonActivity.nativeSetenv("PYTHONPATH", app_root_dir + ":" + app_root_dir + "/lib"); + PythonActivity.nativeSetenv("PYTHONOPTIMIZE", "2"); try { Log.v(TAG, "Access to our meta-data..."); @@ -461,7 +461,7 @@ public static void stop_service() { } - public static native void nativeSetEnv(String j_name, String j_value); + public static native void nativeSetenv(String name, String value); public static native int nativeInit(Object arguments); } diff --git a/pythonforandroid/recipes/sdl2/__init__.py b/pythonforandroid/recipes/sdl2/__init__.py index 6bc9676712..bbfadc2c04 100644 --- a/pythonforandroid/recipes/sdl2/__init__.py +++ b/pythonforandroid/recipes/sdl2/__init__.py @@ -13,8 +13,6 @@ class LibSDL2Recipe(BootstrapNDKRecipe): depends = ['sdl2_image', 'sdl2_mixer', 'sdl2_ttf'] conflicts = ['sdl', 'pygame', 'pygame_bootstrap_components'] - patches = ['add_nativeSetEnv.patch'] - def get_recipe_env(self, arch=None, with_flags_in_cc=True, with_python=True): env = super(LibSDL2Recipe, self).get_recipe_env( arch=arch, with_flags_in_cc=with_flags_in_cc, with_python=with_python) diff --git a/pythonforandroid/recipes/sdl2/add_nativeSetEnv.patch b/pythonforandroid/recipes/sdl2/add_nativeSetEnv.patch deleted file mode 100644 index 2262f1690f..0000000000 --- a/pythonforandroid/recipes/sdl2/add_nativeSetEnv.patch +++ /dev/null @@ -1,22 +0,0 @@ ---- orig/src/core/android/SDL_android.c 2016-01-02 20:56:31.000000000 +0100 -+++ patch/src/core/android/SDL_android.c 2016-04-15 22:21:13.985708267 +0200 -@@ -188,6 +188,19 @@ - Android_OnHat(device_id, hat_id, x, y); - } - -+/* Patched in env var setter for python-for-android */ -+JNIEXPORT void JNICALL Java_org_libsdl_app_SDLActivity_nativeSetEnv( -+ JNIEnv* env, jclass jcls, -+ jstring j_name, jstring j_value) -+{ -+ jboolean iscopy; -+ const char *name = (*env)->GetStringUTFChars(env, j_name, &iscopy); -+ const char *value = (*env)->GetStringUTFChars(env, j_value, &iscopy); -+ setenv(name, value, 1); -+ (*env)->ReleaseStringUTFChars(env, j_name, name); -+ (*env)->ReleaseStringUTFChars(env, j_value, value); -+} -+ - - JNIEXPORT jint JNICALL Java_org_libsdl_app_SDLActivity_nativeAddJoystick( - JNIEnv* env, jclass jcls,