diff --git a/demo-app/src/main/java/com/highcapable/yukihookapi/demo_app/test/Main.java b/demo-app/src/main/java/com/highcapable/yukihookapi/demo_app/test/Main.java deleted file mode 100644 index 1147f867..00000000 --- a/demo-app/src/main/java/com/highcapable/yukihookapi/demo_app/test/Main.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.highcapable.yukihookapi.demo_app.test; - -public class Main extends SuperMain { - - private final String content; - - public Main() { - super(""); - content = ""; - } - - public Main(String content) { - super(content); - this.content = content; - } - - public String getTestResultFirst() { - return "The world is beautiful"; - } - - public String getTestResultFirst(String string) { - return string; - } - - public String getTestResultLast() { - return "The world is fantastic"; - } - - public final String getTestResultLast(String string) { - return string; - } - - public String getContent() { - return content; - } -} \ No newline at end of file diff --git a/demo-app/src/main/java/com/highcapable/yukihookapi/demo_app/test/SuperMain.java b/demo-app/src/main/java/com/highcapable/yukihookapi/demo_app/test/SuperMain.java deleted file mode 100644 index 32efe923..00000000 --- a/demo-app/src/main/java/com/highcapable/yukihookapi/demo_app/test/SuperMain.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.highcapable.yukihookapi.demo_app.test; - -public class SuperMain { - - private final String content; - - public SuperMain(String content) { - this.content = content; - } - - public String getSuperString() { - return "The sea is blue"; - } - - public String getString() { - return getContent(); - } - - public String getContent() { - return content; - } -} \ No newline at end of file diff --git a/img-src/wechat_code.jpg b/img-src/wechat_code.jpg deleted file mode 100644 index 15dbcde7..00000000 Binary files a/img-src/wechat_code.jpg and /dev/null differ diff --git a/demo-app/.gitignore b/samples/.gitignore similarity index 100% rename from demo-app/.gitignore rename to samples/.gitignore diff --git a/yukihookapi/.gitignore b/samples/demo-app/.gitignore similarity index 100% rename from yukihookapi/.gitignore rename to samples/demo-app/.gitignore diff --git a/demo-app/proguard-rules.pro b/samples/demo-app/proguard-rules.pro similarity index 100% rename from demo-app/proguard-rules.pro rename to samples/demo-app/proguard-rules.pro diff --git a/demo-app/src/main/AndroidManifest.xml b/samples/demo-app/src/main/AndroidManifest.xml similarity index 100% rename from demo-app/src/main/AndroidManifest.xml rename to samples/demo-app/src/main/AndroidManifest.xml diff --git a/demo-app/src/main/ic_launcher-playstore.png b/samples/demo-app/src/main/ic_launcher-playstore.png similarity index 100% rename from demo-app/src/main/ic_launcher-playstore.png rename to samples/demo-app/src/main/ic_launcher-playstore.png diff --git a/samples/demo-app/src/main/java/com/highcapable/yukihookapi/demo_app/test/Main.java b/samples/demo-app/src/main/java/com/highcapable/yukihookapi/demo_app/test/Main.java new file mode 100644 index 00000000..420d2967 --- /dev/null +++ b/samples/demo-app/src/main/java/com/highcapable/yukihookapi/demo_app/test/Main.java @@ -0,0 +1,63 @@ +/* + * YukiHookAPI - An efficient Hook API and Xposed Module solution built in Kotlin. + * Copyright (C) 2019-2023 HighCapable + * https://github.com/fankes/YukiHookAPI + * + * MIT License + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * This file is created by fankes on 2022/7/27. + */ +package com.highcapable.yukihookapi.demo_app.test; + +public class Main extends SuperMain { + + private final String content; + + public Main() { + super(""); + content = ""; + } + + public Main(String content) { + super(content); + this.content = content; + } + + public String getTestResultFirst() { + return "The world is beautiful"; + } + + public String getTestResultFirst(String string) { + return string; + } + + public String getTestResultLast() { + return "The world is fantastic"; + } + + public final String getTestResultLast(String string) { + return string; + } + + public String getContent() { + return content; + } +} \ No newline at end of file diff --git a/samples/demo-app/src/main/java/com/highcapable/yukihookapi/demo_app/test/SuperMain.java b/samples/demo-app/src/main/java/com/highcapable/yukihookapi/demo_app/test/SuperMain.java new file mode 100644 index 00000000..096e91e4 --- /dev/null +++ b/samples/demo-app/src/main/java/com/highcapable/yukihookapi/demo_app/test/SuperMain.java @@ -0,0 +1,49 @@ +/* + * YukiHookAPI - An efficient Hook API and Xposed Module solution built in Kotlin. + * Copyright (C) 2019-2023 HighCapable + * https://github.com/fankes/YukiHookAPI + * + * MIT License + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * This file is created by fankes on 2022/7/27. + */ +package com.highcapable.yukihookapi.demo_app.test; + +public class SuperMain { + + private final String content; + + public SuperMain(String content) { + this.content = content; + } + + public String getSuperString() { + return "The sea is blue"; + } + + public String getString() { + return getContent(); + } + + public String getContent() { + return content; + } +} \ No newline at end of file diff --git a/demo-app/src/main/java/com/highcapable/yukihookapi/demo_app/ui/MainActivity.kt b/samples/demo-app/src/main/java/com/highcapable/yukihookapi/demo_app/ui/MainActivity.kt similarity index 100% rename from demo-app/src/main/java/com/highcapable/yukihookapi/demo_app/ui/MainActivity.kt rename to samples/demo-app/src/main/java/com/highcapable/yukihookapi/demo_app/ui/MainActivity.kt diff --git a/demo-app/src/main/res/layout/activity_main.xml b/samples/demo-app/src/main/res/layout/activity_main.xml similarity index 100% rename from demo-app/src/main/res/layout/activity_main.xml rename to samples/demo-app/src/main/res/layout/activity_main.xml diff --git a/demo-app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/samples/demo-app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml similarity index 100% rename from demo-app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml rename to samples/demo-app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml diff --git a/demo-app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/samples/demo-app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml similarity index 100% rename from demo-app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml rename to samples/demo-app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml diff --git a/demo-app/src/main/res/mipmap-hdpi/ic_launcher.png b/samples/demo-app/src/main/res/mipmap-hdpi/ic_launcher.png similarity index 100% rename from demo-app/src/main/res/mipmap-hdpi/ic_launcher.png rename to samples/demo-app/src/main/res/mipmap-hdpi/ic_launcher.png diff --git a/demo-app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png b/samples/demo-app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png similarity index 100% rename from demo-app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png rename to samples/demo-app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png diff --git a/demo-app/src/main/res/mipmap-hdpi/ic_launcher_round.png b/samples/demo-app/src/main/res/mipmap-hdpi/ic_launcher_round.png similarity index 100% rename from demo-app/src/main/res/mipmap-hdpi/ic_launcher_round.png rename to samples/demo-app/src/main/res/mipmap-hdpi/ic_launcher_round.png diff --git a/demo-app/src/main/res/mipmap-mdpi/ic_launcher.png b/samples/demo-app/src/main/res/mipmap-mdpi/ic_launcher.png similarity index 100% rename from demo-app/src/main/res/mipmap-mdpi/ic_launcher.png rename to samples/demo-app/src/main/res/mipmap-mdpi/ic_launcher.png diff --git a/demo-app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png b/samples/demo-app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png similarity index 100% rename from demo-app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png rename to samples/demo-app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png diff --git a/demo-app/src/main/res/mipmap-mdpi/ic_launcher_round.png b/samples/demo-app/src/main/res/mipmap-mdpi/ic_launcher_round.png similarity index 100% rename from demo-app/src/main/res/mipmap-mdpi/ic_launcher_round.png rename to samples/demo-app/src/main/res/mipmap-mdpi/ic_launcher_round.png diff --git a/demo-app/src/main/res/mipmap-xhdpi/ic_launcher.png b/samples/demo-app/src/main/res/mipmap-xhdpi/ic_launcher.png similarity index 100% rename from demo-app/src/main/res/mipmap-xhdpi/ic_launcher.png rename to samples/demo-app/src/main/res/mipmap-xhdpi/ic_launcher.png diff --git a/demo-app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png b/samples/demo-app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png similarity index 100% rename from demo-app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png rename to samples/demo-app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png diff --git a/demo-app/src/main/res/mipmap-xhdpi/ic_launcher_round.png b/samples/demo-app/src/main/res/mipmap-xhdpi/ic_launcher_round.png similarity index 100% rename from demo-app/src/main/res/mipmap-xhdpi/ic_launcher_round.png rename to samples/demo-app/src/main/res/mipmap-xhdpi/ic_launcher_round.png diff --git a/demo-app/src/main/res/mipmap-xxhdpi/ic_face_unhappy.png b/samples/demo-app/src/main/res/mipmap-xxhdpi/ic_face_unhappy.png similarity index 100% rename from demo-app/src/main/res/mipmap-xxhdpi/ic_face_unhappy.png rename to samples/demo-app/src/main/res/mipmap-xxhdpi/ic_face_unhappy.png diff --git a/demo-app/src/main/res/mipmap-xxhdpi/ic_icon.png b/samples/demo-app/src/main/res/mipmap-xxhdpi/ic_icon.png similarity index 100% rename from demo-app/src/main/res/mipmap-xxhdpi/ic_icon.png rename to samples/demo-app/src/main/res/mipmap-xxhdpi/ic_icon.png diff --git a/demo-app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/samples/demo-app/src/main/res/mipmap-xxhdpi/ic_launcher.png similarity index 100% rename from demo-app/src/main/res/mipmap-xxhdpi/ic_launcher.png rename to samples/demo-app/src/main/res/mipmap-xxhdpi/ic_launcher.png diff --git a/demo-app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png b/samples/demo-app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png similarity index 100% rename from demo-app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png rename to samples/demo-app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png diff --git a/demo-app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png b/samples/demo-app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png similarity index 100% rename from demo-app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png rename to samples/demo-app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png diff --git a/demo-app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/samples/demo-app/src/main/res/mipmap-xxxhdpi/ic_launcher.png similarity index 100% rename from demo-app/src/main/res/mipmap-xxxhdpi/ic_launcher.png rename to samples/demo-app/src/main/res/mipmap-xxxhdpi/ic_launcher.png diff --git a/demo-app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png b/samples/demo-app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png similarity index 100% rename from demo-app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png rename to samples/demo-app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png diff --git a/demo-app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png b/samples/demo-app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png similarity index 100% rename from demo-app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png rename to samples/demo-app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png diff --git a/demo-app/src/main/res/values-night/themes.xml b/samples/demo-app/src/main/res/values-night/themes.xml similarity index 100% rename from demo-app/src/main/res/values-night/themes.xml rename to samples/demo-app/src/main/res/values-night/themes.xml diff --git a/demo-app/src/main/res/values/colors.xml b/samples/demo-app/src/main/res/values/colors.xml similarity index 100% rename from demo-app/src/main/res/values/colors.xml rename to samples/demo-app/src/main/res/values/colors.xml diff --git a/demo-app/src/main/res/values/ic_launcher_background.xml b/samples/demo-app/src/main/res/values/ic_launcher_background.xml similarity index 100% rename from demo-app/src/main/res/values/ic_launcher_background.xml rename to samples/demo-app/src/main/res/values/ic_launcher_background.xml diff --git a/demo-app/src/main/res/values/strings.xml b/samples/demo-app/src/main/res/values/strings.xml similarity index 100% rename from demo-app/src/main/res/values/strings.xml rename to samples/demo-app/src/main/res/values/strings.xml diff --git a/demo-app/src/main/res/values/themes.xml b/samples/demo-app/src/main/res/values/themes.xml similarity index 100% rename from demo-app/src/main/res/values/themes.xml rename to samples/demo-app/src/main/res/values/themes.xml diff --git a/demo-module/.gitignore b/samples/demo-module/.gitignore similarity index 100% rename from demo-module/.gitignore rename to samples/demo-module/.gitignore diff --git a/demo-module/proguard-rules.pro b/samples/demo-module/proguard-rules.pro similarity index 100% rename from demo-module/proguard-rules.pro rename to samples/demo-module/proguard-rules.pro diff --git a/demo-module/src/main/AndroidManifest.xml b/samples/demo-module/src/main/AndroidManifest.xml similarity index 100% rename from demo-module/src/main/AndroidManifest.xml rename to samples/demo-module/src/main/AndroidManifest.xml diff --git a/demo-module/src/main/ic_launcher-playstore.png b/samples/demo-module/src/main/ic_launcher-playstore.png similarity index 100% rename from demo-module/src/main/ic_launcher-playstore.png rename to samples/demo-module/src/main/ic_launcher-playstore.png diff --git a/demo-module/src/main/java/com/highcapable/yukihookapi/demo_module/application/DemoApplication.kt b/samples/demo-module/src/main/java/com/highcapable/yukihookapi/demo_module/application/DemoApplication.kt similarity index 100% rename from demo-module/src/main/java/com/highcapable/yukihookapi/demo_module/application/DemoApplication.kt rename to samples/demo-module/src/main/java/com/highcapable/yukihookapi/demo_module/application/DemoApplication.kt diff --git a/demo-module/src/main/java/com/highcapable/yukihookapi/demo_module/data/DataConst.kt b/samples/demo-module/src/main/java/com/highcapable/yukihookapi/demo_module/data/DataConst.kt similarity index 100% rename from demo-module/src/main/java/com/highcapable/yukihookapi/demo_module/data/DataConst.kt rename to samples/demo-module/src/main/java/com/highcapable/yukihookapi/demo_module/data/DataConst.kt diff --git a/demo-module/src/main/java/com/highcapable/yukihookapi/demo_module/hook/HookEntry.kt b/samples/demo-module/src/main/java/com/highcapable/yukihookapi/demo_module/hook/HookEntry.kt similarity index 98% rename from demo-module/src/main/java/com/highcapable/yukihookapi/demo_module/hook/HookEntry.kt rename to samples/demo-module/src/main/java/com/highcapable/yukihookapi/demo_module/hook/HookEntry.kt index 3a92e258..60686648 100644 --- a/demo-module/src/main/java/com/highcapable/yukihookapi/demo_module/hook/HookEntry.kt +++ b/samples/demo-module/src/main/java/com/highcapable/yukihookapi/demo_module/hook/HookEntry.kt @@ -44,7 +44,9 @@ import com.highcapable.yukihookapi.hook.factory.applyModuleTheme import com.highcapable.yukihookapi.hook.factory.registerModuleAppActivities import com.highcapable.yukihookapi.hook.type.android.ActivityClass import com.highcapable.yukihookapi.hook.type.android.BundleClass -import com.highcapable.yukihookapi.hook.type.java.* +import com.highcapable.yukihookapi.hook.type.java.StringArrayClass +import com.highcapable.yukihookapi.hook.type.java.StringClass +import com.highcapable.yukihookapi.hook.type.java.UnitType import com.highcapable.yukihookapi.hook.xposed.bridge.event.YukiXposedEvent import com.highcapable.yukihookapi.hook.xposed.proxy.IYukiHookXposedInit @@ -238,9 +240,9 @@ object HookEntry : IYukiHookXposedInit { .setTitle("Hooked") .setMessage( "This App has been hooked!\n\n" + - "Hook Framework: ${YukiHookAPI.Status.Executor.name}\n\n" + - "Xposed API Version: ${YukiHookAPI.Status.Executor.apiLevel}\n\n" + - "Support Resources Hook: ${YukiHookAPI.Status.isSupportResourcesHook}" + "Hook Framework: ${YukiHookAPI.Status.Executor.name}\n\n" + + "Xposed API Version: ${YukiHookAPI.Status.Executor.apiLevel}\n\n" + + "Support Resources Hook: ${YukiHookAPI.Status.isSupportResourcesHook}" ) .setPositiveButton("OK", null) .show().compatStyle() diff --git a/demo-module/src/main/java/com/highcapable/yukihookapi/demo_module/hook/factory/ComponentCompatFactory.kt b/samples/demo-module/src/main/java/com/highcapable/yukihookapi/demo_module/hook/factory/ComponentCompatFactory.kt similarity index 100% rename from demo-module/src/main/java/com/highcapable/yukihookapi/demo_module/hook/factory/ComponentCompatFactory.kt rename to samples/demo-module/src/main/java/com/highcapable/yukihookapi/demo_module/hook/factory/ComponentCompatFactory.kt diff --git a/demo-module/src/main/java/com/highcapable/yukihookapi/demo_module/hook/java/HookEntry.java b/samples/demo-module/src/main/java/com/highcapable/yukihookapi/demo_module/hook/java/HookEntry.java similarity index 98% rename from demo-module/src/main/java/com/highcapable/yukihookapi/demo_module/hook/java/HookEntry.java rename to samples/demo-module/src/main/java/com/highcapable/yukihookapi/demo_module/hook/java/HookEntry.java index db3ffd70..2716815d 100644 --- a/demo-module/src/main/java/com/highcapable/yukihookapi/demo_module/hook/java/HookEntry.java +++ b/samples/demo-module/src/main/java/com/highcapable/yukihookapi/demo_module/hook/java/HookEntry.java @@ -63,11 +63,9 @@ public class HookEntry implements IYukiHookXposedInit { YukiHookLogger.Configs.USER_ID ); config.setDebug(true); - config.setEnableModulePrefsCache(true); config.setEnableModuleAppResourcesCache(true); config.setEnableHookModuleStatus(true); config.setEnableDataChannel(true); - config.setEnableMemberCache(true); } @Override diff --git a/demo-module/src/main/java/com/highcapable/yukihookapi/demo_module/ui/MainActivity.kt b/samples/demo-module/src/main/java/com/highcapable/yukihookapi/demo_module/ui/MainActivity.kt similarity index 99% rename from demo-module/src/main/java/com/highcapable/yukihookapi/demo_module/ui/MainActivity.kt rename to samples/demo-module/src/main/java/com/highcapable/yukihookapi/demo_module/ui/MainActivity.kt index 1c1ead81..b50ca497 100644 --- a/demo-module/src/main/java/com/highcapable/yukihookapi/demo_module/ui/MainActivity.kt +++ b/samples/demo-module/src/main/java/com/highcapable/yukihookapi/demo_module/ui/MainActivity.kt @@ -40,7 +40,7 @@ import com.highcapable.yukihookapi.hook.factory.dataChannel import com.highcapable.yukihookapi.hook.factory.prefs import com.highcapable.yukihookapi.hook.xposed.parasitic.activity.base.ModuleAppCompatActivity import java.text.SimpleDateFormat -import java.util.* +import java.util.Date class MainActivity : ModuleAppCompatActivity() { diff --git a/demo-module/src/main/java/com/highcapable/yukihookapi/demo_module/ui/PreferenceActivity.kt b/samples/demo-module/src/main/java/com/highcapable/yukihookapi/demo_module/ui/PreferenceActivity.kt similarity index 100% rename from demo-module/src/main/java/com/highcapable/yukihookapi/demo_module/ui/PreferenceActivity.kt rename to samples/demo-module/src/main/java/com/highcapable/yukihookapi/demo_module/ui/PreferenceActivity.kt diff --git a/demo-module/src/main/res/drawable/ic_launcher_foreground.xml b/samples/demo-module/src/main/res/drawable/ic_launcher_foreground.xml similarity index 100% rename from demo-module/src/main/res/drawable/ic_launcher_foreground.xml rename to samples/demo-module/src/main/res/drawable/ic_launcher_foreground.xml diff --git a/demo-module/src/main/res/layout/activity_main.xml b/samples/demo-module/src/main/res/layout/activity_main.xml similarity index 100% rename from demo-module/src/main/res/layout/activity_main.xml rename to samples/demo-module/src/main/res/layout/activity_main.xml diff --git a/demo-module/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/samples/demo-module/src/main/res/mipmap-anydpi-v26/ic_launcher.xml similarity index 100% rename from demo-module/src/main/res/mipmap-anydpi-v26/ic_launcher.xml rename to samples/demo-module/src/main/res/mipmap-anydpi-v26/ic_launcher.xml diff --git a/demo-module/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/samples/demo-module/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml similarity index 100% rename from demo-module/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml rename to samples/demo-module/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml diff --git a/demo-module/src/main/res/mipmap-hdpi/ic_launcher.png b/samples/demo-module/src/main/res/mipmap-hdpi/ic_launcher.png similarity index 100% rename from demo-module/src/main/res/mipmap-hdpi/ic_launcher.png rename to samples/demo-module/src/main/res/mipmap-hdpi/ic_launcher.png diff --git a/demo-module/src/main/res/mipmap-hdpi/ic_launcher_foreground.png b/samples/demo-module/src/main/res/mipmap-hdpi/ic_launcher_foreground.png similarity index 100% rename from demo-module/src/main/res/mipmap-hdpi/ic_launcher_foreground.png rename to samples/demo-module/src/main/res/mipmap-hdpi/ic_launcher_foreground.png diff --git a/demo-module/src/main/res/mipmap-hdpi/ic_launcher_round.png b/samples/demo-module/src/main/res/mipmap-hdpi/ic_launcher_round.png similarity index 100% rename from demo-module/src/main/res/mipmap-hdpi/ic_launcher_round.png rename to samples/demo-module/src/main/res/mipmap-hdpi/ic_launcher_round.png diff --git a/demo-module/src/main/res/mipmap-mdpi/ic_launcher.png b/samples/demo-module/src/main/res/mipmap-mdpi/ic_launcher.png similarity index 100% rename from demo-module/src/main/res/mipmap-mdpi/ic_launcher.png rename to samples/demo-module/src/main/res/mipmap-mdpi/ic_launcher.png diff --git a/demo-module/src/main/res/mipmap-mdpi/ic_launcher_foreground.png b/samples/demo-module/src/main/res/mipmap-mdpi/ic_launcher_foreground.png similarity index 100% rename from demo-module/src/main/res/mipmap-mdpi/ic_launcher_foreground.png rename to samples/demo-module/src/main/res/mipmap-mdpi/ic_launcher_foreground.png diff --git a/demo-module/src/main/res/mipmap-mdpi/ic_launcher_round.png b/samples/demo-module/src/main/res/mipmap-mdpi/ic_launcher_round.png similarity index 100% rename from demo-module/src/main/res/mipmap-mdpi/ic_launcher_round.png rename to samples/demo-module/src/main/res/mipmap-mdpi/ic_launcher_round.png diff --git a/demo-module/src/main/res/mipmap-xhdpi/ic_launcher.png b/samples/demo-module/src/main/res/mipmap-xhdpi/ic_launcher.png similarity index 100% rename from demo-module/src/main/res/mipmap-xhdpi/ic_launcher.png rename to samples/demo-module/src/main/res/mipmap-xhdpi/ic_launcher.png diff --git a/demo-module/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png b/samples/demo-module/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png similarity index 100% rename from demo-module/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png rename to samples/demo-module/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png diff --git a/demo-module/src/main/res/mipmap-xhdpi/ic_launcher_round.png b/samples/demo-module/src/main/res/mipmap-xhdpi/ic_launcher_round.png similarity index 100% rename from demo-module/src/main/res/mipmap-xhdpi/ic_launcher_round.png rename to samples/demo-module/src/main/res/mipmap-xhdpi/ic_launcher_round.png diff --git a/demo-module/src/main/res/mipmap-xxhdpi/ic_face_happy.png b/samples/demo-module/src/main/res/mipmap-xxhdpi/ic_face_happy.png similarity index 100% rename from demo-module/src/main/res/mipmap-xxhdpi/ic_face_happy.png rename to samples/demo-module/src/main/res/mipmap-xxhdpi/ic_face_happy.png diff --git a/demo-module/src/main/res/mipmap-xxhdpi/ic_icon.png b/samples/demo-module/src/main/res/mipmap-xxhdpi/ic_icon.png similarity index 100% rename from demo-module/src/main/res/mipmap-xxhdpi/ic_icon.png rename to samples/demo-module/src/main/res/mipmap-xxhdpi/ic_icon.png diff --git a/demo-module/src/main/res/mipmap-xxhdpi/ic_launcher.png b/samples/demo-module/src/main/res/mipmap-xxhdpi/ic_launcher.png similarity index 100% rename from demo-module/src/main/res/mipmap-xxhdpi/ic_launcher.png rename to samples/demo-module/src/main/res/mipmap-xxhdpi/ic_launcher.png diff --git a/demo-module/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png b/samples/demo-module/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png similarity index 100% rename from demo-module/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png rename to samples/demo-module/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png diff --git a/demo-module/src/main/res/mipmap-xxhdpi/ic_launcher_round.png b/samples/demo-module/src/main/res/mipmap-xxhdpi/ic_launcher_round.png similarity index 100% rename from demo-module/src/main/res/mipmap-xxhdpi/ic_launcher_round.png rename to samples/demo-module/src/main/res/mipmap-xxhdpi/ic_launcher_round.png diff --git a/demo-module/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/samples/demo-module/src/main/res/mipmap-xxxhdpi/ic_launcher.png similarity index 100% rename from demo-module/src/main/res/mipmap-xxxhdpi/ic_launcher.png rename to samples/demo-module/src/main/res/mipmap-xxxhdpi/ic_launcher.png diff --git a/demo-module/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png b/samples/demo-module/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png similarity index 100% rename from demo-module/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png rename to samples/demo-module/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png diff --git a/demo-module/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png b/samples/demo-module/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png similarity index 100% rename from demo-module/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png rename to samples/demo-module/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png diff --git a/demo-module/src/main/res/values-night/themes.xml b/samples/demo-module/src/main/res/values-night/themes.xml similarity index 100% rename from demo-module/src/main/res/values-night/themes.xml rename to samples/demo-module/src/main/res/values-night/themes.xml diff --git a/demo-module/src/main/res/values/array.xml b/samples/demo-module/src/main/res/values/array.xml similarity index 100% rename from demo-module/src/main/res/values/array.xml rename to samples/demo-module/src/main/res/values/array.xml diff --git a/demo-module/src/main/res/values/colors.xml b/samples/demo-module/src/main/res/values/colors.xml similarity index 100% rename from demo-module/src/main/res/values/colors.xml rename to samples/demo-module/src/main/res/values/colors.xml diff --git a/demo-module/src/main/res/values/ic_launcher_background.xml b/samples/demo-module/src/main/res/values/ic_launcher_background.xml similarity index 100% rename from demo-module/src/main/res/values/ic_launcher_background.xml rename to samples/demo-module/src/main/res/values/ic_launcher_background.xml diff --git a/demo-module/src/main/res/values/strings.xml b/samples/demo-module/src/main/res/values/strings.xml similarity index 100% rename from demo-module/src/main/res/values/strings.xml rename to samples/demo-module/src/main/res/values/strings.xml diff --git a/demo-module/src/main/res/values/themes.xml b/samples/demo-module/src/main/res/values/themes.xml similarity index 100% rename from demo-module/src/main/res/values/themes.xml rename to samples/demo-module/src/main/res/values/themes.xml diff --git a/demo-module/src/main/res/xml/settings_preferences.xml b/samples/demo-module/src/main/res/xml/settings_preferences.xml similarity index 100% rename from demo-module/src/main/res/xml/settings_preferences.xml rename to samples/demo-module/src/main/res/xml/settings_preferences.xml diff --git a/yukihookapi-core/.gitignore b/yukihookapi-core/.gitignore new file mode 100644 index 00000000..42afabfd --- /dev/null +++ b/yukihookapi-core/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/yukihookapi/consumer-rules.pro b/yukihookapi-core/consumer-rules.pro similarity index 100% rename from yukihookapi/consumer-rules.pro rename to yukihookapi-core/consumer-rules.pro diff --git a/yukihookapi/proguard-rules.pro b/yukihookapi-core/proguard-rules.pro similarity index 100% rename from yukihookapi/proguard-rules.pro rename to yukihookapi-core/proguard-rules.pro diff --git a/yukihookapi/src/main/AndroidManifest.xml b/yukihookapi-core/src/main/AndroidManifest.xml similarity index 100% rename from yukihookapi/src/main/AndroidManifest.xml rename to yukihookapi-core/src/main/AndroidManifest.xml diff --git a/yukihookapi/src/main/java/com/highcapable/yukihookapi/YukiHookAPI.kt b/yukihookapi-core/src/main/java/com/highcapable/yukihookapi/YukiHookAPI.kt similarity index 99% rename from yukihookapi/src/main/java/com/highcapable/yukihookapi/YukiHookAPI.kt rename to yukihookapi-core/src/main/java/com/highcapable/yukihookapi/YukiHookAPI.kt index dba73525..f348b098 100644 --- a/yukihookapi/src/main/java/com/highcapable/yukihookapi/YukiHookAPI.kt +++ b/yukihookapi-core/src/main/java/com/highcapable/yukihookapi/YukiHookAPI.kt @@ -37,6 +37,7 @@ import com.highcapable.yukihookapi.YukiHookAPI.Configs.debugLog import com.highcapable.yukihookapi.YukiHookAPI.configs import com.highcapable.yukihookapi.YukiHookAPI.encase import com.highcapable.yukihookapi.annotation.xposed.InjectYukiHookWithXposed +import com.highcapable.yukihookapi.generated.YukiHookAPIProperties import com.highcapable.yukihookapi.hook.core.api.compat.HookApiCategoryHelper import com.highcapable.yukihookapi.hook.core.api.compat.HookApiProperty import com.highcapable.yukihookapi.hook.core.api.compat.type.ExecutorType @@ -74,10 +75,10 @@ object YukiHookAPI { internal var isLoadedFromBaseContext = false /** 获取当前 [YukiHookAPI] 的版本 */ - const val API_VERSION_NAME = BuildConfig.API_VERSION_NAME + const val API_VERSION_NAME = YukiHookAPIProperties.PROJECT_YUKIHOOKAPI_CORE_VERSION /** 获取当前 [YukiHookAPI] 的版本号 */ - const val API_VERSION_CODE = BuildConfig.API_VERSION_CODE + const val API_VERSION_CODE = 44 /** * 当前 [YukiHookAPI] 的状态 diff --git a/yukihookapi/src/main/java/com/highcapable/yukihookapi/annotation/CauseProblemsApi.kt b/yukihookapi-core/src/main/java/com/highcapable/yukihookapi/annotation/CauseProblemsApi.kt similarity index 94% rename from yukihookapi/src/main/java/com/highcapable/yukihookapi/annotation/CauseProblemsApi.kt rename to yukihookapi-core/src/main/java/com/highcapable/yukihookapi/annotation/CauseProblemsApi.kt index b289c3d6..8ee38814 100644 --- a/yukihookapi/src/main/java/com/highcapable/yukihookapi/annotation/CauseProblemsApi.kt +++ b/yukihookapi-core/src/main/java/com/highcapable/yukihookapi/annotation/CauseProblemsApi.kt @@ -25,7 +25,7 @@ * * This file is Created by fankes on 2022/4/3. */ -@file:Suppress("OPT_IN_IS_NOT_ENABLED", "EXPERIMENTAL_IS_NOT_ENABLED", "unused") +@file:Suppress("unused") package com.highcapable.yukihookapi.annotation diff --git a/yukihookapi/src/main/java/com/highcapable/yukihookapi/annotation/YukiGenerateApi.kt b/yukihookapi-core/src/main/java/com/highcapable/yukihookapi/annotation/YukiGenerateApi.kt similarity index 95% rename from yukihookapi/src/main/java/com/highcapable/yukihookapi/annotation/YukiGenerateApi.kt rename to yukihookapi-core/src/main/java/com/highcapable/yukihookapi/annotation/YukiGenerateApi.kt index 1095d568..905c49d6 100644 --- a/yukihookapi/src/main/java/com/highcapable/yukihookapi/annotation/YukiGenerateApi.kt +++ b/yukihookapi-core/src/main/java/com/highcapable/yukihookapi/annotation/YukiGenerateApi.kt @@ -25,7 +25,7 @@ * * This file is Created by fankes on 2022/4/3. */ -@file:Suppress("OPT_IN_IS_NOT_ENABLED", "EXPERIMENTAL_IS_NOT_ENABLED") +@file:Suppress("unused") package com.highcapable.yukihookapi.annotation diff --git a/yukihookapi/src/main/java/com/highcapable/yukihookapi/annotation/YukiPrivateApi.kt b/yukihookapi-core/src/main/java/com/highcapable/yukihookapi/annotation/YukiPrivateApi.kt similarity index 94% rename from yukihookapi/src/main/java/com/highcapable/yukihookapi/annotation/YukiPrivateApi.kt rename to yukihookapi-core/src/main/java/com/highcapable/yukihookapi/annotation/YukiPrivateApi.kt index cb3977cc..4b5da852 100644 --- a/yukihookapi/src/main/java/com/highcapable/yukihookapi/annotation/YukiPrivateApi.kt +++ b/yukihookapi-core/src/main/java/com/highcapable/yukihookapi/annotation/YukiPrivateApi.kt @@ -25,7 +25,7 @@ * * This file is Created by fankes on 2022/4/3. */ -@file:Suppress("OPT_IN_IS_NOT_ENABLED", "EXPERIMENTAL_IS_NOT_ENABLED") +@file:Suppress("unused") package com.highcapable.yukihookapi.annotation diff --git a/yukihookapi/src/main/java/com/highcapable/yukihookapi/annotation/xposed/InjectYukiHookWithXposed.kt b/yukihookapi-core/src/main/java/com/highcapable/yukihookapi/annotation/xposed/InjectYukiHookWithXposed.kt similarity index 100% rename from yukihookapi/src/main/java/com/highcapable/yukihookapi/annotation/xposed/InjectYukiHookWithXposed.kt rename to yukihookapi-core/src/main/java/com/highcapable/yukihookapi/annotation/xposed/InjectYukiHookWithXposed.kt diff --git a/yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/bean/CurrentClass.kt b/yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/bean/CurrentClass.kt similarity index 98% rename from yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/bean/CurrentClass.kt rename to yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/bean/CurrentClass.kt index d8e2c6a9..789f8499 100644 --- a/yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/bean/CurrentClass.kt +++ b/yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/bean/CurrentClass.kt @@ -149,7 +149,7 @@ class CurrentClass @PublishedApi internal constructor(@PublishedApi internal val inline fun method(initiate: MethodConditions) = superClassSet.method(initiate).result { if (isShutErrorPrinting) ignored() }.get(instance) - override fun toString() = "CurrentClass super [${superClassSet}]" + override fun toString() = "CurrentClass super [$superClassSet]" } override fun toString() = "CurrentClass [$classSet]" diff --git a/yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/bean/GenericClass.kt b/yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/bean/GenericClass.kt similarity index 100% rename from yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/bean/GenericClass.kt rename to yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/bean/GenericClass.kt diff --git a/yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/bean/HookClass.kt b/yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/bean/HookClass.kt similarity index 100% rename from yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/bean/HookClass.kt rename to yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/bean/HookClass.kt diff --git a/yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/bean/HookResources.kt b/yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/bean/HookResources.kt similarity index 100% rename from yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/bean/HookResources.kt rename to yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/bean/HookResources.kt diff --git a/yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/bean/VariousClass.kt b/yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/bean/VariousClass.kt similarity index 100% rename from yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/bean/VariousClass.kt rename to yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/bean/VariousClass.kt diff --git a/yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/core/YukiMemberHookCreator.kt b/yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/core/YukiMemberHookCreator.kt similarity index 96% rename from yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/core/YukiMemberHookCreator.kt rename to yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/core/YukiMemberHookCreator.kt index 755f624c..a86a7fa9 100644 --- a/yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/core/YukiMemberHookCreator.kt +++ b/yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/core/YukiMemberHookCreator.kt @@ -25,7 +25,7 @@ * * This file is Created by fankes on 2022/2/2. */ -@file:Suppress("MemberVisibilityCanBePrivate", "unused", "PropertyName") +@file:Suppress("MemberVisibilityCanBePrivate", "UnusedReceiverParameter", "unused", "PropertyName") package com.highcapable.yukihookapi.hook.core @@ -46,13 +46,26 @@ import com.highcapable.yukihookapi.hook.core.finder.members.MethodFinder import com.highcapable.yukihookapi.hook.core.finder.type.factory.ConstructorConditions import com.highcapable.yukihookapi.hook.core.finder.type.factory.FieldConditions import com.highcapable.yukihookapi.hook.core.finder.type.factory.MethodConditions -import com.highcapable.yukihookapi.hook.factory.* +import com.highcapable.yukihookapi.hook.factory.MembersType +import com.highcapable.yukihookapi.hook.factory.allConstructors +import com.highcapable.yukihookapi.hook.factory.allMethods +import com.highcapable.yukihookapi.hook.factory.constructor +import com.highcapable.yukihookapi.hook.factory.method +import com.highcapable.yukihookapi.hook.factory.notExtends +import com.highcapable.yukihookapi.hook.factory.notImplements +import com.highcapable.yukihookapi.hook.factory.toJavaPrimitiveType import com.highcapable.yukihookapi.hook.log.yLoggerE import com.highcapable.yukihookapi.hook.log.yLoggerI import com.highcapable.yukihookapi.hook.log.yLoggerW import com.highcapable.yukihookapi.hook.param.HookParam import com.highcapable.yukihookapi.hook.param.PackageParam -import com.highcapable.yukihookapi.hook.type.java.* +import com.highcapable.yukihookapi.hook.type.java.AnyClass +import com.highcapable.yukihookapi.hook.type.java.JavaClass +import com.highcapable.yukihookapi.hook.type.java.JavaClassLoader +import com.highcapable.yukihookapi.hook.type.java.JavaConstructorClass +import com.highcapable.yukihookapi.hook.type.java.JavaFieldClass +import com.highcapable.yukihookapi.hook.type.java.JavaMemberClass +import com.highcapable.yukihookapi.hook.type.java.JavaMethodClass import com.highcapable.yukihookapi.hook.utils.RandomSeed import com.highcapable.yukihookapi.hook.utils.await import com.highcapable.yukihookapi.hook.utils.conditions @@ -189,8 +202,8 @@ class YukiMemberHookCreator @PublishedApi internal constructor( fun throwProblem(name: String, content: String) { if (hookOption != "Yes do as I say!") throw UnsupportedOperationException( "!!!DANGEROUS!!! Hook [$name] Class is a dangerous behavior! $content\n" + - "The hook request was rejected, if you still want to use it, " + - "call \"useDangerousOperation\" and type \"Yes do as I say!\"" + "The hook request was rejected, if you still want to use it, " + + "call \"useDangerousOperation\" and type \"Yes do as I say!\"" ) } when (hookClass.name) { diff --git a/yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/core/YukiResourcesHookCreator.kt b/yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/core/YukiResourcesHookCreator.kt similarity index 94% rename from yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/core/YukiResourcesHookCreator.kt rename to yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/core/YukiResourcesHookCreator.kt index 1244fee9..62c94b4c 100644 --- a/yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/core/YukiResourcesHookCreator.kt +++ b/yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/core/YukiResourcesHookCreator.kt @@ -197,10 +197,12 @@ class YukiResourcesHookCreator @PublishedApi internal constructor( conditions!!.name, compat(replaceInstance) ) { onHookLogMsg(msg = "Hook Resources Value $conditions done [$tag]") } } else when { - layoutInstance != null -> hookResources.instance?.hookLayout(resourceId, layoutInstance!!) - { onHookLogMsg(msg = "Hook Resources Layout Id $resourceId done [$tag]") } - else -> hookResources.instance?.setReplacement(resourceId, compat(replaceInstance)) - { onHookLogMsg(msg = "Hook Resources Value Id $resourceId done [$tag]") } + layoutInstance != null -> hookResources.instance?.hookLayout(resourceId, layoutInstance!!) { + onHookLogMsg(msg = "Hook Resources Layout Id $resourceId done [$tag]") + } + else -> hookResources.instance?.setReplacement(resourceId, compat(replaceInstance)) { + onHookLogMsg(msg = "Hook Resources Value Id $resourceId done [$tag]") + } } packageParam.wrapper?.type == HookEntryType.ZYGOTE -> if (resourceId == -1) when { @@ -214,10 +216,12 @@ class YukiResourcesHookCreator @PublishedApi internal constructor( conditions!!.name, compat(replaceInstance) ) { onHookLogMsg(msg = "Hook Wide Resources Value $conditions done [$tag]") } } else when { - layoutInstance != null -> YukiResources.hookSystemWideLayout(resourceId, layoutInstance!!) - { onHookLogMsg(msg = "Hook Wide Resources Layout Id $resourceId done [$tag]") } - else -> YukiResources.setSystemWideReplacement(resourceId, compat(replaceInstance)) - { onHookLogMsg(msg = "Hook Wide Resources Value Id $resourceId done [$tag]") } + layoutInstance != null -> YukiResources.hookSystemWideLayout(resourceId, layoutInstance!!) { + onHookLogMsg(msg = "Hook Wide Resources Layout Id $resourceId done [$tag]") + } + else -> YukiResources.setSystemWideReplacement(resourceId, compat(replaceInstance)) { + onHookLogMsg(msg = "Hook Wide Resources Value Id $resourceId done [$tag]") + } } else -> yLoggerE(msg = "Resources Hook type is invalid [$tag]") } diff --git a/yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/core/api/compat/HookApiCategory.kt b/yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/core/api/compat/HookApiCategory.kt similarity index 100% rename from yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/core/api/compat/HookApiCategory.kt rename to yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/core/api/compat/HookApiCategory.kt diff --git a/yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/core/api/compat/HookApiCategoryHelper.kt b/yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/core/api/compat/HookApiCategoryHelper.kt similarity index 100% rename from yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/core/api/compat/HookApiCategoryHelper.kt rename to yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/core/api/compat/HookApiCategoryHelper.kt diff --git a/yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/core/api/compat/HookApiProperty.kt b/yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/core/api/compat/HookApiProperty.kt similarity index 100% rename from yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/core/api/compat/HookApiProperty.kt rename to yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/core/api/compat/HookApiProperty.kt diff --git a/yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/core/api/compat/HookCompatHelper.kt b/yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/core/api/compat/HookCompatHelper.kt similarity index 100% rename from yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/core/api/compat/HookCompatHelper.kt rename to yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/core/api/compat/HookCompatHelper.kt diff --git a/yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/core/api/compat/type/ExecutorType.kt b/yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/core/api/compat/type/ExecutorType.kt similarity index 100% rename from yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/core/api/compat/type/ExecutorType.kt rename to yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/core/api/compat/type/ExecutorType.kt diff --git a/yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/core/api/factory/YukiHookDelegateFactory.kt b/yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/core/api/factory/YukiHookDelegateFactory.kt similarity index 100% rename from yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/core/api/factory/YukiHookDelegateFactory.kt rename to yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/core/api/factory/YukiHookDelegateFactory.kt diff --git a/yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/core/api/helper/YukiHookHelper.kt b/yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/core/api/helper/YukiHookHelper.kt similarity index 100% rename from yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/core/api/helper/YukiHookHelper.kt rename to yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/core/api/helper/YukiHookHelper.kt diff --git a/yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/core/api/priority/YukiHookPriority.kt b/yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/core/api/priority/YukiHookPriority.kt similarity index 100% rename from yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/core/api/priority/YukiHookPriority.kt rename to yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/core/api/priority/YukiHookPriority.kt diff --git a/yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/core/api/proxy/YukiHookCallback.kt b/yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/core/api/proxy/YukiHookCallback.kt similarity index 100% rename from yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/core/api/proxy/YukiHookCallback.kt rename to yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/core/api/proxy/YukiHookCallback.kt diff --git a/yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/core/api/proxy/YukiMemberHook.kt b/yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/core/api/proxy/YukiMemberHook.kt similarity index 100% rename from yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/core/api/proxy/YukiMemberHook.kt rename to yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/core/api/proxy/YukiMemberHook.kt diff --git a/yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/core/api/proxy/YukiMemberReplacement.kt b/yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/core/api/proxy/YukiMemberReplacement.kt similarity index 100% rename from yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/core/api/proxy/YukiMemberReplacement.kt rename to yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/core/api/proxy/YukiMemberReplacement.kt diff --git a/yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/core/api/result/YukiHookResult.kt b/yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/core/api/result/YukiHookResult.kt similarity index 100% rename from yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/core/api/result/YukiHookResult.kt rename to yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/core/api/result/YukiHookResult.kt diff --git a/yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/core/api/store/YukiHookCacheStore.kt b/yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/core/api/store/YukiHookCacheStore.kt similarity index 100% rename from yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/core/api/store/YukiHookCacheStore.kt rename to yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/core/api/store/YukiHookCacheStore.kt diff --git a/yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/core/finder/base/BaseFinder.kt b/yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/core/finder/base/BaseFinder.kt similarity index 100% rename from yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/core/finder/base/BaseFinder.kt rename to yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/core/finder/base/BaseFinder.kt diff --git a/yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/core/finder/base/ClassBaseFinder.kt b/yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/core/finder/base/ClassBaseFinder.kt similarity index 100% rename from yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/core/finder/base/ClassBaseFinder.kt rename to yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/core/finder/base/ClassBaseFinder.kt diff --git a/yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/core/finder/base/MemberBaseFinder.kt b/yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/core/finder/base/MemberBaseFinder.kt similarity index 100% rename from yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/core/finder/base/MemberBaseFinder.kt rename to yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/core/finder/base/MemberBaseFinder.kt diff --git a/yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/core/finder/base/data/BaseRulesData.kt b/yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/core/finder/base/data/BaseRulesData.kt similarity index 100% rename from yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/core/finder/base/data/BaseRulesData.kt rename to yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/core/finder/base/data/BaseRulesData.kt diff --git a/yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/core/finder/base/rules/CountRules.kt b/yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/core/finder/base/rules/CountRules.kt similarity index 100% rename from yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/core/finder/base/rules/CountRules.kt rename to yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/core/finder/base/rules/CountRules.kt diff --git a/yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/core/finder/base/rules/ModifierRules.kt b/yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/core/finder/base/rules/ModifierRules.kt similarity index 100% rename from yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/core/finder/base/rules/ModifierRules.kt rename to yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/core/finder/base/rules/ModifierRules.kt diff --git a/yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/core/finder/base/rules/NameRules.kt b/yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/core/finder/base/rules/NameRules.kt similarity index 100% rename from yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/core/finder/base/rules/NameRules.kt rename to yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/core/finder/base/rules/NameRules.kt diff --git a/yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/core/finder/base/rules/ObjectRules.kt b/yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/core/finder/base/rules/ObjectRules.kt similarity index 100% rename from yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/core/finder/base/rules/ObjectRules.kt rename to yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/core/finder/base/rules/ObjectRules.kt diff --git a/yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/core/finder/classes/DexClassFinder.kt b/yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/core/finder/classes/DexClassFinder.kt similarity index 99% rename from yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/core/finder/classes/DexClassFinder.kt rename to yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/core/finder/classes/DexClassFinder.kt index 84ed37c8..65562f44 100644 --- a/yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/core/finder/classes/DexClassFinder.kt +++ b/yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/core/finder/classes/DexClassFinder.kt @@ -94,7 +94,7 @@ class DexClassFinder @PublishedApi internal constructor( * @return [SharedPreferences] */ private fun Context.currentSp(versionName: String? = null, versionCode: Long? = null) = - @Suppress("DEPRECATION") + @Suppress("DEPRECATION", "KotlinRedundantDiagnosticSuppress") getSharedPreferences(packageManager?.getPackageInfo(packageName, PackageManager.GET_META_DATA) ?.let { "${CACHE_FILE_NAME}_${versionName ?: it.versionName}_${versionCode ?: PackageInfoCompat.getLongVersionCode(it)}" } ?: "${CACHE_FILE_NAME}_unknown", diff --git a/yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/core/finder/classes/data/ClassRulesData.kt b/yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/core/finder/classes/data/ClassRulesData.kt similarity index 92% rename from yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/core/finder/classes/data/ClassRulesData.kt rename to yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/core/finder/classes/data/ClassRulesData.kt index 96706808..6bf6efa6 100644 --- a/yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/core/finder/classes/data/ClassRulesData.kt +++ b/yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/core/finder/classes/data/ClassRulesData.kt @@ -171,11 +171,11 @@ internal class ClassRulesData internal constructor( override val isInitialize get() = super.isInitialize || fromPackages.isNotEmpty() || fullName != null || simpleName != null || singleName != null || - fullNameConditions != null || simpleNameConditions != null || singleNameConditions != null || isAnonymousClass != null || - isNoExtendsClass != null || isNoImplementsClass != null || extendsClass.isNotEmpty() || enclosingClass.isNotEmpty() || - memberRules.isNotEmpty() || fieldRules.isNotEmpty() || methodRules.isNotEmpty() || constroctorRules.isNotEmpty() + fullNameConditions != null || simpleNameConditions != null || singleNameConditions != null || isAnonymousClass != null || + isNoExtendsClass != null || isNoImplementsClass != null || extendsClass.isNotEmpty() || enclosingClass.isNotEmpty() || + memberRules.isNotEmpty() || fieldRules.isNotEmpty() || methodRules.isNotEmpty() || constroctorRules.isNotEmpty() override fun toString() = "[$fromPackages][$fullName][$simpleName][$singleName][$fullNameConditions][$simpleNameConditions]" + - "[$singleNameConditions][$modifiers][$isAnonymousClass][$isNoExtendsClass][$isNoImplementsClass][$extendsClass][$implementsClass]" + - "[$enclosingClass][$memberRules][$fieldRules][$methodRules][$constroctorRules]" + super.toString() + "[$singleNameConditions][$modifiers][$isAnonymousClass][$isNoExtendsClass][$isNoImplementsClass][$extendsClass][$implementsClass]" + + "[$enclosingClass][$memberRules][$fieldRules][$methodRules][$constroctorRules]" + super.toString() } \ No newline at end of file diff --git a/yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/core/finder/classes/rules/ConstructorRules.kt b/yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/core/finder/classes/rules/ConstructorRules.kt similarity index 100% rename from yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/core/finder/classes/rules/ConstructorRules.kt rename to yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/core/finder/classes/rules/ConstructorRules.kt diff --git a/yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/core/finder/classes/rules/FieldRules.kt b/yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/core/finder/classes/rules/FieldRules.kt similarity index 100% rename from yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/core/finder/classes/rules/FieldRules.kt rename to yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/core/finder/classes/rules/FieldRules.kt diff --git a/yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/core/finder/classes/rules/MemberRules.kt b/yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/core/finder/classes/rules/MemberRules.kt similarity index 100% rename from yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/core/finder/classes/rules/MemberRules.kt rename to yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/core/finder/classes/rules/MemberRules.kt diff --git a/yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/core/finder/classes/rules/MethodRules.kt b/yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/core/finder/classes/rules/MethodRules.kt similarity index 100% rename from yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/core/finder/classes/rules/MethodRules.kt rename to yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/core/finder/classes/rules/MethodRules.kt diff --git a/yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/core/finder/classes/rules/base/BaseRules.kt b/yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/core/finder/classes/rules/base/BaseRules.kt similarity index 100% rename from yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/core/finder/classes/rules/base/BaseRules.kt rename to yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/core/finder/classes/rules/base/BaseRules.kt diff --git a/yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/core/finder/classes/rules/result/MemberRulesResult.kt b/yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/core/finder/classes/rules/result/MemberRulesResult.kt similarity index 100% rename from yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/core/finder/classes/rules/result/MemberRulesResult.kt rename to yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/core/finder/classes/rules/result/MemberRulesResult.kt diff --git a/yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/core/finder/members/ConstructorFinder.kt b/yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/core/finder/members/ConstructorFinder.kt similarity index 100% rename from yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/core/finder/members/ConstructorFinder.kt rename to yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/core/finder/members/ConstructorFinder.kt diff --git a/yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/core/finder/members/FieldFinder.kt b/yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/core/finder/members/FieldFinder.kt similarity index 100% rename from yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/core/finder/members/FieldFinder.kt rename to yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/core/finder/members/FieldFinder.kt diff --git a/yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/core/finder/members/MethodFinder.kt b/yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/core/finder/members/MethodFinder.kt similarity index 98% rename from yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/core/finder/members/MethodFinder.kt rename to yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/core/finder/members/MethodFinder.kt index 8904edbf..fc9a47b7 100644 --- a/yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/core/finder/members/MethodFinder.kt +++ b/yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/core/finder/members/MethodFinder.kt @@ -25,7 +25,7 @@ * * This file is Created by fankes on 2022/2/4. */ -@file:Suppress("unused", "MemberVisibilityCanBePrivate", "UNCHECKED_CAST", "KotlinConstantConditions") +@file:Suppress("unused", "MemberVisibilityCanBePrivate", "UNCHECKED_CAST", "KotlinConstantConditions", "UNCHECKED_CAST") package com.highcapable.yukihookapi.hook.core.finder.members @@ -37,7 +37,12 @@ import com.highcapable.yukihookapi.hook.core.finder.base.BaseFinder import com.highcapable.yukihookapi.hook.core.finder.base.MemberBaseFinder import com.highcapable.yukihookapi.hook.core.finder.members.data.MethodRulesData import com.highcapable.yukihookapi.hook.core.finder.tools.ReflectionTool -import com.highcapable.yukihookapi.hook.core.finder.type.factory.* +import com.highcapable.yukihookapi.hook.core.finder.type.factory.CountConditions +import com.highcapable.yukihookapi.hook.core.finder.type.factory.MethodConditions +import com.highcapable.yukihookapi.hook.core.finder.type.factory.ModifierConditions +import com.highcapable.yukihookapi.hook.core.finder.type.factory.NameConditions +import com.highcapable.yukihookapi.hook.core.finder.type.factory.ObjectConditions +import com.highcapable.yukihookapi.hook.core.finder.type.factory.ObjectsConditions import com.highcapable.yukihookapi.hook.factory.hasExtends import com.highcapable.yukihookapi.hook.log.yLoggerW import com.highcapable.yukihookapi.hook.type.defined.UndefinedType diff --git a/yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/core/finder/members/data/ConstructorRulesData.kt b/yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/core/finder/members/data/ConstructorRulesData.kt similarity index 97% rename from yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/core/finder/members/data/ConstructorRulesData.kt rename to yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/core/finder/members/data/ConstructorRulesData.kt index a2c41e8f..3f5ff7ee 100644 --- a/yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/core/finder/members/data/ConstructorRulesData.kt +++ b/yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/core/finder/members/data/ConstructorRulesData.kt @@ -61,7 +61,7 @@ internal class ConstructorRulesData internal constructor( override val isInitialize get() = super.isInitializeOfSuper || paramTypes != null || paramTypesConditions != null || paramCount >= 0 || - paramCountRange.isEmpty().not() || paramCountConditions != null + paramCountRange.isEmpty().not() || paramCountConditions != null override fun toString() = "[$paramTypes][$paramTypesConditions][$paramCount][$paramCountRange]" + super.toString() } \ No newline at end of file diff --git a/yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/core/finder/members/data/FieldRulesData.kt b/yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/core/finder/members/data/FieldRulesData.kt similarity index 100% rename from yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/core/finder/members/data/FieldRulesData.kt rename to yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/core/finder/members/data/FieldRulesData.kt diff --git a/yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/core/finder/members/data/MemberRulesData.kt b/yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/core/finder/members/data/MemberRulesData.kt similarity index 100% rename from yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/core/finder/members/data/MemberRulesData.kt rename to yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/core/finder/members/data/MemberRulesData.kt diff --git a/yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/core/finder/members/data/MethodRulesData.kt b/yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/core/finder/members/data/MethodRulesData.kt similarity index 93% rename from yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/core/finder/members/data/MethodRulesData.kt rename to yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/core/finder/members/data/MethodRulesData.kt index aee3dc41..51249bf9 100644 --- a/yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/core/finder/members/data/MethodRulesData.kt +++ b/yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/core/finder/members/data/MethodRulesData.kt @@ -75,9 +75,9 @@ internal class MethodRulesData internal constructor( override val isInitialize get() = super.isInitializeOfSuper || name.isNotBlank() || nameConditions != null || paramTypes != null || paramTypesConditions != null || - paramCount >= 0 || paramCountRange.isEmpty().not() || paramCountConditions != null || - returnType != null || returnTypeConditions != null + paramCount >= 0 || paramCountRange.isEmpty().not() || paramCountConditions != null || + returnType != null || returnTypeConditions != null override fun toString() = "[$name][$nameConditions][$paramTypes][$paramTypesConditions][$paramCount]" + - "[$paramCountRange][$returnType][$returnTypeConditions]" + super.toString() + "[$paramCountRange][$returnType][$returnTypeConditions]" + super.toString() } \ No newline at end of file diff --git a/yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/core/finder/tools/ReflectionTool.kt b/yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/core/finder/tools/ReflectionTool.kt similarity index 99% rename from yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/core/finder/tools/ReflectionTool.kt rename to yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/core/finder/tools/ReflectionTool.kt index d12d74f5..0042ee67 100644 --- a/yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/core/finder/tools/ReflectionTool.kt +++ b/yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/core/finder/tools/ReflectionTool.kt @@ -538,7 +538,7 @@ internal object ReflectionTool { * @return [Boolean] 返回是否成立 */ private fun Pair?.compare(need: Int, last: Int) = this == null || ((first >= 0 && first == need && second) || - (first < 0 && abs(first) == (last - need) && second) || (last == need && second.not())) + (first < 0 && abs(first) == (last - need) && second) || (last == need && second.not())) /** * 比较位置下标的前后顺序 @@ -549,8 +549,8 @@ internal object ReflectionTool { private fun Pair?.compare(need: Int, last: Int, result: (Boolean) -> Unit) { if (this == null) return ((first >= 0 && first == need && second) || - (first < 0 && abs(first) == (last - need) && second) || - (last == need && second.not())).also(result) + (first < 0 && abs(first) == (last - need) && second) || + (last == need && second.not())).also(result) } /** diff --git a/yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/core/finder/type/factory/TypeAliasFactory.kt b/yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/core/finder/type/factory/TypeAliasFactory.kt similarity index 100% rename from yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/core/finder/type/factory/TypeAliasFactory.kt rename to yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/core/finder/type/factory/TypeAliasFactory.kt diff --git a/yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/entity/YukiBaseHooker.kt b/yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/entity/YukiBaseHooker.kt similarity index 100% rename from yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/entity/YukiBaseHooker.kt rename to yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/entity/YukiBaseHooker.kt diff --git a/yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/factory/ReflectionFactory.kt b/yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/factory/ReflectionFactory.kt similarity index 90% rename from yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/factory/ReflectionFactory.kt rename to yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/factory/ReflectionFactory.kt index af841122..e2b8cd37 100644 --- a/yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/factory/ReflectionFactory.kt +++ b/yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/factory/ReflectionFactory.kt @@ -37,11 +37,37 @@ import com.highcapable.yukihookapi.hook.core.finder.members.ConstructorFinder import com.highcapable.yukihookapi.hook.core.finder.members.FieldFinder import com.highcapable.yukihookapi.hook.core.finder.members.MethodFinder import com.highcapable.yukihookapi.hook.core.finder.tools.ReflectionTool -import com.highcapable.yukihookapi.hook.core.finder.type.factory.* -import com.highcapable.yukihookapi.hook.type.java.* +import com.highcapable.yukihookapi.hook.core.finder.type.factory.ClassConditions +import com.highcapable.yukihookapi.hook.core.finder.type.factory.ConstructorConditions +import com.highcapable.yukihookapi.hook.core.finder.type.factory.FieldConditions +import com.highcapable.yukihookapi.hook.core.finder.type.factory.MethodConditions +import com.highcapable.yukihookapi.hook.core.finder.type.factory.ModifierConditions +import com.highcapable.yukihookapi.hook.type.java.AnyClass +import com.highcapable.yukihookapi.hook.type.java.BooleanClass +import com.highcapable.yukihookapi.hook.type.java.BooleanType +import com.highcapable.yukihookapi.hook.type.java.ByteClass +import com.highcapable.yukihookapi.hook.type.java.ByteType +import com.highcapable.yukihookapi.hook.type.java.CharClass +import com.highcapable.yukihookapi.hook.type.java.CharType +import com.highcapable.yukihookapi.hook.type.java.DoubleClass +import com.highcapable.yukihookapi.hook.type.java.DoubleType +import com.highcapable.yukihookapi.hook.type.java.FloatClass +import com.highcapable.yukihookapi.hook.type.java.FloatType +import com.highcapable.yukihookapi.hook.type.java.IntClass +import com.highcapable.yukihookapi.hook.type.java.IntType +import com.highcapable.yukihookapi.hook.type.java.LongClass +import com.highcapable.yukihookapi.hook.type.java.LongType +import com.highcapable.yukihookapi.hook.type.java.ShortClass +import com.highcapable.yukihookapi.hook.type.java.ShortType +import com.highcapable.yukihookapi.hook.type.java.UnitClass +import com.highcapable.yukihookapi.hook.type.java.UnitType import com.highcapable.yukihookapi.hook.xposed.parasitic.AppParasitics import dalvik.system.BaseDexClassLoader -import java.lang.reflect.* +import java.lang.reflect.Constructor +import java.lang.reflect.Field +import java.lang.reflect.Member +import java.lang.reflect.Method +import java.lang.reflect.ParameterizedType /** * 定义一个 [Class] 中的 [Member] 类型 @@ -411,4 +437,4 @@ inline fun Class<*>.allConstructors(isAccessible: Boolean = true, result: (index * @param result 回调 - ([Int] 下标,[Field] 实例) */ inline fun Class<*>.allFields(isAccessible: Boolean = true, result: (index: Int, field: Field) -> Unit) = - declaredFields.forEachIndexed { p, it -> result(p, it.also { e -> e.isAccessible = isAccessible }) } + declaredFields.forEachIndexed { p, it -> result(p, it.also { e -> e.isAccessible = isAccessible }) } \ No newline at end of file diff --git a/yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/factory/YukiHookFactory.kt b/yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/factory/YukiHookFactory.kt similarity index 99% rename from yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/factory/YukiHookFactory.kt rename to yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/factory/YukiHookFactory.kt index 04db07c4..2bb36957 100644 --- a/yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/factory/YukiHookFactory.kt +++ b/yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/factory/YukiHookFactory.kt @@ -25,7 +25,7 @@ * * This file is Created by fankes on 2022/2/2. */ -@file:Suppress("unused", "DEPRECATION", "DeprecatedCallableAddReplaceWith") +@file:Suppress("unused", "UnusedReceiverParameter", "DeprecatedCallableAddReplaceWith") package com.highcapable.yukihookapi.hook.factory diff --git a/yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/log/LoggerFactory.kt b/yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/log/LoggerFactory.kt similarity index 99% rename from yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/log/LoggerFactory.kt rename to yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/log/LoggerFactory.kt index 56fc8461..47ddc07b 100644 --- a/yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/log/LoggerFactory.kt +++ b/yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/log/LoggerFactory.kt @@ -40,7 +40,8 @@ import com.highcapable.yukihookapi.hook.xposed.parasitic.AppParasitics import java.io.File import java.io.Serializable import java.text.SimpleDateFormat -import java.util.* +import java.util.Date +import java.util.Locale /** * 需要打印的日志类型 diff --git a/yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/param/HookParam.kt b/yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/param/HookParam.kt similarity index 100% rename from yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/param/HookParam.kt rename to yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/param/HookParam.kt diff --git a/yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/param/PackageParam.kt b/yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/param/PackageParam.kt similarity index 98% rename from yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/param/PackageParam.kt rename to yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/param/PackageParam.kt index 1fdac3a6..f45234e9 100644 --- a/yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/param/PackageParam.kt +++ b/yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/param/PackageParam.kt @@ -436,10 +436,10 @@ open class PackageParam internal constructor(@PublishedApi internal var wrapper: hooker.assignInstance(packageParam = this) else yLoggerW( msg = "This Hooker \"${hooker::class.java.name}\" is singleton or reused, " + - "but the current process has multiple package name \"${wrapper?.packageName}\", " + - "the original is \"${it.packageName}\"\n" + - "Make sure your Hooker supports multiple instances for this situation\n" + - "The process with package name \"${wrapper?.packageName}\" will be ignored" + "but the current process has multiple package name \"${wrapper?.packageName}\", " + + "the original is \"${it.packageName}\"\n" + + "Make sure your Hooker supports multiple instances for this situation\n" + + "The process with package name \"${wrapper?.packageName}\" will be ignored" ) else hooker.assignInstance(packageParam = this) } ?: hooker.assignInstance(packageParam = this) diff --git a/yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/param/wrapper/PackageParamWrapper.kt b/yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/param/wrapper/PackageParamWrapper.kt similarity index 100% rename from yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/param/wrapper/PackageParamWrapper.kt rename to yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/param/wrapper/PackageParamWrapper.kt diff --git a/yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/type/android/ComponentTypeFactory.kt b/yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/type/android/ComponentTypeFactory.kt similarity index 99% rename from yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/type/android/ComponentTypeFactory.kt rename to yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/type/android/ComponentTypeFactory.kt index ac6191b9..fe0488aa 100644 --- a/yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/type/android/ComponentTypeFactory.kt +++ b/yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/type/android/ComponentTypeFactory.kt @@ -29,7 +29,7 @@ package com.highcapable.yukihookapi.hook.type.android -import android.app.* +import android.app.* // ktlint-disable no-wildcard-imports import android.appwidget.AppWidgetHost import android.appwidget.AppWidgetManager import android.appwidget.AppWidgetProvider diff --git a/yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/type/android/GraphicsTypeFactory.kt b/yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/type/android/GraphicsTypeFactory.kt similarity index 85% rename from yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/type/android/GraphicsTypeFactory.kt rename to yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/type/android/GraphicsTypeFactory.kt index 194d15e8..f25a9178 100644 --- a/yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/type/android/GraphicsTypeFactory.kt +++ b/yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/type/android/GraphicsTypeFactory.kt @@ -29,10 +29,33 @@ package com.highcapable.yukihookapi.hook.type.android -import android.graphics.* -import android.graphics.drawable.* +import android.graphics.Bitmap +import android.graphics.BitmapFactory +import android.graphics.Canvas +import android.graphics.ColorMatrix +import android.graphics.ColorMatrixColorFilter +import android.graphics.Matrix +import android.graphics.NinePatch +import android.graphics.Outline +import android.graphics.Paint +import android.graphics.Point +import android.graphics.PointF +import android.graphics.Rect +import android.graphics.RectF +import android.graphics.Typeface +import android.graphics.drawable.BitmapDrawable +import android.graphics.drawable.ColorDrawable +import android.graphics.drawable.Drawable +import android.graphics.drawable.GradientDrawable +import android.graphics.drawable.Icon import android.os.Build -import android.text.* +import android.text.Editable +import android.text.GetChars +import android.text.Spannable +import android.text.SpannableStringBuilder +import android.text.TextPaint +import android.text.TextUtils +import android.text.TextWatcher import android.util.Size import android.util.SizeF import com.highcapable.yukihookapi.hook.factory.classOf diff --git a/yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/type/android/ViewTypeFactory.kt b/yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/type/android/ViewTypeFactory.kt similarity index 88% rename from yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/type/android/ViewTypeFactory.kt rename to yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/type/android/ViewTypeFactory.kt index 300be92f..ca9137eb 100644 --- a/yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/type/android/ViewTypeFactory.kt +++ b/yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/type/android/ViewTypeFactory.kt @@ -29,17 +29,51 @@ package com.highcapable.yukihookapi.hook.type.android -import android.animation.* +import android.animation.Animator +import android.animation.AnimatorSet +import android.animation.ObjectAnimator +import android.animation.PropertyValuesHolder +import android.animation.ValueAnimator import android.appwidget.AppWidgetHostView import android.util.AttributeSet -import android.view.* +import android.view.GestureDetector +import android.view.LayoutInflater +import android.view.MotionEvent +import android.view.Surface +import android.view.SurfaceView +import android.view.TextureView +import android.view.View +import android.view.ViewGroup +import android.view.ViewParent +import android.view.ViewPropertyAnimator +import android.view.ViewStructure +import android.view.ViewStub import android.view.animation.AlphaAnimation import android.view.animation.Animation import android.view.animation.TranslateAnimation import android.webkit.WebView import android.webkit.WebViewClient -import android.widget.* +import android.widget.ArrayAdapter +import android.widget.AutoCompleteTextView +import android.widget.BaseAdapter +import android.widget.Button +import android.widget.CheckBox +import android.widget.CompoundButton +import android.widget.EditText +import android.widget.FrameLayout +import android.widget.ImageButton +import android.widget.ImageView +import android.widget.LinearLayout +import android.widget.ListAdapter +import android.widget.ListView +import android.widget.ProgressBar +import android.widget.RelativeLayout +import android.widget.RemoteViews import android.widget.RemoteViews.RemoteView +import android.widget.TextClock +import android.widget.TextView +import android.widget.VideoView +import android.widget.ViewAnimator import com.highcapable.yukihookapi.hook.factory.classOf /** diff --git a/yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/type/defined/DefinedTypeFactory.kt b/yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/type/defined/DefinedTypeFactory.kt similarity index 100% rename from yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/type/defined/DefinedTypeFactory.kt rename to yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/type/defined/DefinedTypeFactory.kt diff --git a/yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/type/java/VariableTypeFactory.kt b/yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/type/java/VariableTypeFactory.kt similarity index 99% rename from yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/type/java/VariableTypeFactory.kt rename to yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/type/java/VariableTypeFactory.kt index 93c6a114..7621e5c2 100644 --- a/yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/type/java/VariableTypeFactory.kt +++ b/yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/type/java/VariableTypeFactory.kt @@ -39,7 +39,7 @@ import dalvik.system.InMemoryDexClassLoader import dalvik.system.PathClassLoader import org.json.JSONArray import org.json.JSONObject -import java.io.* +import java.io.* // ktlint-disable no-wildcard-imports import java.lang.ref.Reference import java.lang.ref.WeakReference import java.lang.reflect.Constructor diff --git a/yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/utils/UtilsFactory.kt b/yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/utils/UtilsFactory.kt similarity index 98% rename from yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/utils/UtilsFactory.kt rename to yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/utils/UtilsFactory.kt index 71583583..01c3a40b 100644 --- a/yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/utils/UtilsFactory.kt +++ b/yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/utils/UtilsFactory.kt @@ -198,7 +198,7 @@ internal class Conditions(internal var value: T) { */ private val result by lazy { optConditions.takeIf { it.isNotEmpty() }?.any { it } == true || - andConditions.takeIf { it.isNotEmpty() }?.any { it.not() }?.not() == true + andConditions.takeIf { it.isNotEmpty() }?.any { it.not() }?.not() == true } /** diff --git a/yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/xposed/application/ModuleApplication.kt b/yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/xposed/application/ModuleApplication.kt similarity index 100% rename from yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/xposed/application/ModuleApplication.kt rename to yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/xposed/application/ModuleApplication.kt diff --git a/yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/xposed/bridge/YukiXposedModule.kt b/yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/xposed/bridge/YukiXposedModule.kt similarity index 100% rename from yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/xposed/bridge/YukiXposedModule.kt rename to yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/xposed/bridge/YukiXposedModule.kt diff --git a/yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/xposed/bridge/caller/YukiXposedModuleCaller.kt b/yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/xposed/bridge/caller/YukiXposedModuleCaller.kt similarity index 100% rename from yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/xposed/bridge/caller/YukiXposedModuleCaller.kt rename to yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/xposed/bridge/caller/YukiXposedModuleCaller.kt diff --git a/yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/xposed/bridge/delegate/XSharedPreferencesDelegate.kt b/yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/xposed/bridge/delegate/XSharedPreferencesDelegate.kt similarity index 100% rename from yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/xposed/bridge/delegate/XSharedPreferencesDelegate.kt rename to yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/xposed/bridge/delegate/XSharedPreferencesDelegate.kt diff --git a/yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/xposed/bridge/event/YukiXposedEvent.kt b/yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/xposed/bridge/event/YukiXposedEvent.kt similarity index 100% rename from yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/xposed/bridge/event/YukiXposedEvent.kt rename to yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/xposed/bridge/event/YukiXposedEvent.kt diff --git a/yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/xposed/bridge/event/caller/YukiXposedEventCaller.kt b/yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/xposed/bridge/event/caller/YukiXposedEventCaller.kt similarity index 100% rename from yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/xposed/bridge/event/caller/YukiXposedEventCaller.kt rename to yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/xposed/bridge/event/caller/YukiXposedEventCaller.kt diff --git a/yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/xposed/bridge/proxy/IYukiXposedModuleLifecycle.kt b/yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/xposed/bridge/proxy/IYukiXposedModuleLifecycle.kt similarity index 100% rename from yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/xposed/bridge/proxy/IYukiXposedModuleLifecycle.kt rename to yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/xposed/bridge/proxy/IYukiXposedModuleLifecycle.kt diff --git a/yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/xposed/bridge/resources/YukiModuleResources.kt b/yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/xposed/bridge/resources/YukiModuleResources.kt similarity index 100% rename from yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/xposed/bridge/resources/YukiModuleResources.kt rename to yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/xposed/bridge/resources/YukiModuleResources.kt diff --git a/yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/xposed/bridge/resources/YukiResForwarder.kt b/yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/xposed/bridge/resources/YukiResForwarder.kt similarity index 100% rename from yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/xposed/bridge/resources/YukiResForwarder.kt rename to yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/xposed/bridge/resources/YukiResForwarder.kt diff --git a/yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/xposed/bridge/resources/YukiResources.kt b/yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/xposed/bridge/resources/YukiResources.kt similarity index 100% rename from yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/xposed/bridge/resources/YukiResources.kt rename to yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/xposed/bridge/resources/YukiResources.kt diff --git a/yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/xposed/bridge/resources/caller/YukiXposedResourcesCaller.kt b/yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/xposed/bridge/resources/caller/YukiXposedResourcesCaller.kt similarity index 100% rename from yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/xposed/bridge/resources/caller/YukiXposedResourcesCaller.kt rename to yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/xposed/bridge/resources/caller/YukiXposedResourcesCaller.kt diff --git a/yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/xposed/bridge/status/YukiXposedModuleStatus.kt b/yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/xposed/bridge/status/YukiXposedModuleStatus.kt similarity index 100% rename from yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/xposed/bridge/status/YukiXposedModuleStatus.kt rename to yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/xposed/bridge/status/YukiXposedModuleStatus.kt diff --git a/yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/xposed/bridge/type/HookEntryType.kt b/yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/xposed/bridge/type/HookEntryType.kt similarity index 100% rename from yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/xposed/bridge/type/HookEntryType.kt rename to yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/xposed/bridge/type/HookEntryType.kt diff --git a/yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/xposed/channel/YukiHookDataChannel.kt b/yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/xposed/channel/YukiHookDataChannel.kt similarity index 96% rename from yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/xposed/channel/YukiHookDataChannel.kt rename to yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/xposed/channel/YukiHookDataChannel.kt index 62f1cf81..e52e9962 100644 --- a/yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/xposed/channel/YukiHookDataChannel.kt +++ b/yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/xposed/channel/YukiHookDataChannel.kt @@ -29,6 +29,7 @@ package com.highcapable.yukihookapi.hook.xposed.channel +import android.annotation.SuppressLint import android.app.Activity import android.app.ActivityManager import android.app.Application @@ -37,10 +38,17 @@ import android.content.Context import android.content.Context.ACTIVITY_SERVICE import android.content.Intent import android.content.IntentFilter -import android.os.* +import android.os.Build +import android.os.Bundle +import android.os.Parcel +import android.os.Parcelable +import android.os.TransactionTooLargeException import com.highcapable.yukihookapi.YukiHookAPI import com.highcapable.yukihookapi.annotation.CauseProblemsApi -import com.highcapable.yukihookapi.hook.log.* +import com.highcapable.yukihookapi.hook.log.YukiHookLogger +import com.highcapable.yukihookapi.hook.log.YukiLoggerData +import com.highcapable.yukihookapi.hook.log.yLoggerE +import com.highcapable.yukihookapi.hook.log.yLoggerW import com.highcapable.yukihookapi.hook.utils.RandomSeed import com.highcapable.yukihookapi.hook.xposed.application.ModuleApplication import com.highcapable.yukihookapi.hook.xposed.bridge.YukiXposedModule @@ -215,6 +223,7 @@ class YukiHookDataChannel private constructor() { * 从 Android 14 (及预览版) 开始 * 外部广播必须声明 [Context.RECEIVER_EXPORTED] */ + @SuppressLint("UnspecifiedRegisterReceiverFlag") if (Build.VERSION.SDK_INT >= 33) context.registerReceiver(handlerReceiver, filter, Context.RECEIVER_EXPORTED) else context.registerReceiver(handlerReceiver, filter) @@ -576,9 +585,9 @@ class YukiHookDataChannel private constructor() { val dataByteSize = wrapper.instance.calDataByteSize() if (dataByteSize < 0 && isAllowSendTooLargeData.not()) return yLoggerE( msg = "YukiHookDataChannel cannot calculate the byte size of the data key of \"${wrapper.instance.key}\" to be sent, " + - "so this data cannot be sent\n" + - "If you want to lift this restriction, use the allowSendTooLargeData function when calling, " + - "but this may cause the app crash" + "so this data cannot be sent\n" + + "If you want to lift this restriction, use the allowSendTooLargeData function when calling, " + + "but this may cause the app crash" ) /** * 如果数据过大打印警告信息 - 仅限 [YukiHookAPI.Configs.isDebug] 启用时生效 @@ -588,7 +597,7 @@ class YukiHookDataChannel private constructor() { fun loggerForTooLargeData(name: String, size: Int) { if (YukiHookAPI.Configs.isDebug) yLoggerW( msg = "This data key of \"${wrapper.instance.key}\" type $name is too large (total ${dataByteSize / 1024f} KB, " + - "limit ${receiverDataMaxByteSize / 1024f} KB), will be segmented to $size piece to send" + "limit ${receiverDataMaxByteSize / 1024f} KB), will be segmented to $size piece to send" ) } @@ -598,11 +607,11 @@ class YukiHookDataChannel private constructor() { */ fun loggerForUnprocessableData(suggestionMessage: String = "") = yLoggerE( msg = "YukiHookDataChannel cannot send this data key of \"${wrapper.instance.key}\" type ${wrapper.instance.value?.javaClass}, " + - "because it is too large (total ${dataByteSize / 1024f} KB, " + - "limit ${receiverDataMaxByteSize / 1024f} KB) and cannot be segmented\n" + - (if (suggestionMessage.isNotBlank()) "$suggestionMessage\n" else "") + - "If you want to lift this restriction, use the allowSendTooLargeData function when calling, " + - "but this may cause the app crash" + "because it is too large (total ${dataByteSize / 1024f} KB, " + + "limit ${receiverDataMaxByteSize / 1024f} KB) and cannot be segmented\n" + + (if (suggestionMessage.isNotBlank()) "$suggestionMessage\n" else "") + + "If you want to lift this restriction, use the allowSendTooLargeData function when calling, " + + "but this may cause the app crash" ) /** @@ -681,7 +690,7 @@ class YukiHookDataChannel private constructor() { is IntArray, is LongArray, is FloatArray, is DoubleArray, is BooleanArray, is Array<*> -> loggerForUnprocessableData( suggestionMessage = "Primitive Array type like String[], int[] ... cannot be segmented, " + - "the suggestion is send those data using List type" + "the suggestion is send those data using List type" ) else -> loggerForUnprocessableData() } diff --git a/yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/xposed/channel/data/ChannelData.kt b/yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/xposed/channel/data/ChannelData.kt similarity index 100% rename from yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/xposed/channel/data/ChannelData.kt rename to yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/xposed/channel/data/ChannelData.kt diff --git a/yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/xposed/channel/data/wrapper/ChannelDataWrapper.kt b/yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/xposed/channel/data/wrapper/ChannelDataWrapper.kt similarity index 100% rename from yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/xposed/channel/data/wrapper/ChannelDataWrapper.kt rename to yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/xposed/channel/data/wrapper/ChannelDataWrapper.kt diff --git a/yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/xposed/channel/priority/ChannelPriority.kt b/yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/xposed/channel/priority/ChannelPriority.kt similarity index 100% rename from yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/xposed/channel/priority/ChannelPriority.kt rename to yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/xposed/channel/priority/ChannelPriority.kt diff --git a/yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/xposed/parasitic/AppParasitics.kt b/yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/xposed/parasitic/AppParasitics.kt similarity index 91% rename from yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/xposed/parasitic/AppParasitics.kt rename to yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/xposed/parasitic/AppParasitics.kt index 29e58f36..272ea644 100644 --- a/yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/xposed/parasitic/AppParasitics.kt +++ b/yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/xposed/parasitic/AppParasitics.kt @@ -30,8 +30,17 @@ package com.highcapable.yukihookapi.hook.xposed.parasitic -import android.app.* -import android.content.* +import android.annotation.SuppressLint +import android.app.Activity +import android.app.ActivityManager +import android.app.AndroidAppHelper +import android.app.Application +import android.app.Instrumentation +import android.content.BroadcastReceiver +import android.content.Context +import android.content.Intent +import android.content.IntentFilter +import android.content.SharedPreferences import android.content.pm.ApplicationInfo import android.content.pm.PackageManager import android.content.res.Configuration @@ -46,11 +55,34 @@ import com.highcapable.yukihookapi.hook.core.api.helper.YukiHookHelper import com.highcapable.yukihookapi.hook.core.api.proxy.YukiHookCallback import com.highcapable.yukihookapi.hook.core.api.proxy.YukiMemberHook import com.highcapable.yukihookapi.hook.core.api.proxy.YukiMemberReplacement -import com.highcapable.yukihookapi.hook.factory.* +import com.highcapable.yukihookapi.hook.factory.classOf +import com.highcapable.yukihookapi.hook.factory.current +import com.highcapable.yukihookapi.hook.factory.field +import com.highcapable.yukihookapi.hook.factory.hasClass +import com.highcapable.yukihookapi.hook.factory.hasMethod +import com.highcapable.yukihookapi.hook.factory.method +import com.highcapable.yukihookapi.hook.factory.toClass +import com.highcapable.yukihookapi.hook.factory.toClassOrNull import com.highcapable.yukihookapi.hook.log.yLoggerE import com.highcapable.yukihookapi.hook.log.yLoggerW -import com.highcapable.yukihookapi.hook.type.android.* -import com.highcapable.yukihookapi.hook.type.java.* +import com.highcapable.yukihookapi.hook.type.android.ActivityManagerClass +import com.highcapable.yukihookapi.hook.type.android.ActivityManagerNativeClass +import com.highcapable.yukihookapi.hook.type.android.ActivityTaskManagerClass +import com.highcapable.yukihookapi.hook.type.android.ActivityThreadClass +import com.highcapable.yukihookapi.hook.type.android.ApplicationClass +import com.highcapable.yukihookapi.hook.type.android.ContextClass +import com.highcapable.yukihookapi.hook.type.android.ContextImplClass +import com.highcapable.yukihookapi.hook.type.android.HandlerClass +import com.highcapable.yukihookapi.hook.type.android.IActivityManagerClass +import com.highcapable.yukihookapi.hook.type.android.IActivityTaskManagerClass +import com.highcapable.yukihookapi.hook.type.android.InstrumentationClass +import com.highcapable.yukihookapi.hook.type.android.IntentClass +import com.highcapable.yukihookapi.hook.type.android.SingletonClass +import com.highcapable.yukihookapi.hook.type.android.UserHandleClass +import com.highcapable.yukihookapi.hook.type.java.BooleanType +import com.highcapable.yukihookapi.hook.type.java.IntType +import com.highcapable.yukihookapi.hook.type.java.JavaClassLoader +import com.highcapable.yukihookapi.hook.type.java.StringClass import com.highcapable.yukihookapi.hook.xposed.bridge.YukiXposedModule import com.highcapable.yukihookapi.hook.xposed.bridge.status.YukiXposedModuleStatus import com.highcapable.yukihookapi.hook.xposed.bridge.type.HookEntryType @@ -153,7 +185,7 @@ internal object AppParasitics { * @return [Int] */ internal fun findUserId(packageName: String) = runCatching { - @Suppress("DEPRECATION") + @Suppress("DEPRECATION", "KotlinRedundantDiagnosticSuppress") UserHandleClass.method { name = "getUserId" param(IntType) @@ -309,6 +341,7 @@ internal object AppParasitics { * 从 Android 14 (及预览版) 开始 * 外部广播必须声明 [Context.RECEIVER_EXPORTED] */ + @SuppressLint("UnspecifiedRegisterReceiverFlag") if (Build.VERSION.SDK_INT >= 33) it.registerReceiver(receiver, this, Context.RECEIVER_EXPORTED) else it.registerReceiver(receiver, this) @@ -376,7 +409,7 @@ internal object AppParasitics { else -> error("This proxy [$it] type is not allowed") } }?.takeIf { it.isNotBlank() } ?: context.packageManager?.runCatching { - @Suppress("DEPRECATION") + @Suppress("DEPRECATION", "KotlinRedundantDiagnosticSuppress") queryIntentActivities(getLaunchIntentForPackage(context.packageName)!!, 0).first().activityInfo.name }?.getOrNull() ?: "" if ((proxyClassName.hasClass(context.classLoader) && proxyClassName.toClass(context.classLoader).hasMethod { diff --git a/yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/xposed/parasitic/activity/base/ModuleAppActivity.kt b/yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/xposed/parasitic/activity/base/ModuleAppActivity.kt similarity index 100% rename from yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/xposed/parasitic/activity/base/ModuleAppActivity.kt rename to yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/xposed/parasitic/activity/base/ModuleAppActivity.kt diff --git a/yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/xposed/parasitic/activity/base/ModuleAppCompatActivity.kt b/yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/xposed/parasitic/activity/base/ModuleAppCompatActivity.kt similarity index 100% rename from yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/xposed/parasitic/activity/base/ModuleAppCompatActivity.kt rename to yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/xposed/parasitic/activity/base/ModuleAppCompatActivity.kt diff --git a/yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/xposed/parasitic/activity/config/ActivityProxyConfig.kt b/yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/xposed/parasitic/activity/config/ActivityProxyConfig.kt similarity index 100% rename from yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/xposed/parasitic/activity/config/ActivityProxyConfig.kt rename to yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/xposed/parasitic/activity/config/ActivityProxyConfig.kt diff --git a/yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/xposed/parasitic/activity/delegate/InstrumentationDelegate.kt b/yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/xposed/parasitic/activity/delegate/InstrumentationDelegate.kt similarity index 96% rename from yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/xposed/parasitic/activity/delegate/InstrumentationDelegate.kt rename to yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/xposed/parasitic/activity/delegate/InstrumentationDelegate.kt index f5c6ef5d..832a0a5b 100644 --- a/yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/xposed/parasitic/activity/delegate/InstrumentationDelegate.kt +++ b/yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/xposed/parasitic/activity/delegate/InstrumentationDelegate.kt @@ -37,10 +37,19 @@ import android.content.Context import android.content.Intent import android.content.IntentFilter import android.content.pm.ActivityInfo -import android.os.* +import android.os.Build +import android.os.Bundle +import android.os.IBinder +import android.os.Looper +import android.os.PersistableBundle +import android.os.TestLooperManager import android.view.KeyEvent import android.view.MotionEvent -import com.highcapable.yukihookapi.hook.factory.* +import com.highcapable.yukihookapi.hook.factory.buildOf +import com.highcapable.yukihookapi.hook.factory.current +import com.highcapable.yukihookapi.hook.factory.injectModuleAppResources +import com.highcapable.yukihookapi.hook.factory.processName +import com.highcapable.yukihookapi.hook.factory.toClass import com.highcapable.yukihookapi.hook.xposed.bridge.YukiXposedModule import com.highcapable.yukihookapi.hook.xposed.parasitic.AppParasitics diff --git a/yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/xposed/parasitic/activity/delegate/caller/HandlerDelegateCaller.kt b/yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/xposed/parasitic/activity/delegate/caller/HandlerDelegateCaller.kt similarity index 100% rename from yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/xposed/parasitic/activity/delegate/caller/HandlerDelegateCaller.kt rename to yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/xposed/parasitic/activity/delegate/caller/HandlerDelegateCaller.kt diff --git a/yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/xposed/parasitic/activity/delegate/caller/IActivityManagerProxyCaller.kt b/yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/xposed/parasitic/activity/delegate/caller/IActivityManagerProxyCaller.kt similarity index 93% rename from yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/xposed/parasitic/activity/delegate/caller/IActivityManagerProxyCaller.kt rename to yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/xposed/parasitic/activity/delegate/caller/IActivityManagerProxyCaller.kt index c146c027..6dda46e4 100644 --- a/yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/xposed/parasitic/activity/delegate/caller/IActivityManagerProxyCaller.kt +++ b/yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/xposed/parasitic/activity/delegate/caller/IActivityManagerProxyCaller.kt @@ -34,7 +34,11 @@ import android.app.Activity import android.app.ActivityManager import android.content.Intent import com.highcapable.yukihookapi.annotation.YukiGenerateApi -import com.highcapable.yukihookapi.hook.factory.* +import com.highcapable.yukihookapi.hook.factory.buildOf +import com.highcapable.yukihookapi.hook.factory.classOf +import com.highcapable.yukihookapi.hook.factory.extends +import com.highcapable.yukihookapi.hook.factory.hasClass +import com.highcapable.yukihookapi.hook.factory.toClassOrNull import com.highcapable.yukihookapi.hook.xposed.parasitic.AppParasitics import com.highcapable.yukihookapi.hook.xposed.parasitic.activity.base.ModuleAppActivity import com.highcapable.yukihookapi.hook.xposed.parasitic.activity.base.ModuleAppCompatActivity diff --git a/yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/xposed/parasitic/activity/delegate/impl/HandlerDelegateImpl.kt b/yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/xposed/parasitic/activity/delegate/impl/HandlerDelegateImpl.kt similarity index 100% rename from yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/xposed/parasitic/activity/delegate/impl/HandlerDelegateImpl.kt rename to yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/xposed/parasitic/activity/delegate/impl/HandlerDelegateImpl.kt diff --git a/yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/xposed/parasitic/activity/delegate/impl/IActivityManagerProxyImpl.kt b/yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/xposed/parasitic/activity/delegate/impl/IActivityManagerProxyImpl.kt similarity index 100% rename from yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/xposed/parasitic/activity/delegate/impl/IActivityManagerProxyImpl.kt rename to yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/xposed/parasitic/activity/delegate/impl/IActivityManagerProxyImpl.kt diff --git a/yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/xposed/parasitic/context/wrapper/ModuleContextThemeWrapper.kt b/yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/xposed/parasitic/context/wrapper/ModuleContextThemeWrapper.kt similarity index 100% rename from yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/xposed/parasitic/context/wrapper/ModuleContextThemeWrapper.kt rename to yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/xposed/parasitic/context/wrapper/ModuleContextThemeWrapper.kt diff --git a/yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/xposed/parasitic/reference/ModuleClassLoader.kt b/yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/xposed/parasitic/reference/ModuleClassLoader.kt similarity index 100% rename from yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/xposed/parasitic/reference/ModuleClassLoader.kt rename to yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/xposed/parasitic/reference/ModuleClassLoader.kt diff --git a/yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/xposed/prefs/YukiHookPrefsBridge.kt b/yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/xposed/prefs/YukiHookPrefsBridge.kt similarity index 99% rename from yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/xposed/prefs/YukiHookPrefsBridge.kt rename to yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/xposed/prefs/YukiHookPrefsBridge.kt index ad4ce4af..30dc5f6b 100644 --- a/yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/xposed/prefs/YukiHookPrefsBridge.kt +++ b/yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/xposed/prefs/YukiHookPrefsBridge.kt @@ -129,7 +129,7 @@ class YukiHookPrefsBridge private constructor(private var context: Context? = nu private inline fun makeWorldReadable(callback: () -> T): T { val result = callback() if (isXposedEnvironment.not() && isUsingNewXSharedPreferences.not()) - runCatching { makeWorldReadable(context, prefsFileName = "${currentPrefsName}.xml") } + runCatching { makeWorldReadable(context, prefsFileName = "$currentPrefsName.xml") } return result } diff --git a/yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/xposed/prefs/data/PrefsData.kt b/yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/xposed/prefs/data/PrefsData.kt similarity index 100% rename from yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/xposed/prefs/data/PrefsData.kt rename to yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/xposed/prefs/data/PrefsData.kt diff --git a/yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/xposed/prefs/ui/ModulePreferenceFragment.kt b/yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/xposed/prefs/ui/ModulePreferenceFragment.kt similarity index 100% rename from yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/xposed/prefs/ui/ModulePreferenceFragment.kt rename to yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/xposed/prefs/ui/ModulePreferenceFragment.kt diff --git a/yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/xposed/proxy/IYukiHookXposedInit.kt b/yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/xposed/proxy/IYukiHookXposedInit.kt similarity index 100% rename from yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/xposed/proxy/IYukiHookXposedInit.kt rename to yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/xposed/proxy/IYukiHookXposedInit.kt diff --git a/yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/xposed/proxy/YukiHookXposedInitProxy.kt b/yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/xposed/proxy/YukiHookXposedInitProxy.kt similarity index 100% rename from yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/xposed/proxy/YukiHookXposedInitProxy.kt rename to yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/xposed/proxy/YukiHookXposedInitProxy.kt diff --git a/yukihookapi-ksp-xposed/src/api/kotlin/com/highcapable/yukihookapi_ksp_xposed/YukiHookXposedProcessor.kt b/yukihookapi-ksp-xposed/src/api/kotlin/com/highcapable/yukihookapi/YukiHookXposedProcessor.kt similarity index 92% rename from yukihookapi-ksp-xposed/src/api/kotlin/com/highcapable/yukihookapi_ksp_xposed/YukiHookXposedProcessor.kt rename to yukihookapi-ksp-xposed/src/api/kotlin/com/highcapable/yukihookapi/YukiHookXposedProcessor.kt index 1aa81aff..838a1509 100644 --- a/yukihookapi-ksp-xposed/src/api/kotlin/com/highcapable/yukihookapi_ksp_xposed/YukiHookXposedProcessor.kt +++ b/yukihookapi-ksp-xposed/src/api/kotlin/com/highcapable/yukihookapi/YukiHookXposedProcessor.kt @@ -27,18 +27,23 @@ */ @file:Suppress("unused", "KDocUnresolvedReference") -package com.highcapable.yukihookapi_ksp_xposed +package com.highcapable.yukihookapi import com.google.auto.service.AutoService -import com.google.devtools.ksp.processing.* +import com.google.devtools.ksp.processing.Dependencies +import com.google.devtools.ksp.processing.Resolver +import com.google.devtools.ksp.processing.SymbolProcessor +import com.google.devtools.ksp.processing.SymbolProcessorEnvironment +import com.google.devtools.ksp.processing.SymbolProcessorProvider import com.google.devtools.ksp.symbol.ClassKind import com.google.devtools.ksp.symbol.FileLocation import com.google.devtools.ksp.symbol.KSAnnotated import com.google.devtools.ksp.symbol.KSClassDeclaration -import com.highcapable.yukihookapi_ksp_xposed.bean.GenerateData -import com.highcapable.yukihookapi_ksp_xposed.factory.ClassName -import com.highcapable.yukihookapi_ksp_xposed.factory.PackageName -import com.highcapable.yukihookapi_ksp_xposed.factory.sources +import com.highcapable.yukihookapi.bean.GenerateData +import com.highcapable.yukihookapi.factory.ClassName +import com.highcapable.yukihookapi.factory.PackageName +import com.highcapable.yukihookapi.factory.sources +import com.highcapable.yukihookapi.generated.YukiHookAPIProperties import org.w3c.dom.Element import org.w3c.dom.Node import java.io.File @@ -59,7 +64,7 @@ class YukiHookXposedProcessor : SymbolProcessorProvider { private companion object { /** 自动处理程序的 TAG */ - private const val TAG = "YukiHookAPI" + private const val TAG = YukiHookAPIProperties.PROJECT_NAME /** 查找的注解名称 */ private const val ANNOTATION_NAME = "com.highcapable.yukihookapi.annotation.xposed.InjectYukiHookWithXposed" @@ -93,8 +98,8 @@ class YukiHookXposedProcessor : SymbolProcessorProvider { */ private fun SymbolProcessorEnvironment.problem(msg: String): Nothing { val helpMsg = "Looking for help? Please see the documentation link below\n" + - "- English: https://fankes.github.io/YukiHookAPI/en/config/xposed-using\n" + - "- Chinese(Simplified): https://fankes.github.io/YukiHookAPI/zh-cn/config/xposed-using" + "- English: https://fankes.github.io/YukiHookAPI/en/config/xposed-using\n" + + "- Chinese(Simplified): https://fankes.github.io/YukiHookAPI/zh-cn/config/xposed-using" logger.error(message = "[$TAG] $msg\n$helpMsg") throw RuntimeException("[$TAG] $msg\n$helpMsg") } @@ -183,14 +188,14 @@ class YukiHookXposedProcessor : SymbolProcessorProvider { data.isUsingResourcesHook = args.value as? Boolean ?: true } if ((data.customMPackageName.startsWith(".") || - data.customMPackageName.endsWith(".") || - data.customMPackageName.contains(".").not() || - data.customMPackageName.contains("..")) && + data.customMPackageName.endsWith(".") || + data.customMPackageName.contains(".").not() || + data.customMPackageName.contains("..")) && data.customMPackageName.isNotEmpty() ) problem(msg = "Invalid modulePackageName \"${data.customMPackageName}\"") if ((Pattern.compile("[*,.:~`'\"|/\\\\?!^()\\[\\]{}%@#$&\\-+=<>]").matcher(data.entryClassName).find() || - true.let { for (i in 0..9) if (data.entryClassName.startsWith(i.toString())) return@let true; false }) - && data.entryClassName.isNotEmpty() + true.let { for (i in 0..9) if (data.entryClassName.startsWith(i.toString())) return@let true; false }) && + data.entryClassName.isNotEmpty() ) problem(msg = "Invalid entryClassName \"${data.entryClassName}\"") else fetchKSClassDeclaration(sourcePath) } @@ -255,7 +260,7 @@ class YukiHookXposedProcessor : SymbolProcessorProvider { private fun generateClassFile(data: GenerateData) = environment(ignored = true) { if (data.customMPackageName.isNotBlank()) warn( msg = "You set the customize module package name to \"${data.customMPackageName}\", " + - "please check for yourself if it is correct" + "please check for yourself if it is correct" ) /** 插入 YukiHookAPI_Impl 代码 */ createCodeFile( diff --git a/yukihookapi-ksp-xposed/src/api/kotlin/com/highcapable/yukihookapi_ksp_xposed/bean/GenerateData.kt b/yukihookapi-ksp-xposed/src/api/kotlin/com/highcapable/yukihookapi/bean/GenerateData.kt similarity index 97% rename from yukihookapi-ksp-xposed/src/api/kotlin/com/highcapable/yukihookapi_ksp_xposed/bean/GenerateData.kt rename to yukihookapi-ksp-xposed/src/api/kotlin/com/highcapable/yukihookapi/bean/GenerateData.kt index efef6765..ffb58b4e 100644 --- a/yukihookapi-ksp-xposed/src/api/kotlin/com/highcapable/yukihookapi_ksp_xposed/bean/GenerateData.kt +++ b/yukihookapi-ksp-xposed/src/api/kotlin/com/highcapable/yukihookapi/bean/GenerateData.kt @@ -25,7 +25,7 @@ * * This file is Created by fankes on 2022/9/20. */ -package com.highcapable.yukihookapi_ksp_xposed.bean +package com.highcapable.yukihookapi.bean /** * 生成的模板数据实例 diff --git a/yukihookapi-ksp-xposed/src/api/kotlin/com/highcapable/yukihookapi/factory/CodeSourceFileFactory.kt b/yukihookapi-ksp-xposed/src/api/kotlin/com/highcapable/yukihookapi/factory/CodeSourceFileFactory.kt new file mode 100644 index 00000000..91abdf86 --- /dev/null +++ b/yukihookapi-ksp-xposed/src/api/kotlin/com/highcapable/yukihookapi/factory/CodeSourceFileFactory.kt @@ -0,0 +1,540 @@ +/* + * YukiHookAPI - An efficient Hook API and Xposed Module solution built in Kotlin. + * Copyright (C) 2019-2023 HighCapable + * https://github.com/fankes/YukiHookAPI + * + * MIT License + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * This file is Created by fankes on 2022/9/20. + */ +@file:Suppress("ConstPropertyName") + +package com.highcapable.yukihookapi.factory + +import com.highcapable.yukihookapi.bean.GenerateData +import com.highcapable.yukihookapi.generated.YukiHookAPIProperties +import java.text.SimpleDateFormat +import java.util.Date + +/** + * 包名常量定义类 + */ +object PackageName { + const val YukiHookAPI_Impl = "com.highcapable.yukihookapi" + const val ModuleApplication_Impl = "com.highcapable.yukihookapi.hook.xposed.application" + const val YukiXposedModuleStatus_Impl = "com.highcapable.yukihookapi.hook.xposed.bridge.status" + const val HandlerDelegateImpl_Impl = "com.highcapable.yukihookapi.hook.xposed.parasitic.activity.delegate.impl" + const val HandlerDelegateClass = "com.highcapable.yukihookapi.hook.xposed.parasitic.activity.delegate" + const val IActivityManagerProxyImpl_Impl = "com.highcapable.yukihookapi.hook.xposed.parasitic.activity.delegate.impl" + const val IActivityManagerProxyClass = "com.highcapable.yukihookapi.hook.xposed.parasitic.activity.delegate" + const val BootstrapReflectionClass = "com.highcapable.yukihookapi.thirdparty.me.weishu.reflection" +} + +/** + * 类名常量定义类 + */ +object ClassName { + const val YukiHookAPI_Impl = "YukiHookAPI_Impl" + const val ModuleApplication_Impl = "ModuleApplication_Impl" + const val YukiXposedModuleStatus_Impl = "YukiXposedModuleStatus_Impl" + const val HandlerDelegateImpl_Impl = "HandlerDelegateImpl_Impl" + const val HandlerDelegateClass = "HandlerDelegate" + const val IActivityManagerProxyImpl_Impl = "IActivityManagerProxyImpl_Impl" + const val IActivityManagerProxyClass = "IActivityManagerProxy" + const val XposedInit = "xposed_init" + const val XposedInit_Impl = "xposed_init_Impl" + const val BootstrapClass = "BootstrapClass" + const val Reflection = "Reflection" +} + +/** + * 外部调用者包名和类名定义类 + */ +object ExternalCallerName { + val YukiGenerateApiAnnotation = Pair( + "com.highcapable.yukihookapi.annotation.YukiGenerateApi", + "YukiGenerateApi" + ) + val HandlerDelegateCaller = Pair( + "com.highcapable.yukihookapi.hook.xposed.parasitic.activity.delegate.caller.HandlerDelegateCaller", + "HandlerDelegateCaller" + ) + val IActivityManagerProxyCaller = Pair( + "com.highcapable.yukihookapi.hook.xposed.parasitic.activity.delegate.caller.IActivityManagerProxyCaller", + "IActivityManagerProxyCaller" + ) + val YukiXposedEventCaller = Pair( + "com.highcapable.yukihookapi.hook.xposed.bridge.event.caller.YukiXposedEventCaller", + "YukiXposedEventCaller" + ) + val YukiXposedModuleCaller = Pair( + "com.highcapable.yukihookapi.hook.xposed.bridge.caller.YukiXposedModuleCaller", + "YukiXposedModuleCaller" + ) + val YukiXposedResourcesCaller = Pair( + "com.highcapable.yukihookapi.hook.xposed.bridge.resources.caller.YukiXposedResourcesCaller", + "YukiXposedResourcesCaller" + ) +} + +/** + * YukiXposedModuleStatus 方法名称定义类 + */ +object YukiXposedModuleStatusJvmName { + const val IS_ACTIVE_METHOD_NAME = "__--" + const val IS_SUPPORT_RESOURCES_HOOK_METHOD_NAME = "_--_" + const val GET_EXECUTOR_NAME_METHOD_NAME = "_-_-" + const val GET_EXECUTOR_API_LEVEL_METHOD_NAME = "-__-" + const val GET_EXECUTOR_VERSION_NAME_METHOD_NAME = "-_-_" + const val GET_EXECUTOR_VERSION_CODE_METHOD_NAME = "___-" +} + +/** + * 创建尾部包名名称 + * @param name 前置名称 + * @return [String] + */ +private fun GenerateData.tailPackageName(name: String) = "${name}_${modulePackageName.replace(".", "_")}" + +/** + * 创建文件注释 + * @param currrentClassTag 当前注入类标签 + * @return [String] + */ +private fun createCommentContent(currrentClassTag: String) = + """ + /** + * $currrentClassTag Class + * + * Compiled from YukiHookXposedProcessor + * + * Generate Date: ${SimpleDateFormat.getDateTimeInstance().format(Date())} + * + * Powered by YukiHookAPI (C) HighCapable 2019-2023 + * + * Project URL: [${YukiHookAPIProperties.PROJECT_NAME}](${YukiHookAPIProperties.PROJECT_URL}) + */ + """.trimIndent() + +/** + * 获得注入文件代码内容 + * @return [Map]<[String], [String]> + */ +fun GenerateData.sources() = mapOf( + ClassName.YukiHookAPI_Impl to """ + @file:Suppress("ClassName") + + package ${PackageName.YukiHookAPI_Impl} + """.trimIndent() + "\n\n" + createCommentContent(ClassName.YukiHookAPI_Impl) + "\n" + """ + object ${ClassName.YukiHookAPI_Impl} { + + val compiledTimestamp get() = ${System.currentTimeMillis()} + } + """.trimIndent(), + ClassName.ModuleApplication_Impl to """ + @file:Suppress("ClassName") + + package ${PackageName.ModuleApplication_Impl} + + import $entryPackageName.$entryClassName + """.trimIndent() + "\n\n" + createCommentContent(ClassName.ModuleApplication_Impl) + "\n" + """ + object ${ClassName.ModuleApplication_Impl} { + + fun callHookEntryInit() = try { + ${if (isEntryClassKindOfObject) "$entryClassName.onInit()" else "$entryClassName().onInit()"} + } catch (_: Throwable) { + } + } + """.trimIndent(), + ClassName.YukiXposedModuleStatus_Impl to """ + @file:Suppress("ClassName") + + package ${PackageName.YukiXposedModuleStatus_Impl} + + import android.util.Log + import androidx.annotation.Keep + """.trimIndent() + "\n\n" + createCommentContent(ClassName.YukiXposedModuleStatus_Impl) + "\n" + """ + @Keep + object ${ClassName.YukiXposedModuleStatus_Impl} { + + @JvmName("${YukiXposedModuleStatusJvmName.IS_ACTIVE_METHOD_NAME}") + fun isActive(): Boolean { + placeholderExecution() + return false + } + + @JvmName("${YukiXposedModuleStatusJvmName.IS_SUPPORT_RESOURCES_HOOK_METHOD_NAME}") + fun isSupportResourcesHook(): Boolean { + placeholderExecution() + return false + } + + @JvmName("${YukiXposedModuleStatusJvmName.GET_EXECUTOR_NAME_METHOD_NAME}") + fun getExecutorName(): String { + placeholderExecution() + return "unknown" + } + + @JvmName("${YukiXposedModuleStatusJvmName.GET_EXECUTOR_API_LEVEL_METHOD_NAME}") + fun getExecutorApiLevel(): Int { + placeholderExecution() + return -1 + } + + @JvmName("${YukiXposedModuleStatusJvmName.GET_EXECUTOR_VERSION_NAME_METHOD_NAME}") + fun getExecutorVersionName(): String { + placeholderExecution() + return "unknown" + } + + @JvmName("${YukiXposedModuleStatusJvmName.GET_EXECUTOR_VERSION_CODE_METHOD_NAME}") + fun getExecutorVersionCode(): Int { + placeholderExecution() + return -1 + } + + private fun placeholderExecution() { + /** Consume a long method body */ + if (System.currentTimeMillis() == 0L) Log.d("${(1000..9999).random()}", "${(100000..999999).random()}") + } + } + """.trimIndent(), + ClassName.HandlerDelegateImpl_Impl to """ + @file:Suppress("ClassName") + + package ${PackageName.HandlerDelegateImpl_Impl} + + import android.os.Handler + import ${ExternalCallerName.YukiGenerateApiAnnotation.first} + import ${PackageName.HandlerDelegateClass}.${tailPackageName(ClassName.HandlerDelegateClass)} + """.trimIndent() + "\n\n" + createCommentContent(ClassName.HandlerDelegateImpl_Impl) + "\n" + """ + @${ExternalCallerName.YukiGenerateApiAnnotation.second} + object ${ClassName.HandlerDelegateImpl_Impl} { + + val wrapperClassName get() = "${PackageName.HandlerDelegateClass}.${tailPackageName(ClassName.HandlerDelegateClass)}" + + fun createWrapper(baseInstance: Handler.Callback? = null): Handler.Callback = ${tailPackageName(ClassName.HandlerDelegateClass)}(baseInstance) + } + """.trimIndent(), + ClassName.HandlerDelegateClass to """ + @file:Suppress("ClassName") + + package ${PackageName.HandlerDelegateClass} + + import android.os.Handler + import android.os.Message + import androidx.annotation.Keep + import ${ExternalCallerName.YukiGenerateApiAnnotation.first} + import ${ExternalCallerName.HandlerDelegateCaller.first} + """.trimIndent() + "\n\n" + createCommentContent(ClassName.HandlerDelegateClass) + "\n" + """ + @Keep + @${ExternalCallerName.YukiGenerateApiAnnotation.second} + class ${tailPackageName(ClassName.HandlerDelegateClass)}(private val baseInstance: Handler.Callback?) : Handler.Callback { + + override fun handleMessage(msg: Message) = ${ExternalCallerName.HandlerDelegateCaller.second}.callHandleMessage(baseInstance, msg) + } + """.trimIndent(), + ClassName.IActivityManagerProxyImpl_Impl to """ + @file:Suppress("ClassName") + + package ${PackageName.IActivityManagerProxyImpl_Impl} + + import android.os.Handler + import ${ExternalCallerName.YukiGenerateApiAnnotation.first} + import ${ExternalCallerName.IActivityManagerProxyCaller.first} + import ${PackageName.IActivityManagerProxyClass}.${tailPackageName(ClassName.IActivityManagerProxyClass)} + import java.lang.reflect.Proxy + """.trimIndent() + "\n\n" + createCommentContent(ClassName.IActivityManagerProxyImpl_Impl) + "\n" + """ + @${ExternalCallerName.YukiGenerateApiAnnotation.second} + object ${ClassName.IActivityManagerProxyImpl_Impl} { + + fun createWrapper(clazz: Class<*>?, instance: Any) = + Proxy.newProxyInstance(${ExternalCallerName.IActivityManagerProxyCaller.second}.currentClassLoader, arrayOf(clazz), ${tailPackageName( + ClassName.IActivityManagerProxyClass + )}(instance)) + } + """.trimIndent(), + ClassName.IActivityManagerProxyClass to """ + @file:Suppress("ClassName") + + package ${PackageName.IActivityManagerProxyClass} + + import androidx.annotation.Keep + import ${ExternalCallerName.YukiGenerateApiAnnotation.first} + import ${ExternalCallerName.IActivityManagerProxyCaller.first} + import java.lang.reflect.InvocationHandler + import java.lang.reflect.Method + import java.lang.reflect.Proxy + """.trimIndent() + "\n\n" + createCommentContent(ClassName.IActivityManagerProxyClass) + "\n" + """ + @Keep + @${ExternalCallerName.YukiGenerateApiAnnotation.second} + class ${tailPackageName(ClassName.IActivityManagerProxyClass)}(private val baseInstance: Any) : InvocationHandler { + + override fun invoke(proxy: Any?, method: Method?, args: Array?) = ${ExternalCallerName.IActivityManagerProxyCaller.second}.callInvoke(baseInstance, method, args) + } + """.trimIndent(), + ClassName.XposedInit to """ + @file:Suppress("ClassName") + + package $entryPackageName + + import androidx.annotation.Keep + import ${ExternalCallerName.YukiXposedEventCaller.first} + import ${ExternalCallerName.YukiGenerateApiAnnotation.first} + ${if (isUsingResourcesHook) "import de.robv.android.xposed.IXposedHookInitPackageResources" else ""} + import de.robv.android.xposed.IXposedHookLoadPackage + import de.robv.android.xposed.IXposedHookZygoteInit + ${if (isUsingResourcesHook) "import de.robv.android.xposed.callbacks.XC_InitPackageResources" else ""} + import de.robv.android.xposed.callbacks.XC_LoadPackage + """.trimIndent() + "\n\n" + createCommentContent("Xposed Init") + "\n" + """ + @Keep + @${ExternalCallerName.YukiGenerateApiAnnotation.second} + class $xInitClassName : IXposedHookZygoteInit, IXposedHookLoadPackage${if (isUsingResourcesHook) ", IXposedHookInitPackageResources" else ""} { + + override fun initZygote(sparam: IXposedHookZygoteInit.StartupParam?) { + ${entryClassName}_Impl.callInitZygote(sparam) + ${ExternalCallerName.YukiXposedEventCaller.second}.callInitZygote(sparam) + } + + override fun handleLoadPackage(lpparam: XC_LoadPackage.LoadPackageParam?) { + ${entryClassName}_Impl.callHandleLoadPackage(lpparam) + ${ExternalCallerName.YukiXposedEventCaller.second}.callHandleLoadPackage(lpparam) + } + """.trimIndent() + + (if (isUsingResourcesHook) + "\n" + """ + + override fun handleInitPackageResources(resparam: XC_InitPackageResources.InitPackageResourcesParam?) { + ${entryClassName}_Impl.callHandleInitPackageResources(resparam) + ${ExternalCallerName.YukiXposedEventCaller.second}.callHandleInitPackageResources(resparam) + } + } + """.trimIndent() + else "\n}"), + ClassName.XposedInit_Impl to """ + @file:Suppress("ClassName") + + package $entryPackageName + + import ${ExternalCallerName.YukiGenerateApiAnnotation.first} + import ${ExternalCallerName.YukiXposedModuleCaller.first} + import ${ExternalCallerName.YukiXposedResourcesCaller.first} + import com.highcapable.yukihookapi.hook.xposed.bridge.type.HookEntryType + import de.robv.android.xposed.IXposedHookZygoteInit + import de.robv.android.xposed.XposedBridge + import de.robv.android.xposed.callbacks.XC_InitPackageResources + import de.robv.android.xposed.callbacks.XC_LoadPackage + ${if (customMPackageName.isBlank()) "import $modulePackageName.BuildConfig" else ""} + """.trimIndent() + "\n\n" + createCommentContent("Xposed Init Impl") + "\n" + """ + @${ExternalCallerName.YukiGenerateApiAnnotation.second} + object ${entryClassName}_Impl { + + private const val modulePackageName = ${if (customMPackageName.isNotBlank()) "\"$customMPackageName\"" else "BuildConfig.APPLICATION_ID"} + private var isZygoteCalled = false + private val hookEntry = ${if (isEntryClassKindOfObject) entryClassName else "$entryClassName()"} + + private fun callOnXposedModuleLoaded( + isZygoteLoaded: Boolean = false, + lpparam: XC_LoadPackage.LoadPackageParam? = null, + resparam: XC_InitPackageResources.InitPackageResourcesParam? = null + ) { + if (isZygoteCalled.not()) runCatching { + hookEntry.onXposedEvent() + hookEntry.onInit() + if (${ExternalCallerName.YukiXposedModuleCaller.second}.isXposedCallbackSetUp) { + ${ExternalCallerName.YukiXposedModuleCaller.second}.internalLoggerE("You cannot load a hooker in \"onInit\" or \"onXposedEvent\" method! Aborted") + return + } + hookEntry.onHook() + ${ExternalCallerName.YukiXposedModuleCaller.second}.callOnFinishLoadModule() + }.onFailure { ${ExternalCallerName.YukiXposedModuleCaller.second}.internalLoggerE("YukiHookAPI try to load hook entry class failed", it) } + ${ExternalCallerName.YukiXposedModuleCaller.second}.callOnPackageLoaded( + type = when { + isZygoteLoaded -> HookEntryType.ZYGOTE + lpparam != null -> HookEntryType.PACKAGE + resparam != null -> HookEntryType.RESOURCES + else -> HookEntryType.ZYGOTE + }, + packageName = lpparam?.packageName ?: resparam?.packageName, + processName = lpparam?.processName, + appClassLoader = lpparam?.classLoader ?: runCatching { XposedBridge.BOOTCLASSLOADER }.getOrNull(), + appInfo = lpparam?.appInfo, + appResources = ${ExternalCallerName.YukiXposedResourcesCaller.second}.createYukiResourcesFromXResources(resparam?.res) + ) + } + + fun callInitZygote(sparam: IXposedHookZygoteInit.StartupParam?) { + if (sparam == null) return + runCatching { + ${ExternalCallerName.YukiXposedModuleCaller.second}.callOnStartLoadModule(modulePackageName, sparam.modulePath) + callOnXposedModuleLoaded(isZygoteLoaded = true) + isZygoteCalled = true + }.onFailure { ${ExternalCallerName.YukiXposedModuleCaller.second}.internalLoggerE("An exception occurred when YukiHookAPI loading Xposed Module", it) } + } + + fun callHandleLoadPackage(lpparam: XC_LoadPackage.LoadPackageParam?) { + if (lpparam != null && isZygoteCalled) callOnXposedModuleLoaded(lpparam = lpparam) + } + + fun callHandleInitPackageResources(resparam: XC_InitPackageResources.InitPackageResourcesParam?) { + if (resparam != null && isZygoteCalled) callOnXposedModuleLoaded(resparam = resparam) + } + } + """.trimIndent(), + ClassName.BootstrapClass to ("package ${PackageName.BootstrapReflectionClass};\n" + + "\n" + + "import static android.os.Build.VERSION.SDK_INT;\n" + + "\n" + + "import android.os.Build;\n" + + "import android.util.Log;\n" + + "\n" + + "import androidx.annotation.Keep;\n" + + "\n" + + "import java.lang.reflect.Method;\n" + + "\n" + + createCommentContent(currrentClassTag = ClassName.BootstrapClass) + + "@Keep\n" + + "public final class BootstrapClass {\n" + + "\n" + + " private static final String TAG = \"BootstrapClass\";\n" + + " private static Object sVmRuntime;\n" + + " private static Method setHiddenApiExemptions;\n" + + "\n" + + " static {\n" + + " if (SDK_INT >= Build.VERSION_CODES.P) {\n" + + " try {\n" + + " Method forName = Class.class.getDeclaredMethod(\"forName\", String.class);\n" + + " Method getDeclaredMethod = Class.class.getDeclaredMethod(\"getDeclaredMethod\", String.class, Class[].class);\n" + + " Class vmRuntimeClass = (Class) forName.invoke(null, \"dalvik.system.VMRuntime\");\n" + + " Method getRuntime = (Method) getDeclaredMethod.invoke(vmRuntimeClass, \"getRuntime\", null);\n" + + " setHiddenApiExemptions = (Method) getDeclaredMethod.invoke(vmRuntimeClass, \"setHiddenApiExemptions\", new Class[]{String[].class});\n" + + " sVmRuntime = getRuntime.invoke(null);\n" + + " } catch (Throwable e) {\n" + + " Log.w(TAG, \"reflect bootstrap failed:\", e);\n" + + " }\n" + + " }\n" + + " }\n" + + "\n" + + " public static boolean exempt(String method) {\n" + + " return exempt(new String[]{method});\n" + + " }\n" + + "\n" + + " public static boolean exempt(String... methods) {\n" + + " if (sVmRuntime == null || setHiddenApiExemptions == null) {\n" + + " return false;\n" + + " }\n" + + " try {\n" + + " setHiddenApiExemptions.invoke(sVmRuntime, new Object[]{methods});\n" + + " return true;\n" + + " } catch (Throwable e) {\n" + + " return false;\n" + + " }\n" + + " }\n" + + "\n" + + " public static boolean exemptAll() {\n" + + " return exempt(new String[]{\"L\"});\n" + + " }\n" + + "}"), + ClassName.Reflection to ("package ${PackageName.BootstrapReflectionClass};\n" + + "\n" + + "import static android.os.Build.VERSION.SDK_INT;\n" + + "import static com.highcapable.yukihookapi.thirdparty.me.weishu.reflection.BootstrapClass.exemptAll;\n" + + "\n" + + "import android.content.Context;\n" + + "import android.text.TextUtils;\n" + + "import android.util.Base64;\n" + + "\n" + + "import androidx.annotation.Keep;\n" + + "\n" + + "import java.io.File;\n" + + "import java.io.FileOutputStream;\n" + + "import java.lang.reflect.Method;\n" + + "\n" + + "import dalvik.system.DexFile;\n" + + "\n" + + createCommentContent(currrentClassTag = ClassName.Reflection) + + "@Keep\n" + + "public class Reflection {\n" + + "\n" + + " private static final String TAG = \"Reflection\";\n" + + " private static final String DEX = \"ZGV4CjAzNQCXDT0vQ44GJqsrjm32y0qlQmxUevbk56r0CwAAcAAAAHhWNBIAAAAAAAAAADwLAABDAAAAcAAAABMAAAB8AQAACwAAAMgBAAAMAAAATAIAAA8AAACsAgAAAwAAACQDAABwCAAAhAMAAIQDAACGAwAAiwMAAJUDAACdAwAArQMAALkDAADJAwAA3gMAAPADAAD3AwAA/wMAAAIEAAAGBAAACgQAABAEAAATBAAAGAQAADMEAABZBAAAdQQAAIkEAADYBAAAJgUAAHAFAACDBQAAmQUAAK0FAADBBQAA1QUAAOwFAAAIBgAAFAYAACUGAAAuBgAAMwYAADYGAABEBgAAUgYAAFYGAABZBgAAXQYAAHEGAACGBgAAmwYAAKQGAAC9BgAAwAYAAMgGAADTBgAA3AYAAO0GAAABBwAAFAcAACAHAAAoBwAANQcAAE8HAABXBwAAYAcAAHsHAACEBwAAkAcAAKgHAAC6BwAAwgcAANAHAAALAAAAEQAAABIAAAATAAAAFAAAABUAAAAWAAAAFwAAABgAAAAaAAAAGwAAABwAAAAdAAAAHgAAACMAAAAnAAAAKQAAACoAAAArAAAADAAAAAAAAAD4BwAADQAAAAAAAAAMCAAADgAAAAAAAAAACAAADwAAAAIAAAAAAAAAEAAAAAkAAAAUCAAAEAAAAA0AAADoBwAAIwAAAA4AAAAAAAAAJgAAAA4AAADgBwAAJwAAAA8AAAAAAAAAKAAAAA8AAADgBwAAKAAAAA8AAADwBwAAAgAAAD8AAAADAAAAIQAAAAUACgAEAAAABQAKAAUAAAAFAA8ACQAAAAUACgAKAAAABQAAACQAAAAFAAoAJQAAAAYACgAiAAAABgAJAD0AAAAGAA0APgAAAAcACgAiAAAAAQADADMAAAAEAAIALgAAAAUABgADAAAABgAGAAIAAAAGAAYAAwAAAAYACQAvAAAABgAKAC8AAAAGAAgAMAAAAAcABgADAAAABwABAEAAAAAHAAAAQQAAAAgABQA0AAAACQAGAAMAAAALAAcANwAAAA0ABAA2AAAABQAAABEAAAAJAAAAAAAAAAgAAAAAAAAA7AoAAB8IAAAGAAAAEQAAAAkAAAAAAAAABwAAAAAAAAACCwAAHAgAAAcAAAABAAAACQAAAAAAAAAgAAAAAAAAACULAAArCAAAAAADMS4wAAg8Y2xpbml0PgAGPGluaXQ+AA5BUFBMSUNBVElPTl9JRAAKQlVJTERfVFlQRQAOQm9vdHN0cmFwQ2xhc3MAE0Jvb3RzdHJhcENsYXNzLmphdmEAEEJ1aWxkQ29uZmlnLmphdmEABURFQlVHAAZGTEFWT1IAAUkAAklJAAJJTAAESUxMTAABTAADTExMABlMYW5kcm9pZC9jb250ZW50L0NvbnRleHQ7ACRMYW5kcm9pZC9jb250ZW50L3BtL0FwcGxpY2F0aW9uSW5mbzsAGkxhbmRyb2lkL29zL0J1aWxkJFZFUlNJT047ABJMYW5kcm9pZC91dGlsL0xvZzsATUxjb20vaGlnaGNhcGFibGUveXVraWhvb2thcGkvdGhpcmRwYXJ0eS9tZS93ZWlzaHUvZnJlZXJlZmxlY3Rpb24vQnVpbGRDb25maWc7AExMY29tL2hpZ2hjYXBhYmxlL3l1a2lob29rYXBpL3RoaXJkcGFydHkvbWUvd2Vpc2h1L3JlZmxlY3Rpb24vQm9vdHN0cmFwQ2xhc3M7AEhMY29tL2hpZ2hjYXBhYmxlL3l1a2lob29rYXBpL3RoaXJkcGFydHkvbWUvd2Vpc2h1L3JlZmxlY3Rpb24vUmVmbGVjdGlvbjsAEUxqYXZhL2xhbmcvQ2xhc3M7ABRMamF2YS9sYW5nL0NsYXNzPCo+OwASTGphdmEvbGFuZy9PYmplY3Q7ABJMamF2YS9sYW5nL1N0cmluZzsAEkxqYXZhL2xhbmcvU3lzdGVtOwAVTGphdmEvbGFuZy9UaHJvd2FibGU7ABpMamF2YS9sYW5nL3JlZmxlY3QvTWV0aG9kOwAKUmVmbGVjdGlvbgAPUmVmbGVjdGlvbi5qYXZhAAdTREtfSU5UAANUQUcAAVYADFZFUlNJT05fQ09ERQAMVkVSU0lPTl9OQU1FAAJWTAABWgACWkwAEltMamF2YS9sYW5nL0NsYXNzOwATW0xqYXZhL2xhbmcvT2JqZWN0OwATW0xqYXZhL2xhbmcvU3RyaW5nOwAHY29udGV4dAAXZGFsdmlrLnN5c3RlbS5WTVJ1bnRpbWUAAWUABmV4ZW1wdAAJZXhlbXB0QWxsAAdmb3JOYW1lAA9mcmVlLXJlZmxlY3Rpb24AEmdldEFwcGxpY2F0aW9uSW5mbwARZ2V0RGVjbGFyZWRNZXRob2QACmdldFJ1bnRpbWUABmludm9rZQALbG9hZExpYnJhcnkAGG1lLndlaXNodS5mcmVlcmVmbGVjdGlvbgAGbWV0aG9kAAdtZXRob2RzABlyZWZsZWN0IGJvb3RzdHJhcCBmYWlsZWQ6AAdyZWxlYXNlAApzVm1SdW50aW1lABZzZXRIaWRkZW5BcGlFeGVtcHRpb25zABB0YXJnZXRTZGtWZXJzaW9uAAZ1bnNlYWwADHVuc2VhbE5hdGl2ZQAOdm1SdW50aW1lQ2xhc3MAAQAAAAoAAAACAAAACgAQAAEAAAASAAAAAQAAAAAAAAADAAAACgAKAAwAAAABAAAAAQAAAAIAAAAJABEAARcGBhc4FzwfFwAEARcBARcfAAAAAAAABgAHDgAWAAcOav8DATIOARUQAwI1DvAEBEMJGgESDwMDNg4BGw+pBQIFAwUEGR4DAC8NAA4ABw4ALAE6Bw4ANgE7ByydGuIBAQMALw0eAEgABw4ADQAHDgATAS0HHXIZa1oAAAEAAQABAAAANAgAAAQAAABwEAwAAAAOAAoAAAADAAEAOQgAAHsAAABgBQEAEwYcADRlbQAcBQgAGgYxABIXI3cQABIIHAkKAE0JBwhuMAsAZQcMARwFCAAaBjQAEicjdxAAEggcCQoATQkHCBIYHAkQAE0JBwhuMAsAZQcMAhIFEhYjZhEAEgcaCC0ATQgGB24wDgBRBgwEHwQIABIlI1URABIGGgc1AE0HBQYSFhIHTQcFBm4wDgBCBQwDHwMNABIlI1URABIGGgc+AE0HBQYSFhIXI3cQABIIHAkSAE0JBwhNBwUGbjAOAEIFDAUfBQ0AaQUKABIFEgYjZhEAbjAOAFMGDAVpBQkADgANABoFBgAaBjsAcTABAGUAKPcAAAYAAABrAAEAAQEMcgEAAQABAAAAaAgAAAQAAABwEAwAAAAOAAMAAQABAAAAbQgAAAsAAAASECMAEgASAU0CAAFxEAYAAAAKAA8AAAAIAAEAAwABAHMIAAAdAAAAEhESAmIDCQA4AwYAYgMKADkDBAABIQ8BYgMKAGIECQASFSNVEQASBk0HBQZuMA4AQwUo8g0AASEo7wAADAAAAA0AAQABAQwaAwAAAAEAAACDCAAADQAAABIQIwASABIBGgIPAE0CAAFxEAYAAAAKAA8AAAABAAEAAQAAAIgIAAAEAAAAcBAMAAAADgAEAAEAAQAAAI0IAAAeAAAAEgBgAQEAEwIcADUhAwAPAHEABwAAAAoBOQH7/xoAMgBxEA0AAABuEAAAAwAMAFIAAABxEAoAAAAKACjqBgABAAIZARkBGQEZARkBGQKBgASYEQMABQAIGgEKAQoDiIAEsBEBgYAExBMBCdwTAYkBhBQBCdwUAQADAAsaCIGABIgVAQmgFQGKAgAAAAAPAAAAAAAAAAEAAAAAAAAAAQAAAEMAAABwAAAAAgAAABMAAAB8AQAAAwAAAAsAAADIAQAABAAAAAwAAABMAgAABQAAAA8AAACsAgAABgAAAAMAAAAkAwAAAiAAAEMAAACEAwAAARAAAAcAAADgBwAABSAAAAMAAAAcCAAAAxAAAAEAAAAwCAAAAyAAAAgAAAA0CAAAASAAAAgAAACYCAAAACAAAAMAAADsCgAAABAAAAEAAAA8CwAA\";\n" + + "\n" + + " private static native int unsealNative(int targetSdkVersion);\n" + + "\n" + + " public static int unseal(Context context) {\n" + + " if (SDK_INT < 28) {\n" + + " // Below Android P, ignore\n" + + " return 0;\n" + + " }\n" + + " // try exempt API first.\n" + + " if (exemptAll()) {\n" + + " return 0;\n" + + " }\n" + + " if (unsealByDexFile(context)) {\n" + + " return 0;\n" + + " }\n" + + " return -1;\n" + + " }\n" + + "\n" + + " @SuppressWarnings({\"deprecation\", \"ResultOfMethodCallIgnored\"})\n" + + " private static boolean unsealByDexFile(Context context) {\n" + + " byte[] bytes = Base64.decode(DEX, Base64.NO_WRAP);\n" + + " File codeCacheDir = getCodeCacheDir(context);\n" + + " if (codeCacheDir == null) {\n" + + " return false;\n" + + " }\n" + + " File code = new File(codeCacheDir, \"__temp_\" + System.currentTimeMillis() + \".dex\");\n" + + " try {\n" + + " try (FileOutputStream fos = new FileOutputStream(code)) {\n" + + " fos.write(bytes);\n" + + " }\n" + + " DexFile dexFile = new DexFile(code);\n" + + " // This class is hardcoded in the dex, Don't use BootstrapClass.class to reference it\n" + + " // it maybe obfuscated!!\n" + + " Class bootstrapClass = dexFile.loadClass(\"com.highcapable.yukihookapi.thirdparty.me.weishu.reflection.BootstrapClass\", null);\n" + + " Method exemptAll = bootstrapClass.getDeclaredMethod(\"exemptAll\");\n" + + " return (boolean) exemptAll.invoke(null);\n" + + " } catch (Throwable e) {\n" + + " e.printStackTrace();\n" + + " return false;\n" + + " } finally {\n" + + " if (code.exists()) {\n" + + " code.delete();\n" + + " }\n" + + " }\n" + + " }\n" + + "\n" + + " private static File getCodeCacheDir(Context context) {\n" + + " if (context != null) {\n" + + " return context.getCodeCacheDir();\n" + + " }\n" + + " String tmpDir = System.getProperty(\"java.io.tmpdir\");\n" + + " if (TextUtils.isEmpty(tmpDir)) {\n" + + " return null;\n" + + " }\n" + + " File tmp = new File(tmpDir);\n" + + " if (!tmp.exists()) {\n" + + " return null;\n" + + " }\n" + + " return tmp;\n" + + " }\n" + + "}") +) \ No newline at end of file diff --git a/yukihookapi-ksp-xposed/src/api/kotlin/com/highcapable/yukihookapi_ksp_xposed/factory/CodeSourceFileFactory.kt b/yukihookapi-ksp-xposed/src/api/kotlin/com/highcapable/yukihookapi_ksp_xposed/factory/CodeSourceFileFactory.kt deleted file mode 100644 index cb4670b0..00000000 --- a/yukihookapi-ksp-xposed/src/api/kotlin/com/highcapable/yukihookapi_ksp_xposed/factory/CodeSourceFileFactory.kt +++ /dev/null @@ -1,525 +0,0 @@ -/* - * YukiHookAPI - An efficient Hook API and Xposed Module solution built in Kotlin. - * Copyright (C) 2019-2023 HighCapable - * https://github.com/fankes/YukiHookAPI - * - * MIT License - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - * This file is Created by fankes on 2022/9/20. - */ -package com.highcapable.yukihookapi_ksp_xposed.factory - -import com.highcapable.yukihookapi_ksp_xposed.bean.GenerateData -import java.text.SimpleDateFormat -import java.util.* - -/** - * 包名常量定义类 - */ -object PackageName { - const val YukiHookAPI_Impl = "com.highcapable.yukihookapi" - const val ModuleApplication_Impl = "com.highcapable.yukihookapi.hook.xposed.application" - const val YukiXposedModuleStatus_Impl = "com.highcapable.yukihookapi.hook.xposed.bridge.status" - const val HandlerDelegateImpl_Impl = "com.highcapable.yukihookapi.hook.xposed.parasitic.activity.delegate.impl" - const val HandlerDelegateClass = "com.highcapable.yukihookapi.hook.xposed.parasitic.activity.delegate" - const val IActivityManagerProxyImpl_Impl = "com.highcapable.yukihookapi.hook.xposed.parasitic.activity.delegate.impl" - const val IActivityManagerProxyClass = "com.highcapable.yukihookapi.hook.xposed.parasitic.activity.delegate" - const val BootstrapReflectionClass = "com.highcapable.yukihookapi.thirdparty.me.weishu.reflection" -} - -/** - * 类名常量定义类 - */ -object ClassName { - const val YukiHookAPI_Impl = "YukiHookAPI_Impl" - const val ModuleApplication_Impl = "ModuleApplication_Impl" - const val YukiXposedModuleStatus_Impl = "YukiXposedModuleStatus_Impl" - const val HandlerDelegateImpl_Impl = "HandlerDelegateImpl_Impl" - const val HandlerDelegateClass = "HandlerDelegate" - const val IActivityManagerProxyImpl_Impl = "IActivityManagerProxyImpl_Impl" - const val IActivityManagerProxyClass = "IActivityManagerProxy" - const val XposedInit = "xposed_init" - const val XposedInit_Impl = "xposed_init_Impl" - const val BootstrapClass = "BootstrapClass" - const val Reflection = "Reflection" -} - -/** - * 外部调用者包名和类名定义类 - */ -object ExternalCallerName { - val YukiGenerateApiAnnotation = Pair( - "com.highcapable.yukihookapi.annotation.YukiGenerateApi", - "YukiGenerateApi" - ) - val HandlerDelegateCaller = Pair( - "com.highcapable.yukihookapi.hook.xposed.parasitic.activity.delegate.caller.HandlerDelegateCaller", - "HandlerDelegateCaller" - ) - val IActivityManagerProxyCaller = Pair( - "com.highcapable.yukihookapi.hook.xposed.parasitic.activity.delegate.caller.IActivityManagerProxyCaller", - "IActivityManagerProxyCaller" - ) - val YukiXposedEventCaller = Pair( - "com.highcapable.yukihookapi.hook.xposed.bridge.event.caller.YukiXposedEventCaller", - "YukiXposedEventCaller" - ) - val YukiXposedModuleCaller = Pair( - "com.highcapable.yukihookapi.hook.xposed.bridge.caller.YukiXposedModuleCaller", - "YukiXposedModuleCaller" - ) - val YukiXposedResourcesCaller = Pair( - "com.highcapable.yukihookapi.hook.xposed.bridge.resources.caller.YukiXposedResourcesCaller", - "YukiXposedResourcesCaller" - ) -} - -/** - * YukiXposedModuleStatus 方法名称定义类 - */ -object YukiXposedModuleStatusJvmName { - const val IS_ACTIVE_METHOD_NAME = "__--" - const val IS_SUPPORT_RESOURCES_HOOK_METHOD_NAME = "_--_" - const val GET_EXECUTOR_NAME_METHOD_NAME = "_-_-" - const val GET_EXECUTOR_API_LEVEL_METHOD_NAME = "-__-" - const val GET_EXECUTOR_VERSION_NAME_METHOD_NAME = "-_-_" - const val GET_EXECUTOR_VERSION_CODE_METHOD_NAME = "___-" -} - -/** - * 创建尾部包名名称 - * @param name 前置名称 - * @return [String] - */ -private fun GenerateData.tailPackageName(name: String) = "${name}_${modulePackageName.replace(".", "_")}" - -/** - * 创建文件注释 - * @param entryClassName 入口类名 - 空则不生成 - * @param currrentClassTag 当前注入类标签 - * @return [String] - */ -private fun createCommentContent(entryClassName: String = "", currrentClassTag: String) = - ("/**\n" + - " * $currrentClassTag Class\n" + - " *\n" + - " * Compiled from YukiHookXposedProcessor\n" + - " *\n" + - (if (entryClassName.isNotBlank()) " * Hook entry class: [$entryClassName]\n *\n" else "") + - " * Generate Date: ${SimpleDateFormat.getDateTimeInstance().format(Date())}\n" + - " *\n" + - " * Powered by YukiHookAPI (C) HighCapable 2019-2023\n" + - " *\n" + - " * Project Address: [YukiHookAPI](https://github.com/fankes/YukiHookAPI)\n" + - " */\n") - -/** - * 获得注入文件代码内容 - * @return [Map]<[String],[String]> - */ -fun GenerateData.sources() = mapOf( - ClassName.YukiHookAPI_Impl to ("@file:Suppress(\"ClassName\")\n" + - "\n" + - "package ${PackageName.YukiHookAPI_Impl}\n" + - "\n" + - createCommentContent(currrentClassTag = ClassName.YukiHookAPI_Impl) + - "object ${ClassName.YukiHookAPI_Impl} {\n" + - "\n" + - " val compiledTimestamp get() = ${System.currentTimeMillis()}\n" + - "}"), - ClassName.ModuleApplication_Impl to ("@file:Suppress(\"ClassName\")\n" + - "\n" + - "package ${PackageName.ModuleApplication_Impl}\n" + - "\n" + - "import $entryPackageName.$entryClassName\n" + - "\n" + - createCommentContent(entryClassName, ClassName.ModuleApplication_Impl) + - "object ${ClassName.ModuleApplication_Impl} {\n" + - "\n" + - " fun callHookEntryInit() = try {\n" + - " " + (if (isEntryClassKindOfObject) "$entryClassName.onInit()\n" else "$entryClassName().onInit()\n") + - " } catch (_: Throwable) {\n" + - " }\n" + - "}"), - ClassName.YukiXposedModuleStatus_Impl to ("@file:Suppress(\"ClassName\")\n" + - "\n" + - "package ${PackageName.YukiXposedModuleStatus_Impl}\n" + - "\n" + - "import android.util.Log\n" + - "import androidx.annotation.Keep\n" + - "\n" + - createCommentContent(currrentClassTag = ClassName.YukiXposedModuleStatus_Impl) + - "@Keep\n" + - "object ${ClassName.YukiXposedModuleStatus_Impl} {\n" + - "\n" + - " @JvmName(\"${YukiXposedModuleStatusJvmName.IS_ACTIVE_METHOD_NAME}\")\n" + - " fun isActive(): Boolean {\n" + - " placeholderExecution()\n" + - " return false\n" + - " }\n" + - "\n" + - " @JvmName(\"${YukiXposedModuleStatusJvmName.IS_SUPPORT_RESOURCES_HOOK_METHOD_NAME}\")\n" + - " fun isSupportResourcesHook(): Boolean {\n" + - " placeholderExecution()\n" + - " return false\n" + - " }\n" + - "\n" + - " @JvmName(\"${YukiXposedModuleStatusJvmName.GET_EXECUTOR_NAME_METHOD_NAME}\")\n" + - " fun getExecutorName(): String {\n" + - " placeholderExecution()\n" + - " return \"unknown\"\n" + - " }\n" + - "\n" + - " @JvmName(\"${YukiXposedModuleStatusJvmName.GET_EXECUTOR_API_LEVEL_METHOD_NAME}\")\n" + - " fun getExecutorApiLevel(): Int {\n" + - " placeholderExecution()\n" + - " return -1\n" + - " }\n" + - "\n" + - " @JvmName(\"${YukiXposedModuleStatusJvmName.GET_EXECUTOR_VERSION_NAME_METHOD_NAME}\")\n" + - " fun getExecutorVersionName(): String {\n" + - " placeholderExecution()\n" + - " return \"unknown\"\n" + - " }\n" + - "\n" + - " @JvmName(\"${YukiXposedModuleStatusJvmName.GET_EXECUTOR_VERSION_CODE_METHOD_NAME}\")\n" + - " fun getExecutorVersionCode(): Int {\n" + - " placeholderExecution()\n" + - " return -1\n" + - " }\n" + - "\n" + - " private fun placeholderExecution() {\n" + - " /** Consume a long method body */\n" + - " if (System.currentTimeMillis() == 0L) Log.d(\"${(1000..9999).random()}\", \"${(100000..999999).random()}\")\n" + - " }\n" + - "}"), - ClassName.HandlerDelegateImpl_Impl to ("@file:Suppress(\"ClassName\")\n" + - "\n" + - "package ${PackageName.HandlerDelegateImpl_Impl}\n" + - "\n" + - "import android.os.Handler\n" + - "import ${ExternalCallerName.YukiGenerateApiAnnotation.first}\n" + - "import ${PackageName.HandlerDelegateClass}.${tailPackageName(ClassName.HandlerDelegateClass)}\n" + - "\n" + - createCommentContent(currrentClassTag = ClassName.HandlerDelegateImpl_Impl) + - "@${ExternalCallerName.YukiGenerateApiAnnotation.second}\n" + - "object ${ClassName.HandlerDelegateImpl_Impl} {\n" + - "\n" + - " val wrapperClassName get() = \"${PackageName.HandlerDelegateClass}.${tailPackageName(ClassName.HandlerDelegateClass)}\"\n" + - "\n" + - " fun createWrapper(baseInstance: Handler.Callback? = null): Handler.Callback = ${tailPackageName(ClassName.HandlerDelegateClass)}(baseInstance)\n" + - "}"), - ClassName.HandlerDelegateClass to ("@file:Suppress(\"ClassName\")\n" + - "\n" + - "package ${PackageName.HandlerDelegateClass}\n" + - "\n" + - "import android.os.Handler\n" + - "import android.os.Message\n" + - "import androidx.annotation.Keep\n" + - "import ${ExternalCallerName.YukiGenerateApiAnnotation.first}\n" + - "import ${ExternalCallerName.HandlerDelegateCaller.first}\n" + - "\n" + - createCommentContent(currrentClassTag = ClassName.HandlerDelegateClass) + - "@Keep\n" + - "@${ExternalCallerName.YukiGenerateApiAnnotation.second}\n" + - "class ${tailPackageName(ClassName.HandlerDelegateClass)}(private val baseInstance: Handler.Callback?) : Handler.Callback {\n" + - "\n" + - " override fun handleMessage(msg: Message) = ${ExternalCallerName.HandlerDelegateCaller.second}.callHandleMessage(baseInstance, msg)\n" + - "}"), - ClassName.IActivityManagerProxyImpl_Impl to ("@file:Suppress(\"ClassName\")\n" + - "\n" + - "package ${PackageName.IActivityManagerProxyImpl_Impl}\n" + - "\n" + - "import android.os.Handler\n" + - "import ${ExternalCallerName.YukiGenerateApiAnnotation.first}\n" + - "import ${ExternalCallerName.IActivityManagerProxyCaller.first}\n" + - "import ${PackageName.IActivityManagerProxyClass}.${tailPackageName(ClassName.IActivityManagerProxyClass)}\n" + - "import java.lang.reflect.Proxy\n" + - "\n" + - createCommentContent(currrentClassTag = ClassName.IActivityManagerProxyImpl_Impl) + - "@${ExternalCallerName.YukiGenerateApiAnnotation.second}\n" + - "object ${ClassName.IActivityManagerProxyImpl_Impl} {\n" + - "\n" + - " fun createWrapper(clazz: Class<*>?, instance: Any) = \n" + - " Proxy.newProxyInstance(${ExternalCallerName.IActivityManagerProxyCaller.second}.currentClassLoader, arrayOf(clazz)," + - " ${tailPackageName(ClassName.IActivityManagerProxyClass)}(instance))\n" + - "}"), - ClassName.IActivityManagerProxyClass to ("@file:Suppress(\"ClassName\")\n" + - "\n" + - "package ${PackageName.IActivityManagerProxyClass}\n" + - "\n" + - "import androidx.annotation.Keep\n" + - "import ${ExternalCallerName.YukiGenerateApiAnnotation.first}\n" + - "import ${ExternalCallerName.IActivityManagerProxyCaller.first}\n" + - "import java.lang.reflect.InvocationHandler\n" + - "import java.lang.reflect.Method\n" + - "import java.lang.reflect.Proxy\n" + - "\n" + - createCommentContent(currrentClassTag = ClassName.IActivityManagerProxyClass) + - "@Keep\n" + - "@${ExternalCallerName.YukiGenerateApiAnnotation.second}\n" + - "class ${tailPackageName(ClassName.IActivityManagerProxyClass)}(private val baseInstance: Any) : InvocationHandler {\n" + - "\n" + - " override fun invoke(proxy: Any?, method: Method?, args: Array?) = ${ExternalCallerName.IActivityManagerProxyCaller.second}.callInvoke(baseInstance, method, args)\n" + - "}"), - ClassName.XposedInit to ("@file:Suppress(\"ClassName\")\n" + - "\n" + - "package $entryPackageName\n" + - "\n" + - "import androidx.annotation.Keep\n" + - "import ${ExternalCallerName.YukiXposedEventCaller.first}\n" + - "import ${ExternalCallerName.YukiGenerateApiAnnotation.first}\n" + - (if (isUsingResourcesHook) "import de.robv.android.xposed.IXposedHookInitPackageResources\n" else "") + - "import de.robv.android.xposed.IXposedHookLoadPackage\n" + - "import de.robv.android.xposed.IXposedHookZygoteInit\n" + - (if (isUsingResourcesHook) "import de.robv.android.xposed.callbacks.XC_InitPackageResources\n" else "") + - "import de.robv.android.xposed.callbacks.XC_LoadPackage\n" + - "\n" + - createCommentContent(entryClassName, currrentClassTag = "Xposed Init") + - "@Keep\n" + - "@${ExternalCallerName.YukiGenerateApiAnnotation.second}\n" + - "class $xInitClassName : IXposedHookZygoteInit, IXposedHookLoadPackage" + - "${if (isUsingResourcesHook) ", IXposedHookInitPackageResources" else ""} {\n" + - "\n" + - " override fun initZygote(sparam: IXposedHookZygoteInit.StartupParam?) {\n" + - " ${entryClassName}_Impl.callInitZygote(sparam)\n" + - " ${ExternalCallerName.YukiXposedEventCaller.second}.callInitZygote(sparam)\n" + - " }\n" + - "\n" + - " override fun handleLoadPackage(lpparam: XC_LoadPackage.LoadPackageParam?) {\n" + - " ${entryClassName}_Impl.callHandleLoadPackage(lpparam)\n" + - " ${ExternalCallerName.YukiXposedEventCaller.second}.callHandleLoadPackage(lpparam)\n" + - " }\n" + - (if (isUsingResourcesHook) - ("\n override fun handleInitPackageResources(resparam: XC_InitPackageResources.InitPackageResourcesParam?) {\n" + - " ${entryClassName}_Impl.callHandleInitPackageResources(resparam)\n" + - " ${ExternalCallerName.YukiXposedEventCaller.second}.callHandleInitPackageResources(resparam)\n" + - " }\n") else "") + - "}"), - ClassName.XposedInit_Impl to ("@file:Suppress(\"ClassName\")\n" + - "\n" + - "package $entryPackageName\n" + - "\n" + - "import ${ExternalCallerName.YukiGenerateApiAnnotation.first}\n" + - "import ${ExternalCallerName.YukiXposedModuleCaller.first}\n" + - "import ${ExternalCallerName.YukiXposedResourcesCaller.first}\n" + - "import com.highcapable.yukihookapi.hook.xposed.bridge.type.HookEntryType\n" + - "import de.robv.android.xposed.IXposedHookZygoteInit\n" + - "import de.robv.android.xposed.XposedBridge\n" + - "import de.robv.android.xposed.callbacks.XC_InitPackageResources\n" + - "import de.robv.android.xposed.callbacks.XC_LoadPackage\n" + - (if (customMPackageName.isBlank()) "import $modulePackageName.BuildConfig\n" else "") + - "\n" + - createCommentContent(entryClassName, currrentClassTag = "Xposed Init Impl") + - "@${ExternalCallerName.YukiGenerateApiAnnotation.second}\n" + - "object ${entryClassName}_Impl {\n" + - "\n" + - " private const val modulePackageName = " + - (if (customMPackageName.isNotBlank()) "\"$customMPackageName\"" else "BuildConfig.APPLICATION_ID") + "\n" + - " private var isZygoteCalled = false\n" + - " private val hookEntry = " + (if (isEntryClassKindOfObject) "$entryClassName\n" else "$entryClassName()\n") + - "\n" + - " private fun callOnXposedModuleLoaded(\n" + - " isZygoteLoaded: Boolean = false,\n" + - " lpparam: XC_LoadPackage.LoadPackageParam? = null,\n" + - " resparam: XC_InitPackageResources.InitPackageResourcesParam? = null\n" + - " ) {\n" + - " if (isZygoteCalled.not()) runCatching {\n" + - " hookEntry.onXposedEvent()\n" + - " hookEntry.onInit()\n" + - " if (${ExternalCallerName.YukiXposedModuleCaller.second}.isXposedCallbackSetUp) {\n" + - " ${ExternalCallerName.YukiXposedModuleCaller.second}.internalLoggerE(\"You cannot load a hooker in \\\"onInit\\\" or \\\"onXposedEvent\\\" method! Aborted\")\n" + - " return\n" + - " }\n" + - " hookEntry.onHook()\n" + - " ${ExternalCallerName.YukiXposedModuleCaller.second}.callOnFinishLoadModule()\n" + - " }.onFailure { ${ExternalCallerName.YukiXposedModuleCaller.second}.internalLoggerE(\"YukiHookAPI try to load hook entry class failed\", it) }\n" + - " ${ExternalCallerName.YukiXposedModuleCaller.second}.callOnPackageLoaded(\n" + - " type = when {\n" + - " isZygoteLoaded -> HookEntryType.ZYGOTE\n" + - " lpparam != null -> HookEntryType.PACKAGE\n" + - " resparam != null -> HookEntryType.RESOURCES\n" + - " else -> HookEntryType.ZYGOTE\n" + - " },\n" + - " packageName = lpparam?.packageName ?: resparam?.packageName,\n" + - " processName = lpparam?.processName,\n" + - " appClassLoader = lpparam?.classLoader ?: runCatching { XposedBridge.BOOTCLASSLOADER }.getOrNull(),\n" + - " appInfo = lpparam?.appInfo,\n" + - " appResources = ${ExternalCallerName.YukiXposedResourcesCaller.second}.createYukiResourcesFromXResources(resparam?.res)\n" + - " )\n" + - " }\n" + - "\n" + - " fun callInitZygote(sparam: IXposedHookZygoteInit.StartupParam?) {\n" + - " if (sparam == null) return\n" + - " runCatching {\n" + - " ${ExternalCallerName.YukiXposedModuleCaller.second}.callOnStartLoadModule(modulePackageName, sparam.modulePath)\n" + - " callOnXposedModuleLoaded(isZygoteLoaded = true)\n" + - " isZygoteCalled = true\n" + - " }.onFailure { ${ExternalCallerName.YukiXposedModuleCaller.second}.internalLoggerE(\"An exception occurred when YukiHookAPI loading Xposed Module\", it) }\n" + - " }\n" + - "\n" + - " fun callHandleLoadPackage(lpparam: XC_LoadPackage.LoadPackageParam?) {\n" + - " if (lpparam != null && isZygoteCalled) callOnXposedModuleLoaded(lpparam = lpparam)\n" + - " }\n" + - "\n" + - " fun callHandleInitPackageResources(resparam: XC_InitPackageResources.InitPackageResourcesParam?) {\n" + - " if (resparam != null && isZygoteCalled) callOnXposedModuleLoaded(resparam = resparam)\n" + - " }\n" + - "}"), - ClassName.BootstrapClass to ("package ${PackageName.BootstrapReflectionClass};\n" + - "\n" + - "import static android.os.Build.VERSION.SDK_INT;\n" + - "\n" + - "import android.os.Build;\n" + - "import android.util.Log;\n" + - "\n" + - "import androidx.annotation.Keep;\n" + - "\n" + - "import java.lang.reflect.Method;\n" + - "\n" + - createCommentContent(currrentClassTag = ClassName.BootstrapClass) + - "@Keep\n" + - "public final class BootstrapClass {\n" + - "\n" + - " private static final String TAG = \"BootstrapClass\";\n" + - " private static Object sVmRuntime;\n" + - " private static Method setHiddenApiExemptions;\n" + - "\n" + - " static {\n" + - " if (SDK_INT >= Build.VERSION_CODES.P) {\n" + - " try {\n" + - " Method forName = Class.class.getDeclaredMethod(\"forName\", String.class);\n" + - " Method getDeclaredMethod = Class.class.getDeclaredMethod(\"getDeclaredMethod\", String.class, Class[].class);\n" + - " Class vmRuntimeClass = (Class) forName.invoke(null, \"dalvik.system.VMRuntime\");\n" + - " Method getRuntime = (Method) getDeclaredMethod.invoke(vmRuntimeClass, \"getRuntime\", null);\n" + - " setHiddenApiExemptions = (Method) getDeclaredMethod.invoke(vmRuntimeClass, \"setHiddenApiExemptions\", new Class[]{String[].class});\n" + - " sVmRuntime = getRuntime.invoke(null);\n" + - " } catch (Throwable e) {\n" + - " Log.w(TAG, \"reflect bootstrap failed:\", e);\n" + - " }\n" + - " }\n" + - " }\n" + - "\n" + - " public static boolean exempt(String method) {\n" + - " return exempt(new String[]{method});\n" + - " }\n" + - "\n" + - " public static boolean exempt(String... methods) {\n" + - " if (sVmRuntime == null || setHiddenApiExemptions == null) {\n" + - " return false;\n" + - " }\n" + - " try {\n" + - " setHiddenApiExemptions.invoke(sVmRuntime, new Object[]{methods});\n" + - " return true;\n" + - " } catch (Throwable e) {\n" + - " return false;\n" + - " }\n" + - " }\n" + - "\n" + - " public static boolean exemptAll() {\n" + - " return exempt(new String[]{\"L\"});\n" + - " }\n" + - "}"), - ClassName.Reflection to ("package ${PackageName.BootstrapReflectionClass};\n" + - "\n" + - "import static android.os.Build.VERSION.SDK_INT;\n" + - "import static com.highcapable.yukihookapi.thirdparty.me.weishu.reflection.BootstrapClass.exemptAll;\n" + - "\n" + - "import android.content.Context;\n" + - "import android.text.TextUtils;\n" + - "import android.util.Base64;\n" + - "\n" + - "import androidx.annotation.Keep;\n" + - "\n" + - "import java.io.File;\n" + - "import java.io.FileOutputStream;\n" + - "import java.lang.reflect.Method;\n" + - "\n" + - "import dalvik.system.DexFile;\n" + - "\n" + - createCommentContent(currrentClassTag = ClassName.Reflection) + - "@Keep\n" + - "public class Reflection {\n" + - "\n" + - " private static final String TAG = \"Reflection\";\n" + - " private static final String DEX = \"ZGV4CjAzNQCXDT0vQ44GJqsrjm32y0qlQmxUevbk56r0CwAAcAAAAHhWNBIAAAAAAAAAADwLAABDAAAAcAAAABMAAAB8AQAACwAAAMgBAAAMAAAATAIAAA8AAACsAgAAAwAAACQDAABwCAAAhAMAAIQDAACGAwAAiwMAAJUDAACdAwAArQMAALkDAADJAwAA3gMAAPADAAD3AwAA/wMAAAIEAAAGBAAACgQAABAEAAATBAAAGAQAADMEAABZBAAAdQQAAIkEAADYBAAAJgUAAHAFAACDBQAAmQUAAK0FAADBBQAA1QUAAOwFAAAIBgAAFAYAACUGAAAuBgAAMwYAADYGAABEBgAAUgYAAFYGAABZBgAAXQYAAHEGAACGBgAAmwYAAKQGAAC9BgAAwAYAAMgGAADTBgAA3AYAAO0GAAABBwAAFAcAACAHAAAoBwAANQcAAE8HAABXBwAAYAcAAHsHAACEBwAAkAcAAKgHAAC6BwAAwgcAANAHAAALAAAAEQAAABIAAAATAAAAFAAAABUAAAAWAAAAFwAAABgAAAAaAAAAGwAAABwAAAAdAAAAHgAAACMAAAAnAAAAKQAAACoAAAArAAAADAAAAAAAAAD4BwAADQAAAAAAAAAMCAAADgAAAAAAAAAACAAADwAAAAIAAAAAAAAAEAAAAAkAAAAUCAAAEAAAAA0AAADoBwAAIwAAAA4AAAAAAAAAJgAAAA4AAADgBwAAJwAAAA8AAAAAAAAAKAAAAA8AAADgBwAAKAAAAA8AAADwBwAAAgAAAD8AAAADAAAAIQAAAAUACgAEAAAABQAKAAUAAAAFAA8ACQAAAAUACgAKAAAABQAAACQAAAAFAAoAJQAAAAYACgAiAAAABgAJAD0AAAAGAA0APgAAAAcACgAiAAAAAQADADMAAAAEAAIALgAAAAUABgADAAAABgAGAAIAAAAGAAYAAwAAAAYACQAvAAAABgAKAC8AAAAGAAgAMAAAAAcABgADAAAABwABAEAAAAAHAAAAQQAAAAgABQA0AAAACQAGAAMAAAALAAcANwAAAA0ABAA2AAAABQAAABEAAAAJAAAAAAAAAAgAAAAAAAAA7AoAAB8IAAAGAAAAEQAAAAkAAAAAAAAABwAAAAAAAAACCwAAHAgAAAcAAAABAAAACQAAAAAAAAAgAAAAAAAAACULAAArCAAAAAADMS4wAAg8Y2xpbml0PgAGPGluaXQ+AA5BUFBMSUNBVElPTl9JRAAKQlVJTERfVFlQRQAOQm9vdHN0cmFwQ2xhc3MAE0Jvb3RzdHJhcENsYXNzLmphdmEAEEJ1aWxkQ29uZmlnLmphdmEABURFQlVHAAZGTEFWT1IAAUkAAklJAAJJTAAESUxMTAABTAADTExMABlMYW5kcm9pZC9jb250ZW50L0NvbnRleHQ7ACRMYW5kcm9pZC9jb250ZW50L3BtL0FwcGxpY2F0aW9uSW5mbzsAGkxhbmRyb2lkL29zL0J1aWxkJFZFUlNJT047ABJMYW5kcm9pZC91dGlsL0xvZzsATUxjb20vaGlnaGNhcGFibGUveXVraWhvb2thcGkvdGhpcmRwYXJ0eS9tZS93ZWlzaHUvZnJlZXJlZmxlY3Rpb24vQnVpbGRDb25maWc7AExMY29tL2hpZ2hjYXBhYmxlL3l1a2lob29rYXBpL3RoaXJkcGFydHkvbWUvd2Vpc2h1L3JlZmxlY3Rpb24vQm9vdHN0cmFwQ2xhc3M7AEhMY29tL2hpZ2hjYXBhYmxlL3l1a2lob29rYXBpL3RoaXJkcGFydHkvbWUvd2Vpc2h1L3JlZmxlY3Rpb24vUmVmbGVjdGlvbjsAEUxqYXZhL2xhbmcvQ2xhc3M7ABRMamF2YS9sYW5nL0NsYXNzPCo+OwASTGphdmEvbGFuZy9PYmplY3Q7ABJMamF2YS9sYW5nL1N0cmluZzsAEkxqYXZhL2xhbmcvU3lzdGVtOwAVTGphdmEvbGFuZy9UaHJvd2FibGU7ABpMamF2YS9sYW5nL3JlZmxlY3QvTWV0aG9kOwAKUmVmbGVjdGlvbgAPUmVmbGVjdGlvbi5qYXZhAAdTREtfSU5UAANUQUcAAVYADFZFUlNJT05fQ09ERQAMVkVSU0lPTl9OQU1FAAJWTAABWgACWkwAEltMamF2YS9sYW5nL0NsYXNzOwATW0xqYXZhL2xhbmcvT2JqZWN0OwATW0xqYXZhL2xhbmcvU3RyaW5nOwAHY29udGV4dAAXZGFsdmlrLnN5c3RlbS5WTVJ1bnRpbWUAAWUABmV4ZW1wdAAJZXhlbXB0QWxsAAdmb3JOYW1lAA9mcmVlLXJlZmxlY3Rpb24AEmdldEFwcGxpY2F0aW9uSW5mbwARZ2V0RGVjbGFyZWRNZXRob2QACmdldFJ1bnRpbWUABmludm9rZQALbG9hZExpYnJhcnkAGG1lLndlaXNodS5mcmVlcmVmbGVjdGlvbgAGbWV0aG9kAAdtZXRob2RzABlyZWZsZWN0IGJvb3RzdHJhcCBmYWlsZWQ6AAdyZWxlYXNlAApzVm1SdW50aW1lABZzZXRIaWRkZW5BcGlFeGVtcHRpb25zABB0YXJnZXRTZGtWZXJzaW9uAAZ1bnNlYWwADHVuc2VhbE5hdGl2ZQAOdm1SdW50aW1lQ2xhc3MAAQAAAAoAAAACAAAACgAQAAEAAAASAAAAAQAAAAAAAAADAAAACgAKAAwAAAABAAAAAQAAAAIAAAAJABEAARcGBhc4FzwfFwAEARcBARcfAAAAAAAABgAHDgAWAAcOav8DATIOARUQAwI1DvAEBEMJGgESDwMDNg4BGw+pBQIFAwUEGR4DAC8NAA4ABw4ALAE6Bw4ANgE7ByydGuIBAQMALw0eAEgABw4ADQAHDgATAS0HHXIZa1oAAAEAAQABAAAANAgAAAQAAABwEAwAAAAOAAoAAAADAAEAOQgAAHsAAABgBQEAEwYcADRlbQAcBQgAGgYxABIXI3cQABIIHAkKAE0JBwhuMAsAZQcMARwFCAAaBjQAEicjdxAAEggcCQoATQkHCBIYHAkQAE0JBwhuMAsAZQcMAhIFEhYjZhEAEgcaCC0ATQgGB24wDgBRBgwEHwQIABIlI1URABIGGgc1AE0HBQYSFhIHTQcFBm4wDgBCBQwDHwMNABIlI1URABIGGgc+AE0HBQYSFhIXI3cQABIIHAkSAE0JBwhNBwUGbjAOAEIFDAUfBQ0AaQUKABIFEgYjZhEAbjAOAFMGDAVpBQkADgANABoFBgAaBjsAcTABAGUAKPcAAAYAAABrAAEAAQEMcgEAAQABAAAAaAgAAAQAAABwEAwAAAAOAAMAAQABAAAAbQgAAAsAAAASECMAEgASAU0CAAFxEAYAAAAKAA8AAAAIAAEAAwABAHMIAAAdAAAAEhESAmIDCQA4AwYAYgMKADkDBAABIQ8BYgMKAGIECQASFSNVEQASBk0HBQZuMA4AQwUo8g0AASEo7wAADAAAAA0AAQABAQwaAwAAAAEAAACDCAAADQAAABIQIwASABIBGgIPAE0CAAFxEAYAAAAKAA8AAAABAAEAAQAAAIgIAAAEAAAAcBAMAAAADgAEAAEAAQAAAI0IAAAeAAAAEgBgAQEAEwIcADUhAwAPAHEABwAAAAoBOQH7/xoAMgBxEA0AAABuEAAAAwAMAFIAAABxEAoAAAAKACjqBgABAAIZARkBGQEZARkBGQKBgASYEQMABQAIGgEKAQoDiIAEsBEBgYAExBMBCdwTAYkBhBQBCdwUAQADAAsaCIGABIgVAQmgFQGKAgAAAAAPAAAAAAAAAAEAAAAAAAAAAQAAAEMAAABwAAAAAgAAABMAAAB8AQAAAwAAAAsAAADIAQAABAAAAAwAAABMAgAABQAAAA8AAACsAgAABgAAAAMAAAAkAwAAAiAAAEMAAACEAwAAARAAAAcAAADgBwAABSAAAAMAAAAcCAAAAxAAAAEAAAAwCAAAAyAAAAgAAAA0CAAAASAAAAgAAACYCAAAACAAAAMAAADsCgAAABAAAAEAAAA8CwAA\";\n" + - "\n" + - " private static native int unsealNative(int targetSdkVersion);\n" + - "\n" + - " public static int unseal(Context context) {\n" + - " if (SDK_INT < 28) {\n" + - " // Below Android P, ignore\n" + - " return 0;\n" + - " }\n" + - " // try exempt API first.\n" + - " if (exemptAll()) {\n" + - " return 0;\n" + - " }\n" + - " if (unsealByDexFile(context)) {\n" + - " return 0;\n" + - " }\n" + - " return -1;\n" + - " }\n" + - "\n" + - " @SuppressWarnings({\"deprecation\", \"ResultOfMethodCallIgnored\"})\n" + - " private static boolean unsealByDexFile(Context context) {\n" + - " byte[] bytes = Base64.decode(DEX, Base64.NO_WRAP);\n" + - " File codeCacheDir = getCodeCacheDir(context);\n" + - " if (codeCacheDir == null) {\n" + - " return false;\n" + - " }\n" + - " File code = new File(codeCacheDir, \"__temp_\" + System.currentTimeMillis() + \".dex\");\n" + - " try {\n" + - " try (FileOutputStream fos = new FileOutputStream(code)) {\n" + - " fos.write(bytes);\n" + - " }\n" + - " DexFile dexFile = new DexFile(code);\n" + - " // This class is hardcoded in the dex, Don't use BootstrapClass.class to reference it\n" + - " // it maybe obfuscated!!\n" + - " Class bootstrapClass = dexFile.loadClass(\"com.highcapable.yukihookapi.thirdparty.me.weishu.reflection.BootstrapClass\", null);\n" + - " Method exemptAll = bootstrapClass.getDeclaredMethod(\"exemptAll\");\n" + - " return (boolean) exemptAll.invoke(null);\n" + - " } catch (Throwable e) {\n" + - " e.printStackTrace();\n" + - " return false;\n" + - " } finally {\n" + - " if (code.exists()) {\n" + - " code.delete();\n" + - " }\n" + - " }\n" + - " }\n" + - "\n" + - " private static File getCodeCacheDir(Context context) {\n" + - " if (context != null) {\n" + - " return context.getCodeCacheDir();\n" + - " }\n" + - " String tmpDir = System.getProperty(\"java.io.tmpdir\");\n" + - " if (TextUtils.isEmpty(tmpDir)) {\n" + - " return null;\n" + - " }\n" + - " File tmp = new File(tmpDir);\n" + - " if (!tmp.exists()) {\n" + - " return null;\n" + - " }\n" + - " return tmp;\n" + - " }\n" + - "}") -) \ No newline at end of file