From cdc7ed4121717c81c06060c8f94ec0b72df8c176 Mon Sep 17 00:00:00 2001 From: Artyom Palvelev Date: Wed, 14 Feb 2024 15:12:13 +0000 Subject: fix memory-advice scripts for Windows compatibility Since Windows doesn't have `touch` command, we suggest that we use `echo > filename` command instead. Test: build Hogger sample and run it Fix: 322119350 (cherry picked from https://android-review.googlesource.com/q/commit:e56bed6cb60e16803c2fcfada1de91a23f5443e0) Merged-In: Ie2f17f418c9e1fc1da43e6c5944d652d314b4be0 Change-Id: Ie2f17f418c9e1fc1da43e6c5944d652d314b4be0 --- games-memory-advice/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/games-memory-advice/CMakeLists.txt b/games-memory-advice/CMakeLists.txt index 08645aef..368788f3 100644 --- a/games-memory-advice/CMakeLists.txt +++ b/games-memory-advice/CMakeLists.txt @@ -110,7 +110,7 @@ file(APPEND ${mri_file} "end\n") set(output_archive_placeholder_file ${CMAKE_CURRENT_BINARY_DIR}/${output_archive}.placeholder.cpp) add_custom_command(OUTPUT ${output_archive_placeholder_file} - COMMAND touch ${output_archive_placeholder_file} + COMMAND echo > ${output_archive_placeholder_file} DEPENDS memory_advice_static_pre) -- cgit v1.2.3 From cafd02a652efb6def5d814efdf35b144850a4c46 Mon Sep 17 00:00:00 2001 From: Artyom Palvelev Date: Wed, 14 Feb 2024 16:08:15 +0000 Subject: fix InMemoryDexClassLoader issues with old API levels This CL fixes the rare condition in SDKs before 26 (which do not have InMemoryDexClassLoader). Sometimes, the exception is not triggered during class lookup, so we add an explicit check here. Test: build and run any sample that uses Swappy Bug: 323059686 (cherry picked from https://android-review.googlesource.com/q/commit:9ac9ebdde4c549ea4b0deec2f9a937b0a604a07d) Merged-In: I0d6dd75d1587ca4588039fe2c14ba749d86f89ff Change-Id: I0d6dd75d1587ca4588039fe2c14ba749d86f89ff --- src/common/JNIUtil.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/common/JNIUtil.h b/src/common/JNIUtil.h index 702e24d0..2907eba6 100644 --- a/src/common/JNIUtil.h +++ b/src/common/JNIUtil.h @@ -24,6 +24,7 @@ #include #include "Log.h" +#include "system_utils.h" // The code in this file will dynamically load Java classes from a binary // resource linked to the library. The binary data is in DEX format, accessible @@ -145,7 +146,9 @@ static jclass loadClass(JNIEnv* env, jobject activity, const char* name, classLoaderObj, loadClass, dexLoaderClassName)); env->DeleteLocalRef(dexLoaderClassName); - if (env->ExceptionCheck() || !imclassloaderClass) { + int sdkVersion = gamesdk::GetSystemPropAsInt("ro.build.version.sdk"); + + if (env->ExceptionCheck() || !imclassloaderClass || sdkVersion < 26) { env->ExceptionClear(); // For older SDK versions <26, where InMemoryDexClassLoader is not // available -- cgit v1.2.3