Skip to content

Commit

Permalink
Added a function to get the current Android SDK version at runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
slouken committed May 23, 2019
1 parent f3e76ea commit dce56ab
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/core/android/SDL_android.c
Expand Up @@ -42,6 +42,7 @@
#include "../../haptic/android/SDL_syshaptic_c.h"

#include <android/log.h>
#include <sys/system_properties.h>
#include <pthread.h>
#include <sys/types.h>
#include <unistd.h>
Expand Down Expand Up @@ -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();
Expand Down
2 changes: 2 additions & 0 deletions src/core/android/SDL_android.h
Expand Up @@ -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);
Expand Down

0 comments on commit dce56ab

Please sign in to comment.