Android: use the same naming for JNI env local variables
authorSylvain Becker <sylvain.becker@gmail.com>
Fri, 11 Jan 2019 15:36:16 +0100
changeset 12528e3fddfb03620
parent 12527 0aa9da921db6
child 12529 86c22cfe2d7d
Android: use the same naming for JNI env local variables
src/core/android/SDL_android.c
     1.1 --- a/src/core/android/SDL_android.c	Fri Jan 11 15:33:02 2019 +0100
     1.2 +++ b/src/core/android/SDL_android.c	Fri Jan 11 15:36:16 2019 +0100
     1.3 @@ -68,7 +68,7 @@
     1.4  
     1.5  /* Java class SDLActivity */
     1.6  JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeSetupJNI)(
     1.7 -        JNIEnv *mEnv, jclass cls);
     1.8 +        JNIEnv *env, jclass cls);
     1.9  
    1.10  JNIEXPORT int JNICALL SDL_JAVA_INTERFACE(nativeRunMain)(
    1.11          JNIEnv *env, jclass cls,
    1.12 @@ -350,7 +350,7 @@
    1.13  }
    1.14  
    1.15  /* Activity initialization -- called before SDL_main() to initialize JNI bindings */
    1.16 -JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeSetupJNI)(JNIEnv *mEnv, jclass cls)
    1.17 +JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeSetupJNI)(JNIEnv *env, jclass cls)
    1.18  {
    1.19      __android_log_print(ANDROID_LOG_VERBOSE, "SDL", "nativeSetupJNI()");
    1.20  
    1.21 @@ -367,57 +367,57 @@
    1.22  
    1.23      Android_JNI_SetupThread();
    1.24  
    1.25 -    mActivityClass = (jclass)((*mEnv)->NewGlobalRef(mEnv, cls));
    1.26 -
    1.27 -    midGetNativeSurface = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass,
    1.28 +    mActivityClass = (jclass)((*env)->NewGlobalRef(env, cls));
    1.29 +
    1.30 +    midGetNativeSurface = (*env)->GetStaticMethodID(env, mActivityClass,
    1.31                                  "getNativeSurface","()Landroid/view/Surface;");
    1.32 -    midSetSurfaceViewFormat = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass,
    1.33 +    midSetSurfaceViewFormat = (*env)->GetStaticMethodID(env, mActivityClass,
    1.34                                  "setSurfaceViewFormat","(I)V");
    1.35 -    midSetActivityTitle = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass,
    1.36 +    midSetActivityTitle = (*env)->GetStaticMethodID(env, mActivityClass,
    1.37                                  "setActivityTitle","(Ljava/lang/String;)Z");
    1.38 -    midSetWindowStyle = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass,
    1.39 +    midSetWindowStyle = (*env)->GetStaticMethodID(env, mActivityClass,
    1.40                                  "setWindowStyle","(Z)V");
    1.41 -    midSetOrientation = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass,
    1.42 +    midSetOrientation = (*env)->GetStaticMethodID(env, mActivityClass,
    1.43                                  "setOrientation","(IIZLjava/lang/String;)V");
    1.44 -    midGetContext = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass,
    1.45 +    midGetContext = (*env)->GetStaticMethodID(env, mActivityClass,
    1.46                                  "getContext","()Landroid/content/Context;");
    1.47 -    midIsTablet = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass,
    1.48 +    midIsTablet = (*env)->GetStaticMethodID(env, mActivityClass,
    1.49                                  "isTablet", "()Z");
    1.50 -    midIsAndroidTV = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass,
    1.51 +    midIsAndroidTV = (*env)->GetStaticMethodID(env, mActivityClass,
    1.52                                  "isAndroidTV","()Z");
    1.53 -    midIsChromebook = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass,
    1.54 +    midIsChromebook = (*env)->GetStaticMethodID(env, mActivityClass,
    1.55                                  "isChromebook", "()Z");
    1.56 -    midIsDeXMode = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass,
    1.57 +    midIsDeXMode = (*env)->GetStaticMethodID(env, mActivityClass,
    1.58                                  "isDeXMode", "()Z");
    1.59 -    midManualBackButton = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass,
    1.60 +    midManualBackButton = (*env)->GetStaticMethodID(env, mActivityClass,
    1.61                                  "manualBackButton", "()V");
    1.62 -    midInitTouch = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass,
    1.63 +    midInitTouch = (*env)->GetStaticMethodID(env, mActivityClass,
    1.64                                  "initTouch", "()V");
    1.65 -    midSendMessage = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass,
    1.66 +    midSendMessage = (*env)->GetStaticMethodID(env, mActivityClass,
    1.67                                  "sendMessage", "(II)Z");
    1.68 -    midShowTextInput =  (*mEnv)->GetStaticMethodID(mEnv, mActivityClass,
    1.69 +    midShowTextInput =  (*env)->GetStaticMethodID(env, mActivityClass,
    1.70                                  "showTextInput", "(IIII)Z");
    1.71 -    midIsScreenKeyboardShown = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass,
    1.72 +    midIsScreenKeyboardShown = (*env)->GetStaticMethodID(env, mActivityClass,
    1.73                                  "isScreenKeyboardShown","()Z");
    1.74 -    midClipboardSetText = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass,
    1.75 +    midClipboardSetText = (*env)->GetStaticMethodID(env, mActivityClass,
    1.76                                  "clipboardSetText", "(Ljava/lang/String;)V");
    1.77 -    midClipboardGetText = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass,
    1.78 +    midClipboardGetText = (*env)->GetStaticMethodID(env, mActivityClass,
    1.79                                  "clipboardGetText", "()Ljava/lang/String;");
    1.80 -    midClipboardHasText = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass,
    1.81 +    midClipboardHasText = (*env)->GetStaticMethodID(env, mActivityClass,
    1.82                                  "clipboardHasText", "()Z");
    1.83 -    midOpenAPKExpansionInputStream = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass,
    1.84 +    midOpenAPKExpansionInputStream = (*env)->GetStaticMethodID(env, mActivityClass,
    1.85                                  "openAPKExpansionInputStream", "(Ljava/lang/String;)Ljava/io/InputStream;");
    1.86  
    1.87 -    midGetManifestEnvironmentVariables = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass,
    1.88 +    midGetManifestEnvironmentVariables = (*env)->GetStaticMethodID(env, mActivityClass,
    1.89                                  "getManifestEnvironmentVariables", "()Z");
    1.90  
    1.91 -    midGetDisplayDPI = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass, "getDisplayDPI", "()Landroid/util/DisplayMetrics;");
    1.92 -    midCreateCustomCursor = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass, "createCustomCursor", "([IIIII)I");
    1.93 -    midSetCustomCursor = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass, "setCustomCursor", "(I)Z");
    1.94 -    midSetSystemCursor = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass, "setSystemCursor", "(I)Z");
    1.95 -
    1.96 -    midSupportsRelativeMouse = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass, "supportsRelativeMouse", "()Z");
    1.97 -    midSetRelativeMouseEnabled = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass, "setRelativeMouseEnabled", "(Z)Z");
    1.98 +    midGetDisplayDPI = (*env)->GetStaticMethodID(env, mActivityClass, "getDisplayDPI", "()Landroid/util/DisplayMetrics;");
    1.99 +    midCreateCustomCursor = (*env)->GetStaticMethodID(env, mActivityClass, "createCustomCursor", "([IIIII)I");
   1.100 +    midSetCustomCursor = (*env)->GetStaticMethodID(env, mActivityClass, "setCustomCursor", "(I)Z");
   1.101 +    midSetSystemCursor = (*env)->GetStaticMethodID(env, mActivityClass, "setSystemCursor", "(I)Z");
   1.102 +
   1.103 +    midSupportsRelativeMouse = (*env)->GetStaticMethodID(env, mActivityClass, "supportsRelativeMouse", "()Z");
   1.104 +    midSetRelativeMouseEnabled = (*env)->GetStaticMethodID(env, mActivityClass, "setRelativeMouseEnabled", "(Z)Z");
   1.105  
   1.106  
   1.107      if (!midGetNativeSurface || !midSetSurfaceViewFormat ||
   1.108 @@ -430,7 +430,7 @@
   1.109          __android_log_print(ANDROID_LOG_WARN, "SDL", "Missing some Java callbacks, do you have the latest version of SDLActivity.java?");
   1.110      }
   1.111  
   1.112 -    fidSeparateMouseAndTouch = (*mEnv)->GetStaticFieldID(mEnv, mActivityClass, "mSeparateMouseAndTouch", "Z");
   1.113 +    fidSeparateMouseAndTouch = (*env)->GetStaticFieldID(env, mActivityClass, "mSeparateMouseAndTouch", "Z");
   1.114  
   1.115      if (!fidSeparateMouseAndTouch) {
   1.116          __android_log_print(ANDROID_LOG_WARN, "SDL", "Missing some Java static fields, do you have the latest version of SDLActivity.java?");
   1.117 @@ -440,35 +440,35 @@
   1.118  }
   1.119  
   1.120  /* Audio initialization -- called before SDL_main() to initialize JNI bindings */
   1.121 -JNIEXPORT void JNICALL SDL_JAVA_AUDIO_INTERFACE(nativeSetupJNI)(JNIEnv *mEnv, jclass cls)
   1.122 +JNIEXPORT void JNICALL SDL_JAVA_AUDIO_INTERFACE(nativeSetupJNI)(JNIEnv *env, jclass cls)
   1.123  {
   1.124      __android_log_print(ANDROID_LOG_VERBOSE, "SDL", "AUDIO nativeSetupJNI()");
   1.125  
   1.126      Android_JNI_SetupThread();
   1.127  
   1.128 -    mAudioManagerClass = (jclass)((*mEnv)->NewGlobalRef(mEnv, cls));
   1.129 -
   1.130 -    midAudioOpen = (*mEnv)->GetStaticMethodID(mEnv, mAudioManagerClass,
   1.131 +    mAudioManagerClass = (jclass)((*env)->NewGlobalRef(env, cls));
   1.132 +
   1.133 +    midAudioOpen = (*env)->GetStaticMethodID(env, mAudioManagerClass,
   1.134                                  "audioOpen", "(IIII)[I");
   1.135 -    midAudioWriteByteBuffer = (*mEnv)->GetStaticMethodID(mEnv, mAudioManagerClass,
   1.136 +    midAudioWriteByteBuffer = (*env)->GetStaticMethodID(env, mAudioManagerClass,
   1.137                                  "audioWriteByteBuffer", "([B)V");
   1.138 -    midAudioWriteShortBuffer = (*mEnv)->GetStaticMethodID(mEnv, mAudioManagerClass,
   1.139 +    midAudioWriteShortBuffer = (*env)->GetStaticMethodID(env, mAudioManagerClass,
   1.140                                  "audioWriteShortBuffer", "([S)V");
   1.141 -    midAudioWriteFloatBuffer = (*mEnv)->GetStaticMethodID(mEnv, mAudioManagerClass,
   1.142 +    midAudioWriteFloatBuffer = (*env)->GetStaticMethodID(env, mAudioManagerClass,
   1.143                                  "audioWriteFloatBuffer", "([F)V");
   1.144 -    midAudioClose = (*mEnv)->GetStaticMethodID(mEnv, mAudioManagerClass,
   1.145 +    midAudioClose = (*env)->GetStaticMethodID(env, mAudioManagerClass,
   1.146                                  "audioClose", "()V");
   1.147 -    midCaptureOpen = (*mEnv)->GetStaticMethodID(mEnv, mAudioManagerClass,
   1.148 +    midCaptureOpen = (*env)->GetStaticMethodID(env, mAudioManagerClass,
   1.149                                  "captureOpen", "(IIII)[I");
   1.150 -    midCaptureReadByteBuffer = (*mEnv)->GetStaticMethodID(mEnv, mAudioManagerClass,
   1.151 +    midCaptureReadByteBuffer = (*env)->GetStaticMethodID(env, mAudioManagerClass,
   1.152                                  "captureReadByteBuffer", "([BZ)I");
   1.153 -    midCaptureReadShortBuffer = (*mEnv)->GetStaticMethodID(mEnv, mAudioManagerClass,
   1.154 +    midCaptureReadShortBuffer = (*env)->GetStaticMethodID(env, mAudioManagerClass,
   1.155                                  "captureReadShortBuffer", "([SZ)I");
   1.156 -    midCaptureReadFloatBuffer = (*mEnv)->GetStaticMethodID(mEnv, mAudioManagerClass,
   1.157 +    midCaptureReadFloatBuffer = (*env)->GetStaticMethodID(env, mAudioManagerClass,
   1.158                                  "captureReadFloatBuffer", "([FZ)I");
   1.159 -    midCaptureClose = (*mEnv)->GetStaticMethodID(mEnv, mAudioManagerClass,
   1.160 +    midCaptureClose = (*env)->GetStaticMethodID(env, mAudioManagerClass,
   1.161                                  "captureClose", "()V");
   1.162 -    midAudioSetThreadPriority = (*mEnv)->GetStaticMethodID(mEnv, mAudioManagerClass,
   1.163 +    midAudioSetThreadPriority = (*env)->GetStaticMethodID(env, mAudioManagerClass,
   1.164                                  "audioSetThreadPriority", "(ZI)V");
   1.165  
   1.166      if (!midAudioOpen || !midAudioWriteByteBuffer || !midAudioWriteShortBuffer || !midAudioWriteFloatBuffer || !midAudioClose ||
   1.167 @@ -480,21 +480,21 @@
   1.168  }
   1.169  
   1.170  /* Controller initialization -- called before SDL_main() to initialize JNI bindings */
   1.171 -JNIEXPORT void JNICALL SDL_JAVA_CONTROLLER_INTERFACE(nativeSetupJNI)(JNIEnv *mEnv, jclass cls)
   1.172 +JNIEXPORT void JNICALL SDL_JAVA_CONTROLLER_INTERFACE(nativeSetupJNI)(JNIEnv *env, jclass cls)
   1.173  {
   1.174      __android_log_print(ANDROID_LOG_VERBOSE, "SDL", "CONTROLLER nativeSetupJNI()");
   1.175  
   1.176      Android_JNI_SetupThread();
   1.177  
   1.178 -    mControllerManagerClass = (jclass)((*mEnv)->NewGlobalRef(mEnv, cls));
   1.179 -
   1.180 -    midPollInputDevices = (*mEnv)->GetStaticMethodID(mEnv, mControllerManagerClass,
   1.181 +    mControllerManagerClass = (jclass)((*env)->NewGlobalRef(env, cls));
   1.182 +
   1.183 +    midPollInputDevices = (*env)->GetStaticMethodID(env, mControllerManagerClass,
   1.184                                  "pollInputDevices", "()V");
   1.185 -    midPollHapticDevices = (*mEnv)->GetStaticMethodID(mEnv, mControllerManagerClass,
   1.186 +    midPollHapticDevices = (*env)->GetStaticMethodID(env, mControllerManagerClass,
   1.187                                  "pollHapticDevices", "()V");
   1.188 -    midHapticRun = (*mEnv)->GetStaticMethodID(mEnv, mControllerManagerClass,
   1.189 +    midHapticRun = (*env)->GetStaticMethodID(env, mControllerManagerClass,
   1.190                                  "hapticRun", "(IFI)V");
   1.191 -    midHapticStop = (*mEnv)->GetStaticMethodID(mEnv, mControllerManagerClass,
   1.192 +    midHapticStop = (*env)->GetStaticMethodID(env, mControllerManagerClass,
   1.193                                  "hapticStop", "(I)V");
   1.194  
   1.195      if (!midPollInputDevices || !midPollHapticDevices || !midHapticRun || !midHapticStop) {
   1.196 @@ -1087,7 +1087,7 @@
   1.197  
   1.198  void Android_JNI_SetSurfaceViewFormat(int format)
   1.199  {
   1.200 -    JNIEnv *mEnv = Android_JNI_GetEnv();
   1.201 +    JNIEnv *env = Android_JNI_GetEnv();
   1.202      int new_format = 0;
   1.203  
   1.204      /* Format from android/native_window.h,
   1.205 @@ -1102,31 +1102,31 @@
   1.206          new_format = 0;
   1.207      }
   1.208  
   1.209 -    (*mEnv)->CallStaticVoidMethod(mEnv, mActivityClass, midSetSurfaceViewFormat, new_format);
   1.210 +    (*env)->CallStaticVoidMethod(env, mActivityClass, midSetSurfaceViewFormat, new_format);
   1.211  }
   1.212  
   1.213  void Android_JNI_SetActivityTitle(const char *title)
   1.214  {
   1.215 -    JNIEnv *mEnv = Android_JNI_GetEnv();
   1.216 -
   1.217 -    jstring jtitle = (jstring)((*mEnv)->NewStringUTF(mEnv, title));
   1.218 -    (*mEnv)->CallStaticBooleanMethod(mEnv, mActivityClass, midSetActivityTitle, jtitle);
   1.219 -    (*mEnv)->DeleteLocalRef(mEnv, jtitle);
   1.220 +    JNIEnv *env = Android_JNI_GetEnv();
   1.221 +
   1.222 +    jstring jtitle = (jstring)((*env)->NewStringUTF(env, title));
   1.223 +    (*env)->CallStaticBooleanMethod(env, mActivityClass, midSetActivityTitle, jtitle);
   1.224 +    (*env)->DeleteLocalRef(env, jtitle);
   1.225  }
   1.226  
   1.227  void Android_JNI_SetWindowStyle(SDL_bool fullscreen)
   1.228  {
   1.229 -    JNIEnv *mEnv = Android_JNI_GetEnv();
   1.230 -    (*mEnv)->CallStaticVoidMethod(mEnv, mActivityClass, midSetWindowStyle, fullscreen ? 1 : 0);
   1.231 +    JNIEnv *env = Android_JNI_GetEnv();
   1.232 +    (*env)->CallStaticVoidMethod(env, mActivityClass, midSetWindowStyle, fullscreen ? 1 : 0);
   1.233  }
   1.234  
   1.235  void Android_JNI_SetOrientation(int w, int h, int resizable, const char *hint)
   1.236  {
   1.237 -    JNIEnv *mEnv = Android_JNI_GetEnv();
   1.238 -
   1.239 -    jstring jhint = (jstring)((*mEnv)->NewStringUTF(mEnv, (hint ? hint : "")));
   1.240 -    (*mEnv)->CallStaticVoidMethod(mEnv, mActivityClass, midSetOrientation, w, h, (resizable? 1 : 0), jhint);
   1.241 -    (*mEnv)->DeleteLocalRef(mEnv, jhint);
   1.242 +    JNIEnv *env = Android_JNI_GetEnv();
   1.243 +
   1.244 +    jstring jhint = (jstring)((*env)->NewStringUTF(env, (hint ? hint : "")));
   1.245 +    (*env)->CallStaticVoidMethod(env, mActivityClass, midSetOrientation, w, h, (resizable? 1 : 0), jhint);
   1.246 +    (*env)->DeleteLocalRef(env, jhint);
   1.247  }
   1.248  
   1.249  SDL_bool Android_JNI_GetAccelerometerValues(float values[3])
   1.250 @@ -1522,42 +1522,42 @@
   1.251  /* If the parameter silent is truthy then SDL_SetError() will not be called. */
   1.252  static SDL_bool Android_JNI_ExceptionOccurred(SDL_bool silent)
   1.253  {
   1.254 -    JNIEnv *mEnv = Android_JNI_GetEnv();
   1.255 +    JNIEnv *env = Android_JNI_GetEnv();
   1.256      jthrowable exception;
   1.257  
   1.258      /* Detect mismatch LocalReferenceHolder_Init/Cleanup */
   1.259      SDL_assert((s_active > 0));
   1.260  
   1.261 -    exception = (*mEnv)->ExceptionOccurred(mEnv);
   1.262 +    exception = (*env)->ExceptionOccurred(env);
   1.263      if (exception != NULL) {
   1.264          jmethodID mid;
   1.265  
   1.266          /* Until this happens most JNI operations have undefined behaviour */
   1.267 -        (*mEnv)->ExceptionClear(mEnv);
   1.268 +        (*env)->ExceptionClear(env);
   1.269  
   1.270          if (!silent) {
   1.271 -            jclass exceptionClass = (*mEnv)->GetObjectClass(mEnv, exception);
   1.272 -            jclass classClass = (*mEnv)->FindClass(mEnv, "java/lang/Class");
   1.273 +            jclass exceptionClass = (*env)->GetObjectClass(env, exception);
   1.274 +            jclass classClass = (*env)->FindClass(env, "java/lang/Class");
   1.275              jstring exceptionName;
   1.276              const char *exceptionNameUTF8;
   1.277              jstring exceptionMessage;
   1.278  
   1.279 -            mid = (*mEnv)->GetMethodID(mEnv, classClass, "getName", "()Ljava/lang/String;");
   1.280 -            exceptionName = (jstring)(*mEnv)->CallObjectMethod(mEnv, exceptionClass, mid);
   1.281 -            exceptionNameUTF8 = (*mEnv)->GetStringUTFChars(mEnv, exceptionName, 0);
   1.282 -
   1.283 -            mid = (*mEnv)->GetMethodID(mEnv, exceptionClass, "getMessage", "()Ljava/lang/String;");
   1.284 -            exceptionMessage = (jstring)(*mEnv)->CallObjectMethod(mEnv, exception, mid);
   1.285 +            mid = (*env)->GetMethodID(env, classClass, "getName", "()Ljava/lang/String;");
   1.286 +            exceptionName = (jstring)(*env)->CallObjectMethod(env, exceptionClass, mid);
   1.287 +            exceptionNameUTF8 = (*env)->GetStringUTFChars(env, exceptionName, 0);
   1.288 +
   1.289 +            mid = (*env)->GetMethodID(env, exceptionClass, "getMessage", "()Ljava/lang/String;");
   1.290 +            exceptionMessage = (jstring)(*env)->CallObjectMethod(env, exception, mid);
   1.291  
   1.292              if (exceptionMessage != NULL) {
   1.293 -                const char *exceptionMessageUTF8 = (*mEnv)->GetStringUTFChars(mEnv, exceptionMessage, 0);
   1.294 +                const char *exceptionMessageUTF8 = (*env)->GetStringUTFChars(env, exceptionMessage, 0);
   1.295                  SDL_SetError("%s: %s", exceptionNameUTF8, exceptionMessageUTF8);
   1.296 -                (*mEnv)->ReleaseStringUTFChars(mEnv, exceptionMessage, exceptionMessageUTF8);
   1.297 +                (*env)->ReleaseStringUTFChars(env, exceptionMessage, exceptionMessageUTF8);
   1.298              } else {
   1.299                  SDL_SetError("%s", exceptionNameUTF8);
   1.300              }
   1.301  
   1.302 -            (*mEnv)->ReleaseStringUTFChars(mEnv, exceptionName, exceptionNameUTF8);
   1.303 +            (*env)->ReleaseStringUTFChars(env, exceptionName, exceptionNameUTF8);
   1.304          }
   1.305  
   1.306          return SDL_TRUE;
   1.307 @@ -1583,8 +1583,8 @@
   1.308      jclass fdCls;
   1.309      jfieldID descriptor;
   1.310  
   1.311 -    JNIEnv *mEnv = Android_JNI_GetEnv();
   1.312 -    if (!LocalReferenceHolder_Init(&refs, mEnv)) {
   1.313 +    JNIEnv *env = Android_JNI_GetEnv();
   1.314 +    if (!LocalReferenceHolder_Init(&refs, env)) {
   1.315          goto failure;
   1.316      }
   1.317  
   1.318 @@ -1592,40 +1592,40 @@
   1.319      ctx->hidden.androidio.position = 0;
   1.320  
   1.321      /* context = SDLActivity.getContext(); */
   1.322 -    context = (*mEnv)->CallStaticObjectMethod(mEnv, mActivityClass, midGetContext);
   1.323 +    context = (*env)->CallStaticObjectMethod(env, mActivityClass, midGetContext);
   1.324  
   1.325      /* assetManager = context.getAssets(); */
   1.326 -    mid = (*mEnv)->GetMethodID(mEnv, (*mEnv)->GetObjectClass(mEnv, context),
   1.327 +    mid = (*env)->GetMethodID(env, (*env)->GetObjectClass(env, context),
   1.328              "getAssets", "()Landroid/content/res/AssetManager;");
   1.329 -    assetManager = (*mEnv)->CallObjectMethod(mEnv, context, mid);
   1.330 +    assetManager = (*env)->CallObjectMethod(env, context, mid);
   1.331  
   1.332      /* First let's try opening the file to obtain an AssetFileDescriptor.
   1.333      * This method reads the files directly from the APKs using standard *nix calls
   1.334      */
   1.335 -    mid = (*mEnv)->GetMethodID(mEnv, (*mEnv)->GetObjectClass(mEnv, assetManager), "openFd", "(Ljava/lang/String;)Landroid/content/res/AssetFileDescriptor;");
   1.336 -    inputStream = (*mEnv)->CallObjectMethod(mEnv, assetManager, mid, fileNameJString);
   1.337 +    mid = (*env)->GetMethodID(env, (*env)->GetObjectClass(env, assetManager), "openFd", "(Ljava/lang/String;)Landroid/content/res/AssetFileDescriptor;");
   1.338 +    inputStream = (*env)->CallObjectMethod(env, assetManager, mid, fileNameJString);
   1.339      if (Android_JNI_ExceptionOccurred(SDL_TRUE)) {
   1.340          goto fallback;
   1.341      }
   1.342  
   1.343 -    mid = (*mEnv)->GetMethodID(mEnv, (*mEnv)->GetObjectClass(mEnv, inputStream), "getStartOffset", "()J");
   1.344 -    ctx->hidden.androidio.offset = (long)(*mEnv)->CallLongMethod(mEnv, inputStream, mid);
   1.345 +    mid = (*env)->GetMethodID(env, (*env)->GetObjectClass(env, inputStream), "getStartOffset", "()J");
   1.346 +    ctx->hidden.androidio.offset = (long)(*env)->CallLongMethod(env, inputStream, mid);
   1.347      if (Android_JNI_ExceptionOccurred(SDL_TRUE)) {
   1.348          goto fallback;
   1.349      }
   1.350  
   1.351 -    mid = (*mEnv)->GetMethodID(mEnv, (*mEnv)->GetObjectClass(mEnv, inputStream), "getDeclaredLength", "()J");
   1.352 -    ctx->hidden.androidio.size = (long)(*mEnv)->CallLongMethod(mEnv, inputStream, mid);
   1.353 +    mid = (*env)->GetMethodID(env, (*env)->GetObjectClass(env, inputStream), "getDeclaredLength", "()J");
   1.354 +    ctx->hidden.androidio.size = (long)(*env)->CallLongMethod(env, inputStream, mid);
   1.355      if (Android_JNI_ExceptionOccurred(SDL_TRUE)) {
   1.356          goto fallback;
   1.357      }
   1.358  
   1.359 -    mid = (*mEnv)->GetMethodID(mEnv, (*mEnv)->GetObjectClass(mEnv, inputStream), "getFileDescriptor", "()Ljava/io/FileDescriptor;");
   1.360 -    fd = (*mEnv)->CallObjectMethod(mEnv, inputStream, mid);
   1.361 -    fdCls = (*mEnv)->GetObjectClass(mEnv, fd);
   1.362 -    descriptor = (*mEnv)->GetFieldID(mEnv, fdCls, "descriptor", "I");
   1.363 -    ctx->hidden.androidio.fd = (*mEnv)->GetIntField(mEnv, fd, descriptor);
   1.364 -    ctx->hidden.androidio.assetFileDescriptorRef = (*mEnv)->NewGlobalRef(mEnv, inputStream);
   1.365 +    mid = (*env)->GetMethodID(env, (*env)->GetObjectClass(env, inputStream), "getFileDescriptor", "()Ljava/io/FileDescriptor;");
   1.366 +    fd = (*env)->CallObjectMethod(env, inputStream, mid);
   1.367 +    fdCls = (*env)->GetObjectClass(env, fd);
   1.368 +    descriptor = (*env)->GetFieldID(env, fdCls, "descriptor", "I");
   1.369 +    ctx->hidden.androidio.fd = (*env)->GetIntField(env, fd, descriptor);
   1.370 +    ctx->hidden.androidio.assetFileDescriptorRef = (*env)->NewGlobalRef(env, inputStream);
   1.371  
   1.372      /* Seek to the correct offset in the file. */
   1.373      lseek(ctx->hidden.androidio.fd, (off_t)ctx->hidden.androidio.offset, SEEK_SET);
   1.374 @@ -1639,12 +1639,12 @@
   1.375          ctx->hidden.androidio.assetFileDescriptorRef = NULL;
   1.376  
   1.377          /* inputStream = assetManager.open(<filename>); */
   1.378 -        mid = (*mEnv)->GetMethodID(mEnv, (*mEnv)->GetObjectClass(mEnv, assetManager),
   1.379 +        mid = (*env)->GetMethodID(env, (*env)->GetObjectClass(env, assetManager),
   1.380                  "open", "(Ljava/lang/String;I)Ljava/io/InputStream;");
   1.381 -        inputStream = (*mEnv)->CallObjectMethod(mEnv, assetManager, mid, fileNameJString, 1 /* ACCESS_RANDOM */);
   1.382 +        inputStream = (*env)->CallObjectMethod(env, assetManager, mid, fileNameJString, 1 /* ACCESS_RANDOM */);
   1.383          if (Android_JNI_ExceptionOccurred(SDL_FALSE)) {
   1.384              /* Try fallback to APK expansion files */
   1.385 -            inputStream = (*mEnv)->CallStaticObjectMethod(mEnv, mActivityClass, midOpenAPKExpansionInputStream, fileNameJString);
   1.386 +            inputStream = (*env)->CallStaticObjectMethod(env, mActivityClass, midOpenAPKExpansionInputStream, fileNameJString);
   1.387  
   1.388              /* Exception is checked first because it always needs to be cleared.
   1.389               * If no exception occurred then the last SDL error message is kept.
   1.390 @@ -1654,7 +1654,7 @@
   1.391              }
   1.392          }
   1.393  
   1.394 -        ctx->hidden.androidio.inputStreamRef = (*mEnv)->NewGlobalRef(mEnv, inputStream);
   1.395 +        ctx->hidden.androidio.inputStreamRef = (*env)->NewGlobalRef(env, inputStream);
   1.396  
   1.397          /* Despite all the visible documentation on [Asset]InputStream claiming
   1.398           * that the .available() method is not guaranteed to return the entire file
   1.399 @@ -1664,29 +1664,29 @@
   1.400          */
   1.401  
   1.402          /* size = inputStream.available(); */
   1.403 -        mid = (*mEnv)->GetMethodID(mEnv, (*mEnv)->GetObjectClass(mEnv, inputStream),
   1.404 +        mid = (*env)->GetMethodID(env, (*env)->GetObjectClass(env, inputStream),
   1.405                  "available", "()I");
   1.406 -        ctx->hidden.androidio.size = (long)(*mEnv)->CallIntMethod(mEnv, inputStream, mid);
   1.407 +        ctx->hidden.androidio.size = (long)(*env)->CallIntMethod(env, inputStream, mid);
   1.408          if (Android_JNI_ExceptionOccurred(SDL_FALSE)) {
   1.409              goto failure;
   1.410          }
   1.411  
   1.412          /* readableByteChannel = Channels.newChannel(inputStream); */
   1.413 -        channels = (*mEnv)->FindClass(mEnv, "java/nio/channels/Channels");
   1.414 -        mid = (*mEnv)->GetStaticMethodID(mEnv, channels,
   1.415 +        channels = (*env)->FindClass(env, "java/nio/channels/Channels");
   1.416 +        mid = (*env)->GetStaticMethodID(env, channels,
   1.417                  "newChannel",
   1.418                  "(Ljava/io/InputStream;)Ljava/nio/channels/ReadableByteChannel;");
   1.419 -        readableByteChannel = (*mEnv)->CallStaticObjectMethod(
   1.420 -                mEnv, channels, mid, inputStream);
   1.421 +        readableByteChannel = (*env)->CallStaticObjectMethod(
   1.422 +                env, channels, mid, inputStream);
   1.423          if (Android_JNI_ExceptionOccurred(SDL_FALSE)) {
   1.424              goto failure;
   1.425          }
   1.426  
   1.427          ctx->hidden.androidio.readableByteChannelRef =
   1.428 -            (*mEnv)->NewGlobalRef(mEnv, readableByteChannel);
   1.429 +            (*env)->NewGlobalRef(env, readableByteChannel);
   1.430  
   1.431          /* Store .read id for reading purposes */
   1.432 -        mid = (*mEnv)->GetMethodID(mEnv, (*mEnv)->GetObjectClass(mEnv, readableByteChannel),
   1.433 +        mid = (*env)->GetMethodID(env, (*env)->GetObjectClass(env, readableByteChannel),
   1.434                  "read", "(Ljava/nio/ByteBuffer;)I");
   1.435          ctx->hidden.androidio.readMethod = mid;
   1.436      }
   1.437 @@ -1695,18 +1695,18 @@
   1.438  failure:
   1.439          result = -1;
   1.440  
   1.441 -        (*mEnv)->DeleteGlobalRef(mEnv, (jobject)ctx->hidden.androidio.fileNameRef);
   1.442 +        (*env)->DeleteGlobalRef(env, (jobject)ctx->hidden.androidio.fileNameRef);
   1.443  
   1.444          if(ctx->hidden.androidio.inputStreamRef != NULL) {
   1.445 -            (*mEnv)->DeleteGlobalRef(mEnv, (jobject)ctx->hidden.androidio.inputStreamRef);
   1.446 +            (*env)->DeleteGlobalRef(env, (jobject)ctx->hidden.androidio.inputStreamRef);
   1.447          }
   1.448  
   1.449          if(ctx->hidden.androidio.readableByteChannelRef != NULL) {
   1.450 -            (*mEnv)->DeleteGlobalRef(mEnv, (jobject)ctx->hidden.androidio.readableByteChannelRef);
   1.451 +            (*env)->DeleteGlobalRef(env, (jobject)ctx->hidden.androidio.readableByteChannelRef);
   1.452          }
   1.453  
   1.454          if(ctx->hidden.androidio.assetFileDescriptorRef != NULL) {
   1.455 -            (*mEnv)->DeleteGlobalRef(mEnv, (jobject)ctx->hidden.androidio.assetFileDescriptorRef);
   1.456 +            (*env)->DeleteGlobalRef(env, (jobject)ctx->hidden.androidio.assetFileDescriptorRef);
   1.457          }
   1.458  
   1.459      }
   1.460 @@ -1719,11 +1719,11 @@
   1.461          const char *fileName, const char *mode)
   1.462  {
   1.463      struct LocalReferenceHolder refs = LocalReferenceHolder_Setup(__FUNCTION__);
   1.464 -    JNIEnv *mEnv = Android_JNI_GetEnv();
   1.465 +    JNIEnv *env = Android_JNI_GetEnv();
   1.466      int retval;
   1.467      jstring fileNameJString;
   1.468  
   1.469 -    if (!LocalReferenceHolder_Init(&refs, mEnv)) {
   1.470 +    if (!LocalReferenceHolder_Init(&refs, env)) {
   1.471          LocalReferenceHolder_Cleanup(&refs);
   1.472          return -1;
   1.473      }
   1.474 @@ -1733,8 +1733,8 @@
   1.475          return -1;
   1.476      }
   1.477  
   1.478 -    fileNameJString = (*mEnv)->NewStringUTF(mEnv, fileName);
   1.479 -    ctx->hidden.androidio.fileNameRef = (*mEnv)->NewGlobalRef(mEnv, fileNameJString);
   1.480 +    fileNameJString = (*env)->NewStringUTF(env, fileName);
   1.481 +    ctx->hidden.androidio.fileNameRef = (*env)->NewGlobalRef(env, fileNameJString);
   1.482      ctx->hidden.androidio.inputStreamRef = NULL;
   1.483      ctx->hidden.androidio.readableByteChannelRef = NULL;
   1.484      ctx->hidden.androidio.readMethod = NULL;
   1.485 @@ -1768,7 +1768,7 @@
   1.486          jlong bytesRemaining = (jlong) (size * maxnum);
   1.487          jlong bytesMax = (jlong) (ctx->hidden.androidio.size -  ctx->hidden.androidio.position);
   1.488          int bytesRead = 0;
   1.489 -        JNIEnv *mEnv;
   1.490 +        JNIEnv *env;
   1.491          jobject readableByteChannel;
   1.492          jmethodID readMethod;
   1.493          jobject byteBuffer;
   1.494 @@ -1776,19 +1776,19 @@
   1.495          /* Don't read more bytes than those that remain in the file, otherwise we get an exception */
   1.496          if (bytesRemaining >  bytesMax) bytesRemaining = bytesMax;
   1.497  
   1.498 -        mEnv = Android_JNI_GetEnv();
   1.499 -        if (!LocalReferenceHolder_Init(&refs, mEnv)) {
   1.500 +        env = Android_JNI_GetEnv();
   1.501 +        if (!LocalReferenceHolder_Init(&refs, env)) {
   1.502              LocalReferenceHolder_Cleanup(&refs);
   1.503              return 0;
   1.504          }
   1.505  
   1.506          readableByteChannel = (jobject)ctx->hidden.androidio.readableByteChannelRef;
   1.507          readMethod = (jmethodID)ctx->hidden.androidio.readMethod;
   1.508 -        byteBuffer = (*mEnv)->NewDirectByteBuffer(mEnv, buffer, bytesRemaining);
   1.509 +        byteBuffer = (*env)->NewDirectByteBuffer(env, buffer, bytesRemaining);
   1.510  
   1.511          while (bytesRemaining > 0) {
   1.512              /* result = readableByteChannel.read(...); */
   1.513 -            int result = (*mEnv)->CallIntMethod(mEnv, readableByteChannel, readMethod, byteBuffer);
   1.514 +            int result = (*env)->CallIntMethod(env, readableByteChannel, readMethod, byteBuffer);
   1.515  
   1.516              if (Android_JNI_ExceptionOccurred(SDL_FALSE)) {
   1.517                  LocalReferenceHolder_Cleanup(&refs);
   1.518 @@ -1820,24 +1820,24 @@
   1.519      struct LocalReferenceHolder refs = LocalReferenceHolder_Setup(__FUNCTION__);
   1.520  
   1.521      int result = 0;
   1.522 -    JNIEnv *mEnv = Android_JNI_GetEnv();
   1.523 -
   1.524 -    if (!LocalReferenceHolder_Init(&refs, mEnv)) {
   1.525 +    JNIEnv *env = Android_JNI_GetEnv();
   1.526 +
   1.527 +    if (!LocalReferenceHolder_Init(&refs, env)) {
   1.528          LocalReferenceHolder_Cleanup(&refs);
   1.529          return SDL_SetError("Failed to allocate enough JVM local references");
   1.530      }
   1.531  
   1.532      if (ctx) {
   1.533          if (release) {
   1.534 -            (*mEnv)->DeleteGlobalRef(mEnv, (jobject)ctx->hidden.androidio.fileNameRef);
   1.535 +            (*env)->DeleteGlobalRef(env, (jobject)ctx->hidden.androidio.fileNameRef);
   1.536          }
   1.537  
   1.538          if (ctx->hidden.androidio.assetFileDescriptorRef) {
   1.539              jobject inputStream = (jobject)ctx->hidden.androidio.assetFileDescriptorRef;
   1.540 -            jmethodID mid = (*mEnv)->GetMethodID(mEnv, (*mEnv)->GetObjectClass(mEnv, inputStream),
   1.541 +            jmethodID mid = (*env)->GetMethodID(env, (*env)->GetObjectClass(env, inputStream),
   1.542                      "close", "()V");
   1.543 -            (*mEnv)->CallVoidMethod(mEnv, inputStream, mid);
   1.544 -            (*mEnv)->DeleteGlobalRef(mEnv, (jobject)ctx->hidden.androidio.assetFileDescriptorRef);
   1.545 +            (*env)->CallVoidMethod(env, inputStream, mid);
   1.546 +            (*env)->DeleteGlobalRef(env, (jobject)ctx->hidden.androidio.assetFileDescriptorRef);
   1.547              if (Android_JNI_ExceptionOccurred(SDL_FALSE)) {
   1.548                  result = -1;
   1.549              }
   1.550 @@ -1846,11 +1846,11 @@
   1.551              jobject inputStream = (jobject)ctx->hidden.androidio.inputStreamRef;
   1.552  
   1.553              /* inputStream.close(); */
   1.554 -            jmethodID mid = (*mEnv)->GetMethodID(mEnv, (*mEnv)->GetObjectClass(mEnv, inputStream),
   1.555 +            jmethodID mid = (*env)->GetMethodID(env, (*env)->GetObjectClass(env, inputStream),
   1.556                      "close", "()V");
   1.557 -            (*mEnv)->CallVoidMethod(mEnv, inputStream, mid);
   1.558 -            (*mEnv)->DeleteGlobalRef(mEnv, (jobject)ctx->hidden.androidio.inputStreamRef);
   1.559 -            (*mEnv)->DeleteGlobalRef(mEnv, (jobject)ctx->hidden.androidio.readableByteChannelRef);
   1.560 +            (*env)->CallVoidMethod(env, inputStream, mid);
   1.561 +            (*env)->DeleteGlobalRef(env, (jobject)ctx->hidden.androidio.inputStreamRef);
   1.562 +            (*env)->DeleteGlobalRef(env, (jobject)ctx->hidden.androidio.readableByteChannelRef);
   1.563              if (Android_JNI_ExceptionOccurred(SDL_FALSE)) {
   1.564                  result = -1;
   1.565              }
   1.566 @@ -2189,9 +2189,9 @@
   1.567  
   1.568  SDL_bool Android_JNI_IsScreenKeyboardShown()
   1.569  {
   1.570 -    JNIEnv *mEnv = Android_JNI_GetEnv();
   1.571 +    JNIEnv *env = Android_JNI_GetEnv();
   1.572      jboolean is_shown = 0;
   1.573 -    is_shown = (*mEnv)->CallStaticBooleanMethod(mEnv, mActivityClass, midIsScreenKeyboardShown);
   1.574 +    is_shown = (*env)->CallStaticBooleanMethod(env, mActivityClass, midIsScreenKeyboardShown);
   1.575      return is_shown;
   1.576  }
   1.577  
   1.578 @@ -2492,14 +2492,14 @@
   1.579  
   1.580  int Android_JNI_CreateCustomCursor(SDL_Surface *surface, int hot_x, int hot_y)
   1.581  {
   1.582 -    JNIEnv *mEnv = Android_JNI_GetEnv();
   1.583 +    JNIEnv *env = Android_JNI_GetEnv();
   1.584      int custom_cursor = 0;
   1.585      jintArray pixels;
   1.586 -    pixels = (*mEnv)->NewIntArray(mEnv, surface->w * surface->h);
   1.587 +    pixels = (*env)->NewIntArray(env, surface->w * surface->h);
   1.588      if (pixels) {
   1.589 -        (*mEnv)->SetIntArrayRegion(mEnv, pixels, 0, surface->w * surface->h, (int *)surface->pixels);
   1.590 -        custom_cursor = (*mEnv)->CallStaticIntMethod(mEnv, mActivityClass, midCreateCustomCursor, pixels, surface->w, surface->h, hot_x, hot_y);
   1.591 -        (*mEnv)->DeleteLocalRef(mEnv, pixels);
   1.592 +        (*env)->SetIntArrayRegion(env, pixels, 0, surface->w * surface->h, (int *)surface->pixels);
   1.593 +        custom_cursor = (*env)->CallStaticIntMethod(env, mActivityClass, midCreateCustomCursor, pixels, surface->w, surface->h, hot_x, hot_y);
   1.594 +        (*env)->DeleteLocalRef(env, pixels);
   1.595      } else {
   1.596          SDL_OutOfMemory();
   1.597      }
   1.598 @@ -2509,26 +2509,26 @@
   1.599  
   1.600  SDL_bool Android_JNI_SetCustomCursor(int cursorID)
   1.601  {
   1.602 -    JNIEnv *mEnv = Android_JNI_GetEnv();
   1.603 -    return (*mEnv)->CallStaticBooleanMethod(mEnv, mActivityClass, midSetCustomCursor, cursorID);
   1.604 +    JNIEnv *env = Android_JNI_GetEnv();
   1.605 +    return (*env)->CallStaticBooleanMethod(env, mActivityClass, midSetCustomCursor, cursorID);
   1.606  }
   1.607  
   1.608  SDL_bool Android_JNI_SetSystemCursor(int cursorID)
   1.609  {
   1.610 -    JNIEnv *mEnv = Android_JNI_GetEnv();
   1.611 -    return (*mEnv)->CallStaticBooleanMethod(mEnv, mActivityClass, midSetSystemCursor, cursorID);
   1.612 +    JNIEnv *env = Android_JNI_GetEnv();
   1.613 +    return (*env)->CallStaticBooleanMethod(env, mActivityClass, midSetSystemCursor, cursorID);
   1.614  }
   1.615  
   1.616  SDL_bool Android_JNI_SupportsRelativeMouse()
   1.617  {
   1.618 -    JNIEnv *mEnv = Android_JNI_GetEnv();
   1.619 -    return (*mEnv)->CallStaticBooleanMethod(mEnv, mActivityClass, midSupportsRelativeMouse);
   1.620 +    JNIEnv *env = Android_JNI_GetEnv();
   1.621 +    return (*env)->CallStaticBooleanMethod(env, mActivityClass, midSupportsRelativeMouse);
   1.622  }
   1.623  
   1.624  SDL_bool Android_JNI_SetRelativeMouseEnabled(SDL_bool enabled)
   1.625  {
   1.626 -    JNIEnv *mEnv = Android_JNI_GetEnv();
   1.627 -    return (*mEnv)->CallStaticBooleanMethod(mEnv, mActivityClass, midSetRelativeMouseEnabled, (enabled == 1));
   1.628 +    JNIEnv *env = Android_JNI_GetEnv();
   1.629 +    return (*env)->CallStaticBooleanMethod(env, mActivityClass, midSetRelativeMouseEnabled, (enabled == 1));
   1.630  }
   1.631  
   1.632