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