build: bump patcher to 14.2.2

This commit is contained in:
inotia00 2023-09-05 01:37:09 +09:00
parent 357c5593f9
commit 994c5d197d
220 changed files with 727 additions and 1763 deletions

View File

@ -2,30 +2,31 @@ plugins {
kotlin("jvm") version "1.9.0" kotlin("jvm") version "1.9.0"
} }
group = "io.github.inotia00" group = "app.revanced"
val githubUsername: String = project.findProperty("gpr.user") as? String ?: System.getenv("GITHUB_ACTOR")
val githubPassword: String = project.findProperty("gpr.key") as? String ?: System.getenv("GITHUB_TOKEN")
repositories { repositories {
google() google()
mavenCentral() mavenCentral()
mavenLocal() mavenLocal()
maven { url = uri("https://s01.oss.sonatype.org/content/repositories/snapshots") }
maven { maven {
url = uri("https://repo.sleeping.town") url = uri("https://maven.pkg.github.com/revanced/revanced-patcher")
content { credentials {
includeGroup("com.unascribed") username = githubUsername
password = githubPassword
} }
} }
} }
dependencies { dependencies {
implementation("io.github.inotia00:revanced-patcher:11.0.6-SNAPSHOT") implementation("app.revanced:revanced-patcher:14.2.2")
implementation("com.android.tools.smali:smali:3.0.3") implementation("com.android.tools.smali:smali:3.0.3")
implementation("com.android.tools.smali:smali-dexlib2:3.0.3") implementation("com.android.tools.smali:smali-dexlib2:3.0.3")
// Required for meta // Required for meta
implementation("com.google.code.gson:gson:2.10.1") implementation("com.google.code.gson:gson:2.10.1")
// Required for FlexVer-Java
implementation("com.unascribed:flexver-java:1.1.0")
} }
tasks { tasks {

View File

@ -1,8 +1,9 @@
package app.revanced.extensions package app.revanced.extensions
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.MethodFingerprintExtensions.name import app.revanced.patcher.extensions.MethodFingerprintExtensions.name
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import app.revanced.patcher.patch.PatchResultError import app.revanced.patcher.patch.PatchException
import app.revanced.patcher.util.proxy.mutableTypes.MutableClass import app.revanced.patcher.util.proxy.mutableTypes.MutableClass
import app.revanced.patcher.util.proxy.mutableTypes.MutableField import app.revanced.patcher.util.proxy.mutableTypes.MutableField
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
@ -25,13 +26,13 @@ internal fun MutableMethodImplementation.injectHideCall(
) )
} }
// TODO: populate this to all patches
/** /**
* Convert a [MethodFingerprint] to a [PatchResultError]. * Return [PatchException] from a [MethodFingerprint].
* *
* @return A [PatchResultError] for the [MethodFingerprint]. * @return The [PatchException] for the [MethodFingerprint].
*/ */
fun MethodFingerprint.toErrorResult() = PatchResultError("Failed to resolve $name") val MethodFingerprint.exception
get() = PatchException("Failed to resolve $name")
/** /**
* Find the [MutableMethod] from a given [Method] in a [MutableClass]. * Find the [MutableMethod] from a given [Method] in a [MutableClass].
@ -65,6 +66,22 @@ fun MutableClass.transformFields(transform: MutableField.() -> MutableField) {
fields.addAll(transformedFields) fields.addAll(transformedFields)
} }
/**
* traverse the class hierarchy starting from the given root class
*
* @param targetClass the class to start traversing the class hierarchy from
* @param callback function that is called for every class in the hierarchy
*/
fun BytecodeContext.traverseClassHierarchy(
targetClass: MutableClass,
callback: MutableClass.() -> Unit
) {
callback(targetClass)
this.findClass(targetClass.superclass ?: return)?.mutableClass?.let {
traverseClassHierarchy(it, callback)
}
}
internal fun Node.doRecursively(action: (Node) -> Unit) { internal fun Node.doRecursively(action: (Node) -> Unit) {
action(this) action(this)
for (i in 0 until this.childNodes.length) this.childNodes.item(i).doRecursively(action) for (i in 0 until this.childNodes.length) this.childNodes.item(i).doRecursively(action)

View File

@ -6,7 +6,6 @@ import app.revanced.patcher.extensions.PatchExtensions.description
import app.revanced.patcher.extensions.PatchExtensions.include import app.revanced.patcher.extensions.PatchExtensions.include
import app.revanced.patcher.extensions.PatchExtensions.options import app.revanced.patcher.extensions.PatchExtensions.options
import app.revanced.patcher.extensions.PatchExtensions.patchName import app.revanced.patcher.extensions.PatchExtensions.patchName
import app.revanced.patcher.extensions.PatchExtensions.version
import app.revanced.patcher.patch.PatchOption import app.revanced.patcher.patch.PatchOption
import com.google.gson.GsonBuilder import com.google.gson.GsonBuilder
import java.io.File import java.io.File
@ -17,7 +16,6 @@ internal class JsonGenerator : PatchesFileGenerator {
JsonPatch( JsonPatch(
it.patchName, it.patchName,
it.description ?: "This patch has no description.", it.description ?: "This patch has no description.",
it.version ?: "0.0.0",
!it.include, !it.include,
it.options?.map { option -> it.options?.map { option ->
JsonPatch.Option( JsonPatch.Option(
@ -48,7 +46,6 @@ internal class JsonGenerator : PatchesFileGenerator {
private class JsonPatch( private class JsonPatch(
val name: String, val name: String,
val description: String, val description: String,
val version: String,
val excluded: Boolean, val excluded: Boolean,
val options: Array<Option>, val options: Array<Option>,
val dependencies: Array<String>, val dependencies: Array<String>,

View File

@ -1,25 +1,22 @@
package app.revanced.meta package app.revanced.meta
import app.revanced.patcher.data.Context import app.revanced.patcher.PatchBundleLoader
import app.revanced.patcher.patch.Patch import app.revanced.patcher.patch.PatchClass
import app.revanced.patcher.util.patch.PatchBundle
import java.io.File import java.io.File
internal typealias PatchBundlePatches = List<Class<out Patch<Context>>> internal typealias PatchBundlePatches = List<PatchClass>
internal interface PatchesFileGenerator { internal interface PatchesFileGenerator {
fun generate(bundle: PatchBundlePatches) fun generate(bundle: PatchBundlePatches)
private companion object { private companion object {
@JvmStatic @JvmStatic
fun main(args: Array<String>) = PatchBundle.Jar( fun main(args: Array<String>) = PatchBundleLoader.Jar(
File("build/libs/").listFiles()!!.first { File("build/libs/").listFiles { it -> it.name.endsWith(".jar") }!!.first()
it.name.startsWith("revanced-patches-") && it.name.endsWith(".jar") ).also { loader ->
}.absolutePath if (loader.isEmpty()) throw IllegalStateException("No patches found")
).loadPatches().also {
if (it.isEmpty()) throw IllegalStateException("No patches found")
}.let { bundle -> }.let { bundle ->
arrayOf(JsonGenerator(), ReadmeGenerator()).forEach { it.generate(bundle) } arrayOf(JsonGenerator()).forEach { generator -> generator.generate(bundle) }
} }
} }
} }

View File

@ -1,69 +0,0 @@
package app.revanced.meta
import app.revanced.patcher.data.Context
import app.revanced.patcher.extensions.PatchExtensions.compatiblePackages
import app.revanced.patcher.extensions.PatchExtensions.description
import app.revanced.patcher.extensions.PatchExtensions.patchName
import app.revanced.patcher.patch.Patch
import com.unascribed.flexver.FlexVerComparator
import java.io.File
internal class ReadmeGenerator : PatchesFileGenerator {
private companion object {
private const val TABLE_HEADER =
"| \uD83D\uDC8A Patch | \uD83D\uDCDC Description | \uD83C\uDFF9 Target Version |\n" +
"|:--------:|:--------------:|:-----------------:|"
}
override fun generate(bundle: PatchBundlePatches) {
val output = StringBuilder()
mutableMapOf<String, MutableList<Class<out Patch<Context>>>>()
.apply {
for (patch in bundle) {
patch.compatiblePackages?.forEach { pkg ->
if (!contains(pkg.name)) put(pkg.name, mutableListOf())
this[pkg.name]!!.add(patch)
}
}
}
.entries
.sortedByDescending { it.value.size }
.forEach { (`package`, patches) ->
val mostCommonVersion = buildMap {
patches.forEach { patch ->
patch.compatiblePackages?.single { compatiblePackage -> compatiblePackage.name == `package` }?.versions?.let {
it.forEach { version -> merge(version, 1, Integer::sum) }
}
}
}.let { commonMap ->
commonMap.maxByOrNull { it.value }?.value?.let {
commonMap.entries.filter { mostCommon -> mostCommon.value == it }
.maxOfWith(FlexVerComparator::compare, Map.Entry<String, Int>::key)
} ?: "all"
}
output.apply {
appendLine("### [\uD83D\uDCE6 `${`package`}`](https://play.google.com/store/apps/details?id=${`package`})")
appendLine("<details>\n")
appendLine(TABLE_HEADER)
patches.forEach { patch ->
val recommendedPatchVersion = if (
patch.compatiblePackages?.single { it.name == `package` }?.versions?.isNotEmpty() == true
) mostCommonVersion else "all"
appendLine(
"| `${patch.patchName.lowercase().replace(" ", "-")}` " +
"| ${patch.description} " +
"| $recommendedPatchVersion |"
)
}
appendLine("</details>\n")
}
}
StringBuilder(File("README-template.md").readText())
.replace(Regex("\\{\\{\\s?table\\s?}}"), output.toString())
.let(File("README.md")::writeText)
}
}

View File

@ -2,10 +2,7 @@ package app.revanced.patches.music.ads.music.patch
import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.music.utils.annotations.MusicCompatibility import app.revanced.patches.music.utils.annotations.MusicCompatibility
@ -25,18 +22,16 @@ import app.revanced.util.integrations.Constants.MUSIC_ADS_PATH
] ]
) )
@MusicCompatibility @MusicCompatibility
@Version("0.0.1")
class MusicAdsPatch : AbstractAdsPatch( class MusicAdsPatch : AbstractAdsPatch(
"$MUSIC_ADS_PATH/HideMusicAdsPatch;->hideMusicAds()Z" "$MUSIC_ADS_PATH/HideMusicAdsPatch;->hideMusicAds()Z"
) { ) {
override fun execute(context: BytecodeContext): PatchResult { override fun execute(context: BytecodeContext) {
super.execute(context) super.execute(context)
SettingsPatch.addMusicPreference(CategoryType.ADS, "revanced_hide_music_ads", "true") SettingsPatch.addMusicPreference(CategoryType.ADS, "revanced_hide_music_ads", "true")
LithoFilterPatch.addFilter(FILTER_CLASS_DESCRIPTOR) LithoFilterPatch.addFilter(FILTER_CLASS_DESCRIPTOR)
return PatchResultSuccess()
} }
private companion object { private companion object {

View File

@ -2,10 +2,7 @@ package app.revanced.patches.music.layout.amoled.patch
import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.ResourceContext import app.revanced.patcher.data.ResourceContext
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.ResourcePatch
import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch import app.revanced.patcher.patch.annotations.Patch
@ -18,9 +15,8 @@ import org.w3c.dom.Element
@Description("Applies pure black theme in flyout panels.") @Description("Applies pure black theme in flyout panels.")
@DependsOn([DecodingPatch::class]) @DependsOn([DecodingPatch::class])
@MusicCompatibility @MusicCompatibility
@Version("0.0.1")
class AmoledPatch : ResourcePatch { class AmoledPatch : ResourcePatch {
override fun execute(context: ResourceContext): PatchResult { override fun execute(context: ResourceContext) {
context.xmlEditor["res/values/colors.xml"].use { editor -> context.xmlEditor["res/values/colors.xml"].use { editor ->
val resourcesNode = editor.file.getElementsByTagName("resources").item(0) as Element val resourcesNode = editor.file.getElementsByTagName("resources").item(0) as Element
@ -37,6 +33,5 @@ class AmoledPatch : ResourcePatch {
} }
} }
return PatchResultSuccess()
} }
} }

View File

@ -1,15 +1,12 @@
package app.revanced.patches.music.layout.autocaptions.patch package app.revanced.patches.music.layout.autocaptions.patch
import app.revanced.extensions.toErrorResult import app.revanced.extensions.exception
import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.music.utils.annotations.MusicCompatibility import app.revanced.patches.music.utils.annotations.MusicCompatibility
@ -24,11 +21,10 @@ import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
@Description("Disables forced auto captions.") @Description("Disables forced auto captions.")
@DependsOn([SettingsPatch::class]) @DependsOn([SettingsPatch::class])
@MusicCompatibility @MusicCompatibility
@Version("0.0.1")
class DisableAutoCaptionsPatch : BytecodePatch( class DisableAutoCaptionsPatch : BytecodePatch(
listOf(SubtitleTrackFingerprint) listOf(SubtitleTrackFingerprint)
) { ) {
override fun execute(context: BytecodeContext): PatchResult { override fun execute(context: BytecodeContext) {
SubtitleTrackFingerprint.result?.let { SubtitleTrackFingerprint.result?.let {
it.mutableMethod.apply { it.mutableMethod.apply {
@ -42,7 +38,7 @@ class DisableAutoCaptionsPatch : BytecodePatch(
""" """
) )
} }
} ?: return SubtitleTrackFingerprint.toErrorResult() } ?: throw SubtitleTrackFingerprint.exception
SettingsPatch.addMusicPreference( SettingsPatch.addMusicPreference(
CategoryType.LAYOUT, CategoryType.LAYOUT,
@ -50,6 +46,5 @@ class DisableAutoCaptionsPatch : BytecodePatch(
"false" "false"
) )
return PatchResultSuccess()
} }
} }

View File

@ -1,15 +1,12 @@
package app.revanced.patches.music.layout.blacknavigationbar.patch package app.revanced.patches.music.layout.blacknavigationbar.patch
import app.revanced.extensions.toErrorResult import app.revanced.extensions.exception
import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.music.layout.blacknavbar.fingerprints.TabLayoutFingerprint import app.revanced.patches.music.layout.blacknavbar.fingerprints.TabLayoutFingerprint
@ -30,11 +27,10 @@ import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
] ]
) )
@MusicCompatibility @MusicCompatibility
@Version("0.0.1")
class BlackNavigationBarPatch : BytecodePatch( class BlackNavigationBarPatch : BytecodePatch(
listOf(TabLayoutFingerprint) listOf(TabLayoutFingerprint)
) { ) {
override fun execute(context: BytecodeContext): PatchResult { override fun execute(context: BytecodeContext) {
TabLayoutFingerprint.result?.let { TabLayoutFingerprint.result?.let {
it.mutableMethod.apply { it.mutableMethod.apply {
@ -48,7 +44,7 @@ class BlackNavigationBarPatch : BytecodePatch(
""" """
) )
} }
} ?: return TabLayoutFingerprint.toErrorResult() } ?: throw TabLayoutFingerprint.exception
SettingsPatch.addMusicPreference( SettingsPatch.addMusicPreference(
CategoryType.LAYOUT, CategoryType.LAYOUT,
@ -56,6 +52,5 @@ class BlackNavigationBarPatch : BytecodePatch(
"true" "true"
) )
return PatchResultSuccess()
} }
} }

View File

@ -2,10 +2,7 @@ package app.revanced.patches.music.layout.branding.icon.patch
import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.ResourceContext import app.revanced.patcher.data.ResourceContext
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.ResourcePatch
import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch import app.revanced.patcher.patch.annotations.Patch
@ -19,14 +16,12 @@ import app.revanced.util.resources.IconHelper.customIconMusicAdditional
@Description("Changes the YouTube Music launcher icon to MMT.") @Description("Changes the YouTube Music launcher icon to MMT.")
@DependsOn([DecodingPatch::class]) @DependsOn([DecodingPatch::class])
@MusicCompatibility @MusicCompatibility
@Version("0.0.1")
class CustomBrandingIconMMTPatch : ResourcePatch { class CustomBrandingIconMMTPatch : ResourcePatch {
override fun execute(context: ResourceContext): PatchResult { override fun execute(context: ResourceContext) {
context.customIconMusic("mmt") context.customIconMusic("mmt")
context.customIconMusicAdditional("mmt") context.customIconMusicAdditional("mmt")
return PatchResultSuccess()
} }
} }

View File

@ -2,10 +2,7 @@ package app.revanced.patches.music.layout.branding.icon.patch
import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.ResourceContext import app.revanced.patcher.data.ResourceContext
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.ResourcePatch
import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch import app.revanced.patcher.patch.annotations.Patch
@ -18,13 +15,11 @@ import app.revanced.util.resources.IconHelper.customIconMusic
@Description("Changes the YouTube Music launcher icon to Revancify Blue.") @Description("Changes the YouTube Music launcher icon to Revancify Blue.")
@DependsOn([DecodingPatch::class]) @DependsOn([DecodingPatch::class])
@MusicCompatibility @MusicCompatibility
@Version("0.0.1")
class CustomBrandingIconRevancifyBluePatch : ResourcePatch { class CustomBrandingIconRevancifyBluePatch : ResourcePatch {
override fun execute(context: ResourceContext): PatchResult { override fun execute(context: ResourceContext) {
context.customIconMusic("revancify-blue") context.customIconMusic("revancify-blue")
return PatchResultSuccess()
} }
} }

View File

@ -2,10 +2,7 @@ package app.revanced.patches.music.layout.branding.icon.patch
import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.ResourceContext import app.revanced.patcher.data.ResourceContext
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.ResourcePatch
import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch import app.revanced.patcher.patch.annotations.Patch
@ -18,13 +15,11 @@ import app.revanced.util.resources.IconHelper.customIconMusic
@Description("Changes the YouTube Music launcher icon to Revancify Red.") @Description("Changes the YouTube Music launcher icon to Revancify Red.")
@DependsOn([DecodingPatch::class]) @DependsOn([DecodingPatch::class])
@MusicCompatibility @MusicCompatibility
@Version("0.0.1")
class CustomBrandingIconRevancifyRedPatch : ResourcePatch { class CustomBrandingIconRevancifyRedPatch : ResourcePatch {
override fun execute(context: ResourceContext): PatchResult { override fun execute(context: ResourceContext) {
context.customIconMusic("revancify-red") context.customIconMusic("revancify-red")
return PatchResultSuccess()
} }
} }

View File

@ -2,13 +2,10 @@ package app.revanced.patches.music.layout.branding.name.patch
import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.ResourceContext import app.revanced.patcher.data.ResourceContext
import app.revanced.patcher.patch.OptionsContainer import app.revanced.patcher.patch.OptionsContainer
import app.revanced.patcher.patch.PatchException
import app.revanced.patcher.patch.PatchOption import app.revanced.patcher.patch.PatchOption
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultError
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.ResourcePatch
import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch import app.revanced.patcher.patch.annotations.Patch
@ -25,15 +22,14 @@ import app.revanced.patches.music.utils.fix.decoding.patch.DecodingPatch
] ]
) )
@MusicCompatibility @MusicCompatibility
@Version("0.0.1")
class CustomBrandingNamePatch : ResourcePatch { class CustomBrandingNamePatch : ResourcePatch {
override fun execute(context: ResourceContext): PatchResult { override fun execute(context: ResourceContext) {
val longName = MusicLongName val longName = MusicLongName
?: throw PatchResultError("Invalid app name.") ?: throw PatchException("Invalid app name.")
val shortName = MusicShortName val shortName = MusicShortName
?: throw PatchResultError("Invalid app name.") ?: throw PatchException("Invalid app name.")
context.xmlEditor["res/values/strings.xml"].use { editor -> context.xmlEditor["res/values/strings.xml"].use { editor ->
val document = editor.file val document = editor.file
@ -51,7 +47,6 @@ class CustomBrandingNamePatch : ResourcePatch {
} }
} }
return PatchResultSuccess()
} }
companion object : OptionsContainer() { companion object : OptionsContainer() {

View File

@ -1,13 +1,11 @@
package app.revanced.patches.music.layout.branding.name.patch package app.revanced.patches.music.layout.branding.name.patch
import app.revanced.patcher.data.ResourceContext import app.revanced.patcher.data.ResourceContext
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.ResourcePatch
import kotlin.io.path.exists import kotlin.io.path.exists
class RemoveElementsPatch : ResourcePatch { class RemoveElementsPatch : ResourcePatch {
override fun execute(context: ResourceContext): PatchResult { override fun execute(context: ResourceContext) {
LANGUAGE_LIST.forEach { path -> LANGUAGE_LIST.forEach { path ->
val resDirectory = context["res"] val resDirectory = context["res"]
@ -24,7 +22,6 @@ class RemoveElementsPatch : ResourcePatch {
} }
} }
return PatchResultSuccess()
} }
companion object { companion object {

View File

@ -2,11 +2,8 @@ package app.revanced.patches.music.layout.buttonshelf.patch
import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.music.utils.annotations.MusicCompatibility import app.revanced.patches.music.utils.annotations.MusicCompatibility
@ -25,9 +22,8 @@ import app.revanced.util.integrations.Constants.MUSIC_ADS_PATH
] ]
) )
@MusicCompatibility @MusicCompatibility
@Version("0.0.1")
class HideButtonShelfPatch : BytecodePatch() { class HideButtonShelfPatch : BytecodePatch() {
override fun execute(context: BytecodeContext): PatchResult { override fun execute(context: BytecodeContext) {
SettingsPatch.addMusicPreference( SettingsPatch.addMusicPreference(
CategoryType.LAYOUT, CategoryType.LAYOUT,
@ -37,7 +33,6 @@ class HideButtonShelfPatch : BytecodePatch() {
LithoFilterPatch.addFilter(FILTER_CLASS_DESCRIPTOR) LithoFilterPatch.addFilter(FILTER_CLASS_DESCRIPTOR)
return PatchResultSuccess()
} }
private companion object { private companion object {

View File

@ -2,11 +2,8 @@ package app.revanced.patches.music.layout.carouselshelf.patch
import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.music.utils.annotations.MusicCompatibility import app.revanced.patches.music.utils.annotations.MusicCompatibility
@ -25,9 +22,8 @@ import app.revanced.util.integrations.Constants.MUSIC_ADS_PATH
] ]
) )
@MusicCompatibility @MusicCompatibility
@Version("0.0.1")
class HideCarouselShelfPatch : BytecodePatch() { class HideCarouselShelfPatch : BytecodePatch() {
override fun execute(context: BytecodeContext): PatchResult { override fun execute(context: BytecodeContext) {
SettingsPatch.addMusicPreference( SettingsPatch.addMusicPreference(
CategoryType.LAYOUT, CategoryType.LAYOUT,
@ -37,7 +33,6 @@ class HideCarouselShelfPatch : BytecodePatch() {
LithoFilterPatch.addFilter(FILTER_CLASS_DESCRIPTOR) LithoFilterPatch.addFilter(FILTER_CLASS_DESCRIPTOR)
return PatchResultSuccess()
} }
private companion object { private companion object {

View File

@ -1,15 +1,12 @@
package app.revanced.patches.music.layout.castbutton.patch package app.revanced.patches.music.layout.castbutton.patch
import app.revanced.extensions.toErrorResult import app.revanced.extensions.exception
import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve
import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.music.layout.castbutton.fingerprints.HideCastButtonFingerprint import app.revanced.patches.music.layout.castbutton.fingerprints.HideCastButtonFingerprint
@ -24,11 +21,10 @@ import app.revanced.util.integrations.Constants.MUSIC_LAYOUT
@Description("Hides the cast button in the video player and header.") @Description("Hides the cast button in the video player and header.")
@DependsOn([SettingsPatch::class]) @DependsOn([SettingsPatch::class])
@MusicCompatibility @MusicCompatibility
@Version("0.0.1")
class HideCastButtonPatch : BytecodePatch( class HideCastButtonPatch : BytecodePatch(
listOf(HideCastButtonParentFingerprint) listOf(HideCastButtonParentFingerprint)
) { ) {
override fun execute(context: BytecodeContext): PatchResult { override fun execute(context: BytecodeContext) {
HideCastButtonParentFingerprint.result?.let { parentResult -> HideCastButtonParentFingerprint.result?.let { parentResult ->
HideCastButtonFingerprint.also { HideCastButtonFingerprint.also {
@ -41,8 +37,8 @@ class HideCastButtonPatch : BytecodePatch(
invoke-static {p1}, $MUSIC_LAYOUT->hideCastButton(I)I invoke-static {p1}, $MUSIC_LAYOUT->hideCastButton(I)I
move-result p1 move-result p1
""" """
) ?: return HideCastButtonFingerprint.toErrorResult() ) ?: throw HideCastButtonFingerprint.exception
} ?: return HideCastButtonParentFingerprint.toErrorResult() } ?: throw HideCastButtonParentFingerprint.exception
SettingsPatch.addMusicPreference( SettingsPatch.addMusicPreference(
CategoryType.LAYOUT, CategoryType.LAYOUT,
@ -50,6 +46,5 @@ class HideCastButtonPatch : BytecodePatch(
"true" "true"
) )
return PatchResultSuccess()
} }
} }

View File

@ -1,15 +1,12 @@
package app.revanced.patches.music.layout.categorybar.patch package app.revanced.patches.music.layout.categorybar.patch
import app.revanced.extensions.toErrorResult import app.revanced.extensions.exception
import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.music.layout.categorybar.fingerprints.ChipCloudFingerprint import app.revanced.patches.music.layout.categorybar.fingerprints.ChipCloudFingerprint
@ -30,11 +27,10 @@ import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
] ]
) )
@MusicCompatibility @MusicCompatibility
@Version("0.0.1")
class CategoryBarPatch : BytecodePatch( class CategoryBarPatch : BytecodePatch(
listOf(ChipCloudFingerprint) listOf(ChipCloudFingerprint)
) { ) {
override fun execute(context: BytecodeContext): PatchResult { override fun execute(context: BytecodeContext) {
ChipCloudFingerprint.result?.let { ChipCloudFingerprint.result?.let {
it.mutableMethod.apply { it.mutableMethod.apply {
val targetIndex = it.scanResult.patternScanResult!!.endIndex val targetIndex = it.scanResult.patternScanResult!!.endIndex
@ -45,7 +41,7 @@ class CategoryBarPatch : BytecodePatch(
"invoke-static { v$targetRegister }, $MUSIC_LAYOUT->hideCategoryBar(Landroid/view/View;)V" "invoke-static { v$targetRegister }, $MUSIC_LAYOUT->hideCategoryBar(Landroid/view/View;)V"
) )
} }
} ?: return ChipCloudFingerprint.toErrorResult() } ?: throw ChipCloudFingerprint.exception
SettingsPatch.addMusicPreference( SettingsPatch.addMusicPreference(
CategoryType.LAYOUT, CategoryType.LAYOUT,
@ -53,6 +49,5 @@ class CategoryBarPatch : BytecodePatch(
"true" "true"
) )
return PatchResultSuccess()
} }
} }

View File

@ -2,11 +2,8 @@ package app.revanced.patches.music.layout.carouselshelf.patch
import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.music.utils.annotations.MusicCompatibility import app.revanced.patches.music.utils.annotations.MusicCompatibility
@ -25,9 +22,8 @@ import app.revanced.util.integrations.Constants.MUSIC_ADS_PATH
] ]
) )
@MusicCompatibility @MusicCompatibility
@Version("0.0.1")
class HideChannelGuidelinesPatch : BytecodePatch() { class HideChannelGuidelinesPatch : BytecodePatch() {
override fun execute(context: BytecodeContext): PatchResult { override fun execute(context: BytecodeContext) {
SettingsPatch.addMusicPreference( SettingsPatch.addMusicPreference(
CategoryType.LAYOUT, CategoryType.LAYOUT,
@ -37,7 +33,6 @@ class HideChannelGuidelinesPatch : BytecodePatch() {
LithoFilterPatch.addFilter(FILTER_CLASS_DESCRIPTOR) LithoFilterPatch.addFilter(FILTER_CLASS_DESCRIPTOR)
return PatchResultSuccess()
} }
private companion object { private companion object {

View File

@ -1,17 +1,14 @@
package app.revanced.patches.music.layout.colormatchplayer.patch package app.revanced.patches.music.layout.colormatchplayer.patch
import app.revanced.extensions.toErrorResult import app.revanced.extensions.exception
import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.extensions.InstructionExtensions.removeInstruction import app.revanced.patcher.extensions.InstructionExtensions.removeInstruction
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve
import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
@ -30,11 +27,10 @@ import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction
@Description("Matches the color of the mini player and the fullscreen player.") @Description("Matches the color of the mini player and the fullscreen player.")
@DependsOn([SettingsPatch::class]) @DependsOn([SettingsPatch::class])
@MusicCompatibility @MusicCompatibility
@Version("0.0.1")
class ColorMatchPlayerPatch : BytecodePatch( class ColorMatchPlayerPatch : BytecodePatch(
listOf(ColorMatchPlayerParentFingerprint) listOf(ColorMatchPlayerParentFingerprint)
) { ) {
override fun execute(context: BytecodeContext): PatchResult { override fun execute(context: BytecodeContext) {
ColorMatchPlayerParentFingerprint.result?.let { parentResult -> ColorMatchPlayerParentFingerprint.result?.let { parentResult ->
ColorMatchPlayerFingerprint.also { ColorMatchPlayerFingerprint.also {
@ -74,8 +70,8 @@ class ColorMatchPlayerPatch : BytecodePatch(
) )
removeInstruction(insertIndex - 1) removeInstruction(insertIndex - 1)
} }
} ?: return ColorMatchPlayerFingerprint.toErrorResult() } ?: throw ColorMatchPlayerFingerprint.exception
} ?: return ColorMatchPlayerParentFingerprint.toErrorResult() } ?: throw ColorMatchPlayerParentFingerprint.exception
SettingsPatch.addMusicPreference( SettingsPatch.addMusicPreference(
CategoryType.LAYOUT, CategoryType.LAYOUT,
@ -83,7 +79,6 @@ class ColorMatchPlayerPatch : BytecodePatch(
"true" "true"
) )
return PatchResultSuccess()
} }
private companion object { private companion object {

View File

@ -1,15 +1,11 @@
package app.revanced.patches.music.layout.compactdialog.patch package app.revanced.patches.music.layout.compactdialog.patch
import app.revanced.extensions.toErrorResult import app.revanced.extensions.exception
import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.data.toMethodWalker
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
@ -30,11 +26,10 @@ import app.revanced.util.integrations.Constants.MUSIC_LAYOUT
] ]
) )
@MusicCompatibility @MusicCompatibility
@Version("0.0.1")
class CompactDialogPatch : BytecodePatch( class CompactDialogPatch : BytecodePatch(
listOf(DialogSolidFingerprint) listOf(DialogSolidFingerprint)
) { ) {
override fun execute(context: BytecodeContext): PatchResult { override fun execute(context: BytecodeContext) {
DialogSolidFingerprint.result?.let { DialogSolidFingerprint.result?.let {
with( with(
context context
@ -49,7 +44,7 @@ class CompactDialogPatch : BytecodePatch(
""" """
) )
} }
} ?: return DialogSolidFingerprint.toErrorResult() } ?: throw DialogSolidFingerprint.exception
SettingsPatch.addMusicPreference( SettingsPatch.addMusicPreference(
CategoryType.LAYOUT, CategoryType.LAYOUT,
@ -57,6 +52,5 @@ class CompactDialogPatch : BytecodePatch(
"true" "true"
) )
return PatchResultSuccess()
} }
} }

View File

@ -2,10 +2,7 @@ package app.revanced.patches.music.layout.customfilter.patch
import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.ResourceContext import app.revanced.patcher.data.ResourceContext
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.ResourcePatch
import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch import app.revanced.patcher.patch.annotations.Patch
@ -25,9 +22,8 @@ import app.revanced.util.integrations.Constants.MUSIC_ADS_PATH
] ]
) )
@MusicCompatibility @MusicCompatibility
@Version("0.0.1")
class CustomFilterPatch : ResourcePatch { class CustomFilterPatch : ResourcePatch {
override fun execute(context: ResourceContext): PatchResult { override fun execute(context: ResourceContext) {
SettingsPatch.addMusicPreference( SettingsPatch.addMusicPreference(
CategoryType.LAYOUT, CategoryType.LAYOUT,
@ -42,7 +38,6 @@ class CustomFilterPatch : ResourcePatch {
LithoFilterPatch.addFilter(FILTER_CLASS_DESCRIPTOR) LithoFilterPatch.addFilter(FILTER_CLASS_DESCRIPTOR)
return PatchResultSuccess()
} }
private companion object { private companion object {

View File

@ -1,16 +1,13 @@
package app.revanced.patches.music.layout.floatingbutton.patch package app.revanced.patches.music.layout.floatingbutton.patch
import app.revanced.extensions.toErrorResult import app.revanced.extensions.exception
import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve
import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patcher.util.smali.ExternalLabel import app.revanced.patcher.util.smali.ExternalLabel
@ -32,11 +29,10 @@ import app.revanced.util.integrations.Constants.MUSIC_LAYOUT
] ]
) )
@MusicCompatibility @MusicCompatibility
@Version("0.0.1")
class NewPlaylistButtonPatch : BytecodePatch( class NewPlaylistButtonPatch : BytecodePatch(
listOf(FloatingButtonParentFingerprint) listOf(FloatingButtonParentFingerprint)
) { ) {
override fun execute(context: BytecodeContext): PatchResult { override fun execute(context: BytecodeContext) {
FloatingButtonParentFingerprint.result?.let { parentResult -> FloatingButtonParentFingerprint.result?.let { parentResult ->
FloatingButtonFingerprint.also { FloatingButtonFingerprint.also {
@ -55,8 +51,8 @@ class NewPlaylistButtonPatch : BytecodePatch(
""", ExternalLabel("show", getInstruction(1)) """, ExternalLabel("show", getInstruction(1))
) )
} }
} ?: return FloatingButtonFingerprint.toErrorResult() } ?: throw FloatingButtonFingerprint.exception
} ?: return FloatingButtonParentFingerprint.toErrorResult() } ?: throw FloatingButtonParentFingerprint.exception
SettingsPatch.addMusicPreference( SettingsPatch.addMusicPreference(
CategoryType.LAYOUT, CategoryType.LAYOUT,
@ -64,6 +60,5 @@ class NewPlaylistButtonPatch : BytecodePatch(
"false" "false"
) )
return PatchResultSuccess()
} }
} }

View File

@ -1,14 +1,11 @@
package app.revanced.patches.music.layout.landscapemode.patch package app.revanced.patches.music.layout.landscapemode.patch
import app.revanced.extensions.toErrorResult import app.revanced.extensions.exception
import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.music.layout.landscapemode.fingerprints.TabletIdentifierFingerprint import app.revanced.patches.music.layout.landscapemode.fingerprints.TabletIdentifierFingerprint
@ -28,11 +25,10 @@ import app.revanced.util.integrations.Constants.MUSIC_LAYOUT
] ]
) )
@MusicCompatibility @MusicCompatibility
@Version("0.0.1")
class LandScapeModePatch : BytecodePatch( class LandScapeModePatch : BytecodePatch(
listOf(TabletIdentifierFingerprint) listOf(TabletIdentifierFingerprint)
) { ) {
override fun execute(context: BytecodeContext): PatchResult { override fun execute(context: BytecodeContext) {
TabletIdentifierFingerprint.result?.let { TabletIdentifierFingerprint.result?.let {
it.mutableMethod.addInstructions( it.mutableMethod.addInstructions(
it.scanResult.patternScanResult!!.endIndex + 1, """ it.scanResult.patternScanResult!!.endIndex + 1, """
@ -40,7 +36,7 @@ class LandScapeModePatch : BytecodePatch(
move-result p0 move-result p0
""" """
) )
} ?: return TabletIdentifierFingerprint.toErrorResult() } ?: throw TabletIdentifierFingerprint.exception
SettingsPatch.addMusicPreference( SettingsPatch.addMusicPreference(
CategoryType.LAYOUT, CategoryType.LAYOUT,
@ -48,6 +44,5 @@ class LandScapeModePatch : BytecodePatch(
"true" "true"
) )
return PatchResultSuccess()
} }
} }

View File

@ -1,14 +1,11 @@
package app.revanced.patches.music.layout.minimizedplayer.patch package app.revanced.patches.music.layout.minimizedplayer.patch
import app.revanced.extensions.toErrorResult import app.revanced.extensions.exception
import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.music.layout.minimizedplayer.fingerprints.MinimizedPlayerFingerprint import app.revanced.patches.music.layout.minimizedplayer.fingerprints.MinimizedPlayerFingerprint
@ -23,11 +20,10 @@ import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
@Description("Permanently keep player minimized even if another track is played.") @Description("Permanently keep player minimized even if another track is played.")
@DependsOn([SettingsPatch::class]) @DependsOn([SettingsPatch::class])
@MusicCompatibility @MusicCompatibility
@Version("0.0.1")
class MinimizedPlayerPatch : BytecodePatch( class MinimizedPlayerPatch : BytecodePatch(
listOf(MinimizedPlayerFingerprint) listOf(MinimizedPlayerFingerprint)
) { ) {
override fun execute(context: BytecodeContext): PatchResult { override fun execute(context: BytecodeContext) {
MinimizedPlayerFingerprint.result?.let { MinimizedPlayerFingerprint.result?.let {
with(it.mutableMethod) { with(it.mutableMethod) {
@ -42,7 +38,7 @@ class MinimizedPlayerPatch : BytecodePatch(
""" """
) )
} }
} ?: return MinimizedPlayerFingerprint.toErrorResult() } ?: throw MinimizedPlayerFingerprint.exception
SettingsPatch.addMusicPreference( SettingsPatch.addMusicPreference(
CategoryType.LAYOUT, CategoryType.LAYOUT,
@ -50,6 +46,5 @@ class MinimizedPlayerPatch : BytecodePatch(
"true" "true"
) )
return PatchResultSuccess()
} }
} }

View File

@ -1,16 +1,13 @@
package app.revanced.patches.music.layout.navigationlabel.patch package app.revanced.patches.music.layout.navigationlabel.patch
import app.revanced.extensions.toErrorResult import app.revanced.extensions.exception
import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchException
import app.revanced.patcher.patch.PatchResultError
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.music.layout.navigationlabel.fingerprints.TabLayoutTextFingerprint import app.revanced.patches.music.layout.navigationlabel.fingerprints.TabLayoutTextFingerprint
@ -35,11 +32,10 @@ import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction
] ]
) )
@MusicCompatibility @MusicCompatibility
@Version("0.0.1")
class NavigationLabelPatch : BytecodePatch( class NavigationLabelPatch : BytecodePatch(
listOf(TabLayoutTextFingerprint) listOf(TabLayoutTextFingerprint)
) { ) {
override fun execute(context: BytecodeContext): PatchResult { override fun execute(context: BytecodeContext) {
TabLayoutTextFingerprint.result?.let { TabLayoutTextFingerprint.result?.let {
it.mutableMethod.apply { it.mutableMethod.apply {
val targetIndex = getWideLiteralIndex(Text1) + 3 val targetIndex = getWideLiteralIndex(Text1) + 3
@ -47,14 +43,14 @@ class NavigationLabelPatch : BytecodePatch(
val targetRegister = getInstruction<OneRegisterInstruction>(targetIndex).registerA val targetRegister = getInstruction<OneRegisterInstruction>(targetIndex).registerA
if (!targetParameter.toString().endsWith("Landroid/widget/TextView;")) if (!targetParameter.toString().endsWith("Landroid/widget/TextView;"))
return PatchResultError("Method signature parameter did not match: $targetParameter") throw PatchException("Method signature parameter did not match: $targetParameter")
addInstruction( addInstruction(
targetIndex + 1, targetIndex + 1,
"invoke-static {v$targetRegister}, $MUSIC_LAYOUT->hideNavigationLabel(Landroid/widget/TextView;)V" "invoke-static {v$targetRegister}, $MUSIC_LAYOUT->hideNavigationLabel(Landroid/widget/TextView;)V"
) )
} }
} ?: return TabLayoutTextFingerprint.toErrorResult() } ?: throw TabLayoutTextFingerprint.exception
contexts.xmlEditor[RESOURCE_FILE_PATH].use { editor -> contexts.xmlEditor[RESOURCE_FILE_PATH].use { editor ->
val document = editor.file val document = editor.file
@ -74,7 +70,6 @@ class NavigationLabelPatch : BytecodePatch(
"false" "false"
) )
return PatchResultSuccess()
} }
private companion object { private companion object {

View File

@ -1,15 +1,12 @@
package app.revanced.patches.music.layout.newlayout.patch package app.revanced.patches.music.layout.newlayout.patch
import app.revanced.extensions.toErrorResult import app.revanced.extensions.exception
import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.music.layout.newlayout.fingerprints.NewLayoutFingerprint import app.revanced.patches.music.layout.newlayout.fingerprints.NewLayoutFingerprint
@ -24,11 +21,10 @@ import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
@Description("Enable new player layouts. (YT Music v5.47.51+)") @Description("Enable new player layouts. (YT Music v5.47.51+)")
@DependsOn([SettingsPatch::class]) @DependsOn([SettingsPatch::class])
@MusicCompatibility @MusicCompatibility
@Version("0.0.1")
class NewLayoutPatch : BytecodePatch( class NewLayoutPatch : BytecodePatch(
listOf(NewLayoutFingerprint) listOf(NewLayoutFingerprint)
) { ) {
override fun execute(context: BytecodeContext): PatchResult { override fun execute(context: BytecodeContext) {
NewLayoutFingerprint.result?.let { NewLayoutFingerprint.result?.let {
it.mutableMethod.apply { it.mutableMethod.apply {
@ -42,7 +38,7 @@ class NewLayoutPatch : BytecodePatch(
""" """
) )
} }
} ?: return NewLayoutFingerprint.toErrorResult() } ?: throw NewLayoutFingerprint.exception
SettingsPatch.addMusicPreference( SettingsPatch.addMusicPreference(
CategoryType.LAYOUT, CategoryType.LAYOUT,
@ -50,6 +46,5 @@ class NewLayoutPatch : BytecodePatch(
"true" "true"
) )
return PatchResultSuccess()
} }
} }

View File

@ -1,16 +1,13 @@
package app.revanced.patches.music.layout.oldstyleminiplayer.patch package app.revanced.patches.music.layout.oldstyleminiplayer.patch
import app.revanced.extensions.toErrorResult import app.revanced.extensions.exception
import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve
import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.music.layout.oldstyleminiplayer.fingerprints.NextButtonVisibilityFingerprint import app.revanced.patches.music.layout.oldstyleminiplayer.fingerprints.NextButtonVisibilityFingerprint
@ -27,14 +24,13 @@ import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
@Description("Return the miniplayers to old style. (for YT Music v5.55.53+)") @Description("Return the miniplayers to old style. (for YT Music v5.55.53+)")
@DependsOn([SettingsPatch::class]) @DependsOn([SettingsPatch::class])
@MusicCompatibility @MusicCompatibility
@Version("0.0.1")
class OldStyleMiniPlayerPatch : BytecodePatch( class OldStyleMiniPlayerPatch : BytecodePatch(
listOf( listOf(
ColorMatchPlayerParentFingerprint, ColorMatchPlayerParentFingerprint,
SwipeToCloseFingerprint SwipeToCloseFingerprint
) )
) { ) {
override fun execute(context: BytecodeContext): PatchResult { override fun execute(context: BytecodeContext) {
ColorMatchPlayerParentFingerprint.result?.let { parentResult -> ColorMatchPlayerParentFingerprint.result?.let { parentResult ->
NextButtonVisibilityFingerprint.also { NextButtonVisibilityFingerprint.also {
@ -55,8 +51,8 @@ class OldStyleMiniPlayerPatch : BytecodePatch(
""" """
) )
} }
} ?: return NextButtonVisibilityFingerprint.toErrorResult() } ?: throw NextButtonVisibilityFingerprint.exception
} ?: return ColorMatchPlayerParentFingerprint.toErrorResult() } ?: throw ColorMatchPlayerParentFingerprint.exception
SwipeToCloseFingerprint.result?.let { SwipeToCloseFingerprint.result?.let {
it.mutableMethod.apply { it.mutableMethod.apply {
@ -70,7 +66,7 @@ class OldStyleMiniPlayerPatch : BytecodePatch(
""" """
) )
} }
} ?: return SwipeToCloseFingerprint.toErrorResult() } ?: throw SwipeToCloseFingerprint.exception
SettingsPatch.addMusicPreference( SettingsPatch.addMusicPreference(
CategoryType.LAYOUT, CategoryType.LAYOUT,
@ -78,6 +74,5 @@ class OldStyleMiniPlayerPatch : BytecodePatch(
"false" "false"
) )
return PatchResultSuccess()
} }
} }

View File

@ -2,11 +2,8 @@ package app.revanced.patches.music.layout.playlistcard.patch
import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.music.utils.annotations.MusicCompatibility import app.revanced.patches.music.utils.annotations.MusicCompatibility
@ -25,9 +22,8 @@ import app.revanced.util.integrations.Constants.MUSIC_ADS_PATH
] ]
) )
@MusicCompatibility @MusicCompatibility
@Version("0.0.1")
class HidePlaylistCardPatch : BytecodePatch() { class HidePlaylistCardPatch : BytecodePatch() {
override fun execute(context: BytecodeContext): PatchResult { override fun execute(context: BytecodeContext) {
SettingsPatch.addMusicPreference( SettingsPatch.addMusicPreference(
CategoryType.LAYOUT, CategoryType.LAYOUT,
@ -37,7 +33,6 @@ class HidePlaylistCardPatch : BytecodePatch() {
LithoFilterPatch.addFilter(FILTER_CLASS_DESCRIPTOR) LithoFilterPatch.addFilter(FILTER_CLASS_DESCRIPTOR)
return PatchResultSuccess()
} }
private companion object { private companion object {

View File

@ -1,15 +1,12 @@
package app.revanced.patches.music.layout.sleeptimer.patch package app.revanced.patches.music.layout.sleeptimer.patch
import app.revanced.extensions.toErrorResult import app.revanced.extensions.exception
import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.music.layout.sleeptimer.fingerprints.SleepTimerFingerprint import app.revanced.patches.music.layout.sleeptimer.fingerprints.SleepTimerFingerprint
@ -24,11 +21,10 @@ import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
@Description("Add sleep timer to flyout menu.") @Description("Add sleep timer to flyout menu.")
@DependsOn([SettingsPatch::class]) @DependsOn([SettingsPatch::class])
@MusicCompatibility @MusicCompatibility
@Version("0.0.1")
class SleepTimerPatch : BytecodePatch( class SleepTimerPatch : BytecodePatch(
listOf(SleepTimerFingerprint) listOf(SleepTimerFingerprint)
) { ) {
override fun execute(context: BytecodeContext): PatchResult { override fun execute(context: BytecodeContext) {
SleepTimerFingerprint.result?.let { SleepTimerFingerprint.result?.let {
it.mutableMethod.apply { it.mutableMethod.apply {
@ -42,7 +38,7 @@ class SleepTimerPatch : BytecodePatch(
""" """
) )
} }
} ?: return SleepTimerFingerprint.toErrorResult() } ?: throw SleepTimerFingerprint.exception
SettingsPatch.addMusicPreference( SettingsPatch.addMusicPreference(
CategoryType.LAYOUT, CategoryType.LAYOUT,
@ -50,6 +46,5 @@ class SleepTimerPatch : BytecodePatch(
"true" "true"
) )
return PatchResultSuccess()
} }
} }

View File

@ -1,17 +1,14 @@
package app.revanced.patches.music.layout.zenmode.patch package app.revanced.patches.music.layout.zenmode.patch
import app.revanced.extensions.toErrorResult import app.revanced.extensions.exception
import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.extensions.InstructionExtensions.removeInstruction import app.revanced.patcher.extensions.InstructionExtensions.removeInstruction
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve
import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.music.layout.zenmode.fingerprints.ZenModeFingerprint import app.revanced.patches.music.layout.zenmode.fingerprints.ZenModeFingerprint
@ -28,11 +25,10 @@ import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction
@Description("Adds a grey tint to the video player to reduce eye strain.") @Description("Adds a grey tint to the video player to reduce eye strain.")
@DependsOn([SettingsPatch::class]) @DependsOn([SettingsPatch::class])
@MusicCompatibility @MusicCompatibility
@Version("0.0.1")
class ZenModePatch : BytecodePatch( class ZenModePatch : BytecodePatch(
listOf(ColorMatchPlayerParentFingerprint) listOf(ColorMatchPlayerParentFingerprint)
) { ) {
override fun execute(context: BytecodeContext): PatchResult { override fun execute(context: BytecodeContext) {
ColorMatchPlayerParentFingerprint.result?.let { parentResult -> ColorMatchPlayerParentFingerprint.result?.let { parentResult ->
ZenModeFingerprint.also { it.resolve(context, parentResult.classDef) }.result?.let { ZenModeFingerprint.also { it.resolve(context, parentResult.classDef) }.result?.let {
@ -65,8 +61,8 @@ class ZenModePatch : BytecodePatch(
) )
removeInstruction(referenceIndex) removeInstruction(referenceIndex)
} }
} ?: return ZenModeFingerprint.toErrorResult() } ?: throw ZenModeFingerprint.exception
} ?: return ColorMatchPlayerParentFingerprint.toErrorResult() } ?: throw ColorMatchPlayerParentFingerprint.exception
SettingsPatch.addMusicPreference( SettingsPatch.addMusicPreference(
CategoryType.LAYOUT, CategoryType.LAYOUT,
@ -74,6 +70,5 @@ class ZenModePatch : BytecodePatch(
"false" "false"
) )
return PatchResultSuccess()
} }
} }

View File

@ -1,15 +1,11 @@
package app.revanced.patches.music.misc.backgroundplay.patch package app.revanced.patches.music.misc.backgroundplay.patch
import app.revanced.extensions.toErrorResult import app.revanced.extensions.exception
import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.data.toMethodWalker
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
@ -22,11 +18,10 @@ import app.revanced.patches.music.utils.fix.decoding.patch.DecodingPatch
@Description("Enables playing music in the background.") @Description("Enables playing music in the background.")
@DependsOn([DecodingPatch::class]) @DependsOn([DecodingPatch::class])
@MusicCompatibility @MusicCompatibility
@Version("0.0.1")
class BackgroundPlayPatch : BytecodePatch( class BackgroundPlayPatch : BytecodePatch(
listOf(BackgroundPlaybackParentFingerprint) listOf(BackgroundPlaybackParentFingerprint)
) { ) {
override fun execute(context: BytecodeContext): PatchResult { override fun execute(context: BytecodeContext) {
BackgroundPlaybackParentFingerprint.result?.let { BackgroundPlaybackParentFingerprint.result?.let {
with( with(
@ -42,8 +37,7 @@ class BackgroundPlayPatch : BytecodePatch(
""" """
) )
} }
} ?: return BackgroundPlaybackParentFingerprint.toErrorResult() } ?: throw BackgroundPlaybackParentFingerprint.exception
return PatchResultSuccess()
} }
} }

View File

@ -2,10 +2,7 @@ package app.revanced.patches.music.misc.bitrate.patch
import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.ResourceContext import app.revanced.patcher.data.ResourceContext
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.ResourcePatch
import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch import app.revanced.patcher.patch.annotations.Patch
@ -17,9 +14,8 @@ import app.revanced.patches.music.utils.fix.decoding.patch.DecodingPatch
@Description("Set the audio quality to \"Always High\" when you first install the app.") @Description("Set the audio quality to \"Always High\" when you first install the app.")
@DependsOn([DecodingPatch::class]) @DependsOn([DecodingPatch::class])
@MusicCompatibility @MusicCompatibility
@Version("0.0.1")
class BitrateDefaultValuePatch : ResourcePatch { class BitrateDefaultValuePatch : ResourcePatch {
override fun execute(context: ResourceContext): PatchResult { override fun execute(context: ResourceContext) {
context.xmlEditor[RESOURCE_FILE_PATH].use { editor -> context.xmlEditor[RESOURCE_FILE_PATH].use { editor ->
editor.file.getElementsByTagName("com.google.android.apps.youtube.music.ui.preference.PreferenceCategoryCompat") editor.file.getElementsByTagName("com.google.android.apps.youtube.music.ui.preference.PreferenceCategoryCompat")
.item(0).childNodes.apply { .item(0).childNodes.apply {
@ -39,7 +35,6 @@ class BitrateDefaultValuePatch : ResourcePatch {
} }
} }
return PatchResultSuccess()
} }
private companion object { private companion object {

View File

@ -2,10 +2,7 @@ package app.revanced.patches.music.misc.codecs.patch
import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.music.utils.annotations.MusicCompatibility import app.revanced.patches.music.utils.annotations.MusicCompatibility
@ -19,11 +16,10 @@ import app.revanced.util.integrations.Constants.MUSIC_MISC_PATH
@Description("Enable opus codec when playing audio.") @Description("Enable opus codec when playing audio.")
@DependsOn([SettingsPatch::class]) @DependsOn([SettingsPatch::class])
@MusicCompatibility @MusicCompatibility
@Version("0.0.1")
class CodecsUnlockPatch : AbstractOpusCodecsPatch( class CodecsUnlockPatch : AbstractOpusCodecsPatch(
"$MUSIC_MISC_PATH/OpusCodecPatch;->enableOpusCodec()Z" "$MUSIC_MISC_PATH/OpusCodecPatch;->enableOpusCodec()Z"
) { ) {
override fun execute(context: BytecodeContext): PatchResult { override fun execute(context: BytecodeContext) {
super.execute(context) super.execute(context)
SettingsPatch.addMusicPreference( SettingsPatch.addMusicPreference(
@ -32,6 +28,5 @@ class CodecsUnlockPatch : AbstractOpusCodecsPatch(
"true" "true"
) )
return PatchResultSuccess()
} }
} }

View File

@ -2,10 +2,7 @@ package app.revanced.patches.music.misc.debugging.patch
import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.ResourceContext import app.revanced.patcher.data.ResourceContext
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.ResourcePatch
import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch import app.revanced.patcher.patch.annotations.Patch
@ -18,9 +15,8 @@ import app.revanced.util.enum.CategoryType
@Description("Adds debugging options.") @Description("Adds debugging options.")
@DependsOn([SettingsPatch::class]) @DependsOn([SettingsPatch::class])
@MusicCompatibility @MusicCompatibility
@Version("0.0.1")
class DebuggingPatch : ResourcePatch { class DebuggingPatch : ResourcePatch {
override fun execute(context: ResourceContext): PatchResult { override fun execute(context: ResourceContext) {
SettingsPatch.addMusicPreference( SettingsPatch.addMusicPreference(
CategoryType.MISC, CategoryType.MISC,
@ -28,6 +24,5 @@ class DebuggingPatch : ResourcePatch {
"false" "false"
) )
return PatchResultSuccess()
} }
} }

View File

@ -1,15 +1,12 @@
package app.revanced.patches.music.misc.exclusiveaudio.patch package app.revanced.patches.music.misc.exclusiveaudio.patch
import app.revanced.extensions.toErrorResult import app.revanced.extensions.exception
import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction
import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.music.misc.exclusiveaudio.fingerprints.AudioOnlyEnablerFingerprint import app.revanced.patches.music.misc.exclusiveaudio.fingerprints.AudioOnlyEnablerFingerprint
@ -21,17 +18,15 @@ import app.revanced.patches.music.utils.fix.decoding.patch.DecodingPatch
@Description("Enables the option to play music without video.") @Description("Enables the option to play music without video.")
@DependsOn([DecodingPatch::class]) @DependsOn([DecodingPatch::class])
@MusicCompatibility @MusicCompatibility
@Version("0.0.1")
class ExclusiveAudioPatch : BytecodePatch( class ExclusiveAudioPatch : BytecodePatch(
listOf(AudioOnlyEnablerFingerprint) listOf(AudioOnlyEnablerFingerprint)
) { ) {
override fun execute(context: BytecodeContext): PatchResult { override fun execute(context: BytecodeContext) {
AudioOnlyEnablerFingerprint.result?.mutableMethod?.let { AudioOnlyEnablerFingerprint.result?.mutableMethod?.let {
it.replaceInstruction(it.implementation!!.instructions.count() - 1, "const/4 v0, 0x1") it.replaceInstruction(it.implementation!!.instructions.count() - 1, "const/4 v0, 0x1")
it.addInstruction("return v0") it.addInstruction("return v0")
} ?: return AudioOnlyEnablerFingerprint.toErrorResult() } ?: throw AudioOnlyEnablerFingerprint.exception
return PatchResultSuccess()
} }
} }

View File

@ -1,14 +1,11 @@
package app.revanced.patches.music.misc.minimizedplayback.patch package app.revanced.patches.music.misc.minimizedplayback.patch
import app.revanced.extensions.toErrorResult import app.revanced.extensions.exception
import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.Patch import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.music.misc.minimizedplayback.fingerprints.MinimizedPlaybackManagerFingerprint import app.revanced.patches.music.misc.minimizedplayback.fingerprints.MinimizedPlaybackManagerFingerprint
import app.revanced.patches.music.utils.annotations.MusicCompatibility import app.revanced.patches.music.utils.annotations.MusicCompatibility
@ -17,16 +14,14 @@ import app.revanced.patches.music.utils.annotations.MusicCompatibility
@Name("Enable minimized playback") @Name("Enable minimized playback")
@Description("Enables minimized playback on Kids music.") @Description("Enables minimized playback on Kids music.")
@MusicCompatibility @MusicCompatibility
@Version("0.0.1")
class MinimizedPlaybackPatch : BytecodePatch( class MinimizedPlaybackPatch : BytecodePatch(
listOf(MinimizedPlaybackManagerFingerprint) listOf(MinimizedPlaybackManagerFingerprint)
) { ) {
override fun execute(context: BytecodeContext): PatchResult { override fun execute(context: BytecodeContext) {
MinimizedPlaybackManagerFingerprint.result?.mutableMethod?.addInstruction( MinimizedPlaybackManagerFingerprint.result?.mutableMethod?.addInstruction(
0, "return-void" 0, "return-void"
) ?: return MinimizedPlaybackManagerFingerprint.toErrorResult() ) ?: throw MinimizedPlaybackManagerFingerprint.exception
return PatchResultSuccess()
} }
} }

View File

@ -2,10 +2,7 @@ package app.revanced.patches.music.misc.optimizeresource.patch
import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.ResourceContext import app.revanced.patcher.data.ResourceContext
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.ResourcePatch
import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch import app.revanced.patcher.patch.annotations.Patch
@ -19,9 +16,8 @@ import java.nio.file.StandardCopyOption
@Description("Remove unnecessary resources.") @Description("Remove unnecessary resources.")
@DependsOn([DecodingPatch::class]) @DependsOn([DecodingPatch::class])
@MusicCompatibility @MusicCompatibility
@Version("0.0.1")
class OptimizeResourcePatch : ResourcePatch { class OptimizeResourcePatch : ResourcePatch {
override fun execute(context: ResourceContext): PatchResult { override fun execute(context: ResourceContext) {
val relativePath = "raw/third_party_licenses" val relativePath = "raw/third_party_licenses"
@ -31,6 +27,5 @@ class OptimizeResourcePatch : ResourcePatch {
StandardCopyOption.REPLACE_EXISTING StandardCopyOption.REPLACE_EXISTING
) )
return PatchResultSuccess()
} }
} }

View File

@ -1,16 +1,12 @@
package app.revanced.patches.music.misc.premium.patch package app.revanced.patches.music.misc.premium.patch
import app.revanced.extensions.toErrorResult import app.revanced.extensions.exception
import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.data.toMethodWalker
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
@ -37,14 +33,13 @@ import com.android.tools.smali.dexlib2.iface.reference.Reference
] ]
) )
@MusicCompatibility @MusicCompatibility
@Version("0.0.1")
class HideGetPremiumPatch : BytecodePatch( class HideGetPremiumPatch : BytecodePatch(
listOf( listOf(
AccountMenuFooterFingerprint, AccountMenuFooterFingerprint,
HideGetPremiumFingerprint HideGetPremiumFingerprint
) )
) { ) {
override fun execute(context: BytecodeContext): PatchResult { override fun execute(context: BytecodeContext) {
HideGetPremiumFingerprint.result?.let { HideGetPremiumFingerprint.result?.let {
it.mutableMethod.apply { it.mutableMethod.apply {
@ -56,7 +51,7 @@ class HideGetPremiumPatch : BytecodePatch(
"const/4 v$register, 0x0" "const/4 v$register, 0x0"
) )
} }
} ?: return HideGetPremiumFingerprint.toErrorResult() } ?: throw HideGetPremiumFingerprint.exception
AccountMenuFooterFingerprint.result?.let { AccountMenuFooterFingerprint.result?.let {
@ -89,9 +84,8 @@ class HideGetPremiumPatch : BytecodePatch(
} }
} }
} }
} ?: return AccountMenuFooterFingerprint.toErrorResult() } ?: throw AccountMenuFooterFingerprint.exception
return PatchResultSuccess()
} }
private companion object { private companion object {

View File

@ -1,18 +1,15 @@
package app.revanced.patches.music.misc.quality.patch package app.revanced.patches.music.misc.quality.patch
import app.revanced.extensions.exception
import app.revanced.extensions.findMutableMethodOf import app.revanced.extensions.findMutableMethodOf
import app.revanced.extensions.toErrorResult
import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve
import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.music.misc.quality.fingerprints.MusicVideoQualitySettingsFingerprint import app.revanced.patches.music.misc.quality.fingerprints.MusicVideoQualitySettingsFingerprint
@ -42,14 +39,13 @@ import com.android.tools.smali.dexlib2.iface.reference.Reference
] ]
) )
@MusicCompatibility @MusicCompatibility
@Version("0.0.1")
class VideoQualityPatch : BytecodePatch( class VideoQualityPatch : BytecodePatch(
listOf( listOf(
MusicVideoQualitySettingsParentFingerprint, MusicVideoQualitySettingsParentFingerprint,
UserQualityChangeFingerprint UserQualityChangeFingerprint
) )
) { ) {
override fun execute(context: BytecodeContext): PatchResult { override fun execute(context: BytecodeContext) {
UserQualityChangeFingerprint.result?.let { UserQualityChangeFingerprint.result?.let {
it.mutableMethod.apply { it.mutableMethod.apply {
@ -82,7 +78,7 @@ class VideoQualityPatch : BytecodePatch(
} }
} }
} }
} ?: return UserQualityChangeFingerprint.toErrorResult() } ?: throw UserQualityChangeFingerprint.exception
MusicVideoQualitySettingsParentFingerprint.result?.let { parentResult -> MusicVideoQualitySettingsParentFingerprint.result?.let { parentResult ->
MusicVideoQualitySettingsFingerprint.also { MusicVideoQualitySettingsFingerprint.also {
@ -98,8 +94,8 @@ class VideoQualityPatch : BytecodePatch(
invoke-static {p1, p2, v0}, $INTEGRATIONS_VIDEO_QUALITY_CLASS_DESCRIPTOR->setVideoQuality([Ljava/lang/Object;ILjava/lang/Object;)I invoke-static {p1, p2, v0}, $INTEGRATIONS_VIDEO_QUALITY_CLASS_DESCRIPTOR->setVideoQuality([Ljava/lang/Object;ILjava/lang/Object;)I
move-result p2 move-result p2
""" """
) ?: return MusicVideoQualitySettingsFingerprint.toErrorResult() ) ?: throw MusicVideoQualitySettingsFingerprint.exception
} ?: return MusicVideoQualitySettingsParentFingerprint.toErrorResult() } ?: throw MusicVideoQualitySettingsParentFingerprint.exception
VideoIdPatch.injectCall("$INTEGRATIONS_VIDEO_QUALITY_CLASS_DESCRIPTOR->newVideoStarted(Ljava/lang/String;)V") VideoIdPatch.injectCall("$INTEGRATIONS_VIDEO_QUALITY_CLASS_DESCRIPTOR->newVideoStarted(Ljava/lang/String;)V")
SettingsPatch.addMusicPreference( SettingsPatch.addMusicPreference(
@ -108,7 +104,6 @@ class VideoQualityPatch : BytecodePatch(
"true" "true"
) )
return PatchResultSuccess()
} }
private companion object { private companion object {

View File

@ -1,17 +1,14 @@
package app.revanced.patches.music.misc.sharebuttonhook.patch package app.revanced.patches.music.misc.sharebuttonhook.patch
import app.revanced.extensions.toErrorResult import app.revanced.extensions.exception
import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patcher.util.smali.ExternalLabel import app.revanced.patcher.util.smali.ExternalLabel
@ -36,7 +33,6 @@ import app.revanced.util.integrations.Constants.MUSIC_MISC_PATH
] ]
) )
@MusicCompatibility @MusicCompatibility
@Version("0.0.1")
class ShareButtonHookPatch : BytecodePatch( class ShareButtonHookPatch : BytecodePatch(
listOf( listOf(
ConnectionTrackerFingerprint, ConnectionTrackerFingerprint,
@ -45,7 +41,7 @@ class ShareButtonHookPatch : BytecodePatch(
ShowToastFingerprint ShowToastFingerprint
) )
) { ) {
override fun execute(context: BytecodeContext): PatchResult { override fun execute(context: BytecodeContext) {
SharePanelFingerprint.result?.let { SharePanelFingerprint.result?.let {
it.mutableMethod.apply { it.mutableMethod.apply {
val targetIndex = it.scanResult.patternScanResult!!.startIndex val targetIndex = it.scanResult.patternScanResult!!.startIndex
@ -60,26 +56,26 @@ class ShareButtonHookPatch : BytecodePatch(
""", ExternalLabel("default", getInstruction(targetIndex)) """, ExternalLabel("default", getInstruction(targetIndex))
) )
} }
} ?: return SharePanelFingerprint.toErrorResult() } ?: throw SharePanelFingerprint.exception
ConnectionTrackerFingerprint.result?.mutableMethod?.addInstruction( ConnectionTrackerFingerprint.result?.mutableMethod?.addInstruction(
0, 0,
"sput-object p1, $INTEGRATIONS_CLASS_DESCRIPTOR->context:Landroid/content/Context;" "sput-object p1, $INTEGRATIONS_CLASS_DESCRIPTOR->context:Landroid/content/Context;"
) ?: return ConnectionTrackerFingerprint.toErrorResult() ) ?: throw ConnectionTrackerFingerprint.exception
ShowToastFingerprint.result?.mutableMethod?.addInstructions( ShowToastFingerprint.result?.mutableMethod?.addInstructions(
0, """ 0, """
invoke-static {p0}, $INTEGRATIONS_CLASS_DESCRIPTOR->dismissContext(Landroid/content/Context;)Landroid/content/Context; invoke-static {p0}, $INTEGRATIONS_CLASS_DESCRIPTOR->dismissContext(Landroid/content/Context;)Landroid/content/Context;
move-result-object p0 move-result-object p0
""" """
) ?: return ShowToastFingerprint.toErrorResult() ) ?: throw ShowToastFingerprint.exception
FullStackTraceActivityFingerprint.result?.mutableMethod?.addInstructions( FullStackTraceActivityFingerprint.result?.mutableMethod?.addInstructions(
1, """ 1, """
invoke-static {p0}, $MUSIC_INTEGRATIONS_PATH/settingsmenu/SharedPreferenceChangeListener;->initializeSettings(Landroid/app/Activity;)V invoke-static {p0}, $MUSIC_INTEGRATIONS_PATH/settingsmenu/SharedPreferenceChangeListener;->initializeSettings(Landroid/app/Activity;)V
return-void return-void
""" """
) ?: return FullStackTraceActivityFingerprint.toErrorResult() ) ?: throw FullStackTraceActivityFingerprint.exception
SettingsPatch.addMusicPreference( SettingsPatch.addMusicPreference(
CategoryType.MISC, CategoryType.MISC,
@ -92,7 +88,6 @@ class ShareButtonHookPatch : BytecodePatch(
"revanced_hook_share_button" "revanced_hook_share_button"
) )
return PatchResultSuccess()
} }
private companion object { private companion object {

View File

@ -1,21 +1,18 @@
package app.revanced.patches.music.misc.shuffle.patch package app.revanced.patches.music.misc.shuffle.patch
import app.revanced.extensions.toErrorResult import app.revanced.extensions.exception
import app.revanced.extensions.transformFields import app.revanced.extensions.transformFields
import app.revanced.extensions.traverseClassHierarchy
import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.extensions.or import app.revanced.patcher.extensions.or
import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patcher.util.TypeUtil.traverseClassHierarchy
import app.revanced.patcher.util.proxy.mutableTypes.MutableField.Companion.toMutable import app.revanced.patcher.util.proxy.mutableTypes.MutableField.Companion.toMutable
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod.Companion.toMutable import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod.Companion.toMutable
import app.revanced.patcher.util.smali.toInstructions import app.revanced.patcher.util.smali.toInstructions
@ -47,7 +44,6 @@ import com.android.tools.smali.dexlib2.immutable.ImmutableMethodParameter
] ]
) )
@MusicCompatibility @MusicCompatibility
@Version("0.0.1")
class EnforceShufflePatch : BytecodePatch( class EnforceShufflePatch : BytecodePatch(
listOf( listOf(
MusicPlaybackControlsFingerprint, MusicPlaybackControlsFingerprint,
@ -55,7 +51,7 @@ class EnforceShufflePatch : BytecodePatch(
ShuffleClassReferenceFingerprint ShuffleClassReferenceFingerprint
) )
) { ) {
override fun execute(context: BytecodeContext): PatchResult { override fun execute(context: BytecodeContext) {
ShuffleClassReferenceFingerprint.result?.let { ShuffleClassReferenceFingerprint.result?.let {
it.mutableMethod.apply { it.mutableMethod.apply {
@ -72,7 +68,7 @@ class EnforceShufflePatch : BytecodePatch(
shuffleReference3 = getInstruction(endIndex).descriptor shuffleReference3 = getInstruction(endIndex).descriptor
shuffleReference4 = getInstruction(imageViewIndex).descriptor shuffleReference4 = getInstruction(imageViewIndex).descriptor
} }
} ?: return ShuffleClassReferenceFingerprint.toErrorResult() } ?: throw ShuffleClassReferenceFingerprint.exception
ShuffleClassFingerprint.result?.let { ShuffleClassFingerprint.result?.let {
@ -97,7 +93,7 @@ class EnforceShufflePatch : BytecodePatch(
).toMutable() ).toMutable()
} }
} }
} ?: return ShuffleClassFingerprint.toErrorResult() } ?: throw ShuffleClassFingerprint.exception
MusicPlaybackControlsFingerprint.result?.let { MusicPlaybackControlsFingerprint.result?.let {
it.mutableMethod.apply { it.mutableMethod.apply {
@ -163,7 +159,7 @@ class EnforceShufflePatch : BytecodePatch(
).toMutable() ).toMutable()
) )
} }
} ?: return MusicPlaybackControlsFingerprint.toErrorResult() } ?: throw MusicPlaybackControlsFingerprint.exception
SettingsPatch.addMusicPreference( SettingsPatch.addMusicPreference(
CategoryType.MISC, CategoryType.MISC,
@ -171,7 +167,6 @@ class EnforceShufflePatch : BytecodePatch(
"true" "true"
) )
return PatchResultSuccess()
} }
private companion object { private companion object {

View File

@ -1,15 +1,12 @@
package app.revanced.patches.music.misc.tastebuilder.patch package app.revanced.patches.music.misc.tastebuilder.patch
import app.revanced.extensions.toErrorResult import app.revanced.extensions.exception
import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.music.misc.tastebuilder.fingerprints.TasteBuilderConstructorFingerprint import app.revanced.patches.music.misc.tastebuilder.fingerprints.TasteBuilderConstructorFingerprint
@ -22,11 +19,10 @@ import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction
@Description("Hides the \"Tell us which artists you like\" card from homepage.") @Description("Hides the \"Tell us which artists you like\" card from homepage.")
@DependsOn([DecodingPatch::class]) @DependsOn([DecodingPatch::class])
@MusicCompatibility @MusicCompatibility
@Version("0.0.1")
class TasteBuilderPatch : BytecodePatch( class TasteBuilderPatch : BytecodePatch(
listOf(TasteBuilderConstructorFingerprint) listOf(TasteBuilderConstructorFingerprint)
) { ) {
override fun execute(context: BytecodeContext): PatchResult { override fun execute(context: BytecodeContext) {
TasteBuilderConstructorFingerprint.result?.let { TasteBuilderConstructorFingerprint.result?.let {
it.mutableMethod.apply { it.mutableMethod.apply {
val insertIndex = it.scanResult.patternScanResult!!.endIndex - 8 val insertIndex = it.scanResult.patternScanResult!!.endIndex - 8
@ -39,8 +35,7 @@ class TasteBuilderPatch : BytecodePatch(
""" """
) )
} }
} ?: return TasteBuilderConstructorFingerprint.toErrorResult() } ?: throw TasteBuilderConstructorFingerprint.exception
return PatchResultSuccess()
} }
} }

View File

@ -2,10 +2,7 @@ package app.revanced.patches.music.misc.translations.patch
import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.ResourceContext import app.revanced.patcher.data.ResourceContext
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.ResourcePatch
import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch import app.revanced.patcher.patch.annotations.Patch
@ -18,13 +15,11 @@ import app.revanced.util.resources.ResourceHelper.addTranslations
@Description("Add Crowdin translations for YouTube Music.") @Description("Add Crowdin translations for YouTube Music.")
@DependsOn([SettingsPatch::class]) @DependsOn([SettingsPatch::class])
@MusicCompatibility @MusicCompatibility
@Version("0.0.1")
class TranslationsPatch : ResourcePatch { class TranslationsPatch : ResourcePatch {
override fun execute(context: ResourceContext): PatchResult { override fun execute(context: ResourceContext) {
context.addTranslations("music", LANGUAGE_LIST) context.addTranslations("music", LANGUAGE_LIST)
return PatchResultSuccess()
} }
private companion object { private companion object {

View File

@ -1,17 +1,14 @@
package app.revanced.patches.music.misc.upgradebutton.patch package app.revanced.patches.music.misc.upgradebutton.patch
import app.revanced.extensions.toErrorResult import app.revanced.extensions.exception
import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction
import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.music.misc.upgradebutton.fingerprints.NotifierShelfFingerprint import app.revanced.patches.music.misc.upgradebutton.fingerprints.NotifierShelfFingerprint
@ -35,14 +32,13 @@ import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction
] ]
) )
@MusicCompatibility @MusicCompatibility
@Version("0.0.1")
class UpgradeButtonPatch : BytecodePatch( class UpgradeButtonPatch : BytecodePatch(
listOf( listOf(
PivotBarConstructorFingerprint, PivotBarConstructorFingerprint,
NotifierShelfFingerprint NotifierShelfFingerprint
) )
) { ) {
override fun execute(context: BytecodeContext): PatchResult { override fun execute(context: BytecodeContext) {
PivotBarConstructorFingerprint.result?.let { PivotBarConstructorFingerprint.result?.let {
it.mutableMethod.apply { it.mutableMethod.apply {
val targetIndex = it.scanResult.patternScanResult!!.startIndex val targetIndex = it.scanResult.patternScanResult!!.startIndex
@ -67,7 +63,7 @@ class UpgradeButtonPatch : BytecodePatch(
""" """
) )
} }
} ?: return PivotBarConstructorFingerprint.toErrorResult() } ?: throw PivotBarConstructorFingerprint.exception
NotifierShelfFingerprint.result?.let { NotifierShelfFingerprint.result?.let {
it.mutableMethod.apply { it.mutableMethod.apply {
@ -78,8 +74,7 @@ class UpgradeButtonPatch : BytecodePatch(
"invoke-static {v$targetRegister}, Lapp/revanced/music/utils/ReVancedUtils;->hideViewByLayoutParams(Landroid/view/View;)V" "invoke-static {v$targetRegister}, Lapp/revanced/music/utils/ReVancedUtils;->hideViewByLayoutParams(Landroid/view/View;)V"
) )
} }
} ?: return NotifierShelfFingerprint.toErrorResult() } ?: throw NotifierShelfFingerprint.exception
return PatchResultSuccess()
} }
} }

View File

@ -2,10 +2,7 @@ package app.revanced.patches.music.misc.versionspoof.patch
import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.music.utils.annotations.MusicCompatibility import app.revanced.patches.music.utils.annotations.MusicCompatibility
@ -19,11 +16,10 @@ import app.revanced.util.integrations.Constants.MUSIC_MISC_PATH
@Description("Spoof the YouTube Music client version.") @Description("Spoof the YouTube Music client version.")
@DependsOn([SettingsPatch::class]) @DependsOn([SettingsPatch::class])
@MusicCompatibility @MusicCompatibility
@Version("0.0.1")
class SpoofAppVersionPatch : AbstractVersionSpoofPatch( class SpoofAppVersionPatch : AbstractVersionSpoofPatch(
"$MUSIC_MISC_PATH/SpoofAppVersionPatch;->getVersionOverride(Ljava/lang/String;)Ljava/lang/String;" "$MUSIC_MISC_PATH/SpoofAppVersionPatch;->getVersionOverride(Ljava/lang/String;)Ljava/lang/String;"
) { ) {
override fun execute(context: BytecodeContext): PatchResult { override fun execute(context: BytecodeContext) {
super.execute(context) super.execute(context)
SettingsPatch.addMusicPreference( SettingsPatch.addMusicPreference(
@ -32,6 +28,5 @@ class SpoofAppVersionPatch : AbstractVersionSpoofPatch(
"false" "false"
) )
return PatchResultSuccess()
} }
} }

View File

@ -1,14 +1,11 @@
package app.revanced.patches.music.utils.fix.androidauto.patch package app.revanced.patches.music.utils.fix.androidauto.patch
import app.revanced.extensions.toErrorResult import app.revanced.extensions.exception
import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.music.utils.annotations.MusicCompatibility import app.revanced.patches.music.utils.annotations.MusicCompatibility
@ -20,19 +17,17 @@ import app.revanced.patches.music.utils.fix.decoding.patch.DecodingPatch
@Description("Spoofs the YouTube Music certificate for Android Auto.") @Description("Spoofs the YouTube Music certificate for Android Auto.")
@DependsOn([DecodingPatch::class]) @DependsOn([DecodingPatch::class])
@MusicCompatibility @MusicCompatibility
@Version("0.0.1")
class AndroidAutoCertificatePatch : BytecodePatch( class AndroidAutoCertificatePatch : BytecodePatch(
listOf(CertificateCheckFingerprint) listOf(CertificateCheckFingerprint)
) { ) {
override fun execute(context: BytecodeContext): PatchResult { override fun execute(context: BytecodeContext) {
CertificateCheckFingerprint.result?.mutableMethod?.addInstructions( CertificateCheckFingerprint.result?.mutableMethod?.addInstructions(
0, """ 0, """
const/4 v0, 0x1 const/4 v0, 0x1
return v0 return v0
""" """
) ?: return CertificateCheckFingerprint.toErrorResult() ) ?: throw CertificateCheckFingerprint.exception
return PatchResultSuccess()
} }
} }

View File

@ -1,12 +1,10 @@
package app.revanced.patches.music.utils.fix.clientspoof.patch package app.revanced.patches.music.utils.fix.clientspoof.patch
import app.revanced.extensions.toErrorResult import app.revanced.extensions.exception
import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patches.music.utils.fix.clientspoof.fingerprints.UserAgentHeaderBuilderFingerprint import app.revanced.patches.music.utils.fix.clientspoof.fingerprints.UserAgentHeaderBuilderFingerprint
import app.revanced.patches.music.utils.microg.shared.Constants.MUSIC_PACKAGE_NAME import app.revanced.patches.music.utils.microg.shared.Constants.MUSIC_PACKAGE_NAME
import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
@ -14,7 +12,7 @@ import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
class ClientSpoofMusicPatch : BytecodePatch( class ClientSpoofMusicPatch : BytecodePatch(
listOf(UserAgentHeaderBuilderFingerprint) listOf(UserAgentHeaderBuilderFingerprint)
) { ) {
override fun execute(context: BytecodeContext): PatchResult { override fun execute(context: BytecodeContext) {
UserAgentHeaderBuilderFingerprint.result?.let { UserAgentHeaderBuilderFingerprint.result?.let {
it.mutableMethod.apply { it.mutableMethod.apply {
@ -27,8 +25,7 @@ class ClientSpoofMusicPatch : BytecodePatch(
"const-string v$packageNameRegister, \"$MUSIC_PACKAGE_NAME\"" "const-string v$packageNameRegister, \"$MUSIC_PACKAGE_NAME\""
) )
} }
} ?: return UserAgentHeaderBuilderFingerprint.toErrorResult() } ?: throw UserAgentHeaderBuilderFingerprint.exception
return PatchResultSuccess()
} }
} }

View File

@ -1,12 +1,10 @@
package app.revanced.patches.music.utils.fix.decoding.patch package app.revanced.patches.music.utils.fix.decoding.patch
import app.revanced.patcher.data.ResourceContext import app.revanced.patcher.data.ResourceContext
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.ResourcePatch
class DecodingPatch : ResourcePatch { class DecodingPatch : ResourcePatch {
override fun execute(context: ResourceContext): PatchResult { override fun execute(context: ResourceContext) {
/** /**
* For some reason, Androlib is incorrectly decoding some resources of YT Music * For some reason, Androlib is incorrectly decoding some resources of YT Music
@ -29,6 +27,5 @@ class DecodingPatch : ResourcePatch {
} }
} }
return PatchResultSuccess()
} }
} }

View File

@ -1,14 +1,11 @@
package app.revanced.patches.music.utils.litho.patch package app.revanced.patches.music.utils.litho.patch
import app.revanced.extensions.toErrorResult import app.revanced.extensions.exception
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
import app.revanced.patcher.extensions.InstructionExtensions.removeInstructions import app.revanced.patcher.extensions.InstructionExtensions.removeInstructions
import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction
import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patches.music.utils.annotations.MusicCompatibility import app.revanced.patches.music.utils.annotations.MusicCompatibility
import app.revanced.patches.music.utils.litho.fingerprints.LithoFilterFingerprint import app.revanced.patches.music.utils.litho.fingerprints.LithoFilterFingerprint
@ -19,11 +16,10 @@ import java.io.Closeable
@DependsOn([ComponentParserPatch::class]) @DependsOn([ComponentParserPatch::class])
@MusicCompatibility @MusicCompatibility
@Version("0.0.1")
class LithoFilterPatch : BytecodePatch( class LithoFilterPatch : BytecodePatch(
listOf(LithoFilterFingerprint) listOf(LithoFilterFingerprint)
), Closeable { ), Closeable {
override fun execute(context: BytecodeContext): PatchResult { override fun execute(context: BytecodeContext) {
identifierHook("$MUSIC_ADS_PATH/LithoFilterPatch;->filter") identifierHook("$MUSIC_ADS_PATH/LithoFilterPatch;->filter")
LithoFilterFingerprint.result?.mutableMethod?.apply { LithoFilterFingerprint.result?.mutableMethod?.apply {
@ -40,9 +36,8 @@ class LithoFilterPatch : BytecodePatch(
""" """
) )
} }
} ?: return LithoFilterFingerprint.toErrorResult() } ?: throw LithoFilterFingerprint.exception
return PatchResultSuccess()
} }
override fun close() = LithoFilterFingerprint.result!! override fun close() = LithoFilterFingerprint.result!!

View File

@ -2,12 +2,9 @@ package app.revanced.patches.music.utils.microg.bytecode.patch
import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchException
import app.revanced.patcher.patch.PatchResultError
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.music.utils.annotations.MusicCompatibility import app.revanced.patches.music.utils.annotations.MusicCompatibility
@ -37,7 +34,6 @@ import app.revanced.util.microg.MicroGBytecodeHelper
@Name("MicroG support") @Name("MicroG support")
@Description("Allows ReVanced Music to run without root and under a different package name with MicroG.") @Description("Allows ReVanced Music to run without root and under a different package name with MicroG.")
@MusicCompatibility @MusicCompatibility
@Version("0.0.2")
class MicroGPatch : BytecodePatch( class MicroGPatch : BytecodePatch(
listOf( listOf(
ServiceCheckFingerprint, ServiceCheckFingerprint,
@ -55,15 +51,15 @@ class MicroGPatch : BytecodePatch(
// - "com.google.android.gms.phenotype.PACKAGE_NAME", // - "com.google.android.gms.phenotype.PACKAGE_NAME",
// - "com.google.android.gms.phenotype.UPDATE", // - "com.google.android.gms.phenotype.UPDATE",
// - "com.google.android.gms.phenotype", // - "com.google.android.gms.phenotype",
override fun execute(context: BytecodeContext): PatchResult { override fun execute(context: BytecodeContext) {
val youtubePackageName = PackageNamePatch.YouTubePackageName val youtubePackageName = PackageNamePatch.YouTubePackageName
?: throw PatchResultError("Invalid package name.") ?: throw PatchException("Invalid package name.")
val musicPackageName = PackageNamePatch.MusicPackageName val musicPackageName = PackageNamePatch.MusicPackageName
?: throw PatchResultError("Invalid package name.") ?: throw PatchException("Invalid package name.")
if (youtubePackageName == YOUTUBE_PACKAGE_NAME || musicPackageName == MUSIC_PACKAGE_NAME) if (youtubePackageName == YOUTUBE_PACKAGE_NAME || musicPackageName == MUSIC_PACKAGE_NAME)
throw PatchResultError("Original package name is not available as package name for MicroG build.") throw PatchException("Original package name is not available as package name for MicroG build.")
// apply common microG patch // apply common microG patch
MicroGBytecodeHelper.patchBytecode( MicroGBytecodeHelper.patchBytecode(
@ -88,6 +84,5 @@ class MicroGPatch : BytecodePatch(
) )
) )
return PatchResultSuccess()
} }
} }

View File

@ -1,9 +1,7 @@
package app.revanced.patches.music.utils.microg.resource.patch package app.revanced.patches.music.utils.microg.resource.patch
import app.revanced.patcher.data.ResourceContext import app.revanced.patcher.data.ResourceContext
import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchException
import app.revanced.patcher.patch.PatchResultError
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.ResourcePatch
import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patches.music.utils.microg.shared.Constants.MUSIC_PACKAGE_NAME import app.revanced.patches.music.utils.microg.shared.Constants.MUSIC_PACKAGE_NAME
@ -16,12 +14,12 @@ import app.revanced.util.resources.MusicResourceHelper.setMicroG
@DependsOn([PackageNamePatch::class]) @DependsOn([PackageNamePatch::class])
class MicroGResourcePatch : ResourcePatch { class MicroGResourcePatch : ResourcePatch {
override fun execute(context: ResourceContext): PatchResult { override fun execute(context: ResourceContext) {
val packageName = PackageNamePatch.MusicPackageName val packageName = PackageNamePatch.MusicPackageName
?: throw PatchResultError("Invalid package name.") ?: throw PatchException("Invalid package name.")
if (packageName == MUSIC_PACKAGE_NAME) if (packageName == MUSIC_PACKAGE_NAME)
throw PatchResultError("Original package name is not available as package name for MicroG build.") throw PatchException("Original package name is not available as package name for MicroG build.")
// update manifest // update manifest
context.patchManifest( context.patchManifest(
@ -37,6 +35,5 @@ class MicroGResourcePatch : ResourcePatch {
context.setMicroG(packageName) context.setMicroG(packageName)
return PatchResultSuccess()
} }
} }

View File

@ -1,9 +1,7 @@
package app.revanced.patches.music.utils.resourceid.patch package app.revanced.patches.music.utils.resourceid.patch
import app.revanced.patcher.data.ResourceContext import app.revanced.patcher.data.ResourceContext
import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchException
import app.revanced.patcher.patch.PatchResultError
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.ResourcePatch
import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patches.shared.patch.mapping.ResourceMappingPatch import app.revanced.patches.shared.patch.mapping.ResourceMappingPatch
@ -30,12 +28,12 @@ class SharedResourceIdPatch : ResourcePatch {
var Text1: Long = -1 var Text1: Long = -1
} }
override fun execute(context: ResourceContext): PatchResult { override fun execute(context: ResourceContext) {
fun find(resourceType: ResourceType, resourceName: String) = ResourceMappingPatch fun find(resourceType: ResourceType, resourceName: String) = ResourceMappingPatch
.resourceMappings .resourceMappings
.find { it.type == resourceType.value && it.name == resourceName }?.id .find { it.type == resourceType.value && it.name == resourceName }?.id
?: throw PatchResultError("Failed to find resource id : $resourceName") ?: throw PatchException("Failed to find resource id : $resourceName")
ChipCloud = find(LAYOUT, "chip_cloud") ChipCloud = find(LAYOUT, "chip_cloud")
ColorGrey = find(COLOR, "ytm_color_grey_12") ColorGrey = find(COLOR, "ytm_color_grey_12")
@ -47,6 +45,5 @@ class SharedResourceIdPatch : ResourcePatch {
QualityTitle = find(STRING, "quality_title") QualityTitle = find(STRING, "quality_title")
Text1 = find(ID, "text1") Text1 = find(ID, "text1")
return PatchResultSuccess()
} }
} }

View File

@ -1,12 +1,10 @@
package app.revanced.patches.music.utils.settings.bytecode.patch package app.revanced.patches.music.utils.settings.bytecode.patch
import app.revanced.extensions.toErrorResult import app.revanced.extensions.exception
import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patches.music.utils.integrations.patch.IntegrationsPatch import app.revanced.patches.music.utils.integrations.patch.IntegrationsPatch
import app.revanced.patches.music.utils.settings.bytecode.fingerprints.PreferenceFingerprint import app.revanced.patches.music.utils.settings.bytecode.fingerprints.PreferenceFingerprint
@ -22,7 +20,7 @@ class SettingsBytecodePatch : BytecodePatch(
SettingsHeadersFragmentFingerprint SettingsHeadersFragmentFingerprint
) )
) { ) {
override fun execute(context: BytecodeContext): PatchResult { override fun execute(context: BytecodeContext) {
SettingsHeadersFragmentFingerprint.result?.let { SettingsHeadersFragmentFingerprint.result?.let {
it.mutableMethod.apply { it.mutableMethod.apply {
@ -34,7 +32,7 @@ class SettingsBytecodePatch : BytecodePatch(
"invoke-static {v$targetRegister}, $INTEGRATIONS_CLASS_DESCRIPTOR->setActivity(Ljava/lang/Object;)V" "invoke-static {v$targetRegister}, $INTEGRATIONS_CLASS_DESCRIPTOR->setActivity(Ljava/lang/Object;)V"
) )
} }
} ?: return SettingsHeadersFragmentFingerprint.toErrorResult() } ?: throw SettingsHeadersFragmentFingerprint.exception
PreferenceFingerprint.result?.let { PreferenceFingerprint.result?.let {
it.mutableMethod.apply { it.mutableMethod.apply {
@ -47,9 +45,8 @@ class SettingsBytecodePatch : BytecodePatch(
"invoke-static {v$keyRegister, v$valueRegister}, $INTEGRATIONS_CLASS_DESCRIPTOR->onPreferenceChanged(Ljava/lang/String;Z)V" "invoke-static {v$keyRegister, v$valueRegister}, $INTEGRATIONS_CLASS_DESCRIPTOR->onPreferenceChanged(Ljava/lang/String;Z)V"
) )
} }
} ?: return PreferenceFingerprint.toErrorResult() } ?: throw PreferenceFingerprint.exception
return PatchResultSuccess()
} }
companion object { companion object {

View File

@ -2,10 +2,7 @@ package app.revanced.patches.music.utils.settings.resource.patch
import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.ResourceContext import app.revanced.patcher.data.ResourceContext
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.music.utils.annotations.MusicCompatibility import app.revanced.patches.music.utils.annotations.MusicCompatibility
@ -37,13 +34,12 @@ import java.nio.file.Paths
] ]
) )
@MusicCompatibility @MusicCompatibility
@Version("0.0.1")
class SettingsPatch : AbstractSettingsResourcePatch( class SettingsPatch : AbstractSettingsResourcePatch(
"music/settings", "music/settings",
"music/settings/host", "music/settings/host",
false false
) { ) {
override fun execute(context: ResourceContext): PatchResult { override fun execute(context: ResourceContext) {
super.execute(context) super.execute(context)
contexts = context contexts = context
@ -110,7 +106,6 @@ class SettingsPatch : AbstractSettingsResourcePatch(
.let(::copyResources) .let(::copyResources)
} }
return PatchResultSuccess()
} }
companion object { companion object {

View File

@ -1,12 +1,10 @@
package app.revanced.patches.music.utils.videoid.patch package app.revanced.patches.music.utils.videoid.patch
import app.revanced.extensions.toErrorResult import app.revanced.extensions.exception
import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
import app.revanced.patches.music.utils.videoid.fingerprint.VideoIdParentFingerprint import app.revanced.patches.music.utils.videoid.fingerprint.VideoIdParentFingerprint
import app.revanced.util.integrations.Constants.MUSIC_UTILS_PATH import app.revanced.util.integrations.Constants.MUSIC_UTILS_PATH
@ -18,7 +16,7 @@ import com.android.tools.smali.dexlib2.iface.reference.FieldReference
class VideoIdPatch : BytecodePatch( class VideoIdPatch : BytecodePatch(
listOf(VideoIdParentFingerprint) listOf(VideoIdParentFingerprint)
) { ) {
override fun execute(context: BytecodeContext): PatchResult { override fun execute(context: BytecodeContext) {
VideoIdParentFingerprint.result?.let { VideoIdParentFingerprint.result?.let {
it.mutableMethod.apply { it.mutableMethod.apply {
@ -33,7 +31,7 @@ class VideoIdPatch : BytecodePatch(
method.name == "handleVideoStageEvent" method.name == "handleVideoStageEvent"
} }
} }
} ?: return VideoIdParentFingerprint.toErrorResult() } ?: throw VideoIdParentFingerprint.exception
insertMethod.apply { insertMethod.apply {
for (index in implementation!!.instructions.size - 1 downTo 0) { for (index in implementation!!.instructions.size - 1 downTo 0) {
@ -53,7 +51,6 @@ class VideoIdPatch : BytecodePatch(
injectCall("$INTEGRATIONS_CLASS_DESCRIPTOR->setVideoId(Ljava/lang/String;)V") injectCall("$INTEGRATIONS_CLASS_DESCRIPTOR->setVideoId(Ljava/lang/String;)V")
return PatchResultSuccess()
} }
companion object { companion object {

View File

@ -1,12 +1,10 @@
package app.revanced.patches.reddit.ad.banner.patch package app.revanced.patches.reddit.ad.banner.patch
import app.revanced.patcher.data.ResourceContext import app.revanced.patcher.data.ResourceContext
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.ResourcePatch
class HideBannerPatch : ResourcePatch { class HideBannerPatch : ResourcePatch {
override fun execute(context: ResourceContext): PatchResult { override fun execute(context: ResourceContext) {
context.xmlEditor[RESOURCE_FILE_PATH].use { context.xmlEditor[RESOURCE_FILE_PATH].use {
it.file.getElementsByTagName("merge").item(0).childNodes.apply { it.file.getElementsByTagName("merge").item(0).childNodes.apply {
val attributes = arrayOf("height", "width") val attributes = arrayOf("height", "width")
@ -28,7 +26,6 @@ class HideBannerPatch : ResourcePatch {
} }
} }
return PatchResultSuccess()
} }
private companion object { private companion object {

View File

@ -1,13 +1,10 @@
package app.revanced.patches.reddit.ad.comments.patch package app.revanced.patches.reddit.ad.comments.patch
import app.revanced.extensions.toErrorResult import app.revanced.extensions.exception
import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.data.toMethodWalker
import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
import app.revanced.patcher.util.smali.ExternalLabel import app.revanced.patcher.util.smali.ExternalLabel
import app.revanced.patches.reddit.ad.comments.fingerprints.HideCommentAdsFingerprint import app.revanced.patches.reddit.ad.comments.fingerprints.HideCommentAdsFingerprint
@ -15,7 +12,7 @@ import app.revanced.patches.reddit.ad.comments.fingerprints.HideCommentAdsFinger
class HideCommentAdsPatch : BytecodePatch( class HideCommentAdsPatch : BytecodePatch(
listOf(HideCommentAdsFingerprint) listOf(HideCommentAdsFingerprint)
) { ) {
override fun execute(context: BytecodeContext): PatchResult { override fun execute(context: BytecodeContext) {
HideCommentAdsFingerprint.result?.let { HideCommentAdsFingerprint.result?.let {
with( with(
context context
@ -34,9 +31,8 @@ class HideCommentAdsPatch : BytecodePatch(
""", ExternalLabel("show", getInstruction(0)) """, ExternalLabel("show", getInstruction(0))
) )
} }
} ?: return HideCommentAdsFingerprint.toErrorResult() } ?: throw HideCommentAdsFingerprint.exception
return PatchResultSuccess()
} }
private companion object { private companion object {

View File

@ -1,17 +1,14 @@
package app.revanced.patches.reddit.ad.general.patch package app.revanced.patches.reddit.ad.general.patch
import app.revanced.extensions.toErrorResult import app.revanced.extensions.exception
import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchException
import app.revanced.patcher.patch.PatchResultError
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patcher.patch.annotations.RequiresIntegrations import app.revanced.patcher.patch.annotations.RequiresIntegrations
@ -40,14 +37,13 @@ import com.android.tools.smali.dexlib2.iface.reference.FieldReference
) )
@RedditCompatibility @RedditCompatibility
@RequiresIntegrations @RequiresIntegrations
@Version("0.0.2")
class HideAdsPatch : BytecodePatch( class HideAdsPatch : BytecodePatch(
listOf( listOf(
AdPostFingerprint, AdPostFingerprint,
NewAdPostFingerprint NewAdPostFingerprint
) )
) { ) {
override fun execute(context: BytecodeContext): PatchResult { override fun execute(context: BytecodeContext) {
// region Filter promoted ads (does not work in popular or latest feed) // region Filter promoted ads (does not work in popular or latest feed)
AdPostFingerprint.result?.let { AdPostFingerprint.result?.let {
@ -57,7 +53,7 @@ class HideAdsPatch : BytecodePatch(
val targetReferenceName = (targetReference as FieldReference).name val targetReferenceName = (targetReference as FieldReference).name
if (targetReferenceName != "children") if (targetReferenceName != "children")
throw PatchResultError("Method signature reference name did not match: $targetReferenceName") throw PatchException("Method signature reference name did not match: $targetReferenceName")
val targetRegister = getInstruction<Instruction22c>(targetIndex).registerA val targetRegister = getInstruction<Instruction22c>(targetIndex).registerA
@ -68,7 +64,7 @@ class HideAdsPatch : BytecodePatch(
""" """
) )
} }
} ?: return AdPostFingerprint.toErrorResult() } ?: throw AdPostFingerprint.exception
// The new feeds work by inserting posts into lists. // The new feeds work by inserting posts into lists.
// AdElementConverter is conveniently responsible for inserting all feed ads. // AdElementConverter is conveniently responsible for inserting all feed ads.
@ -80,7 +76,7 @@ class HideAdsPatch : BytecodePatch(
getInstruction<ReferenceInstruction>(targetIndex).reference.toString() getInstruction<ReferenceInstruction>(targetIndex).reference.toString()
if (!targetParameter.endsWith("Ljava/util/ArrayList;->add(Ljava/lang/Object;)Z")) if (!targetParameter.endsWith("Ljava/util/ArrayList;->add(Ljava/lang/Object;)Z"))
throw PatchResultError("Method signature parameter did not match: $targetParameter") throw PatchException("Method signature parameter did not match: $targetParameter")
val targetRegister = val targetRegister =
getInstruction<FiveRegisterInstruction>(targetIndex).registerD + 1 getInstruction<FiveRegisterInstruction>(targetIndex).registerD + 1
@ -93,11 +89,10 @@ class HideAdsPatch : BytecodePatch(
""", ExternalLabel("show", getInstruction(targetIndex + 1)) """, ExternalLabel("show", getInstruction(targetIndex + 1))
) )
} }
} ?: return NewAdPostFingerprint.toErrorResult() } ?: throw NewAdPostFingerprint.exception
updateSettingsStatus("GeneralAds") updateSettingsStatus("GeneralAds")
return PatchResultSuccess()
} }
private companion object { private companion object {

View File

@ -1,15 +1,12 @@
package app.revanced.patches.reddit.layout.navigation.patch package app.revanced.patches.reddit.layout.navigation.patch
import app.revanced.extensions.toErrorResult import app.revanced.extensions.exception
import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.reddit.layout.navigation.fingerprints.BottomNavScreenFingerprint import app.revanced.patches.reddit.layout.navigation.fingerprints.BottomNavScreenFingerprint
@ -23,11 +20,10 @@ import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
@Description("Hide buttons at navigation bar.") @Description("Hide buttons at navigation bar.")
@DependsOn([SettingsPatch::class]) @DependsOn([SettingsPatch::class])
@RedditCompatibility @RedditCompatibility
@Version("0.0.1")
class NavigationButtonsPatch : BytecodePatch( class NavigationButtonsPatch : BytecodePatch(
listOf(BottomNavScreenFingerprint) listOf(BottomNavScreenFingerprint)
) { ) {
override fun execute(context: BytecodeContext): PatchResult { override fun execute(context: BytecodeContext) {
BottomNavScreenFingerprint.result?.let { BottomNavScreenFingerprint.result?.let {
it.mutableMethod.apply { it.mutableMethod.apply {
@ -40,11 +36,10 @@ class NavigationButtonsPatch : BytecodePatch(
"invoke-static {v$targetRegister}, $INTEGRATIONS_METHOD_DESCRIPTOR" "invoke-static {v$targetRegister}, $INTEGRATIONS_METHOD_DESCRIPTOR"
) )
} }
} ?: return BottomNavScreenFingerprint.toErrorResult() } ?: throw BottomNavScreenFingerprint.exception
updateSettingsStatus("NavigationButtons") updateSettingsStatus("NavigationButtons")
return PatchResultSuccess()
} }
companion object { companion object {

View File

@ -1,15 +1,12 @@
package app.revanced.patches.reddit.layout.place.patch package app.revanced.patches.reddit.layout.place.patch
import app.revanced.extensions.toErrorResult import app.revanced.extensions.exception
import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.reddit.layout.place.fingerprints.HomePagerScreenFingerprint import app.revanced.patches.reddit.layout.place.fingerprints.HomePagerScreenFingerprint
@ -24,11 +21,10 @@ import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
@Description("Hide r/place button in toolbar.") @Description("Hide r/place button in toolbar.")
@DependsOn([SettingsPatch::class]) @DependsOn([SettingsPatch::class])
@RedditCompatibility @RedditCompatibility
@Version("0.0.1")
class PlaceButtonPatch : BytecodePatch( class PlaceButtonPatch : BytecodePatch(
listOf(HomePagerScreenFingerprint) listOf(HomePagerScreenFingerprint)
) { ) {
override fun execute(context: BytecodeContext): PatchResult { override fun execute(context: BytecodeContext) {
HomePagerScreenFingerprint.result?.let { HomePagerScreenFingerprint.result?.let {
it.mutableMethod.apply { it.mutableMethod.apply {
@ -42,11 +38,10 @@ class PlaceButtonPatch : BytecodePatch(
"invoke-static {v$targetRegister}, $INTEGRATIONS_METHOD_DESCRIPTOR" "invoke-static {v$targetRegister}, $INTEGRATIONS_METHOD_DESCRIPTOR"
) )
} }
} ?: return HomePagerScreenFingerprint.toErrorResult() } ?: throw HomePagerScreenFingerprint.exception
updateSettingsStatus("PlaceButton") updateSettingsStatus("PlaceButton")
return PatchResultSuccess()
} }
companion object { companion object {

View File

@ -1,14 +1,11 @@
package app.revanced.patches.reddit.layout.premiumicon.patch package app.revanced.patches.reddit.layout.premiumicon.patch
import app.revanced.extensions.toErrorResult import app.revanced.extensions.exception
import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.Patch import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.reddit.layout.premiumicon.fingerprints.PremiumIconFingerprint import app.revanced.patches.reddit.layout.premiumicon.fingerprints.PremiumIconFingerprint
import app.revanced.patches.reddit.utils.annotations.RedditCompatibility import app.revanced.patches.reddit.utils.annotations.RedditCompatibility
@ -17,11 +14,10 @@ import app.revanced.patches.reddit.utils.annotations.RedditCompatibility
@Name("Premium icon") @Name("Premium icon")
@Description("Unlocks premium icons.") @Description("Unlocks premium icons.")
@RedditCompatibility @RedditCompatibility
@Version("0.0.1")
class PremiumIconPatch : BytecodePatch( class PremiumIconPatch : BytecodePatch(
listOf(PremiumIconFingerprint) listOf(PremiumIconFingerprint)
) { ) {
override fun execute(context: BytecodeContext): PatchResult { override fun execute(context: BytecodeContext) {
PremiumIconFingerprint.result?.let { PremiumIconFingerprint.result?.let {
it.mutableMethod.apply { it.mutableMethod.apply {
@ -32,8 +28,7 @@ class PremiumIconPatch : BytecodePatch(
""" """
) )
} }
} ?: return PremiumIconFingerprint.toErrorResult() } ?: throw PremiumIconFingerprint.exception
return PatchResultSuccess()
} }
} }

View File

@ -1,15 +1,12 @@
package app.revanced.patches.reddit.layout.screenshotpopup.patch package app.revanced.patches.reddit.layout.screenshotpopup.patch
import app.revanced.extensions.toErrorResult import app.revanced.extensions.exception
import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patcher.util.smali.ExternalLabel import app.revanced.patcher.util.smali.ExternalLabel
@ -29,11 +26,10 @@ import app.revanced.patches.reddit.utils.settings.resource.patch.SettingsPatch
] ]
) )
@RedditCompatibility @RedditCompatibility
@Version("0.0.1")
class ScreenshotPopupPatch : BytecodePatch( class ScreenshotPopupPatch : BytecodePatch(
listOf(ScreenshotTakenBannerFingerprint) listOf(ScreenshotTakenBannerFingerprint)
) { ) {
override fun execute(context: BytecodeContext): PatchResult { override fun execute(context: BytecodeContext) {
ScreenshotTakenBannerFingerprint.result?.let { ScreenshotTakenBannerFingerprint.result?.let {
it.mutableMethod.apply { it.mutableMethod.apply {
@ -46,11 +42,10 @@ class ScreenshotPopupPatch : BytecodePatch(
""", ExternalLabel("dismiss", getInstruction(0)) """, ExternalLabel("dismiss", getInstruction(0))
) )
} }
} ?: return ScreenshotTakenBannerFingerprint.toErrorResult() } ?: throw ScreenshotTakenBannerFingerprint.exception
updateSettingsStatus("ScreenshotPopup") updateSettingsStatus("ScreenshotPopup")
return PatchResultSuccess()
} }
private companion object { private companion object {

View File

@ -1,14 +1,11 @@
package app.revanced.patches.reddit.misc.openlink.patch package app.revanced.patches.reddit.misc.openlink.patch
import app.revanced.extensions.toErrorResult import app.revanced.extensions.exception
import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.reddit.misc.openlink.fingerprints.ScreenNavigatorFingerprint import app.revanced.patches.reddit.misc.openlink.fingerprints.ScreenNavigatorFingerprint
@ -21,11 +18,10 @@ import app.revanced.patches.reddit.utils.settings.resource.patch.SettingsPatch
@Description("Skips over redirection URLs to external links.") @Description("Skips over redirection URLs to external links.")
@DependsOn([SettingsPatch::class]) @DependsOn([SettingsPatch::class])
@RedditCompatibility @RedditCompatibility
@Version("0.0.1")
class OpenLinksDirectlyPatch : BytecodePatch( class OpenLinksDirectlyPatch : BytecodePatch(
listOf(ScreenNavigatorFingerprint) listOf(ScreenNavigatorFingerprint)
) { ) {
override fun execute(context: BytecodeContext): PatchResult { override fun execute(context: BytecodeContext) {
ScreenNavigatorFingerprint.result?.let { ScreenNavigatorFingerprint.result?.let {
it.mutableMethod.apply { it.mutableMethod.apply {
addInstructions( addInstructions(
@ -35,11 +31,10 @@ class OpenLinksDirectlyPatch : BytecodePatch(
""" """
) )
} }
} ?: return ScreenNavigatorFingerprint.toErrorResult() } ?: throw ScreenNavigatorFingerprint.exception
updateSettingsStatus("OpenLinksDirectly") updateSettingsStatus("OpenLinksDirectly")
return PatchResultSuccess()
} }
private companion object { private companion object {

View File

@ -1,15 +1,12 @@
package app.revanced.patches.reddit.misc.openlink.patch package app.revanced.patches.reddit.misc.openlink.patch
import app.revanced.extensions.toErrorResult import app.revanced.extensions.exception
import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patcher.util.smali.ExternalLabel import app.revanced.patcher.util.smali.ExternalLabel
@ -24,11 +21,10 @@ import app.revanced.util.bytecode.getStringIndex
@Description("Open links outside of the app directly in your browser.") @Description("Open links outside of the app directly in your browser.")
@DependsOn([SettingsPatch::class]) @DependsOn([SettingsPatch::class])
@RedditCompatibility @RedditCompatibility
@Version("0.0.1")
class OpenLinksExternallyPatch : BytecodePatch( class OpenLinksExternallyPatch : BytecodePatch(
listOf(ScreenNavigatorFingerprint) listOf(ScreenNavigatorFingerprint)
) { ) {
override fun execute(context: BytecodeContext): PatchResult { override fun execute(context: BytecodeContext) {
ScreenNavigatorFingerprint.result?.let { ScreenNavigatorFingerprint.result?.let {
it.mutableMethod.apply { it.mutableMethod.apply {
val insertIndex = getStringIndex("uri") + 2 val insertIndex = getStringIndex("uri") + 2
@ -42,11 +38,10 @@ class OpenLinksExternallyPatch : BytecodePatch(
""", ExternalLabel("dismiss", getInstruction(insertIndex)) """, ExternalLabel("dismiss", getInstruction(insertIndex))
) )
} }
} ?: return ScreenNavigatorFingerprint.toErrorResult() } ?: throw ScreenNavigatorFingerprint.exception
updateSettingsStatus("OpenLinksExternally") updateSettingsStatus("OpenLinksExternally")
return PatchResultSuccess()
} }
private companion object { private companion object {

View File

@ -1,15 +1,12 @@
package app.revanced.patches.reddit.misc.tracking.url.patch package app.revanced.patches.reddit.misc.tracking.url.patch
import app.revanced.extensions.toErrorResult import app.revanced.extensions.exception
import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patcher.util.smali.ExternalLabel import app.revanced.patcher.util.smali.ExternalLabel
@ -23,11 +20,10 @@ import app.revanced.patches.reddit.utils.settings.resource.patch.SettingsPatch
@Description("Removes (tracking) query parameters from the URLs when sharing links.") @Description("Removes (tracking) query parameters from the URLs when sharing links.")
@DependsOn([SettingsPatch::class]) @DependsOn([SettingsPatch::class])
@RedditCompatibility @RedditCompatibility
@Version("0.0.1")
class SanitizeUrlQueryPatch : BytecodePatch( class SanitizeUrlQueryPatch : BytecodePatch(
listOf(ShareLinkFormatterFingerprint) listOf(ShareLinkFormatterFingerprint)
) { ) {
override fun execute(context: BytecodeContext): PatchResult { override fun execute(context: BytecodeContext) {
ShareLinkFormatterFingerprint.result?.let { result -> ShareLinkFormatterFingerprint.result?.let { result ->
result.mutableMethod.apply { result.mutableMethod.apply {
@ -41,11 +37,10 @@ class SanitizeUrlQueryPatch : BytecodePatch(
""", ExternalLabel("off", getInstruction(0)) """, ExternalLabel("off", getInstruction(0))
) )
} }
} ?: return ShareLinkFormatterFingerprint.toErrorResult() } ?: throw ShareLinkFormatterFingerprint.exception
updateSettingsStatus("SanitizeUrlQuery") updateSettingsStatus("SanitizeUrlQuery")
return PatchResultSuccess()
} }
private companion object { private companion object {

View File

@ -1,12 +1,10 @@
package app.revanced.patches.reddit.utils.fix.decoding.patch package app.revanced.patches.reddit.utils.fix.decoding.patch
import app.revanced.patcher.data.ResourceContext import app.revanced.patcher.data.ResourceContext
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.ResourcePatch
class DecodingPatch : ResourcePatch { class DecodingPatch : ResourcePatch {
override fun execute(context: ResourceContext): PatchResult { override fun execute(context: ResourceContext) {
arrayOf( arrayOf(
"res/layout/notification_media_cancel_action.xml", "res/layout/notification_media_cancel_action.xml",
@ -26,6 +24,5 @@ class DecodingPatch : ResourcePatch {
} }
} }
return PatchResultSuccess()
} }
} }

View File

@ -1,9 +1,7 @@
package app.revanced.patches.reddit.utils.resourceid.patch package app.revanced.patches.reddit.utils.resourceid.patch
import app.revanced.patcher.data.ResourceContext import app.revanced.patcher.data.ResourceContext
import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchException
import app.revanced.patcher.patch.PatchResultError
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.ResourcePatch
import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patches.shared.patch.mapping.ResourceMappingPatch import app.revanced.patches.shared.patch.mapping.ResourceMappingPatch
@ -16,15 +14,14 @@ class SharedResourceIdPatch : ResourcePatch {
var ScreenShotShareBanner: Long = -1 var ScreenShotShareBanner: Long = -1
} }
override fun execute(context: ResourceContext): PatchResult { override fun execute(context: ResourceContext) {
fun find(resourceType: ResourceType, resourceName: String) = ResourceMappingPatch fun find(resourceType: ResourceType, resourceName: String) = ResourceMappingPatch
.resourceMappings .resourceMappings
.find { it.type == resourceType.value && it.name == resourceName }?.id .find { it.type == resourceType.value && it.name == resourceName }?.id
?: throw PatchResultError("Failed to find resource id : $resourceName") ?: throw PatchException("Failed to find resource id : $resourceName")
ScreenShotShareBanner = find(STRING, "screenshot_share_banner_title") ScreenShotShareBanner = find(STRING, "screenshot_share_banner_title")
return PatchResultSuccess()
} }
} }

View File

@ -1,13 +1,11 @@
package app.revanced.patches.reddit.utils.settings.bytecode.patch package app.revanced.patches.reddit.utils.settings.bytecode.patch
import app.revanced.extensions.toErrorResult import app.revanced.extensions.exception
import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
import app.revanced.patches.reddit.utils.settings.bytecode.fingerprints.AcknowledgementsLabelBuilderFingerprint import app.revanced.patches.reddit.utils.settings.bytecode.fingerprints.AcknowledgementsLabelBuilderFingerprint
import app.revanced.patches.reddit.utils.settings.bytecode.fingerprints.OssLicensesMenuActivityOnCreateFingerprint import app.revanced.patches.reddit.utils.settings.bytecode.fingerprints.OssLicensesMenuActivityOnCreateFingerprint
@ -22,7 +20,7 @@ class SettingsBytecodePatch : BytecodePatch(
SettingsStatusLoadFingerprint SettingsStatusLoadFingerprint
) )
) { ) {
override fun execute(context: BytecodeContext): PatchResult { override fun execute(context: BytecodeContext) {
/** /**
* Replace settings label * Replace settings label
@ -39,7 +37,7 @@ class SettingsBytecodePatch : BytecodePatch(
"const-string v$insertRegister, \"ReVanced Extended\"" "const-string v$insertRegister, \"ReVanced Extended\""
) )
} }
} ?: return AcknowledgementsLabelBuilderFingerprint.toErrorResult() } ?: throw AcknowledgementsLabelBuilderFingerprint.exception
/** /**
* Initialize settings activity * Initialize settings activity
@ -55,12 +53,11 @@ class SettingsBytecodePatch : BytecodePatch(
""" """
) )
} }
} ?: return OssLicensesMenuActivityOnCreateFingerprint.toErrorResult() } ?: throw OssLicensesMenuActivityOnCreateFingerprint.exception
settingsMethod = SettingsStatusLoadFingerprint.result?.mutableMethod settingsMethod = SettingsStatusLoadFingerprint.result?.mutableMethod
?: return SettingsStatusLoadFingerprint.toErrorResult() ?: throw SettingsStatusLoadFingerprint.exception
return PatchResultSuccess()
} }
internal companion object { internal companion object {

View File

@ -2,11 +2,8 @@ package app.revanced.patches.reddit.utils.settings.resource.patch
import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.ResourceContext import app.revanced.patcher.data.ResourceContext
import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchException
import app.revanced.patcher.patch.PatchResultError
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.ResourcePatch
import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch import app.revanced.patcher.patch.annotations.Patch
@ -27,9 +24,8 @@ import kotlin.io.path.exists
] ]
) )
@RedditCompatibility @RedditCompatibility
@Version("0.0.1")
class SettingsPatch : ResourcePatch { class SettingsPatch : ResourcePatch {
override fun execute(context: ResourceContext): PatchResult { override fun execute(context: ResourceContext) {
/** /**
* Replace settings icon and label * Replace settings icon and label
@ -39,7 +35,7 @@ class SettingsPatch : ResourcePatch {
val targetXml = resDirectory.resolve("xml").resolve("$targetXML.xml").toPath() val targetXml = resDirectory.resolve("xml").resolve("$targetXML.xml").toPath()
if (!targetXml.exists()) if (!targetXml.exists())
return PatchResultError("The preferences can not be found.") throw PatchException("The preferences can not be found.")
val preference = context["res/xml/$targetXML.xml"] val preference = context["res/xml/$targetXML.xml"]
@ -52,6 +48,5 @@ class SettingsPatch : ResourcePatch {
) )
} }
return PatchResultSuccess()
} }
} }

View File

@ -1,14 +1,11 @@
package app.revanced.patches.shared.patch.ads package app.revanced.patches.shared.patch.ads
import app.revanced.extensions.toErrorResult import app.revanced.extensions.exception
import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.data.toMethodWalker
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
import app.revanced.patcher.util.smali.ExternalLabel import app.revanced.patcher.util.smali.ExternalLabel
import app.revanced.patches.shared.fingerprints.ads.LegacyAdsFingerprint import app.revanced.patches.shared.fingerprints.ads.LegacyAdsFingerprint
@ -22,7 +19,7 @@ abstract class AbstractAdsPatch(
MainstreamAdsFingerprint MainstreamAdsFingerprint
) )
) { ) {
override fun execute(context: BytecodeContext): PatchResult { override fun execute(context: BytecodeContext) {
LegacyAdsFingerprint.result?.let { LegacyAdsFingerprint.result?.let {
(context.toMethodWalker(it.method) (context.toMethodWalker(it.method)
.nextMethod(13, true) .nextMethod(13, true)
@ -34,7 +31,7 @@ abstract class AbstractAdsPatch(
""" """
) )
} }
} ?: return LegacyAdsFingerprint.toErrorResult() } ?: throw LegacyAdsFingerprint.exception
MainstreamAdsFingerprint.result?.let { MainstreamAdsFingerprint.result?.let {
it.mutableMethod.apply { it.mutableMethod.apply {
@ -49,6 +46,5 @@ abstract class AbstractAdsPatch(
} }
} }
return PatchResultSuccess()
} }
} }

View File

@ -1,22 +1,17 @@
package app.revanced.patches.shared.patch.integrations package app.revanced.patches.shared.patch.integrations
import app.revanced.extensions.toErrorResult
import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchException
import app.revanced.patcher.patch.PatchResultError
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patches.shared.patch.integrations.AbstractIntegrationsPatch.IntegrationsFingerprint.RegisterResolver import app.revanced.patches.shared.patch.integrations.AbstractIntegrationsPatch.IntegrationsFingerprint.RegisterResolver
import com.android.tools.smali.dexlib2.Opcode import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.ClassDef import com.android.tools.smali.dexlib2.iface.ClassDef
import com.android.tools.smali.dexlib2.iface.Method import com.android.tools.smali.dexlib2.iface.Method
@Description("Applies mandatory patches to implement the ReVanced integrations into the application.") @Description("Applies mandatory patches to implement the ReVanced integrations into the application.")
@Version("0.0.1")
abstract class AbstractIntegrationsPatch( abstract class AbstractIntegrationsPatch(
private val integrationsDescriptor: String, private val integrationsDescriptor: String,
private val hooks: Iterable<IntegrationsFingerprint> private val hooks: Iterable<IntegrationsFingerprint>
@ -43,7 +38,7 @@ abstract class AbstractIntegrationsPatch(
strings, strings,
customFingerprint customFingerprint
) { ) {
fun invoke(integrationsDescriptor: String): PatchResult { fun invoke(integrationsDescriptor: String) {
result?.mutableMethod?.let { method -> result?.mutableMethod?.let { method ->
val contextRegister = contextRegisterResolver(method) val contextRegister = contextRegisterResolver(method)
@ -52,9 +47,7 @@ abstract class AbstractIntegrationsPatch(
"sput-object v$contextRegister, " + "sput-object v$contextRegister, " +
"$integrationsDescriptor->context:Landroid/content/Context;" "$integrationsDescriptor->context:Landroid/content/Context;"
) )
} ?: return toErrorResult() } ?: throw PatchException("Could not find target fingerprint.")
return PatchResultSuccess()
} }
interface RegisterResolver : (Method) -> Int { interface RegisterResolver : (Method) -> Int {
@ -62,20 +55,11 @@ abstract class AbstractIntegrationsPatch(
} }
} }
override fun execute(context: BytecodeContext): PatchResult { override fun execute(context: BytecodeContext) {
if (context.findClass(integrationsDescriptor) == null) return MISSING_INTEGRATIONS if (context.findClass(integrationsDescriptor) == null) throw PatchException(
"Integrations have not been merged yet. This patch can not succeed without merging the integrations."
for (hook in hooks) hook.invoke(integrationsDescriptor).let {
if (it is PatchResultError) return it
}
return PatchResultSuccess()
}
private companion object {
val MISSING_INTEGRATIONS = PatchResultError(
"Integrations have not been merged yet. " +
"This patch can not succeed without merging the integrations."
) )
for (hook in hooks) hook.invoke(integrationsDescriptor)
} }
} }

View File

@ -1,13 +1,11 @@
package app.revanced.patches.shared.patch.litho package app.revanced.patches.shared.patch.litho
import app.revanced.extensions.toErrorResult import app.revanced.extensions.exception
import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchException
import app.revanced.patcher.patch.PatchResultError
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
import app.revanced.patcher.util.smali.ExternalLabel import app.revanced.patcher.util.smali.ExternalLabel
import app.revanced.patches.shared.fingerprints.litho.EmptyComponentBuilderFingerprint import app.revanced.patches.shared.fingerprints.litho.EmptyComponentBuilderFingerprint
@ -27,7 +25,7 @@ class ComponentParserPatch : BytecodePatch(
IdentifierFingerprint IdentifierFingerprint
) )
) { ) {
override fun execute(context: BytecodeContext): PatchResult { override fun execute(context: BytecodeContext) {
EmptyComponentBuilderFingerprint.result?.let { EmptyComponentBuilderFingerprint.result?.let {
it.mutableMethod.apply { it.mutableMethod.apply {
@ -52,9 +50,9 @@ class ComponentParserPatch : BytecodePatch(
} }
if (emptyComponentLabel.isEmpty()) if (emptyComponentLabel.isEmpty())
throw PatchResultError("could not find Empty Component Label in method") throw PatchException("could not find Empty Component Label in method")
} }
} ?: return EmptyComponentBuilderFingerprint.toErrorResult() } ?: throw EmptyComponentBuilderFingerprint.exception
IdentifierFingerprint.result?.let { IdentifierFingerprint.result?.let {
it.mutableMethod.apply { it.mutableMethod.apply {
@ -89,9 +87,8 @@ class ComponentParserPatch : BytecodePatch(
insertIndex = stringBuilderIndex + 1 insertIndex = stringBuilderIndex + 1
} }
} ?: return IdentifierFingerprint.toErrorResult() } ?: throw IdentifierFingerprint.exception
return PatchResultSuccess()
} }
internal companion object { internal companion object {

View File

@ -1,8 +1,6 @@
package app.revanced.patches.shared.patch.mapping package app.revanced.patches.shared.patch.mapping
import app.revanced.patcher.data.ResourceContext import app.revanced.patcher.data.ResourceContext
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.ResourcePatch
import org.w3c.dom.Element import org.w3c.dom.Element
import java.util.Collections import java.util.Collections
@ -18,7 +16,7 @@ class ResourceMappingPatch : ResourcePatch {
private val threadPoolExecutor = Executors.newFixedThreadPool(THREAD_COUNT) private val threadPoolExecutor = Executors.newFixedThreadPool(THREAD_COUNT)
} }
override fun execute(context: ResourceContext): PatchResult { override fun execute(context: ResourceContext) {
// save the file in memory to concurrently read from // save the file in memory to concurrently read from
val resourceXmlFile = context["res/values/public.xml"].readBytes() val resourceXmlFile = context["res/values/public.xml"].readBytes()
@ -59,7 +57,6 @@ class ResourceMappingPatch : ResourcePatch {
resourceMappings = mappings resourceMappings = mappings
return PatchResultSuccess()
} }
} }

View File

@ -1,13 +1,11 @@
package app.revanced.patches.shared.patch.opus package app.revanced.patches.shared.patch.opus
import app.revanced.extensions.toErrorResult import app.revanced.extensions.exception
import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchException
import app.revanced.patcher.patch.PatchResultError
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.util.smali.ExternalLabel import app.revanced.patcher.util.smali.ExternalLabel
import app.revanced.patches.shared.fingerprints.opus.CodecReferenceFingerprint import app.revanced.patches.shared.fingerprints.opus.CodecReferenceFingerprint
import app.revanced.patches.shared.fingerprints.opus.CodecSelectorFingerprint import app.revanced.patches.shared.fingerprints.opus.CodecSelectorFingerprint
@ -24,7 +22,7 @@ abstract class AbstractOpusCodecsPatch(
CodecSelectorFingerprint CodecSelectorFingerprint
) )
) { ) {
override fun execute(context: BytecodeContext): PatchResult { override fun execute(context: BytecodeContext) {
CodecReferenceFingerprint.result?.mutableMethod?.let { CodecReferenceFingerprint.result?.mutableMethod?.let {
it.implementation!!.instructions.apply { it.implementation!!.instructions.apply {
@ -41,9 +39,9 @@ abstract class AbstractOpusCodecsPatch(
} }
} }
if (targetIndex == 0) if (targetIndex == 0)
throw PatchResultError("Target method not found!") throw PatchException("Target method not found!")
} }
} ?: return CodecReferenceFingerprint.toErrorResult() } ?: throw CodecReferenceFingerprint.exception
CodecSelectorFingerprint.result?.let { CodecSelectorFingerprint.result?.let {
it.mutableMethod.apply { it.mutableMethod.apply {
@ -60,9 +58,8 @@ abstract class AbstractOpusCodecsPatch(
""", ExternalLabel("mp4a", getInstruction(targetIndex + 1)) """, ExternalLabel("mp4a", getInstruction(targetIndex + 1))
) )
} }
} ?: return CodecSelectorFingerprint.toErrorResult() } ?: throw CodecSelectorFingerprint.exception
return PatchResultSuccess()
} }
companion object { companion object {

View File

@ -2,12 +2,9 @@ package app.revanced.patches.shared.patch.packagename
import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.ResourceContext import app.revanced.patcher.data.ResourceContext
import app.revanced.patcher.patch.OptionsContainer import app.revanced.patcher.patch.OptionsContainer
import app.revanced.patcher.patch.PatchOption import app.revanced.patcher.patch.PatchOption
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.ResourcePatch
import app.revanced.patcher.patch.annotations.Patch import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.shared.annotation.RVXCompatibility import app.revanced.patches.shared.annotation.RVXCompatibility
@ -16,10 +13,8 @@ import app.revanced.patches.shared.annotation.RVXCompatibility
@Name("Custom package name") @Name("Custom package name")
@Description("Specifies the package name for YouTube and YT Music in the MicroG build.") @Description("Specifies the package name for YouTube and YT Music in the MicroG build.")
@RVXCompatibility @RVXCompatibility
@Version("0.0.1")
class PackageNamePatch : ResourcePatch { class PackageNamePatch : ResourcePatch {
override fun execute(context: ResourceContext): PatchResult { override fun execute(context: ResourceContext) {
return PatchResultSuccess()
} }
companion object : OptionsContainer() { companion object : OptionsContainer() {

View File

@ -1,8 +1,6 @@
package app.revanced.patches.shared.patch.settings package app.revanced.patches.shared.patch.settings
import app.revanced.patcher.data.ResourceContext import app.revanced.patcher.data.ResourceContext
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.ResourcePatch
import app.revanced.util.resources.ResourceUtils import app.revanced.util.resources.ResourceUtils
import app.revanced.util.resources.ResourceUtils.copyResources import app.revanced.util.resources.ResourceUtils.copyResources
@ -19,7 +17,7 @@ abstract class AbstractSettingsResourcePatch(
private val sourceHostDirectory: String, private val sourceHostDirectory: String,
private val isYouTube: Boolean, private val isYouTube: Boolean,
) : ResourcePatch { ) : ResourcePatch {
override fun execute(context: ResourceContext): PatchResult { override fun execute(context: ResourceContext) {
/** /**
* Copy strings * Copy strings
*/ */
@ -34,6 +32,5 @@ abstract class AbstractSettingsResourcePatch(
ResourceUtils.ResourceGroup("xml", "revanced_prefs.xml") ResourceUtils.ResourceGroup("xml", "revanced_prefs.xml")
) )
return PatchResultSuccess()
} }
} }

View File

@ -1,12 +1,10 @@
package app.revanced.patches.shared.patch.versionspoof package app.revanced.patches.shared.patch.versionspoof
import app.revanced.extensions.toErrorResult import app.revanced.extensions.exception
import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve
import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patches.shared.fingerprints.versionspoof.ClientInfoFingerprint import app.revanced.patches.shared.fingerprints.versionspoof.ClientInfoFingerprint
import app.revanced.patches.shared.fingerprints.versionspoof.ClientInfoParentFingerprint import app.revanced.patches.shared.fingerprints.versionspoof.ClientInfoParentFingerprint
import com.android.tools.smali.dexlib2.Opcode import com.android.tools.smali.dexlib2.Opcode
@ -19,7 +17,7 @@ abstract class AbstractVersionSpoofPatch(
) : BytecodePatch( ) : BytecodePatch(
listOf(ClientInfoParentFingerprint) listOf(ClientInfoParentFingerprint)
) { ) {
override fun execute(context: BytecodeContext): PatchResult { override fun execute(context: BytecodeContext) {
ClientInfoParentFingerprint.result?.let { parentResult -> ClientInfoParentFingerprint.result?.let { parentResult ->
ClientInfoFingerprint.also { ClientInfoFingerprint.also {
@ -52,11 +50,10 @@ abstract class AbstractVersionSpoofPatch(
) )
break break
} }
if (insertIndex <= 0) return ClientInfoFingerprint.toErrorResult() if (insertIndex <= 0) throw ClientInfoFingerprint.exception
} }
} ?: return ClientInfoFingerprint.toErrorResult() } ?: throw ClientInfoFingerprint.exception
} ?: return ClientInfoParentFingerprint.toErrorResult() } ?: throw ClientInfoParentFingerprint.exception
return PatchResultSuccess()
} }
} }

