style: lots of changes

- move demo-app, demo-module to samples
- rename yukihookapi to yukihookapi-core
- optimize code
- other small changes
This commit is contained in:
2023-09-21 03:19:13 +08:00
parent dd7912a577
commit 8ba166dab9
179 changed files with 919 additions and 682 deletions

View File

@@ -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;
}
}

View File

@@ -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;
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

View File

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 16 KiB

View File

@@ -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;
}
}

View File

@@ -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;
}
}

View File

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

Before

Width:  |  Height:  |  Size: 2.4 KiB

After

Width:  |  Height:  |  Size: 2.4 KiB

View File

Before

Width:  |  Height:  |  Size: 3.9 KiB

After

Width:  |  Height:  |  Size: 3.9 KiB

View File

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

Before

Width:  |  Height:  |  Size: 2.4 KiB

After

Width:  |  Height:  |  Size: 2.4 KiB

View File

Before

Width:  |  Height:  |  Size: 2.7 KiB

After

Width:  |  Height:  |  Size: 2.7 KiB

View File

Before

Width:  |  Height:  |  Size: 3.3 KiB

After

Width:  |  Height:  |  Size: 3.3 KiB

View File

Before

Width:  |  Height:  |  Size: 5.7 KiB

After

Width:  |  Height:  |  Size: 5.7 KiB

View File

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

View File

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 24 KiB

View File

Before

Width:  |  Height:  |  Size: 4.1 KiB

After

Width:  |  Height:  |  Size: 4.1 KiB

View File

Before

Width:  |  Height:  |  Size: 5.3 KiB

After

Width:  |  Height:  |  Size: 5.3 KiB

View File

Before

Width:  |  Height:  |  Size: 8.8 KiB

After

Width:  |  Height:  |  Size: 8.8 KiB

View File

Before

Width:  |  Height:  |  Size: 5.6 KiB

After

Width:  |  Height:  |  Size: 5.6 KiB

View File

Before

Width:  |  Height:  |  Size: 7.3 KiB

After

Width:  |  Height:  |  Size: 7.3 KiB

View File

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 13 KiB

View File

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

View File

@@ -44,7 +44,9 @@ import com.highcapable.yukihookapi.hook.factory.applyModuleTheme
import com.highcapable.yukihookapi.hook.factory.registerModuleAppActivities import com.highcapable.yukihookapi.hook.factory.registerModuleAppActivities
import com.highcapable.yukihookapi.hook.type.android.ActivityClass import com.highcapable.yukihookapi.hook.type.android.ActivityClass
import com.highcapable.yukihookapi.hook.type.android.BundleClass 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.bridge.event.YukiXposedEvent
import com.highcapable.yukihookapi.hook.xposed.proxy.IYukiHookXposedInit import com.highcapable.yukihookapi.hook.xposed.proxy.IYukiHookXposedInit
@@ -238,9 +240,9 @@ object HookEntry : IYukiHookXposedInit {
.setTitle("Hooked") .setTitle("Hooked")
.setMessage( .setMessage(
"This App has been hooked!\n\n" + "This App has been hooked!\n\n" +
"Hook Framework: ${YukiHookAPI.Status.Executor.name}\n\n" + "Hook Framework: ${YukiHookAPI.Status.Executor.name}\n\n" +
"Xposed API Version: ${YukiHookAPI.Status.Executor.apiLevel}\n\n" + "Xposed API Version: ${YukiHookAPI.Status.Executor.apiLevel}\n\n" +
"Support Resources Hook: ${YukiHookAPI.Status.isSupportResourcesHook}" "Support Resources Hook: ${YukiHookAPI.Status.isSupportResourcesHook}"
) )
.setPositiveButton("OK", null) .setPositiveButton("OK", null)
.show().compatStyle() .show().compatStyle()

View File

@@ -63,11 +63,9 @@ public class HookEntry implements IYukiHookXposedInit {
YukiHookLogger.Configs.USER_ID YukiHookLogger.Configs.USER_ID
); );
config.setDebug(true); config.setDebug(true);
config.setEnableModulePrefsCache(true);
config.setEnableModuleAppResourcesCache(true); config.setEnableModuleAppResourcesCache(true);
config.setEnableHookModuleStatus(true); config.setEnableHookModuleStatus(true);
config.setEnableDataChannel(true); config.setEnableDataChannel(true);
config.setEnableMemberCache(true);
} }
@Override @Override

View File

