diff --git a/edxp-core/src/main/cpp/main/include/framework/fd_utils.h b/edxp-core/src/main/cpp/main/include/framework/fd_utils.h index 58a3aa0d..8fe4190c 100644 --- a/edxp-core/src/main/cpp/main/include/framework/fd_utils.h +++ b/edxp-core/src/main/cpp/main/include/framework/fd_utils.h @@ -4,7 +4,6 @@ #include #include "base/object.h" -// NOT USED namespace android { // Static whitelist of open paths that the zygote is allowed to keep open. @@ -20,7 +19,8 @@ namespace android { static void Setup(void *handle, HookFunType hook_func) { HOOK_FUNC(IsAllowed, - "_ZNK23FileDescriptorWhitelist9IsAllowedERKNSt3__112basic_stringIcNS0_11char_traitsIcEENS0_9allocatorIcEEEE"); + "_ZNK23FileDescriptorWhitelist9IsAllowedERKNSt3__112" + "basic_stringIcNS0_11char_traitsIcEENS0_9allocatorIcEEEE"); } private: diff --git a/edxp-core/src/main/cpp/main/src/riru_hook.cpp b/edxp-core/src/main/cpp/main/src/riru_hook.cpp index b21a14a6..66539978 100644 --- a/edxp-core/src/main/cpp/main/src/riru_hook.cpp +++ b/edxp-core/src/main/cpp/main/src/riru_hook.cpp @@ -14,46 +14,36 @@ namespace edxp { static int api_level = 0; - + //Max length of property values //Ref https://android.googlesource.com/platform/frameworks/base/+/master/core/java/android/os/SystemProperties.java //static const int PROP_VALUE_MAX = 91; NEW_FUNC_DEF(int, __system_property_get, const char *key, char *value) { int res = old___system_property_get(key, value); - + if (key) { - /* if (strcmp(kPropKeyCompilerFilter, key) == 0) { - strcpy(value, kPropValueCompilerFilter); - LOGI("system_property_get: %s -> %s", key, value); - } else if (strcmp(kPropKeyCompilerFlags, key) == 0) { - strcpy(value, kPropValueCompilerFlags); +// strcpy(value, kPropValueCompilerFilter); LOGI("system_property_get: %s -> %s", key, value); } - */ - - if(strcmp(kPropKeyCompilerFlags, key) == 0) { - if(strcmp(value,"") == 0) + + if (strcmp(kPropKeyCompilerFlags, key) == 0) { + if (strcmp(value, "") == 0) strcpy(value, kPropValueCompilerFlags); - else { - if(strstr(value,kPropValueCompilerFlags) == NULL) { - if(strlen(value) + strlen(kPropValueCompilerFlagsWS) > PROP_VALUE_MAX) { - //just fallback,why not - LOGI("Cannot add option to disable inline opt!Fall back to replace.."); - strcpy(value, kPropValueCompilerFlags); - }else { - strcat(value,kPropValueCompilerFlagsWS); - } + else if (strstr(value, kPropValueCompilerFlags) == nullptr) { + if (strlen(value) + strlen(kPropValueCompilerFlagsWS) > PROP_VALUE_MAX) { + //just fallback, why not + LOGI("Cannot add option to disable inline opt! Fall back to replace.."); + strcpy(value, kPropValueCompilerFlags); + } else { + strcat(value, kPropValueCompilerFlagsWS); } } - if(strstr(value,kPropValueCompilerFlags) != NULL) - LOGI("system_property_get: %s -> %s", key, value); + LOGI("system_property_get: %s -> %s", key, value); } - - - - + + if (api_level == __ANDROID_API_O_MR1__) { // https://android.googlesource.com/platform/art/+/f5516d38736fb97bfd0435ad03bbab17ddabbe4e // Android 8.1 add a fatal check for debugging (removed in Android 9.0), @@ -77,35 +67,27 @@ namespace edxp { const std::string &key, const std::string &default_value) { std::string res = old__ZN7android4base11GetPropertyERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEES9_( key, default_value); - /* + if (strcmp(kPropKeyCompilerFilter, key.c_str()) == 0) { - res = kPropValueCompilerFilter; - LOGI("android::base::GetProperty: %s -> %s", key.c_str(), res.c_str()); - } else if (strcmp(kPropKeyCompilerFlags, key.c_str()) == 0) { - res = kPropValueCompilerFlags; +// res = kPropValueCompilerFilter; LOGI("android::base::GetProperty: %s -> %s", key.c_str(), res.c_str()); } - */ - - if(strcmp(kPropKeyCompilerFlags, key.c_str()) == 0) { - if(strcmp(res.c_str(),"") == 0) + + if (strcmp(kPropKeyCompilerFlags, key.c_str()) == 0) { + if (strcmp(res.c_str(), "") == 0) res = kPropValueCompilerFlags; - else{ - if(strstr(res.c_str(),kPropValueCompilerFlags) == NULL) { - if(strlen(res.c_str()) + strlen(kPropValueCompilerFlagsWS) > PROP_VALUE_MAX) { - //just fallback,why not - LOGI("Cannot add option to disable inline opt!Fall back to replace.."); - res = kPropValueCompilerFlags; - }else { - res.append(kPropValueCompilerFlagsWS); - } + else if (strstr(res.c_str(), kPropValueCompilerFlags) == nullptr) { + if (strlen(res.c_str()) + strlen(kPropValueCompilerFlagsWS) > PROP_VALUE_MAX) { + //just fallback, why not + LOGI("Cannot add option to disable inline opt! Fall back to replace.."); + res = kPropValueCompilerFlags; + } else { + res.append(kPropValueCompilerFlagsWS); } } - if(strstr(res.c_str(),kPropValueCompilerFlags) != NULL) - LOGI("android::base::GetProperty: %s -> %s", key.c_str(), res.c_str()); + LOGI("android::base::GetProperty: %s -> %s", key.c_str(), res.c_str()); } - - + if (api_level == __ANDROID_API_O_MR1__) { // see __system_property_get hook above for explanations if (strcmp(kPropKeyUseJitProfiles, key.c_str()) == 0) { diff --git a/edxp-core/template_override/system.prop b/edxp-core/template_override/system.prop index e7264828..0735313f 100644 --- a/edxp-core/template_override/system.prop +++ b/edxp-core/template_override/system.prop @@ -1,3 +1,4 @@ +# TODO ensure quicken is not essential #dalvik.vm.dex2oat-filter=quicken dalvik.vm.dex2oat-flags=--inline-max-code-units=0 #dalvik.vm.image-dex2oat-flags=--inline-max-code-units=0 --compiler-filter=speed