mirror of
https://github.com/HighCapable/YukiHookAPI.git
synced 2025-09-01 08:15:37 +08:00
refactor: update KavaRef usage to 1.0.1
This commit is contained in:
@@ -56,9 +56,9 @@ libraries:
|
||||
version: 1.2.0
|
||||
com.highcapable.kavaref:
|
||||
kavaref-core:
|
||||
version: 1.0.0
|
||||
version: 1.0.1
|
||||
kavaref-extension:
|
||||
version: 1.0.0
|
||||
version: 1.0.1
|
||||
com.highcapable.hikage:
|
||||
hikage-core:
|
||||
version: 1.0.1
|
||||
|
@@ -25,7 +25,7 @@ import android.graphics.drawable.Drawable
|
||||
import android.util.TypedValue
|
||||
import android.widget.Button
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import com.highcapable.kavaref.KavaRef.Companion.resolve
|
||||
import com.highcapable.kavaref.KavaRef.Companion.asResolver
|
||||
|
||||
/**
|
||||
* Fixed [AlertDialog] dialog button issue after injecting Module App's Resources in some Host Apps
|
||||
@@ -38,9 +38,9 @@ import com.highcapable.kavaref.KavaRef.Companion.resolve
|
||||
* @return [AlertDialog]
|
||||
*/
|
||||
fun AlertDialog.compatStyle(): AlertDialog {
|
||||
resolve().firstField {
|
||||
asResolver().firstField {
|
||||
name = "mAlert"
|
||||
}.get()?.resolve()?.apply {
|
||||
}.get()?.asResolver()?.apply {
|
||||
listOf(
|
||||
firstField { name = "mButtonPositive" }.get<Button>(),
|
||||
firstField { name = "mButtonNegative" }.get<Button>(),
|
||||
|
@@ -43,6 +43,7 @@ import android.os.UserHandle
|
||||
import androidx.annotation.RequiresApi
|
||||
import com.highcapable.betterandroid.system.extension.component.registerReceiver
|
||||
import com.highcapable.betterandroid.system.extension.tool.SystemVersion
|
||||
import com.highcapable.kavaref.KavaRef.Companion.asResolver
|
||||
import com.highcapable.kavaref.KavaRef.Companion.resolve
|
||||
import com.highcapable.kavaref.extension.classOf
|
||||
import com.highcapable.kavaref.extension.lazyClass
|
||||
@@ -158,9 +159,9 @@ internal object AppParasitics {
|
||||
name = "currentActivityThread"
|
||||
emptyParameters()
|
||||
}?.invoke()
|
||||
val currentScope = current?.resolve()?.optional(silent = true)
|
||||
val currentScope = current?.asResolver()?.optional(silent = true)
|
||||
val mBoundApplication = currentScope?.firstFieldOrNull { name = "mBoundApplication" }?.get()
|
||||
val appScope = mBoundApplication?.resolve()?.optional(silent = true)
|
||||
val appScope = mBoundApplication?.asResolver()?.optional(silent = true)
|
||||
appScope?.firstFieldOrNull { name = "appInfo" }?.get<ApplicationInfo>()
|
||||
}
|
||||
|
||||
@@ -402,7 +403,7 @@ internal object AppParasitics {
|
||||
if (YukiXposedModule.isXposedEnvironment) runCatching {
|
||||
if (currentPackageName == YukiXposedModule.modulePackageName)
|
||||
return YLog.innerE("You cannot inject module resources into yourself")
|
||||
hostResources.assets.resolve()
|
||||
hostResources.assets.asResolver()
|
||||
.processor(AndroidHiddenApiBypassResolver.get())
|
||||
.optional(silent = true)
|
||||
.firstMethodOrNull {
|
||||
@@ -457,17 +458,17 @@ internal object AppParasitics {
|
||||
.optional(silent = true)
|
||||
.firstFieldOrNull { name = "sCurrentActivityThread" }
|
||||
?.get()
|
||||
val instrumentation = sCurrentActivityThread?.resolve()
|
||||
val instrumentation = sCurrentActivityThread?.asResolver()
|
||||
?.processor(AndroidHiddenApiBypassResolver.get())
|
||||
?.optional(silent = true)
|
||||
?.firstMethodOrNull { name = "getInstrumentation" }
|
||||
?.invoke<Instrumentation>() ?: error("Could not found Instrumentation in ActivityThread")
|
||||
sCurrentActivityThread.resolve()
|
||||
sCurrentActivityThread.asResolver()
|
||||
.processor(AndroidHiddenApiBypassResolver.get())
|
||||
.optional(silent = true)
|
||||
.firstFieldOrNull { name = "mInstrumentation" }
|
||||
?.set(InstrumentationDelegate.wrapper(instrumentation))
|
||||
val mH = sCurrentActivityThread.resolve()
|
||||
val mH = sCurrentActivityThread.asResolver()
|
||||
.processor(AndroidHiddenApiBypassResolver.get())
|
||||
.optional(silent = true)
|
||||
.firstFieldOrNull { name = "mH" }
|
||||
|
@@ -31,6 +31,7 @@ import android.os.Handler
|
||||
import android.os.IBinder
|
||||
import android.os.Message
|
||||
import com.highcapable.betterandroid.system.extension.tool.SystemVersion
|
||||
import com.highcapable.kavaref.KavaRef.Companion.asResolver
|
||||
import com.highcapable.kavaref.KavaRef.Companion.resolve
|
||||
import com.highcapable.kavaref.extension.lazyClass
|
||||
import com.highcapable.yukihookapi.hook.core.api.reflect.AndroidHiddenApiBypassResolver
|
||||
@@ -64,7 +65,7 @@ internal object HandlerDelegateCaller {
|
||||
internal fun callHandleMessage(baseInstance: Handler.Callback?, msg: Message): Boolean {
|
||||
when (msg.what) {
|
||||
LAUNCH_ACTIVITY -> {
|
||||
val intentResolver = msg.obj.resolve()
|
||||
val intentResolver = msg.obj.asResolver()
|
||||
.processor(AndroidHiddenApiBypassResolver.get())
|
||||
.optional(silent = true)
|
||||
.firstFieldOrNull { name = "intent" }
|
||||
@@ -85,7 +86,7 @@ internal object HandlerDelegateCaller {
|
||||
?.invokeQuietly<List<Any>>()
|
||||
?.takeIf { it.isNotEmpty() }
|
||||
callbacks?.filter { it.javaClass.name.contains("LaunchActivityItem") }?.forEach { item ->
|
||||
val itemResolver = item.resolve().optional(silent = true)
|
||||
val itemResolver = item.asResolver().optional(silent = true)
|
||||
.firstFieldOrNull { name = "mIntent" }
|
||||
val intent = itemResolver?.get<Intent>()
|
||||
val mExtras = mExtrasResolver?.copy()?.of(intent)?.getQuietly<Bundle>()
|
||||
@@ -99,19 +100,19 @@ internal object HandlerDelegateCaller {
|
||||
.optional(silent = true)
|
||||
.firstMethodOrNull { name = "currentActivityThread" }
|
||||
?.invoke()
|
||||
val token = msg.obj.resolve()
|
||||
val token = msg.obj.asResolver()
|
||||
.processor(AndroidHiddenApiBypassResolver.get())
|
||||
.optional(silent = true)
|
||||
.firstMethodOrNull { name = "getActivityToken" }
|
||||
?.invokeQuietly()
|
||||
val launchingActivity = currentActivityThread?.resolve()
|
||||
val launchingActivity = currentActivityThread?.asResolver()
|
||||
?.processor(AndroidHiddenApiBypassResolver.get())
|
||||
?.optional(silent = true)
|
||||
?.firstMethodOrNull {
|
||||
name = "getLaunchingActivity"
|
||||
parameters(IBinder::class)
|
||||
}?.invokeQuietly(token)
|
||||
launchingActivity?.resolve()
|
||||
launchingActivity?.asResolver()
|
||||
?.processor(AndroidHiddenApiBypassResolver.get())
|
||||
?.optional(silent = true)
|
||||
?.firstFieldOrNull { name = "intent" }
|
||||
|
Reference in New Issue
Block a user