mirror of
https://github.com/HighCapable/YukiHookAPI.git
synced 2025-09-06 02:35:40 +08:00
Added systemContext function in PackageParam
This commit is contained in:
@@ -85,20 +85,6 @@ open class PackageParam internal constructor(@PublishedApi internal var wrapper:
|
||||
*/
|
||||
val appInfo get() = wrapper?.appInfo ?: YukiHookAppHelper.currentApplicationInfo() ?: ApplicationInfo()
|
||||
|
||||
/**
|
||||
* 获取当前 Hook APP 的进程名称
|
||||
*
|
||||
* 默认的进程名称是 [packageName]
|
||||
* @return [String]
|
||||
*/
|
||||
val processName get() = wrapper?.processName ?: YukiHookAppHelper.currentProcessName() ?: packageName
|
||||
|
||||
/**
|
||||
* 获取当前 Hook APP 的包名
|
||||
* @return [String]
|
||||
*/
|
||||
val packageName get() = wrapper?.packageName ?: YukiHookAppHelper.currentPackageName() ?: ""
|
||||
|
||||
/**
|
||||
* 获取当前 Hook APP 的 [Application] 实例
|
||||
*
|
||||
@@ -117,6 +103,27 @@ open class PackageParam internal constructor(@PublishedApi internal var wrapper:
|
||||
*/
|
||||
val appResources get() = wrapper?.appResources ?: appContext.resources ?: error("You cannot call to appResources in this time")
|
||||
|
||||
/**
|
||||
* 获取当前系统框架的 [Context]
|
||||
* @return [Context] ContextImpl 实例对象
|
||||
* @throws IllegalStateException 如果获取不到系统框架的 [Context]
|
||||
*/
|
||||
val systemContext get() = YukiHookBridge.systemContext
|
||||
|
||||
/**
|
||||
* 获取当前 Hook APP 的进程名称
|
||||
*
|
||||
* 默认的进程名称是 [packageName]
|
||||
* @return [String]
|
||||
*/
|
||||
val processName get() = wrapper?.processName ?: YukiHookAppHelper.currentProcessName() ?: packageName
|
||||
|
||||
/**
|
||||
* 获取当前 Hook APP 的包名
|
||||
* @return [String]
|
||||
*/
|
||||
val packageName get() = wrapper?.packageName ?: YukiHookAppHelper.currentPackageName() ?: ""
|
||||
|
||||
/**
|
||||
* 获取当前 Hook APP 是否为第一个 [Application]
|
||||
* @return [Boolean]
|
||||
|
@@ -46,10 +46,7 @@ import com.highcapable.yukihookapi.hook.param.PackageParam
|
||||
import com.highcapable.yukihookapi.hook.param.type.HookEntryType
|
||||
import com.highcapable.yukihookapi.hook.param.wrapper.HookParamWrapper
|
||||
import com.highcapable.yukihookapi.hook.param.wrapper.PackageParamWrapper
|
||||
import com.highcapable.yukihookapi.hook.type.android.ApplicationClass
|
||||
import com.highcapable.yukihookapi.hook.type.android.ConfigurationClass
|
||||
import com.highcapable.yukihookapi.hook.type.android.ContextClass
|
||||
import com.highcapable.yukihookapi.hook.type.android.InstrumentationClass
|
||||
import com.highcapable.yukihookapi.hook.type.android.*
|
||||
import com.highcapable.yukihookapi.hook.type.java.IntType
|
||||
import com.highcapable.yukihookapi.hook.xposed.bridge.dummy.YukiModuleResources
|
||||
import com.highcapable.yukihookapi.hook.xposed.bridge.dummy.YukiResources
|
||||
@@ -122,6 +119,17 @@ object YukiHookBridge {
|
||||
*/
|
||||
internal val moduleGeneratedVersion get() = YukiHookBridge_Injector.getModuleGeneratedVersion()
|
||||
|
||||
/**
|
||||
* 获取当前系统框架的 [Context]
|
||||
* @return [Context] ContextImpl 实例对象
|
||||
* @throws IllegalStateException 如果获取不到系统框架的 [Context]
|
||||
*/
|
||||
internal val systemContext
|
||||
get() = runCatching {
|
||||
Hooker.findMethod(ActivityThreadClass, name = "getSystemContext")
|
||||
.invoke(Hooker.findMethod(ActivityThreadClass, name = "currentActivityThread").invoke(null)) as? Context?
|
||||
}.getOrNull() ?: error("Failed to got SystemContext")
|
||||
|
||||
/**
|
||||
* 模块是否装载了 Xposed 回调方法
|
||||
*
|
||||
|
Reference in New Issue
Block a user