Removed the need for libSDL2main.a on Android, and separated JNI initialization out for other integrations
authorSam Lantinga <slouken@libsdl.org>
Mon, 28 Aug 2017 14:34:15 -0700
changeset 11395a8c29f5b679f
parent 11394 910be5fe412a
child 11396 3742ce262471
Removed the need for libSDL2main.a on Android, and separated JNI initialization out for other integrations
android-project/src/org/libsdl/app/SDLActivity.java
configure
configure.in
include/SDL_main.h
src/core/android/SDL_android.c
src/main/android/SDL_android_main.c
     1.1 --- a/android-project/src/org/libsdl/app/SDLActivity.java	Mon Aug 28 13:40:32 2017 -0700
     1.2 +++ b/android-project/src/org/libsdl/app/SDLActivity.java	Mon Aug 28 14:34:15 2017 -0700
     1.3 @@ -136,10 +136,11 @@
     1.4      protected void onCreate(Bundle savedInstanceState) {
     1.5          Log.v(TAG, "Device: " + android.os.Build.DEVICE);
     1.6          Log.v(TAG, "Model: " + android.os.Build.MODEL);
     1.7 -        Log.v(TAG, "onCreate(): " + mSingleton);
     1.8 +        Log.v(TAG, "onCreate()");
     1.9          super.onCreate(savedInstanceState);
    1.10  
    1.11          SDLActivity.initialize();
    1.12 +
    1.13          // So we can call stuff from static callbacks
    1.14          mSingleton = this;
    1.15  
    1.16 @@ -179,18 +180,16 @@
    1.17             return;
    1.18          }
    1.19  
    1.20 -        // Set up the surface
    1.21 -        mSurface = new SDLSurface(getApplication());
    1.22 +        // Set up JNI
    1.23 +        SDLActivity.nativeSetupJNI();
    1.24  
    1.25 -
    1.26 -        if(Build.VERSION.SDK_INT >= 16) {
    1.27 +        if (Build.VERSION.SDK_INT >= 16) {
    1.28              mJoystickHandler = new SDLJoystickHandler_API16();
    1.29 -        } else if(Build.VERSION.SDK_INT >= 12) {
    1.30 +        } else if (Build.VERSION.SDK_INT >= 12) {
    1.31              mJoystickHandler = new SDLJoystickHandler_API12();
    1.32          } else {
    1.33              mJoystickHandler = new SDLJoystickHandler();
    1.34          }
    1.35 -
    1.36          mHapticHandler = new SDLHapticHandler();
    1.37  
    1.38          if (Build.VERSION.SDK_INT >= 11) {
    1.39 @@ -200,6 +199,9 @@
    1.40              mClipboardHandler = new SDLClipboardHandler_Old();
    1.41          }
    1.42  
    1.43 +        // Set up the surface
    1.44 +        mSurface = new SDLSurface(getApplication());
    1.45 +
    1.46          mLayout = new RelativeLayout(this);
    1.47          mLayout.addView(mSurface);
    1.48  
    1.49 @@ -207,7 +209,6 @@
    1.50          
    1.51          // Get filename from "Open with" of another application
    1.52          Intent intent = getIntent();
    1.53 -
    1.54          if (intent != null && intent.getData() != null) {
    1.55              String filename = intent.getData().getPath();
    1.56              if (filename != null) {
    1.57 @@ -309,6 +310,7 @@
    1.58          }
    1.59  
    1.60          super.onDestroy();
    1.61 +
    1.62          // Reset everything in case the user re opens the app
    1.63          SDLActivity.initialize();
    1.64      }
    1.65 @@ -358,43 +360,42 @@
    1.66  
    1.67          // Try a transition to resumed state
    1.68          if (mNextNativeState == NativeState.RESUMED) {
    1.69 +            if (mIsSurfaceReady && mHasFocus && mIsResumedCalled) {
    1.70 +                if (mSDLThread == null) {
    1.71 +                    // This is the entry point to the C app.
    1.72 +                    // Start up the C app thread and enable sensor input for the first time
    1.73 +                    // FIXME: Why aren't we enabling sensor input at start?
    1.74  
    1.75 -           if (mIsSurfaceReady && mHasFocus && mIsResumedCalled) {
    1.76 +                    final Thread sdlThread = new Thread(new SDLMain(), "SDLThread");
    1.77 +                    mSurface.enableSensor(Sensor.TYPE_ACCELEROMETER, true);
    1.78 +                    sdlThread.start();
    1.79  
    1.80 -              if (mSDLThread == null) {
    1.81 -                  // This is the entry point to the C app.
    1.82 -                  // Start up the C app thread and enable sensor input for the first time
    1.83 +                    // Set up a listener thread to catch when the native thread ends
    1.84 +                    mSDLThread = new Thread(new Runnable() {
    1.85 +                        @Override
    1.86 +                        public void run() {
    1.87 +                            try {
    1.88 +                                sdlThread.join();
    1.89 +                            } catch (Exception e) {
    1.90 +                                // Ignore any exception
    1.91 +                            } finally {
    1.92 +                                // Native thread has finished
    1.93 +                                if (!mExitCalledFromJava) {
    1.94 +                                    handleNativeExit();
    1.95 +                                }
    1.96 +                            }
    1.97 +                        }
    1.98 +                    }, "SDLThreadListener");
    1.99  
   1.100 -                  final Thread sdlThread = new Thread(new SDLMain(), "SDLThread");
   1.101 -                  mSurface.enableSensor(Sensor.TYPE_ACCELEROMETER, true);
   1.102 -                  sdlThread.start();
   1.103 +                    mSDLThread.start();
   1.104 +                }
   1.105  
   1.106 -                  // Set up a listener thread to catch when the native thread ends
   1.107 -                  mSDLThread = new Thread(new Runnable(){
   1.108 -                      @Override
   1.109 -                      public void run(){
   1.110 -                          try {
   1.111 -                              sdlThread.join();
   1.112 -                          }
   1.113 -                          catch(Exception e){}
   1.114 -                          finally{
   1.115 -                              // Native thread has finished
   1.116 -                              if (! mExitCalledFromJava) {
   1.117 -                                  handleNativeExit();
   1.118 -                              }
   1.119 -                          }
   1.120 -                      }
   1.121 -                  }, "SDLThreadListener");
   1.122 -                  mSDLThread.start();
   1.123 -              }
   1.124 -
   1.125 -
   1.126 -              nativeResume();
   1.127 -              mSurface.handleResume();
   1.128 -              mCurrentNativeState = mNextNativeState;
   1.129 -          }
   1.130 -          return;
   1.131 -       }
   1.132 +                nativeResume();
   1.133 +                mSurface.handleResume();
   1.134 +                mCurrentNativeState = mNextNativeState;
   1.135 +            }
   1.136 +            return;
   1.137 +        }
   1.138      }
   1.139  
   1.140      /* The native thread has finished */
   1.141 @@ -460,12 +461,14 @@
   1.142                  break;
   1.143              case COMMAND_SET_KEEP_SCREEN_ON:
   1.144              {
   1.145 -                Window window = ((Activity) context).getWindow();
   1.146 -                if (window != null) {
   1.147 -                    if ((msg.obj instanceof Integer) && (((Integer) msg.obj).intValue() != 0)) {
   1.148 -                        window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
   1.149 -                    } else {
   1.150 -                        window.clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
   1.151 +                if (context instanceof Activity) {
   1.152 +                    Window window = ((Activity) context).getWindow();
   1.153 +                    if (window != null) {
   1.154 +                        if ((msg.obj instanceof Integer) && (((Integer) msg.obj).intValue() != 0)) {
   1.155 +                            window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
   1.156 +                        } else {
   1.157 +                            window.clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
   1.158 +                        }
   1.159                      }
   1.160                  }
   1.161                  break;
   1.162 @@ -490,7 +493,8 @@
   1.163      }
   1.164  
   1.165      // C functions we call
   1.166 -    public static native int nativeInit(Object arguments);
   1.167 +    public static native int nativeSetupJNI();
   1.168 +    public static native int nativeRunMain(String library, String function, Object arguments);
   1.169      public static native void nativeLowMemory();
   1.170      public static native void nativeQuit();
   1.171      public static native void nativePause();
   1.172 @@ -1208,15 +1212,25 @@
   1.173  }
   1.174  
   1.175  /**
   1.176 -    Simple nativeInit() runnable
   1.177 +    Simple runnable to start the SDL application
   1.178  */
   1.179  class SDLMain implements Runnable {
   1.180      @Override
   1.181      public void run() {
   1.182          // Runs SDL_main()
   1.183 -        SDLActivity.nativeInit(SDLActivity.mSingleton.getArguments());
   1.184 +        String library;
   1.185 +        String[] libraries = SDLActivity.mSingleton.getLibraries();
   1.186 +        if (libraries.length > 0) {
   1.187 +            library = "lib" + libraries[libraries.length - 1] + ".so";
   1.188 +        } else {
   1.189 +            library = "libmain.so";
   1.190 +        }
   1.191 +        String function = "SDL_main";
   1.192  
   1.193 -        //Log.v("SDL", "SDL thread terminated");
   1.194 +        Log.v("SDL", "Running main function " + function + " from library " + library);
   1.195 +        SDLActivity.nativeRunMain(library, function, SDLActivity.mSingleton.getArguments());
   1.196 +
   1.197 +        Log.v("SDL", "Finished main function");
   1.198      }
   1.199  }
   1.200  
   1.201 @@ -1251,7 +1265,7 @@
   1.202          mDisplay = ((WindowManager)context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
   1.203          mSensorManager = (SensorManager)context.getSystemService(Context.SENSOR_SERVICE);
   1.204  
   1.205 -        if(Build.VERSION.SDK_INT >= 12) {
   1.206 +        if (Build.VERSION.SDK_INT >= 12) {
   1.207              setOnGenericMotionListener(new SDLGenericMotionListener_API12());
   1.208          }
   1.209  
   1.210 @@ -1964,8 +1978,8 @@
   1.211              SDLHaptic haptic = getHaptic(deviceIds[i]);
   1.212              if (haptic == null) {
   1.213                  InputDevice device = InputDevice.getDevice(deviceIds[i]);
   1.214 -                Vibrator vib = device.getVibrator ();
   1.215 -                if(vib.hasVibrator ()) {
   1.216 +                Vibrator vib = device.getVibrator();
   1.217 +                if (vib.hasVibrator()) {
   1.218                      haptic = new SDLHaptic();
   1.219                      haptic.device_id = deviceIds[i];
   1.220                      haptic.name = device.getName();
     2.1 --- a/configure	Mon Aug 28 13:40:32 2017 -0700
     2.2 +++ b/configure	Mon Aug 28 14:34:15 2017 -0700
     2.3 @@ -1616,7 +1616,7 @@
     2.4                            include OpenGL ES 1.1 support [[default=yes]]
     2.5    --enable-video-opengles2
     2.6                            include OpenGL ES 2.0 support [[default=yes]]
     2.7 -  --enable-video-vulkan   include Vulkan surface support [[default=yes]]
     2.8 +  --enable-video-vulkan   include Vulkan support [[default=yes]]
     2.9    --enable-libudev        enable libudev support [[default=yes]]
    2.10    --enable-dbus           enable D-Bus support [[default=yes]]
    2.11    --enable-ime            enable IME support [[default=yes]]
    2.12 @@ -23641,7 +23641,6 @@
    2.13                  ANDROID_CFLAGS="-DGL_GLEXT_PROTOTYPES"
    2.14                  CFLAGS="$CFLAGS $ANDROID_CFLAGS"
    2.15                  SDL_CFLAGS="$SDL_CFLAGS $ANDROID_CFLAGS"
    2.16 -                SDL_LIBS="$SDL_LIBS -lSDL2main -Wl,-u,SDL_main_dummy"
    2.17                  EXTRA_CFLAGS="$EXTRA_CFLAGS $ANDROID_CFLAGS"
    2.18                  EXTRA_LDFLAGS="$EXTRA_LDFLAGS -ldl -lGLESv1_CM -lGLESv2 -llog -landroid"
    2.19                  SDLMAIN_SOURCES="$srcdir/src/main/android/*.c"
     3.1 --- a/configure.in	Mon Aug 28 13:40:32 2017 -0700
     3.2 +++ b/configure.in	Mon Aug 28 14:34:15 2017 -0700
     3.3 @@ -3201,7 +3201,6 @@
     3.4                  ANDROID_CFLAGS="-DGL_GLEXT_PROTOTYPES"
     3.5                  CFLAGS="$CFLAGS $ANDROID_CFLAGS"
     3.6                  SDL_CFLAGS="$SDL_CFLAGS $ANDROID_CFLAGS"
     3.7 -                SDL_LIBS="$SDL_LIBS -lSDL2main -Wl,-u,SDL_main_dummy"
     3.8                  EXTRA_CFLAGS="$EXTRA_CFLAGS $ANDROID_CFLAGS"
     3.9                  EXTRA_LDFLAGS="$EXTRA_LDFLAGS -ldl -lGLESv1_CM -lGLESv2 -llog -landroid"
    3.10                  SDLMAIN_SOURCES="$srcdir/src/main/android/*.c"
     4.1 --- a/include/SDL_main.h	Mon Aug 28 13:40:32 2017 -0700
     4.2 +++ b/include/SDL_main.h	Mon Aug 28 14:34:15 2017 -0700
     4.3 @@ -107,7 +107,7 @@
     4.4  /**
     4.5   *  The prototype for the application's main() function
     4.6   */
     4.7 -extern C_LINKAGE int SDL_main(int argc, char *argv[]);
     4.8 +extern C_LINKAGE DECLSPEC int SDL_main(int argc, char *argv[]);
     4.9  
    4.10  
    4.11  #include "begin_code.h"
     5.1 --- a/src/core/android/SDL_android.c	Mon Aug 28 13:40:32 2017 -0700
     5.2 +++ b/src/core/android/SDL_android.c	Mon Aug 28 14:34:15 2017 -0700
     5.3 @@ -43,6 +43,7 @@
     5.4  #include <pthread.h>
     5.5  #include <sys/types.h>
     5.6  #include <unistd.h>
     5.7 +#include <dlfcn.h>
     5.8  /* #define LOG_TAG "SDL_android" */
     5.9  /* #define LOGI(...)  __android_log_print(ANDROID_LOG_INFO,LOG_TAG,__VA_ARGS__) */
    5.10  /* #define LOGE(...)  __android_log_print(ANDROID_LOG_ERROR,LOG_TAG,__VA_ARGS__) */
    5.11 @@ -58,6 +59,13 @@
    5.12  
    5.13  
    5.14  /* Java class SDLActivity */
    5.15 +JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeSetupJNI)(
    5.16 +        JNIEnv* mEnv, jclass cls);
    5.17 +
    5.18 +JNIEXPORT int JNICALL SDL_JAVA_INTERFACE(nativeRunMain)(
    5.19 +        JNIEnv* env, jclass cls,
    5.20 +        jstring library, jstring function, jobject array);
    5.21 +
    5.22  JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeDropFile)(
    5.23          JNIEnv* env, jclass jcls,
    5.24          jstring filename);
    5.25 @@ -237,9 +245,9 @@
    5.26  }
    5.27  
    5.28  /* Called before SDL_main() to initialize JNI bindings */
    5.29 -JNIEXPORT void JNICALL SDL_Android_Init(JNIEnv* mEnv, jclass cls)
    5.30 +JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeSetupJNI)(JNIEnv* mEnv, jclass cls)
    5.31  {
    5.32 -    __android_log_print(ANDROID_LOG_INFO, "SDL", "SDL_Android_Init()");
    5.33 +    __android_log_print(ANDROID_LOG_VERBOSE, "SDL", "nativeSetupJNI()");
    5.34  
    5.35      Android_JNI_SetupThread();
    5.36  
    5.37 @@ -299,16 +307,95 @@
    5.38         !midSetActivityTitle || !midSetOrientation || !midGetContext || !midInputGetInputDeviceIds ||
    5.39         !midSendMessage || !midShowTextInput || !midIsScreenKeyboardShown || 
    5.40         !midClipboardSetText || !midClipboardGetText || !midClipboardHasText) {
    5.41 -        __android_log_print(ANDROID_LOG_WARN, "SDL", "SDL: Couldn't locate Java callbacks, check that they're named and typed correctly");
    5.42 +        __android_log_print(ANDROID_LOG_WARN, "SDL", "Missing some Java callbacks, do you have the latest version of SDLActivity.java?");
    5.43      }
    5.44  
    5.45      fidSeparateMouseAndTouch = (*mEnv)->GetStaticFieldID(mEnv, mActivityClass, "mSeparateMouseAndTouch", "Z");
    5.46  
    5.47      if (!fidSeparateMouseAndTouch) {
    5.48 -        __android_log_print(ANDROID_LOG_WARN, "SDL", "SDL: Couldn't locate Java static fields, check that they're named and typed correctly");
    5.49 +        __android_log_print(ANDROID_LOG_WARN, "SDL", "Missing some Java static fields, do you have the latest version of SDLActivity.java?");
    5.50      }
    5.51  
    5.52 -    __android_log_print(ANDROID_LOG_INFO, "SDL", "SDL_Android_Init() finished!");
    5.53 +    SDL_SetMainReady();
    5.54 +}
    5.55 +
    5.56 +/* SDL main function prototype */
    5.57 +typedef int (*SDL_main_func)(int argc, char *argv[]);
    5.58 +
    5.59 +/* Start up the SDL app */
    5.60 +JNIEXPORT int JNICALL SDL_JAVA_INTERFACE(nativeRunMain)(JNIEnv* env, jclass cls, jstring library, jstring function, jobject array)
    5.61 +{
    5.62 +    int status = -1;
    5.63 +    const char *library_file;
    5.64 +    void *library_handle;
    5.65 +
    5.66 +    library_file = (*env)->GetStringUTFChars(env, library, NULL);
    5.67 +    library_handle = dlopen(library_file, RTLD_GLOBAL);
    5.68 +    if (library_handle) {
    5.69 +        const char *function_name;
    5.70 +        SDL_main_func SDL_main;
    5.71 +
    5.72 +        function_name = (*env)->GetStringUTFChars(env, function, NULL);
    5.73 +        SDL_main = (SDL_main_func)dlsym(library_handle, function_name);
    5.74 +        if (SDL_main) {
    5.75 +            int i;
    5.76 +            int argc;
    5.77 +            int len;
    5.78 +            char **argv;
    5.79 +
    5.80 +            /* Prepare the arguments. */
    5.81 +            len = (*env)->GetArrayLength(env, array);
    5.82 +            argv = SDL_stack_alloc(char*, 1 + len + 1);
    5.83 +            argc = 0;
    5.84 +            /* Use the name "app_process" so PHYSFS_platformCalcBaseDir() works.
    5.85 +               https://bitbucket.org/MartinFelis/love-android-sdl2/issue/23/release-build-crash-on-start
    5.86 +             */
    5.87 +            argv[argc++] = SDL_strdup("app_process");
    5.88 +            for (i = 0; i < len; ++i) {
    5.89 +                const char* utf;
    5.90 +                char* arg = NULL;
    5.91 +                jstring string = (*env)->GetObjectArrayElement(env, array, i);
    5.92 +                if (string) {
    5.93 +                    utf = (*env)->GetStringUTFChars(env, string, 0);
    5.94 +                    if (utf) {
    5.95 +                        arg = SDL_strdup(utf);
    5.96 +                        (*env)->ReleaseStringUTFChars(env, string, utf);
    5.97 +                    }
    5.98 +                    (*env)->DeleteLocalRef(env, string);
    5.99 +                }
   5.100 +                if (!arg) {
   5.101 +                    arg = SDL_strdup("");
   5.102 +                }
   5.103 +                argv[argc++] = arg;
   5.104 +            }
   5.105 +            argv[argc] = NULL;
   5.106 +
   5.107 +
   5.108 +            /* Run the application. */
   5.109 +            status = SDL_main(argc, argv);
   5.110 +
   5.111 +            /* Release the arguments. */
   5.112 +            for (i = 0; i < argc; ++i) {
   5.113 +                SDL_free(argv[i]);
   5.114 +            }
   5.115 +            SDL_stack_free(argv);
   5.116 +
   5.117 +        } else {
   5.118 +            __android_log_print(ANDROID_LOG_ERROR, "SDL", "nativeRunMain(): Couldn't find function %s in library %s", function_name, library_file);
   5.119 +        }
   5.120 +        (*env)->ReleaseStringUTFChars(env, function, function_name);
   5.121 +
   5.122 +        dlclose(library_handle);
   5.123 +
   5.124 +    } else {
   5.125 +        __android_log_print(ANDROID_LOG_ERROR, "SDL", "nativeRunMain(): Couldn't load library %s", library_file);
   5.126 +    }
   5.127 +    (*env)->ReleaseStringUTFChars(env, library, library_file);
   5.128 +
   5.129 +    /* Do not issue an exit or the whole application will terminate instead of just the SDL thread */
   5.130 +    /* exit(status); */
   5.131 +
   5.132 +    return status;
   5.133  }
   5.134  
   5.135  /* Drop file */
   5.136 @@ -548,6 +635,7 @@
   5.137                                      JNIEnv* env, jclass cls)
   5.138  {
   5.139      __android_log_print(ANDROID_LOG_VERBOSE, "SDL", "nativePause()");
   5.140 +
   5.141      if (Android_Window) {
   5.142          SDL_SendWindowEvent(Android_Window, SDL_WINDOWEVENT_FOCUS_LOST, 0, 0);
   5.143          SDL_SendWindowEvent(Android_Window, SDL_WINDOWEVENT_MINIMIZED, 0, 0);
     6.1 --- a/src/main/android/SDL_android_main.c	Mon Aug 28 13:40:32 2017 -0700
     6.2 +++ b/src/main/android/SDL_android_main.c	Mon Aug 28 14:34:15 2017 -0700
     6.3 @@ -1,88 +1,7 @@
     6.4  /*
     6.5      SDL_android_main.c, placed in the public domain by Sam Lantinga  3/13/14
     6.6 +
     6.7 +    As of SDL 2.0.6 this file is no longer necessary.
     6.8  */
     6.9  
    6.10 -#include "SDL_config.h"
    6.11 -#include "SDL.h"
    6.12 -
    6.13 -#ifdef __ANDROID__
    6.14 -
    6.15 -/* Include the SDL main definition header */
    6.16 -#include "SDL_main.h"
    6.17 -
    6.18 -/*******************************************************************************
    6.19 -                 Functions called by JNI
    6.20 -*******************************************************************************/
    6.21 -#include <jni.h>
    6.22 -
    6.23 -/* Dummy symbol so '-u SDL_main_dummy' forces ld to link in libSDL2main.a */
    6.24 -JNIEXPORT int SDL_main_dummy;
    6.25 -
    6.26 -/* Called before SDL_main() to initialize JNI bindings in SDL library */
    6.27 -extern void SDL_Android_Init(JNIEnv* env, jclass cls);
    6.28 -
    6.29 -/* This prototype is needed to prevent a warning about the missing prototype for global function below */
    6.30 -JNIEXPORT int JNICALL Java_org_libsdl_app_SDLActivity_nativeInit(JNIEnv* env, jclass cls, jobject array);
    6.31 -
    6.32 -/* Start up the SDL app */
    6.33 -JNIEXPORT int JNICALL Java_org_libsdl_app_SDLActivity_nativeInit(JNIEnv* env, jclass cls, jobject array)
    6.34 -{
    6.35 -    int i;
    6.36 -    int argc;
    6.37 -    int status;
    6.38 -    int len;
    6.39 -    char** argv;
    6.40 -
    6.41 -    /* This interface could expand with ABI negotiation, callbacks, etc. */
    6.42 -    SDL_Android_Init(env, cls);
    6.43 -
    6.44 -    SDL_SetMainReady();
    6.45 -
    6.46 -    /* Prepare the arguments. */
    6.47 -
    6.48 -    len = (*env)->GetArrayLength(env, array);
    6.49 -    argv = SDL_stack_alloc(char*, 1 + len + 1);
    6.50 -    argc = 0;
    6.51 -    /* Use the name "app_process" so PHYSFS_platformCalcBaseDir() works.
    6.52 -       https://bitbucket.org/MartinFelis/love-android-sdl2/issue/23/release-build-crash-on-start
    6.53 -     */
    6.54 -    argv[argc++] = SDL_strdup("app_process");
    6.55 -    for (i = 0; i < len; ++i) {
    6.56 -        const char* utf;
    6.57 -        char* arg = NULL;
    6.58 -        jstring string = (*env)->GetObjectArrayElement(env, array, i);
    6.59 -        if (string) {
    6.60 -            utf = (*env)->GetStringUTFChars(env, string, 0);
    6.61 -            if (utf) {
    6.62 -                arg = SDL_strdup(utf);
    6.63 -                (*env)->ReleaseStringUTFChars(env, string, utf);
    6.64 -            }
    6.65 -            (*env)->DeleteLocalRef(env, string);
    6.66 -        }
    6.67 -        if (!arg) {
    6.68 -            arg = SDL_strdup("");
    6.69 -        }
    6.70 -        argv[argc++] = arg;
    6.71 -    }
    6.72 -    argv[argc] = NULL;
    6.73 -
    6.74 -
    6.75 -    /* Run the application. */
    6.76 -
    6.77 -    status = SDL_main(argc, argv);
    6.78 -
    6.79 -    /* Release the arguments. */
    6.80 -
    6.81 -    for (i = 0; i < argc; ++i) {
    6.82 -        SDL_free(argv[i]);
    6.83 -    }
    6.84 -    SDL_stack_free(argv);
    6.85 -    /* Do not issue an exit or the whole application will terminate instead of just the SDL thread */
    6.86 -    /* exit(status); */
    6.87 -
    6.88 -    return status;
    6.89 -}
    6.90 -
    6.91 -#endif /* __ANDROID__ */
    6.92 -
    6.93  /* vi: set ts=4 sw=4 expandtab: */