build(Needs bump): Bump dependencies

This commit is contained in:
oSumAtrIX 2023-08-19 01:50:29 +02:00
parent c0a13bbb78
commit dba0d0c1ae
214 changed files with 473 additions and 1271 deletions

View file

@ -25,7 +25,7 @@ repositories {
}
dependencies {
implementation("app.revanced:revanced-patcher:13.0.0")
implementation("app.revanced:revanced-patcher:14.0.0")
implementation("com.android.tools.smali:smali:3.0.3")
// Required because build fails without it.
// TODO: Find a way to remove this dependency.

View file

@ -1,9 +1,10 @@
package app.revanced.extensions
import app.revanced.patcher.extensions.MethodFingerprintExtensions.name
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
import app.revanced.patcher.extensions.MethodFingerprintExtensions.name
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.MutableMethod
import app.revanced.patches.shared.mapping.misc.patch.ResourceMappingPatch
@ -13,13 +14,12 @@ import com.android.tools.smali.dexlib2.iface.instruction.WideLiteralInstruction
import com.android.tools.smali.dexlib2.util.MethodUtil
import org.w3c.dom.Node
// 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].
*/
internal fun MethodFingerprint.toErrorResult() = PatchResultError("Failed to resolve $name")
internal fun MethodFingerprint.toErrorResult() = PatchException("Failed to resolve $name")
/**
* Find the [MutableMethod] from a given [Method] in a [MutableClass].
@ -82,3 +82,16 @@ fun Method.indexOfFirstConstantInstructionValue(constantValue: Long): Int {
fun Method.containsConstantInstructionValue(constantValue: Long): Boolean {
return indexOfFirstConstantInstructionValue(constantValue) >= 0
}
/**
* 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)
}
}

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

View file

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

View file

@ -1,10 +1,8 @@
package app.revanced.patches.all.activity.exportAll.patch
package app.revanced.patches.all.activity.exportall.patch
import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name
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.annotations.Patch
@ -12,7 +10,7 @@ import app.revanced.patcher.patch.annotations.Patch
@Name("Export all activities")
@Description("Makes all app activities exportable.")
class ExportAllActivitiesPatch : ResourcePatch {
override fun execute(context: ResourceContext): PatchResult {
override fun execute(context: ResourceContext) {
context.xmlEditor["AndroidManifest.xml"].use { editor ->
val document = editor.file
val activities = document.getElementsByTagName("activity")
@ -33,8 +31,6 @@ class ExportAllActivitiesPatch : ResourcePatch {
}
}
}
return PatchResultSuccess()
}
private companion object {

View file

@ -3,8 +3,6 @@ package app.revanced.patches.all.interaction.gestures.patch
import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name
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.annotations.Patch
@ -12,7 +10,7 @@ import app.revanced.patcher.patch.annotations.Patch
@Name("Predictive back gesture")
@Description("Enables the predictive back gesture introduced on Android 13.")
class PredictiveBackGesturePatch : ResourcePatch {
override fun execute(context: ResourceContext): PatchResult {
override fun execute(context: ResourceContext) {
context.xmlEditor["AndroidManifest.xml"].use { editor ->
val document = editor.file
@ -25,8 +23,6 @@ class PredictiveBackGesturePatch : ResourcePatch {
}
}
return PatchResultSuccess()
}
private companion object {

View file

@ -11,7 +11,7 @@ import org.w3c.dom.Element
@Name("Enable android debugging")
@Description("Enables Android debugging capabilities.")
class EnableAndroidDebuggingPatch : ResourcePatch {
override fun execute(context: ResourceContext): PatchResult {
override fun execute(context: ResourceContext) {
context.xmlEditor["AndroidManifest.xml"].use { dom ->
val applicationNode = dom
.file
@ -21,8 +21,6 @@ class EnableAndroidDebuggingPatch : ResourcePatch {
// set application as debuggable
applicationNode.setAttribute("android:debuggable", "true")
}
return PatchResultSuccess()
}
}

View file

@ -2,9 +2,8 @@ package app.revanced.patches.all.misc.network.patch
import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.ResourceContext
import app.revanced.patcher.patch.*
import app.revanced.patcher.patch.ResourcePatch
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.all.misc.debugging.patch.EnableAndroidDebuggingPatch
@ -16,8 +15,7 @@ import java.io.File
@Description("Overrides certificate pinning, allowing to inspect traffic via a proxy.")
@DependsOn([EnableAndroidDebuggingPatch::class])
class OverrideCertificatePinningPatch : ResourcePatch {
override fun execute(context: ResourceContext): PatchResult {
override fun execute(context: ResourceContext) {
val resXmlDirectory = context["res/xml"]
// Add android:networkSecurityConfig="@xml/network_security_config" and the "networkSecurityConfig" attribute if it does not exist.
@ -73,7 +71,5 @@ class OverrideCertificatePinningPatch : ResourcePatch {
}
}
return PatchResultSuccess()
}
}

View file

@ -11,20 +11,18 @@ import org.w3c.dom.Element
@Name("Change package name")
@Description("Changes the package name. Appends \".revanced\" to the package name by default.")
class ChangePackageNamePatch : ResourcePatch {
override fun execute(context: ResourceContext): PatchResult {
override fun execute(context: ResourceContext) {
val packageNameToUse = packageName ?: getDefaultPackageName(context)
val packageNameRegex = Regex("^[a-z]\\w*(\\.[a-z]\\w*)+\$")
if (!packageNameToUse.matches(packageNameRegex))
return PatchResultError("Invalid package name")
throw PatchException("Invalid package name")
val originalPackageName = getOriginalPackageName(context)
context["AndroidManifest.xml"].apply {
readText().replace(originalPackageName, packageNameToUse).let(::writeText)
}
return PatchResultSuccess()
}
private fun getDefaultPackageName(context: ResourceContext): String {

View file

@ -2,14 +2,12 @@ package app.revanced.patches.all.screencapture.removerestriction.resource.patch
import app.revanced.patcher.annotation.Description
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 org.w3c.dom.Element
@Description("Sets allowAudioPlaybackCapture in manifest to true.")
internal class RemoveCaptureRestrictionResourcePatch : ResourcePatch {
override fun execute(context: ResourceContext): PatchResult {
override fun execute(context: ResourceContext) {
// create an xml editor instance
context.xmlEditor["AndroidManifest.xml"].use { dom ->
// get the application node
@ -21,7 +19,5 @@ internal class RemoveCaptureRestrictionResourcePatch : ResourcePatch {
// set allowAudioPlaybackCapture attribute to true
applicationNode.setAttribute("android:allowAudioPlaybackCapture", "true")
}
return PatchResultSuccess()
}
}

View file

@ -7,8 +7,6 @@ import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
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.patches.backdrops.misc.pro.annotations.ProUnlockCompatibility
import app.revanced.patches.backdrops.misc.pro.fingerprints.ProUnlockFingerprint
@ -21,7 +19,7 @@ import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
class ProUnlockPatch : BytecodePatch(
listOf(ProUnlockFingerprint)
) {
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
ProUnlockFingerprint.result?.let { result ->
val registerIndex = result.scanResult.patternScanResult!!.endIndex - 1
@ -35,8 +33,6 @@ class ProUnlockPatch : BytecodePatch(
)
}
} ?: return ProUnlockFingerprint.toErrorResult()
return PatchResultSuccess()
} ?: throw ProUnlockFingerprint.toErrorResult()
}
}

View file

@ -6,8 +6,6 @@ import app.revanced.patcher.annotation.Name
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
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.patches.candylinkvpn.annotations.UnlockProCompatibility
import app.revanced.patches.candylinkvpn.fingerprints.IsPremiumPurchasedFingerprint
@ -19,15 +17,13 @@ import app.revanced.patches.candylinkvpn.fingerprints.IsPremiumPurchasedFingerpr
class UnlockProPatch : BytecodePatch(
listOf(IsPremiumPurchasedFingerprint)
) {
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
IsPremiumPurchasedFingerprint.result?.mutableMethod?.addInstructions(
0,
"""
const/4 v0, 0x1
return v0
"""
) ?: return IsPremiumPurchasedFingerprint.toErrorResult()
return PatchResultSuccess()
) ?: throw IsPremiumPurchasedFingerprint.toErrorResult()
}
}

View file

@ -6,8 +6,6 @@ import app.revanced.patcher.annotation.Name
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
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.patches.finanzonline.detection.bootloader.fingerprints.BootStateFingerprint
import app.revanced.patches.finanzonline.detection.bootloader.fingerprints.CreateKeyFingerprint
@ -21,7 +19,7 @@ import app.revanced.patches.finanzonline.detection.shared.annotations.DetectionC
class BootloaderDetectionPatch : BytecodePatch(
listOf(CreateKeyFingerprint, BootStateFingerprint)
) {
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
arrayOf(CreateKeyFingerprint, BootStateFingerprint).forEach { fingerprint ->
fingerprint.result?.mutableMethod?.addInstructions(
0,
@ -29,9 +27,7 @@ class BootloaderDetectionPatch : BytecodePatch(
const/4 v0, 0x1
return v0
"""
) ?: return fingerprint.toErrorResult()
) ?: throw fingerprint.toErrorResult()
}
return PatchResultSuccess()
}
}

View file

@ -6,8 +6,6 @@ import app.revanced.patcher.annotation.Name
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
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.patches.finanzonline.detection.root.fingerprints.RootDetectionFingerprint
import app.revanced.patches.finanzonline.detection.shared.annotations.DetectionCompatibility
@ -19,15 +17,13 @@ import app.revanced.patches.finanzonline.detection.shared.annotations.DetectionC
class RootDetectionPatch : BytecodePatch(
listOf(RootDetectionFingerprint)
) {
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
RootDetectionFingerprint.result?.mutableMethod?.addInstructions(
0,
"""
sget-object v0, Ljava/lang/Boolean;->FALSE:Ljava/lang/Boolean;
return-object v0
"""
) ?: return RootDetectionFingerprint.toErrorResult()
return PatchResultSuccess()
) ?: throw RootDetectionFingerprint.toErrorResult()
}
}

View file

@ -10,8 +10,6 @@ import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.extensions.InstructionExtensions.removeInstructions
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.patches.googlerecorder.restrictions.fingerprints.OnApplicationCreateFingerprint
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
@ -23,7 +21,7 @@ import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
class RemoveDeviceRestrictions : BytecodePatch(
listOf(OnApplicationCreateFingerprint)
) {
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
OnApplicationCreateFingerprint.result?.let {
val featureStringIndex = it.scanResult.stringsScanResult!!.matches.first().index
@ -36,8 +34,6 @@ class RemoveDeviceRestrictions : BytecodePatch(
// Override "isPixelDevice()" to return true.
addInstruction(featureStringIndex, "const/4 v$featureAvailableRegister, 0x1")
}
} ?: return OnApplicationCreateFingerprint.toErrorResult()
return PatchResultSuccess()
} ?: throw OnApplicationCreateFingerprint.toErrorResult()
}
}

View file

@ -5,8 +5,6 @@ import app.revanced.patcher.annotation.Name
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.replaceInstructions
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.patches.hexeditor.ad.annotations.HexEditorAdsCompatibility
import app.revanced.patches.hexeditor.ad.fingerprints.PrimaryAdsFingerprint
@ -20,7 +18,7 @@ class HexEditorAdsPatch : BytecodePatch(
PrimaryAdsFingerprint
)
) {
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
val method = PrimaryAdsFingerprint.result!!.mutableMethod
method.replaceInstructions(
@ -30,7 +28,5 @@ class HexEditorAdsPatch : BytecodePatch(
return v0
"""
)
return PatchResultSuccess()
}
}

View file

@ -5,8 +5,6 @@ import app.revanced.patcher.annotation.Name
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
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.patches.iconpackstudio.misc.pro.annotations.UnlockProCompatibility
import app.revanced.patches.iconpackstudio.misc.pro.fingerprints.CheckProFingerprint
@ -20,7 +18,7 @@ class UnlockProPatch : BytecodePatch(
CheckProFingerprint
)
) {
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
val method = CheckProFingerprint.result!!.mutableMethod
method.addInstructions(
0,
@ -29,7 +27,5 @@ class UnlockProPatch : BytecodePatch(
return v0
"""
)
return PatchResultSuccess()
}
}

View file

@ -5,8 +5,6 @@ import app.revanced.patcher.annotation.Name
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
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.patches.idaustria.detection.root.fingerprints.RootDetectionFingerprint
import app.revanced.patches.idaustria.detection.shared.annotations.DetectionCompatibility
@ -18,8 +16,6 @@ import app.revanced.patches.idaustria.detection.shared.annotations.DetectionComp
class RootDetectionPatch : BytecodePatch(
listOf(RootDetectionFingerprint)
) {
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) =
RootDetectionFingerprint.result!!.mutableMethod.addInstruction(0, "return-void")
return PatchResultSuccess()
}
}

View file

@ -5,8 +5,6 @@ import app.revanced.patcher.annotation.Name
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
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.patches.idaustria.detection.shared.annotations.DetectionCompatibility
import app.revanced.patches.idaustria.detection.signature.fingerprints.SpoofSignatureFingerprint
@ -32,7 +30,7 @@ class SpoofSignaturePatch : BytecodePatch(
"bf42c121d620ddfb7914f7a95c713d9e1c1b7bdb4a03d618e40cf7e9e235c0b5687e03b7ab3,publicExponent=10001}"
}
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
SpoofSignatureFingerprint.result!!.mutableMethod.addInstructions(
0,
"""
@ -40,6 +38,5 @@ class SpoofSignaturePatch : BytecodePatch(
return-object v0
"""
)
return PatchResultSuccess()
}
}

View file

@ -6,8 +6,6 @@ import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
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.patches.inshorts.ad.annotations.HideAdsCompatibility
import app.revanced.patches.inshorts.ad.fingerprints.InshortsAdsFingerprint
@ -19,7 +17,7 @@ import app.revanced.patches.inshorts.ad.fingerprints.InshortsAdsFingerprint
class HideAdsPatch : BytecodePatch(
listOf(InshortsAdsFingerprint)
) {
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
InshortsAdsFingerprint.result?.let { result ->
result.apply {
mutableMethod.addInstruction(
@ -29,8 +27,6 @@ class HideAdsPatch : BytecodePatch(
"""
)
}
} ?: return InshortsAdsFingerprint.toErrorResult()
return PatchResultSuccess()
} ?: throw InshortsAdsFingerprint.toErrorResult()
}
}

View file

@ -8,8 +8,6 @@ import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.extensions.InstructionExtensions.removeInstruction
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve
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.util.smali.ExternalLabel
import app.revanced.patches.instagram.patches.ads.timeline.fingerprints.MediaFingerprint
@ -32,19 +30,19 @@ class HideTimelineAdsPatch : BytecodePatch(
PaidPartnershipAdFingerprint // Unlike the other ads this one is resolved from all classes.
)
) {
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
// region Resolve required methods to check for ads.
ShowAdFingerprint.result ?: return ShowAdFingerprint.toErrorResult()
ShowAdFingerprint.result ?: throw ShowAdFingerprint.toErrorResult()
PaidPartnershipAdFingerprint.result ?: return PaidPartnershipAdFingerprint.toErrorResult()
PaidPartnershipAdFingerprint.result ?: throw PaidPartnershipAdFingerprint.toErrorResult()
MediaFingerprint.result?.let {
GenericMediaAdFingerprint.resolve(context, it.classDef)
ShoppingAdFingerprint.resolve(context, it.classDef)
return@let
} ?: return MediaFingerprint.toErrorResult()
} ?: throw MediaFingerprint.toErrorResult()
// endregion
@ -99,7 +97,5 @@ class HideTimelineAdsPatch : BytecodePatch(
// endregion
}
return PatchResultSuccess()
}
}

View file

@ -5,8 +5,6 @@ import app.revanced.patcher.annotation.Name
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
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.patches.irplus.ad.annotations.IrplusAdsCompatibility
import app.revanced.patches.irplus.ad.fingerprints.IrplusAdsFingerprint
@ -19,13 +17,11 @@ import app.revanced.patches.irplus.ad.fingerprints.IrplusAdsFingerprint
class IrplusAdsPatch : BytecodePatch(
listOf(IrplusAdsFingerprint)
) {
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
val method = IrplusAdsFingerprint.result!!.mutableMethod
// By overwriting the second parameter of the method,
// the view which holds the advertisement is removed.
method.addInstruction(0, "const/4 p2, 0x0")
return PatchResultSuccess()
}
}

View file

@ -5,8 +5,6 @@ import app.revanced.patcher.annotation.Name
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction
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.patches.lightroom.misc.login.annotations.DisableMandatoryLoginCompatibility
import app.revanced.patches.lightroom.misc.login.fingerprint.IsLoggedInFingerprint
@ -15,13 +13,11 @@ import app.revanced.patches.lightroom.misc.login.fingerprint.IsLoggedInFingerpri
@Name("Disable mandatory login")
@DisableMandatoryLoginCompatibility
class DisableMandatoryLoginPatch : BytecodePatch(listOf(IsLoggedInFingerprint)) {
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
IsLoggedInFingerprint.result?.mutableMethod?.apply {
val index = implementation!!.instructions.lastIndex - 1
// Set isLoggedIn = true.
replaceInstruction(index, "const/4 v0, 0x1")
} ?: throw IsLoggedInFingerprint.toErrorResult()
return PatchResultSuccess()
}
}

View file

@ -6,8 +6,6 @@ import app.revanced.patcher.annotation.Name
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction
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.patches.lightroom.misc.premium.annotations.UnlockPremiumCompatibility
import app.revanced.patches.lightroom.misc.premium.fingerprint.HasPurchasedFingerprint
@ -17,11 +15,9 @@ import app.revanced.patches.lightroom.misc.premium.fingerprint.HasPurchasedFinge
@Description("Unlocks premium features.")
@UnlockPremiumCompatibility
class UnlockPremiumPatch : BytecodePatch(listOf(HasPurchasedFingerprint)) {
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
// Set hasPremium = true.
HasPurchasedFingerprint.result?.mutableMethod?.replaceInstruction(2, "const/4 v2, 0x1")
?: throw HasPurchasedFingerprint.toErrorResult()
return PatchResultSuccess()
}
}

View file

@ -5,15 +5,13 @@ import app.revanced.patcher.annotation.Description
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.replaceInstructions
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patches.memegenerator.detection.license.fingerprint.LicenseValidationFingerprint
@Description("Disables Firebase license validation.")
class LicenseValidationPatch : BytecodePatch(
listOf(LicenseValidationFingerprint)
) {
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
LicenseValidationFingerprint.result?.apply {
mutableMethod.replaceInstructions(
0,
@ -23,7 +21,5 @@ class LicenseValidationPatch : BytecodePatch(
"""
)
} ?: throw LicenseValidationFingerprint.toErrorResult()
return PatchResultSuccess()
}
}

View file

@ -5,15 +5,13 @@ import app.revanced.patcher.annotation.Description
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.replaceInstructions
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patches.memegenerator.detection.signature.fingerprint.VerifySignatureFingerprint
@Description("Disables detection of incorrect signature.")
class SignatureVerificationPatch : BytecodePatch(
listOf(VerifySignatureFingerprint)
) {
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
VerifySignatureFingerprint.result?.apply {
mutableMethod.replaceInstructions(
0,
@ -23,7 +21,5 @@ class SignatureVerificationPatch : BytecodePatch(
"""
)
} ?: throw VerifySignatureFingerprint.toErrorResult()
return PatchResultSuccess()
}
}

View file

@ -6,8 +6,6 @@ import app.revanced.patcher.annotation.Name
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.replaceInstructions
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.Patch
import app.revanced.patches.memegenerator.detection.license.patch.LicenseValidationPatch
@ -28,7 +26,7 @@ class UnlockProVersionPatch : BytecodePatch(
IsFreeVersionFingerprint
)
) {
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
IsFreeVersionFingerprint.result?.apply {
mutableMethod.replaceInstructions(0,
"""
@ -37,7 +35,5 @@ class UnlockProVersionPatch : BytecodePatch(
"""
)
} ?: throw IsFreeVersionFingerprint.toErrorResult()
return PatchResultSuccess()
}
}

View file

@ -5,8 +5,6 @@ import app.revanced.patcher.annotation.*
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction
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.patches.messenger.ads.inbox.fingerprints.LoadInboxAdsFingerprint
@ -17,12 +15,10 @@ import app.revanced.patches.messenger.ads.inbox.fingerprints.LoadInboxAdsFingerp
class HideInboxAdsPatch : BytecodePatch(
listOf(LoadInboxAdsFingerprint)
) {
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
LoadInboxAdsFingerprint.result?.mutableMethod?.apply {
this.replaceInstruction(0, "return-void")
} ?: return LoadInboxAdsFingerprint.toErrorResult()
return PatchResultSuccess()
} ?: throw LoadInboxAdsFingerprint.toErrorResult()
}
}

View file

@ -6,8 +6,6 @@ import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction
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.patches.messenger.inputfield.fingerprints.SwitchMessangeInputEmojiButtonFingerprint
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
@ -17,7 +15,7 @@ import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
@Description("Disables switching from emoji to sticker search mode in message input field")
@Compatibility([Package("com.facebook.orca")])
class DisableSwitchingEmojiToStickerInMessageInputField : BytecodePatch(listOf(SwitchMessangeInputEmojiButtonFingerprint)) {
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
SwitchMessangeInputEmojiButtonFingerprint.result?.let {
val setStringIndex = it.scanResult.patternScanResult!!.startIndex + 2
@ -30,7 +28,5 @@ class DisableSwitchingEmojiToStickerInMessageInputField : BytecodePatch(listOf(S
)
}
} ?: throw SwitchMessangeInputEmojiButtonFingerprint.toErrorResult()
return PatchResultSuccess()
}
}

View file

@ -8,8 +8,6 @@ import app.revanced.patcher.annotation.Package
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction
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.patches.messenger.inputfield.fingerprints.SendTypingIndicatorFingerprint
@ -18,10 +16,8 @@ import app.revanced.patches.messenger.inputfield.fingerprints.SendTypingIndicato
@Description("Disables the indicator while typing a message")
@Compatibility([Package("com.facebook.orca")])
class DisableTypingIndicator : BytecodePatch(listOf(SendTypingIndicatorFingerprint)) {
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
SendTypingIndicatorFingerprint.result?.mutableMethod?.replaceInstruction(0, "return-void")
?: throw SendTypingIndicatorFingerprint.toErrorResult()
return PatchResultSuccess()
}
}

View file

@ -5,8 +5,6 @@ import app.revanced.patcher.annotation.Name
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
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.patches.moneymanager.annotations.UnlockProCompatibility
import app.revanced.patches.moneymanager.fingerprints.UnlockProFingerprint
@ -18,7 +16,7 @@ import app.revanced.patches.moneymanager.fingerprints.UnlockProFingerprint
class UnlockProPatch : BytecodePatch(
listOf(UnlockProFingerprint)
) {
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
UnlockProFingerprint.result!!.mutableMethod.addInstructions(
0,
"""
@ -26,6 +24,5 @@ class UnlockProPatch : BytecodePatch(
return v0
"""
)
return PatchResultSuccess()
}
}

View file

@ -6,8 +6,6 @@ import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve
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.patches.music.ad.video.fingerprints.ShowMusicVideoAdsConstructorFingerprint
import app.revanced.patches.music.ad.video.fingerprints.ShowMusicVideoAdsFingerprint
@ -20,7 +18,7 @@ import app.revanced.patches.music.annotations.MusicCompatibility
class MusicVideoAdsPatch : BytecodePatch(
listOf(ShowMusicVideoAdsConstructorFingerprint)
) {
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
ShowMusicVideoAdsFingerprint.resolve(context, ShowMusicVideoAdsConstructorFingerprint.result!!.classDef)
val result = ShowMusicVideoAdsFingerprint.result!!
@ -31,7 +29,5 @@ class MusicVideoAdsPatch : BytecodePatch(
const/4 p1, 0x0
"""
)
return PatchResultSuccess()
}
}

View file

@ -3,10 +3,7 @@ package app.revanced.patches.music.audio.codecs.patch
import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.data.toMethodWalker
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.util.smali.toInstruction
import app.revanced.patches.music.annotations.MusicCompatibility
@ -23,7 +20,7 @@ class CodecsUnlockPatch : BytecodePatch(
CodecsLockFingerprint, AllCodecsReferenceFingerprint
)
) {
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
val codecsLockResult = CodecsLockFingerprint.result!!
val implementation = codecsLockResult.mutableMethod.implementation!!
@ -48,7 +45,5 @@ class CodecsUnlockPatch : BytecodePatch(
instructionIndex,
"invoke-static {}, ${allCodecsMethod.definingClass}->${allCodecsMethod.name}()Ljava/util/Set;".toInstruction()
)
return PatchResultSuccess()
}
}

View file

@ -6,8 +6,6 @@ import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction
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.patches.music.annotations.MusicCompatibility
import app.revanced.patches.music.audio.exclusiveaudio.fingerprints.AudioOnlyEnablerFingerprint
@ -19,11 +17,9 @@ import app.revanced.patches.music.audio.exclusiveaudio.fingerprints.AudioOnlyEna
class ExclusiveAudioPatch : BytecodePatch(
listOf(AudioOnlyEnablerFingerprint)
) {
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
val method = AudioOnlyEnablerFingerprint.result!!.mutableMethod
method.replaceInstruction(method.implementation!!.instructions.count() - 1, "const/4 v0, 0x1")
method.addInstruction("return v0")
return PatchResultSuccess()
}
}

View file

@ -7,8 +7,6 @@ import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
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.util.smali.ExternalLabel
import app.revanced.patches.music.annotations.MusicCompatibility
@ -21,7 +19,7 @@ import app.revanced.patches.music.interaction.permanentrepeat.fingerprints.Repea
class PermanentRepeatPatch : BytecodePatch(
listOf(RepeatTrackFingerprint)
) {
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
RepeatTrackFingerprint.result?.let {
val startIndex = it.scanResult.patternScanResult!!.endIndex
val repeatIndex = startIndex + 3
@ -33,8 +31,6 @@ class PermanentRepeatPatch : BytecodePatch(
ExternalLabel("repeat", getInstruction(repeatIndex))
)
}
} ?: return RepeatTrackFingerprint.toErrorResult()
return PatchResultSuccess()
} ?: throw RepeatTrackFingerprint.toErrorResult()
}
}

View file

@ -6,8 +6,6 @@ import app.revanced.patcher.annotation.Name
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
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.patches.music.annotations.MusicCompatibility
import app.revanced.patches.music.interaction.permanentshuffle.fingerprints.DisableShuffleFingerprint
@ -20,10 +18,8 @@ import app.revanced.patches.music.interaction.permanentshuffle.fingerprints.Disa
class PermanentShuffleTogglePatch : BytecodePatch(
listOf(DisableShuffleFingerprint)
) {
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
DisableShuffleFingerprint.result?.mutableMethod?.addInstruction(0, "return-void")
?: return DisableShuffleFingerprint.toErrorResult()
return PatchResultSuccess()
?: throw DisableShuffleFingerprint.toErrorResult()
}
}

View file

@ -5,8 +5,6 @@ import app.revanced.patcher.annotation.Name
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
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.patches.music.annotations.MusicCompatibility
import app.revanced.patches.music.layout.compactheader.fingerprints.CompactHeaderConstructorFingerprint
@ -19,7 +17,7 @@ import com.android.tools.smali.dexlib2.builder.instruction.BuilderInstruction11x
class CompactHeaderPatch : BytecodePatch(
listOf(CompactHeaderConstructorFingerprint)
) {
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
val result = CompactHeaderConstructorFingerprint.result!!
val method = result.mutableMethod
@ -31,7 +29,5 @@ class CompactHeaderPatch : BytecodePatch(
invoke-virtual {v${register}, v2}, Landroid/view/View;->setVisibility(I)V
"""
)
return PatchResultSuccess()
}
}

View file

@ -5,8 +5,6 @@ import app.revanced.patcher.annotation.Name
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
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.patches.music.annotations.MusicCompatibility
import app.revanced.patches.music.layout.minimizedplayback.fingerprints.MinimizedPlaybackManagerFingerprint
@ -18,14 +16,12 @@ import app.revanced.patches.music.layout.minimizedplayback.fingerprints.Minimize
class MinimizedPlaybackPatch : BytecodePatch(
listOf(MinimizedPlaybackManagerFingerprint)
) {
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
MinimizedPlaybackManagerFingerprint.result!!.mutableMethod.addInstruction(
0,
"""
return-void
"""
)
return PatchResultSuccess()
}
}

View file

@ -7,8 +7,6 @@ import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve
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.patches.music.annotations.MusicCompatibility
import app.revanced.patches.music.layout.premium.fingerprints.HideGetPremiumFingerprint
@ -21,7 +19,7 @@ import app.revanced.patches.music.layout.premium.fingerprints.HideGetPremiumPare
class HideGetPremiumPatch : BytecodePatch(
listOf(HideGetPremiumParentFingerprint)
) {
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
val parentResult = HideGetPremiumParentFingerprint.result!!
HideGetPremiumFingerprint.resolve(context, parentResult.classDef)
@ -43,7 +41,5 @@ class HideGetPremiumPatch : BytecodePatch(
const/16 v0, 0x8
"""
)
return PatchResultSuccess()
}
}

View file

@ -5,8 +5,6 @@ import app.revanced.patcher.annotation.Name
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
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.util.smali.toInstructions
import app.revanced.patches.music.annotations.MusicCompatibility
@ -24,7 +22,7 @@ import com.android.tools.smali.dexlib2.iface.instruction.formats.Instruction35c
class RemoveUpgradeButtonPatch : BytecodePatch(
listOf(PivotBarConstructorFingerprint)
) {
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
val result = PivotBarConstructorFingerprint.result!!
val implementation = result.mutableMethod.implementation!!
@ -69,6 +67,5 @@ class RemoveUpgradeButtonPatch : BytecodePatch(
implementation.addInstructions(
endIndex, instructionList
)
return PatchResultSuccess()
}
}

View file

@ -6,8 +6,6 @@ import app.revanced.patcher.annotation.Name
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
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.patches.music.annotations.MusicCompatibility
import app.revanced.patches.music.misc.androidauto.fingerprints.CheckCertificateFingerprint
@ -19,7 +17,7 @@ import app.revanced.patches.music.misc.androidauto.fingerprints.CheckCertificate
class BypassCertificateChecksPatch : BytecodePatch(
listOf(CheckCertificateFingerprint)
) {
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
CheckCertificateFingerprint.result?.apply {
mutableMethod.addInstructions(
0, """
@ -27,8 +25,6 @@ class BypassCertificateChecksPatch : BytecodePatch(
return v0
"""
)
} ?: return CheckCertificateFingerprint.toErrorResult()
return PatchResultSuccess()
} ?: throw CheckCertificateFingerprint.toErrorResult()
}
}

View file

@ -4,7 +4,6 @@ import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.music.annotations.MusicCompatibility
@ -37,27 +36,25 @@ class MicroGBytecodePatch : BytecodePatch(
// - "com.google.android.gms.phenotype.PACKAGE_NAME",
// - "com.google.android.gms.phenotype.UPDATE",
// - "com.google.android.gms.phenotype",
override fun execute(context: BytecodeContext) =
// apply common microG patch
MicroGBytecodeHelper.patchBytecode(
context,
arrayOf(
MicroGBytecodeHelper.packageNameTransform(
Constants.PACKAGE_NAME,
Constants.REVANCED_PACKAGE_NAME
)
),
MicroGBytecodeHelper.PrimeMethodTransformationData(
PrimeFingerprint,
MUSIC_PACKAGE_NAME,
REVANCED_MUSIC_PACKAGE_NAME
),
listOf(
ServiceCheckFingerprint,
GooglePlayUtilityFingerprint,
CastDynamiteModuleFingerprint,
CastDynamiteModuleV2Fingerprint,
CastContextFetchFingerprint
override fun execute(context: BytecodeContext) = MicroGBytecodeHelper.patchBytecode(
context,
arrayOf(
MicroGBytecodeHelper.packageNameTransform(
Constants.PACKAGE_NAME,
Constants.REVANCED_PACKAGE_NAME
)
).let { PatchResultSuccess() }
),
MicroGBytecodeHelper.PrimeMethodTransformationData(
PrimeFingerprint,
MUSIC_PACKAGE_NAME,
REVANCED_MUSIC_PACKAGE_NAME
),
listOf(
ServiceCheckFingerprint,
GooglePlayUtilityFingerprint,
CastDynamiteModuleFingerprint,
CastDynamiteModuleV2Fingerprint,
CastContextFetchFingerprint
)
)
}

View file

@ -2,8 +2,6 @@ package app.revanced.patches.music.misc.microg.patch.resource
import app.revanced.patcher.annotation.Description
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.patches.music.misc.microg.shared.Constants.MUSIC_PACKAGE_NAME
import app.revanced.patches.music.misc.microg.shared.Constants.REVANCED_MUSIC_APP_NAME
@ -15,7 +13,7 @@ import app.revanced.util.microg.MicroGResourceHelper
@Description("Resource patch to allow YouTube Music ReVanced to run without root and under a different package name.")
class MicroGResourcePatch : ResourcePatch {
override fun execute(context: ResourceContext): PatchResult {
override fun execute(context: ResourceContext) {
// update manifest
MicroGResourceHelper.patchManifest(
context,
@ -30,6 +28,5 @@ class MicroGResourcePatch : ResourcePatch {
SPOOFED_PACKAGE_NAME,
SPOOFED_PACKAGE_SIGNATURE
)
return PatchResultSuccess()
}
}

View file

@ -5,8 +5,6 @@ import app.revanced.patcher.annotation.Name
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
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.patches.music.annotations.MusicCompatibility
import app.revanced.patches.music.premium.backgroundplay.fingerprints.BackgroundPlaybackDisableFingerprint
@ -18,7 +16,7 @@ import app.revanced.patches.music.premium.backgroundplay.fingerprints.Background
class BackgroundPlayPatch : BytecodePatch(
listOf(BackgroundPlaybackDisableFingerprint)
) {
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
BackgroundPlaybackDisableFingerprint.result!!.mutableMethod.addInstructions(
0,
"""
@ -26,7 +24,5 @@ class BackgroundPlayPatch : BytecodePatch(
return v0
"""
)
return PatchResultSuccess()
}
}

View file

@ -5,8 +5,6 @@ import app.revanced.patcher.annotation.Name
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
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.patches.myexpenses.misc.pro.annotations.UnlockProCompatibility
import app.revanced.patches.myexpenses.misc.pro.fingerprints.IsEnabledFingerprint
@ -20,7 +18,7 @@ class UnlockProPatch : BytecodePatch(
IsEnabledFingerprint
)
) {
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
val method = IsEnabledFingerprint.result!!.mutableMethod
method.addInstructions(
0,
@ -29,7 +27,5 @@ class UnlockProPatch : BytecodePatch(
return v0
"""
)
return PatchResultSuccess()
}
}

View file

@ -3,8 +3,6 @@ package app.revanced.patches.netguard.broadcasts.removerestriction.resource.patc
import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name
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.annotations.Patch
import app.revanced.patches.netguard.broadcasts.removerestriction.resource.annotations.RemoveBroadcastsRestrictionCompatibility
@ -15,7 +13,7 @@ import org.w3c.dom.Element
@Description("Enables starting/stopping NetGuard via broadcasts.")
@RemoveBroadcastsRestrictionCompatibility
class RemoveBroadcastsRestrictionPatch : ResourcePatch {
override fun execute(context: ResourceContext): PatchResult {
override fun execute(context: ResourceContext) {
context.xmlEditor["AndroidManifest.xml"].use { dom ->
val applicationNode = dom
.file
@ -32,7 +30,5 @@ class RemoveBroadcastsRestrictionPatch : ResourcePatch {
}
}
}
return PatchResultSuccess()
}
}

View file

@ -6,8 +6,6 @@ import app.revanced.patcher.annotation.Name
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
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.patches.nfctoolsse.misc.pro.annotations.UnlockProCompatibility
import app.revanced.patches.nfctoolsse.misc.pro.fingerprints.IsLicenseRegisteredFingerprint
@ -22,7 +20,7 @@ class UnlockProPatch : BytecodePatch(
IsLicenseRegisteredFingerprint
)
) {
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
IsLicenseRegisteredFingerprint.result?.mutableMethod?.apply {
addInstructions(
0,
@ -31,9 +29,7 @@ class UnlockProPatch : BytecodePatch(
return v0
"""
)
} ?: return IsLicenseRegisteredFingerprint.toErrorResult()
return PatchResultSuccess()
} ?: throw IsLicenseRegisteredFingerprint.toErrorResult()
}
}

View file

@ -5,8 +5,6 @@ import app.revanced.patcher.annotation.Name
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
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.patches.nyx.misc.pro.annotations.UnlockProCompatibility
import app.revanced.patches.nyx.misc.pro.fingerprints.CheckProFingerprint
@ -20,7 +18,7 @@ class UnlockProPatch : BytecodePatch(
CheckProFingerprint
)
) {
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
val method = CheckProFingerprint.result!!.mutableMethod
method.addInstructions(
0,
@ -29,7 +27,5 @@ class UnlockProPatch : BytecodePatch(
return v0
"""
)
return PatchResultSuccess()
}
}

View file

@ -6,8 +6,6 @@ import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patches.photomath.detection.signature.fingerprints.CheckSignatureFingerprint
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
@ -17,15 +15,13 @@ class SignatureDetectionPatch : BytecodePatch(
CheckSignatureFingerprint
)
) {
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
CheckSignatureFingerprint.result?.apply {
val signatureCheckInstruction = mutableMethod.getInstruction(scanResult.patternScanResult!!.endIndex)
val checkRegister = (signatureCheckInstruction as OneRegisterInstruction).registerA
mutableMethod.replaceInstruction(signatureCheckInstruction.location.index, "const/4 v$checkRegister, 0x1")
} ?: throw CheckSignatureFingerprint.toErrorResult()
return PatchResultSuccess()
}
}

View file

@ -6,8 +6,6 @@ import app.revanced.patcher.annotation.Name
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
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.Patch
import app.revanced.patches.photomath.detection.signature.patch.SignatureDetectionPatch
@ -24,7 +22,7 @@ class UnlockPlusPatch : BytecodePatch(
IsPlusUnlockedFingerprint
)
) {
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
IsPlusUnlockedFingerprint.result?.mutableMethod?.apply {
addInstructions(
0,
@ -33,9 +31,7 @@ class UnlockPlusPatch : BytecodePatch(
return v0
"""
)
} ?: return IsPlusUnlockedFingerprint.toErrorResult()
return PatchResultSuccess()
} ?: throw IsPlusUnlockedFingerprint.toErrorResult()
}
}

View file

@ -5,8 +5,6 @@ import app.revanced.patcher.annotation.*
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
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.patches.pixiv.ads.fingerprints.IsNotPremiumFingerprint
@ -15,7 +13,7 @@ import app.revanced.patches.pixiv.ads.fingerprints.IsNotPremiumFingerprint
@Description("Hides ads.")
@Compatibility([Package("jp.pxv.android")])
class HideAdsPatch : BytecodePatch(listOf(IsNotPremiumFingerprint)) {
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
// Always return false in the "isNotPremium" method which normally returns !this.accountManager.isPremium.
// However, this is not the method that controls the user's premium status.
// Instead, this method is used to determine whether ads should be shown.
@ -25,8 +23,6 @@ class HideAdsPatch : BytecodePatch(listOf(IsNotPremiumFingerprint)) {
const/4 v0, 0x0
return v0
"""
) ?: return IsNotPremiumFingerprint.toErrorResult()
return PatchResultSuccess()
) ?: throw IsNotPremiumFingerprint.toErrorResult()
}
}

View file

@ -3,14 +3,12 @@ package app.revanced.patches.reddit.ad.banner.patch
import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name
import app.revanced.patcher.data.ResourceContext
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.ResourcePatch
@Name("Hide subreddit banner")
@Description("Hides banner ads from comments on subreddits.")
class HideBannerPatch : ResourcePatch {
override fun execute(context: ResourceContext): PatchResult {
override fun execute(context: ResourceContext) {
context.xmlEditor[RESOURCE_FILE_PATH].use {
it.file.getElementsByTagName("merge").item(0).childNodes.apply {
val attributes = arrayOf("height", "width")
@ -30,8 +28,6 @@ class HideBannerPatch : ResourcePatch {
}
}
}
return PatchResultSuccess()
}
private companion object {

View file

@ -5,8 +5,6 @@ import app.revanced.patcher.annotation.Name
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patches.reddit.ad.comments.fingerprints.HideCommentAdsFingerprint
@Name("Hide comment ads")
@ -14,7 +12,7 @@ import app.revanced.patches.reddit.ad.comments.fingerprints.HideCommentAdsFinger
class HideCommentAdsPatch : BytecodePatch(
listOf(HideCommentAdsFingerprint)
) {
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
val method = HideCommentAdsFingerprint.result!!.mutableMethod
// Returns a blank object instead of the comment ad.
method.addInstructions(
@ -25,6 +23,5 @@ class HideCommentAdsPatch : BytecodePatch(
return-object v0
"""
)
return PatchResultSuccess()
}
}

View file

@ -6,8 +6,6 @@ import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
import app.revanced.patcher.extensions.InstructionExtensions.removeInstruction
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.Patch
import app.revanced.patcher.patch.annotations.RequiresIntegrations
@ -31,7 +29,7 @@ import com.android.tools.smali.dexlib2.iface.reference.MethodReference
class HideAdsPatch : BytecodePatch(
listOf(AdPostFingerprint, NewAdPostFingerprint)
) {
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
// region Filter promoted ads (does not work in popular or latest feed)
AdPostFingerprint.result?.mutableMethod?.apply {
@ -78,8 +76,6 @@ class HideAdsPatch : BytecodePatch(
}
// endregion
return PatchResultSuccess()
}
private companion object {

View file

@ -5,7 +5,10 @@ import app.revanced.extensions.toErrorResult
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprintResult
import app.revanced.patcher.patch.*
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.OptionsContainer
import app.revanced.patcher.patch.PatchException
import app.revanced.patcher.patch.PatchOption
import java.io.File
abstract class AbstractSpoofClientPatch(
@ -17,13 +20,13 @@ abstract class AbstractSpoofClientPatch(
addAll(clientIdFingerprints)
userAgentFingerprints?.let(::addAll)
}) {
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
if (options.clientId == null) {
// Ensure device runs Android.
try {
Class.forName("android.os.Environment")
} catch (e: ClassNotFoundException) {
return PatchResultError("No client ID provided")
throw PatchException("No client ID provided")
}
File(Environment.getExternalStorageDirectory(), "reddit_client_id_revanced.txt").also {
@ -38,22 +41,16 @@ abstract class AbstractSpoofClientPatch(
The application type has to be "Installed app" and the redirect URI has to be set to "$redirectUri".
""".trimIndent()
return PatchResultError(error)
throw PatchException(error)
}.let { options.clientId = it.readText().trim() }
}
fun List<MethodFingerprint>?.executePatch(
patch: List<MethodFingerprintResult>.(BytecodeContext) -> PatchResult
) {
when (val result = this?.map { it.result ?: throw it.toErrorResult() }?.patch(context)) {
is PatchResultError -> throw result
}
}
patch: List<MethodFingerprintResult>.(BytecodeContext) -> Unit
) = this?.map { it.result ?: throw it.toErrorResult() }?.patch(context)
clientIdFingerprints.executePatch { patchClientId(context) }
userAgentFingerprints.executePatch { patchUserAgent(context) }
return PatchResultSuccess()
}
/**
@ -62,7 +59,7 @@ abstract class AbstractSpoofClientPatch(
* @param context The current [BytecodeContext].
*
*/
abstract fun List<MethodFingerprintResult>.patchClientId(context: BytecodeContext): PatchResult
abstract fun List<MethodFingerprintResult>.patchClientId(context: BytecodeContext)
/**
* Patch the user agent. The fingerprints are guaranteed to be in the same order as in [userAgentFingerprints].
@ -70,8 +67,7 @@ abstract class AbstractSpoofClientPatch(
* @param context The current [BytecodeContext].
*/
// Not every client needs to patch the user agent.
open fun List<MethodFingerprintResult>.patchUserAgent(context: BytecodeContext): PatchResult =
PatchResultSuccess()
open fun List<MethodFingerprintResult>.patchUserAgent(context: BytecodeContext) {}
companion object Options {
open class SpoofClientOptionsContainer : OptionsContainer() {

View file

@ -7,8 +7,6 @@ import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprintResult
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patches.reddit.customclients.AbstractSpoofClientPatch
import app.revanced.patches.reddit.customclients.SpoofClientAnnotation
import app.revanced.patches.reddit.customclients.baconreader.api.fingerprints.GetAuthorizationUrlFingerprint
@ -30,7 +28,7 @@ class SpoofClientPatch : AbstractSpoofClientPatch(
"http://baconreader.com/auth", Options, listOf(GetAuthorizationUrlFingerprint, RequestTokenFingerprint)
) {
override fun List<MethodFingerprintResult>.patchClientId(context: BytecodeContext): PatchResult {
override fun List<MethodFingerprintResult>.patchClientId(context: BytecodeContext) {
fun MethodFingerprintResult.patch(replacementString: String) {
val clientIdIndex = scanResult.stringsScanResult!!.matches.first().index
@ -48,8 +46,6 @@ class SpoofClientPatch : AbstractSpoofClientPatch(
// Patch client id for access token request.
last().patch(clientId!!)
return PatchResultSuccess()
}
companion object Options : AbstractSpoofClientPatch.Options.SpoofClientOptionsContainer()

View file

@ -6,8 +6,6 @@ import app.revanced.patcher.annotation.Package
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprintResult
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patches.reddit.customclients.AbstractSpoofClientPatch
import app.revanced.patches.reddit.customclients.SpoofClientAnnotation
import app.revanced.patches.reddit.customclients.boostforreddit.api.fingerprints.GetClientIdFingerprint
@ -20,7 +18,7 @@ import app.revanced.patches.reddit.customclients.boostforreddit.api.fingerprints
class SpoofClientPatch : AbstractSpoofClientPatch(
"http://rubenmayayo.com", Options, listOf(GetClientIdFingerprint)
) {
override fun List<MethodFingerprintResult>.patchClientId(context: BytecodeContext): PatchResult {
override fun List<MethodFingerprintResult>.patchClientId(context: BytecodeContext) {
first().mutableMethod.addInstructions(
0,
"""
@ -28,8 +26,6 @@ class SpoofClientPatch : AbstractSpoofClientPatch(
return-object v0
"""
)
return PatchResultSuccess()
}
companion object Options : AbstractSpoofClientPatch.Options.SpoofClientOptionsContainer()

View file

@ -7,8 +7,6 @@ import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprintResult
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patches.reddit.customclients.AbstractSpoofClientPatch
import app.revanced.patches.reddit.customclients.SpoofClientAnnotation
import app.revanced.patches.reddit.customclients.infinityforreddit.api.fingerprints.GetHttpBasicAuthHeaderFingerprint
@ -25,7 +23,7 @@ class SpoofClientPatch : AbstractSpoofClientPatch(
Options,
listOf(GetHttpBasicAuthHeaderFingerprint, LoginActivityOnCreateFingerprint)
) {
override fun List<MethodFingerprintResult>.patchClientId(context: BytecodeContext): PatchResult {
override fun List<MethodFingerprintResult>.patchClientId(context: BytecodeContext) {
forEach {
val clientIdIndex = it.scanResult.stringsScanResult!!.matches.first().index
it.mutableMethod.apply {
@ -37,8 +35,6 @@ class SpoofClientPatch : AbstractSpoofClientPatch(
)
}
}
return PatchResultSuccess()
}
companion object Options : AbstractSpoofClientPatch.Options.SpoofClientOptionsContainer()

View file

@ -7,8 +7,6 @@ import app.revanced.patcher.annotation.Package
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
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.Patch
import app.revanced.patches.reddit.customclients.joeyforreddit.ads.fingerprints.IsAdFreeUserFingerprint
@ -19,15 +17,13 @@ import app.revanced.patches.reddit.customclients.joeyforreddit.detection.piracy.
@DependsOn([DisablePiracyDetectionPatch::class])
@Compatibility([Package("o.o.joey")])
class DisableAdsPatch : BytecodePatch(listOf(IsAdFreeUserFingerprint)) {
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
IsAdFreeUserFingerprint.result?.mutableMethod?.addInstructions(
0,
"""
const/4 v0, 0x1
return v0
"""
) ?: return IsAdFreeUserFingerprint.toErrorResult()
return PatchResultSuccess()
) ?: throw IsAdFreeUserFingerprint.toErrorResult()
}
}

View file

@ -6,8 +6,6 @@ import app.revanced.patcher.annotation.Package
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprintResult
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patches.reddit.customclients.AbstractSpoofClientPatch
import app.revanced.patches.reddit.customclients.SpoofClientAnnotation
@ -31,7 +29,7 @@ import app.revanced.patches.reddit.customclients.joeyforreddit.detection.piracy.
class SpoofClientPatch : AbstractSpoofClientPatch(
"https://127.0.0.1:65023/authorize_callback", Options, listOf(GetClientIdFingerprint)
) {
override fun List<MethodFingerprintResult>.patchClientId(context: BytecodeContext): PatchResult {
override fun List<MethodFingerprintResult>.patchClientId(context: BytecodeContext) {
first().mutableMethod.addInstructions(
0,
"""
@ -39,8 +37,6 @@ class SpoofClientPatch : AbstractSpoofClientPatch(
return-object v0
"""
)
return PatchResultSuccess()
}
companion object Options : AbstractSpoofClientPatch.Options.SpoofClientOptionsContainer()

View file

@ -4,19 +4,15 @@ import app.revanced.extensions.toErrorResult
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patches.reddit.customclients.joeyforreddit.detection.piracy.fingerprints.PiracyDetectionFingerprint
class DisablePiracyDetectionPatch : BytecodePatch(listOf(PiracyDetectionFingerprint)) {
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
PiracyDetectionFingerprint.result?.mutableMethod?.addInstruction(
0,
"""
return-void
"""
) ?: return PiracyDetectionFingerprint.toErrorResult()
return PatchResultSuccess()
) ?: throw PiracyDetectionFingerprint.toErrorResult()
}
}

View file

@ -9,8 +9,6 @@ import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprintResult
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprintResult.MethodFingerprintScanResult.StringsScanResult.StringMatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patches.reddit.customclients.AbstractSpoofClientPatch
import app.revanced.patches.reddit.customclients.SpoofClientAnnotation
import app.revanced.patches.reddit.customclients.redditisfun.api.fingerprints.BasicAuthorizationFingerprint
@ -29,7 +27,7 @@ class SpoofClientPatch : AbstractSpoofClientPatch(
listOf(BuildAuthorizationStringFingerprint, BasicAuthorizationFingerprint),
listOf(GetUserAgentFingerprint)
) {
override fun List<MethodFingerprintResult>.patchClientId(context: BytecodeContext): PatchResult {
override fun List<MethodFingerprintResult>.patchClientId(context: BytecodeContext) {
/**
* Replaces a one register instruction with a const-string instruction
* at the index returned by [getReplacementIndex].
@ -53,11 +51,9 @@ class SpoofClientPatch : AbstractSpoofClientPatch(
// Path basic authorization.
last().replaceWith("$clientId:") { last().index + 7 }
return PatchResultSuccess()
}
override fun List<MethodFingerprintResult>.patchUserAgent(context: BytecodeContext): PatchResult {
override fun List<MethodFingerprintResult>.patchUserAgent(context: BytecodeContext) {
// Use a random user agent.
val randomName = (0..100000).random()
val userAgent = "android:app.revanced.$randomName:v1.0.0 (by /u/revanced)"
@ -69,8 +65,6 @@ class SpoofClientPatch : AbstractSpoofClientPatch(
return-object v0
"""
)
return PatchResultSuccess()
}
companion object Options : AbstractSpoofClientPatch.Options.SpoofClientOptionsContainer()

View file

@ -7,8 +7,6 @@ import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprintResult
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patches.reddit.customclients.AbstractSpoofClientPatch
import app.revanced.patches.reddit.customclients.SpoofClientAnnotation
import app.revanced.patches.reddit.customclients.relayforreddit.api.fingerprints.GetLoggedInBearerTokenFingerprint
@ -32,7 +30,7 @@ class SpoofClientPatch : AbstractSpoofClientPatch(
GetRefreshTokenFingerprint
)
) {
override fun List<MethodFingerprintResult>.patchClientId(context: BytecodeContext): PatchResult {
override fun List<MethodFingerprintResult>.patchClientId(context: BytecodeContext) {
forEach {
val clientIdIndex = it.scanResult.stringsScanResult!!.matches.first().index
it.mutableMethod.apply {
@ -44,8 +42,6 @@ class SpoofClientPatch : AbstractSpoofClientPatch(
)
}
}
return PatchResultSuccess()
}
companion object Options : AbstractSpoofClientPatch.Options.SpoofClientOptionsContainer()

View file

@ -6,8 +6,6 @@ import app.revanced.patcher.annotation.Package
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprintResult
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patches.reddit.customclients.AbstractSpoofClientPatch
import app.revanced.patches.reddit.customclients.SpoofClientAnnotation
import app.revanced.patches.reddit.customclients.boostforreddit.api.fingerprints.GetClientIdFingerprint
@ -20,7 +18,7 @@ import app.revanced.patches.reddit.customclients.boostforreddit.api.fingerprints
class SpoofClientPatch : AbstractSpoofClientPatch(
"http://www.ccrama.me", Options, listOf(GetClientIdFingerprint)
) {
override fun List<MethodFingerprintResult>.patchClientId(context: BytecodeContext): PatchResult {
override fun List<MethodFingerprintResult>.patchClientId(context: BytecodeContext) {
first().mutableMethod.addInstructions(
0,
"""
@ -28,8 +26,6 @@ class SpoofClientPatch : AbstractSpoofClientPatch(
return-object v0
"""
)
return PatchResultSuccess()
}
companion object Options : AbstractSpoofClientPatch.Options.SpoofClientOptionsContainer()

View file

@ -5,8 +5,6 @@ import app.revanced.patcher.annotation.*
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
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.Patch
import app.revanced.patches.reddit.customclients.syncforreddit.ads.fingerprints.IsAdsEnabledFingerprint
@ -17,7 +15,7 @@ import app.revanced.patches.reddit.customclients.syncforreddit.detection.piracy.
@DependsOn([DisablePiracyDetectionPatch::class])
@Compatibility([Package("com.laurencedawson.reddit_sync")])
class DisableAdsPatch : BytecodePatch(listOf(IsAdsEnabledFingerprint)) {
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
IsAdsEnabledFingerprint.result?.mutableMethod?.apply {
addInstructions(
0,
@ -26,9 +24,7 @@ class DisableAdsPatch : BytecodePatch(listOf(IsAdsEnabledFingerprint)) {
return v0
"""
)
} ?: return IsAdsEnabledFingerprint.toErrorResult()
return PatchResultSuccess()
} ?: throw IsAdsEnabledFingerprint.toErrorResult()
}
}

View file

@ -7,8 +7,6 @@ import app.revanced.patcher.annotation.Package
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.removeInstruction
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.patches.reddit.customclients.syncforreddit.annoyances.startup.fingerprints.MainActivityOnCreate
@ -23,13 +21,11 @@ import app.revanced.patches.reddit.customclients.syncforreddit.annoyances.startu
]
)
class DisableSyncForLemmyBottomSheetPatch : BytecodePatch(listOf(MainActivityOnCreate)) {
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
MainActivityOnCreate.result?.mutableMethod?.apply {
val showBottomSheetIndex = implementation!!.instructions.lastIndex - 1
removeInstruction(showBottomSheetIndex)
}
return PatchResultSuccess()
}
}

View file

@ -10,8 +10,6 @@ import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprintResult
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patches.reddit.customclients.AbstractSpoofClientPatch
import app.revanced.patches.reddit.customclients.SpoofClientAnnotation
@ -38,7 +36,7 @@ import java.util.*
class SpoofClientPatch : AbstractSpoofClientPatch(
"http://redditsync/auth", Options, listOf(GetAuthorizationStringFingerprint)
) {
override fun List<MethodFingerprintResult>.patchClientId(context: BytecodeContext): PatchResult {
override fun List<MethodFingerprintResult>.patchClientId(context: BytecodeContext) {
forEach { fingerprintResult ->
fingerprintResult.also { result ->
GetBearerTokenFingerprint.also { it.resolve(context, result.classDef) }.result?.mutableMethod?.apply {
@ -50,7 +48,7 @@ class SpoofClientPatch : AbstractSpoofClientPatch(
return-object v0
"""
)
} ?: return GetBearerTokenFingerprint.toErrorResult()
} ?: throw GetBearerTokenFingerprint.toErrorResult()
}.let {
val occurrenceIndex = it.scanResult.stringsScanResult!!.matches.first().index
@ -71,8 +69,6 @@ class SpoofClientPatch : AbstractSpoofClientPatch(
}
}
}
return PatchResultSuccess()
}
companion object Options : AbstractSpoofClientPatch.Options.SpoofClientOptionsContainer()

View file

@ -4,13 +4,11 @@ import app.revanced.patcher.annotation.Description
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patches.reddit.customclients.syncforreddit.detection.piracy.fingerprints.PiracyDetectionFingerprint
@Description("Disables detection of modified versions.")
class DisablePiracyDetectionPatch : BytecodePatch(listOf(PiracyDetectionFingerprint)) {
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
// Do not return an error if the fingerprint is not resolved.
// This is fine because new versions of the target app do not need this patch.
PiracyDetectionFingerprint.result?.mutableMethod?.apply {
@ -21,7 +19,5 @@ class DisablePiracyDetectionPatch : BytecodePatch(listOf(PiracyDetectionFingerpr
"""
)
}
return PatchResultSuccess()
}
}

View file

@ -6,8 +6,6 @@ import app.revanced.patcher.annotation.Name
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
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.patches.reddit.layout.disablescreenshotpopup.annotations.DisableScreenshotPopupCompatibility
import app.revanced.patches.reddit.layout.disablescreenshotpopup.fingerprints.DisableScreenshotPopupFingerprint
@ -19,10 +17,8 @@ import app.revanced.patches.reddit.layout.disablescreenshotpopup.fingerprints.Di
class DisableScreenshotPopupPatch : BytecodePatch(
listOf(DisableScreenshotPopupFingerprint)
) {
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
DisableScreenshotPopupFingerprint.result?.mutableMethod?.addInstruction(0, "return-void")
?: return DisableScreenshotPopupFingerprint.toErrorResult()
return PatchResultSuccess()
?: throw DisableScreenshotPopupFingerprint.toErrorResult()
}
}

View file

@ -5,8 +5,6 @@ import app.revanced.patcher.annotation.Name
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
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.patches.reddit.layout.premiumicon.annotations.PremiumIconCompatibility
import app.revanced.patches.reddit.layout.premiumicon.fingerprints.PremiumIconFingerprint
@ -20,7 +18,7 @@ class PremiumIconPatch : BytecodePatch(
PremiumIconFingerprint
)
) {
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
val method = PremiumIconFingerprint.result!!.mutableMethod
method.addInstructions(
0,
@ -29,6 +27,5 @@ class PremiumIconPatch : BytecodePatch(
return v0
"""
)
return PatchResultSuccess()
}
}

View file

@ -6,8 +6,6 @@ import app.revanced.patcher.annotation.Name
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
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.patches.reddit.misc.tracking.url.annotations.SanitizeUrlQueryCompatibility
import app.revanced.patches.reddit.misc.tracking.url.fingerprints.ShareLinkFormatterFingerprint
@ -19,14 +17,12 @@ import app.revanced.patches.reddit.misc.tracking.url.fingerprints.ShareLinkForma
class SanitizeUrlQueryPatch : BytecodePatch(
listOf(ShareLinkFormatterFingerprint)
) {
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
ShareLinkFormatterFingerprint.result?.mutableMethod?.addInstructions(
0,
"return-object p0"
) ?: return ShareLinkFormatterFingerprint.toErrorResult()
return PatchResultSuccess()
) ?: throw ShareLinkFormatterFingerprint.toErrorResult()
}
}

View file

@ -5,8 +5,6 @@ import app.revanced.patcher.annotation.Name
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
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.patches.scbeasy.detection.debugging.annotations.RemoveDebuggingDetectionCompatibility
import app.revanced.patches.scbeasy.detection.debugging.fingerprints.DebuggingDetectionFingerprint
@ -18,7 +16,7 @@ import app.revanced.patches.scbeasy.detection.debugging.fingerprints.DebuggingDe
class RemoveDebuggingDetectionPatch : BytecodePatch(
listOf(DebuggingDetectionFingerprint)
) {
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
DebuggingDetectionFingerprint.result!!.mutableMethod.addInstructions(
0,
"""
@ -26,6 +24,5 @@ class RemoveDebuggingDetectionPatch : BytecodePatch(
return v0
"""
)
return PatchResultSuccess()
}
}

View file

@ -5,9 +5,7 @@ import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultError
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.PatchException
import app.revanced.patches.shared.integrations.patch.AbstractIntegrationsPatch.IntegrationsFingerprint.RegisterResolver
import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.ClassDef
@ -40,7 +38,7 @@ abstract class AbstractIntegrationsPatch(
strings,
customFingerprint
) {
fun invoke(integrationsDescriptor: String): PatchResult {
fun invoke(integrationsDescriptor: String) {
result?.mutableMethod?.let { method ->
val contextRegister = contextRegisterResolver(method)
@ -49,9 +47,7 @@ abstract class AbstractIntegrationsPatch(
"sput-object v$contextRegister, " +
"$integrationsDescriptor->context:Landroid/content/Context;"
)
} ?: return PatchResultError("Could not find hook target fingerprint.")
return PatchResultSuccess()
} ?: throw PatchException("Could not find hook target fingerprint.")
}
interface RegisterResolver : (Method) -> Int {
@ -59,20 +55,11 @@ abstract class AbstractIntegrationsPatch(
}
}
override fun execute(context: BytecodeContext): PatchResult {
if (context.findClass(integrationsDescriptor) == null) return MISSING_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."
override fun execute(context: BytecodeContext) {
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)
}
}

View file

@ -1,8 +1,6 @@
package app.revanced.patches.shared.mapping.misc.patch
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 org.w3c.dom.Element
import java.util.*
@ -19,7 +17,7 @@ class ResourceMappingPatch : ResourcePatch {
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
val resourceXmlFile = context["res/values/public.xml"].readBytes()
@ -59,8 +57,6 @@ class ResourceMappingPatch : ResourcePatch {
.awaitTermination(Long.MAX_VALUE, TimeUnit.SECONDS)
resourceMappings = mappings
return PatchResultSuccess()
}
}

View file

@ -6,8 +6,6 @@ import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patches.shared.misc.fix.verticalscroll.annotations.VerticalScrollCompatibility
import app.revanced.patches.shared.misc.fix.verticalscroll.fingerprints.CanScrollVerticallyFingerprint
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
@ -17,7 +15,7 @@ import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
class VerticalScrollPatch : BytecodePatch(
listOf(CanScrollVerticallyFingerprint)
) {
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
CanScrollVerticallyFingerprint.result?.let {
it.mutableMethod.apply {
val moveResultIndex = it.scanResult.patternScanResult!!.endIndex
@ -29,8 +27,6 @@ class VerticalScrollPatch : BytecodePatch(
"const/4 v$moveResultRegister, 0x0"
)
}
} ?: return CanScrollVerticallyFingerprint.toErrorResult()
return PatchResultSuccess()
} ?: throw CanScrollVerticallyFingerprint.toErrorResult()
}
}

View file

@ -1,10 +1,8 @@
package app.revanced.patches.shared.settings.resource.patch
import app.revanced.patcher.data.DomFileEditor
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.util.DomFileEditor
import app.revanced.patches.shared.settings.preference.BasePreference
import app.revanced.patches.shared.settings.preference.BaseResource
import app.revanced.patches.shared.settings.preference.addPreference
@ -26,7 +24,7 @@ abstract class AbstractSettingsResourcePatch(
private val preferenceFileName: String,
private val sourceDirectory: String,
) : ResourcePatch, Closeable {
override fun execute(context: ResourceContext): PatchResult {
override fun execute(context: ResourceContext) {
/*
* used for self-restart
* TODO: do this only, when necessary
@ -51,8 +49,6 @@ abstract class AbstractSettingsResourcePatch(
stringsEditor = context.xmlEditor["res/values/strings.xml"]
arraysEditor = context.xmlEditor["res/values/arrays.xml"]
revancedPreferencesEditor = context.xmlEditor["res/xml/$preferenceFileName.xml"]
return PatchResultSuccess()
}
internal companion object {

View file

@ -7,8 +7,6 @@ import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
import app.revanced.patcher.extensions.InstructionExtensions.removeInstructions
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.patches.songpal.badge.annotations.BadgeCompatibility
import app.revanced.patches.songpal.badge.fingerprints.CreateTabsFingerprint
@ -20,7 +18,7 @@ import app.revanced.patches.songpal.badge.fingerprints.CreateTabsFingerprint
class BadgeTabPatch : BytecodePatch(
listOf(CreateTabsFingerprint)
) {
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
CreateTabsFingerprint.result?.mutableMethod?.apply {
removeInstructions(0, 2)
@ -52,9 +50,7 @@ class BadgeTabPatch : BytecodePatch(
"""
)
} ?: return CreateTabsFingerprint.toErrorResult()
return PatchResultSuccess()
} ?: throw CreateTabsFingerprint.toErrorResult()
}
companion object {

View file

@ -6,8 +6,6 @@ import app.revanced.patcher.annotation.Name
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
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.patches.songpal.badge.annotations.BadgeCompatibility
import app.revanced.patches.songpal.badge.fingerprints.ShowNotificationFingerprint
@ -19,11 +17,9 @@ import app.revanced.patches.songpal.badge.fingerprints.ShowNotificationFingerpri
class RemoveNotificationBadgePatch : BytecodePatch(
listOf(ShowNotificationFingerprint)
) {
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
ShowNotificationFingerprint.result?.mutableMethod?.apply {
addInstructions(0, "return-void")
} ?: return ShowNotificationFingerprint.toErrorResult()
return PatchResultSuccess()
} ?: throw ShowNotificationFingerprint.toErrorResult()
}
}

View file

@ -3,7 +3,9 @@ package app.revanced.patches.spotify.layout.theme.patch
import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name
import app.revanced.patcher.data.ResourceContext
import app.revanced.patcher.patch.*
import app.revanced.patcher.patch.OptionsContainer
import app.revanced.patcher.patch.PatchOption
import app.revanced.patcher.patch.ResourcePatch
import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.spotify.layout.theme.annotations.ThemeCompatibility
import org.w3c.dom.Element
@ -13,7 +15,7 @@ import org.w3c.dom.Element
@Description("Applies a custom theme.")
@ThemeCompatibility
class ThemePatch : ResourcePatch {
override fun execute(context: ResourceContext): PatchResult {
override fun execute(context: ResourceContext) {
context.xmlEditor["res/values/colors.xml"].use { editor ->
val resourcesNode = editor.file.getElementsByTagName("resources").item(0) as Element
@ -28,8 +30,6 @@ class ThemePatch : ResourcePatch {
}
}
}
return PatchResultSuccess()
}
companion object : OptionsContainer() {

View file

@ -6,8 +6,6 @@ import app.revanced.patcher.annotation.Name
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
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.patches.spotify.lite.ondemand.annotations.OnDemandCompatibility
import app.revanced.patches.spotify.lite.ondemand.fingerprints.OnDemandFingerprint
@ -21,12 +19,11 @@ class OnDemandPatch : BytecodePatch(
OnDemandFingerprint
)
) {
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
OnDemandFingerprint.result?.apply {
val insertIndex = scanResult.patternScanResult!!.endIndex - 1
// Spoof a premium account
mutableMethod.addInstruction(insertIndex, "const/4 v0, 0x2")
} ?: return OnDemandFingerprint.toErrorResult()
return PatchResultSuccess()
} ?: throw OnDemandFingerprint.toErrorResult()
}
}

View file

@ -6,8 +6,6 @@ import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.removeInstruction
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve
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.Patch
import app.revanced.patches.spotify.premium_navbar_tab.annotations.PremiumNavbarTabCompatibility
@ -27,7 +25,7 @@ class PremiumNavbarTabPatch : BytecodePatch(
AddPremiumNavbarTabParentFingerprint
)
) {
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
val parentResult = AddPremiumNavbarTabParentFingerprint.result!!
AddPremiumNavbarTabFingerprint.resolve(context, parentResult.classDef)
@ -55,7 +53,5 @@ class PremiumNavbarTabPatch : BytecodePatch(
if (--removeAmount == 0) break
}
return PatchResultSuccess()
}
}

View file

@ -6,8 +6,6 @@ import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
import app.revanced.patcher.extensions.InstructionExtensions.removeInstructions
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.patches.ticktick.misc.themeunlock.annotations.UnlockThemesCompatibility
import app.revanced.patches.ticktick.misc.themeunlock.fingerprints.CheckLockedThemesFingerprint
@ -23,7 +21,7 @@ class UnlockProPatch : BytecodePatch(
SetThemeFingerprint
)
) {
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
val lockedThemesMethod = CheckLockedThemesFingerprint.result!!.mutableMethod
lockedThemesMethod.addInstructions(
0,
@ -35,7 +33,5 @@ class UnlockProPatch : BytecodePatch(
val setThemeMethod = SetThemeFingerprint.result!!.mutableMethod
setThemeMethod.removeInstructions(0, 10)
return PatchResultSuccess()
}
}

View file

@ -5,9 +5,7 @@ import app.revanced.patcher.annotation.Name
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultError
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.PatchException
import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.tiktok.ad.annotations.HideAdsCompatibility
import app.revanced.patches.tiktok.ad.fingerprints.ConvertHelpFeedItemListFingerprint
@ -27,7 +25,7 @@ class HideAdsPatch : BytecodePatch(
ConvertHelpFeedItemListFingerprint
)
) {
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
listOf(
FeedItemListCloneFingerprint,
ConvertHelpFeedItemListFingerprint
@ -48,8 +46,7 @@ class HideAdsPatch : BytecodePatch(
)
return@forEach
}
return PatchResultError("Can not find required instruction.")
throw PatchException("Can not find required instruction.")
}
return PatchResultSuccess()
}
}

View file

@ -5,8 +5,6 @@ import app.revanced.patcher.annotation.Name
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
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.Patch
import app.revanced.patches.tiktok.feedfilter.annotations.FeedFilterCompatibility
@ -28,7 +26,7 @@ class FeedFilterPatch : BytecodePatch(
SettingsStatusLoadFingerprint
)
) {
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
val method = FeedApiServiceLIZFingerprint.result!!.mutableMethod
for ((index, instruction) in method.implementation!!.instructions.withIndex()) {
if (instruction.opcode != Opcode.RETURN_OBJECT) continue
@ -44,6 +42,5 @@ class FeedFilterPatch : BytecodePatch(
0,
"invoke-static {}, Lapp/revanced/tiktok/settingsmenu/SettingsStatus;->enableFeedFilter()V"
)
return PatchResultSuccess()
}
}

View file

@ -3,16 +3,13 @@ package app.revanced.patches.tiktok.interaction.downloads.patch
import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name
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.addInstructions
import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels
import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction
import app.revanced.patcher.extensions.InstructionExtensions.replaceInstructions
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultError
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.PatchException
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
@ -43,7 +40,7 @@ class DownloadsPatch : BytecodePatch(
SettingsStatusLoadFingerprint
)
) {
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
val method1 = ACLCommonShareFingerprint.result!!.mutableMethod
method1.replaceInstructions(
0,
@ -89,7 +86,7 @@ class DownloadsPatch : BytecodePatch(
targetOffset = index + 1
break
}
if (targetOffset == -1) return PatchResultError("Can not find download path uri method.")
if (targetOffset == -1) throw PatchException("Can not find download path uri method.")
//Change videos' download path.
val downloadUriMethod = context
.toMethodWalker(DownloadPathParentFingerprint.result!!.method)
@ -125,6 +122,5 @@ class DownloadsPatch : BytecodePatch(
0,
"invoke-static {}, Lapp/revanced/tiktok/settingsmenu/SettingsStatus;->enableDownload()V"
)
return PatchResultSuccess()
}
}

View file

@ -6,8 +6,6 @@ import app.revanced.patcher.annotation.Name
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
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.patches.tiktok.interaction.seekbar.annotations.ShowSeekbarCompatibility
import app.revanced.patches.tiktok.interaction.seekbar.fingerprints.SetSeekBarShowTypeFingerprint
@ -23,7 +21,7 @@ class ShowSeekbarPatch : BytecodePatch(
ShouldShowSeekBarFingerprint,
)
) {
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
ShouldShowSeekBarFingerprint.result?.mutableMethod?.apply {
addInstructions(
0,
@ -42,8 +40,7 @@ class ShowSeekbarPatch : BytecodePatch(
const/16 v$typeRegister, 0x64
"""
)
} ?: return SetSeekBarShowTypeFingerprint.toErrorResult()
return PatchResultSuccess()
} ?: throw SetSeekBarShowTypeFingerprint.toErrorResult()
}
}

View file

@ -3,11 +3,8 @@ package app.revanced.patches.tiktok.interaction.speed.patch
import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.data.toMethodWalker
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
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.util.proxy.mutableTypes.MutableMethod
import app.revanced.patches.tiktok.interaction.speed.annotations.PlaybackSpeedCompatibility
@ -23,7 +20,7 @@ class PlaybackSpeedPatch : BytecodePatch(
SpeedControlParentFingerprint
)
) {
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
val parentMethod = SpeedControlParentFingerprint.result!!.mutableMethod
val parentMethodInstructions = parentMethod.implementation!!.instructions
for ((index, instruction) in parentMethodInstructions.withIndex()) {
@ -41,6 +38,5 @@ class PlaybackSpeedPatch : BytecodePatch(
)
break
}
return PatchResultSuccess()
}
}

View file

@ -5,8 +5,6 @@ import app.revanced.patcher.annotation.Name
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
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.patches.tiktok.misc.login.disablerequirement.annotations.DisableLoginRequirementCompatibility
import app.revanced.patches.tiktok.misc.login.disablerequirement.fingerprints.MandatoryLoginServiceFingerprint
@ -22,7 +20,7 @@ class DisableLoginRequirementPatch : BytecodePatch(
MandatoryLoginServiceFingerprint2
)
) {
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
listOf(
MandatoryLoginServiceFingerprint,
MandatoryLoginServiceFingerprint2
@ -36,6 +34,5 @@ class DisableLoginRequirementPatch : BytecodePatch(
"""
)
}
return PatchResultSuccess()
}
}

View file

@ -5,8 +5,6 @@ import app.revanced.patcher.annotation.Name
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
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.patches.tiktok.misc.login.fixgoogle.annotations.FixGoogleLoginCompatibility
import app.revanced.patches.tiktok.misc.login.fixgoogle.fingerprints.GoogleAuthAvailableFingerprint
@ -22,7 +20,7 @@ class FixGoogleLoginPatch : BytecodePatch(
GoogleAuthAvailableFingerprint
)
) {
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
listOf(
GoogleOneTapAuthAvailableFingerprint,
GoogleAuthAvailableFingerprint
@ -37,6 +35,5 @@ class FixGoogleLoginPatch : BytecodePatch(
)
}
}
return PatchResultSuccess()
}
}

View file

@ -8,8 +8,6 @@ import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
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.Patch
import app.revanced.patcher.util.smali.ExternalLabel
@ -33,12 +31,12 @@ class SettingsPatch : BytecodePatch(
SettingsEntryInfoFingerprint,
)
) {
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
// Find the class name of classes which construct a settings entry
val settingsButtonClass = SettingsEntryFingerprint.result?.classDef?.type?.toClassName()
?: return SettingsEntryFingerprint.toErrorResult()
?: throw SettingsEntryFingerprint.toErrorResult()
val settingsButtonInfoClass = SettingsEntryInfoFingerprint.result?.classDef?.type?.toClassName()
?: return SettingsEntryInfoFingerprint.toErrorResult()
?: throw SettingsEntryInfoFingerprint.toErrorResult()
// Create a settings entry for 'revanced settings' and add it to settings fragment
AddSettingsEntryFingerprint.result?.apply {
@ -66,7 +64,7 @@ class SettingsPatch : BytecodePatch(
"""
)
}
} ?: return AddSettingsEntryFingerprint.toErrorResult()
} ?: throw AddSettingsEntryFingerprint.toErrorResult()
// Initialize the settings menu once the replaced setting entry is clicked.
AdPersonalizationActivityOnCreateFingerprint.result?.mutableMethod?.apply {
@ -87,9 +85,7 @@ class SettingsPatch : BytecodePatch(
""",
ExternalLabel("notrevanced", getInstruction(initializeSettingsIndex))
)
} ?: return AdPersonalizationActivityOnCreateFingerprint.toErrorResult()
return PatchResultSuccess()
} ?: throw AdPersonalizationActivityOnCreateFingerprint.toErrorResult()
}
private fun String.toClassName(): String {

View file

@ -8,8 +8,6 @@ import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
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.Patch
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
@ -39,7 +37,7 @@ class SpoofSimPatch : BytecodePatch() {
)
}
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
// Find all api call to check sim information
buildMap {
context.classes.forEach { classDef ->
@ -89,8 +87,6 @@ class SpoofSimPatch : BytecodePatch() {
"invoke-static {}, Lapp/revanced/tiktok/settingsmenu/SettingsStatus;->enableSimSpoof()V"
)
}
return PatchResultSuccess()
}
// Patch Android API and return fake sim information

View file

@ -7,8 +7,6 @@ import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve
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.patches.trakt.annotations.UnlockProCompatibility
import app.revanced.patches.trakt.fingerprints.IsVIPEPFingerprint
@ -22,7 +20,7 @@ import app.revanced.patches.trakt.fingerprints.RemoteUserFingerprint
class UnlockProPatch : BytecodePatch(
listOf(RemoteUserFingerprint)
) {
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
RemoteUserFingerprint.result?.classDef?.let { remoteUserClass ->
arrayOf(IsVIPFingerprint, IsVIPEPFingerprint).onEach { fingerprint ->
// Resolve both fingerprints on the same class.
@ -31,11 +29,9 @@ class UnlockProPatch : BytecodePatch(
}.forEach { fingerprint ->
// Return true for both VIP check methods.
fingerprint.result?.mutableMethod?.addInstructions(0, RETURN_TRUE_INSTRUCTIONS)
?: return fingerprint.toErrorResult()
?: throw fingerprint.toErrorResult()
}
} ?: return RemoteUserFingerprint.toErrorResult()
return PatchResultSuccess()
} ?: throw RemoteUserFingerprint.toErrorResult()
}
private companion object {

View file

@ -6,8 +6,6 @@ import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
import app.revanced.patcher.extensions.InstructionExtensions.removeInstructions
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.patches.twelvewidgets.unlock.fingerprints.*
@ -25,7 +23,7 @@ class UnlockPaidWidgetsPatch : BytecodePatch(
WeatherWidgetUnlockFingerprint
)
) {
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
listOf(
AgendaDaysWidgetUnlockFingerprint,
CalendarBigWidgetUnlockFingerprint,
@ -34,7 +32,7 @@ class UnlockPaidWidgetsPatch : BytecodePatch(
ScreentimeSmallWidgetUnlockFingerprint,
WeatherWidgetUnlockFingerprint
).map { fingerprint ->
fingerprint.result?.mutableMethod ?: return fingerprint.toErrorResult()
fingerprint.result?.mutableMethod ?: throw fingerprint.toErrorResult()
}.forEach { method ->
method.apply {
removeInstructions(4, 3)
@ -48,7 +46,5 @@ class UnlockPaidWidgetsPatch : BytecodePatch(
)
}
}
return PatchResultSuccess()
}
}

View file

@ -6,8 +6,6 @@ import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
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.Patch
import app.revanced.patcher.util.smali.ExternalLabel
@ -26,7 +24,7 @@ import app.revanced.patches.twitch.misc.settings.bytecode.patch.SettingsPatch
class AudioAdsPatch : BytecodePatch(
listOf(AudioAdsPresenterPlayFingerprint)
) {
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
// Block playAds call
with(AudioAdsPresenterPlayFingerprint.result!!) {
mutableMethod.addInstructionsWithLabels(
@ -59,7 +57,5 @@ class AudioAdsPatch : BytecodePatch(
default = true,
)
)
return PatchResultSuccess()
}
}

View file

@ -6,9 +6,7 @@ import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.MethodFingerprintExtensions.name
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultError
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.PatchException
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.shared.settings.preference.impl.ArrayResource
@ -28,8 +26,8 @@ import app.revanced.patches.twitch.misc.settings.bytecode.patch.SettingsPatch
class EmbeddedAdsPatch : BytecodePatch(
listOf(CreateUsherClientFingerprint)
) {
override fun execute(context: BytecodeContext): PatchResult {
val result = CreateUsherClientFingerprint.result ?: return PatchResultError("${CreateUsherClientFingerprint.name} not found")
override fun execute(context: BytecodeContext) {
val result = CreateUsherClientFingerprint.result ?: throw PatchException("${CreateUsherClientFingerprint.name} not found")
// Inject OkHttp3 application interceptor
result.mutableMethod.addInstructions(
@ -70,7 +68,5 @@ class EmbeddedAdsPatch : BytecodePatch(
SettingsPatch.addString("revanced_embedded_ads_service_unavailable", "%s is unavailable. Ads may show. Try switching to another ad block service in settings.")
SettingsPatch.addString("revanced_embedded_ads_service_failed", "%s server returned an error. Ads may show. Try switching to another ad block service in settings.")
return PatchResultSuccess()
}
}

View file

@ -7,8 +7,6 @@ import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
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.Patch
import app.revanced.patcher.util.smali.ExternalLabel
@ -36,7 +34,7 @@ class VideoAdsPatch : AbstractAdPatch(
GetReadyToShowAdFingerprint
)
) {
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
/* Amazon ads SDK */
context.blockMethods(
"Lcom/amazon/ads/video/player/AdsManagerImpl;",
@ -97,7 +95,7 @@ class VideoAdsPatch : AbstractAdPatch(
""",
ExternalLabel(skipLabelName, mutableMethod.getInstruction(0))
)
} ?: return CheckAdEligibilityLambdaFingerprint.toErrorResult()
} ?: throw CheckAdEligibilityLambdaFingerprint.toErrorResult()
GetReadyToShowAdFingerprint.result?.apply {
val adFormatDeclined = "Ltv/twitch/android/shared/display/ads/theatre/StreamDisplayAdsPresenter\$Action\$AdFormatDeclined;"
@ -112,7 +110,7 @@ class VideoAdsPatch : AbstractAdPatch(
""",
ExternalLabel(skipLabelName, mutableMethod.getInstruction(0))
)
} ?: return GetReadyToShowAdFingerprint.toErrorResult()
} ?: throw GetReadyToShowAdFingerprint.toErrorResult()
// Spoof showAds JSON field
ContentConfigShowAdsFingerprint.result?.apply {
@ -123,7 +121,7 @@ class VideoAdsPatch : AbstractAdPatch(
return v0
"""
)
} ?: return ContentConfigShowAdsFingerprint.toErrorResult()
} ?: throw ContentConfigShowAdsFingerprint.toErrorResult()
SettingsPatch.PreferenceScreen.ADS.CLIENT_SIDE.addPreferences(
SwitchPreference(
@ -143,7 +141,5 @@ class VideoAdsPatch : AbstractAdPatch(
default = true
)
)
return PatchResultSuccess()
}
}

View file

@ -8,8 +8,6 @@ import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
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.Patch
import app.revanced.patcher.util.smali.ExternalLabel
@ -41,7 +39,7 @@ class ShowDeletedMessagesPatch : BytecodePatch(
if-eqz $register, :no_spoiler
"""
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
// Spoiler mode: Force set hasModAccess member to true in constructor
DeletedMessageClickableSpanCtorFingerprint.result?.mutableMethod?.apply {
addInstructionsWithLabels(
@ -53,11 +51,11 @@ class ShowDeletedMessagesPatch : BytecodePatch(
""",
ExternalLabel("no_spoiler", getInstruction(implementation!!.instructions.lastIndex))
)
} ?: return DeletedMessageClickableSpanCtorFingerprint.toErrorResult()
} ?: throw DeletedMessageClickableSpanCtorFingerprint.toErrorResult()
// Spoiler mode: Disable setHasModAccess setter
SetHasModAccessFingerprint.result?.mutableMethod?.addInstruction(0, "return-void")
?: return SetHasModAccessFingerprint.toErrorResult()
?: throw SetHasModAccessFingerprint.toErrorResult()
// Cross-out mode: Reformat span of deleted message
ChatUtilCreateDeletedSpanFingerprint.result?.mutableMethod?.apply {
@ -71,7 +69,7 @@ class ShowDeletedMessagesPatch : BytecodePatch(
""",
ExternalLabel("no_reformat", getInstruction(0))
)
} ?: return ChatUtilCreateDeletedSpanFingerprint.toErrorResult()
} ?: throw ChatUtilCreateDeletedSpanFingerprint.toErrorResult()
SettingsPatch.PreferenceScreen.CHAT.GENERAL.addPreferences(
ListPreference(
@ -101,7 +99,5 @@ class ShowDeletedMessagesPatch : BytecodePatch(
)
SettingsPatch.addString("revanced_deleted_msg", "message deleted")
return PatchResultSuccess()
}
}

View file

@ -7,8 +7,6 @@ import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
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.Patch
import app.revanced.patcher.util.smali.ExternalLabel
@ -26,7 +24,7 @@ import app.revanced.patches.twitch.misc.settings.bytecode.patch.SettingsPatch
class AutoClaimChannelPointPatch : BytecodePatch(
listOf(CommunityPointsButtonViewDelegateFingerprint)
) {
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
SettingsPatch.PreferenceScreen.CHAT.GENERAL.addPreferences(
SwitchPreference(
"revanced_auto_claim_channel_points",
@ -62,8 +60,6 @@ class AutoClaimChannelPointPatch : BytecodePatch(
""",
ExternalLabel("auto_claim", getInstruction(lastIndex))
)
} ?: return CommunityPointsButtonViewDelegateFingerprint.toErrorResult()
return PatchResultSuccess()
} ?: throw CommunityPointsButtonViewDelegateFingerprint.toErrorResult()
}
}

View file

@ -6,8 +6,6 @@ import app.revanced.patcher.annotation.Name
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
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.Patch
import app.revanced.patches.shared.settings.preference.impl.StringResource
@ -31,7 +29,7 @@ class DebugModePatch : BytecodePatch(
ShouldShowDebugOptionsFingerprint
)
) {
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
listOf(
IsDebugConfigEnabledFingerprint,
IsOmVerificationEnabledFingerprint,
@ -46,7 +44,7 @@ class DebugModePatch : BytecodePatch(
return v0
"""
)
} ?: return it.toErrorResult()
} ?: throw it.toErrorResult()
}
SettingsPatch.PreferenceScreen.MISC.OTHER.addPreferences(
@ -67,7 +65,5 @@ class DebugModePatch : BytecodePatch(
default = false,
)
)
return PatchResultSuccess()
}
}

View file

@ -10,8 +10,6 @@ import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.extensions.or
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprintResult
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.Patch
import app.revanced.patcher.util.proxy.mutableTypes.MutableField.Companion.toMutable
@ -43,7 +41,7 @@ class SettingsPatch : BytecodePatch(
MenuGroupsOnClickFingerprint
)
), Closeable {
override fun execute(context: BytecodeContext): PatchResult {
override fun execute(context: BytecodeContext) {
// Hook onCreate to handle fragment creation
SettingsActivityOnCreateFingerprint.result?.apply {
val insertIndex = mutableMethod.implementation!!.instructions.size - 2
@ -57,7 +55,7 @@ class SettingsPatch : BytecodePatch(
""",
ExternalLabel("no_rv_settings_init", mutableMethod.getInstruction(insertIndex))
)
} ?: return SettingsActivityOnCreateFingerprint.toErrorResult()
} ?: throw SettingsActivityOnCreateFingerprint.toErrorResult()
// Create new menu item for settings menu
SettingsMenuItemEnumFingerprint.result?.apply {
@ -67,7 +65,7 @@ class SettingsPatch : BytecodePatch(
REVANCED_SETTINGS_MENU_ITEM_TITLE_RES,
REVANCED_SETTINGS_MENU_ITEM_ICON_RES
)
} ?: return SettingsMenuItemEnumFingerprint.toErrorResult()
} ?: throw SettingsMenuItemEnumFingerprint.toErrorResult()
// Intercept settings menu creation and add new menu item
MenuGroupsUpdatedFingerprint.result?.apply {
@ -79,7 +77,7 @@ class SettingsPatch : BytecodePatch(
move-result-object p1
"""
)
} ?: return MenuGroupsUpdatedFingerprint.toErrorResult()
} ?: throw MenuGroupsUpdatedFingerprint.toErrorResult()
// Intercept onclick events for the settings menu
MenuGroupsOnClickFingerprint.result?.apply {
@ -96,14 +94,12 @@ class SettingsPatch : BytecodePatch(
""",
ExternalLabel("no_rv_settings_onclick", mutableMethod.getInstruction(insertIndex))
)
} ?: return MenuGroupsOnClickFingerprint.toErrorResult()
} ?: throw MenuGroupsOnClickFingerprint.toErrorResult()
addString("revanced_settings", "ReVanced Settings", false)
addString("revanced_reboot_message", "Twitch needs to restart to apply your changes. Restart now?", false)
addString("revanced_reboot", "Restart", false)
addString("revanced_cancel", "Cancel", false)
return PatchResultSuccess()
}
internal companion object {

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