mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-06-12 21:27:43 +02:00
refactor: move the patch to the correct path
This commit is contained in:
@ -14,6 +14,10 @@ fun Method.isWideLiteralExists(value: Long): Boolean {
|
||||
return getWideLiteralIndex(value) != -1
|
||||
}
|
||||
|
||||
fun Method.isWide32LiteralExists(value: Long): Boolean {
|
||||
return getWide32LiteralIndex(value) != -1
|
||||
}
|
||||
|
||||
fun Method.getNarrowLiteralIndex(value: Int): Int {
|
||||
return implementation?.let {
|
||||
it.instructions.indexOfFirst { instruction ->
|
||||
@ -41,3 +45,12 @@ fun Method.getWideLiteralIndex(value: Long): Int {
|
||||
} ?: -1
|
||||
}
|
||||
|
||||
fun Method.getWide32LiteralIndex(value: Long): Int {
|
||||
return implementation?.let {
|
||||
it.instructions.indexOfFirst { instruction ->
|
||||
instruction.opcode == Opcode.CONST_WIDE_32
|
||||
&& (instruction as WideLiteralInstruction).wideLiteral == value
|
||||
}
|
||||
} ?: -1
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
package app.revanced.util.enum
|
||||
|
||||
internal enum class ResourceType(val value: String) {
|
||||
ATTR("attr"),
|
||||
BOOL("bool"),
|
||||
COLOR("color"),
|
||||
DIMEN("dimen"),
|
||||
|
@ -1,5 +1,6 @@
|
||||
package app.revanced.util.microg
|
||||
|
||||
import app.revanced.extensions.toErrorResult
|
||||
import app.revanced.patcher.data.BytecodeContext
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction
|
||||
@ -53,23 +54,26 @@ internal object MicroGBytecodeHelper {
|
||||
* Patch the prime method to accept the new package name.
|
||||
*/
|
||||
fun transformPrimeMethodPackageName() {
|
||||
val primeMethod = primeMethodFingerprint.result!!.mutableMethod
|
||||
val implementation = primeMethod.implementation!!
|
||||
primeMethodFingerprint.result?.let {
|
||||
var targetRegister = 2
|
||||
|
||||
var register = 2
|
||||
val index = implementation.instructions.indexOfFirst {
|
||||
if (it.opcode != Opcode.CONST_STRING) return@indexOfFirst false
|
||||
it.mutableMethod.apply {
|
||||
val targetIndex = implementation!!.instructions.indexOfFirst { instructions ->
|
||||
if (instructions.opcode != Opcode.CONST_STRING) return@indexOfFirst false
|
||||
|
||||
val instructionString = ((it as Instruction21c).reference as StringReference).string
|
||||
if (instructionString != fromPackageName) return@indexOfFirst false
|
||||
val instructionString = ((instructions as Instruction21c).reference as StringReference).string
|
||||
if (instructionString != fromPackageName) return@indexOfFirst false
|
||||
|
||||
register = it.registerA
|
||||
return@indexOfFirst true
|
||||
}
|
||||
targetRegister = instructions.registerA
|
||||
return@indexOfFirst true
|
||||
}
|
||||
|
||||
primeMethod.replaceInstruction(
|
||||
index, "const-string v$register, \"$toPackageName\""
|
||||
)
|
||||
replaceInstruction(
|
||||
targetIndex,
|
||||
"const-string v$targetRegister, \"$toPackageName\""
|
||||
)
|
||||
}
|
||||
} ?: throw primeMethodFingerprint.toErrorResult()
|
||||
}
|
||||
}
|
||||
|
||||
@ -206,24 +210,27 @@ internal object MicroGBytecodeHelper {
|
||||
*/
|
||||
private fun List<MethodFingerprint>.returnEarly() {
|
||||
this.forEach { fingerprint ->
|
||||
val result = fingerprint.result!!
|
||||
val stringInstructions = when (result.method.returnType.first()) {
|
||||
'L' -> """
|
||||
fingerprint.result?.let {
|
||||
it.mutableMethod.apply {
|
||||
val stringInstructions = when (it.method.returnType.first()) {
|
||||
'L' -> """
|
||||
const/4 v0, 0x0
|
||||
return-object v0
|
||||
"""
|
||||
|
||||
'V' -> "return-void"
|
||||
'I' -> """
|
||||
'V' -> "return-void"
|
||||
'I' -> """
|
||||
const/4 v0, 0x0
|
||||
return v0
|
||||
"""
|
||||
|
||||
else -> throw Exception("This case should never happen.")
|
||||
}
|
||||
result.mutableMethod.addInstructions(
|
||||
0, stringInstructions
|
||||
)
|
||||
else -> throw Exception("This case should never happen.")
|
||||
}
|
||||
addInstructions(
|
||||
0, stringInstructions
|
||||
)
|
||||
}
|
||||
} ?: throw fingerprint.toErrorResult()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package app.revanced.util.resources
|
||||
|
||||
import app.revanced.patcher.data.ResourceContext
|
||||
import org.w3c.dom.Element
|
||||
import java.io.File
|
||||
import java.nio.file.Files
|
||||
import java.nio.file.Paths
|
||||
@ -98,9 +99,7 @@ internal object IconHelper {
|
||||
iconName
|
||||
)
|
||||
|
||||
this["res/values-v31/styles.xml"].writeText(
|
||||
this["res/values-v31/styles.xml"].readText().replace("<item name=\"android:windowSplashScreenAnimatedIcon\">@drawable/avd_anim</item>", "")
|
||||
)
|
||||
this.disableSplashAnimation()
|
||||
}
|
||||
|
||||
internal fun ResourceContext.customIconMusic(iconName: String) {
|
||||
@ -219,4 +218,15 @@ internal object IconHelper {
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private fun ResourceContext.disableSplashAnimation() {
|
||||
val targetPath = "res/values-v31/styles.xml"
|
||||
|
||||
xmlEditor[targetPath].use { editor ->
|
||||
val tags = editor.file.getElementsByTagName("item")
|
||||
List(tags.length) { tags.item(it) as Element }
|
||||
.filter { it.getAttribute("name").contains("android:windowSplashScreenAnimatedIcon") }
|
||||
.forEach { it.parentNode.removeChild(it) }
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user