SDL: Revert "Use the correct return type for SDL_GetAndroidJNIEnv()"

From 153f90a7256a5a22babbbf0554775822cbf6c59e Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Sat, 19 Oct 2024 10:17:33 -0700
Subject: [PATCH] Revert "Use the correct return type for
 SDL_GetAndroidJNIEnv()"
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This reverts commit 2d3fa03d53b419bed2647cab2574ae27e9889586.

Different JDK implementations define JNIEnv differently for C++, so we can't provide the definition here.

Fixes:
/usr/lib/jvm/temurin-11-jdk-amd64/include/jni.h:195:17: error: conflicting declaration ‘typedef struct JNIEnv_ JNIEnv’
/home/runner/work/sdlwiki/sdlwiki/.github/../external/SDL3/include/SDL3/SDL_system.h:266:24: note: previous declaration as ‘typedef struct _JNIEnv JNIEnv’
---
 include/SDL3/SDL_system.h       |  9 +--------
 src/core/SDL_core_unsupported.c |  4 ++--
 src/core/android/SDL_android.c  |  2 +-
 src/dynapi/SDL_dynapi_procs.h   |  2 +-
 src/hidapi/android/hid.cpp      | 12 ++++++------
 5 files changed, 11 insertions(+), 18 deletions(-)

diff --git a/include/SDL3/SDL_system.h b/include/SDL3/SDL_system.h
index 8f92b615da402..6d3e61a403d89 100644
--- a/include/SDL3/SDL_system.h
+++ b/include/SDL3/SDL_system.h
@@ -261,13 +261,6 @@ extern SDL_DECLSPEC void SDLCALL SDL_SetiOSEventPump(bool enabled);
 /*
  * Platform specific functions for Android
  */
-
-#if defined(__cplusplus)
-typedef struct _JNIEnv JNIEnv;
-#else
-typedef const struct JNINativeInterface* JNIEnv;
-#endif
-
 #ifdef SDL_PLATFORM_ANDROID
 
 /**
@@ -290,7 +283,7 @@ typedef const struct JNINativeInterface* JNIEnv;
  *
  * \sa SDL_GetAndroidActivity
  */
-extern SDL_DECLSPEC JNIEnv * SDLCALL SDL_GetAndroidJNIEnv(void);
+extern SDL_DECLSPEC void * SDLCALL SDL_GetAndroidJNIEnv(void);
 
 /**
  * Retrieve the Java instance of the Android activity class.
diff --git a/src/core/SDL_core_unsupported.c b/src/core/SDL_core_unsupported.c
index 54fa095a85bdc..b36c7f7441ec7 100644
--- a/src/core/SDL_core_unsupported.c
+++ b/src/core/SDL_core_unsupported.c
@@ -146,8 +146,8 @@ const char *SDL_GetAndroidInternalStoragePath(void)
     return NULL;
 }
 
-SDL_DECLSPEC JNIEnv *SDLCALL SDL_GetAndroidJNIEnv(void);
-JNIEnv *SDL_GetAndroidJNIEnv(void)
+SDL_DECLSPEC void *SDLCALL SDL_GetAndroidJNIEnv(void);
+void *SDL_GetAndroidJNIEnv(void)
 {
     SDL_Unsupported();
     return NULL;
diff --git a/src/core/android/SDL_android.c b/src/core/android/SDL_android.c
index 7f8b56ee88349..78d8b71941e1c 100644
--- a/src/core/android/SDL_android.c
+++ b/src/core/android/SDL_android.c
@@ -2177,7 +2177,7 @@ bool Android_JNI_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *b
 //////////////////////////////////////////////////////////////////////////////
 */
 
-JNIEnv *SDL_GetAndroidJNIEnv(void)
+void *SDL_GetAndroidJNIEnv(void)
 {
     return Android_JNI_GetEnv();
 }
