[core] Support riru24 (#329)
* Support riru24 * tmp aar for build * Check riru version * Rename libriru_lspd to liblspd * Fix hiddenapi * Use maven
This commit is contained in:
parent
696309af0b
commit
c5bac3415c
|
|
@ -41,7 +41,7 @@ val commitCount = Git(repo).log().add(refId).call().count()
|
||||||
|
|
||||||
val defaultManagerPackageName by extra("org.lsposed.manager")
|
val defaultManagerPackageName by extra("org.lsposed.manager")
|
||||||
val verCode by extra(commitCount + 4200)
|
val verCode by extra(commitCount + 4200)
|
||||||
val verName by extra("v1.3.2")
|
val verName by extra("v1.3.3")
|
||||||
val androidTargetSdkVersion by extra(30)
|
val androidTargetSdkVersion by extra(30)
|
||||||
val androidMinSdkVersion by extra(27)
|
val androidMinSdkVersion by extra(27)
|
||||||
val androidBuildToolsVersion by extra("30.0.3")
|
val androidBuildToolsVersion by extra("30.0.3")
|
||||||
|
|
|
||||||
|
|
@ -37,15 +37,14 @@ fun calcSha256(file: File): String {
|
||||||
}
|
}
|
||||||
|
|
||||||
val moduleName = "LSPosed"
|
val moduleName = "LSPosed"
|
||||||
val jarDestDir = "${projectDir}/template_override/system/framework/"
|
|
||||||
val isWindows = OperatingSystem.current().isWindows
|
val isWindows = OperatingSystem.current().isWindows
|
||||||
val moduleId = "riru_lsposed"
|
val moduleId = "riru_lsposed"
|
||||||
val authors = "LSPosed Developers"
|
val authors = "LSPosed Developers"
|
||||||
|
|
||||||
val riruModuleId = "lsposed"
|
val riruModuleId = "lsposed"
|
||||||
val moduleMinRiruApiVersion = 10
|
val moduleMinRiruApiVersion = 24
|
||||||
val moduleMinRiruVersionName = "v23.0"
|
val moduleMinRiruVersionName = "v24.0.0"
|
||||||
val moduleMaxRiruApiVersion = 10
|
val moduleMaxRiruApiVersion = 24
|
||||||
|
|
||||||
val defaultManagerPackageName: String by rootProject.extra
|
val defaultManagerPackageName: String by rootProject.extra
|
||||||
val apiCode: Int by rootProject.extra
|
val apiCode: Int by rootProject.extra
|
||||||
|
|
@ -64,7 +63,7 @@ val verCode: Int by rootProject.extra
|
||||||
val verName: String by rootProject.extra
|
val verName: String by rootProject.extra
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation("dev.rikka.ndk:riru:10")
|
implementation("dev.rikka.ndk:riru:24.0.0")
|
||||||
implementation("com.android.tools.build:apksig:4.1.2")
|
implementation("com.android.tools.build:apksig:4.1.2")
|
||||||
compileOnly(project(":hiddenapi-stubs"))
|
compileOnly(project(":hiddenapi-stubs"))
|
||||||
compileOnly("androidx.annotation:annotation:1.1.0")
|
compileOnly("androidx.annotation:annotation:1.1.0")
|
||||||
|
|
@ -183,7 +182,7 @@ afterEvaluate {
|
||||||
from(dexOutPath) {
|
from(dexOutPath) {
|
||||||
rename("classes.dex", "lspd.dex")
|
rename("classes.dex", "lspd.dex")
|
||||||
}
|
}
|
||||||
into(file(zipPathMagiskReleasePath + "system/framework/"))
|
into(file(zipPathMagiskReleasePath + "framework/"))
|
||||||
}
|
}
|
||||||
copy {
|
copy {
|
||||||
from("${projectDir}/template_override")
|
from("${projectDir}/template_override")
|
||||||
|
|
@ -203,27 +202,27 @@ afterEvaluate {
|
||||||
}
|
}
|
||||||
copy {
|
copy {
|
||||||
include("riru_lspd")
|
include("riru_lspd")
|
||||||
rename("riru_lspd", "libriru_lspd.so")
|
rename("riru_lspd", "liblspd.so")
|
||||||
from("$libPathRelease/armeabi-v7a")
|
from("$libPathRelease/armeabi-v7a")
|
||||||
into("$zipPathMagiskReleasePath/system/lib")
|
into("$zipPathMagiskReleasePath/riru/lib")
|
||||||
}
|
}
|
||||||
copy {
|
copy {
|
||||||
include("riru_lspd")
|
include("riru_lspd")
|
||||||
rename("riru_lspd", "libriru_lspd.so")
|
rename("riru_lspd", "liblspd.so")
|
||||||
from("$libPathRelease/arm64-v8a")
|
from("$libPathRelease/arm64-v8a")
|
||||||
into("$zipPathMagiskReleasePath/system/lib64")
|
into("$zipPathMagiskReleasePath/riru/lib64")
|
||||||
}
|
}
|
||||||
copy {
|
copy {
|
||||||
include("riru_lspd")
|
include("riru_lspd")
|
||||||
rename("riru_lspd", "libriru_lspd.so")
|
rename("riru_lspd", "liblspd.so")
|
||||||
from("$libPathRelease/x86")
|
from("$libPathRelease/x86")
|
||||||
into("$zipPathMagiskReleasePath/system_x86/lib")
|
into("$zipPathMagiskReleasePath/riru_x86/lib")
|
||||||
}
|
}
|
||||||
copy {
|
copy {
|
||||||
include("riru_lspd")
|
include("riru_lspd")
|
||||||
rename("riru_lspd", "libriru_lspd.so")
|
rename("riru_lspd", "liblspd.so")
|
||||||
from("$libPathRelease/x86_64")
|
from("$libPathRelease/x86_64")
|
||||||
into("$zipPathMagiskReleasePath/system_x86/lib64")
|
into("$zipPathMagiskReleasePath/riru_x86/lib64")
|
||||||
}
|
}
|
||||||
copy {
|
copy {
|
||||||
from("${project(":app").projectDir}/build/outputs/apk/${variantLowered}")
|
from("${project(":app").projectDir}/build/outputs/apk/${variantLowered}")
|
||||||
|
|
|
||||||
|
|
@ -23,10 +23,10 @@ cmake_minimum_required(VERSION 3.4.1)
|
||||||
aux_source_directory(src SRC_LIST)
|
aux_source_directory(src SRC_LIST)
|
||||||
aux_source_directory(src/jni SRC_JNI_LIST)
|
aux_source_directory(src/jni SRC_JNI_LIST)
|
||||||
include_directories(include src)
|
include_directories(include src)
|
||||||
add_executable(riru_lspd ${SRC_LIST} ${SRC_JNI_LIST})
|
add_executable(lspd ${SRC_LIST} ${SRC_JNI_LIST})
|
||||||
|
|
||||||
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--dynamic-list=${CMAKE_SOURCE_DIR}/dynamic_list")
|
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--dynamic-list=${CMAKE_SOURCE_DIR}/dynamic_list")
|
||||||
|
|
||||||
find_package(riru REQUIRED CONFIG)
|
find_package(riru REQUIRED CONFIG)
|
||||||
find_library(log-lib log)
|
find_library(log-lib log)
|
||||||
target_link_libraries(riru_lspd yahfa riru::riru android dobby dex_builder ${log-lib})
|
target_link_libraries(lspd yahfa riru::riru android dobby dex_builder ${log-lib})
|
||||||
|
|
|
||||||
|
|
@ -50,8 +50,8 @@ namespace art {
|
||||||
// Note: these identifiers should be consistent with those in Java layer
|
// Note: these identifiers should be consistent with those in Java layer
|
||||||
if (strstr(thisDesc, "LspHooker_") != nullptr
|
if (strstr(thisDesc, "LspHooker_") != nullptr
|
||||||
|| strstr(thatDesc, "LspHooker_") != nullptr
|
|| strstr(thatDesc, "LspHooker_") != nullptr
|
||||||
|| strstr(thisDesc, "io/github/lsposed/") != nullptr
|
|| strstr(thisDesc, "org/lsposed/") != nullptr
|
||||||
|| strstr(thatDesc, "io/github/lsposed/") != nullptr) {
|
|| strstr(thatDesc, "org/lsposed/") != nullptr) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// for MIUI resources hooking
|
// for MIUI resources hooking
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,7 @@ inline constexpr bool is64 = Is64();
|
||||||
static const auto kEntryClassName = "org.lsposed.lspd.core.Main"s;
|
static const auto kEntryClassName = "org.lsposed.lspd.core.Main"s;
|
||||||
static const auto kClassLinkerClassName = "org.lsposed.lspd.nativebridge.ClassLinker"s;
|
static const auto kClassLinkerClassName = "org.lsposed.lspd.nativebridge.ClassLinker"s;
|
||||||
static const auto kBridgeServiceClassName = "org.lsposed.lspd.service.BridgeService"s;
|
static const auto kBridgeServiceClassName = "org.lsposed.lspd.service.BridgeService"s;
|
||||||
static const auto kDexPath = "/data/adb/lspd/framework/lspd.dex"s;
|
static const auto kDexPath = "framework/lspd.dex"s;
|
||||||
|
|
||||||
static const auto kLibArtName = "libart.so"s;
|
static const auto kLibArtName = "libart.so"s;
|
||||||
static const auto kLibFwName = "libandroidfw.so"s;
|
static const auto kLibFwName = "libandroidfw.so"s;
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,6 @@
|
||||||
#include "jni/logger.h"
|
#include "jni/logger.h"
|
||||||
#include "jni/native_api.h"
|
#include "jni/native_api.h"
|
||||||
#include "service.h"
|
#include "service.h"
|
||||||
#include "rirud_socket.h"
|
|
||||||
|
|
||||||
namespace lspd {
|
namespace lspd {
|
||||||
constexpr int FIRST_ISOLATED_UID = 99000;
|
constexpr int FIRST_ISOLATED_UID = 99000;
|
||||||
|
|
@ -60,14 +59,13 @@ namespace lspd {
|
||||||
void Context::PreLoadDex(const std::string &dex_path) {
|
void Context::PreLoadDex(const std::string &dex_path) {
|
||||||
if (LIKELY(!dex.empty())) return;
|
if (LIKELY(!dex.empty())) return;
|
||||||
|
|
||||||
try {
|
std::ifstream is(dex_path);
|
||||||
RirudSocket socket;
|
if (!is.good()) {
|
||||||
auto dex_content = socket.ReadFile(dex_path);
|
LOGE("Failed to read dex");
|
||||||
dex.assign(dex_content.begin(), dex_content.end());
|
return;
|
||||||
} catch (RirudSocket::RirudSocketException &e) {
|
|
||||||
LOGE("%s", e.what());
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
dex.assign(std::istreambuf_iterator<char>(is), std::istreambuf_iterator<char>());
|
||||||
|
|
||||||
LOGI("Loaded %s with size %zu", dex_path.c_str(), dex.size());
|
LOGI("Loaded %s with size %zu", dex_path.c_str(), dex.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -126,9 +124,10 @@ namespace lspd {
|
||||||
jclass
|
jclass
|
||||||
Context::FindClassFromLoader(JNIEnv *env, jobject class_loader, std::string_view class_name) {
|
Context::FindClassFromLoader(JNIEnv *env, jobject class_loader, std::string_view class_name) {
|
||||||
if (class_loader == nullptr) return nullptr;
|
if (class_loader == nullptr) return nullptr;
|
||||||
static auto clz = (jclass)env->NewGlobalRef(env->FindClass( "dalvik/system/DexClassLoader"));
|
static auto clz = (jclass) env->NewGlobalRef(
|
||||||
|
env->FindClass("dalvik/system/DexClassLoader"));
|
||||||
static jmethodID mid = JNI_GetMethodID(env, clz, "loadClass",
|
static jmethodID mid = JNI_GetMethodID(env, clz, "loadClass",
|
||||||
"(Ljava/lang/String;)Ljava/lang/Class;");
|
"(Ljava/lang/String;)Ljava/lang/Class;");
|
||||||
jclass ret = nullptr;
|
jclass ret = nullptr;
|
||||||
if (!mid) {
|
if (!mid) {
|
||||||
mid = JNI_GetMethodID(env, clz, "findClass", "(Ljava/lang/String;)Ljava/lang/Class;");
|
mid = JNI_GetMethodID(env, clz, "findClass", "(Ljava/lang/String;)Ljava/lang/Class;");
|
||||||
|
|
@ -202,9 +201,9 @@ namespace lspd {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!skip_ && ((app_id >= FIRST_ISOLATED_UID && app_id <= LAST_ISOLATED_UID) ||
|
if (!skip_ && ((app_id >= FIRST_ISOLATED_UID && app_id <= LAST_ISOLATED_UID) ||
|
||||||
(app_id >= FIRST_APP_ZYGOTE_ISOLATED_UID &&
|
(app_id >= FIRST_APP_ZYGOTE_ISOLATED_UID &&
|
||||||
app_id <= LAST_APP_ZYGOTE_ISOLATED_UID) ||
|
app_id <= LAST_APP_ZYGOTE_ISOLATED_UID) ||
|
||||||
app_id == SHARED_RELRO_UID)) {
|
app_id == SHARED_RELRO_UID)) {
|
||||||
skip_ = true;
|
skip_ = true;
|
||||||
LOGI("skip injecting into %s because it's isolated", process_name.get());
|
LOGI("skip injecting into %s because it's isolated", process_name.get());
|
||||||
}
|
}
|
||||||
|
|
@ -213,7 +212,7 @@ namespace lspd {
|
||||||
void
|
void
|
||||||
Context::OnNativeForkAndSpecializePost(JNIEnv *env) {
|
Context::OnNativeForkAndSpecializePost(JNIEnv *env) {
|
||||||
const JUTFString process_name(env, nice_name_);
|
const JUTFString process_name(env, nice_name_);
|
||||||
auto binder = skip_? nullptr : Service::instance()->RequestBinder(env, nice_name_);
|
auto binder = skip_ ? nullptr : Service::instance()->RequestBinder(env, nice_name_);
|
||||||
if (binder) {
|
if (binder) {
|
||||||
LoadDex(env);
|
LoadDex(env);
|
||||||
InstallInlineHooks();
|
InstallInlineHooks();
|
||||||
|
|
|
||||||
|
|
@ -29,123 +29,98 @@
|
||||||
#include "symbol_cache.h"
|
#include "symbol_cache.h"
|
||||||
|
|
||||||
namespace lspd {
|
namespace lspd {
|
||||||
static void onModuleLoaded() {
|
namespace {
|
||||||
LOGI("onModuleLoaded: welcome to LSPosed!");
|
std::string magiskPath;
|
||||||
// rirud must be used in onModuleLoaded
|
|
||||||
Context::GetInstance()->PreLoadDex(kDexPath);
|
|
||||||
InitSymbolCache();
|
|
||||||
}
|
|
||||||
|
|
||||||
static int shouldSkipUid(int) {
|
void onModuleLoaded() {
|
||||||
return 0;
|
LOGI("onModuleLoaded: welcome to LSPosed!");
|
||||||
}
|
// rirud must be used in onModuleLoaded
|
||||||
|
Context::GetInstance()->PreLoadDex(magiskPath + '/' + kDexPath);
|
||||||
|
InitSymbolCache();
|
||||||
|
}
|
||||||
|
|
||||||
static void nativeForkAndSpecializePre(JNIEnv *env, jclass, jint *_uid, jint *,
|
int shouldSkipUid(int) {
|
||||||
jintArray *, jint *,
|
return 0;
|
||||||
jobjectArray *, jint *,
|
}
|
||||||
jstring *, jstring *nice_name,
|
|
||||||
jintArray *, jintArray *,
|
|
||||||
jboolean *start_child_zygote, jstring *,
|
|
||||||
jstring *app_data_dir, jboolean *,
|
|
||||||
jobjectArray *,
|
|
||||||
jobjectArray *,
|
|
||||||
jboolean *,
|
|
||||||
jboolean *) {
|
|
||||||
Context::GetInstance()->OnNativeForkAndSpecializePre(env, *_uid,
|
|
||||||
*nice_name,
|
|
||||||
*start_child_zygote,
|
|
||||||
*app_data_dir);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void nativeForkAndSpecializePost(JNIEnv *env, jclass, jint res) {
|
void nativeForkAndSpecializePre(JNIEnv *env, jclass, jint *_uid, jint *,
|
||||||
if (res == 0)
|
jintArray *, jint *,
|
||||||
Context::GetInstance()->OnNativeForkAndSpecializePost(env);
|
jobjectArray *, jint *,
|
||||||
}
|
jstring *, jstring *nice_name,
|
||||||
|
jintArray *, jintArray *,
|
||||||
static void nativeForkSystemServerPre(JNIEnv *env, jclass, uid_t *, gid_t *,
|
|
||||||
jintArray *, jint *,
|
|
||||||
jobjectArray *, jlong *,
|
|
||||||
jlong *) {
|
|
||||||
Context::GetInstance()->OnNativeForkSystemServerPre(env);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void nativeForkSystemServerPost(JNIEnv *env, jclass, jint res) {
|
|
||||||
Context::GetInstance()->OnNativeForkSystemServerPost(env, res);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* method added in Android Q */
|
|
||||||
static void specializeAppProcessPre(JNIEnv *env, jclass, jint *uid, jint *,
|
|
||||||
jintArray *, jint *, jobjectArray *,
|
|
||||||
jint *, jstring *, jstring *nice_name,
|
|
||||||
jboolean *start_child_zygote, jstring *,
|
jboolean *start_child_zygote, jstring *,
|
||||||
jstring *app_data_dir, jboolean *,
|
jstring *app_data_dir, jboolean *,
|
||||||
jobjectArray *,
|
jobjectArray *,
|
||||||
jobjectArray *,
|
jobjectArray *,
|
||||||
jboolean *,
|
jboolean *,
|
||||||
jboolean *) {
|
jboolean *) {
|
||||||
Context::GetInstance()->OnNativeForkAndSpecializePre(env, *uid, *nice_name, *start_child_zygote,
|
Context::GetInstance()->OnNativeForkAndSpecializePre(env, *_uid,
|
||||||
*app_data_dir);
|
*nice_name,
|
||||||
}
|
*start_child_zygote,
|
||||||
|
*app_data_dir);
|
||||||
static void specializeAppProcessPost(JNIEnv *env, jclass) {
|
|
||||||
Context::GetInstance()->OnNativeForkAndSpecializePost(env);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int riru_api_version;
|
|
||||||
|
|
||||||
RIRU_EXPORT __attribute__((noinline)) void *init(void *arg) {
|
|
||||||
static int step = 0;
|
|
||||||
step += 1;
|
|
||||||
|
|
||||||
static void *_module;
|
|
||||||
|
|
||||||
switch (step) {
|
|
||||||
case 1: {
|
|
||||||
auto core_max_api_version = *(int *) arg;
|
|
||||||
riru_api_version =
|
|
||||||
core_max_api_version <= RIRU_MODULE_API_VERSION ? core_max_api_version
|
|
||||||
: RIRU_MODULE_API_VERSION;
|
|
||||||
return &riru_api_version;
|
|
||||||
}
|
}
|
||||||
case 2: {
|
|
||||||
switch (riru_api_version) {
|
|
||||||
case 10:
|
|
||||||
[[fallthrough]];
|
|
||||||
case 9: {
|
|
||||||
auto module = (RiruModuleInfoV10 *) malloc(sizeof(RiruModuleInfoV10));
|
|
||||||
memset(module, 0, sizeof(RiruModuleInfoV10));
|
|
||||||
_module = module;
|
|
||||||
|
|
||||||
module->supportHide = true;
|
void nativeForkAndSpecializePost(JNIEnv *env, jclass, jint res) {
|
||||||
|
if (res == 0)
|
||||||
|
Context::GetInstance()->OnNativeForkAndSpecializePost(env);
|
||||||
|
}
|
||||||
|
|
||||||
module->version = RIRU_MODULE_VERSION;
|
void nativeForkSystemServerPre(JNIEnv *env, jclass, uid_t *, gid_t *,
|
||||||
module->versionName = STRINGIFY(RIRU_MODULE_VERSION_NAME);
|
jintArray *, jint *,
|
||||||
module->onModuleLoaded = lspd::onModuleLoaded;
|
jobjectArray *, jlong *,
|
||||||
module->shouldSkipUid = lspd::shouldSkipUid;
|
jlong *) {
|
||||||
module->forkAndSpecializePre = lspd::nativeForkAndSpecializePre;
|
Context::GetInstance()->OnNativeForkSystemServerPre(env);
|
||||||
module->forkAndSpecializePost = lspd::nativeForkAndSpecializePost;
|
}
|
||||||
module->specializeAppProcessPre = lspd::specializeAppProcessPre;
|
|
||||||
module->specializeAppProcessPost = lspd::specializeAppProcessPost;
|
void nativeForkSystemServerPost(JNIEnv *env, jclass, jint res) {
|
||||||
module->forkSystemServerPre = lspd::nativeForkSystemServerPre;
|
Context::GetInstance()->OnNativeForkSystemServerPost(env, res);
|
||||||
module->forkSystemServerPost = lspd::nativeForkSystemServerPost;
|
}
|
||||||
return module;
|
|
||||||
}
|
/* method added in Android Q */
|
||||||
default: {
|
void specializeAppProcessPre(JNIEnv *env, jclass, jint *uid, jint *,
|
||||||
return nullptr;
|
jintArray *, jint *, jobjectArray *,
|
||||||
}
|
jint *, jstring *, jstring *nice_name,
|
||||||
|
jboolean *start_child_zygote, jstring *,
|
||||||
|
jstring *app_data_dir, jboolean *,
|
||||||
|
jobjectArray *,
|
||||||
|
jobjectArray *,
|
||||||
|
jboolean *,
|
||||||
|
jboolean *) {
|
||||||
|
Context::GetInstance()->OnNativeForkAndSpecializePre(env, *uid, *nice_name,
|
||||||
|
*start_child_zygote,
|
||||||
|
*app_data_dir);
|
||||||
|
}
|
||||||
|
|
||||||
|
void specializeAppProcessPost(JNIEnv *env, jclass) {
|
||||||
|
Context::GetInstance()->OnNativeForkAndSpecializePost(env);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
RiruVersionedModuleInfo module{
|
||||||
|
.moduleApiVersion = RIRU_MODULE_API_VERSION,
|
||||||
|
.moduleInfo = RiruModuleInfo{
|
||||||
|
.supportHide = true,
|
||||||
|
.version = RIRU_MODULE_VERSION,
|
||||||
|
.versionName = STRINGIFY(RIRU_MODULE_VERSION_NAME),
|
||||||
|
.onModuleLoaded = lspd::onModuleLoaded,
|
||||||
|
.shouldSkipUid = lspd::shouldSkipUid,
|
||||||
|
.forkAndSpecializePre = lspd::nativeForkAndSpecializePre,
|
||||||
|
.forkAndSpecializePost = lspd::nativeForkAndSpecializePost,
|
||||||
|
.forkSystemServerPre = lspd::nativeForkSystemServerPre,
|
||||||
|
.forkSystemServerPost = lspd::nativeForkSystemServerPost,
|
||||||
|
.specializeAppProcessPre = lspd::specializeAppProcessPre,
|
||||||
|
.specializeAppProcessPost = lspd::specializeAppProcessPost,
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
case 3: {
|
|
||||||
free(_module);
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
default: {
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(){
|
__attribute__((noinline)) RIRU_EXPORT RiruVersionedModuleInfo *init(Riru *riru) {
|
||||||
|
LOGD("Using riru %d", riru->riruApiVersion);
|
||||||
|
LOGD("module path: %s", riru->magiskModulePath);
|
||||||
|
lspd::magiskPath = riru->magiskModulePath;
|
||||||
|
return &lspd::module;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main() {
|
||||||
init(nullptr);
|
init(nullptr);
|
||||||
}
|
}
|
||||||
|
|
@ -1,121 +0,0 @@
|
||||||
/*
|
|
||||||
* This file is part of LSPosed.
|
|
||||||
*
|
|
||||||
* LSPosed is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* LSPosed is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with LSPosed. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2020 EdXposed Contributors
|
|
||||||
* Copyright (C) 2021 LSPosed Contributors
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "rirud_socket.h"
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <sys/socket.h>
|
|
||||||
#include <sys/un.h>
|
|
||||||
#include <logging.h>
|
|
||||||
#include <cerrno>
|
|
||||||
|
|
||||||
template<>
|
|
||||||
void RirudSocket::Write<std::string>(const std::string &str) {
|
|
||||||
auto count = str.size();
|
|
||||||
auto *buf = str.data();
|
|
||||||
Write(buf, count);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
void RirudSocket::Write(const T &obj) {
|
|
||||||
auto len = sizeof(T);
|
|
||||||
auto *buf = &obj;
|
|
||||||
Write(reinterpret_cast<const char*>(buf), len);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<>
|
|
||||||
void RirudSocket::Read<std::string>(std::string &str) {
|
|
||||||
auto count = str.size();
|
|
||||||
auto *buf = str.data();
|
|
||||||
Read(buf, count);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
void RirudSocket::Read(T &obj) {
|
|
||||||
auto len = sizeof(T);
|
|
||||||
auto *buf = &obj;
|
|
||||||
Read(reinterpret_cast<char*>(buf), len);
|
|
||||||
}
|
|
||||||
|
|
||||||
RirudSocket::RirudSocket() {
|
|
||||||
if ((fd_ = socket(PF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0)) < 0) {
|
|
||||||
throw RirudSocketException(strerror(errno));
|
|
||||||
}
|
|
||||||
|
|
||||||
struct sockaddr_un addr{
|
|
||||||
.sun_family = AF_UNIX,
|
|
||||||
.sun_path={0}
|
|
||||||
};
|
|
||||||
strcpy(addr.sun_path + 1, "rirud");
|
|
||||||
socklen_t socklen = sizeof(sa_family_t) + strlen(addr.sun_path + 1) + 1;
|
|
||||||
|
|
||||||
if (connect(fd_, reinterpret_cast<struct sockaddr *>(&addr), socklen) == -1) {
|
|
||||||
close(fd_);
|
|
||||||
fd_ = -1;
|
|
||||||
throw RirudSocketException(strerror(errno));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
RirudSocket::~RirudSocket() {
|
|
||||||
if (fd_ != -1)
|
|
||||||
close(fd_);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string RirudSocket::ReadFile(const std::string &path) {
|
|
||||||
Write(ACTION_READ_FILE);
|
|
||||||
Write(static_cast<uint32_t>(path.size()));
|
|
||||||
Write(path);
|
|
||||||
int32_t rirud_errno;
|
|
||||||
Read(rirud_errno);
|
|
||||||
if(rirud_errno != 0) {
|
|
||||||
throw RirudSocketException(strerror(rirud_errno));
|
|
||||||
}
|
|
||||||
uint32_t file_size;
|
|
||||||
Read(file_size);
|
|
||||||
std::string content;
|
|
||||||
content.resize(file_size);
|
|
||||||
Read(content);
|
|
||||||
return content;
|
|
||||||
}
|
|
||||||
|
|
||||||
void RirudSocket::Write(const char *buf, size_t len) const {
|
|
||||||
auto count = len;
|
|
||||||
while (count > 0) {
|
|
||||||
ssize_t size = write(fd_, buf, count < SSIZE_MAX ? count : SSIZE_MAX);
|
|
||||||
if (size == -1) {
|
|
||||||
if (errno == EINTR) continue;
|
|
||||||
else throw RirudSocketException(strerror(errno));
|
|
||||||
}
|
|
||||||
buf = buf + size;
|
|
||||||
count -= size;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void RirudSocket::Read(char *out, size_t len) const {
|
|
||||||
while (len > 0) {
|
|
||||||
ssize_t ret = read(fd_, out, len);
|
|
||||||
if (ret <= 0) {
|
|
||||||
if(errno == EINTR) continue;
|
|
||||||
else throw RirudSocketException(strerror(errno));
|
|
||||||
}
|
|
||||||
out = out + ret;
|
|
||||||
len -= ret;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
@ -1,64 +0,0 @@
|
||||||
/*
|
|
||||||
* This file is part of LSPosed.
|
|
||||||
*
|
|
||||||
* LSPosed is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* LSPosed is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with LSPosed. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2020 EdXposed Contributors
|
|
||||||
* Copyright (C) 2021 LSPosed Contributors
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
#include <filesystem>
|
|
||||||
|
|
||||||
|
|
||||||
class RirudSocket {
|
|
||||||
public:
|
|
||||||
// class DirIter {};
|
|
||||||
|
|
||||||
class RirudSocketException : public std::runtime_error {
|
|
||||||
public:
|
|
||||||
RirudSocketException(const std::string &what) : std::runtime_error(what) {}
|
|
||||||
};
|
|
||||||
|
|
||||||
RirudSocket();
|
|
||||||
|
|
||||||
std::string ReadFile(const std::string &path);
|
|
||||||
|
|
||||||
// DirIter ReadDir(const std::filesystem::path &path);
|
|
||||||
// DirIter RecursiveReadDir(const std::filesystem::path &path);
|
|
||||||
|
|
||||||
~RirudSocket();
|
|
||||||
|
|
||||||
private:
|
|
||||||
RirudSocket(const RirudSocket &) = delete;
|
|
||||||
|
|
||||||
RirudSocket operator=(const RirudSocket &) = delete;
|
|
||||||
|
|
||||||
|
|
||||||
inline static const uint32_t ACTION_READ_FILE = 4;
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
void Write(const T &);
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
void Read(T &);
|
|
||||||
|
|
||||||
void Write(const char *buf, size_t len) const;
|
|
||||||
|
|
||||||
void Read(char *buf, size_t len) const;
|
|
||||||
|
|
||||||
int fd_ = -1;
|
|
||||||
};
|
|
||||||
|
|
@ -22,45 +22,15 @@ SKIPUNZIP=1
|
||||||
|
|
||||||
abortC() {
|
abortC() {
|
||||||
rm -rf "${MODPATH}"
|
rm -rf "${MODPATH}"
|
||||||
if [[ ! -f /data/adb/lspd/misc_path ]]; then
|
if [ ! -f /data/adb/lspd/misc_path ]; then
|
||||||
[[ -d "${MISC_PATH}" ]] && rm -rf "${MISC_PATH}"
|
[ -d "${MISC_PATH}" ] && rm -rf "${MISC_PATH}"
|
||||||
fi
|
fi
|
||||||
abort "$1"
|
abort "$1"
|
||||||
}
|
}
|
||||||
|
|
||||||
getRandomNameExist() {
|
|
||||||
RAND_PATH=$4
|
|
||||||
RAND_SUFFIX=$3
|
|
||||||
RAND_PREFIX=$2
|
|
||||||
RAND_DIGIT=$1
|
|
||||||
RAND_RAND="$(cat /proc/sys/kernel/random/uuid|md5sum|cut -c 1-"${RAND_DIGIT}")"
|
|
||||||
RAND_PATH_EXIST=false
|
|
||||||
for TARGET in ${RAND_PATH}; do
|
|
||||||
if [[ -e "${TARGET}/${RAND_PREFIX}${RAND_RAND}${RAND_SUFFIX}" ]]; then
|
|
||||||
RAND_PATH_EXIST=true
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
if [[ "${RAND_PATH_EXIST}" == true ]]; then
|
|
||||||
getRandomNameExist "${RAND_DIGIT}" "${RAND_PREFIX}" "${RAND_SUFFIX}" "${RAND_PATH}"
|
|
||||||
else
|
|
||||||
echo "${RAND_RAND}"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
POUNDS="*********************************************************"
|
POUNDS="*********************************************************"
|
||||||
RIRU_PATH="/data/adb/riru"
|
|
||||||
RIRU_EDXP="$(getRandomNameExist 4 "libriru_" ".so" "
|
|
||||||
/system/lib
|
|
||||||
/system/lib64
|
|
||||||
")"
|
|
||||||
RIRU_MODULES="${RIRU_PATH}/modules"
|
|
||||||
RIRU_TARGET="${RIRU_MODULES}/${RIRU_EDXP}"
|
|
||||||
|
|
||||||
|
|
||||||
VERSION=$(grep_prop version "${TMPDIR}/module.prop")
|
VERSION=$(grep_prop version "${TMPDIR}/module.prop")
|
||||||
RIRU_MIN_API_VERSION=$(grep_prop api "${TMPDIR}/module.prop")
|
|
||||||
|
|
||||||
LIB_RIRU_EDXP="libriru_${RIRU_EDXP}.so"
|
|
||||||
|
|
||||||
### lang start ###
|
### lang start ###
|
||||||
# Default en_US
|
# Default en_US
|
||||||
|
|
@ -76,8 +46,6 @@ LANG_CUST_INST_CONF_OLD="Use previous path"
|
||||||
LANG_CUST_DISABLE_EDXP="**WARNING**: This installation will disable edxposed because of incompatibility"
|
LANG_CUST_DISABLE_EDXP="**WARNING**: This installation will disable edxposed because of incompatibility"
|
||||||
LANG_CUST_INST_CONF_NEW="Use new path"
|
LANG_CUST_INST_CONF_NEW="Use new path"
|
||||||
LANG_CUST_INST_COPY_LIB="Copying framework libraries"
|
LANG_CUST_INST_COPY_LIB="Copying framework libraries"
|
||||||
LANG_CUST_INST_REM_OLDCONF="Removing old configuration"
|
|
||||||
LANG_CUST_INST_COPT_EXTRA="Copying extra files"
|
|
||||||
LANG_CUST_INST_DONE="Welcome to"
|
LANG_CUST_INST_DONE="Welcome to"
|
||||||
|
|
||||||
LANG_CUST_ERR_VERIFY_FAIL="Unable to extract verify tool!"
|
LANG_CUST_ERR_VERIFY_FAIL="Unable to extract verify tool!"
|
||||||
|
|
@ -86,7 +54,6 @@ LANG_CUST_ERR_CONF_CREATE="Can't create configuration path"
|
||||||
LANG_CUST_ERR_CONF_STORE="Can't store configuration path"
|
LANG_CUST_ERR_CONF_STORE="Can't store configuration path"
|
||||||
LANG_CUST_ERR_CONF_FIRST="Can't create first install flag"
|
LANG_CUST_ERR_CONF_FIRST="Can't create first install flag"
|
||||||
LANG_CUST_ERR_CONF_UNINST="Can't write uninstall script"
|
LANG_CUST_ERR_CONF_UNINST="Can't write uninstall script"
|
||||||
LANG_CUST_ERR_EXTRA_CREATE="Can't create"
|
|
||||||
|
|
||||||
# verify
|
# verify
|
||||||
LANG_VERIFY_SUCCESS="Verified"
|
LANG_VERIFY_SUCCESS="Verified"
|
||||||
|
|
@ -109,9 +76,9 @@ LANG_UTIL_ERR_PLATFORM_UNSUPPORT="Unsupported platform"
|
||||||
LANG_CUST_INST_MIGRATE_CONF="Migrating configuration"
|
LANG_CUST_INST_MIGRATE_CONF="Migrating configuration"
|
||||||
|
|
||||||
# Load lang
|
# Load lang
|
||||||
if [[ ${BOOTMODE} == true ]]; then
|
if [ ${BOOTMODE} == true ]; then
|
||||||
locale=$(getprop persist.sys.locale|awk -F "-" '{print $1"_"$NF}')
|
locale=$(getprop persist.sys.locale|awk -F "-" '{print $1"_"$NF}')
|
||||||
[[ ${locale} == "" ]] && locale=$(settings get system system_locales|awk -F "," '{print $1}'|awk -F "-" '{print $1"_"$NF}')
|
[ ${locale} == "" ] && locale=$(settings get system system_locales|awk -F "," '{print $1}'|awk -F "-" '{print $1"_"$NF}')
|
||||||
file=${locale}.sh
|
file=${locale}.sh
|
||||||
unzip -o "$ZIPFILE" "${file}" -d "$TMPDIR" >&2
|
unzip -o "$ZIPFILE" "${file}" -d "$TMPDIR" >&2
|
||||||
unzip -o "$ZIPFILE" "${file}.sha256" -d "$TMPDIR" >&2
|
unzip -o "$ZIPFILE" "${file}.sha256" -d "$TMPDIR" >&2
|
||||||
|
|
@ -149,34 +116,32 @@ extract "${ZIPFILE}" 'post-fs-data.sh' "${MODPATH}"
|
||||||
extract "${ZIPFILE}" 'service.sh' "${MODPATH}"
|
extract "${ZIPFILE}" 'service.sh' "${MODPATH}"
|
||||||
extract "${ZIPFILE}" 'uninstall.sh' "${MODPATH}"
|
extract "${ZIPFILE}" 'uninstall.sh' "${MODPATH}"
|
||||||
|
|
||||||
extract "${ZIPFILE}" 'system/framework/lspd.dex' "${MODPATH}"
|
extract "${ZIPFILE}" 'framework/lspd.dex' "${MODPATH}"
|
||||||
|
|
||||||
if [ "$ARCH" = "x86" ] || [ "$ARCH" = "x64" ]; then
|
if [ "$ARCH" = "x86" ] || [ "$ARCH" = "x64" ]; then
|
||||||
ui_print "- ${LANG_CUST_INST_EXT_LIB_X86}"
|
ui_print "- ${LANG_CUST_INST_EXT_LIB_X86}"
|
||||||
extract "$ZIPFILE" 'system_x86/lib/libriru_lspd.so' "${MODPATH}"
|
extract "$ZIPFILE" 'riru_x86/lib/liblspd.so' "${MODPATH}"
|
||||||
mv "${MODPATH}/system_x86/lib" "${MODPATH}/system/lib"
|
|
||||||
|
|
||||||
if [ "$IS64BIT" = true ]; then
|
if [ "$IS64BIT" = true ]; then
|
||||||
ui_print "- ${LANG_CUST_INST_EXT_LIB_X64}"
|
ui_print "- ${LANG_CUST_INST_EXT_LIB_X64}"
|
||||||
extract "$ZIPFILE" 'system_x86/lib64/libriru_lspd.so' "${MODPATH}"
|
extract "$ZIPFILE" 'riru_x86/lib64/liblspd.so' "${MODPATH}"
|
||||||
mv "${MODPATH}/system_x86/lib64" "${MODPATH}/system/lib64"
|
|
||||||
fi
|
fi
|
||||||
|
mv "${MODPATH}/riru_x86" "${MODPATH}/riru"
|
||||||
else
|
else
|
||||||
ui_print "- ${LANG_CUST_INST_EXT_LIB_ARM}"
|
ui_print "- ${LANG_CUST_INST_EXT_LIB_ARM}"
|
||||||
extract "$ZIPFILE" 'system/lib/libriru_lspd.so' "${MODPATH}"
|
extract "$ZIPFILE" 'riru/lib/liblspd.so' "${MODPATH}"
|
||||||
|
|
||||||
if [ "$IS64BIT" = true ]; then
|
if [ "$IS64BIT" = true ]; then
|
||||||
ui_print "- ${LANG_CUST_INST_EXT_LIB_ARM64}"
|
ui_print "- ${LANG_CUST_INST_EXT_LIB_ARM64}"
|
||||||
extract "$ZIPFILE" 'system/lib64/libriru_lspd.so' "${MODPATH}"
|
extract "$ZIPFILE" 'riru/lib64/liblspd.so' "${MODPATH}"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ui_print "- ${LANG_CUST_INST_CONF_CREATE}"
|
ui_print "- ${LANG_CUST_INST_CONF_CREATE}"
|
||||||
if [[ -f /data/adb/lspd/misc_path ]]; then
|
if [ -f /data/adb/lspd/misc_path ]; then
|
||||||
# read current MISC_PATH
|
# read current MISC_PATH
|
||||||
MISC_PATH=$(cat /data/adb/lspd/misc_path)
|
MISC_PATH=$(cat /data/adb/lspd/misc_path)
|
||||||
ui_print " - ${LANG_CUST_INST_CONF_OLD} $MISC_PATH"
|
ui_print " - ${LANG_CUST_INST_CONF_OLD} $MISC_PATH"
|
||||||
elif [[ -f /data/adb/edxp/misc_path ]]; then
|
elif [ -f /data/adb/edxp/misc_path ]; then
|
||||||
mkdir -p /data/adb/lspd || abortC "! ${LANG_CUST_ERR_CONF_CREATE}"
|
mkdir -p /data/adb/lspd || abortC "! ${LANG_CUST_ERR_CONF_CREATE}"
|
||||||
MISC_PATH=$(cat /data/adb/edxp/misc_path | sed "s/edxp/lspd/")
|
MISC_PATH=$(cat /data/adb/edxp/misc_path | sed "s/edxp/lspd/")
|
||||||
echo $MISC_PATH > /data/adb/lspd/misc_path
|
echo $MISC_PATH > /data/adb/lspd/misc_path
|
||||||
|
|
@ -195,55 +160,24 @@ else
|
||||||
fi
|
fi
|
||||||
touch /data/adb/lspd/new_install || abortC "! ${LANG_CUST_ERR_CONF_FIRST}"
|
touch /data/adb/lspd/new_install || abortC "! ${LANG_CUST_ERR_CONF_FIRST}"
|
||||||
ui_print "- ${LANG_CUST_INST_COPY_LIB}"
|
ui_print "- ${LANG_CUST_INST_COPY_LIB}"
|
||||||
rm -rf "/data/adb/lspd/framework"
|
|
||||||
mv "${MODPATH}/system/framework" "/data/adb/lspd/framework"
|
|
||||||
extract "${ZIPFILE}" 'manager.apk' "/data/adb/lspd/"
|
extract "${ZIPFILE}" 'manager.apk' "/data/adb/lspd/"
|
||||||
mkdir -p /data/misc/$MISC_PATH
|
mkdir -p /data/misc/$MISC_PATH
|
||||||
set_perm /data/misc/$MISC_PATH 0 0 0771 "u:object_r:magisk_file:s0" || abortC "! ${LANG_CUST_ERR_PERM}"
|
set_perm /data/misc/$MISC_PATH 0 0 0771 "u:object_r:magisk_file:s0" || abortC "! ${LANG_CUST_ERR_PERM}"
|
||||||
|
|
||||||
if [[ ! -d /data/adb/lspd/config ]]; then
|
if [ ! -d /data/adb/lspd/config ]; then
|
||||||
mkdir -p /data/adb/lspd/config
|
mkdir -p /data/adb/lspd/config
|
||||||
ui_print "- ${LANG_CUST_INST_MIGRATE_CONF}"
|
ui_print "- ${LANG_CUST_INST_MIGRATE_CONF}"
|
||||||
cp -r /data/misc/$MISC_PATH/0/prefs /data/misc/$MISC_PATH/prefs
|
cp -r /data/misc/$MISC_PATH/0/prefs /data/misc/$MISC_PATH/prefs
|
||||||
/system/bin/app_process -Djava.class.path=/data/adb/lspd/framework/lspd.dex /system/bin --nice-name=lspd_config org.lsposed.lspd.service.ConfigManager
|
/system/bin/app_process -Djava.class.path=/data/adb/lspd/framework/lspd.dex /system/bin --nice-name=lspd_config org.lsposed.lspd.service.ConfigManager
|
||||||
fi
|
fi
|
||||||
echo "rm -rf /data/misc/$MISC_PATH" >> "${MODPATH}/uninstall.sh" || abortC "! ${LANG_CUST_ERR_CONF_UNINST}"
|
|
||||||
echo "[[ -f /data/adb/lspd/new_install ]] || rm -rf /data/adb/lspd" >> "${MODPATH}/uninstall.sh" || abortC "! ${LANG_CUST_ERR_CONF_UNINST}"
|
|
||||||
|
|
||||||
if [[ ! -e /data/adb/lspd/config/verbose_log ]]; then
|
echo "rm -rf /data/misc/$MISC_PATH" >> "${MODPATH}/uninstall.sh" || abortC "! ${LANG_CUST_ERR_CONF_UNINST}"
|
||||||
|
echo "[ -f /data/adb/lspd/new_install ] || rm -rf /data/adb/lspd" >> "${MODPATH}/uninstall.sh" || abortC "! ${LANG_CUST_ERR_CONF_UNINST}"
|
||||||
|
|
||||||
|
if [ ! -e /data/adb/lspd/config/verbose_log ]; then
|
||||||
echo "0" > /data/adb/lspd/config/verbose_log
|
echo "0" > /data/adb/lspd/config/verbose_log
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
mv "${MODPATH}/system/lib/libriru_lspd.so" "${MODPATH}/system/lib/${LIB_RIRU_EDXP}"
|
|
||||||
if [[ "${IS64BIT}" == true ]]; then
|
|
||||||
mv "${MODPATH}/system/lib64/libriru_lspd.so" "${MODPATH}/system/lib64/${LIB_RIRU_EDXP}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
ui_print "- ${LANG_CUST_INST_REM_OLDCONF}"
|
|
||||||
|
|
||||||
if [[ -f "${RIRU_MODULES}/lspd.prop" ]]; then
|
|
||||||
OLD_CONFIG=$(cat "${RIRU_MODULES}/lspd.prop")
|
|
||||||
rm -rf "${RIRU_MODULES}/${OLD_CONFIG}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ -e "${RIRU_MODULES}/lspd" ]]; then
|
|
||||||
rm -rf "${RIRU_MODULES}/lspd"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# extract Riru files
|
|
||||||
ui_print "- ${LANG_CUST_INST_COPT_EXTRA}"
|
|
||||||
|
|
||||||
[[ -d "${RIRU_TARGET}" ]] || mkdir -p "${RIRU_TARGET}" || abortC "! ${LANG_CUST_ERR_EXTRA_CREATE} ${RIRU_TARGET}"
|
|
||||||
|
|
||||||
echo "${RIRU_EDXP}">"${RIRU_MODULES}/lspd.prop"
|
|
||||||
|
|
||||||
rm -f "${RIRU_TARGET}/module.prop"
|
|
||||||
|
|
||||||
cp "${MODPATH}/module.prop" "${RIRU_TARGET}/module.prop" || abortC "! ${LANG_CUST_ERR_EXTRA_CREATE} ${RIRU_TARGET}/module.prop"
|
|
||||||
|
|
||||||
set_perm "$RIRU_TARGET/module.prop" 0 0 0600 $RIRU_SECONTEXT || abortC "! ${LANG_CUST_ERR_PERM}"
|
|
||||||
|
|
||||||
set_perm_recursive "${MODPATH}" 0 0 0755 0644
|
set_perm_recursive "${MODPATH}" 0 0 0755 0644
|
||||||
ui_print "- ${LANG_CUST_INST_DONE} LSPosed ${VERSION}!"
|
ui_print "- ${LANG_CUST_INST_DONE} LSPosed ${VERSION}!"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ grep_prop() {
|
||||||
local REGEX="s/^$1=//p"
|
local REGEX="s/^$1=//p"
|
||||||
shift
|
shift
|
||||||
local FILES="$@"
|
local FILES="$@"
|
||||||
[[ -z "$FILES" ]] && FILES='/system/build.prop'
|
[ -z "$FILES" ] && FILES='/system/build.prop'
|
||||||
sed -n "$REGEX" ${FILES} 2>/dev/null | head -n 1
|
sed -n "$REGEX" ${FILES} 2>/dev/null | head -n 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -75,7 +75,7 @@ loop_logcat() {
|
||||||
while true
|
while true
|
||||||
do
|
do
|
||||||
logcat $*
|
logcat $*
|
||||||
if [[ $? -ne 1 ]]; then
|
if [ $? -ne 1 ]; then
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
@ -114,12 +114,12 @@ start_log_catcher () {
|
||||||
LOG_FILE="${LOG_PATH}/${LOG_FILE_NAME}.log"
|
LOG_FILE="${LOG_PATH}/${LOG_FILE_NAME}.log"
|
||||||
PID_FILE="${LOG_PATH}/${LOG_FILE_NAME}.pid"
|
PID_FILE="${LOG_PATH}/${LOG_FILE_NAME}.pid"
|
||||||
mkdir -p ${LOG_PATH}
|
mkdir -p ${LOG_PATH}
|
||||||
if [[ ${CLEAN_OLD} == true ]]; then
|
if [ ${CLEAN_OLD} == true ]; then
|
||||||
rm "${LOG_FILE}.old"
|
rm "${LOG_FILE}.old"
|
||||||
mv "${LOG_FILE}" "${LOG_FILE}.old"
|
mv "${LOG_FILE}" "${LOG_FILE}.old"
|
||||||
fi
|
fi
|
||||||
rm "${LOG_PATH}/${LOG_FILE_NAME}.pid"
|
rm "${LOG_PATH}/${LOG_FILE_NAME}.pid"
|
||||||
if [[ ${START_NEW} == false ]]; then
|
if [ ${START_NEW} == false ]; then
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
touch "${PID_FILE}"
|
touch "${PID_FILE}"
|
||||||
|
|
@ -129,9 +129,9 @@ start_log_catcher () {
|
||||||
echo "${LOG_PID}">"${LOG_PATH}/${LOG_FILE_NAME}.pid"
|
echo "${LOG_PID}">"${LOG_PATH}/${LOG_FILE_NAME}.pid"
|
||||||
}
|
}
|
||||||
|
|
||||||
if [[ -f "/data/adb/riru/modules/lspd.prop" ]]; then
|
if [ -f "/data/adb/riru/modules/lspd.prop" ]; then
|
||||||
CONFIG=$(cat "/data/adb/riru/modules/lspd.prop")
|
CONFIG=$(cat "/data/adb/riru/modules/lspd.prop")
|
||||||
[[ -d "${TARGET}/${CONFIG}" ]] || mkdir -p "${TARGET}/${CONFIG}"
|
[ -d "${TARGET}/${CONFIG}" ] || mkdir -p "${TARGET}/${CONFIG}"
|
||||||
cp "${MODDIR}/module.prop" "${TARGET}/${CONFIG}/module.prop"
|
cp "${MODDIR}/module.prop" "${TARGET}/${CONFIG}/module.prop"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
@ -142,7 +142,7 @@ mv ${LOG_PATH} ${LOG_PATH}.old
|
||||||
mkdir -p ${LOG_PATH}
|
mkdir -p ${LOG_PATH}
|
||||||
chcon -R u:object_r:magisk_file:s0 ${LOG_PATH}
|
chcon -R u:object_r:magisk_file:s0 ${LOG_PATH}
|
||||||
|
|
||||||
if [[ ! -z "${MISC_PATH}" ]]; then
|
if [ ! -z "${MISC_PATH}" ]; then
|
||||||
chcon -R u:object_r:magisk_file:s0 "${BASE_PATH}"
|
chcon -R u:object_r:magisk_file:s0 "${BASE_PATH}"
|
||||||
chmod 771 "${BASE_PATH}"
|
chmod 771 "${BASE_PATH}"
|
||||||
print_log_head "${LOG_PATH}/modules.log"
|
print_log_head "${LOG_PATH}/modules.log"
|
||||||
|
|
@ -155,7 +155,7 @@ start_app_process() {
|
||||||
while true
|
while true
|
||||||
do
|
do
|
||||||
if [ -S "/dev/socket/zygote" ]; then
|
if [ -S "/dev/socket/zygote" ]; then
|
||||||
/system/bin/app_process -Djava.class.path=/data/adb/lspd/framework/lspd.dex /system/bin --nice-name=lspd org.lsposed.lspd.core.Main
|
/system/bin/app_process -Djava.class.path=$(magisk --path)/.magisk/modules/riru_lsposed/framework/lspd.dex /system/bin --nice-name=lspd org.lsposed.lspd.core.Main
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,22 +24,22 @@ MODDIR=${0%/*}
|
||||||
VARIANT="YAHFA"
|
VARIANT="YAHFA"
|
||||||
REMOVE=false
|
REMOVE=false
|
||||||
|
|
||||||
[[ "$(echo ${MODDIR} | grep sandhook)" != "" ]] && VARIANT="SandHook"
|
[ "$(echo ${MODDIR} | grep sandhook)" != "" ] && VARIANT="SandHook"
|
||||||
|
|
||||||
if [[ "${VARIANT}" == "SandHook" ]]; then
|
if [ "${VARIANT}" == "SandHook" ]; then
|
||||||
[[ -f "${MODDIR}/../riru_lsposed/module.prop" ]] || REMOVE=true
|
[ -f "${MODDIR}/../riru_lsposed/module.prop" ] || REMOVE=true
|
||||||
else
|
else
|
||||||
[[ -f "${MODDIR}/../riru_lsposed_sandhook/module.prop" ]] || REMOVE=true
|
[ -f "${MODDIR}/../riru_lsposed_sandhook/module.prop" ] || REMOVE=true
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "${REMOVE}" == true ]]; then
|
if [ "${REMOVE}" == true ]; then
|
||||||
rm -rf /data/misc/riru/modules/lspd
|
rm -rf /data/misc/riru/modules/lspd
|
||||||
if [[ -f "/data/adb/riru/modules/lspd.prop" ]]; then
|
if [ -f "/data/adb/riru/modules/lspd.prop" ]; then
|
||||||
OLD_CONFIG=$(cat "/data/adb/riru/modules/lspd.prop")
|
OLD_CONFIG=$(cat "/data/adb/riru/modules/lspd.prop")
|
||||||
rm -rf "/data/adb/riru/modules/${OLD_CONFIG}"
|
rm -rf "/data/adb/riru/modules/${OLD_CONFIG}"
|
||||||
rm "/data/adb/riru/modules/lspd.prop"
|
rm "/data/adb/riru/modules/lspd.prop"
|
||||||
fi
|
fi
|
||||||
if [[ -f "/data/misc/riru/modules/lspd.prop" ]]; then
|
if [ -f "/data/misc/riru/modules/lspd.prop" ]; then
|
||||||
OLD_CONFIG=$(cat "/data/misc/riru/modules/lspd.prop")
|
OLD_CONFIG=$(cat "/data/misc/riru/modules/lspd.prop")
|
||||||
rm -rf "/data/misc/riru/modules/${OLD_CONFIG}"
|
rm -rf "/data/misc/riru/modules/${OLD_CONFIG}"
|
||||||
rm "/data/misc/riru/modules/lspd.prop"
|
rm "/data/misc/riru/modules/lspd.prop"
|
||||||
|
|
|
||||||
|
|
@ -18,31 +18,29 @@
|
||||||
# Copyright (C) 2021 LSPosed Contributors
|
# Copyright (C) 2021 LSPosed Contributors
|
||||||
#
|
#
|
||||||
|
|
||||||
RIRU_PATH="/data/adb/riru"
|
|
||||||
RIRU_MODULE_ID="%%%RIRU_MODULE_ID%%%"
|
RIRU_MODULE_ID="%%%RIRU_MODULE_ID%%%"
|
||||||
RIRU_MODULE_PATH="$RIRU_PATH/modules/$RIRU_MODULE_ID"
|
RIRU_MODULE_API_VERSION=%%%RIRU_MODULE_API_VERSION%%%
|
||||||
RIRU_SECONTEXT="u:object_r:magisk_file:s0"
|
RIRU_MODULE_MIN_API_VERSION=%%%RIRU_MODULE_MIN_API_VERSION%%%
|
||||||
|
RIRU_MODULE_MIN_RIRU_VERSION_NAME="%%%RIRU_MODULE_MIN_RIRU_VERSION_NAME%%%"
|
||||||
|
|
||||||
|
|
||||||
check_riru_version() {
|
check_riru_version() {
|
||||||
RIRU_MIN_API_VERSION=%%%RIRU_MIN_API_VERSION%%%
|
RIRU_CORE_MODULES_PATH=/data/adb/modules/riru-core
|
||||||
RIRU_MIN_VERSION_NAME="%%%RIRU_MIN_VERSION_NAME%%%"
|
RIRU_CORE_MODULES_UPDATE_PATH=/data/adb/modules_update/riru-core
|
||||||
|
if [ ! -f "$RIRU_CORE_MODULES_UPDATE_PATH/api_version" ] && [ ! -f "$RIRU_CORE_MODULES_PATH/api_version" ] && [ ! -f "/data/adb/riru/api_version" ] && [ ! -f "/data/adb/riru/api_version.new" ]; then
|
||||||
if [ ! -f "$RIRU_PATH/api_version" ] && [ ! -f "$RIRU_PATH/api_version.new" ]; then
|
ui_print "*********************************************************"
|
||||||
ui_print "${POUNDS}"
|
ui_print "! Riru $RIRU_MODULE_MIN_RIRU_VERSION_NAME or above is required"
|
||||||
ui_print "! ${LANG_UTIL_ERR_RIRU_NOT_FOUND_1}"
|
ui_print "! Please install Riru from Magisk Manager or https://github.com/RikkaApps/Riru/releases"
|
||||||
ui_print "! ${LANG_UTIL_ERR_RIRU_NOT_FOUND_2}"
|
abort "*********************************************************"
|
||||||
[[ ${BOOTMODE} == true ]] && am start -a android.intent.action.VIEW -d https://github.com/RikkaApps/Riru/releases
|
|
||||||
abortC "${POUNDS}"
|
|
||||||
fi
|
fi
|
||||||
RIRU_API_VERSION=$(cat "$RIRU_PATH/api_version.new") || RIRU_API_VERSION=$(cat "$RIRU_PATH/api_version") || RIRU_API_VERSION=0
|
RIRU_API=$(cat "$RIRU_CORE_MODULES_UPDATE_PATH/api_version") || RIRU_API=$(cat "$RIRU_CORE_MODULES_PATH/api_version") || RIRU_API=$(cat "/data/adb/riru/api_version.new") || RIRU_API=$(cat "/data/adb/riru/api_version") || RIRU_API=0
|
||||||
[ "$RIRU_API_VERSION" -eq "$RIRU_API_VERSION" ] || RIRU_API_VERSION=0
|
[ "$RIRU_API" -eq "$RIRU_API" ] || RIRU_API=0
|
||||||
ui_print "- Riru API ${LANG_CUST_INST_VERSION}: $RIRU_API_VERSION"
|
ui_print "- Riru API version: $RIRU_API"
|
||||||
if [ "$RIRU_API_VERSION" -lt $RIRU_MIN_API_VERSION ]; then
|
if [ "$RIRU_API" -lt $RIRU_MODULE_MIN_API_VERSION ]; then
|
||||||
ui_print "${POUNDS}"
|
ui_print "*********************************************************"
|
||||||
ui_print "! Riru $RIRU_MIN_VERSION_NAME ${LANG_UTIL_ERR_RIRU_LOW_1}"
|
ui_print "! Riru $RIRU_MODULE_MIN_RIRU_VERSION_NAME or above is required"
|
||||||
ui_print "! ${LANG_UTIL_ERR_RIRU_LOW_2}"
|
ui_print "! Please upgrade Riru from Magisk Manager or https://github.com/RikkaApps/Riru/releases"
|
||||||
[[ ${BOOTMODE} == true ]] && am start -a android.intent.action.VIEW -d https://github.com/RikkaApps/Riru/releases
|
abort "*********************************************************"
|
||||||
abortC "${POUNDS}"
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -54,12 +52,12 @@ require_new_android() {
|
||||||
ui_print "${POUNDS}"
|
ui_print "${POUNDS}"
|
||||||
ui_print "! ${LANG_UTIL_ERR_ANDROID_UNSUPPORT_1} ${1} ${LANG_UTIL_ERR_ANDROID_UNSUPPORT_2}"
|
ui_print "! ${LANG_UTIL_ERR_ANDROID_UNSUPPORT_1} ${1} ${LANG_UTIL_ERR_ANDROID_UNSUPPORT_2}"
|
||||||
ui_print "! ${LANG_UTIL_ERR_ANDROID_UNSUPPORT_3}"
|
ui_print "! ${LANG_UTIL_ERR_ANDROID_UNSUPPORT_3}"
|
||||||
[[ ${BOOTMODE} == true ]] && am start -a android.intent.action.VIEW -d https://github.com/LSPosed/LSPosed/wiki/Available-Android-versions
|
[ ${BOOTMODE} == true ] && am start -a android.intent.action.VIEW -d https://github.com/LSPosed/LSPosed/wiki/Available-Android-versions
|
||||||
abortC "${POUNDS}"
|
abortC "${POUNDS}"
|
||||||
}
|
}
|
||||||
|
|
||||||
lspd_check_architecture() {
|
lspd_check_architecture() {
|
||||||
if [[ "${ARCH}" != "arm" && "${ARCH}" != "arm64" && "${ARCH}" != "x86" && "${ARCH}" != "x64" ]]; then
|
if [ "${ARCH}" != "arm" && "${ARCH}" != "arm64" && "${ARCH}" != "x86" && "${ARCH}" != "x64" ]; then
|
||||||
abortC "! ${LANG_UTIL_ERR_PLATFORM_UNSUPPORT}: ${ARCH}"
|
abortC "! ${LANG_UTIL_ERR_PLATFORM_UNSUPPORT}: ${ARCH}"
|
||||||
else
|
else
|
||||||
ui_print "- ${LANG_UTIL_PLATFORM}: ${ARCH}"
|
ui_print "- ${LANG_UTIL_PLATFORM}: ${ARCH}"
|
||||||
|
|
@ -67,7 +65,7 @@ lspd_check_architecture() {
|
||||||
}
|
}
|
||||||
|
|
||||||
check_android_version() {
|
check_android_version() {
|
||||||
if [[ ${API} -ge 27 ]]; then
|
if [ ${API} -ge 27 ]; then
|
||||||
ui_print "- Android SDK ${LANG_CUST_INST_VERSION}: ${API}"
|
ui_print "- Android SDK ${LANG_CUST_INST_VERSION}: ${API}"
|
||||||
else
|
else
|
||||||
require_new_android "${API}"
|
require_new_android "${API}"
|
||||||
|
|
|
||||||
|
|
@ -34,8 +34,6 @@ LANG_CUST_INST_CONF_OLD="使用旧目录"
|
||||||
LANG_CUST_DISABLE_EDXP="**警告**: 由于不兼容,此次安装会自动禁用EdXposed"
|
LANG_CUST_DISABLE_EDXP="**警告**: 由于不兼容,此次安装会自动禁用EdXposed"
|
||||||
LANG_CUST_INST_CONF_NEW="使用新目录"
|
LANG_CUST_INST_CONF_NEW="使用新目录"
|
||||||
LANG_CUST_INST_COPY_LIB="正在复制框架运行库"
|
LANG_CUST_INST_COPY_LIB="正在复制框架运行库"
|
||||||
LANG_CUST_INST_REM_OLDCONF="正在移除老旧配置"
|
|
||||||
LANG_CUST_INST_COPT_EXTRA="正在复制文件"
|
|
||||||
LANG_CUST_INST_DONE="欢迎使用"
|
LANG_CUST_INST_DONE="欢迎使用"
|
||||||
|
|
||||||
LANG_CUST_ERR_VERIFY_FAIL="无法解压校验工具!"
|
LANG_CUST_ERR_VERIFY_FAIL="无法解压校验工具!"
|
||||||
|
|
@ -45,7 +43,6 @@ LANG_CUST_ERR_CONF_CREATE="无法创建配置路径"
|
||||||
LANG_CUST_ERR_CONF_STORE="无法写入配置路径"
|
LANG_CUST_ERR_CONF_STORE="无法写入配置路径"
|
||||||
LANG_CUST_ERR_CONF_FIRST="无法创建首次安装标识"
|
LANG_CUST_ERR_CONF_FIRST="无法创建首次安装标识"
|
||||||
LANG_CUST_ERR_CONF_UNINST="无法写入卸载脚本"
|
LANG_CUST_ERR_CONF_UNINST="无法写入卸载脚本"
|
||||||
LANG_CUST_ERR_EXTRA_CREATE="无法创建"
|
|
||||||
|
|
||||||
# verify
|
# verify
|
||||||
LANG_VERIFY_SUCCESS="已验证"
|
LANG_VERIFY_SUCCESS="已验证"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue