mirror of
https://github.com/HighCapable/YukiHookAPI.git
synced 2025-09-04 01:35:17 +08:00
Modify remove stub-jar and add stub-project and change the compiled class
This commit is contained in:
@@ -18,3 +18,4 @@ include ':demo-app'
|
||||
include ':demo-module'
|
||||
include ':yukihookapi'
|
||||
include ':yukihookapi-ksp-xposed'
|
||||
include ':yukihookapi-stub'
|
||||
|
@@ -231,19 +231,17 @@ class YukiHookXposedProcessor : SymbolProcessorProvider {
|
||||
msg = "You set the customize module package name to \"${data.customMPackageName}\", " +
|
||||
"please check for yourself if it is correct"
|
||||
)
|
||||
val mdAppInjectPackageName = "com.highcapable.yukihookapi.hook.xposed.application.inject"
|
||||
val ykBridgeInjectPackageName = "com.highcapable.yukihookapi.hook.xposed.bridge.inject"
|
||||
/** 插入 ModuleApplication_Injector 代码 */
|
||||
/** 插入 ModuleApplication_Impl 代码 */
|
||||
createCodeFile(
|
||||
fileName = "ModuleApplication_Injector",
|
||||
packageName = mdAppInjectPackageName,
|
||||
content = data.apply { injectPackageName = mdAppInjectPackageName }.sources()["ModuleApplication_Injector"]
|
||||
fileName = "ModuleApplication_Impl",
|
||||
packageName = "com.highcapable.yukihookapi.hook.xposed.application",
|
||||
content = data.sources()["ModuleApplication_Impl"]
|
||||
)
|
||||
/** 插入 YukiHookBridge_Injector 代码 */
|
||||
/** 插入 YukiHookBridge_Impl 代码 */
|
||||
createCodeFile(
|
||||
fileName = "YukiHookBridge_Injector",
|
||||
packageName = ykBridgeInjectPackageName,
|
||||
content = data.apply { injectPackageName = ykBridgeInjectPackageName }.sources()["YukiHookBridge_Injector"]
|
||||
fileName = "YukiHookBridge_Impl",
|
||||
packageName = "com.highcapable.yukihookapi.hook.xposed.bridge",
|
||||
content = data.sources()["YukiHookBridge_Impl"]
|
||||
)
|
||||
/** 插入 xposed_init 代码 */
|
||||
createCodeFile(
|
||||
|
@@ -30,7 +30,6 @@ package com.highcapable.yukihookapi_ksp_xposed.bean
|
||||
/**
|
||||
* 生成的模板数据实例
|
||||
* @param entryPackageName 入口类包名
|
||||
* @param injectPackageName 注入类包名
|
||||
* @param modulePackageName 模块包名 (命名空间)
|
||||
* @param customMPackageName 自定义模块包名
|
||||
* @param entryClassName 入口类名
|
||||
@@ -39,7 +38,6 @@ package com.highcapable.yukihookapi_ksp_xposed.bean
|
||||
*/
|
||||
data class GenerateData(
|
||||
var entryPackageName: String = "",
|
||||
var injectPackageName: String = "",
|
||||
var modulePackageName: String = "",
|
||||
var customMPackageName: String = "",
|
||||
var entryClassName: String = "",
|
||||
|
@@ -56,30 +56,28 @@ private fun createCommentContent(entryClassName: String = "", currrentClassTag:
|
||||
* @return [Map]<[String],[String]>
|
||||
*/
|
||||
fun GenerateData.sources() = mapOf(
|
||||
"ModuleApplication_Injector" to ("@file:Suppress(\"ClassName\")\n" +
|
||||
"ModuleApplication_Impl" to ("@file:Suppress(\"ClassName\")\n" +
|
||||
"\n" +
|
||||
"package $injectPackageName\n" +
|
||||
"package com.highcapable.yukihookapi.hook.xposed.application\n" +
|
||||
"\n" +
|
||||
"import $entryPackageName.$entryClassName\n" +
|
||||
"\n" +
|
||||
createCommentContent(entryClassName, currrentClassTag = "ModuleApplication") +
|
||||
"object ModuleApplication_Injector {\n" +
|
||||
"object ModuleApplication_Impl {\n" +
|
||||
"\n" +
|
||||
" @JvmStatic\n" +
|
||||
" fun callApiInit() = try {\n" +
|
||||
" fun callHookEntryInit() = try {\n" +
|
||||
" $entryClassName().onInit()\n" +
|
||||
" } catch (_: Throwable) {\n" +
|
||||
" }\n" +
|
||||
"}"),
|
||||
"YukiHookBridge_Injector" to ("@file:Suppress(\"ClassName\")\n" +
|
||||
"YukiHookBridge_Impl" to ("@file:Suppress(\"ClassName\")\n" +
|
||||
"\n" +
|
||||
"package $injectPackageName\n" +
|
||||
"package com.highcapable.yukihookapi.hook.xposed.bridge\n" +
|
||||
"\n" +
|
||||
createCommentContent(currrentClassTag = "YukiHookBridge") +
|
||||
"object YukiHookBridge_Injector {\n" +
|
||||
"object YukiHookBridge_Impl {\n" +
|
||||
"\n" +
|
||||
" @JvmStatic\n" +
|
||||
" fun getModuleGeneratedVersion() = \"${System.currentTimeMillis()}\"\n" +
|
||||
" val compiledTimestamp get() = ${System.currentTimeMillis()}\n" +
|
||||
"}"),
|
||||
"xposed_init" to ("@file:Suppress(\"ClassName\")\n" +
|
||||
"\n" +
|
||||
|
1
yukihookapi-stub/.gitignore
vendored
Normal file
1
yukihookapi-stub/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
/build
|
9
yukihookapi-stub/build.gradle
Normal file
9
yukihookapi-stub/build.gradle
Normal file
@@ -0,0 +1,9 @@
|
||||
plugins {
|
||||
id 'java-library'
|
||||
id 'org.jetbrains.kotlin.jvm'
|
||||
}
|
||||
|
||||
java {
|
||||
sourceCompatibility = JavaVersion.VERSION_11
|
||||
targetCompatibility = JavaVersion.VERSION_11
|
||||
}
|
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* YukiHookAPI - An efficient Kotlin version of the Xposed Hook API.
|
||||
* Copyright (C) 2019-2022 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/26.
|
||||
*/
|
||||
@file:Suppress("ClassName")
|
||||
|
||||
package com.highcapable.yukihookapi.hook.xposed.application
|
||||
|
||||
/**
|
||||
* ModuleApplication 注入 Stub
|
||||
*/
|
||||
object ModuleApplication_Impl {
|
||||
|
||||
/**
|
||||
* 调用 Hook 入口类的 onInit 方法
|
||||
*
|
||||
* 方法内容将在每次编译时自动生成
|
||||
*/
|
||||
fun callHookEntryInit(): Unit = error("Stub!")
|
||||
}
|
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* YukiHookAPI - An efficient Kotlin version of the Xposed Hook API.
|
||||
* Copyright (C) 2019-2022 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/26.
|
||||
*/
|
||||
@file:Suppress("ClassName")
|
||||
|
||||
package com.highcapable.yukihookapi.hook.xposed.bridge
|
||||
|
||||
/**
|
||||
* YukiHookBridge 注入 Stub
|
||||
*/
|
||||
object YukiHookBridge_Impl {
|
||||
|
||||
/**
|
||||
* 获取项目编译完成的时间戳 (当前本地时间)
|
||||
*
|
||||
* 返回值将在每次编译时自动生成
|
||||
* @return [Long]
|
||||
*/
|
||||
val compiledTimestamp: Long get() = error("Stub!")
|
||||
}
|
@@ -46,6 +46,7 @@ tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach {
|
||||
dependencies {
|
||||
// Used 82 API Version
|
||||
compileOnly 'de.robv.android.xposed:api:82'
|
||||
compileOnly project(':yukihookapi-stub')
|
||||
compileOnly fileTree(include: ['*.jar'], dir: 'libs')
|
||||
implementation 'androidx.annotation:annotation:1.4.0'
|
||||
}
|
||||
|
Binary file not shown.
Binary file not shown.
@@ -92,7 +92,7 @@ object YukiHookAPI {
|
||||
* 获取项目编译完成的时间戳 (当前本地时间)
|
||||
* @return [Long]
|
||||
*/
|
||||
val compiledTimestamp get() = YukiHookBridge.moduleGeneratedVersion.toLongOrNull() ?: 0L
|
||||
val compiledTimestamp get() = YukiHookBridge.compiledTimestamp
|
||||
|
||||
/**
|
||||
* 获取当前是否为 (Xposed) 宿主环境
|
||||
|
@@ -31,7 +31,6 @@ import android.app.Application
|
||||
import android.content.Context
|
||||
import com.highcapable.yukihookapi.YukiHookAPI
|
||||
import com.highcapable.yukihookapi.hook.xposed.application.ModuleApplication.Companion.appContext
|
||||
import com.highcapable.yukihookapi.hook.xposed.application.inject.ModuleApplication_Injector
|
||||
import com.highcapable.yukihookapi.hook.xposed.channel.YukiHookDataChannel
|
||||
import com.highcapable.yukihookapi.hook.xposed.proxy.IYukiHookXposedInit
|
||||
import com.highcapable.yukihookapi.thirdparty.me.weishu.reflection.Reflection
|
||||
@@ -82,10 +81,8 @@ open class ModuleApplication : Application() {
|
||||
override fun onCreate() {
|
||||
super.onCreate()
|
||||
currentContext = this
|
||||
callApiInit()
|
||||
/** 调用 Hook 入口类的 [IYukiHookXposedInit.onInit] 方法 */
|
||||
runCatching { ModuleApplication_Impl.callHookEntryInit() }
|
||||
YukiHookDataChannel.instance().register(context = this)
|
||||
}
|
||||
|
||||
/** 调用入口类的 [IYukiHookXposedInit.onInit] 方法 */
|
||||
private fun callApiInit() = runCatching { ModuleApplication_Injector.callApiInit() }
|
||||
}
|
@@ -39,7 +39,6 @@ import com.highcapable.yukihookapi.hook.param.PackageParam
|
||||
import com.highcapable.yukihookapi.hook.param.type.HookEntryType
|
||||
import com.highcapable.yukihookapi.hook.param.wrapper.PackageParamWrapper
|
||||
import com.highcapable.yukihookapi.hook.xposed.bridge.dummy.YukiResources
|
||||
import com.highcapable.yukihookapi.hook.xposed.bridge.inject.YukiHookBridge_Injector
|
||||
import com.highcapable.yukihookapi.hook.xposed.helper.YukiHookAppHelper
|
||||
import com.highcapable.yukihookapi.hook.xposed.parasitic.AppParasitics
|
||||
import dalvik.system.PathClassLoader
|
||||
@@ -88,11 +87,19 @@ object YukiHookBridge {
|
||||
*/
|
||||
internal val hostProcessName get() = if (isInitializingZygote) "android-zygote" else YukiHookAppHelper.currentPackageName() ?: "unknown"
|
||||
|
||||
/**
|
||||
* 获取项目编译完成的时间戳 (当前本地时间)
|
||||
* @return [Long]
|
||||
*/
|
||||
internal val compiledTimestamp get() = runCatching { YukiHookBridge_Impl.compiledTimestamp }.getOrNull() ?: 0L
|
||||
|
||||
/**
|
||||
* 自动生成的 Xposed 模块构建版本号
|
||||
*
|
||||
* 获取 [compiledTimestamp] 并转换为字符串
|
||||
* @return [String]
|
||||
*/
|
||||
internal val moduleGeneratedVersion get() = YukiHookBridge_Injector.getModuleGeneratedVersion()
|
||||
internal val moduleGeneratedVersion get() = compiledTimestamp.toString()
|
||||
|
||||
/**
|
||||
* 预设的 Xposed 模块包名
|
||||
|
Reference in New Issue
Block a user