Skip to content

Commit

Permalink
refactor: simplify code by removing the with block
Browse files Browse the repository at this point in the history
  • Loading branch information
oSumAtrIX committed Jun 11, 2022
1 parent 2dcbd8d commit afcba5c
Showing 1 changed file with 20 additions and 15 deletions.
35 changes: 20 additions & 15 deletions src/main/kotlin/app/revanced/patcher/Patcher.kt
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import org.jf.dexlib2.iface.ClassDef
import org.jf.dexlib2.iface.DexFile
import org.jf.dexlib2.writer.io.MemoryDataStore
import java.io.File
import java.nio.file.Files

val NAMER = BasicDexFileNamer()

Expand Down Expand Up @@ -162,23 +163,27 @@ class Patcher(

ResXmlPatcher.fixingPublicAttrsInProviderAttributes(manifestFile)

with(cacheDirectory.resolve("aapt_temp_file")) {
val resDirectory = cacheDirectory.resolve("res")
val includedFiles = metaInfo.usesFramework.ids.map { id ->
androlibResources.getFrameworkApk(
id,
metaInfo.usesFramework.tag
)
}.toTypedArray()

androlibResources.aaptPackage(
this, manifestFile, resDirectory, null,
null, includedFiles
val aaptFile = cacheDirectory.resolve("aapt_temp_file")

// delete if it exists
Files.deleteIfExists(aaptFile.toPath())

val resDirectory = cacheDirectory.resolve("res")
val includedFiles = metaInfo.usesFramework.ids.map { id ->
androlibResources.getFrameworkApk(
id,
metaInfo.usesFramework.tag
)
}.toTypedArray()

androlibResources.aaptPackage(
aaptFile, manifestFile, resDirectory, null,
null, includedFiles
)

// write packaged resources to cache directory
ExtFile(aaptFile).directory.copyToDir(cacheDirectory.resolve("build/"))

// write packaged resources to cache directory
ExtFile(this).directory.copyToDir(cacheDirectory.resolve("build/"))
}
}

val newDexFile = object : DexFile {
Expand Down

0 comments on commit afcba5c

Please sign in to comment.