ANDROID: Add a method to get running SDK version
Co-authored-by: antoniou79 <a.antoniou79@gmail.com>
This commit is contained in:
parent
c84c9cd313
commit
9631567923
3 changed files with 27 additions and 1 deletions
|
@ -872,11 +872,30 @@ void JNI::setPause(JNIEnv *env, jobject self, jboolean value) {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
jstring JNI::getNativeVersionInfo(JNIEnv *env, jobject self) {
|
||||
return convertToJString(env, Common::U32String(gScummVMVersion));
|
||||
}
|
||||
|
||||
jint JNI::getAndroidSDKVersionId() {
|
||||
// based on: https://stackoverflow.com/a/10511880
|
||||
JNIEnv *env = JNI::getEnv();
|
||||
// VERSION is a nested class within android.os.Build (hence "$" rather than "/")
|
||||
jclass versionClass = env->FindClass("android/os/Build$VERSION");
|
||||
if (!versionClass) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
jfieldID sdkIntFieldID = NULL;
|
||||
sdkIntFieldID = env->GetStaticFieldID(versionClass, "SDK_INT", "I");
|
||||
if (!sdkIntFieldID) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
jint sdkInt = env->GetStaticIntField(versionClass, sdkIntFieldID);
|
||||
//LOGD("sdkInt = %d", sdkInt);
|
||||
return sdkInt;
|
||||
}
|
||||
|
||||
jstring JNI::convertToJString(JNIEnv *env, const Common::U32String &str) {
|
||||
uint len = 0;
|
||||
uint16 *u16str = str.encodeUTF16Native(&len);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue