@@ -23,6 +23,7 @@ import li.songe.gkd.util.toast
2323import rikka.shizuku.Shizuku
2424import rikka.shizuku.ShizukuBinderWrapper
2525import rikka.shizuku.SystemServiceHelper
26+ import java.lang.reflect.Method
2627
2728inline fun <T > safeInvokeMethod (
2829 block : () -> T
@@ -43,11 +44,16 @@ fun getStubService(name: String, condition: Boolean): ShizukuBinderWrapper? {
4344 return ShizukuBinderWrapper (service)
4445}
4546
47+ private fun Method.simpleString (): String {
48+ return " ${name} (${parameterTypes.joinToString(" ," ) { it.name }} ):${returnType.name} "
49+ }
50+
4651fun Class <* >.detectHiddenMethod (
4752 methodName : String ,
4853 vararg args : Pair <Int , List <Class <* >>>,
4954): Int {
50- declaredMethods.forEach { method ->
55+ val methodsVal = methods
56+ methodsVal.forEach { method ->
5157 if (method.name == methodName) {
5258 val types = method.parameterTypes.toList()
5359 args.forEach { (value, argTypes) ->
@@ -57,7 +63,13 @@ fun Class<*>.detectHiddenMethod(
5763 }
5864 }
5965 }
60- throw NoSuchMethodException ()
66+ val result = methodsVal.filter { it.name == methodName }
67+ if (result.isEmpty()) {
68+ throw NoSuchMethodException (" ${name} ::${methodName} not found" )
69+ } else {
70+ LogUtils .d(" detectHiddenMethod" , * result.map { it.simpleString() }.toTypedArray())
71+ throw NoSuchMethodException (" ${name} ::${methodName} not match" )
72+ }
6173}
6274
6375class ShizukuContext (
0 commit comments