View File

@ -5,8 +5,6 @@ import app.revanced.extensions.injectHideCall
import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch
import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch.Companion.AdAttribution import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch.Companion.AdAttribution
@ -18,7 +16,7 @@ import com.android.tools.smali.dexlib2.iface.instruction.formats.Instruction35c
@DependsOn([SharedResourceIdPatch::class]) @DependsOn([SharedResourceIdPatch::class])
@Suppress("LABEL_NAME_CLASH") @Suppress("LABEL_NAME_CLASH")
class GeneralAdsBytecodePatch : BytecodePatch() { class GeneralAdsBytecodePatch : BytecodePatch() {
override fun execute(context: BytecodeContext): PatchResult { override fun execute(context: BytecodeContext) {
context.classes.forEach { classDef -> context.classes.forEach { classDef ->
classDef.methods.forEach { method -> classDef.methods.forEach { method ->
if (!method.isWideLiteralExists(AdAttribution)) if (!method.isWideLiteralExists(AdAttribution))
@ -44,6 +42,5 @@ class GeneralAdsBytecodePatch : BytecodePatch() {
} }
} }
return PatchResultSuccess()
} }
} }

View File

@ -4,10 +4,7 @@ import app.revanced.extensions.doRecursively
import app.revanced.extensions.startsWithAny import app.revanced.extensions.startsWithAny
import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.ResourceContext import app.revanced.patcher.data.ResourceContext
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.ResourcePatch
import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch import app.revanced.patcher.patch.annotations.Patch
@ -36,7 +33,6 @@ import org.w3c.dom.Element
] ]
) )
@YouTubeCompatibility @YouTubeCompatibility
@Version("0.0.1")
class GeneralAdsPatch : ResourcePatch { class GeneralAdsPatch : ResourcePatch {
private val resourceFileNames = arrayOf( private val resourceFileNames = arrayOf(
"promoted_", "promoted_",
@ -59,7 +55,7 @@ class GeneralAdsPatch : ResourcePatch {
"Top" "Top"
) )
override fun execute(context: ResourceContext): PatchResult { override fun execute(context: ResourceContext) {
LithoFilterPatch.addFilter("$PATCHES_PATH/ads/AdsFilter;") LithoFilterPatch.addFilter("$PATCHES_PATH/ads/AdsFilter;")
context.forEach { context.forEach {
@ -111,6 +107,5 @@ class GeneralAdsPatch : ResourcePatch {
SettingsPatch.updatePatchStatus("hide-general-ads") SettingsPatch.updatePatchStatus("hide-general-ads")
return PatchResultSuccess()
} }
} }

View File

@ -1,12 +1,10 @@
package app.revanced.patches.youtube.ads.getpremium.patch package app.revanced.patches.youtube.ads.getpremium.patch
import app.revanced.extensions.toErrorResult import app.revanced.extensions.exception
import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.util.smali.ExternalLabel import app.revanced.patcher.util.smali.ExternalLabel
import app.revanced.patches.youtube.ads.getpremium.fingerprints.CompactYpcOfferModuleViewFingerprint import app.revanced.patches.youtube.ads.getpremium.fingerprints.CompactYpcOfferModuleViewFingerprint
import app.revanced.util.integrations.Constants.PATCHES_PATH import app.revanced.util.integrations.Constants.PATCHES_PATH
@ -15,7 +13,7 @@ import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction
class HideGetPremiumPatch : BytecodePatch( class HideGetPremiumPatch : BytecodePatch(
listOf(CompactYpcOfferModuleViewFingerprint) listOf(CompactYpcOfferModuleViewFingerprint)
) { ) {
override fun execute(context: BytecodeContext): PatchResult { override fun execute(context: BytecodeContext) {
CompactYpcOfferModuleViewFingerprint.result?.let { CompactYpcOfferModuleViewFingerprint.result?.let {
it.mutableMethod.apply { it.mutableMethod.apply {
@ -37,8 +35,7 @@ class HideGetPremiumPatch : BytecodePatch(
""", ExternalLabel("show", getInstruction(startIndex + 2)) """, ExternalLabel("show", getInstruction(startIndex + 2))
) )
} }
} ?: return CompactYpcOfferModuleViewFingerprint.toErrorResult() } ?: throw CompactYpcOfferModuleViewFingerprint.exception
return PatchResultSuccess()
} }
} }

View File

@ -2,10 +2,7 @@ package app.revanced.patches.youtube.ads.video.patch
import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.shared.patch.ads.AbstractAdsPatch import app.revanced.patches.shared.patch.ads.AbstractAdsPatch
@ -18,11 +15,10 @@ import app.revanced.util.integrations.Constants.ADS_PATH
@Description("Hides ads in the video player.") @Description("Hides ads in the video player.")
@DependsOn([SettingsPatch::class]) @DependsOn([SettingsPatch::class])
@YouTubeCompatibility @YouTubeCompatibility
@Version("0.0.1")
class VideoAdsPatch : AbstractAdsPatch( class VideoAdsPatch : AbstractAdsPatch(
"$ADS_PATH/HideVideoAdsPatch;->hideVideoAds()Z" "$ADS_PATH/HideVideoAdsPatch;->hideVideoAds()Z"
) { ) {
override fun execute(context: BytecodeContext): PatchResult { override fun execute(context: BytecodeContext) {
super.execute(context) super.execute(context)
/** /**
@ -37,6 +33,5 @@ class VideoAdsPatch : AbstractAdsPatch(
SettingsPatch.updatePatchStatus("hide-video-ads") SettingsPatch.updatePatchStatus("hide-video-ads")
return PatchResultSuccess()
} }
} }

View File

@ -2,10 +2,7 @@ package app.revanced.patches.youtube.buttomplayer.buttoncontainer.patch
import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.ResourceContext import app.revanced.patcher.data.ResourceContext
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.ResourcePatch
import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch import app.revanced.patcher.patch.annotations.Patch
@ -24,9 +21,8 @@ import app.revanced.util.integrations.Constants.PATCHES_PATH
] ]
) )
@YouTubeCompatibility @YouTubeCompatibility
@Version("0.0.1")
class ButtonContainerPatch : ResourcePatch { class ButtonContainerPatch : ResourcePatch {
override fun execute(context: ResourceContext): PatchResult { override fun execute(context: ResourceContext) {
LithoFilterPatch.addFilter("$PATCHES_PATH/ads/ButtonsFilter;") LithoFilterPatch.addFilter("$PATCHES_PATH/ads/ButtonsFilter;")
@ -42,6 +38,5 @@ class ButtonContainerPatch : ResourcePatch {
SettingsPatch.updatePatchStatus("hide-button-container") SettingsPatch.updatePatchStatus("hide-button-container")
return PatchResultSuccess()
} }
} }

View File

@ -2,10 +2,7 @@ package app.revanced.patches.youtube.buttomplayer.comment.patch
import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.ResourceContext import app.revanced.patcher.data.ResourceContext
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.ResourcePatch
import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch import app.revanced.patcher.patch.annotations.Patch
@ -26,9 +23,8 @@ import app.revanced.util.integrations.Constants.PATCHES_PATH
] ]
) )
@YouTubeCompatibility @YouTubeCompatibility
@Version("0.0.1")
class CommentComponentPatch : ResourcePatch { class CommentComponentPatch : ResourcePatch {
override fun execute(context: ResourceContext): PatchResult { override fun execute(context: ResourceContext) {
LithoFilterPatch.addFilter("$PATCHES_PATH/ads/CommentsFilter;") LithoFilterPatch.addFilter("$PATCHES_PATH/ads/CommentsFilter;")
LithoFilterPatch.addFilter("$PATCHES_PATH/ads/CommentsPreviewDotsFilter;") LithoFilterPatch.addFilter("$PATCHES_PATH/ads/CommentsPreviewDotsFilter;")
@ -44,6 +40,5 @@ class CommentComponentPatch : ResourcePatch {
SettingsPatch.updatePatchStatus("hide-comment-component") SettingsPatch.updatePatchStatus("hide-comment-component")
return PatchResultSuccess()
} }
} }

View File

@ -1,16 +1,13 @@
package app.revanced.patches.youtube.flyoutpanel.feed.patch package app.revanced.patches.youtube.flyoutpanel.feed.patch
import app.revanced.extensions.toErrorResult import app.revanced.extensions.exception
import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchException
import app.revanced.patcher.patch.PatchResultError
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.youtube.flyoutpanel.feed.fingerprints.BottomSheetMenuItemBuilderFingerprint import app.revanced.patches.youtube.flyoutpanel.feed.fingerprints.BottomSheetMenuItemBuilderFingerprint
@ -25,11 +22,10 @@ import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction
@Description("Hides feed flyout panel components.") @Description("Hides feed flyout panel components.")
@DependsOn([SettingsPatch::class]) @DependsOn([SettingsPatch::class])
@YouTubeCompatibility @YouTubeCompatibility
@Version("0.0.1")
class FeedFlyoutPanelPatch : BytecodePatch( class FeedFlyoutPanelPatch : BytecodePatch(
listOf(BottomSheetMenuItemBuilderFingerprint) listOf(BottomSheetMenuItemBuilderFingerprint)
) { ) {
override fun execute(context: BytecodeContext): PatchResult { override fun execute(context: BytecodeContext) {
BottomSheetMenuItemBuilderFingerprint.result?.let { BottomSheetMenuItemBuilderFingerprint.result?.let {
it.mutableMethod.apply { it.mutableMethod.apply {
@ -39,7 +35,7 @@ class FeedFlyoutPanelPatch : BytecodePatch(
val targetParameter = val targetParameter =
getInstruction<ReferenceInstruction>(targetIndex - 1).reference getInstruction<ReferenceInstruction>(targetIndex - 1).reference
if (!targetParameter.toString().endsWith("Ljava/lang/CharSequence;")) if (!targetParameter.toString().endsWith("Ljava/lang/CharSequence;"))
return PatchResultError("Method signature parameter did not match: $targetParameter") throw PatchException("Method signature parameter did not match: $targetParameter")
addInstructions( addInstructions(
targetIndex + 1, """ targetIndex + 1, """
@ -48,7 +44,7 @@ class FeedFlyoutPanelPatch : BytecodePatch(
""" """
) )
} }
} ?: return BottomSheetMenuItemBuilderFingerprint.toErrorResult() } ?: throw BottomSheetMenuItemBuilderFingerprint.exception
/** /**
* Add settings * Add settings
@ -62,6 +58,5 @@ class FeedFlyoutPanelPatch : BytecodePatch(
SettingsPatch.updatePatchStatus("hide-feed-flyout-panel") SettingsPatch.updatePatchStatus("hide-feed-flyout-panel")
return PatchResultSuccess()
} }
} }

View File

@ -1,15 +1,12 @@
package app.revanced.patches.youtube.flyoutpanel.oldqualitylayout.patch package app.revanced.patches.youtube.flyoutpanel.oldqualitylayout.patch
import app.revanced.extensions.toErrorResult import app.revanced.extensions.exception
import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.youtube.flyoutpanel.oldqualitylayout.fingerprints.QualityMenuViewInflateFingerprint import app.revanced.patches.youtube.flyoutpanel.oldqualitylayout.fingerprints.QualityMenuViewInflateFingerprint
@ -33,14 +30,13 @@ import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
] ]
) )
@YouTubeCompatibility @YouTubeCompatibility
@Version("0.0.1")
class OldQualityLayoutPatch : BytecodePatch( class OldQualityLayoutPatch : BytecodePatch(
listOf( listOf(
NewFlyoutPanelBuilderFingerprint, NewFlyoutPanelBuilderFingerprint,
QualityMenuViewInflateFingerprint QualityMenuViewInflateFingerprint
) )
) { ) {
override fun execute(context: BytecodeContext): PatchResult { override fun execute(context: BytecodeContext) {
/** /**
* Old method * Old method
@ -55,7 +51,7 @@ class OldQualityLayoutPatch : BytecodePatch(
"invoke-static { v$insertRegister }, $FLYOUT_PANEL->enableOldQualityMenu(Landroid/widget/ListView;)V" "invoke-static { v$insertRegister }, $FLYOUT_PANEL->enableOldQualityMenu(Landroid/widget/ListView;)V"
) )
} }
} ?: return QualityMenuViewInflateFingerprint.toErrorResult() } ?: throw QualityMenuViewInflateFingerprint.exception
/** /**
* New method * New method
@ -70,7 +66,7 @@ class OldQualityLayoutPatch : BytecodePatch(
"invoke-static { v$insertRegister }, $FLYOUT_PANEL->onFlyoutMenuCreate(Landroid/widget/LinearLayout;)V" "invoke-static { v$insertRegister }, $FLYOUT_PANEL->onFlyoutMenuCreate(Landroid/widget/LinearLayout;)V"
) )
} }
} ?: return NewFlyoutPanelBuilderFingerprint.toErrorResult() } ?: throw NewFlyoutPanelBuilderFingerprint.exception
LithoFilterPatch.addFilter("$PATCHES_PATH/ads/VideoQualityMenuFilter;") LithoFilterPatch.addFilter("$PATCHES_PATH/ads/VideoQualityMenuFilter;")
@ -87,6 +83,5 @@ class OldQualityLayoutPatch : BytecodePatch(
SettingsPatch.updatePatchStatus("enable-old-quality-layout") SettingsPatch.updatePatchStatus("enable-old-quality-layout")
return PatchResultSuccess()
} }
} }

View File

@ -1,6 +1,6 @@
package app.revanced.patches.youtube.flyoutpanel.oldspeedlayout.patch package app.revanced.patches.youtube.flyoutpanel.oldspeedlayout.patch
import app.revanced.extensions.toErrorResult import app.revanced.extensions.exception
import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels
@ -8,8 +8,6 @@ import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.extensions.InstructionExtensions.removeInstruction import app.revanced.patcher.extensions.InstructionExtensions.removeInstruction
import app.revanced.patcher.extensions.or import app.revanced.patcher.extensions.or
import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.util.proxy.mutableTypes.MutableField.Companion.toMutable import app.revanced.patcher.util.proxy.mutableTypes.MutableField.Companion.toMutable
import app.revanced.patches.youtube.flyoutpanel.oldspeedlayout.fingerprints.CustomPlaybackSpeedIntegrationsFingerprint import app.revanced.patches.youtube.flyoutpanel.oldspeedlayout.fingerprints.CustomPlaybackSpeedIntegrationsFingerprint
@ -32,7 +30,7 @@ class OldSpeedLayoutPatch : BytecodePatch(
PlaybackRateBottomSheetBuilderFingerprint PlaybackRateBottomSheetBuilderFingerprint
) )
) { ) {
override fun execute(context: BytecodeContext): PatchResult { override fun execute(context: BytecodeContext) {
/** /**
* Find the values we need * Find the values we need
@ -42,7 +40,7 @@ class OldSpeedLayoutPatch : BytecodePatch(
PLAYBACK_RATE_BOTTOM_SHEET_CLASS = definingClass PLAYBACK_RATE_BOTTOM_SHEET_CLASS = definingClass
PLAYBACK_RATE_BOTTOM_SHEET_BUILDER_METHOD = name PLAYBACK_RATE_BOTTOM_SHEET_BUILDER_METHOD = name
} }
} ?: return PlaybackRateBottomSheetClassFingerprint.toErrorResult() } ?: throw PlaybackRateBottomSheetClassFingerprint.exception
/** /**
* Create a static field in the patch * Create a static field in the patch
@ -76,7 +74,7 @@ class OldSpeedLayoutPatch : BytecodePatch(
""" """
) )
} }
} ?: return CustomPlaybackSpeedIntegrationsFingerprint.toErrorResult() } ?: throw CustomPlaybackSpeedIntegrationsFingerprint.exception
/** /**
* Input 'playbackRateBottomSheetClass' in FlyoutPanelPatch. * Input 'playbackRateBottomSheetClass' in FlyoutPanelPatch.
@ -88,7 +86,7 @@ class OldSpeedLayoutPatch : BytecodePatch(
"sput-object p0, $INTEGRATIONS_CLASS_DESCRIPTOR->playbackRateBottomSheetClass:$PLAYBACK_RATE_BOTTOM_SHEET_CLASS" "sput-object p0, $INTEGRATIONS_CLASS_DESCRIPTOR->playbackRateBottomSheetClass:$PLAYBACK_RATE_BOTTOM_SHEET_CLASS"
) )
} }
} ?: return PlaybackRateBottomSheetClassFingerprint.toErrorResult() } ?: throw PlaybackRateBottomSheetClassFingerprint.exception
/** /**
* New method * New method
@ -103,11 +101,10 @@ class OldSpeedLayoutPatch : BytecodePatch(
"invoke-static { v$insertRegister }, $INTEGRATIONS_CLASS_DESCRIPTOR->onFlyoutMenuCreate(Landroid/widget/LinearLayout;)V" "invoke-static { v$insertRegister }, $INTEGRATIONS_CLASS_DESCRIPTOR->onFlyoutMenuCreate(Landroid/widget/LinearLayout;)V"
) )
} }
} ?: return NewFlyoutPanelBuilderFingerprint.toErrorResult() } ?: throw NewFlyoutPanelBuilderFingerprint.exception
LithoFilterPatch.addFilter("$PATCHES_PATH/ads/PlaybackSpeedMenuFilter;") LithoFilterPatch.addFilter("$PATCHES_PATH/ads/PlaybackSpeedMenuFilter;")
return PatchResultSuccess()
} }
private companion object { private companion object {

View File

@ -2,10 +2,7 @@ package app.revanced.patches.youtube.flyoutpanel.player.patch
import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.ResourceContext import app.revanced.patcher.data.ResourceContext
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.ResourcePatch
import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch import app.revanced.patcher.patch.annotations.Patch
@ -24,9 +21,8 @@ import app.revanced.util.integrations.Constants.PATCHES_PATH
] ]
) )
@YouTubeCompatibility @YouTubeCompatibility
@Version("0.0.1")
class PlayerFlyoutPanelPatch : ResourcePatch { class PlayerFlyoutPanelPatch : ResourcePatch {
override fun execute(context: ResourceContext): PatchResult { override fun execute(context: ResourceContext) {
LithoFilterPatch.addFilter("$PATCHES_PATH/ads/PlayerFlyoutPanelsFilter;") LithoFilterPatch.addFilter("$PATCHES_PATH/ads/PlayerFlyoutPanelsFilter;")
/** /**
@ -42,6 +38,5 @@ class PlayerFlyoutPanelPatch : ResourcePatch {
SettingsPatch.updatePatchStatus("hide-player-flyout-panel") SettingsPatch.updatePatchStatus("hide-player-flyout-panel")
return PatchResultSuccess()
} }
} }

View File

@ -1,15 +1,12 @@
package app.revanced.patches.youtube.fullscreen.autoplaypreview.patch package app.revanced.patches.youtube.fullscreen.autoplaypreview.patch
import app.revanced.extensions.toErrorResult import app.revanced.extensions.exception
import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patcher.util.smali.ExternalLabel import app.revanced.patcher.util.smali.ExternalLabel
@ -34,11 +31,10 @@ import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
] ]
) )
@YouTubeCompatibility @YouTubeCompatibility
@Version("0.0.1")
class HideAutoplayPreviewPatch : BytecodePatch( class HideAutoplayPreviewPatch : BytecodePatch(
listOf(LayoutConstructorFingerprint) listOf(LayoutConstructorFingerprint)
) { ) {
override fun execute(context: BytecodeContext): PatchResult { override fun execute(context: BytecodeContext) {
LayoutConstructorFingerprint.result?.let { LayoutConstructorFingerprint.result?.let {
it.mutableMethod.apply { it.mutableMethod.apply {
val dummyRegister = val dummyRegister =
@ -54,7 +50,7 @@ class HideAutoplayPreviewPatch : BytecodePatch(
""", ExternalLabel("hidden", getInstruction(jumpIndex)) """, ExternalLabel("hidden", getInstruction(jumpIndex))
) )
} }
} ?: return LayoutConstructorFingerprint.toErrorResult() } ?: throw LayoutConstructorFingerprint.exception
/** /**
* Add settings * Add settings
@ -68,7 +64,6 @@ class HideAutoplayPreviewPatch : BytecodePatch(
SettingsPatch.updatePatchStatus("hide-autoplay-preview") SettingsPatch.updatePatchStatus("hide-autoplay-preview")
return PatchResultSuccess()
} }
} }

View File

@ -1,16 +1,12 @@
package app.revanced.patches.youtube.fullscreen.compactcontrolsoverlay.patch package app.revanced.patches.youtube.fullscreen.compactcontrolsoverlay.patch
import app.revanced.extensions.toErrorResult import app.revanced.extensions.exception
import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.data.toMethodWalker
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
@ -31,11 +27,10 @@ import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
] ]
) )
@YouTubeCompatibility @YouTubeCompatibility
@Version("0.0.1")
class CompactControlsOverlayPatch : BytecodePatch( class CompactControlsOverlayPatch : BytecodePatch(
listOf(YouTubeControlsOverlayFingerprint) listOf(YouTubeControlsOverlayFingerprint)
) { ) {
override fun execute(context: BytecodeContext): PatchResult { override fun execute(context: BytecodeContext) {
YouTubeControlsOverlayFingerprint.result?.let { YouTubeControlsOverlayFingerprint.result?.let {
with( with(
@ -55,7 +50,7 @@ class CompactControlsOverlayPatch : BytecodePatch(
""" """
) )
} }
} ?: return YouTubeControlsOverlayFingerprint.toErrorResult() } ?: throw YouTubeControlsOverlayFingerprint.exception
/** /**
* Add settings * Add settings
@ -69,6 +64,5 @@ class CompactControlsOverlayPatch : BytecodePatch(
SettingsPatch.updatePatchStatus("enable-compact-controls-overlay") SettingsPatch.updatePatchStatus("enable-compact-controls-overlay")
return PatchResultSuccess()
} }
} }

View File

@ -1,15 +1,12 @@
package app.revanced.patches.youtube.fullscreen.endscreenoverlay.patch package app.revanced.patches.youtube.fullscreen.endscreenoverlay.patch
import app.revanced.extensions.toErrorResult import app.revanced.extensions.exception
import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patcher.util.smali.ExternalLabel import app.revanced.patcher.util.smali.ExternalLabel
@ -29,11 +26,10 @@ import app.revanced.util.integrations.Constants.FULLSCREEN
] ]
) )
@YouTubeCompatibility @YouTubeCompatibility
@Version("0.0.1")
class HideEndScreenOverlayPatch : BytecodePatch( class HideEndScreenOverlayPatch : BytecodePatch(
listOf(EndScreenResultsFingerprint) listOf(EndScreenResultsFingerprint)
) { ) {
override fun execute(context: BytecodeContext): PatchResult { override fun execute(context: BytecodeContext) {
EndScreenResultsFingerprint.result?.let { EndScreenResultsFingerprint.result?.let {
it.mutableMethod.apply { it.mutableMethod.apply {
addInstructionsWithLabels( addInstructionsWithLabels(
@ -45,7 +41,7 @@ class HideEndScreenOverlayPatch : BytecodePatch(
""", ExternalLabel("show", getInstruction(0)) """, ExternalLabel("show", getInstruction(0))
) )
} }
} ?: return EndScreenResultsFingerprint.toErrorResult() } ?: throw EndScreenResultsFingerprint.exception
/** /**
* Add settings * Add settings
@ -59,6 +55,5 @@ class HideEndScreenOverlayPatch : BytecodePatch(
SettingsPatch.updatePatchStatus("hide-endscreen-overlay") SettingsPatch.updatePatchStatus("hide-endscreen-overlay")
return PatchResultSuccess()
} }
} }

View File

@ -1,9 +1,8 @@
package app.revanced.patches.youtube.fullscreen.fullscreenpanels.patch package app.revanced.patches.youtube.fullscreen.fullscreenpanels.patch
import app.revanced.extensions.toErrorResult import app.revanced.extensions.exception
import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
@ -11,8 +10,6 @@ import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWith
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.extensions.InstructionExtensions.removeInstruction import app.revanced.patcher.extensions.InstructionExtensions.removeInstruction
import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patcher.util.smali.ExternalLabel import app.revanced.patcher.util.smali.ExternalLabel
@ -43,7 +40,6 @@ import com.android.tools.smali.dexlib2.iface.instruction.formats.Instruction35c
] ]
) )
@YouTubeCompatibility @YouTubeCompatibility
@Version("0.0.1")
class HideFullscreenPanelsPatch : BytecodePatch( class HideFullscreenPanelsPatch : BytecodePatch(
listOf( listOf(
FullscreenEngagementPanelFingerprint, FullscreenEngagementPanelFingerprint,
@ -51,7 +47,7 @@ class HideFullscreenPanelsPatch : BytecodePatch(
LayoutConstructorFingerprint LayoutConstructorFingerprint
) )
) { ) {
override fun execute(context: BytecodeContext): PatchResult { override fun execute(context: BytecodeContext) {
FullscreenEngagementPanelFingerprint.result?.let { FullscreenEngagementPanelFingerprint.result?.let {
it.mutableMethod.apply { it.mutableMethod.apply {
@ -63,7 +59,7 @@ class HideFullscreenPanelsPatch : BytecodePatch(
"invoke-static {v$targetRegister}, $FULLSCREEN->hideFullscreenPanels(Landroidx/coordinatorlayout/widget/CoordinatorLayout;)V" "invoke-static {v$targetRegister}, $FULLSCREEN->hideFullscreenPanels(Landroidx/coordinatorlayout/widget/CoordinatorLayout;)V"
) )
} }
} ?: return FullscreenEngagementPanelFingerprint.toErrorResult() } ?: throw FullscreenEngagementPanelFingerprint.exception
FullscreenViewAdderFingerprint.result?.let { FullscreenViewAdderFingerprint.result?.let {
it.mutableMethod.apply { it.mutableMethod.apply {
@ -100,7 +96,7 @@ class HideFullscreenPanelsPatch : BytecodePatch(
""", ExternalLabel("hidden", getInstruction(invokeIndex + 1)) """, ExternalLabel("hidden", getInstruction(invokeIndex + 1))
) )
} }
} ?: return LayoutConstructorFingerprint.toErrorResult() } ?: throw LayoutConstructorFingerprint.exception
/** /**
* Add settings * Add settings
@ -114,6 +110,5 @@ class HideFullscreenPanelsPatch : BytecodePatch(
SettingsPatch.updatePatchStatus("hide-fullscreen-panels") SettingsPatch.updatePatchStatus("hide-fullscreen-panels")
return PatchResultSuccess()
} }
} }

View File

@ -1,17 +1,14 @@
package app.revanced.patches.youtube.fullscreen.landscapemode.patch package app.revanced.patches.youtube.fullscreen.landscapemode.patch
import app.revanced.extensions.toErrorResult import app.revanced.extensions.exception
import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprintResult import app.revanced.patcher.fingerprint.method.impl.MethodFingerprintResult
import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.youtube.fullscreen.landscapemode.fingerprints.OrientationParentFingerprint import app.revanced.patches.youtube.fullscreen.landscapemode.fingerprints.OrientationParentFingerprint
@ -27,20 +24,19 @@ import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
@Description("Disable landscape mode when entering fullscreen.") @Description("Disable landscape mode when entering fullscreen.")
@DependsOn([SettingsPatch::class]) @DependsOn([SettingsPatch::class])
@YouTubeCompatibility @YouTubeCompatibility
@Version("0.0.1")
class LandScapeModePatch : BytecodePatch( class LandScapeModePatch : BytecodePatch(
listOf(OrientationParentFingerprint) listOf(OrientationParentFingerprint)
) { ) {
override fun execute(context: BytecodeContext): PatchResult { override fun execute(context: BytecodeContext) {
OrientationParentFingerprint.result?.classDef?.let { classDef -> OrientationParentFingerprint.result?.classDef?.let { classDef ->
arrayOf( arrayOf(
OrientationPrimaryFingerprint, OrientationPrimaryFingerprint,
OrientationSecondaryFingerprint OrientationSecondaryFingerprint
).forEach { ).forEach {
it.also { it.resolve(context, classDef) }.result?.injectOverride() it.also { it.resolve(context, classDef) }.result?.injectOverride()
?: return it.toErrorResult() ?: throw it.exception
} }
} ?: return OrientationParentFingerprint.toErrorResult() } ?: throw OrientationParentFingerprint.exception
/** /**
* Add settings * Add settings
@ -54,7 +50,6 @@ class LandScapeModePatch : BytecodePatch(
SettingsPatch.updatePatchStatus("disable-landscape-mode") SettingsPatch.updatePatchStatus("disable-landscape-mode")
return PatchResultSuccess()
} }
private companion object { private companion object {

View File

@ -2,10 +2,7 @@ package app.revanced.patches.youtube.fullscreen.quickactions.patch
import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.ResourceContext import app.revanced.patcher.data.ResourceContext
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.ResourcePatch
import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch import app.revanced.patcher.patch.annotations.Patch
@ -26,9 +23,8 @@ import app.revanced.util.integrations.Constants.PATCHES_PATH
] ]
) )
@YouTubeCompatibility @YouTubeCompatibility
@Version("0.0.1")
class QuickActionsPatch : ResourcePatch { class QuickActionsPatch : ResourcePatch {
override fun execute(context: ResourceContext): PatchResult { override fun execute(context: ResourceContext) {
LithoFilterPatch.addFilter("$PATCHES_PATH/ads/QuickActionFilter;") LithoFilterPatch.addFilter("$PATCHES_PATH/ads/QuickActionFilter;")
/** /**
@ -43,6 +39,5 @@ class QuickActionsPatch : ResourcePatch {
SettingsPatch.updatePatchStatus("hide-quick-actions") SettingsPatch.updatePatchStatus("hide-quick-actions")
return PatchResultSuccess()
} }
} }

View File

@ -1,16 +1,13 @@
package app.revanced.patches.youtube.general.accountmenu.patch package app.revanced.patches.youtube.general.accountmenu.patch
import app.revanced.extensions.toErrorResult import app.revanced.extensions.exception
import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve
import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.youtube.general.accountmenu.fingerprints.AccountMenuFingerprint import app.revanced.patches.youtube.general.accountmenu.fingerprints.AccountMenuFingerprint
@ -31,11 +28,10 @@ import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
] ]
) )
@YouTubeCompatibility @YouTubeCompatibility
@Version("0.0.1")
class AccountMenuPatch : BytecodePatch( class AccountMenuPatch : BytecodePatch(
listOf(AccountMenuParentFingerprint) listOf(AccountMenuParentFingerprint)
) { ) {
override fun execute(context: BytecodeContext): PatchResult { override fun execute(context: BytecodeContext) {
AccountMenuParentFingerprint.result?.let { parentResult -> AccountMenuParentFingerprint.result?.let { parentResult ->
AccountMenuFingerprint.also { it.resolve(context, parentResult.classDef) }.result?.let { AccountMenuFingerprint.also { it.resolve(context, parentResult.classDef) }.result?.let {
@ -48,7 +44,7 @@ class AccountMenuPatch : BytecodePatch(
"invoke-static {v$register}, $GENERAL->hideAccountMenu(Landroid/text/Spanned;)V" "invoke-static {v$register}, $GENERAL->hideAccountMenu(Landroid/text/Spanned;)V"
) )
} }
} ?: return AccountMenuFingerprint.toErrorResult() } ?: throw AccountMenuFingerprint.exception
parentResult.mutableMethod.apply { parentResult.mutableMethod.apply {
val endIndex = parentResult.scanResult.patternScanResult!!.endIndex val endIndex = parentResult.scanResult.patternScanResult!!.endIndex
@ -59,7 +55,7 @@ class AccountMenuPatch : BytecodePatch(
"sput-object v$register, $GENERAL->compactLink:Landroid/view/View;" "sput-object v$register, $GENERAL->compactLink:Landroid/view/View;"
) )
} }
} ?: return AccountMenuParentFingerprint.toErrorResult() } ?: throw AccountMenuParentFingerprint.exception
/** /**
* Add settings * Add settings
@ -73,6 +69,5 @@ class AccountMenuPatch : BytecodePatch(
SettingsPatch.updatePatchStatus("hide-account-menu") SettingsPatch.updatePatchStatus("hide-account-menu")
return PatchResultSuccess()
} }
} }

View File

@ -1,17 +1,14 @@
package app.revanced.patches.youtube.general.autocaptions.patch package app.revanced.patches.youtube.general.autocaptions.patch
import app.revanced.extensions.toErrorResult import app.revanced.extensions.exception
import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patcher.util.smali.ExternalLabel import app.revanced.patcher.util.smali.ExternalLabel
@ -35,7 +32,6 @@ import app.revanced.util.integrations.Constants.GENERAL
] ]
) )
@YouTubeCompatibility @YouTubeCompatibility
@Version("0.0.1")
class AutoCaptionsPatch : BytecodePatch( class AutoCaptionsPatch : BytecodePatch(
listOf( listOf(
StartVideoInformerFingerprint, StartVideoInformerFingerprint,
@ -43,7 +39,7 @@ class AutoCaptionsPatch : BytecodePatch(
SubtitleTrackFingerprint SubtitleTrackFingerprint
) )
) { ) {
override fun execute(context: BytecodeContext): PatchResult { override fun execute(context: BytecodeContext) {
listOf( listOf(
StartVideoInformerFingerprint.toPatch(Status.DISABLED), StartVideoInformerFingerprint.toPatch(Status.DISABLED),
SubtitleButtonControllerFingerprint.toPatch(Status.ENABLED) SubtitleButtonControllerFingerprint.toPatch(Status.ENABLED)
@ -53,7 +49,7 @@ class AutoCaptionsPatch : BytecodePatch(
const/4 v0, ${status.value} const/4 v0, ${status.value}
sput-boolean v0, $GENERAL->captionsButtonStatus:Z sput-boolean v0, $GENERAL->captionsButtonStatus:Z
""" """
) ?: return fingerprint.toErrorResult() ) ?: throw fingerprint.exception
} }
SubtitleTrackFingerprint.result?.let { SubtitleTrackFingerprint.result?.let {
@ -70,7 +66,7 @@ class AutoCaptionsPatch : BytecodePatch(
""", ExternalLabel("auto_captions_shown", getInstruction(0)) """, ExternalLabel("auto_captions_shown", getInstruction(0))
) )
} }
} ?: return SubtitleTrackFingerprint.toErrorResult() } ?: throw SubtitleTrackFingerprint.exception
/** /**
* Add settings * Add settings
@ -84,7 +80,6 @@ class AutoCaptionsPatch : BytecodePatch(
SettingsPatch.updatePatchStatus("disable-auto-captions") SettingsPatch.updatePatchStatus("disable-auto-captions")
return PatchResultSuccess()
} }
private fun MethodFingerprint.toPatch(visibility: Status) = SetStatus(this, visibility) private fun MethodFingerprint.toPatch(visibility: Status) = SetStatus(this, visibility)

View File

@ -1,15 +1,12 @@
package app.revanced.patches.youtube.general.autopopuppanels.patch package app.revanced.patches.youtube.general.autopopuppanels.patch
import app.revanced.extensions.toErrorResult import app.revanced.extensions.exception
import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patcher.util.smali.ExternalLabel import app.revanced.patcher.util.smali.ExternalLabel
@ -23,11 +20,10 @@ import app.revanced.util.integrations.Constants.GENERAL
@Description("Hide automatic popup panels (playlist or live chat) on video player.") @Description("Hide automatic popup panels (playlist or live chat) on video player.")
@DependsOn([SettingsPatch::class]) @DependsOn([SettingsPatch::class])
@YouTubeCompatibility @YouTubeCompatibility
@Version("0.0.1")
class PlayerPopupPanelsPatch : BytecodePatch( class PlayerPopupPanelsPatch : BytecodePatch(
listOf(EngagementPanelControllerFingerprint) listOf(EngagementPanelControllerFingerprint)
) { ) {
override fun execute(context: BytecodeContext): PatchResult { override fun execute(context: BytecodeContext) {
EngagementPanelControllerFingerprint.result?.let { EngagementPanelControllerFingerprint.result?.let {
it.mutableMethod.apply { it.mutableMethod.apply {
@ -42,7 +38,7 @@ class PlayerPopupPanelsPatch : BytecodePatch(
""", ExternalLabel("player_popup_panels_shown", getInstruction(0)) """, ExternalLabel("player_popup_panels_shown", getInstruction(0))
) )
} }
} ?: return EngagementPanelControllerFingerprint.toErrorResult() } ?: throw EngagementPanelControllerFingerprint.exception
/** /**
* Add settings * Add settings
@ -56,6 +52,5 @@ class PlayerPopupPanelsPatch : BytecodePatch(
SettingsPatch.updatePatchStatus("hide-auto-player-popup-panels") SettingsPatch.updatePatchStatus("hide-auto-player-popup-panels")
return PatchResultSuccess()
} }
} }

View File

@ -1,16 +1,13 @@
package app.revanced.patches.youtube.general.categorybar.patch package app.revanced.patches.youtube.general.categorybar.patch
import app.revanced.extensions.toErrorResult import app.revanced.extensions.exception
import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.youtube.general.categorybar.fingerprints.FilterBarHeightFingerprint import app.revanced.patches.youtube.general.categorybar.fingerprints.FilterBarHeightFingerprint
@ -33,7 +30,6 @@ import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction
] ]
) )
@YouTubeCompatibility @YouTubeCompatibility
@Version("0.0.1")
class CategoryBarPatch : BytecodePatch( class CategoryBarPatch : BytecodePatch(
listOf( listOf(
FilterBarHeightFingerprint, FilterBarHeightFingerprint,
@ -41,7 +37,7 @@ class CategoryBarPatch : BytecodePatch(
SearchResultsChipBarFingerprint SearchResultsChipBarFingerprint
) )
) { ) {
override fun execute(context: BytecodeContext): PatchResult { override fun execute(context: BytecodeContext) {
FilterBarHeightFingerprint.patch<TwoRegisterInstruction> { register -> FilterBarHeightFingerprint.patch<TwoRegisterInstruction> { register ->
""" """
@ -74,7 +70,6 @@ class CategoryBarPatch : BytecodePatch(
SettingsPatch.updatePatchStatus("hide-category-bar") SettingsPatch.updatePatchStatus("hide-category-bar")
return PatchResultSuccess()
} }
private companion object { private companion object {
@ -93,6 +88,6 @@ class CategoryBarPatch : BytecodePatch(
addInstructions(insertIndex, instructions(register)) addInstructions(insertIndex, instructions(register))
} }
} ?: throw toErrorResult() } ?: throw exception
} }
} }

View File

@ -1,15 +1,12 @@
package app.revanced.patches.youtube.general.channellistsubmenu.patch package app.revanced.patches.youtube.general.channellistsubmenu.patch
import app.revanced.extensions.toErrorResult import app.revanced.extensions.exception
import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.youtube.general.channellistsubmenu.fingerprints.ChannelListSubMenuFingerprint import app.revanced.patches.youtube.general.channellistsubmenu.fingerprints.ChannelListSubMenuFingerprint
@ -29,11 +26,10 @@ import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
] ]
) )
@YouTubeCompatibility @YouTubeCompatibility
@Version("0.0.1")
class ChannelListSubMenuPatch : BytecodePatch( class ChannelListSubMenuPatch : BytecodePatch(
listOf(ChannelListSubMenuFingerprint) listOf(ChannelListSubMenuFingerprint)
) { ) {
override fun execute(context: BytecodeContext): PatchResult { override fun execute(context: BytecodeContext) {
ChannelListSubMenuFingerprint.result?.let { ChannelListSubMenuFingerprint.result?.let {
it.mutableMethod.apply { it.mutableMethod.apply {
@ -45,7 +41,7 @@ class ChannelListSubMenuPatch : BytecodePatch(
"invoke-static {v$register}, $GENERAL->hideChannelListSubMenu(Landroid/view/View;)V" "invoke-static {v$register}, $GENERAL->hideChannelListSubMenu(Landroid/view/View;)V"
) )
} }
} ?: return ChannelListSubMenuFingerprint.toErrorResult() } ?: throw ChannelListSubMenuFingerprint.exception
/** /**
* Add settings * Add settings
@ -59,6 +55,5 @@ class ChannelListSubMenuPatch : BytecodePatch(
SettingsPatch.updatePatchStatus("hide-channel-avatar-section") SettingsPatch.updatePatchStatus("hide-channel-avatar-section")
return PatchResultSuccess()
} }
} }

View File

@ -1,15 +1,12 @@
package app.revanced.patches.youtube.general.crowdfundingbox.patch package app.revanced.patches.youtube.general.crowdfundingbox.patch
import app.revanced.extensions.toErrorResult import app.revanced.extensions.exception
import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.youtube.general.crowdfundingbox.fingerprints.CrowdfundingBoxFingerprint import app.revanced.patches.youtube.general.crowdfundingbox.fingerprints.CrowdfundingBoxFingerprint
@ -29,11 +26,10 @@ import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction
] ]
) )
@YouTubeCompatibility @YouTubeCompatibility
@Version("0.0.1")
class CrowdfundingBoxPatch : BytecodePatch( class CrowdfundingBoxPatch : BytecodePatch(
listOf(CrowdfundingBoxFingerprint) listOf(CrowdfundingBoxFingerprint)
) { ) {
override fun execute(context: BytecodeContext): PatchResult { override fun execute(context: BytecodeContext) {
CrowdfundingBoxFingerprint.result?.let { CrowdfundingBoxFingerprint.result?.let {
it.mutableMethod.apply { it.mutableMethod.apply {
@ -45,7 +41,7 @@ class CrowdfundingBoxPatch : BytecodePatch(
"invoke-static {v$register}, $GENERAL->hideCrowdfundingBox(Landroid/view/View;)V" "invoke-static {v$register}, $GENERAL->hideCrowdfundingBox(Landroid/view/View;)V"
) )
} }
} ?: return CrowdfundingBoxFingerprint.toErrorResult() } ?: throw CrowdfundingBoxFingerprint.exception
/** /**
* Add settings * Add settings
@ -59,6 +55,5 @@ class CrowdfundingBoxPatch : BytecodePatch(
SettingsPatch.updatePatchStatus("hide-crowdfunding-box") SettingsPatch.updatePatchStatus("hide-crowdfunding-box")
return PatchResultSuccess()
} }
} }

Some files were not shown because too many files have changed in this diff Show More