From 96fbd2d045dd0f3263557a0186435e5920def899 Mon Sep 17 00:00:00 2001 From: tehcneko <7764726+tehcneko@users.noreply.github.com> Date: Sat, 20 Feb 2021 22:30:01 +0800 Subject: [PATCH] [core] Remove unused codes --- core/build.gradle | 38 +-------- .../hooker/LoadedApkConstructorHooker.java | 81 ------------------- .../hooker/StartBootstrapServicesHooker.java | 62 -------------- .../StartBootstrapServicesHooker11.java | 66 --------------- .../sandhook/hooker/SystemMainHooker.java | 71 ---------------- 5 files changed, 2 insertions(+), 316 deletions(-) delete mode 100644 core/src/main/java/io/github/lsposed/lspd/sandhook/hooker/LoadedApkConstructorHooker.java delete mode 100644 core/src/main/java/io/github/lsposed/lspd/sandhook/hooker/StartBootstrapServicesHooker.java delete mode 100644 core/src/main/java/io/github/lsposed/lspd/sandhook/hooker/StartBootstrapServicesHooker11.java delete mode 100644 core/src/main/java/io/github/lsposed/lspd/sandhook/hooker/SystemMainHooker.java diff --git a/core/build.gradle b/core/build.gradle index a68c23ad..0daea3b3 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -18,7 +18,6 @@ * Copyright (C) 2021 LSPosed Contributors */ -import groovy.xml.XmlUtil import org.apache.tools.ant.filters.FixCrLfFilter import org.gradle.internal.os.OperatingSystem @@ -133,49 +132,16 @@ android { } } -task cleanTemplate(type: Delete) { - delete file(templateSystemx86Path) -} - -preBuild.doLast { - def imlFile = file(project.name + ".iml") - try { - def parsedXml = (new XmlParser()).parse(imlFile) - def jdkNode = parsedXml.component[1].orderEntry.find { it.'@type' == 'jdk' } - parsedXml.component[1].remove(jdkNode) - def sdkString = "Android API " + android.compileSdkVersion.substring("android-".length()) + " Platform" - new Node(parsedXml.component[1], 'orderEntry', ['type': 'jdk', 'jdkName': sdkString, 'jdkType': 'Android SDK']) - XmlUtil.serialize(parsedXml, new FileOutputStream(imlFile)) - } catch (FileNotFoundException ignored) { - // nop, iml not found - } -} - afterEvaluate { - task("copyCommonProperties", type: Copy) { - from file("${projectDir}/template_override/") - into file(templateRootPath) - } android.applicationVariants.all { variant -> def variantCapped = variant.name.capitalize() def variantLowered = variant.name.toLowerCase() def zipFileName = "${module_name}-${rootProject.ext.versionName}-${rootProject.ext.versionCode}-${variantLowered}.zip" - task("copyMainDex${variantCapped}", type: Copy) { - def dexOutPath = variant.name.contains("release") ? - "${buildDir}/intermediates/dex/${variantLowered}/minify${variantCapped}WithR8" : - "${buildDir}/intermediates/dex/${variantLowered}/mergeDex${variantCapped}" - from (dexOutPath){ - rename("classes.dex", "lspd.dex") - } - destinationDir file(zipPathMagiskReleasePath + "system/framework/") - outputs.upToDateWhen { false } - } - delete file(zipPathMagiskReleasePath) - def prepareMagiskFilesTask = task("prepareMagiskFiles${variantCapped}", type: Delete) { + def prepareMagiskFilesTask = task("prepareMagiskFiles${variantCapped}") { dependsOn "assemble${variantCapped}" dependsOn tasks.getByPath(":key-selector:copyKeySelector${variantCapped}LibraryToMagiskTemplate") doFirst { @@ -195,7 +161,7 @@ afterEvaluate { } } def libPathRelease = "${buildDir}/intermediates/cmake/${variantLowered}/obj" - def exclude_list = ["riru.sh"] + def exclude_list = ["util_functions.sh"] doLast { def dexOutPath = variant.name.contains("release") ? "${buildDir}/intermediates/dex/${variantLowered}/minify${variantCapped}WithR8" : diff --git a/core/src/main/java/io/github/lsposed/lspd/sandhook/hooker/LoadedApkConstructorHooker.java b/core/src/main/java/io/github/lsposed/lspd/sandhook/hooker/LoadedApkConstructorHooker.java deleted file mode 100644 index 2656b6e9..00000000 --- a/core/src/main/java/io/github/lsposed/lspd/sandhook/hooker/LoadedApkConstructorHooker.java +++ /dev/null @@ -1,81 +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 . - * - * Copyright (C) 2020 EdXposed Contributors - * Copyright (C) 2021 LSPosed Contributors - */ - -package io.github.lsposed.lspd.sandhook.hooker; - -import android.app.ActivityThread; -import android.app.LoadedApk; -import android.content.pm.ApplicationInfo; -import android.content.res.CompatibilityInfo; - -import io.github.lsposed.common.KeepMembers; -import io.github.lsposed.lspd.hooker.LoadedApkCstrHooker; -import com.swift.sandhook.SandHook; -import com.swift.sandhook.annotation.HookClass; -import com.swift.sandhook.annotation.HookMethod; -import com.swift.sandhook.annotation.HookMethodBackup; -import com.swift.sandhook.annotation.SkipParamCheck; -import com.swift.sandhook.annotation.ThisObject; - -import java.lang.reflect.Method; - -import de.robv.android.xposed.XC_MethodHook; -import de.robv.android.xposed.annotation.ApiSensitive; -import de.robv.android.xposed.annotation.Level; - -@ApiSensitive(Level.LOW) -@HookClass(LoadedApk.class) -public class LoadedApkConstructorHooker implements KeepMembers { - public static String className = "android.app.LoadedApk"; - public static String methodName = ""; - public static String methodSig = "(Landroid/app/ActivityThread;" + - "Landroid/content/pm/ApplicationInfo;" + - "Landroid/content/res/CompatibilityInfo;" + - "Ljava/lang/ClassLoader;ZZZ)V"; - - @HookMethodBackup - @SkipParamCheck - static Method backup; - - @HookMethod - public static void hook(@ThisObject Object thiz, ActivityThread activityThread, - ApplicationInfo aInfo, CompatibilityInfo compatInfo, - ClassLoader baseLoader, boolean securityViolation, - boolean includeCode, boolean registerPackage) throws Throwable { - final XC_MethodHook methodHook = new LoadedApkCstrHooker(); - final XC_MethodHook.MethodHookParam param = new XC_MethodHook.MethodHookParam(); - param.thisObject = thiz; - param.args = new Object[]{activityThread, aInfo, compatInfo, baseLoader, securityViolation, - includeCode, registerPackage}; - methodHook.callBeforeHookedMethod(param); - if (!param.returnEarly) { - backup(thiz, activityThread, aInfo, compatInfo, baseLoader, securityViolation, - includeCode, registerPackage); - } - methodHook.callAfterHookedMethod(param); - } - - public static void backup(Object thiz, ActivityThread activityThread, - ApplicationInfo aInfo, CompatibilityInfo compatInfo, - ClassLoader baseLoader, boolean securityViolation, - boolean includeCode, boolean registerPackage) throws Throwable { - SandHook.callOriginByBackup(backup, thiz, activityThread, aInfo, compatInfo, baseLoader, securityViolation, includeCode, registerPackage); - } -} \ No newline at end of file diff --git a/core/src/main/java/io/github/lsposed/lspd/sandhook/hooker/StartBootstrapServicesHooker.java b/core/src/main/java/io/github/lsposed/lspd/sandhook/hooker/StartBootstrapServicesHooker.java deleted file mode 100644 index dab2027e..00000000 --- a/core/src/main/java/io/github/lsposed/lspd/sandhook/hooker/StartBootstrapServicesHooker.java +++ /dev/null @@ -1,62 +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 . - * - * Copyright (C) 2020 EdXposed Contributors - * Copyright (C) 2021 LSPosed Contributors - */ - -package io.github.lsposed.lspd.sandhook.hooker; - -import io.github.lsposed.common.KeepMembers; - -import com.swift.sandhook.SandHook; -import com.swift.sandhook.annotation.HookMethod; -import com.swift.sandhook.annotation.HookMethodBackup; -import com.swift.sandhook.annotation.HookReflectClass; -import com.swift.sandhook.annotation.SkipParamCheck; -import com.swift.sandhook.annotation.ThisObject; - -import java.lang.reflect.Method; - -import de.robv.android.xposed.XC_MethodHook; - -@HookReflectClass("com.android.server.SystemServer") -public class StartBootstrapServicesHooker implements KeepMembers { - public static String className = "com.android.server.SystemServer"; - public static String methodName = "startBootstrapServices"; - public static String methodSig = "()V"; - - @HookMethodBackup("startBootstrapServices") - @SkipParamCheck - static Method backup; - - @HookMethod("startBootstrapServices") - public static void hook(@ThisObject Object systemServer) throws Throwable { - final XC_MethodHook methodHook = new io.github.lsposed.lspd.hooker.StartBootstrapServicesHooker(); - final XC_MethodHook.MethodHookParam param = new XC_MethodHook.MethodHookParam(); - param.thisObject = systemServer; - param.args = new Object[]{}; - methodHook.callBeforeHookedMethod(param); - if (!param.returnEarly) { - backup(systemServer); - } - methodHook.callAfterHookedMethod(param); - } - - public static void backup(Object systemServer) throws Throwable { - SandHook.callOriginByBackup(backup, systemServer); - } -} diff --git a/core/src/main/java/io/github/lsposed/lspd/sandhook/hooker/StartBootstrapServicesHooker11.java b/core/src/main/java/io/github/lsposed/lspd/sandhook/hooker/StartBootstrapServicesHooker11.java deleted file mode 100644 index a3ea0275..00000000 --- a/core/src/main/java/io/github/lsposed/lspd/sandhook/hooker/StartBootstrapServicesHooker11.java +++ /dev/null @@ -1,66 +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 . - * - * Copyright (C) 2020 EdXposed Contributors - * Copyright (C) 2021 LSPosed Contributors - */ - -package io.github.lsposed.lspd.sandhook.hooker; - -import io.github.lsposed.common.KeepMembers; -import io.github.lsposed.lspd.hooker.StartBootstrapServicesHooker; -import com.swift.sandhook.SandHook; -import com.swift.sandhook.annotation.HookMethod; -import com.swift.sandhook.annotation.HookMethodBackup; -import com.swift.sandhook.annotation.HookReflectClass; -import com.swift.sandhook.annotation.Param; -import com.swift.sandhook.annotation.SkipParamCheck; -import com.swift.sandhook.annotation.ThisObject; - -import java.lang.reflect.Method; - -import de.robv.android.xposed.XC_MethodHook; -import de.robv.android.xposed.annotation.ApiSensitive; -import de.robv.android.xposed.annotation.Level; - -@ApiSensitive(Level.LOW) -@HookReflectClass("com.android.server.SystemServer") -public class StartBootstrapServicesHooker11 implements KeepMembers { - public static String className = "com.android.server.SystemServer"; - public static String methodName = "startBootstrapServices"; - public static String methodSig = "(Lcom/android/server/utils/TimingsTraceAndSlog;)V"; - - @HookMethodBackup("startBootstrapServices") - @SkipParamCheck - static Method backup; - - @HookMethod("startBootstrapServices") - public static void hook(@ThisObject Object systemServer, @Param("com.android.server.utils.TimingsTraceAndSlog") Object traceAndSlog) throws Throwable { - final XC_MethodHook methodHook = new StartBootstrapServicesHooker(); - final XC_MethodHook.MethodHookParam param = new XC_MethodHook.MethodHookParam(); - param.thisObject = systemServer; - param.args = new Object[]{traceAndSlog}; - methodHook.callBeforeHookedMethod(param); - if (!param.returnEarly) { - backup(systemServer, traceAndSlog); - } - methodHook.callAfterHookedMethod(param); - } - - public static void backup(Object systemServer, Object traceAndSlog) throws Throwable { - SandHook.callOriginByBackup(backup, systemServer, traceAndSlog); - } -} diff --git a/core/src/main/java/io/github/lsposed/lspd/sandhook/hooker/SystemMainHooker.java b/core/src/main/java/io/github/lsposed/lspd/sandhook/hooker/SystemMainHooker.java deleted file mode 100644 index cc79775a..00000000 --- a/core/src/main/java/io/github/lsposed/lspd/sandhook/hooker/SystemMainHooker.java +++ /dev/null @@ -1,71 +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 . - * - * Copyright (C) 2020 EdXposed Contributors - * Copyright (C) 2021 LSPosed Contributors - */ - -package io.github.lsposed.lspd.sandhook.hooker; - -import android.app.ActivityThread; - -import io.github.lsposed.common.KeepMembers; - -import com.swift.sandhook.SandHook; -import com.swift.sandhook.annotation.HookClass; -import com.swift.sandhook.annotation.HookMethod; -import com.swift.sandhook.annotation.HookMethodBackup; - -import java.lang.reflect.Method; - -import de.robv.android.xposed.XC_MethodHook; -import de.robv.android.xposed.annotation.ApiSensitive; -import de.robv.android.xposed.annotation.Level; - - -@ApiSensitive(Level.LOW) -// system_server initialization -// ed: only support sdk >= 21 for now -@HookClass(ActivityThread.class) -public class SystemMainHooker implements KeepMembers { - - public static String className = "android.app.ActivityThread"; - public static String methodName = "systemMain"; - public static String methodSig = "()Landroid/app/ActivityThread;"; - - public static ClassLoader systemServerCL; - - @HookMethodBackup("systemMain") - static Method backup; - - @HookMethod("systemMain") - public static ActivityThread hook() throws Throwable { - final XC_MethodHook methodHook = new io.github.lsposed.lspd.hooker.SystemMainHooker(); - final XC_MethodHook.MethodHookParam param = new XC_MethodHook.MethodHookParam(); - param.thisObject = null; - param.args = new Object[]{}; - methodHook.callBeforeHookedMethod(param); - if (!param.returnEarly) { - param.setResult(backup()); - } - methodHook.callAfterHookedMethod(param); - return (ActivityThread) param.getResult(); - } - - public static ActivityThread backup() throws Throwable { - return (ActivityThread) SandHook.callOriginByBackup(backup, null); - } -} \ No newline at end of file