Use System_GetPropertyInt(SYSPROP_SYSTEMVERSION to retrieve version.

This commit is contained in:
Filippo Scognamiglio 2020-02-03 22:10:47 +01:00
parent f514852791
commit c00ce91a2a

View file

@ -20,6 +20,7 @@
#ifdef __ANDROID__
#include "base/logging.h"
#include "base/NativeApp.h"
#include "MemoryUtil.h"
#include "MemArena.h"
#include "StringUtils.h"
@ -41,14 +42,6 @@ bool MemArena::NeedsProbing() {
return false;
}
static int get_sdk_version() {
char sdk[PROP_VALUE_MAX] = {0};
if (__system_property_get("ro.build.version.sdk", sdk) != 0) {
return atoi(sdk);
}
return -1;
}
// ashmem_create_region - creates a new ashmem region and returns the file
// descriptor, or <0 on error
// This function is defined in much later version of the ndk, so we can only access it via dlopen().
@ -111,7 +104,7 @@ void MemArena::GrabLowMemSpace(size_t size) {
const char* name = "PPSSPP_RAM";
// Since version 26 Android provides a new api for accessing SharedMemory.
if (get_sdk_version() >= 26) {
if (System_GetPropertyInt(SYSPROP_SYSTEMVERSION) >= 26) {
fd = ashmem_create_region(name, size);
} else {
fd = legacy_ashmem_create_region(name, size);