Build log strings in suppliers

This commit is contained in:
oSumAtrIX 2024-10-27 15:59:52 +01:00
parent f62e952514
commit 35b85b2c29
No known key found for this signature in database
GPG Key ID: A9B3094ACDB604B4
3 changed files with 10 additions and 10 deletions

View File

@ -89,9 +89,9 @@ val patcherResult = Patcher(PatcherConfig(apkFile = File("some.apk"))).use { pat
runBlocking { runBlocking {
patcher().collect { patchResult -> patcher().collect { patchResult ->
if (patchResult.exception != null) if (patchResult.exception != null)
logger.info("\"${patchResult.patch}\" failed:\n${patchResult.exception}") logger.info { "\"${patchResult.patch}\" failed:\n${patchResult.exception}" }
else else
logger.info("\"${patchResult.patch}\" succeeded") logger.info { "\"${patchResult.patch}\" succeeded" }
} }
} }

View File

@ -97,7 +97,7 @@ class BytecodePatchContext internal constructor(private val config: PatcherConfi
bytecodePatch.extensionInputStream?.get()?.use { extensionStream -> bytecodePatch.extensionInputStream?.get()?.use { extensionStream ->
RawDexIO.readRawDexFile(extensionStream, 0, null).classes.forEach { classDef -> RawDexIO.readRawDexFile(extensionStream, 0, null).classes.forEach { classDef ->
val existingClass = lookupMaps.classesByType[classDef.type] ?: run { val existingClass = lookupMaps.classesByType[classDef.type] ?: run {
logger.fine("Adding class \"$classDef\"") logger.fine { "Adding class \"$classDef\"" }
classes += classDef classes += classDef
lookupMaps.classesByType[classDef.type] = classDef lookupMaps.classesByType[classDef.type] = classDef
@ -105,7 +105,7 @@ class BytecodePatchContext internal constructor(private val config: PatcherConfi
return@forEach return@forEach
} }
logger.fine("Class \"$classDef\" exists already. Adding missing methods and fields.") logger.fine { "Class \"$classDef\" exists already. Adding missing methods and fields." }
existingClass.merge(classDef, this@BytecodePatchContext).let { mergedClass -> existingClass.merge(classDef, this@BytecodePatchContext).let { mergedClass ->
// If the class was merged, replace the original class with the merged class. // If the class was merged, replace the original class with the merged class.
@ -178,7 +178,7 @@ class BytecodePatchContext internal constructor(private val config: PatcherConfi
override fun getOpcodes() = this@BytecodePatchContext.opcodes override fun getOpcodes() = this@BytecodePatchContext.opcodes
}, },
DexIO.DEFAULT_MAX_DEX_POOL_SIZE, DexIO.DEFAULT_MAX_DEX_POOL_SIZE,
) { _, entryName, _ -> logger.info("Compiled $entryName") } ) { _, entryName, _ -> logger.info { "Compiled $entryName" } }
}.listFiles(FileFilter { it.isFile })!!.map { }.listFiles(FileFilter { it.isFile })!!.map {
PatcherResult.PatchedDexFile(it.name, it.inputStream()) PatcherResult.PatchedDexFile(it.name, it.inputStream())
}.toSet() }.toSet()

View File

@ -60,7 +60,7 @@ internal object ClassMerger {
if (missingMethods.isEmpty()) return this if (missingMethods.isEmpty()) return this
logger.fine("Found ${missingMethods.size} missing methods") logger.fine { "Found ${missingMethods.size} missing methods" }
return asMutableClass().apply { return asMutableClass().apply {
methods.addAll(missingMethods.map { it.toMutable() }) methods.addAll(missingMethods.map { it.toMutable() })
@ -80,7 +80,7 @@ internal object ClassMerger {
if (missingFields.isEmpty()) return this if (missingFields.isEmpty()) return this
logger.fine("Found ${missingFields.size} missing fields") logger.fine { "Found ${missingFields.size} missing fields" }
return asMutableClass().apply { return asMutableClass().apply {
fields.addAll(missingFields.map { it.toMutable() }) fields.addAll(missingFields.map { it.toMutable() })
@ -100,7 +100,7 @@ internal object ClassMerger {
context.traverseClassHierarchy(this) { context.traverseClassHierarchy(this) {
if (accessFlags.isPublic()) return@traverseClassHierarchy if (accessFlags.isPublic()) return@traverseClassHierarchy
logger.fine("Publicizing ${this.type}") logger.fine { "Publicizing ${this.type}" }
accessFlags = accessFlags.toPublic() accessFlags = accessFlags.toPublic()
} }
@ -124,7 +124,7 @@ internal object ClassMerger {
if (brokenFields.isEmpty()) return this if (brokenFields.isEmpty()) return this
logger.fine("Found ${brokenFields.size} broken fields") logger.fine { "Found ${brokenFields.size} broken fields" }
/** /**
* Make a field public. * Make a field public.
@ -153,7 +153,7 @@ internal object ClassMerger {
if (brokenMethods.isEmpty()) return this if (brokenMethods.isEmpty()) return this
logger.fine("Found ${brokenMethods.size} methods") logger.fine { "Found ${brokenMethods.size} methods" }
/** /**
* Make a method public. * Make a method public.