From 7757c5d19bcec06b7cb568fcd53a417958b0febd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8F=8C=E8=8D=89=E9=85=B8=E9=85=AF?= <17663689+kotori2@users.noreply.github.com> Date: Thu, 4 Feb 2021 03:23:48 +0800 Subject: [PATCH] [core] Remove redundant code (#65) --- core/src/main/cpp/main/src/context.cpp | 16 +++++----------- core/src/main/cpp/main/src/context.h | 2 -- 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/core/src/main/cpp/main/src/context.cpp b/core/src/main/cpp/main/src/context.cpp index 38485f78..b3fff427 100644 --- a/core/src/main/cpp/main/src/context.cpp +++ b/core/src/main/cpp/main/src/context.cpp @@ -35,26 +35,20 @@ namespace lspd { constexpr int SHARED_RELRO_UID = 1037; constexpr int PER_USER_RANGE = 100000; - void Context::CallPostFixupStaticTrampolinesCallback(void *class_ptr, jmethodID callback_mid) { - if (UNLIKELY(!callback_mid || !class_linker_class_)) { - return; - } - if (!class_ptr) { + void Context::CallOnPostFixupStaticTrampolines(void *class_ptr) { + if (UNLIKELY(!class_ptr || !class_linker_class_ || !post_fixup_static_mid_)) { return; } + JNIEnv *env; vm_->GetEnv((void **) (&env), JNI_VERSION_1_4); art::JNIEnvExt env_ext(env); ScopedLocalRef clazz(env, env_ext.NewLocalRefer(class_ptr)); if (clazz != nullptr) { - JNI_CallStaticVoidMethod(env, class_linker_class_, callback_mid, clazz.get()); + JNI_CallStaticVoidMethod(env, class_linker_class_, post_fixup_static_mid_, clazz.get()); } } - void Context::CallOnPostFixupStaticTrampolines(void *class_ptr) { - CallPostFixupStaticTrampolinesCallback(class_ptr, post_fixup_static_mid_); - } - void Context::PreLoadDex(const fs::path &dex_path) { if (LIKELY(!dexes.empty())) return; @@ -264,7 +258,7 @@ namespace lspd { jfieldID path_fid = JNI_GetStaticFieldID(env, service_class, "CONFIG_PATH", "Ljava/lang/String;"); jfieldID pn_fid = JNI_GetStaticFieldID(env, service_class, "INSTALLER_PACKAGE_NAME", - "Ljava/lang/String;"); + "Ljava/lang/String;"); if (LIKELY(path_fid) && LIKELY(pn_fid)) { env->SetStaticObjectField(service_class, path_fid, env->NewStringUTF( ConfigManager::GetMiscPath().c_str())); diff --git a/core/src/main/cpp/main/src/context.h b/core/src/main/cpp/main/src/context.h index 3dba9350..7bea7f0e 100644 --- a/core/src/main/cpp/main/src/context.h +++ b/core/src/main/cpp/main/src/context.h @@ -107,8 +107,6 @@ namespace lspd { static jclass FindClassFromLoader(JNIEnv *env, jobject class_loader, const char *class_name); - void CallPostFixupStaticTrampolinesCallback(void *class_ptr, jmethodID mid); - static bool ShouldSkipInject(const std::string &package_name, uid_t user, uid_t uid, bool res, const std::function& empty_list,