src/core/android/SDL_android.c


Log

Author Commit Date CI Message
Sam Lantinga 0ad65277 2022-06-29T17:26:09 Refactored code to send scancodes for an ASCII on-screen keyboard key
Sam Lantinga fd2a2eea 2022-05-28T07:49:18 Fixed declaration-after-statement warning
Guus Waals 7495b981 2022-03-11T15:14:51 Make SDL_VIDEO_OPENGL_EGL optional on Android
Sylvain fe2ed6cf 2022-02-01T11:30:43 Fixed bug #5221 - Add SDL_AndroidSendMessage()
Sam Lantinga 120c76c8 2022-01-03T09:40:00 Updated copyright for 2022
Sylvain a1e992b1 2021-12-21T22:07:17 Fixed bug #5118 - [Android] PointerIcon leak in Cursor API
Sam Lantinga be5b4d98 2021-11-15T16:52:54 Added nativeGetHintBoolean for Java code
Sam Lantinga c2dd50a9 2021-11-12T08:28:02 Fixed whitespace
Sylvain 8b1a2fe8 2021-10-17T23:47:59 backout SDL_AndroidSetInputType()
Sylvain ccb12457 2021-10-17T23:17:54 Fixed bug #4843 - Can not get the ime candidatelist like chinese/japaness input method
Sylvain 98a966d1 2021-04-22T18:06:17 Android: don't need to set the SurfaceHolder format from java code It's already set with ANativeWindow_setGeometry, and eventually set/changed also by eglCreateWindowSurface. - avoid issues with older device where SurfaceView cycle create/changed/destroy appears broken: calling create/changed/changed, and leading to "deuqueBuffer failed at server side, error: -19", with black screen. - re-read the format after egl window surface is created, to report the correct one (sometimes, changed from RGBA8888 to RGB24)
Amir 1a924bc0 2021-02-19T12:54:57 add SDL_AndroidShowToast for https://developer.android.com/reference/android/widget/Toast
Sam Lantinga 9130f7c3 2021-01-02T10:25:38 Updated copyright for 2021
Sam Lantinga cb361896 2020-12-09T07:16:22 Fixed bug 5235 - All internal sources should include SDL_assert.h Ryan C. Gordon We should really stick this in SDL_internal.h or something so it's always available.
Ryan C. Gordon 2d82cf78 2020-10-05T13:59:03 url: put the Android bits in core/android
Ryan C. Gordon efd665e2 2020-10-05T13:56:45 Backed out changeset a43cb4e54949 Trying this a different way.
Ryan C. Gordon 5f688122 2020-10-05T13:52:52 url: patched to compile on Android.
Ryan C. Gordon 77c9d73b 2020-10-05T11:30:33 Removed SDL_AndroidOpenURL, added SDL_OpenURL. Still needs to be wired into Xcode and Visual Studio projects.
Sylvain Becker dd55bfe8 2020-10-01T14:41:09 Android: add helper function to open an URL/URI (see bug 2783)
Sylvain Becker 97fad045 2020-09-02T19:38:03 Fixed bug 5278 - export SDL_AndroidRequestPermission() (Thanks Huki!)
Sylvain Becker 965b466e 2020-08-17T19:50:20 Fixed bug 4297 - Android StrictMode policy. Remove APK expansion support "In the second half of 2021, new apps will be required to publish with the Android App Bundle on Google Play" (see https://developer.android.com/guide/app-bundle) And "Android App Bundles don't support APK expansion (*.obb) files".
Sylvain Becker 2491f16f 2020-05-08T21:40:28 Android: send SDL_LOCALECHANGED when locale changes
Sylvain Becker 0059ace0 2020-05-08T11:00:51 Android: factorize asset manager code (bug 2131 and 4297)
Ryan C. Gordon fa23e3d0 2020-05-04T02:27:29 locale: Implemented SDL_GetPreferredLocales(). This was something I proposed a long time ago, Sylvain Becker did additional work on it, then back to me. Fixes Bugzilla #2131.
Sam Lantinga b6afbe63 2020-04-07T09:38:57 Added SDL_log.h to SDL_internal.h so logging is available everywhere
Sam Lantinga b4312864 2020-02-13T10:19:05 Resolved conflict and added Android_JNI_RequestPermission()
Sylvain Becker 005e2dff 2020-01-17T12:41:54 Android: prevents rare crashes when app goes to background or ends. Make sure the thread is actually paused, and context backep-up, before SurfaceView is destroyed (eg surfaceDestroyed() actually returns). Add a timeout when surfaceDestroyed() is called, and check 'backup_done' variable. It prevents crashes like: #00 pc 000000000000c0d0 /system/lib64/libutils.so (android::RefBase::incStrong(void const*) const+8) #01 pc 000000000000c7f4 /vendor/lib64/egl/eglSubDriverAndroid.so (EglAndroidWindowSurface::UpdateBufferList(ANativeWindowBuffer*)+284) #02 pc 000000000000c390 /vendor/lib64/egl/eglSubDriverAndroid.so (EglAndroidWindowSurface::DequeueBuffer()+240) #03 pc 000000000000bb10 /vendor/lib64/egl/eglSubDriverAndroid.so (EglAndroidWindowSurface::GetBuffer(EglSubResource*, EglMemoryDesc*)+64) #04 pc 000000000032732c /vendor/lib64/egl/libGLESv2_adreno.so (EglWindowSurface::UpdateResource(EsxContext*)+116) #05 pc 0000000000326dd0 /vendor/lib64/egl/libGLESv2_adreno.so (EglWindowSurface::GetResource(EsxContext*, EsxResource**, EsxResource**, int)+56) #06 pc 00000000002ae484 /vendor/lib64/egl/libGLESv2_adreno.so (EsxContext::AcquireBackBuffer(int)+364) #07 pc 0000000000249680 /vendor/lib64/egl/libGLESv2_adreno.so (EsxContext::Clear(unsigned int, unsigned int, unsigned int, EsxClearValues*)+1800) #08 pc 00000000002cb52c /vendor/lib64/egl/libGLESv2_adreno.so (EsxGlApiParamValidate::GlClear(EsxDispatch*, unsigned int)+132)
Sam Lantinga a8780c6a 2020-01-16T20:49:25 Updated copyright date for 2020
Sylvain Becker d004cc70 2019-12-21T22:40:33 Android: same way as in nativePause(), resume events are sent from SDL thread
Sylvain Becker 45a9b5fa 2019-12-21T21:18:02 Android: fix call of glFinish without context. Message in the log, when going to background: "call to OpenGL ES API with no current context (logged once per thread)" Because of SDL_WINDOWEVENT_MINIMIZED is sent from the Java Activity thread. It calls SDL_RendererEventWatch(), _WindowEvent() and glFinish() without context. Solution is to move sending of SDL_WINDOWEVENT_MINIMIZED to the SDL thread.
Sylvain Becker 13e10151 2019-12-12T20:33:11 Android: use SDL_arraysize()
Sylvain Becker 210f6dda 2019-12-12T18:38:36 Android: use 'RegisterNatives' to export the native methods "The advantages of RegisterNatives are that you get up-front checking that the symbols exist, plus you can have smaller and faster shared libraries by not exporting anything but JNI_OnLoad" https://developer.android.com/training/articles/perf-jni#native-libraries
Sylvain Becker 303646a6 2019-10-31T15:53:10 Android: some readability: redundant casts, deads stores, redundant control flow
Ozkan Sezer 9c8e403f 2019-08-30T11:35:20 use 'U' suffix on constants instead of (unsigned int) cast.
Sylvain Becker 70dc8d16 2019-08-30T08:55:20 Android: fix corresponding warnings
Sam Lantinga 63197c43 2019-08-02T17:19:50 Fix bug where the wrong button was the default in the old message box because buttons were added backwards, breaking the indexing used by GetButtonIndex. Add messagebox flags to explicilty request left-to-right button order or right-to-left. If neither is specified it'll be some platform default.
Sylvain Becker 18bcafff 2019-07-27T20:21:42 Fixed bug 4739 - Android: loading native libs, generated by bundletool (Thanks akk0rd87)
Sylvain Becker 22a2decf 2019-06-28T16:38:42 Android: concurrency issues, make sure Activity is in running State when calling functions like SDL_CreateWindow, SDL_CreateRenderer, Android_GLES_CreateContext Bugs 4694, 4681, 4142
Sylvain Becker ccba8d46 2019-06-24T18:08:11 Android: export Lock/Unlock activity API
Sylvain Becker a55c0e14 2019-06-18T10:23:19 Android: revert previous commit (Bug 4669) (Refs #1)
Sylvain Becker f2157b6c 2019-06-17T22:31:36 Fixed bug 4669: Android software renderer, black screen when window resizes Using the software SDL_Renderer on Android leads to GL errors & black screen when window resizes
Sylvain Becker f9a9193e 2019-06-10T21:58:03 Android: add MinimizeWindow function (Bug 4580, 4657) shouldMinimizeOnFocusLoss is un-activated (return false)
Sam Lantinga b1100ec1 2019-06-08T10:23:52 Fixed Android build warning
Sam Lantinga dce56ab9 2019-05-23T14:19:00 Added a function to get the current Android SDK version at runtime
Sam Lantinga 8b57331e 2019-05-23T11:05:43 Fixed hiding the Android virtual keyboard when the return key is pressed
Sam Lantinga 9950271b 2019-04-22T16:19:52 Fixed bug 4580 - Android 8: immersive fullscreen notification causes flickering between fullscreen and non-fullscreen and app is unresponsive Sylvain 2019-04-18 21:22:59 UTC Changes: - SDL_WINDOWEVENT_FOCUS_GAINED and SDL_WINDOWEVENT_FOCUS_LOST are sent when the java method onWindowFocusChanged() is called. - If we have support for MultiWindow (eg API >= 24), SDL event loop is blocked/un-blocked (or simply egl-backed-up or not), when java onStart()/onStop() are called. - If not, this behaves like now, SDL event loop is blocked/un-blocked when onPause()/onResume() are called. So if we have two app on screen and switch from one to the other, only FOCUS events are sent (and onPause()/onResume() are called but empty. onStart()/onStop() are not called). The SDL app, un-focused, would still continue to run and display frames (currently the App would be displayed, but paused). Like a video player app or a chronometer that would still be refreshed, even if the window hasn't the focus. It should work also on ChromeBooks (not tested), with two apps opened at the same time. I am not sure this fix Dan's issue. Because focus lost event triggers Minimize function (which BTW is not provided on android). https://hg.libsdl.org/SDL/file/bb41b3635c34/src/video/SDL_video.c#l2653 https://hg.libsdl.org/SDL/file/bb41b3635c34/src/video/SDL_video.c#l2634 So, in addition, it would need to add by default SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS to 0. So that the lost focus event doesn't try to minimize the window. And this should fix also the issue.
Sam Lantinga a46af76b 2019-04-05T08:15:01 Fixed bug 4579 - SDL_android.c s_active not being atomic Isaias Brunet This bug cause a false assert due to multiple threads modifying the same variable without any atomic operation.
Sylvain Becker bfdd0b22 2019-04-04T17:01:02 Android: remove SDL_HINT_ANDROID_SEPARATE_MOUSE_AND_TOUCH java layer runs as if separate mouse and touch was 1, Use SDL_HINT_MOUSE_TOUCH_EVENTS and SDL_HINT_TOUCH_MOUSE_EVENTS for generating synthetic touch/mouse events
Sylvain Becker 063c0c2a 2019-03-13T09:39:30 Android: check SDL is initialized before sending the event Avoid error message: SDLActivity thread ends (error=Video subsystem has not been initialized)
Sam Lantinga d05eec72 2019-03-12T14:44:25 Fixed initial display orientation at Android app start
Sylvain Becker 8ad4000c 2019-01-20T22:17:41 Android: some typos
Sylvain Becker b9aa3768 2019-01-20T22:11:56 Android: automatically attach to the JVM non-SDL threads It allows a thread created with pthread_create() to access the JNI Env
Sylvain Becker e5f8801f 2019-01-17T11:05:05 Android: prevent concurrency in Android_SetScreenResolution() when exiting by checking Android_Window validity - SDLThread: user application is exiting: SDL_VideoQuit() and clearing SDL_GetVideoDevice() - ActivityThread is changing orientation/size surfaceChanged() > Android_SetScreenResolution() > SDL_GetVideoDevice() - Separate function into Android_SetScreenResolution() and Android_SendResize(), formating, and mark Android_DeviceWidth/Heigh as static
Sylvain Becker 8a19ff3e 2019-01-16T10:48:28 Android: add mutex protection to onNativeOrientationChanged it's possible receive try to send an event between the check first for SDL_GetVideoDevice and SDL_VideoQuit is called
Sylvain Becker e994be58 2019-01-16T10:31:51 Android: move static variable isPaused/isPausing to SDL_VideoData structure - remove unneed check to Android_Window->driverdata - add window check into context_backup/restore
Sylvain Becker dc263450 2019-01-14T23:33:48 Android: create Pause/ResumeSem semaphore at higher level than CreateWindow() - If you call onPause() before CreateWindow(), SDLThread will run in infinite loop in background. - If you call onPause() between a DestroyWindow() and a new CreateWindow(), semaphores are invalids. SDLActivity.java: the first resume() starts the SDLThread, don't call nativeResume() as it would post ResumeSem. And the first pause would automatically be resumed.
Sylvain Becker 7b42f03f 2019-01-11T21:52:43 Android: move and group JNIEnv helper functions
Sylvain Becker 7f347830 2019-01-11T21:42:52 Android: change the way JNIEnv is retrieved - Currently, it tries to Attach the JVM first and update the thread local storage, which are two operations. Now, it simply gives back the JNI Env stored for the thread. - Android_JNI_SetupThreadi() should only be used for external. For internal SDL thread, it's already called in RunThread() (SDL_systhread.c), and other thread are Java threads which don't need to be attached. i (even if it doesn't hurt to do it, since it's a no-op). - JNI_OnLoad is filled with pthread_create, GetEnv, AttachCurrentThread... It's called for all shared libraries which may don't want this setup, and loading libraries can be also modified to be done from a static context, or with relinker. So it's not really clear how, who and what it sets up. => Reduce this function to the minimal
Sylvain Becker dc10d96c 2019-01-11T15:36:16 Android: use the same naming for JNI env local variables
Sylvain Becker 3cfd907d 2019-01-11T15:33:02 Android: Audio thread is already setup for the JVM In 'src/thread/pthread/SDL_systhread.c' RunThread() calls first 'Android_JNI_SetupThread()'
Sylvain Becker 9d82f4e9 2019-01-11T15:27:53 Android: use pthread_once for creating thread key 'mThreadKey'
Sylvain Becker 9a98e5af 2019-01-11T14:50:43 Android: don't call Android_JNI_ThreadDestroyed() for Java SDLThread SDLThread is a Java Thread, it's not needed to call 'Detach' from the JVM. Clear mThreadKey, so that the pthread_create destructor is not called for this thread.
Sylvain Becker b44a7aea 2019-01-10T21:49:00 Android: fix prototype of Android_JNI_InitTouch
Sylvain Becker 7a1d1bae 2019-01-10T21:40:57 Android: add name for Touch devices and simplification, from bug 3958
Sylvain Becker d23c2f07 2019-01-10T18:05:56 Fixed bug 3930 - Android, set thread priorities and names SDLActivity thread priority is unchanged, by default -10 (THREAD_PRIORITY_VIDEO). SDLAudio thread priority was -4 (SDL_SetThreadPriority was ignored) and is now -16 (THREAD_PRIORITY_AUDIO). SDLThread thread priority was 0 (THREAD_PRIORITY_DEFAULT) and is -4 (THREAD_PRIORITY_DISPLAY).
Sylvain Becker 66fbfe1d 2019-01-10T15:43:07 Android: nativeQuit for SDLActivity thread - destroy Android_ActivityMutex - display any SDL error message that may have occured in this thread, since SDL_GetError() is thread specific, and user has no access to it.
Sylvain Becker dad81611 2019-01-10T15:35:46 Android: only send Quit event to SDLThread if it's not already terminated And it avoids reporting errors using Android_Pause/ResumeSem that are NULL.
Sylvain Becker 8dd91550 2019-01-09T23:19:26 Android: prevent a dummy error message sending SDL_DISPLAYEVENT_ORIENTATION In the usual case, first call to onNativeOrientationChanged() is done before SDL has been initialised and would just set an error message "Video subsystem has not been initialized" without sending the event.
Sylvain Becker 68c0e69f 2019-01-09T22:41:52 Android: native_window validity is guaranteed between surfaceCreated and Destroyed It's currently still available after surfaceDestroyed(). And available (but invalid) between surfaceCreated() and surfaceChanged(). Which means ANativewindow_getWidth/Height/Format() fail in those cases. https://developer.android.com/reference/android/view/SurfaceHolder.html#getSurface()
Sylvain Becker cfe2924d 2019-01-07T11:35:31 Android: some robustness when quitting application from onDestroy() Make sure there is not pending Pause accumulated, so the the application doesn't remain paused and stucked in onDestroy(). Can be tested by adding: SDLActivity.nativePause(); SDLActivity.nativePause(); mSingleton.finish();
Sylvain Becker 462e62e1 2019-01-06T20:25:54 Android: better fix for bug 3186. Run those commands from SDL thread.
Sylvain Becker 9f23d181 2019-01-06T17:35:42 Android: allow multiple calls to nativeResume() Doesn't seem to happen manually, but symetrical to the pause handling. Can be tested by adding: mNextNativeState = SDLActivity.NativeState.PAUSED; handleNativeState(); mNextNativeState = SDLActivity.NativeState.RESUMED; handleNativeState(); mNextNativeState = SDLActivity.NativeState.PAUSED; handleNativeState(); mNextNativeState = SDLActivity.NativeState.RESUMED; handleNativeState(); Before, it ends in 'paused' state. Now, it ends in 'resumed' state.
Sylvain Becker 35722b64 2019-01-05T22:27:25 Android: fix wrong state after immediate sequence pause() / resume() / pause() It may happen to have the sequence pause()/resume()/pause(), before polling any events. Before, it ends in 'resumed' state because as the check is greedy. Now, always increase the Pause semaphore, and stop at each pause. It ends in 'paused' state. Related to bug 3250: set up a reconfiguration of SurfaceView holder. Turn the screen off manually before the app starts (repro rate is not 100%..)
Sam Lantinga 5e13087b 2019-01-04T22:01:14 Updated copyright for 2019
Sylvain Becker 2e19343d 2019-01-03T20:18:29 Android: use Mutex instead of Semphore for bug 4142
Sylvain Becker cc8f1136 2019-01-03T14:18:06 Fixed bug 4142 - Concurrency issues in Android backend Use a semaphore to prevent concurrency issues between Java Activity and Native thread code, when using 'Android_Window'. (Eg. Java sending Touch events, while native code is destroying the main SDL_Window. )
Sylvain Becker 5dc25fef 2019-01-03T13:14:16 Android: preparation bug 4142, reduce usage of global variable Android_Window
Sylvain Becker a95f91bc 2019-01-02T18:06:33 Fixed bug 3250 - Wrong backbuffer pixel format on Android, keep getting RGB_565 Use the egl format to reconfigure java SurfaceView holder format. If there is a change, it triggers a surfaceDestroyed/Created/Change sequence.
Sylvain Becker 03b0e1de 2018-12-30T22:44:25 Android: on rare occasion, prevent Android_JNI_GetNativeWindow() from crashing If Java getNativeSurface() returns null, then ANativeWindow_fromSurface() would crash().
Sylvain Becker 1e22fc15 2018-12-30T15:41:28 Android: fixed comments and spaces
Sylvain Becker 2a412eb9 2018-12-30T15:39:37 Fixed bug 3186 - Android SW keyboard not restored when app becomes foreground.
Sylvain Becker 7468d1e0 2018-12-06T15:46:40 Fix warnings detected on Android build
Sam Lantinga 47fb450b 2018-11-02T17:18:03 Fixed bug 4315 - little Warning in Android_JNI_CaptureAudioBuffer Sylvain SDL_android.c src/core/android/SDL_android.c:1302:5: warning: variable 'br' is used uninitialized whenever switch default is taken [-Wsometimes-uninitialized] default: ^~~~~~~ src/core/android/SDL_android.c:1306:12: note: uninitialized use occurs here return br; ^~ src/core/android/SDL_android.c:1270:12: note: initialize the variable 'br' to silence this warning jint br; ^ Maybe we could add some basics warning flags, not to see all warnings, but so that new warnings are caught sooner. I would go for -Wall -Wextra, and some -Wno-warning for the allowed warnings.
Ryan C. Gordon 62494a2e 2018-10-31T15:03:41 Merge SDL-ryan-batching-renderer branch to default.
Ryan C. Gordon b262b0eb 2018-10-22T20:50:32 Small stack allocations fall back to malloc if they're unexpectedly large.
Sam Lantinga b0c48dd9 2018-10-16T08:29:27 Support vibration magnitude on Android 8.0 (thanks Rachel!)
Sam Lantinga f5a21ebf 2018-10-09T20:12:43 Added support for surround sound and float audio on Android
Sam Lantinga 7df0f4fd 2018-09-27T14:56:29 Fixed bug 4277 - warnings patch Sylvain Patch a few warnings when using: -Wmissing-prototypes -Wdocumentation -Wdocumentation-unknown-command They are automatically enabled with -Wall
Sam Lantinga e236e843 2018-09-25T20:08:51 Fixed bug 4268 - Android_JNI_OpenAudioDevice function has error alittle where iscapture == 1 1.param set error (*env)->CallStaticIntMethod(env, mAudioManagerClass, midCaptureOpen, sampleRate, audioBuffer16Bit, audioBufferStereo, desiredBufferFrames) param:audioBuffer16Bit need change to captureBuffer16Bit 2.logic error if (is16Bit) { // ALITTLE Modify the source code if (iscapture) { audioBufferFrames = (*env)->GetArrayLength(env, (jshortArray)captureBuffer); } else { audioBufferPinned = (*env)->GetShortArrayElements(env, (jshortArray)audioBuffer, &isCopy); audioBufferFrames = (*env)->GetArrayLength(env, (jshortArray)audioBuffer); } // if (!iscapture) { // audioBufferPinned = (*env)->GetShortArrayElements(env, (jshortArray)audioBuffer, &isCopy); // } // audioBufferFrames = (*env)->GetArrayLength(env, (jshortArray)audioBuffer); } else { // ALITTLE Modify the source code if (iscapture) { audioBufferFrames = (*env)->GetArrayLength(env, (jbyteArray)captureBuffer); } else { audioBufferPinned = (*env)->GetByteArrayElements(env, (jbyteArray)audioBuffer, &isCopy); audioBufferFrames = (*env)->GetArrayLength(env, (jbyteArray)audioBuffer); } // if (!iscapture) { // audioBufferPinned = (*env)->GetByteArrayElements(env, (jbyteArray)audioBuffer, &isCopy); // } // audioBufferFrames = (*env)->GetArrayLength(env, (jbyteArray)audioBuffer); }
Sam Lantinga 5febdfce 2018-09-24T11:49:25 Fixed whitespace
Sam Lantinga 09ab752a 2018-08-24T10:41:57 Implement SDL_HapticStopEffect on Android (thanks Rachel!)
Sam Lantinga a003fa0a 2018-08-23T14:05:25 Implemented SDL_GetDisplayOrientation() on Android (thanks Rachel!)
Sam Lantinga 6f758ad2 2018-08-21T20:03:54 Moved SDL_IsTablet() to a cross-platform API function
Sam Lantinga 109544ca 2018-08-21T11:23:47 Add SDL_IsTablet() to Android and iOS SDL.
Sam Lantinga ff8c9538 2018-07-12T13:28:13 Allow trapping the back button so right mouse click can work on some Android systems (thanks Rachel!) Also, added a function SDL_AndroidBackButton() so applications can respond to the back button directly
Sam Lantinga a5158535 2018-06-18T13:14:02 Added support for external mouse in Samsung DeX mode relative mode doesn't work, but absolute coordinates are functional
Sam Lantinga fe196db7 2018-06-07T17:07:03 Track android device panel width & height as well as window surface & height. Expand SDLActivity::SDLSurface::surfaceChanged() callback to grab the panel width and height at the same time and pass that along to the native code. Only works on API 17+. Duplicates surface dimensions whenever it fails. Add Android_DeviceWidth/Android_DeviceHeight globals to native code. Disambiguate Android_ScreenWidth/Android_ScreenHeight -> Android_SurfaceWidth/Android_SurfaceHeight Use device width/height for all display mode settings.
Sam Lantinga 113801b7 2018-06-05T12:46:13 Added SDL_IsChromebook() to determine if we're running on a Chromebook.
Sam Lantinga 2dedbc72 2018-06-05T12:46:11 Add Android support for relative mouse mode to SDL.
Sam Lantinga f536fbea 2018-03-16T11:08:53 Reimplemented Android cursor API support using reflection so it builds with older SDKs