@@ -40,7 +40,7 @@ import com.highcapable.yukihookapi.hook.factory.dataChannel
import com.highcapable.yukihookapi.hook.factory.prefs import com.highcapable.yukihookapi.hook.factory.prefs
import com.highcapable.yukihookapi.hook.xposed.parasitic.activity.base.ModuleAppCompatActivity import com.highcapable.yukihookapi.hook.xposed.parasitic.activity.base.ModuleAppCompatActivity
import java.text.SimpleDateFormat import java.text.SimpleDateFormat
import java.util.* import java.util.Date
class MainActivity : ModuleAppCompatActivity() { class MainActivity : ModuleAppCompatActivity() {

View File

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

Before

Width:  |  Height:  |  Size: 2.4 KiB

After

Width:  |  Height:  |  Size: 2.4 KiB

View File

Before

Width:  |  Height:  |  Size: 3.9 KiB

After

Width:  |  Height:  |  Size: 3.9 KiB

View File

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

Before

Width:  |  Height:  |  Size: 2.4 KiB

After

Width:  |  Height:  |  Size: 2.4 KiB

View File

Before

Width:  |  Height:  |  Size: 2.7 KiB

After

Width:  |  Height:  |  Size: 2.7 KiB

View File

Before

Width:  |  Height:  |  Size: 3.3 KiB

After

Width:  |  Height:  |  Size: 3.3 KiB

View File

Before

Width:  |  Height:  |  Size: 5.7 KiB

After

Width:  |  Height:  |  Size: 5.7 KiB

View File

Before

Width:  |  Height:  |  Size: 4.5 KiB

After

Width:  |  Height:  |  Size: 4.5 KiB

View File

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 24 KiB

View File

Before

Width:  |  Height:  |  Size: 4.1 KiB

After

Width:  |  Height:  |  Size: 4.1 KiB

View File

Before

Width:  |  Height:  |  Size: 5.3 KiB

After

Width:  |  Height:  |  Size: 5.3 KiB

View File

Before

Width:  |  Height:  |  Size: 8.8 KiB

After

Width:  |  Height:  |  Size: 8.8 KiB

View File

Before

Width:  |  Height:  |  Size: 5.6 KiB

After

Width:  |  Height:  |  Size: 5.6 KiB

View File

Before

Width:  |  Height:  |  Size: 7.3 KiB

After

Width:  |  Height:  |  Size: 7.3 KiB

View File

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 13 KiB

1
yukihookapi-core/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
/build

View File

@@ -37,6 +37,7 @@ import com.highcapable.yukihookapi.YukiHookAPI.Configs.debugLog
import com.highcapable.yukihookapi.YukiHookAPI.configs import com.highcapable.yukihookapi.YukiHookAPI.configs
import com.highcapable.yukihookapi.YukiHookAPI.encase import com.highcapable.yukihookapi.YukiHookAPI.encase
import com.highcapable.yukihookapi.annotation.xposed.InjectYukiHookWithXposed 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.HookApiCategoryHelper
import com.highcapable.yukihookapi.hook.core.api.compat.HookApiProperty import com.highcapable.yukihookapi.hook.core.api.compat.HookApiProperty
import com.highcapable.yukihookapi.hook.core.api.compat.type.ExecutorType import com.highcapable.yukihookapi.hook.core.api.compat.type.ExecutorType
@@ -74,10 +75,10 @@ object YukiHookAPI {
internal var isLoadedFromBaseContext = false internal var isLoadedFromBaseContext = false
/** 获取当前 [YukiHookAPI] 的版本 */ /** 获取当前 [YukiHookAPI] 的版本 */
const val API_VERSION_NAME = BuildConfig.API_VERSION_NAME const val API_VERSION_NAME = YukiHookAPIProperties.PROJECT_YUKIHOOKAPI_CORE_VERSION
/** 获取当前 [YukiHookAPI] 的版本号 */ /** 获取当前 [YukiHookAPI] 的版本号 */
const val API_VERSION_CODE = BuildConfig.API_VERSION_CODE const val API_VERSION_CODE = 44
/** /**
* 当前 [YukiHookAPI] 的状态 * 当前 [YukiHookAPI] 的状态

View File

@@ -25,7 +25,7 @@
* *
* This file is Created by fankes on 2022/4/3. * 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 package com.highcapable.yukihookapi.annotation

View File

@@ -25,7 +25,7 @@
* *
* This file is Created by fankes on 2022/4/3. * 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 package com.highcapable.yukihookapi.annotation

View File

@@ -25,7 +25,7 @@
* *
* This file is Created by fankes on 2022/4/3. * 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 package com.highcapable.yukihookapi.annotation

View File

@@ -149,7 +149,7 @@ class CurrentClass @PublishedApi internal constructor(@PublishedApi internal val
inline fun method(initiate: MethodConditions) = inline fun method(initiate: MethodConditions) =
superClassSet.method(initiate).result { if (isShutErrorPrinting) ignored() }.get(instance) 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]" override fun toString() = "CurrentClass [$classSet]"

View File

@@ -25,7 +25,7 @@
* *
* This file is Created by fankes on 2022/2/2. * 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 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.ConstructorConditions
import com.highcapable.yukihookapi.hook.core.finder.type.factory.FieldConditions 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.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.yLoggerE
import com.highcapable.yukihookapi.hook.log.yLoggerI import com.highcapable.yukihookapi.hook.log.yLoggerI
import com.highcapable.yukihookapi.hook.log.yLoggerW import com.highcapable.yukihookapi.hook.log.yLoggerW
import com.highcapable.yukihookapi.hook.param.HookParam import com.highcapable.yukihookapi.hook.param.HookParam
import com.highcapable.yukihookapi.hook.param.PackageParam 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.RandomSeed
import com.highcapable.yukihookapi.hook.utils.await import com.highcapable.yukihookapi.hook.utils.await
import com.highcapable.yukihookapi.hook.utils.conditions import com.highcapable.yukihookapi.hook.utils.conditions
@@ -189,8 +202,8 @@ class YukiMemberHookCreator @PublishedApi internal constructor(
fun throwProblem(name: String, content: String) { fun throwProblem(name: String, content: String) {
if (hookOption != "Yes do as I say!") throw UnsupportedOperationException( if (hookOption != "Yes do as I say!") throw UnsupportedOperationException(
"!!!DANGEROUS!!! Hook [$name] Class is a dangerous behavior! $content\n" + "!!!DANGEROUS!!! Hook [$name] Class is a dangerous behavior! $content\n" +
"The hook request was rejected, if you still want to use it, " + "The hook request was rejected, if you still want to use it, " +
"call \"useDangerousOperation\" and type \"Yes do as I say!\"" "call \"useDangerousOperation\" and type \"Yes do as I say!\""
) )
} }
when (hookClass.name) { when (hookClass.name) {

View File

@@ -197,10 +197,12 @@ class YukiResourcesHookCreator @PublishedApi internal constructor(
conditions!!.name, compat(replaceInstance) conditions!!.name, compat(replaceInstance)
) { onHookLogMsg(msg = "Hook Resources Value $conditions done [$tag]") } ) { onHookLogMsg(msg = "Hook Resources Value $conditions done [$tag]") }
} else when { } else when {
layoutInstance != null -> hookResources.instance?.hookLayout(resourceId, layoutInstance!!) layoutInstance != null -> hookResources.instance?.hookLayout(resourceId, layoutInstance!!) {
{ onHookLogMsg(msg = "Hook Resources Layout Id $resourceId done [$tag]") } 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]") } else -> hookResources.instance?.setReplacement(resourceId, compat(replaceInstance)) {
onHookLogMsg(msg = "Hook Resources Value Id $resourceId done [$tag]")
}
} }
packageParam.wrapper?.type == HookEntryType.ZYGOTE -> packageParam.wrapper?.type == HookEntryType.ZYGOTE ->
if (resourceId == -1) when { if (resourceId == -1) when {
@@ -214,10 +216,12 @@ class YukiResourcesHookCreator @PublishedApi internal constructor(
conditions!!.name, compat(replaceInstance) conditions!!.name, compat(replaceInstance)
) { onHookLogMsg(msg = "Hook Wide Resources Value $conditions done [$tag]") } ) { onHookLogMsg(msg = "Hook Wide Resources Value $conditions done [$tag]") }
} else when { } else when {
layoutInstance != null -> YukiResources.hookSystemWideLayout(resourceId, layoutInstance!!) layoutInstance != null -> YukiResources.hookSystemWideLayout(resourceId, layoutInstance!!) {
{ onHookLogMsg(msg = "Hook Wide Resources Layout Id $resourceId done [$tag]") } 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 -> YukiResources.setSystemWideReplacement(resourceId, compat(replaceInstance)) {
onHookLogMsg(msg = "Hook Wide Resources Value Id $resourceId done [$tag]")
}
} }
else -> yLoggerE(msg = "Resources Hook type is invalid [$tag]") else -> yLoggerE(msg = "Resources Hook type is invalid [$tag]")
} }

Some files were not shown because too many files have changed in this diff Show More