mirror of
https://github.com/HighCapable/YukiHookAPI.git
synced 2025-10-18 00:59:27 +08:00
refactor: merge to BetterAndroid new usage
This commit is contained in:
@@ -28,7 +28,7 @@ import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.widget.Button
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
import com.highcapable.betterandroid.system.extension.tool.SystemVersion
|
||||
import com.highcapable.betterandroid.system.extension.tool.AndroidVersion
|
||||
import com.highcapable.kavaref.KavaRef.Companion.resolve
|
||||
import com.highcapable.kavaref.extension.ArrayClass
|
||||
import com.highcapable.yukihookapi.YukiHookAPI
|
||||
@@ -190,7 +190,7 @@ object HookEntry : IYukiHookXposedInit {
|
||||
// Register Activity Proxy
|
||||
// 注册模块 Activity 代理
|
||||
onAppLifecycle {
|
||||
onCreate { if (SystemVersion.isHighOrEqualsTo(SystemVersion.N)) registerModuleAppActivities() }
|
||||
onCreate { if (AndroidVersion.isAtLeast(AndroidVersion.N)) registerModuleAppActivities() }
|
||||
}
|
||||
// Find Class to hook
|
||||
// 得到需要 Hook 的 Class
|
||||
@@ -288,7 +288,7 @@ object HookEntry : IYukiHookXposedInit {
|
||||
.setTitle("Hooked")
|
||||
.setMessage("I am hook your toast showing!")
|
||||
.apply {
|
||||
if (SystemVersion.isHighOrEqualsTo(SystemVersion.N))
|
||||
if (AndroidVersion.isAtLeast(AndroidVersion.N))
|
||||
setPositiveButton("START PARASITIC") { _, _ ->
|
||||
MaterialAlertDialogBuilder(context)
|
||||
.setTitle("Start Parasitic")
|
||||
|
@@ -21,7 +21,7 @@
|
||||
*/
|
||||
package com.highcapable.yukihookapi.hook.core.api.reflect
|
||||
|
||||
import com.highcapable.betterandroid.system.extension.tool.SystemVersion
|
||||
import com.highcapable.betterandroid.system.extension.tool.AndroidVersion
|
||||
import com.highcapable.kavaref.resolver.processor.MemberProcessor
|
||||
import org.lsposed.hiddenapibypass.HiddenApiBypass
|
||||
import java.lang.reflect.Constructor
|
||||
@@ -50,12 +50,12 @@ class AndroidHiddenApiBypassResolver private constructor() : MemberProcessor.Res
|
||||
}
|
||||
|
||||
override fun <T : Any> getDeclaredConstructors(declaringClass: Class<T>): List<Constructor<T>> =
|
||||
SystemVersion.require(SystemVersion.P, super.getDeclaredConstructors(declaringClass)) {
|
||||
AndroidVersion.require(AndroidVersion.P, super.getDeclaredConstructors(declaringClass)) {
|
||||
HiddenApiBypass.getDeclaredMethods(declaringClass).filterIsInstance<Constructor<T>>().toList()
|
||||
}
|
||||
|
||||
override fun <T : Any> getDeclaredMethods(declaringClass: Class<T>): List<Method> =
|
||||
SystemVersion.require(SystemVersion.P, super.getDeclaredMethods(declaringClass)) {
|
||||
AndroidVersion.require(AndroidVersion.P, super.getDeclaredMethods(declaringClass)) {
|
||||
HiddenApiBypass.getDeclaredMethods(declaringClass).filterIsInstance<Method>().toList()
|
||||
}
|
||||
}
|
@@ -34,7 +34,7 @@ import android.widget.ImageView
|
||||
import androidx.annotation.RequiresApi
|
||||
import androidx.annotation.StyleRes
|
||||
import androidx.core.net.toUri
|
||||
import com.highcapable.betterandroid.system.extension.tool.SystemVersion
|
||||
import com.highcapable.betterandroid.system.extension.tool.AndroidVersion
|
||||
import com.highcapable.yukihookapi.YukiHookAPI
|
||||
import com.highcapable.yukihookapi.hook.entity.YukiBaseHooker
|
||||
import com.highcapable.yukihookapi.hook.param.PackageParam
|
||||
@@ -118,7 +118,7 @@ fun Context.dataChannel(packageName: String) = YukiHookDataChannel.instance().na
|
||||
val Context.processName
|
||||
get() = runCatching {
|
||||
BufferedReader(FileReader(File("/proc/${Process.myPid()}/cmdline"))).let { buff ->
|
||||
buff.readLine().trim { it <= ' ' }.let {
|
||||
buff.readLine().trim().let {
|
||||
buff.close()
|
||||
it
|
||||
}
|
||||
@@ -173,7 +173,7 @@ fun Resources.injectModuleAppResources() = AppParasitics.injectModuleAppResource
|
||||
* - 最低支持 Android 7.0 (API 24)
|
||||
* @param proxy 代理的 [Activity] - 必须存在于宿主的 AndroidMainifest 清单中 - 不填使用默认 [Activity]
|
||||
*/
|
||||
@RequiresApi(SystemVersion.N)
|
||||
@RequiresApi(AndroidVersion.N)
|
||||
fun Context.registerModuleAppActivities(proxy: Any? = null) = AppParasitics.registerModuleAppActivities(context = this, proxy)
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user