Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not force quicken,preserve dex2oat flags. #543

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 53 additions & 2 deletions edxp-core/src/main/cpp/main/src/riru_hook.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//
/
// Created by solo on 2019/3/16.
//

Expand All @@ -14,17 +14,46 @@
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);
LOGI("system_property_get: %s -> %s", key, value);
}
*/

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);
}
}
if(strstr(value,kPropValueCompilerFlags) != NULL)
LOGI("system_property_get: %s -> %s", key, value);
}
}




if (api_level == ANDROID_O_MR1) {
// https://android.googlesource.com/platform/art/+/f5516d38736fb97bfd0435ad03bbab17ddabbe4e
// Android 8.1 add a fatal check for debugging (removed in Android 9.0),
Expand All @@ -48,13 +77,35 @@ 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;
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)
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);
}
}
if(strstr(res.c_str(),kPropValueCompilerFlags) != NULL)
LOGI("android::base::GetProperty: %s -> %s", key.c_str(), res.c_str());
}
}


if (api_level == ANDROID_O_MR1) {
// see __system_property_get hook above for explanations
if (strcmp(kPropKeyUseJitProfiles, key.c_str()) == 0) {
Expand Down Expand Up @@ -88,4 +139,4 @@ namespace edxp {
}
}

}
}
1 change: 1 addition & 0 deletions edxp-core/src/main/cpp/main/src/riru_hook.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ namespace edxp {
static constexpr const char *kPropValueCompilerFilter = "quicken";
static constexpr const char *kPropValuePmBgDexopt = "speed";
static constexpr const char *kPropValueCompilerFlags = "--inline-max-code-units=0";
static constexpr const char *kPropValueCompilerFlagsWS = " --inline-max-code-units=0";


void InstallRiruHooks();
Expand Down