mirror of
https://github.com/ReVanced/revanced-patcher.git
synced 2026-01-28 21:51:02 +00:00
refactor: use apktool fork
also fixed some compilation issues
This commit is contained in:
@@ -5,6 +5,7 @@ import app.revanced.patcher.data.PatcherData
|
||||
import app.revanced.patcher.data.base.Data
|
||||
import app.revanced.patcher.data.implementation.findIndexed
|
||||
import app.revanced.patcher.extensions.findAnnotationRecursively
|
||||
import app.revanced.patcher.extensions.nullOutputStream
|
||||
import app.revanced.patcher.patch.base.Patch
|
||||
import app.revanced.patcher.patch.implementation.BytecodePatch
|
||||
import app.revanced.patcher.patch.implementation.ResourcePatch
|
||||
@@ -28,7 +29,6 @@ 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.io.OutputStream
|
||||
|
||||
val NAMER = BasicDexFileNamer()
|
||||
|
||||
@@ -41,7 +41,8 @@ val NAMER = BasicDexFileNamer()
|
||||
class Patcher(
|
||||
inputFile: File,
|
||||
// TODO: maybe a file system in memory is better. Could cause high memory usage.
|
||||
private val resourceCacheDirectory: String, private val patchResources: Boolean = false
|
||||
private val resourceCacheDirectory: String,
|
||||
private val patchResources: Boolean = false
|
||||
) {
|
||||
val packageVersion: String
|
||||
val packageName: String
|
||||
@@ -51,7 +52,6 @@ class Patcher(
|
||||
private val opcodes: Opcodes
|
||||
private var signaturesResolved = false
|
||||
|
||||
|
||||
init {
|
||||
val extFileInput = ExtFile(inputFile)
|
||||
val outDir = File(resourceCacheDirectory)
|
||||
@@ -85,7 +85,7 @@ class Patcher(
|
||||
XmlPullStreamDecoder(
|
||||
axmlParser, AndrolibResources().resXmlSerializer
|
||||
).decodeManifest(
|
||||
extFileInput.directory.getFileInput("AndroidManifest.xml"), OutputStream.nullOutputStream()
|
||||
extFileInput.directory.getFileInput("AndroidManifest.xml"), nullOutputStream
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ import org.jf.dexlib2.iface.reference.MethodReference
|
||||
import org.jf.dexlib2.immutable.ImmutableMethod
|
||||
import org.jf.dexlib2.immutable.ImmutableMethodImplementation
|
||||
import org.jf.dexlib2.util.MethodUtil
|
||||
import java.io.OutputStream
|
||||
|
||||
/**
|
||||
* Recursively find a given annotation on a class
|
||||
@@ -105,4 +106,9 @@ internal fun parametersEqual(
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal val nullOutputStream: OutputStream =
|
||||
object : OutputStream() {
|
||||
override fun write(b: Int) {}
|
||||
}
|
||||
@@ -19,7 +19,7 @@ object PatchLoader {
|
||||
val entry = entries.nextElement()
|
||||
if (!entry.name.endsWith(".class") || entry.name.contains("$")) continue
|
||||
|
||||
val clazz = classLoader.loadClass(entry.realName.replace('/', '.').replace(".class", ""))
|
||||
val clazz = classLoader.loadClass(entry.name.replace('/', '.').replace(".class", ""))
|
||||
|
||||
if (!clazz.isAnnotationPresent(app.revanced.patcher.patch.annotations.Patch::class.java)) continue
|
||||
|
||||
|
||||
Reference in New Issue
Block a user