diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 2cca70d..5eebdc3 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -36,7 +36,7 @@ android:name="xposedminversion" android:value="30" /> - + diff --git a/app/src/main/java/me/firesun/wechat/enhancement/Main.java b/app/src/main/java/me/firesun/wechat/enhancement/Main.java index 48f1a1a..b7e4e6c 100644 --- a/app/src/main/java/me/firesun/wechat/enhancement/Main.java +++ b/app/src/main/java/me/firesun/wechat/enhancement/Main.java @@ -5,6 +5,8 @@ import android.content.pm.PackageInfo; import android.content.pm.PackageManager; +import java.util.List; + import de.robv.android.xposed.IXposedHookLoadPackage; import de.robv.android.xposed.XC_MethodHook; import de.robv.android.xposed.XposedHelpers; @@ -14,6 +16,7 @@ import me.firesun.wechat.enhancement.plugin.AntiSnsDelete; import me.firesun.wechat.enhancement.plugin.AutoLogin; import me.firesun.wechat.enhancement.plugin.HideModule; +import me.firesun.wechat.enhancement.plugin.IPlugin; import me.firesun.wechat.enhancement.plugin.LuckMoney; import me.firesun.wechat.enhancement.util.HookParams; import me.firesun.wechat.enhancement.util.SearchClasses; @@ -23,6 +26,15 @@ public class Main implements IXposedHookLoadPackage { + private static IPlugin[] plugins={ + new ADBlock(), + new AntiRevoke(), + new AntiSnsDelete(), + new AutoLogin(), + new HideModule(), + new LuckMoney(), + }; + @Override public void handleLoadPackage(final LoadPackageParam lpparam) { if (lpparam.packageName.equals(HookParams.WECHAT_PACKAGE_NAME)) { @@ -64,17 +76,16 @@ private String getVersionName(Context context, String packageName) { return ""; } + private void loadPlugins(LoadPackageParam lpparam) { - try { - ADBlock.getInstance().hook(lpparam); - AntiRevoke.getInstance().hook(lpparam); - AntiSnsDelete.getInstance().hook(lpparam); - LuckMoney.getInstance().hook(lpparam); - AutoLogin.getInstance().hook(lpparam); - HideModule.getInstance().hook(lpparam); - } catch (Error | Exception e) { - log("loadPlugins error" + e); + for (IPlugin plugin:plugins) { + try { + plugin.hook(lpparam); + } catch (Error | Exception e) { + log("loadPlugins error" + e); + } } + } } diff --git a/app/src/main/java/me/firesun/wechat/enhancement/plugin/ADBlock.java b/app/src/main/java/me/firesun/wechat/enhancement/plugin/ADBlock.java index b839534..689ab18 100644 --- a/app/src/main/java/me/firesun/wechat/enhancement/plugin/ADBlock.java +++ b/app/src/main/java/me/firesun/wechat/enhancement/plugin/ADBlock.java @@ -8,18 +8,8 @@ import me.firesun.wechat.enhancement.util.HookParams; -public class ADBlock { - private static ADBlock instance = null; - - private ADBlock() { - } - - public static ADBlock getInstance() { - if (instance == null) - instance = new ADBlock(); - return instance; - } - +public class ADBlock implements IPlugin { + @Override public void hook(XC_LoadPackage.LoadPackageParam lpparam) { XposedHelpers.findAndHookMethod(HookParams.getInstance().XMLParserClassName, lpparam.classLoader, HookParams.getInstance().XMLParserMethod, String.class, String.class, new XC_MethodHook() { @Override diff --git a/app/src/main/java/me/firesun/wechat/enhancement/plugin/AntiRevoke.java b/app/src/main/java/me/firesun/wechat/enhancement/plugin/AntiRevoke.java index 374c4ee..79f8ff9 100644 --- a/app/src/main/java/me/firesun/wechat/enhancement/plugin/AntiRevoke.java +++ b/app/src/main/java/me/firesun/wechat/enhancement/plugin/AntiRevoke.java @@ -15,21 +15,12 @@ import me.firesun.wechat.enhancement.util.HookParams; -public class AntiRevoke { - private static AntiRevoke instance = null; +public class AntiRevoke implements IPlugin { private static Map msgCacheMap = new HashMap<>(); private static Object storageInsertClazz; - private AntiRevoke() { - } - - public static AntiRevoke getInstance() { - if (instance == null) - instance = new AntiRevoke(); - return instance; - } - - public static void hook(XC_LoadPackage.LoadPackageParam lpparam) { + @Override + public void hook(XC_LoadPackage.LoadPackageParam lpparam) { XposedHelpers.findAndHookMethod(HookParams.getInstance().SQLiteDatabaseClassName, lpparam.classLoader, HookParams.getInstance().SQLiteDatabaseUpdateMethod, String.class, ContentValues.class, String.class, String[].class, int.class, new XC_MethodHook() { @Override protected void beforeHookedMethod(MethodHookParam param) { @@ -108,7 +99,7 @@ protected void afterHookedMethod(MethodHookParam param) { }); } - private static void handleMessageRecall(ContentValues contentValues) { + private void handleMessageRecall(ContentValues contentValues) { long msgId = contentValues.getAsLong("msgId"); Object msg = msgCacheMap.get(msgId); diff --git a/app/src/main/java/me/firesun/wechat/enhancement/plugin/AntiSnsDelete.java b/app/src/main/java/me/firesun/wechat/enhancement/plugin/AntiSnsDelete.java index 036d8a1..6ade430 100644 --- a/app/src/main/java/me/firesun/wechat/enhancement/plugin/AntiSnsDelete.java +++ b/app/src/main/java/me/firesun/wechat/enhancement/plugin/AntiSnsDelete.java @@ -13,19 +13,8 @@ import static java.util.Arrays.copyOfRange; -public class AntiSnsDelete { - private static AntiSnsDelete instance = null; - - private AntiSnsDelete() { - } - - public static AntiSnsDelete getInstance() { - if (instance == null) - instance = new AntiSnsDelete(); - return instance; - } - - +public class AntiSnsDelete implements IPlugin { + @Override public void hook(XC_LoadPackage.LoadPackageParam lpparam) { XposedHelpers.findAndHookMethod(HookParams.getInstance().SQLiteDatabaseClassName, lpparam.classLoader, HookParams.getInstance().SQLiteDatabaseUpdateMethod, String.class, ContentValues.class, String.class, String[].class, int.class, new XC_MethodHook() { diff --git a/app/src/main/java/me/firesun/wechat/enhancement/plugin/AutoLogin.java b/app/src/main/java/me/firesun/wechat/enhancement/plugin/AutoLogin.java index 42726ef..1f0128a 100644 --- a/app/src/main/java/me/firesun/wechat/enhancement/plugin/AutoLogin.java +++ b/app/src/main/java/me/firesun/wechat/enhancement/plugin/AutoLogin.java @@ -13,18 +13,8 @@ import me.firesun.wechat.enhancement.util.HookParams; -public class AutoLogin { - private static AutoLogin instance = null; - - private AutoLogin() { - } - - public static AutoLogin getInstance() { - if (instance == null) - instance = new AutoLogin(); - return instance; - } - +public class AutoLogin implements IPlugin { + @Override public void hook(XC_LoadPackage.LoadPackageParam lpparam) { XposedHelpers.findAndHookMethod(android.app.Activity.class, "onStart", new XC_MethodHook() { @Override diff --git a/app/src/main/java/me/firesun/wechat/enhancement/plugin/HideModule.java b/app/src/main/java/me/firesun/wechat/enhancement/plugin/HideModule.java index 00ffdb7..34cb90a 100644 --- a/app/src/main/java/me/firesun/wechat/enhancement/plugin/HideModule.java +++ b/app/src/main/java/me/firesun/wechat/enhancement/plugin/HideModule.java @@ -13,18 +13,8 @@ import me.firesun.wechat.enhancement.util.HookParams; -public class HideModule { - private static HideModule instance = null; - - private HideModule() { - } - - public static HideModule getInstance() { - if (instance == null) - instance = new HideModule(); - return instance; - } - +public class HideModule implements IPlugin { + @Override public void hook(XC_LoadPackage.LoadPackageParam lpparam) { XposedHelpers.findAndHookMethod("android.app.ApplicationPackageManager", lpparam.classLoader, "getInstalledApplications", int.class, new XC_MethodHook() { @Override diff --git a/app/src/main/java/me/firesun/wechat/enhancement/plugin/IPlugin.java b/app/src/main/java/me/firesun/wechat/enhancement/plugin/IPlugin.java new file mode 100644 index 0000000..4cfd461 --- /dev/null +++ b/app/src/main/java/me/firesun/wechat/enhancement/plugin/IPlugin.java @@ -0,0 +1,7 @@ +package me.firesun.wechat.enhancement.plugin; + +import de.robv.android.xposed.callbacks.XC_LoadPackage; + +public interface IPlugin { + public void hook(XC_LoadPackage.LoadPackageParam lpparam); +} diff --git a/app/src/main/java/me/firesun/wechat/enhancement/plugin/LuckMoney.java b/app/src/main/java/me/firesun/wechat/enhancement/plugin/LuckMoney.java index 26f625a..ef045d4 100644 --- a/app/src/main/java/me/firesun/wechat/enhancement/plugin/LuckMoney.java +++ b/app/src/main/java/me/firesun/wechat/enhancement/plugin/LuckMoney.java @@ -34,20 +34,11 @@ import static de.robv.android.xposed.XposedHelpers.newInstance; -public class LuckMoney { - private static LuckMoney instance = null; +public class LuckMoney implements IPlugin { private static Object requestCaller; private static List luckyMoneyMessages = new ArrayList<>(); - private LuckMoney() { - } - - public static LuckMoney getInstance() { - if (instance == null) - instance = new LuckMoney(); - return instance; - } - + @Override public void hook(final XC_LoadPackage.LoadPackageParam lpparam) { XposedHelpers.findAndHookMethod(HookParams.getInstance().SQLiteDatabaseClassName, lpparam.classLoader, HookParams.getInstance().SQLiteDatabaseInsertMethod, String.class, String.class, ContentValues.class, new XC_MethodHook() { @Override @@ -72,7 +63,6 @@ protected void afterHookedMethod(MethodHookParam param) { } }); - XposedHelpers.findAndHookMethod(HookParams.getInstance().ReceiveLuckyMoneyRequestClassName, lpparam.classLoader, HookParams.getInstance().ReceiveLuckyMoneyRequestMethod, int.class, String.class, JSONObject.class, new XC_MethodHook() { @Override protected void beforeHookedMethod(MethodHookParam param) { diff --git a/app/src/main/java/me/firesun/wechat/enhancement/util/Receiver.java b/app/src/main/java/me/firesun/wechat/enhancement/util/ConfigReceiver.java similarity index 94% rename from app/src/main/java/me/firesun/wechat/enhancement/util/Receiver.java rename to app/src/main/java/me/firesun/wechat/enhancement/util/ConfigReceiver.java index 27bc5aa..bf24e8b 100644 --- a/app/src/main/java/me/firesun/wechat/enhancement/util/Receiver.java +++ b/app/src/main/java/me/firesun/wechat/enhancement/util/ConfigReceiver.java @@ -8,7 +8,7 @@ import android.os.Bundle; -public class Receiver extends BroadcastReceiver { +public class ConfigReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) {