@@ -219,41 +219,18 @@ abstract class BaseHook(val app: Application, val lpparam: LoadPackageParam) : I
219219 }
220220 }
221221
222- private fun <T , R > getFromCacheOrFind (
223- key : String ,
224- findFunc : (DexKitBridge .() -> T )? ,
225- serialize : (T ) -> String ,
226- deserialize : (String ) -> R
227- ): R {
228- return cache.get(key, null )?.let { deserialize(it) }
229- ? : findFunc!! (dexkit.bridge).let { result ->
230- val serializedValue = serialize(result)
231- cache.put(key, serializedValue)
232- Logger .printInfo { " $key Matches: $serializedValue " }
233- deserialize(serializedValue)
234- }
235- }
236-
237222 fun getDexClass (key : String , findFunc : (DexKitBridge .() -> ClassData )? = null): DexClass =
238- if (findFunc == null ) dexkit.getClassDirect(key) else dexkit.getClassDirect( key, findFunc)
223+ dexkit.getClassDirect(key) { findFunc !! (). also { Logger .printInfo { " $ key Matches: ${it.descriptor} " } } }
239224
240225 fun getDexMethod (key : String , findFunc : (DexKitBridge .() -> MethodData )? = null): DexMethod =
241- if (findFunc == null ) dexkit.getMethodDirect(key) else dexkit.getMethodDirect( key, findFunc)
226+ dexkit.getMethodDirect(key) { findFunc !! (). also { Logger .printInfo { " $ key Matches: ${it.descriptor} " } } }
242227
243228 fun getDexField (key : String , findFunc : (DexKitBridge .() -> FieldData )? = null): DexField =
244- if (findFunc == null ) dexkit.getFieldDirect(key) else dexkit.getFieldDirect(key, findFunc)
245-
246- fun getString (key : String , findFunc : (DexKitBridge .() -> String )? = null): String =
247- getFromCacheOrFind(key, findFunc, { it }, { it })
248-
249- fun getNumber (key : String , findFunc : (DexKitBridge .() -> Int )? = null): Int =
250- getFromCacheOrFind(key, findFunc, { it.toString() }, { Integer .parseInt(it) })
229+ dexkit.getFieldDirect(key) { findFunc!! ().also { Logger .printInfo { " $key Matches: ${it.descriptor} " } } }
251230
252231 fun getDexMethods (
253232 key : String , findFunc : (DexKitBridge .() -> List <MethodData >)? = null
254- ): List <DexMethod > = if (findFunc == null ) {
255- dexkit.getMethodsDirect(key)
256- } else {
257- dexkit.getMethodsDirect(key, findFunc)
258- }
233+ ): List <DexMethod > =
234+ dexkit.getMethodsDirect(key) { findFunc!! ().also { Logger .printInfo { " $key Matches: ${it.joinToString { m -> m.descriptor }} " } } }
235+
259236}
0 commit comments