add: resource patcher
Signed-off-by: oSumAtrIX <johan.melkonyan1@web.de>
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
package app.revanced.patches.youtube.misc
|
||||
|
||||
import app.revanced.patcher.data.implementation.ResourceData
|
||||
import app.revanced.patcher.patch.implementation.ResourcePatch
|
||||
import app.revanced.patcher.patch.implementation.metadata.PackageMetadata
|
||||
import app.revanced.patcher.patch.implementation.metadata.PatchMetadata
|
||||
import app.revanced.patcher.patch.implementation.misc.PatchResult
|
||||
import app.revanced.patcher.patch.implementation.misc.PatchResultSuccess
|
||||
import com.sun.org.apache.xerces.internal.dom.ElementImpl
|
||||
|
||||
private val compatiblePackages = listOf(
|
||||
PackageMetadata(
|
||||
"com.google.android.youtube",
|
||||
listOf("17.14.35")
|
||||
)
|
||||
)
|
||||
class FixLocaleConfigErrorPatch : ResourcePatch(
|
||||
PatchMetadata(
|
||||
"locale-config-fix",
|
||||
"Manifest attribute fix patch",
|
||||
"Fix an error when building the resources by patching the manifest file.",
|
||||
compatiblePackages,
|
||||
"0.0.1"
|
||||
),
|
||||
) {
|
||||
override fun execute(data: ResourceData): PatchResult {
|
||||
// create an xml editor instance
|
||||
val editor = data.getXmlEditor("AndroidManifest.xml")
|
||||
|
||||
// edit the application nodes attribute...
|
||||
val applicationNode = editor
|
||||
.file
|
||||
.getElementsByTagName("application")
|
||||
.item(0) as ElementImpl
|
||||
|
||||
// by replacing the attributes name
|
||||
val attribute = "android:localeConfig"
|
||||
applicationNode.setAttribute("localeConfig", applicationNode.getAttribute(attribute))
|
||||
applicationNode.removeAttribute("android:localeConfig")
|
||||
|
||||
// close & save the modified file
|
||||
editor.close()
|
||||
|
||||
return PatchResultSuccess()
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,13 @@
|
||||
package app.revanced.patches.youtube.misc
|
||||
|
||||
import app.revanced.patcher.PatcherData
|
||||
import app.revanced.patcher.data.implementation.BytecodeData
|
||||
import app.revanced.patcher.extensions.addInstructions
|
||||
import app.revanced.patcher.extensions.or
|
||||
import app.revanced.patcher.patch.*
|
||||
import app.revanced.patcher.patch.implementation.BytecodePatch
|
||||
import app.revanced.patcher.patch.implementation.metadata.PackageMetadata
|
||||
import app.revanced.patcher.patch.implementation.metadata.PatchMetadata
|
||||
import app.revanced.patcher.patch.implementation.misc.PatchResult
|
||||
import app.revanced.patcher.patch.implementation.misc.PatchResultSuccess
|
||||
import app.revanced.patcher.proxy.mutableTypes.MutableMethod.Companion.toMutable
|
||||
import app.revanced.patcher.signature.MethodMetadata
|
||||
import app.revanced.patcher.signature.MethodSignature
|
||||
@@ -22,7 +26,7 @@ private val compatiblePackages = listOf(
|
||||
)
|
||||
)
|
||||
|
||||
class IntegrationsPatch : Patch(
|
||||
class IntegrationsPatch : BytecodePatch(
|
||||
PatchMetadata(
|
||||
"integrations",
|
||||
"Inject Integrations Patch",
|
||||
@@ -80,7 +84,7 @@ class IntegrationsPatch : Patch(
|
||||
)
|
||||
)
|
||||
) {
|
||||
override fun execute(patcherData: PatcherData): PatchResult {
|
||||
override fun execute(data: BytecodeData): PatchResult {
|
||||
val result = signatures.first().result!!
|
||||
|
||||
val implementation = result.method.implementation!!
|
||||
|
||||
Reference in New Issue
Block a user