diff --git a/src/dynapi/SDL_dynapi_procs.h b/src/dynapi/SDL_dynapi_procs.h
index 165de3c0640fb..f308ce52efc38 100644
--- a/src/dynapi/SDL_dynapi_procs.h
+++ b/src/dynapi/SDL_dynapi_procs.h
@@ -255,7 +255,7 @@ SDL_DYNAPI_PROC(const char*,SDL_GetAndroidCachePath,(void),(),return)
 SDL_DYNAPI_PROC(const char*,SDL_GetAndroidExternalStoragePath,(void),(),return)
 SDL_DYNAPI_PROC(Uint32,SDL_GetAndroidExternalStorageState,(void),(),return)
 SDL_DYNAPI_PROC(const char*,SDL_GetAndroidInternalStoragePath,(void),(),return)
-SDL_DYNAPI_PROC(JNIEnv*,SDL_GetAndroidJNIEnv,(void),(),return)
+SDL_DYNAPI_PROC(void*,SDL_GetAndroidJNIEnv,(void),(),return)
 SDL_DYNAPI_PROC(int,SDL_GetAndroidSDKVersion,(void),(),return)
 SDL_DYNAPI_PROC(const char*,SDL_GetAppMetadataProperty,(const char *a),(a),return)
 SDL_DYNAPI_PROC(SDL_AssertionHandler,SDL_GetAssertionHandler,(void **a),(a),return)
diff --git a/src/hidapi/android/hid.cpp b/src/hidapi/android/hid.cpp
index 86040d655f54e..13f312921ab96 100644
--- a/src/hidapi/android/hid.cpp
+++ b/src/hidapi/android/hid.cpp
@@ -492,7 +492,7 @@ class CHIDDevice
 
 	bool BOpen()
 	{
-		JNIEnv *env = SDL_GetAndroidJNIEnv();
+		JNIEnv *env = (JNIEnv *)SDL_GetAndroidJNIEnv();
 
 		if ( !g_HIDDeviceManagerCallbackHandler )
 		{
@@ -624,7 +624,7 @@ class CHIDDevice
 
 	int WriteReport( const unsigned char *pData, size_t nDataLen, bool bFeature )
 	{
-		JNIEnv *env = SDL_GetAndroidJNIEnv();
+		JNIEnv *env = (JNIEnv *)SDL_GetAndroidJNIEnv();
 
 		if ( !g_HIDDeviceManagerCallbackHandler )
 		{
@@ -654,7 +654,7 @@ class CHIDDevice
 
 	int ReadReport( unsigned char *pData, size_t nDataLen, bool bFeature )
 	{
-		JNIEnv *env = SDL_GetAndroidJNIEnv();
+		JNIEnv *env = (JNIEnv *)SDL_GetAndroidJNIEnv();
 
 		if ( !g_HIDDeviceManagerCallbackHandler )
 		{
@@ -727,7 +727,7 @@ class CHIDDevice
 
 	void Close( bool bDeleteDevice )
 	{
-		JNIEnv *env = SDL_GetAndroidJNIEnv();
+		JNIEnv *env = (JNIEnv *)SDL_GetAndroidJNIEnv();
 
 		if ( g_HIDDeviceManagerCallbackHandler )
 		{
@@ -1022,7 +1022,7 @@ static void SDLCALL RequestBluetoothPermissionCallback( void *userdata, const ch
 
 	if ( granted && g_HIDDeviceManagerCallbackHandler )
 	{
-		JNIEnv *env = SDL_GetAndroidJNIEnv();
+		JNIEnv *env = (JNIEnv *)SDL_GetAndroidJNIEnv();
 
 		env->CallBooleanMethod( g_HIDDeviceManagerCallbackHandler, g_midHIDDeviceManagerInitialize, false, true );
 	}
@@ -1035,7 +1035,7 @@ int hid_init(void)
 		// HIDAPI doesn't work well with Android < 4.3
 		if ( SDL_GetAndroidSDKVersion() >= 18 )
 		{
-			JNIEnv *env = SDL_GetAndroidJNIEnv();
+			JNIEnv *env = (JNIEnv *)SDL_GetAndroidJNIEnv();
 
 			env->CallBooleanMethod( g_HIDDeviceManagerCallbackHandler, g_midHIDDeviceManagerInitialize, true, false );