mirror of
https://github.com/revanced/revanced-patcher.git
synced 2025-05-08 08:04:25 +02:00
Merge remote-tracking branch 'origin/non-root' into non-root
# Conflicts: # src/main/kotlin/app/revanced/patcher/Patcher.kt
This commit is contained in:
commit
81895c7d5c
@ -64,9 +64,10 @@ class Patcher(
|
||||
androlib.decodeResourcesFull(extInputFile, outDir, resourceTable)
|
||||
|
||||
// read additional metadata from the resource table
|
||||
packageMetadata.metaInfo.usesFramework = UsesFramework().also { usesFramework ->
|
||||
usesFramework.ids = resourceTable.listFramePackages().map { it.id }.sorted()
|
||||
packageMetadata.metaInfo.usesFramework = UsesFramework().also { framework ->
|
||||
framework.ids = resourceTable.listFramePackages().map { it.id }.sorted()
|
||||
}
|
||||
|
||||
packageMetadata.metaInfo.doNotCompress = buildList {
|
||||
androlib.recordUncompressedFiles(extInputFile, this)
|
||||
}
|
||||
@ -95,10 +96,9 @@ class Patcher(
|
||||
packageMetadata.metaInfo.sdkInfo = resourceTable.sdkInfo
|
||||
|
||||
// read dex files
|
||||
val dexFile = MultiDexIO.readDexFile(true, options.inputFile, NAMER, null, null).also { dexFile ->
|
||||
val dexFile = MultiDexIO.readDexFile(true, options.inputFile, NAMER, null, null)
|
||||
// get the opcodes
|
||||
opcodes = dexFile.opcodes
|
||||
}
|
||||
|
||||
// finally create patcher data
|
||||
data = PatcherData(
|
||||
@ -116,10 +116,8 @@ class Patcher(
|
||||
files: List<File>, allowedOverwrites: Iterable<String> = emptyList(), throwOnDuplicates: Boolean = false
|
||||
) {
|
||||
for (file in files) {
|
||||
MultiDexIO.readDexFile(true, file, NAMER, null, null).let { dexFile ->
|
||||
for (classDef in dexFile.classes) {
|
||||
val e =
|
||||
data.bytecodeData.classes.internalClasses.findIndexed { internalClass -> internalClass.type == classDef.type }
|
||||
for (classDef in MultiDexIO.readDexFile(true, file, NAMER, null, null).classes) {
|
||||
val e = data.bytecodeData.classes.internalClasses.findIndexed { it.type == classDef.type }
|
||||
if (e != null) {
|
||||
if (throwOnDuplicates) {
|
||||
throw Exception("Class ${classDef.type} has already been added to the patcher.")
|
||||
@ -134,7 +132,6 @@ class Patcher(
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Save the patched dex file.
|
||||
@ -165,21 +162,22 @@ class Patcher(
|
||||
|
||||
ResXmlPatcher.fixingPublicAttrsInProviderAttributes(manifestFile)
|
||||
|
||||
cacheDirectory.resolve("aapt_temp_file").let { temporalFile ->
|
||||
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()
|
||||
val includedFiles = metaInfo.usesFramework.ids.map { id ->
|
||||
androlibResources.getFrameworkApk(
|
||||
id,
|
||||
metaInfo.usesFramework.tag
|
||||
)
|
||||
}.toTypedArray()
|
||||
|
||||
androlibResources.aaptPackage(
|
||||
temporalFile, manifestFile, resDirectory, null,
|
||||
this, manifestFile, resDirectory, null,
|
||||
null, includedFiles
|
||||
)
|
||||
|
||||
// write packaged resources to cache directory
|
||||
// TODO: consider returning a list of the files instead of extracting them to the cache directory,
|
||||
// less disk but more ram usage
|
||||
ExtFile(temporalFile).directory.copyToDir(cacheDirectory.resolve("build/"))
|
||||
ExtFile(this).directory.copyToDir(cacheDirectory.resolve("build/"))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -76,10 +76,9 @@ internal class MethodSignatureResolver(
|
||||
signature.strings?.let { strings ->
|
||||
method.implementation ?: return null
|
||||
|
||||
method.implementation!!.instructions.let { instructions ->
|
||||
val stringsList = strings.toMutableList()
|
||||
|
||||
for (instruction in instructions) {
|
||||
for (instruction in method.implementation!!.instructions) {
|
||||
if (instruction.opcode != Opcode.CONST_STRING) continue
|
||||
|
||||
val string = ((instruction as Instruction21c).reference as StringReference).string
|
||||
@ -89,7 +88,6 @@ internal class MethodSignatureResolver(
|
||||
|
||||
if (stringsList.isNotEmpty()) return null
|
||||
}
|
||||
}
|
||||
|
||||
return if (signature.opcodes == null) {
|
||||
PatternScanResult(0, 0)
|
||||
|
Loading…
x
Reference in New Issue
Block a user