From dce56ab9fa9979e6a635d5d108a65d72a186a175 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Thu, 23 May 2019 14:19:00 -0700 Subject: [PATCH] Added a function to get the current Android SDK version at runtime --- src/core/android/SDL_android.c | 13 +++++++++++++ src/core/android/SDL_android.h | 2 ++ 2 files changed, 15 insertions(+) diff --git a/src/core/android/SDL_android.c b/src/core/android/SDL_android.c index 2793ec70a..2e082a2a2 100644 --- a/src/core/android/SDL_android.c +++ b/src/core/android/SDL_android.c @@ -42,6 +42,7 @@ #include "../../haptic/android/SDL_syshaptic_c.h" #include +#include #include #include #include @@ -2406,6 +2407,18 @@ void *SDL_AndroidGetActivity(void) return (*env)->CallStaticObjectMethod(env, mActivityClass, midGetContext); } +int SDL_GetAndroidSDKVersion(void) +{ + static int sdk_version; + if (!sdk_version) { + char sdk[PROP_VALUE_MAX] = {0}; + if (__system_property_get("ro.build.version.sdk", sdk) != 0) { + sdk_version = SDL_atoi(sdk); + } + } + return sdk_version; +} + SDL_bool SDL_IsAndroidTablet(void) { JNIEnv *env = Android_JNI_GetEnv(); diff --git a/src/core/android/SDL_android.h b/src/core/android/SDL_android.h index 52332fb92..7469de93e 100644 --- a/src/core/android/SDL_android.h +++ b/src/core/android/SDL_android.h @@ -122,6 +122,8 @@ SDL_bool Android_JNI_SupportsRelativeMouse(void); SDL_bool Android_JNI_SetRelativeMouseEnabled(SDL_bool enabled); +int SDL_GetAndroidSDKVersion(void); + SDL_bool SDL_IsAndroidTablet(void); SDL_bool SDL_IsAndroidTV(void); SDL_bool SDL_IsChromebook(void);