diff --git a/src/main/kotlin/app/revanced/extensions/Extensions.kt b/src/main/kotlin/app/revanced/extensions/Extensions.kt index 649cf6c287..226f4b143d 100644 --- a/src/main/kotlin/app/revanced/extensions/Extensions.kt +++ b/src/main/kotlin/app/revanced/extensions/Extensions.kt @@ -15,11 +15,12 @@ import com.android.tools.smali.dexlib2.util.MethodUtil import org.w3c.dom.Node /** - * Return [PatchException] from a [MethodFingerprint]. + * The [PatchException] of failing to resolve a [MethodFingerprint]. * - * @return The [PatchException] for the [MethodFingerprint]. + * @return The [PatchException]. */ -internal fun MethodFingerprint.toErrorResult() = PatchException("Failed to resolve $name") +val MethodFingerprint.exception + get() = PatchException("Failed to resolve $name") /** * Find the [MutableMethod] from a given [Method] in a [MutableClass]. @@ -27,27 +28,27 @@ internal fun MethodFingerprint.toErrorResult() = PatchException("Failed to resol * @param method The [Method] to find. * @return The [MutableMethod]. */ -internal fun MutableClass.findMutableMethodOf(method: Method) = this.methods.first { +fun MutableClass.findMutableMethodOf(method: Method) = this.methods.first { MethodUtil.methodSignaturesMatch(it, method) } /** - * apply a transform to all methods of the class + * apply a transform to all methods of the class. * - * @param transform the transformation function. original method goes in, transformed method goes out + * @param transform the transformation function. original method goes in, transformed method goes out. */ -internal fun MutableClass.transformMethods(transform: MutableMethod.() -> MutableMethod) { +fun MutableClass.transformMethods(transform: MutableMethod.() -> MutableMethod) { val transformedMethods = methods.map { it.transform() } methods.clear() methods.addAll(transformedMethods) } -internal fun Node.doRecursively(action: (Node) -> Unit) { +fun Node.doRecursively(action: (Node) -> Unit) { action(this) for (i in 0 until this.childNodes.length) this.childNodes.item(i).doRecursively(action) } -internal fun MutableMethod.injectHideViewCall( +fun MutableMethod.injectHideViewCall( insertIndex: Int, viewRegister: Int, classDescriptor: String, @@ -57,7 +58,13 @@ internal fun MutableMethod.injectHideViewCall( "invoke-static { v$viewRegister }, $classDescriptor->$targetMethod(Landroid/view/View;)V" ) -internal fun Method.findIndexForIdResource(resourceName: String): Int { +/** + * Find the index of the first constant instruction with the id of the given resource name. + * + * @param resourceName the name of the resource to find the id for. + * @return the index of the first constant instruction with the id of the given resource name, or -1 if not found. + */ +fun Method.findIndexForIdResource(resourceName: String): Int { fun getIdResourceId(resourceName: String) = ResourceMappingPatch.resourceMappings.single { it.type == "id" && it.name == resourceName }.id @@ -66,6 +73,8 @@ internal fun Method.findIndexForIdResource(resourceName: String): Int { } /** + * Find the index of the first constant instruction with the given value. + * * @return the first constant instruction with the value, or -1 if not found. */ fun Method.indexOfFirstConstantInstructionValue(constantValue: Long): Int { @@ -77,6 +86,8 @@ fun Method.indexOfFirstConstantInstructionValue(constantValue: Long): Int { } /** + * Check if the method contains a constant with the given value. + * * @return if the method contains a constant with the given value. */ fun Method.containsConstantInstructionValue(constantValue: Long): Boolean { @@ -84,10 +95,10 @@ fun Method.containsConstantInstructionValue(constantValue: Long): Boolean { } /** - * traverse the class hierarchy starting from the given root class + * 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 + * @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) diff --git a/src/main/kotlin/app/revanced/patches/backdrops/misc/pro/patch/ProUnlockPatch.kt b/src/main/kotlin/app/revanced/patches/backdrops/misc/pro/patch/ProUnlockPatch.kt index b5ed2aae09..2c5d8ed5ce 100644 --- a/src/main/kotlin/app/revanced/patches/backdrops/misc/pro/patch/ProUnlockPatch.kt +++ b/src/main/kotlin/app/revanced/patches/backdrops/misc/pro/patch/ProUnlockPatch.kt @@ -1,6 +1,6 @@ package app.revanced.patches.backdrops.misc.pro.patch -import app.revanced.extensions.toErrorResult +import app.revanced.extensions.exception import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.data.BytecodeContext @@ -33,6 +33,6 @@ class ProUnlockPatch : BytecodePatch( ) } - } ?: throw ProUnlockFingerprint.toErrorResult() + } ?: throw ProUnlockFingerprint.exception } } \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/candylinkvpn/patch/UnlockProPatch.kt b/src/main/kotlin/app/revanced/patches/candylinkvpn/patch/UnlockProPatch.kt index 8c7713bf83..c1eb4b7f6f 100644 --- a/src/main/kotlin/app/revanced/patches/candylinkvpn/patch/UnlockProPatch.kt +++ b/src/main/kotlin/app/revanced/patches/candylinkvpn/patch/UnlockProPatch.kt @@ -1,6 +1,6 @@ package app.revanced.patches.candylinkvpn.patch -import app.revanced.extensions.toErrorResult +import app.revanced.extensions.exception import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.data.BytecodeContext @@ -24,6 +24,6 @@ class UnlockProPatch : BytecodePatch( const/4 v0, 0x1 return v0 """ - ) ?: throw IsPremiumPurchasedFingerprint.toErrorResult() + ) ?: throw IsPremiumPurchasedFingerprint.exception } } \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/duolingo/unlocksuper/patch/UnlockDuolingoSuperPatch.kt b/src/main/kotlin/app/revanced/patches/duolingo/unlocksuper/patch/UnlockDuolingoSuperPatch.kt index 86d2ecbc78..c02228f2b1 100644 --- a/src/main/kotlin/app/revanced/patches/duolingo/unlocksuper/patch/UnlockDuolingoSuperPatch.kt +++ b/src/main/kotlin/app/revanced/patches/duolingo/unlocksuper/patch/UnlockDuolingoSuperPatch.kt @@ -1,6 +1,6 @@ package app.revanced.patches.duolingo.unlocksuper.patch -import app.revanced.extensions.toErrorResult +import app.revanced.extensions.exception import app.revanced.patcher.annotation.Compatibility import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name @@ -38,7 +38,7 @@ class UnlockDuolingoSuperPatch : BytecodePatch( ?.filterIsInstance() ?.firstOrNull { it.opcode == Opcode.IGET_BOOLEAN } ?.reference - ?: throw IsUserSuperMethodFingerprint.toErrorResult() + ?: throw IsUserSuperMethodFingerprint.exception // Patch the instruction that assigns isUserSuper to true. UserSerializationMethodFingerprint @@ -50,7 +50,7 @@ class UnlockDuolingoSuperPatch : BytecodePatch( "const/4 v2, 0x1" ) } - ?: throw UserSerializationMethodFingerprint.toErrorResult() + ?: throw UserSerializationMethodFingerprint.exception } private companion object { diff --git a/src/main/kotlin/app/revanced/patches/finanzonline/detection/bootloader/patch/BootloaderDetectionPatch.kt b/src/main/kotlin/app/revanced/patches/finanzonline/detection/bootloader/patch/BootloaderDetectionPatch.kt index d2e9231fef..6864d96355 100644 --- a/src/main/kotlin/app/revanced/patches/finanzonline/detection/bootloader/patch/BootloaderDetectionPatch.kt +++ b/src/main/kotlin/app/revanced/patches/finanzonline/detection/bootloader/patch/BootloaderDetectionPatch.kt @@ -1,6 +1,6 @@ package app.revanced.patches.finanzonline.detection.bootloader.patch -import app.revanced.extensions.toErrorResult +import app.revanced.extensions.exception import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.data.BytecodeContext @@ -27,7 +27,7 @@ class BootloaderDetectionPatch : BytecodePatch( const/4 v0, 0x1 return v0 """ - ) ?: throw fingerprint.toErrorResult() + ) ?: throw fingerprint.exception } } } diff --git a/src/main/kotlin/app/revanced/patches/finanzonline/detection/root/patch/RootDetectionPatch.kt b/src/main/kotlin/app/revanced/patches/finanzonline/detection/root/patch/RootDetectionPatch.kt index 820b309b33..35ebdfe323 100644 --- a/src/main/kotlin/app/revanced/patches/finanzonline/detection/root/patch/RootDetectionPatch.kt +++ b/src/main/kotlin/app/revanced/patches/finanzonline/detection/root/patch/RootDetectionPatch.kt @@ -1,6 +1,6 @@ package app.revanced.patches.finanzonline.detection.root.patch -import app.revanced.extensions.toErrorResult +import app.revanced.extensions.exception import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.data.BytecodeContext @@ -24,6 +24,6 @@ class RootDetectionPatch : BytecodePatch( sget-object v0, Ljava/lang/Boolean;->FALSE:Ljava/lang/Boolean; return-object v0 """ - ) ?: throw RootDetectionFingerprint.toErrorResult() + ) ?: throw RootDetectionFingerprint.exception } } diff --git a/src/main/kotlin/app/revanced/patches/googlerecorder/restrictions/patch/RemoveDeviceRestrictions.kt b/src/main/kotlin/app/revanced/patches/googlerecorder/restrictions/patch/RemoveDeviceRestrictions.kt index a051958831..f505efbac1 100644 --- a/src/main/kotlin/app/revanced/patches/googlerecorder/restrictions/patch/RemoveDeviceRestrictions.kt +++ b/src/main/kotlin/app/revanced/patches/googlerecorder/restrictions/patch/RemoveDeviceRestrictions.kt @@ -1,6 +1,6 @@ package app.revanced.patches.googlerecorder.restrictions.patch -import app.revanced.extensions.toErrorResult +import app.revanced.extensions.exception import app.revanced.patcher.annotation.Compatibility import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name @@ -34,6 +34,6 @@ class RemoveDeviceRestrictions : BytecodePatch( // Override "isPixelDevice()" to return true. addInstruction(featureStringIndex, "const/4 v$featureAvailableRegister, 0x1") } - } ?: throw OnApplicationCreateFingerprint.toErrorResult() + } ?: throw OnApplicationCreateFingerprint.exception } } diff --git a/src/main/kotlin/app/revanced/patches/inshorts/ad/patch/InshortsAdsPatch.kt b/src/main/kotlin/app/revanced/patches/inshorts/ad/patch/InshortsAdsPatch.kt index ef882c63a5..8b48bcd415 100644 --- a/src/main/kotlin/app/revanced/patches/inshorts/ad/patch/InshortsAdsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/inshorts/ad/patch/InshortsAdsPatch.kt @@ -1,6 +1,6 @@ package app.revanced.patches.inshorts.ad.patch -import app.revanced.extensions.toErrorResult +import app.revanced.extensions.exception import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name @@ -27,6 +27,6 @@ class HideAdsPatch : BytecodePatch( """ ) } - } ?: throw InshortsAdsFingerprint.toErrorResult() + } ?: throw InshortsAdsFingerprint.exception } } diff --git a/src/main/kotlin/app/revanced/patches/instagram/patches/ads/timeline/patch/HideTimelineAdsPatch.kt b/src/main/kotlin/app/revanced/patches/instagram/patches/ads/timeline/patch/HideTimelineAdsPatch.kt index 79a1ba508c..a8b2cc699a 100644 --- a/src/main/kotlin/app/revanced/patches/instagram/patches/ads/timeline/patch/HideTimelineAdsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/instagram/patches/ads/timeline/patch/HideTimelineAdsPatch.kt @@ -1,6 +1,6 @@ package app.revanced.patches.instagram.patches.ads.timeline.patch -import app.revanced.extensions.toErrorResult +import app.revanced.extensions.exception import app.revanced.patcher.annotation.* import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels @@ -33,16 +33,16 @@ class HideTimelineAdsPatch : BytecodePatch( override fun execute(context: BytecodeContext) { // region Resolve required methods to check for ads. - ShowAdFingerprint.result ?: throw ShowAdFingerprint.toErrorResult() + ShowAdFingerprint.result ?: throw ShowAdFingerprint.exception - PaidPartnershipAdFingerprint.result ?: throw PaidPartnershipAdFingerprint.toErrorResult() + PaidPartnershipAdFingerprint.result ?: throw PaidPartnershipAdFingerprint.exception MediaFingerprint.result?.let { GenericMediaAdFingerprint.resolve(context, it.classDef) ShoppingAdFingerprint.resolve(context, it.classDef) return@let - } ?: throw MediaFingerprint.toErrorResult() + } ?: throw MediaFingerprint.exception // endregion diff --git a/src/main/kotlin/app/revanced/patches/lightroom/misc/login/patch/DisableMandatoryLoginPatch.kt b/src/main/kotlin/app/revanced/patches/lightroom/misc/login/patch/DisableMandatoryLoginPatch.kt index 6759a2093d..b1317bb071 100644 --- a/src/main/kotlin/app/revanced/patches/lightroom/misc/login/patch/DisableMandatoryLoginPatch.kt +++ b/src/main/kotlin/app/revanced/patches/lightroom/misc/login/patch/DisableMandatoryLoginPatch.kt @@ -1,6 +1,6 @@ package app.revanced.patches.lightroom.misc.login.patch -import app.revanced.extensions.toErrorResult +import app.revanced.extensions.exception import app.revanced.patcher.annotation.Name import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction @@ -18,6 +18,6 @@ class DisableMandatoryLoginPatch : BytecodePatch(listOf(IsLoggedInFingerprint)) val index = implementation!!.instructions.lastIndex - 1 // Set isLoggedIn = true. replaceInstruction(index, "const/4 v0, 0x1") - } ?: throw IsLoggedInFingerprint.toErrorResult() + } ?: throw IsLoggedInFingerprint.exception } } \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/lightroom/misc/premium/patch/UnlockPremiumPatch.kt b/src/main/kotlin/app/revanced/patches/lightroom/misc/premium/patch/UnlockPremiumPatch.kt index f854f726f0..f71cc2a95b 100644 --- a/src/main/kotlin/app/revanced/patches/lightroom/misc/premium/patch/UnlockPremiumPatch.kt +++ b/src/main/kotlin/app/revanced/patches/lightroom/misc/premium/patch/UnlockPremiumPatch.kt @@ -1,6 +1,6 @@ package app.revanced.patches.lightroom.misc.premium.patch -import app.revanced.extensions.toErrorResult +import app.revanced.extensions.exception import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.data.BytecodeContext @@ -18,6 +18,6 @@ class UnlockPremiumPatch : BytecodePatch(listOf(HasPurchasedFingerprint)) { override fun execute(context: BytecodeContext) { // Set hasPremium = true. HasPurchasedFingerprint.result?.mutableMethod?.replaceInstruction(2, "const/4 v2, 0x1") - ?: throw HasPurchasedFingerprint.toErrorResult() + ?: throw HasPurchasedFingerprint.exception } } \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/memegenerator/detection/license/patch/LicenseValidationPatch.kt b/src/main/kotlin/app/revanced/patches/memegenerator/detection/license/patch/LicenseValidationPatch.kt index 21b0211be5..337d3e171e 100644 --- a/src/main/kotlin/app/revanced/patches/memegenerator/detection/license/patch/LicenseValidationPatch.kt +++ b/src/main/kotlin/app/revanced/patches/memegenerator/detection/license/patch/LicenseValidationPatch.kt @@ -1,6 +1,6 @@ package app.revanced.patches.memegenerator.detection.license.patch -import app.revanced.extensions.toErrorResult +import app.revanced.extensions.exception import app.revanced.patcher.annotation.Description import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.InstructionExtensions.replaceInstructions @@ -20,6 +20,6 @@ class LicenseValidationPatch : BytecodePatch( return p0 """ ) - } ?: throw LicenseValidationFingerprint.toErrorResult() + } ?: throw LicenseValidationFingerprint.exception } } \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/memegenerator/detection/signature/patch/SignatureVerificationPatch.kt b/src/main/kotlin/app/revanced/patches/memegenerator/detection/signature/patch/SignatureVerificationPatch.kt index 2a74d0a112..47b056daf5 100644 --- a/src/main/kotlin/app/revanced/patches/memegenerator/detection/signature/patch/SignatureVerificationPatch.kt +++ b/src/main/kotlin/app/revanced/patches/memegenerator/detection/signature/patch/SignatureVerificationPatch.kt @@ -1,6 +1,6 @@ package app.revanced.patches.memegenerator.detection.signature.patch -import app.revanced.extensions.toErrorResult +import app.revanced.extensions.exception import app.revanced.patcher.annotation.Description import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.InstructionExtensions.replaceInstructions @@ -20,6 +20,6 @@ class SignatureVerificationPatch : BytecodePatch( return p0 """ ) - } ?: throw VerifySignatureFingerprint.toErrorResult() + } ?: throw VerifySignatureFingerprint.exception } } \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/memegenerator/misc/pro/patch/UnlockProVersionPatch.kt b/src/main/kotlin/app/revanced/patches/memegenerator/misc/pro/patch/UnlockProVersionPatch.kt index e89a1063a6..601e78b240 100644 --- a/src/main/kotlin/app/revanced/patches/memegenerator/misc/pro/patch/UnlockProVersionPatch.kt +++ b/src/main/kotlin/app/revanced/patches/memegenerator/misc/pro/patch/UnlockProVersionPatch.kt @@ -1,6 +1,6 @@ package app.revanced.patches.memegenerator.misc.pro.patch -import app.revanced.extensions.toErrorResult +import app.revanced.extensions.exception import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.data.BytecodeContext @@ -34,6 +34,6 @@ class UnlockProVersionPatch : BytecodePatch( return-object p0 """ ) - } ?: throw IsFreeVersionFingerprint.toErrorResult() + } ?: throw IsFreeVersionFingerprint.exception } } \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/messenger/ads/inbox/patch/HideInboxAdsPatch.kt b/src/main/kotlin/app/revanced/patches/messenger/ads/inbox/patch/HideInboxAdsPatch.kt index 0d90a50ff4..6101f4e6f5 100644 --- a/src/main/kotlin/app/revanced/patches/messenger/ads/inbox/patch/HideInboxAdsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/messenger/ads/inbox/patch/HideInboxAdsPatch.kt @@ -1,6 +1,6 @@ package app.revanced.patches.messenger.ads.inbox.patch -import app.revanced.extensions.toErrorResult +import app.revanced.extensions.exception import app.revanced.patcher.annotation.* import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction @@ -18,7 +18,7 @@ class HideInboxAdsPatch : BytecodePatch( override fun execute(context: BytecodeContext) { LoadInboxAdsFingerprint.result?.mutableMethod?.apply { this.replaceInstruction(0, "return-void") - } ?: throw LoadInboxAdsFingerprint.toErrorResult() + } ?: throw LoadInboxAdsFingerprint.exception } } diff --git a/src/main/kotlin/app/revanced/patches/messenger/inputfield/patch/DisableSwitchingEmojiToStickerInMessageInputField.kt b/src/main/kotlin/app/revanced/patches/messenger/inputfield/patch/DisableSwitchingEmojiToStickerInMessageInputField.kt index 8912c6a473..dee26e289b 100644 --- a/src/main/kotlin/app/revanced/patches/messenger/inputfield/patch/DisableSwitchingEmojiToStickerInMessageInputField.kt +++ b/src/main/kotlin/app/revanced/patches/messenger/inputfield/patch/DisableSwitchingEmojiToStickerInMessageInputField.kt @@ -1,6 +1,6 @@ package app.revanced.patches.messenger.inputfield.patch -import app.revanced.extensions.toErrorResult +import app.revanced.extensions.exception import app.revanced.patcher.annotation.* import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.InstructionExtensions.getInstruction @@ -27,6 +27,6 @@ class DisableSwitchingEmojiToStickerInMessageInputField : BytecodePatch(listOf(S "const-string v$targetRegister, \"expression\"" ) } - } ?: throw SwitchMessangeInputEmojiButtonFingerprint.toErrorResult() + } ?: throw SwitchMessangeInputEmojiButtonFingerprint.exception } } diff --git a/src/main/kotlin/app/revanced/patches/messenger/inputfield/patch/DisableTypingIndicator.kt b/src/main/kotlin/app/revanced/patches/messenger/inputfield/patch/DisableTypingIndicator.kt index 680f38d34a..cfd852dad5 100644 --- a/src/main/kotlin/app/revanced/patches/messenger/inputfield/patch/DisableTypingIndicator.kt +++ b/src/main/kotlin/app/revanced/patches/messenger/inputfield/patch/DisableTypingIndicator.kt @@ -1,6 +1,6 @@ package app.revanced.patches.messenger.inputfield.patch -import app.revanced.extensions.toErrorResult +import app.revanced.extensions.exception import app.revanced.patcher.annotation.Compatibility import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name @@ -18,6 +18,6 @@ import app.revanced.patches.messenger.inputfield.fingerprints.SendTypingIndicato class DisableTypingIndicator : BytecodePatch(listOf(SendTypingIndicatorFingerprint)) { override fun execute(context: BytecodeContext) { SendTypingIndicatorFingerprint.result?.mutableMethod?.replaceInstruction(0, "return-void") - ?: throw SendTypingIndicatorFingerprint.toErrorResult() + ?: throw SendTypingIndicatorFingerprint.exception } } diff --git a/src/main/kotlin/app/revanced/patches/music/interaction/permanentrepeat/patch/PermanentRepeatPatch.kt b/src/main/kotlin/app/revanced/patches/music/interaction/permanentrepeat/patch/PermanentRepeatPatch.kt index 3dfc1102a9..bba4649c71 100644 --- a/src/main/kotlin/app/revanced/patches/music/interaction/permanentrepeat/patch/PermanentRepeatPatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/interaction/permanentrepeat/patch/PermanentRepeatPatch.kt @@ -1,6 +1,6 @@ package app.revanced.patches.music.interaction.permanentrepeat.patch -import app.revanced.extensions.toErrorResult +import app.revanced.extensions.exception import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.data.BytecodeContext @@ -31,6 +31,6 @@ class PermanentRepeatPatch : BytecodePatch( ExternalLabel("repeat", getInstruction(repeatIndex)) ) } - } ?: throw RepeatTrackFingerprint.toErrorResult() + } ?: throw RepeatTrackFingerprint.exception } } diff --git a/src/main/kotlin/app/revanced/patches/music/interaction/permanentshuffle/patch/PermanentShufflePatch.kt b/src/main/kotlin/app/revanced/patches/music/interaction/permanentshuffle/patch/PermanentShufflePatch.kt index 6a15edba8b..3bb5fde34a 100644 --- a/src/main/kotlin/app/revanced/patches/music/interaction/permanentshuffle/patch/PermanentShufflePatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/interaction/permanentshuffle/patch/PermanentShufflePatch.kt @@ -1,6 +1,6 @@ package app.revanced.patches.music.interaction.permanentshuffle.patch -import app.revanced.extensions.toErrorResult +import app.revanced.extensions.exception import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.data.BytecodeContext @@ -20,6 +20,6 @@ class PermanentShuffleTogglePatch : BytecodePatch( ) { override fun execute(context: BytecodeContext) { DisableShuffleFingerprint.result?.mutableMethod?.addInstruction(0, "return-void") - ?: throw DisableShuffleFingerprint.toErrorResult() + ?: throw DisableShuffleFingerprint.exception } } diff --git a/src/main/kotlin/app/revanced/patches/music/misc/androidauto/patch/BypassCertificateChecksPatch.kt b/src/main/kotlin/app/revanced/patches/music/misc/androidauto/patch/BypassCertificateChecksPatch.kt index 20f0481796..aaf43598da 100644 --- a/src/main/kotlin/app/revanced/patches/music/misc/androidauto/patch/BypassCertificateChecksPatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/misc/androidauto/patch/BypassCertificateChecksPatch.kt @@ -1,6 +1,6 @@ package app.revanced.patches.music.misc.androidauto.patch -import app.revanced.extensions.toErrorResult +import app.revanced.extensions.exception import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.data.BytecodeContext @@ -25,6 +25,6 @@ class BypassCertificateChecksPatch : BytecodePatch( return v0 """ ) - } ?: throw CheckCertificateFingerprint.toErrorResult() + } ?: throw CheckCertificateFingerprint.exception } } diff --git a/src/main/kotlin/app/revanced/patches/nfctoolsse/misc/pro/patch/UnlockProPatch.kt b/src/main/kotlin/app/revanced/patches/nfctoolsse/misc/pro/patch/UnlockProPatch.kt index 210ec7adf7..ce45d1d372 100644 --- a/src/main/kotlin/app/revanced/patches/nfctoolsse/misc/pro/patch/UnlockProPatch.kt +++ b/src/main/kotlin/app/revanced/patches/nfctoolsse/misc/pro/patch/UnlockProPatch.kt @@ -1,6 +1,6 @@ package app.revanced.patches.nfctoolsse.misc.pro.patch -import app.revanced.extensions.toErrorResult +import app.revanced.extensions.exception import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.data.BytecodeContext @@ -29,7 +29,7 @@ class UnlockProPatch : BytecodePatch( return v0 """ ) - } ?: throw IsLicenseRegisteredFingerprint.toErrorResult() + } ?: throw IsLicenseRegisteredFingerprint.exception } } \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/photomath/detection/signature/patch/SignatureDetectionPatch.kt b/src/main/kotlin/app/revanced/patches/photomath/detection/signature/patch/SignatureDetectionPatch.kt index 9e8e08ef0e..f6bc11609f 100644 --- a/src/main/kotlin/app/revanced/patches/photomath/detection/signature/patch/SignatureDetectionPatch.kt +++ b/src/main/kotlin/app/revanced/patches/photomath/detection/signature/patch/SignatureDetectionPatch.kt @@ -1,6 +1,6 @@ package app.revanced.patches.photomath.detection.signature.patch -import app.revanced.extensions.toErrorResult +import app.revanced.extensions.exception import app.revanced.patcher.annotation.Description import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.InstructionExtensions.getInstruction @@ -21,7 +21,7 @@ class SignatureDetectionPatch : BytecodePatch( val checkRegister = (signatureCheckInstruction as OneRegisterInstruction).registerA mutableMethod.replaceInstruction(signatureCheckInstruction.location.index, "const/4 v$checkRegister, 0x1") - } ?: throw CheckSignatureFingerprint.toErrorResult() + } ?: throw CheckSignatureFingerprint.exception } } diff --git a/src/main/kotlin/app/revanced/patches/photomath/misc/unlockplus/patch/UnlockPlusPatch.kt b/src/main/kotlin/app/revanced/patches/photomath/misc/unlockplus/patch/UnlockPlusPatch.kt index 893e9476ae..6d76eb0ed2 100644 --- a/src/main/kotlin/app/revanced/patches/photomath/misc/unlockplus/patch/UnlockPlusPatch.kt +++ b/src/main/kotlin/app/revanced/patches/photomath/misc/unlockplus/patch/UnlockPlusPatch.kt @@ -1,6 +1,6 @@ package app.revanced.patches.photomath.misc.unlockplus.patch -import app.revanced.extensions.toErrorResult +import app.revanced.extensions.exception import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.data.BytecodeContext @@ -31,7 +31,7 @@ class UnlockPlusPatch : BytecodePatch( return v0 """ ) - } ?: throw IsPlusUnlockedFingerprint.toErrorResult() + } ?: throw IsPlusUnlockedFingerprint.exception } } \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/pixiv/ads/patch/HideAdsPatch.kt b/src/main/kotlin/app/revanced/patches/pixiv/ads/patch/HideAdsPatch.kt index 66d797f1f4..df9d3591f5 100644 --- a/src/main/kotlin/app/revanced/patches/pixiv/ads/patch/HideAdsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/pixiv/ads/patch/HideAdsPatch.kt @@ -1,6 +1,6 @@ package app.revanced.patches.pixiv.ads.patch -import app.revanced.extensions.toErrorResult +import app.revanced.extensions.exception import app.revanced.patcher.annotation.* import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.InstructionExtensions.addInstructions @@ -23,6 +23,6 @@ class HideAdsPatch : BytecodePatch(listOf(IsNotPremiumFingerprint)) { const/4 v0, 0x0 return v0 """ - ) ?: throw IsNotPremiumFingerprint.toErrorResult() + ) ?: throw IsNotPremiumFingerprint.exception } } \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/reddit/customclients/AbstractSpoofClientPatch.kt b/src/main/kotlin/app/revanced/patches/reddit/customclients/AbstractSpoofClientPatch.kt index eb976004d5..3121dcb132 100644 --- a/src/main/kotlin/app/revanced/patches/reddit/customclients/AbstractSpoofClientPatch.kt +++ b/src/main/kotlin/app/revanced/patches/reddit/customclients/AbstractSpoofClientPatch.kt @@ -1,7 +1,7 @@ package app.revanced.patches.reddit.customclients import android.os.Environment -import app.revanced.extensions.toErrorResult +import app.revanced.extensions.exception import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patcher.fingerprint.method.impl.MethodFingerprintResult @@ -47,7 +47,7 @@ abstract class AbstractSpoofClientPatch( fun List?.executePatch( patch: List.(BytecodeContext) -> Unit - ) = this?.map { it.result ?: throw it.toErrorResult() }?.patch(context) + ) = this?.map { it.result ?: throw it.exception }?.patch(context) clientIdFingerprints.executePatch { patchClientId(context) } userAgentFingerprints.executePatch { patchUserAgent(context) } diff --git a/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/ads/patch/DisableAdsPatch.kt b/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/ads/patch/DisableAdsPatch.kt index 46735d2030..ca3de93e2e 100644 --- a/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/ads/patch/DisableAdsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/ads/patch/DisableAdsPatch.kt @@ -1,6 +1,6 @@ package app.revanced.patches.reddit.customclients.joeyforreddit.ads.patch -import app.revanced.extensions.toErrorResult +import app.revanced.extensions.exception import app.revanced.patcher.annotation.Compatibility import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Package @@ -24,6 +24,6 @@ class DisableAdsPatch : BytecodePatch(listOf(IsAdFreeUserFingerprint)) { const/4 v0, 0x1 return v0 """ - ) ?: throw IsAdFreeUserFingerprint.toErrorResult() + ) ?: throw IsAdFreeUserFingerprint.exception } } \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/detection/piracy/patch/DisablePiracyDetectionPatch.kt b/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/detection/piracy/patch/DisablePiracyDetectionPatch.kt index 3af32e15f4..360fa7d792 100644 --- a/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/detection/piracy/patch/DisablePiracyDetectionPatch.kt +++ b/src/main/kotlin/app/revanced/patches/reddit/customclients/joeyforreddit/detection/piracy/patch/DisablePiracyDetectionPatch.kt @@ -1,6 +1,6 @@ package app.revanced.patches.reddit.customclients.joeyforreddit.detection.piracy.patch -import app.revanced.extensions.toErrorResult +import app.revanced.extensions.exception import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.InstructionExtensions.addInstruction import app.revanced.patcher.patch.BytecodePatch @@ -13,6 +13,6 @@ class DisablePiracyDetectionPatch : BytecodePatch(listOf(PiracyDetectionFingerpr """ return-void """ - ) ?: throw PiracyDetectionFingerprint.toErrorResult() + ) ?: throw PiracyDetectionFingerprint.exception } } \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/reddit/customclients/syncforreddit/ads/patch/DisableAdsPatch.kt b/src/main/kotlin/app/revanced/patches/reddit/customclients/syncforreddit/ads/patch/DisableAdsPatch.kt index edc876f4e3..91460a4200 100644 --- a/src/main/kotlin/app/revanced/patches/reddit/customclients/syncforreddit/ads/patch/DisableAdsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/reddit/customclients/syncforreddit/ads/patch/DisableAdsPatch.kt @@ -1,6 +1,6 @@ package app.revanced.patches.reddit.customclients.syncforreddit.ads.patch -import app.revanced.extensions.toErrorResult +import app.revanced.extensions.exception import app.revanced.patcher.annotation.* import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.InstructionExtensions.addInstructions @@ -24,7 +24,7 @@ class DisableAdsPatch : BytecodePatch(listOf(IsAdsEnabledFingerprint)) { return v0 """ ) - } ?: throw IsAdsEnabledFingerprint.toErrorResult() + } ?: throw IsAdsEnabledFingerprint.exception } } \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/reddit/customclients/syncforreddit/api/patch/SpoofClientPatch.kt b/src/main/kotlin/app/revanced/patches/reddit/customclients/syncforreddit/api/patch/SpoofClientPatch.kt index 7ed9dbb55c..7c329de376 100644 --- a/src/main/kotlin/app/revanced/patches/reddit/customclients/syncforreddit/api/patch/SpoofClientPatch.kt +++ b/src/main/kotlin/app/revanced/patches/reddit/customclients/syncforreddit/api/patch/SpoofClientPatch.kt @@ -1,6 +1,6 @@ package app.revanced.patches.reddit.customclients.syncforreddit.api.patch -import app.revanced.extensions.toErrorResult +import app.revanced.extensions.exception import app.revanced.patcher.annotation.Compatibility import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Package @@ -48,7 +48,7 @@ class SpoofClientPatch : AbstractSpoofClientPatch( return-object v0 """ ) - } ?: throw GetBearerTokenFingerprint.toErrorResult() + } ?: throw GetBearerTokenFingerprint.exception }.let { val occurrenceIndex = it.scanResult.stringsScanResult!!.matches.first().index diff --git a/src/main/kotlin/app/revanced/patches/reddit/layout/disablescreenshotpopup/patch/DisableScreenshotPopupPatch.kt b/src/main/kotlin/app/revanced/patches/reddit/layout/disablescreenshotpopup/patch/DisableScreenshotPopupPatch.kt index efb9a20ab9..f59c020781 100644 --- a/src/main/kotlin/app/revanced/patches/reddit/layout/disablescreenshotpopup/patch/DisableScreenshotPopupPatch.kt +++ b/src/main/kotlin/app/revanced/patches/reddit/layout/disablescreenshotpopup/patch/DisableScreenshotPopupPatch.kt @@ -1,6 +1,6 @@ package app.revanced.patches.reddit.layout.disablescreenshotpopup.patch -import app.revanced.extensions.toErrorResult +import app.revanced.extensions.exception import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.data.BytecodeContext @@ -19,6 +19,6 @@ class DisableScreenshotPopupPatch : BytecodePatch( ) { override fun execute(context: BytecodeContext) { DisableScreenshotPopupFingerprint.result?.mutableMethod?.addInstruction(0, "return-void") - ?: throw DisableScreenshotPopupFingerprint.toErrorResult() + ?: throw DisableScreenshotPopupFingerprint.exception } } diff --git a/src/main/kotlin/app/revanced/patches/reddit/misc/tracking/url/patch/SanitizeUrlQueryPatch.kt b/src/main/kotlin/app/revanced/patches/reddit/misc/tracking/url/patch/SanitizeUrlQueryPatch.kt index 1d5312fca9..94404f0789 100644 --- a/src/main/kotlin/app/revanced/patches/reddit/misc/tracking/url/patch/SanitizeUrlQueryPatch.kt +++ b/src/main/kotlin/app/revanced/patches/reddit/misc/tracking/url/patch/SanitizeUrlQueryPatch.kt @@ -1,6 +1,6 @@ package app.revanced.patches.reddit.misc.tracking.url.patch -import app.revanced.extensions.toErrorResult +import app.revanced.extensions.exception import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.data.BytecodeContext @@ -22,7 +22,7 @@ class SanitizeUrlQueryPatch : BytecodePatch( ShareLinkFormatterFingerprint.result?.mutableMethod?.addInstructions( 0, "return-object p0" - ) ?: throw ShareLinkFormatterFingerprint.toErrorResult() + ) ?: throw ShareLinkFormatterFingerprint.exception } } diff --git a/src/main/kotlin/app/revanced/patches/shared/misc/fix/verticalscroll/patch/VerticalScrollPatch.kt b/src/main/kotlin/app/revanced/patches/shared/misc/fix/verticalscroll/patch/VerticalScrollPatch.kt index 5c32a51898..cea86414e8 100644 --- a/src/main/kotlin/app/revanced/patches/shared/misc/fix/verticalscroll/patch/VerticalScrollPatch.kt +++ b/src/main/kotlin/app/revanced/patches/shared/misc/fix/verticalscroll/patch/VerticalScrollPatch.kt @@ -1,6 +1,6 @@ package app.revanced.patches.shared.misc.fix.verticalscroll.patch -import app.revanced.extensions.toErrorResult +import app.revanced.extensions.exception import app.revanced.patcher.annotation.Description import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.InstructionExtensions.addInstruction @@ -27,6 +27,6 @@ class VerticalScrollPatch : BytecodePatch( "const/4 v$moveResultRegister, 0x0" ) } - } ?: throw CanScrollVerticallyFingerprint.toErrorResult() + } ?: throw CanScrollVerticallyFingerprint.exception } } diff --git a/src/main/kotlin/app/revanced/patches/solidexplorer2/functionality/filesize/patch/RemoveFileSizeLimitPatch.kt b/src/main/kotlin/app/revanced/patches/solidexplorer2/functionality/filesize/patch/RemoveFileSizeLimitPatch.kt index 28a2dc1bde..3fed6f5381 100644 --- a/src/main/kotlin/app/revanced/patches/solidexplorer2/functionality/filesize/patch/RemoveFileSizeLimitPatch.kt +++ b/src/main/kotlin/app/revanced/patches/solidexplorer2/functionality/filesize/patch/RemoveFileSizeLimitPatch.kt @@ -1,6 +1,6 @@ package app.revanced.patches.solidexplorer2.functionality.filesize.patch -import app.revanced.extensions.toErrorResult +import app.revanced.extensions.exception import app.revanced.patcher.annotation.Compatibility import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name @@ -23,5 +23,5 @@ class RemoveFileSizeLimitPatch : BytecodePatch(listOf(OnReadyFingerprint)) { val cmpResultRegister = result.mutableMethod.getInstruction(cmpIndex).registerA result.mutableMethod.replaceInstruction(cmpIndex, "const/4 v${cmpResultRegister}, 0x0") - } ?: throw OnReadyFingerprint.toErrorResult() + } ?: throw OnReadyFingerprint.exception } diff --git a/src/main/kotlin/app/revanced/patches/songpal/badge/patch/BadgeTabPatch.kt b/src/main/kotlin/app/revanced/patches/songpal/badge/patch/BadgeTabPatch.kt index 28fa2ef1da..9e00514e65 100644 --- a/src/main/kotlin/app/revanced/patches/songpal/badge/patch/BadgeTabPatch.kt +++ b/src/main/kotlin/app/revanced/patches/songpal/badge/patch/BadgeTabPatch.kt @@ -1,6 +1,6 @@ package app.revanced.patches.songpal.badge.patch -import app.revanced.extensions.toErrorResult +import app.revanced.extensions.exception import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.data.BytecodeContext @@ -50,7 +50,7 @@ class BadgeTabPatch : BytecodePatch( """ ) - } ?: throw CreateTabsFingerprint.toErrorResult() + } ?: throw CreateTabsFingerprint.exception } companion object { diff --git a/src/main/kotlin/app/revanced/patches/songpal/badge/patch/RemoveNotificationBadgePatch.kt b/src/main/kotlin/app/revanced/patches/songpal/badge/patch/RemoveNotificationBadgePatch.kt index 73e43586db..3794339a85 100644 --- a/src/main/kotlin/app/revanced/patches/songpal/badge/patch/RemoveNotificationBadgePatch.kt +++ b/src/main/kotlin/app/revanced/patches/songpal/badge/patch/RemoveNotificationBadgePatch.kt @@ -1,6 +1,6 @@ package app.revanced.patches.songpal.badge.patch -import app.revanced.extensions.toErrorResult +import app.revanced.extensions.exception import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.data.BytecodeContext @@ -20,6 +20,6 @@ class RemoveNotificationBadgePatch : BytecodePatch( override fun execute(context: BytecodeContext) { ShowNotificationFingerprint.result?.mutableMethod?.apply { addInstructions(0, "return-void") - } ?: throw ShowNotificationFingerprint.toErrorResult() + } ?: throw ShowNotificationFingerprint.exception } } diff --git a/src/main/kotlin/app/revanced/patches/spotify/lite/ondemand/patch/OnDemandPatch.kt b/src/main/kotlin/app/revanced/patches/spotify/lite/ondemand/patch/OnDemandPatch.kt index 3b1342f9d6..7ab6ff29a2 100644 --- a/src/main/kotlin/app/revanced/patches/spotify/lite/ondemand/patch/OnDemandPatch.kt +++ b/src/main/kotlin/app/revanced/patches/spotify/lite/ondemand/patch/OnDemandPatch.kt @@ -1,6 +1,6 @@ package app.revanced.patches.spotify.lite.ondemand.patch -import app.revanced.extensions.toErrorResult +import app.revanced.extensions.exception import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.data.BytecodeContext @@ -24,6 +24,6 @@ class OnDemandPatch : BytecodePatch( val insertIndex = scanResult.patternScanResult!!.endIndex - 1 // Spoof a premium account mutableMethod.addInstruction(insertIndex, "const/4 v0, 0x2") - } ?: throw OnDemandFingerprint.toErrorResult() + } ?: throw OnDemandFingerprint.exception } } diff --git a/src/main/kotlin/app/revanced/patches/tiktok/interaction/seekbar/patch/ShowSeekbarPatch.kt b/src/main/kotlin/app/revanced/patches/tiktok/interaction/seekbar/patch/ShowSeekbarPatch.kt index 94e0bc1143..85bbe3378c 100644 --- a/src/main/kotlin/app/revanced/patches/tiktok/interaction/seekbar/patch/ShowSeekbarPatch.kt +++ b/src/main/kotlin/app/revanced/patches/tiktok/interaction/seekbar/patch/ShowSeekbarPatch.kt @@ -1,6 +1,6 @@ package app.revanced.patches.tiktok.interaction.seekbar.patch -import app.revanced.extensions.toErrorResult +import app.revanced.extensions.exception import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.data.BytecodeContext @@ -40,7 +40,7 @@ class ShowSeekbarPatch : BytecodePatch( const/16 v$typeRegister, 0x64 """ ) - } ?: throw SetSeekBarShowTypeFingerprint.toErrorResult() + } ?: throw SetSeekBarShowTypeFingerprint.exception } } \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/tiktok/misc/settings/patch/SettingsPatch.kt b/src/main/kotlin/app/revanced/patches/tiktok/misc/settings/patch/SettingsPatch.kt index 0bdf374a68..dfa3c2368e 100644 --- a/src/main/kotlin/app/revanced/patches/tiktok/misc/settings/patch/SettingsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/tiktok/misc/settings/patch/SettingsPatch.kt @@ -1,6 +1,6 @@ package app.revanced.patches.tiktok.misc.settings.patch -import app.revanced.extensions.toErrorResult +import app.revanced.extensions.exception import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.data.BytecodeContext @@ -34,9 +34,9 @@ class SettingsPatch : BytecodePatch( override fun execute(context: BytecodeContext) { // Find the class name of classes which construct a settings entry val settingsButtonClass = SettingsEntryFingerprint.result?.classDef?.type?.toClassName() - ?: throw SettingsEntryFingerprint.toErrorResult() + ?: throw SettingsEntryFingerprint.exception val settingsButtonInfoClass = SettingsEntryInfoFingerprint.result?.classDef?.type?.toClassName() - ?: throw SettingsEntryInfoFingerprint.toErrorResult() + ?: throw SettingsEntryInfoFingerprint.exception // Create a settings entry for 'revanced settings' and add it to settings fragment AddSettingsEntryFingerprint.result?.apply { @@ -64,7 +64,7 @@ class SettingsPatch : BytecodePatch( """ ) } - } ?: throw AddSettingsEntryFingerprint.toErrorResult() + } ?: throw AddSettingsEntryFingerprint.exception // Initialize the settings menu once the replaced setting entry is clicked. AdPersonalizationActivityOnCreateFingerprint.result?.mutableMethod?.apply { @@ -85,7 +85,7 @@ class SettingsPatch : BytecodePatch( """, ExternalLabel("notrevanced", getInstruction(initializeSettingsIndex)) ) - } ?: throw AdPersonalizationActivityOnCreateFingerprint.toErrorResult() + } ?: throw AdPersonalizationActivityOnCreateFingerprint.exception } private fun String.toClassName(): String { diff --git a/src/main/kotlin/app/revanced/patches/trakt/patch/UnlockProPatch.kt b/src/main/kotlin/app/revanced/patches/trakt/patch/UnlockProPatch.kt index e739567488..0d5254a028 100644 --- a/src/main/kotlin/app/revanced/patches/trakt/patch/UnlockProPatch.kt +++ b/src/main/kotlin/app/revanced/patches/trakt/patch/UnlockProPatch.kt @@ -1,6 +1,6 @@ package app.revanced.patches.trakt.patch -import app.revanced.extensions.toErrorResult +import app.revanced.extensions.exception import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.data.BytecodeContext @@ -25,13 +25,13 @@ class UnlockProPatch : BytecodePatch( arrayOf(IsVIPFingerprint, IsVIPEPFingerprint).onEach { fingerprint -> // Resolve both fingerprints on the same class. if (!fingerprint.resolve(context, remoteUserClass)) - throw fingerprint.toErrorResult() + throw fingerprint.exception }.forEach { fingerprint -> // Return true for both VIP check methods. fingerprint.result?.mutableMethod?.addInstructions(0, RETURN_TRUE_INSTRUCTIONS) - ?: throw fingerprint.toErrorResult() + ?: throw fingerprint.exception } - } ?: throw RemoteUserFingerprint.toErrorResult() + } ?: throw RemoteUserFingerprint.exception } private companion object { diff --git a/src/main/kotlin/app/revanced/patches/twelvewidgets/unlock/patch/UnlockPaidWidgetsPatch.kt b/src/main/kotlin/app/revanced/patches/twelvewidgets/unlock/patch/UnlockPaidWidgetsPatch.kt index 20b35c140a..665ba9f6ce 100644 --- a/src/main/kotlin/app/revanced/patches/twelvewidgets/unlock/patch/UnlockPaidWidgetsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/twelvewidgets/unlock/patch/UnlockPaidWidgetsPatch.kt @@ -1,6 +1,6 @@ package app.revanced.patches.twelvewidgets.unlock.patch -import app.revanced.extensions.toErrorResult +import app.revanced.extensions.exception import app.revanced.patcher.annotation.* import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.InstructionExtensions.addInstructions @@ -32,7 +32,7 @@ class UnlockPaidWidgetsPatch : BytecodePatch( ScreentimeSmallWidgetUnlockFingerprint, WeatherWidgetUnlockFingerprint ).map { fingerprint -> - fingerprint.result?.mutableMethod ?: throw fingerprint.toErrorResult() + fingerprint.result?.mutableMethod ?: throw fingerprint.exception }.forEach { method -> method.apply { removeInstructions(4, 3) diff --git a/src/main/kotlin/app/revanced/patches/twitch/ad/video/patch/VideoAdsPatch.kt b/src/main/kotlin/app/revanced/patches/twitch/ad/video/patch/VideoAdsPatch.kt index 216e676e86..12ab6178ea 100644 --- a/src/main/kotlin/app/revanced/patches/twitch/ad/video/patch/VideoAdsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/twitch/ad/video/patch/VideoAdsPatch.kt @@ -1,6 +1,6 @@ package app.revanced.patches.twitch.ad.video.patch -import app.revanced.extensions.toErrorResult +import app.revanced.extensions.exception import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.data.BytecodeContext @@ -95,7 +95,7 @@ class VideoAdsPatch : AbstractAdPatch( """, ExternalLabel(skipLabelName, mutableMethod.getInstruction(0)) ) - } ?: throw CheckAdEligibilityLambdaFingerprint.toErrorResult() + } ?: throw CheckAdEligibilityLambdaFingerprint.exception GetReadyToShowAdFingerprint.result?.apply { val adFormatDeclined = "Ltv/twitch/android/shared/display/ads/theatre/StreamDisplayAdsPresenter\$Action\$AdFormatDeclined;" @@ -110,7 +110,7 @@ class VideoAdsPatch : AbstractAdPatch( """, ExternalLabel(skipLabelName, mutableMethod.getInstruction(0)) ) - } ?: throw GetReadyToShowAdFingerprint.toErrorResult() + } ?: throw GetReadyToShowAdFingerprint.exception // Spoof showAds JSON field ContentConfigShowAdsFingerprint.result?.apply { @@ -121,7 +121,7 @@ class VideoAdsPatch : AbstractAdPatch( return v0 """ ) - } ?: throw ContentConfigShowAdsFingerprint.toErrorResult() + } ?: throw ContentConfigShowAdsFingerprint.exception SettingsPatch.PreferenceScreen.ADS.CLIENT_SIDE.addPreferences( SwitchPreference( diff --git a/src/main/kotlin/app/revanced/patches/twitch/chat/antidelete/patch/ShowDeletedMessagesPatch.kt b/src/main/kotlin/app/revanced/patches/twitch/chat/antidelete/patch/ShowDeletedMessagesPatch.kt index 1c9f93a3f2..caea459254 100644 --- a/src/main/kotlin/app/revanced/patches/twitch/chat/antidelete/patch/ShowDeletedMessagesPatch.kt +++ b/src/main/kotlin/app/revanced/patches/twitch/chat/antidelete/patch/ShowDeletedMessagesPatch.kt @@ -1,6 +1,6 @@ package app.revanced.patches.twitch.chat.antidelete.patch -import app.revanced.extensions.toErrorResult +import app.revanced.extensions.exception import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.data.BytecodeContext @@ -51,11 +51,11 @@ class ShowDeletedMessagesPatch : BytecodePatch( """, ExternalLabel("no_spoiler", getInstruction(implementation!!.instructions.lastIndex)) ) - } ?: throw DeletedMessageClickableSpanCtorFingerprint.toErrorResult() + } ?: throw DeletedMessageClickableSpanCtorFingerprint.exception // Spoiler mode: Disable setHasModAccess setter SetHasModAccessFingerprint.result?.mutableMethod?.addInstruction(0, "return-void") - ?: throw SetHasModAccessFingerprint.toErrorResult() + ?: throw SetHasModAccessFingerprint.exception // Cross-out mode: Reformat span of deleted message ChatUtilCreateDeletedSpanFingerprint.result?.mutableMethod?.apply { @@ -69,7 +69,7 @@ class ShowDeletedMessagesPatch : BytecodePatch( """, ExternalLabel("no_reformat", getInstruction(0)) ) - } ?: throw ChatUtilCreateDeletedSpanFingerprint.toErrorResult() + } ?: throw ChatUtilCreateDeletedSpanFingerprint.exception SettingsPatch.PreferenceScreen.CHAT.GENERAL.addPreferences( ListPreference( diff --git a/src/main/kotlin/app/revanced/patches/twitch/chat/autoclaim/patch/AutoClaimChannelPointsPatch.kt b/src/main/kotlin/app/revanced/patches/twitch/chat/autoclaim/patch/AutoClaimChannelPointsPatch.kt index c2cbac8bcb..3eeea60585 100644 --- a/src/main/kotlin/app/revanced/patches/twitch/chat/autoclaim/patch/AutoClaimChannelPointsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/twitch/chat/autoclaim/patch/AutoClaimChannelPointsPatch.kt @@ -1,6 +1,6 @@ package app.revanced.patches.twitch.chat.autoclaim.patch -import app.revanced.extensions.toErrorResult +import app.revanced.extensions.exception import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.data.BytecodeContext @@ -60,6 +60,6 @@ class AutoClaimChannelPointPatch : BytecodePatch( """, ExternalLabel("auto_claim", getInstruction(lastIndex)) ) - } ?: throw CommunityPointsButtonViewDelegateFingerprint.toErrorResult() + } ?: throw CommunityPointsButtonViewDelegateFingerprint.exception } } diff --git a/src/main/kotlin/app/revanced/patches/twitch/debug/patch/DebugModePatch.kt b/src/main/kotlin/app/revanced/patches/twitch/debug/patch/DebugModePatch.kt index 918a31db4b..a38e80db8e 100644 --- a/src/main/kotlin/app/revanced/patches/twitch/debug/patch/DebugModePatch.kt +++ b/src/main/kotlin/app/revanced/patches/twitch/debug/patch/DebugModePatch.kt @@ -1,6 +1,6 @@ package app.revanced.patches.twitch.debug.patch -import app.revanced.extensions.toErrorResult +import app.revanced.extensions.exception import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.data.BytecodeContext @@ -44,7 +44,7 @@ class DebugModePatch : BytecodePatch( return v0 """ ) - } ?: throw it.toErrorResult() + } ?: throw it.exception } SettingsPatch.PreferenceScreen.MISC.OTHER.addPreferences( diff --git a/src/main/kotlin/app/revanced/patches/twitch/misc/settings/bytecode/patch/SettingsPatch.kt b/src/main/kotlin/app/revanced/patches/twitch/misc/settings/bytecode/patch/SettingsPatch.kt index 8bc157b174..8aec9bb52d 100644 --- a/src/main/kotlin/app/revanced/patches/twitch/misc/settings/bytecode/patch/SettingsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/twitch/misc/settings/bytecode/patch/SettingsPatch.kt @@ -1,6 +1,6 @@ package app.revanced.patches.twitch.misc.settings.bytecode.patch -import app.revanced.extensions.toErrorResult +import app.revanced.extensions.exception import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.data.BytecodeContext @@ -55,7 +55,7 @@ class SettingsPatch : BytecodePatch( """, ExternalLabel("no_rv_settings_init", mutableMethod.getInstruction(insertIndex)) ) - } ?: throw SettingsActivityOnCreateFingerprint.toErrorResult() + } ?: throw SettingsActivityOnCreateFingerprint.exception // Create new menu item for settings menu SettingsMenuItemEnumFingerprint.result?.apply { @@ -65,7 +65,7 @@ class SettingsPatch : BytecodePatch( REVANCED_SETTINGS_MENU_ITEM_TITLE_RES, REVANCED_SETTINGS_MENU_ITEM_ICON_RES ) - } ?: throw SettingsMenuItemEnumFingerprint.toErrorResult() + } ?: throw SettingsMenuItemEnumFingerprint.exception // Intercept settings menu creation and add new menu item MenuGroupsUpdatedFingerprint.result?.apply { @@ -77,7 +77,7 @@ class SettingsPatch : BytecodePatch( move-result-object p1 """ ) - } ?: throw MenuGroupsUpdatedFingerprint.toErrorResult() + } ?: throw MenuGroupsUpdatedFingerprint.exception // Intercept onclick events for the settings menu MenuGroupsOnClickFingerprint.result?.apply { @@ -94,7 +94,7 @@ class SettingsPatch : BytecodePatch( """, ExternalLabel("no_rv_settings_onclick", mutableMethod.getInstruction(insertIndex)) ) - } ?: throw MenuGroupsOnClickFingerprint.toErrorResult() + } ?: throw MenuGroupsOnClickFingerprint.exception addString("revanced_settings", "ReVanced Settings", false) addString("revanced_reboot_message", "Twitch needs to restart to apply your changes. Restart now?", false) diff --git a/src/main/kotlin/app/revanced/patches/vsco/misc/pro/patch/UnlockProPatch.kt b/src/main/kotlin/app/revanced/patches/vsco/misc/pro/patch/UnlockProPatch.kt index 74181cedc1..5df0ec811b 100644 --- a/src/main/kotlin/app/revanced/patches/vsco/misc/pro/patch/UnlockProPatch.kt +++ b/src/main/kotlin/app/revanced/patches/vsco/misc/pro/patch/UnlockProPatch.kt @@ -1,6 +1,6 @@ package app.revanced.patches.vsco.misc.pro.patch -import app.revanced.extensions.toErrorResult +import app.revanced.extensions.exception import app.revanced.patcher.annotation.* import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.InstructionExtensions.addInstruction @@ -25,6 +25,6 @@ class UnlockProPatch : BytecodePatch( const p1, 0x1 """ ) - } ?: throw RevCatSubscriptionFingerprint.toErrorResult() + } ?: throw RevCatSubscriptionFingerprint.exception } } diff --git a/src/main/kotlin/app/revanced/patches/youtube/ad/getpremium/bytecode/patch/HideGetPremiumVideoAdvertisementPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/ad/getpremium/bytecode/patch/HideGetPremiumVideoAdvertisementPatch.kt index 2ee456adb8..1748b6008a 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/ad/getpremium/bytecode/patch/HideGetPremiumVideoAdvertisementPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/ad/getpremium/bytecode/patch/HideGetPremiumVideoAdvertisementPatch.kt @@ -1,6 +1,6 @@ package app.revanced.patches.youtube.ad.getpremium.bytecode.patch -import app.revanced.extensions.toErrorResult +import app.revanced.extensions.exception import app.revanced.patcher.annotation.Name import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels @@ -62,7 +62,7 @@ class HideGetPremiumPatch : BytecodePatch(listOf(GetPremiumViewFingerprint)) { """ ) } - } ?: throw GetPremiumViewFingerprint.toErrorResult() + } ?: throw GetPremiumViewFingerprint.exception } private companion object { diff --git a/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/patch/EnableSeekbarTappingPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/patch/EnableSeekbarTappingPatch.kt index 775fd6aeda..78e27e802c 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/patch/EnableSeekbarTappingPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/interaction/seekbar/patch/EnableSeekbarTappingPatch.kt @@ -1,6 +1,6 @@ package app.revanced.patches.youtube.interaction.seekbar.patch -import app.revanced.extensions.toErrorResult +import app.revanced.extensions.exception import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.data.BytecodeContext @@ -43,7 +43,7 @@ class EnableSeekbarTappingPatch : BytecodePatch( } } - seekbarTappingMethods ?: throw OnTouchEventHandlerFingerprint.toErrorResult() + seekbarTappingMethods ?: throw OnTouchEventHandlerFingerprint.exception SeekbarTappingFingerprint.result?.let { val insertIndex = it.scanResult.patternScanResult!!.endIndex - 1 @@ -72,6 +72,6 @@ class EnableSeekbarTappingPatch : BytecodePatch( ExternalLabel("disabled", getInstruction(insertIndex)) ) } - } ?: throw SeekbarTappingFingerprint.toErrorResult() + } ?: throw SeekbarTappingFingerprint.exception } } \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/autoplay/patch/HideAutoplayButtonPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/autoplay/patch/HideAutoplayButtonPatch.kt index 6081ad74bd..8857d85446 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/autoplay/patch/HideAutoplayButtonPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/autoplay/patch/HideAutoplayButtonPatch.kt @@ -1,7 +1,7 @@ package app.revanced.patches.youtube.layout.buttons.autoplay.patch import app.revanced.extensions.findIndexForIdResource -import app.revanced.extensions.toErrorResult +import app.revanced.extensions.exception import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.data.BytecodeContext @@ -68,6 +68,6 @@ class HideAutoplayButtonPatch : BytecodePatch( """, ExternalLabel("hidden", jumpInstruction) ) - } ?: throw LayoutConstructorFingerprint.toErrorResult() + } ?: throw LayoutConstructorFingerprint.exception } } \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/navigation/patch/NavigationButtonsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/navigation/patch/NavigationButtonsPatch.kt index 1fd963fa80..fc708d6ef7 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/navigation/patch/NavigationButtonsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/navigation/patch/NavigationButtonsPatch.kt @@ -1,6 +1,6 @@ package app.revanced.patches.youtube.layout.buttons.navigation.patch -import app.revanced.extensions.toErrorResult +import app.revanced.extensions.exception import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.data.BytecodeContext @@ -101,7 +101,7 @@ class NavigationButtonsPatch : BytecodePatch(listOf(AddCreateButtonViewFingerpri initializeButtonsResult.mutableClass ) ) - throw it.toErrorResult() + throw it.exception } .map { it.result!!.scanResult.patternScanResult!! } @@ -150,7 +150,7 @@ class NavigationButtonsPatch : BytecodePatch(listOf(AddCreateButtonViewFingerpri """ ) } - } ?: throw AddCreateButtonViewFingerprint.toErrorResult() + } ?: throw AddCreateButtonViewFingerprint.exception /* * Resolve fingerprints @@ -158,7 +158,7 @@ class NavigationButtonsPatch : BytecodePatch(listOf(AddCreateButtonViewFingerpri InitializeButtonsFingerprint.result!!.let { if (!PivotBarCreateButtonViewFingerprint.resolve(context, it.mutableMethod, it.mutableClass)) - throw PivotBarCreateButtonViewFingerprint.toErrorResult() + throw PivotBarCreateButtonViewFingerprint.exception } PivotBarCreateButtonViewFingerprint.result!!.apply { diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/navigation/patch/ResolvePivotBarFingerprintsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/navigation/patch/ResolvePivotBarFingerprintsPatch.kt index 99d36b4ba2..eb7bfd40e3 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/navigation/patch/ResolvePivotBarFingerprintsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/navigation/patch/ResolvePivotBarFingerprintsPatch.kt @@ -1,6 +1,6 @@ package app.revanced.patches.youtube.layout.buttons.navigation.patch -import app.revanced.extensions.toErrorResult +import app.revanced.extensions.exception import app.revanced.patcher.annotation.Description import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve @@ -28,8 +28,8 @@ class ResolvePivotBarFingerprintsPatch : BytecodePatch( context, it.classDef ) - ) throw InitializeButtonsFingerprint.toErrorResult() - } ?: throw PivotBarConstructorFingerprint.toErrorResult() + ) throw InitializeButtonsFingerprint.exception + } ?: throw PivotBarConstructorFingerprint.exception } internal companion object { diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/player/hide/patch/HidePlayerButtonsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/player/hide/patch/HidePlayerButtonsPatch.kt index 58065b6907..b719359bfa 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/player/hide/patch/HidePlayerButtonsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/buttons/player/hide/patch/HidePlayerButtonsPatch.kt @@ -1,6 +1,6 @@ package app.revanced.patches.youtube.layout.buttons.player.hide.patch -import app.revanced.extensions.toErrorResult +import app.revanced.extensions.exception import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.data.BytecodeContext @@ -67,6 +67,6 @@ class HidePlayerButtonsPatch : BytecodePatch( move-result v$hasPreviousParameterRegister """ ) - } ?: throw PlayerControlsVisibilityModelFingerprint.toErrorResult() + } ?: throw PlayerControlsVisibilityModelFingerprint.exception } } diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/albumcards/bytecode/patch/AlbumCardsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/albumcards/bytecode/patch/AlbumCardsPatch.kt index a58f135310..3b699b36fe 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/albumcards/bytecode/patch/AlbumCardsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/albumcards/bytecode/patch/AlbumCardsPatch.kt @@ -1,6 +1,6 @@ package app.revanced.patches.youtube.layout.hide.albumcards.bytecode.patch -import app.revanced.extensions.toErrorResult +import app.revanced.extensions.exception import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.data.BytecodeContext @@ -41,6 +41,6 @@ class AlbumCardsPatch : BytecodePatch( "hideAlbumCard(Landroid/view/View;)V" ) } - } ?: throw AlbumCardsFingerprint.toErrorResult() + } ?: throw AlbumCardsFingerprint.exception } } diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/breakingnews/bytecode/patch/BreakingNewsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/breakingnews/bytecode/patch/BreakingNewsPatch.kt index 05e847ffda..ee09bed14e 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/breakingnews/bytecode/patch/BreakingNewsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/breakingnews/bytecode/patch/BreakingNewsPatch.kt @@ -1,6 +1,6 @@ package app.revanced.patches.youtube.layout.hide.breakingnews.bytecode.patch -import app.revanced.extensions.toErrorResult +import app.revanced.extensions.exception import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.data.BytecodeContext @@ -42,7 +42,7 @@ class BreakingNewsPatch : BytecodePatch( ) } - } ?: throw BreakingNewsFingerprint.toErrorResult() + } ?: throw BreakingNewsFingerprint.exception } } diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/crowdfundingbox/bytecode/patch/CrowdfundingBoxPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/crowdfundingbox/bytecode/patch/CrowdfundingBoxPatch.kt index eb500c7528..1ebdb0eb67 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/crowdfundingbox/bytecode/patch/CrowdfundingBoxPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/crowdfundingbox/bytecode/patch/CrowdfundingBoxPatch.kt @@ -1,6 +1,6 @@ package app.revanced.patches.youtube.layout.hide.crowdfundingbox.bytecode.patch -import app.revanced.extensions.toErrorResult +import app.revanced.extensions.exception import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.data.BytecodeContext @@ -33,7 +33,7 @@ class CrowdfundingBoxPatch : BytecodePatch( addInstruction(insertIndex, "invoke-static {v$objectRegister}, $INTEGRATIONS_METHOD_DESCRIPTOR") } - } ?: throw CrowdfundingBoxFingerprint.toErrorResult() + } ?: throw CrowdfundingBoxFingerprint.exception } private companion object { diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/endscreencards/bytecode/patch/HideEndscreenCardsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/endscreencards/bytecode/patch/HideEndscreenCardsPatch.kt index 007a303ccd..43f7208ed6 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/endscreencards/bytecode/patch/HideEndscreenCardsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/endscreencards/bytecode/patch/HideEndscreenCardsPatch.kt @@ -1,6 +1,6 @@ package app.revanced.patches.youtube.layout.hide.endscreencards.bytecode.patch -import app.revanced.extensions.toErrorResult +import app.revanced.extensions.exception import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.data.BytecodeContext @@ -32,7 +32,7 @@ class HideEndscreenCardsPatch : BytecodePatch( ) { override fun execute(context: BytecodeContext) { fun MethodFingerprint.injectHideCall() { - val layoutResult = result ?: throw toErrorResult() + val layoutResult = result ?: throw exception layoutResult.mutableMethod.apply { val insertIndex = layoutResult.scanResult.patternScanResult!!.endIndex + 1 val viewRegister = getInstruction(insertIndex - 1).registerA diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/filterbar/patch/HideFilterBarPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/filterbar/patch/HideFilterBarPatch.kt index 91067ea5b9..02c7fa0098 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/filterbar/patch/HideFilterBarPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/filterbar/patch/HideFilterBarPatch.kt @@ -1,6 +1,6 @@ package app.revanced.patches.youtube.layout.hide.filterbar.patch -import app.revanced.extensions.toErrorResult +import app.revanced.extensions.exception import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.data.BytecodeContext @@ -76,6 +76,6 @@ class HideFilterBarPatch : BytecodePatch( addInstructions(insertIndex, instructions(register)) } - } ?: throw toErrorResult() + } ?: throw exception } } diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/floatingmicrophone/patch/HideFloatingMicrophoneButtonPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/floatingmicrophone/patch/HideFloatingMicrophoneButtonPatch.kt index 541dcfe8fb..1f9e638678 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/floatingmicrophone/patch/HideFloatingMicrophoneButtonPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/floatingmicrophone/patch/HideFloatingMicrophoneButtonPatch.kt @@ -1,6 +1,6 @@ package app.revanced.patches.youtube.layout.hide.floatingmicrophone.patch -import app.revanced.extensions.toErrorResult +import app.revanced.extensions.exception import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.data.BytecodeContext @@ -35,7 +35,7 @@ class HideFloatingMicrophoneButtonPatch : BytecodePatch( """ ) } - } ?: throw ShowFloatingMicrophoneButtonFingerprint.toErrorResult() + } ?: throw ShowFloatingMicrophoneButtonFingerprint.exception } private companion object { diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/general/patch/HideLayoutComponentsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/general/patch/HideLayoutComponentsPatch.kt index 75c1a8cc98..27877de6e1 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/general/patch/HideLayoutComponentsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/general/patch/HideLayoutComponentsPatch.kt @@ -1,6 +1,6 @@ package app.revanced.patches.youtube.layout.hide.general.patch -import app.revanced.extensions.toErrorResult +import app.revanced.extensions.exception import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.data.BytecodeContext @@ -272,7 +272,7 @@ class HideLayoutComponentsPatch : BytecodePatch( addInstruction(0, "move-object/from16 v$freeRegister, p3") } - } ?: throw ConvertElementToFlatBufferFingerprint.toErrorResult() + } ?: throw ConvertElementToFlatBufferFingerprint.exception // endregion } diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/loadmorebutton/bytecode/patch/HideLoadMoreButtonPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/loadmorebutton/bytecode/patch/HideLoadMoreButtonPatch.kt index 768a7ba652..97c34561fc 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/loadmorebutton/bytecode/patch/HideLoadMoreButtonPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/loadmorebutton/bytecode/patch/HideLoadMoreButtonPatch.kt @@ -1,6 +1,6 @@ package app.revanced.patches.youtube.layout.hide.loadmorebutton.bytecode.patch -import app.revanced.extensions.toErrorResult +import app.revanced.extensions.exception import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.data.BytecodeContext @@ -33,7 +33,7 @@ class HideLoadMoreButtonPatch : BytecodePatch(listOf(HideLoadMoreButtonFingerpri "$INTEGRATIONS_CLASS_DESCRIPTOR->hideLoadMoreButton(Landroid/view/View;)V" ) } - } ?: throw HideLoadMoreButtonFingerprint.toErrorResult() + } ?: throw HideLoadMoreButtonFingerprint.exception } private companion object { diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/personalinformation/bytecode/patch/HideEmailAddressPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/personalinformation/bytecode/patch/HideEmailAddressPatch.kt index fef13b0969..2c2eabc2e4 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/personalinformation/bytecode/patch/HideEmailAddressPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/personalinformation/bytecode/patch/HideEmailAddressPatch.kt @@ -1,6 +1,6 @@ package app.revanced.patches.youtube.layout.hide.personalinformation.bytecode.patch -import app.revanced.extensions.toErrorResult +import app.revanced.extensions.exception import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.data.BytecodeContext @@ -41,6 +41,6 @@ class HideEmailAddressPatch : BytecodePatch( """ ) } - } ?: throw AccountSwitcherAccessibilityLabelFingerprint.toErrorResult() + } ?: throw AccountSwitcherAccessibilityLabelFingerprint.exception } } diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/player/overlay/bytecode/patch/HidePlayerOverlayPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/player/overlay/bytecode/patch/HidePlayerOverlayPatch.kt index ab7914eb1d..f9582806ca 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/player/overlay/bytecode/patch/HidePlayerOverlayPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/player/overlay/bytecode/patch/HidePlayerOverlayPatch.kt @@ -1,7 +1,7 @@ package app.revanced.patches.youtube.layout.hide.player.overlay.bytecode.patch import app.revanced.extensions.indexOfFirstConstantInstructionValue -import app.revanced.extensions.toErrorResult +import app.revanced.extensions.exception import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.data.BytecodeContext @@ -35,7 +35,7 @@ class HidePlayerOverlayPatch : BytecodePatch(listOf(CreatePlayerOverviewFingerpr "$INTEGRATIONS_CLASS_DESCRIPTOR->hidePlayerOverlay(Landroid/widget/ImageView;)V" ) } - } ?: throw CreatePlayerOverviewFingerprint.toErrorResult() + } ?: throw CreatePlayerOverviewFingerprint.exception } private companion object { diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/shorts/bytecode/patch/HideShortsComponentsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/shorts/bytecode/patch/HideShortsComponentsPatch.kt index 74659eeea8..04262324a4 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/shorts/bytecode/patch/HideShortsComponentsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/shorts/bytecode/patch/HideShortsComponentsPatch.kt @@ -2,7 +2,7 @@ package app.revanced.patches.youtube.layout.hide.shorts.bytecode.patch import app.revanced.extensions.findIndexForIdResource import app.revanced.extensions.injectHideViewCall -import app.revanced.extensions.toErrorResult +import app.revanced.extensions.exception import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.data.BytecodeContext @@ -61,7 +61,7 @@ class HideShortsComponentsPatch : BytecodePatch( "hideShortsShelf" ) } - } ?: throw ReelConstructorFingerprint.toErrorResult() + } ?: throw ReelConstructorFingerprint.exception // endregion @@ -70,7 +70,7 @@ class HideShortsComponentsPatch : BytecodePatch( // Some Shorts buttons are views, hide them by setting their visibility to GONE. CreateShortsButtonsFingerprint.result?.let { ShortsButtons.values().forEach { button -> button.injectHideCall(it.mutableMethod) } - } ?: throw CreateShortsButtonsFingerprint.toErrorResult() + } ?: throw CreateShortsButtonsFingerprint.exception // endregion @@ -79,7 +79,7 @@ class HideShortsComponentsPatch : BytecodePatch( // Hook to get the pivotBar view. SetPivotBarVisibilityParentFingerprint.result?.let { if (!SetPivotBarVisibilityFingerprint.resolve(context, it.classDef)) - throw SetPivotBarVisibilityFingerprint.toErrorResult() + throw SetPivotBarVisibilityFingerprint.exception SetPivotBarVisibilityFingerprint.result!!.let { result -> result.mutableMethod.apply { @@ -92,17 +92,17 @@ class HideShortsComponentsPatch : BytecodePatch( ) } } - } ?: throw SetPivotBarVisibilityParentFingerprint.toErrorResult() + } ?: throw SetPivotBarVisibilityParentFingerprint.exception // Hook to hide the navigation bar when Shorts are being played. RenderBottomNavigationBarParentFingerprint.result?.let { if (!RenderBottomNavigationBarFingerprint.resolve(context, it.classDef)) - throw RenderBottomNavigationBarFingerprint.toErrorResult() + throw RenderBottomNavigationBarFingerprint.exception RenderBottomNavigationBarFingerprint.result!!.mutableMethod.apply { addInstruction(0, "invoke-static { }, $FILTER_CLASS_DESCRIPTOR->hideNavigationBar()V") } - } ?: throw RenderBottomNavigationBarParentFingerprint.toErrorResult() + } ?: throw RenderBottomNavigationBarParentFingerprint.exception // Required to prevent a black bar from appearing at the bottom of the screen. BottomNavigationBarFingerprint.result?.let { @@ -117,7 +117,7 @@ class HideShortsComponentsPatch : BytecodePatch( "hideNavigationBar(Landroid/view/View;)Landroid/view/View;" ) } - } ?: throw BottomNavigationBarFingerprint.toErrorResult() + } ?: throw BottomNavigationBarFingerprint.exception // endregion } diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/time/patch/HideTimestampPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/time/patch/HideTimestampPatch.kt index 2246e56110..a8efcdcba0 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/time/patch/HideTimestampPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/time/patch/HideTimestampPatch.kt @@ -1,6 +1,6 @@ package app.revanced.patches.youtube.layout.hide.time.patch -import app.revanced.extensions.toErrorResult +import app.revanced.extensions.exception import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.data.BytecodeContext @@ -47,6 +47,6 @@ class HideTimestampPatch : BytecodePatch( nop """ ) - } ?: throw TimeCounterFingerprint.toErrorResult() + } ?: throw TimeCounterFingerprint.exception } } diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/panels/popup/patch/PlayerPopupPanelsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/panels/popup/patch/PlayerPopupPanelsPatch.kt index 65445b88bb..d9848d0dfa 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/panels/popup/patch/PlayerPopupPanelsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/panels/popup/patch/PlayerPopupPanelsPatch.kt @@ -1,6 +1,6 @@ package app.revanced.patches.youtube.layout.panels.popup.patch -import app.revanced.extensions.toErrorResult +import app.revanced.extensions.exception import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.data.BytecodeContext @@ -36,7 +36,7 @@ class PlayerPopupPanelsPatch : BytecodePatch( ) val engagementPanelControllerMethod = EngagementPanelControllerFingerprint - .result?.mutableMethod ?: throw EngagementPanelControllerFingerprint.toErrorResult() + .result?.mutableMethod ?: throw EngagementPanelControllerFingerprint.exception engagementPanelControllerMethod.addInstructionsWithLabels( 0, diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/patch/ReturnYouTubeDislikePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/patch/ReturnYouTubeDislikePatch.kt index c73db88b4f..9214dd56c0 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/patch/ReturnYouTubeDislikePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/returnyoutubedislike/patch/ReturnYouTubeDislikePatch.kt @@ -1,6 +1,6 @@ package app.revanced.patches.youtube.layout.returnyoutubedislike.patch -import app.revanced.extensions.toErrorResult +import app.revanced.extensions.exception import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.data.BytecodeContext @@ -89,7 +89,7 @@ class ReturnYouTubeDislikePatch : BytecodePatch( ) }.result?.also { result -> if (!TextComponentAtomicReferenceFingerprint.resolve(context, result.method, result.classDef)) - throw TextComponentAtomicReferenceFingerprint.toErrorResult() + throw TextComponentAtomicReferenceFingerprint.exception }?.let { textComponentContextFingerprintResult -> val conversionContextIndex = textComponentContextFingerprintResult .scanResult.patternScanResult!!.startIndex @@ -126,7 +126,7 @@ class ReturnYouTubeDislikePatch : BytecodePatch( """ ) } - } ?: throw TextComponentContextFingerprint.toErrorResult() + } ?: throw TextComponentContextFingerprint.exception // endregion @@ -166,7 +166,7 @@ class ReturnYouTubeDislikePatch : BytecodePatch( """ ) } - } ?: throw ShortsTextViewFingerprint.toErrorResult() + } ?: throw ShortsTextViewFingerprint.exception // endregion @@ -184,7 +184,7 @@ class ReturnYouTubeDislikePatch : BytecodePatch( "invoke-static {v$resourceIdentifierRegister, v$textViewRegister}, $INTEGRATIONS_CLASS_DESCRIPTOR->setOldUILayoutDislikes(ILandroid/widget/TextView;)V" ) } - } ?: throw DislikesOldLayoutTextViewFingerprint.toErrorResult() + } ?: throw DislikesOldLayoutTextViewFingerprint.exception // endregion } diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/searchbar/patch/WideSearchbarPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/searchbar/patch/WideSearchbarPatch.kt index d985edfd23..21dc3495f7 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/searchbar/patch/WideSearchbarPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/searchbar/patch/WideSearchbarPatch.kt @@ -1,6 +1,6 @@ package app.revanced.patches.youtube.layout.searchbar.patch -import app.revanced.extensions.toErrorResult +import app.revanced.extensions.exception import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.data.BytecodeContext @@ -38,7 +38,7 @@ class WideSearchbarPatch : BytecodePatch( ) ) - val result = CreateSearchSuggestionsFingerprint.result ?: throw CreateSearchSuggestionsFingerprint.toErrorResult() + val result = CreateSearchSuggestionsFingerprint.result ?: throw CreateSearchSuggestionsFingerprint.exception // patch methods mapOf( @@ -60,7 +60,7 @@ class WideSearchbarPatch : BytecodePatch( fun BytecodeContext.walkMutable(index: Int, fromFingerprint: MethodFingerprint) = fromFingerprint.result?.let { toMethodWalker(it.method).nextMethod(index, true).getMethod() as MutableMethod - } ?: throw fromFingerprint.toErrorResult() + } ?: throw fromFingerprint.exception /** diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/bytecode/patch/SeekbarColorBytecodePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/bytecode/patch/SeekbarColorBytecodePatch.kt index 2ff0da1a78..065b894b85 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/bytecode/patch/SeekbarColorBytecodePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/seekbar/bytecode/patch/SeekbarColorBytecodePatch.kt @@ -1,7 +1,7 @@ package app.revanced.patches.youtube.layout.seekbar.bytecode.patch import app.revanced.extensions.indexOfFirstConstantInstructionValue -import app.revanced.extensions.toErrorResult +import app.revanced.extensions.exception import app.revanced.patcher.annotation.Description import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.InstructionExtensions.addInstructions @@ -42,11 +42,11 @@ class SeekbarColorBytecodePatch : BytecodePatch( PlayerSeekbarColorFingerprint.result?.mutableMethod?.apply { addColorChangeInstructions(SeekbarColorResourcePatch.inlineTimeBarColorizedBarPlayedColorDarkId) addColorChangeInstructions(SeekbarColorResourcePatch.inlineTimeBarPlayedNotHighlightedColorId) - } ?: throw PlayerSeekbarColorFingerprint.toErrorResult() + } ?: throw PlayerSeekbarColorFingerprint.exception ShortsSeekbarColorFingerprint.result?.mutableMethod?.apply { addColorChangeInstructions(SeekbarColorResourcePatch.reelTimeBarPlayedColorId) - } ?: throw ShortsSeekbarColorFingerprint.toErrorResult() + } ?: throw ShortsSeekbarColorFingerprint.exception SetSeekbarClickedColorFingerprint.result?.let { result -> result.mutableMethod.let { @@ -67,7 +67,7 @@ class SeekbarColorBytecodePatch : BytecodePatch( ) } } - } ?: throw SetSeekbarClickedColorFingerprint.toErrorResult() + } ?: throw SetSeekbarClickedColorFingerprint.exception lithoColorOverrideHook(INTEGRATIONS_CLASS_DESCRIPTOR, "getLithoColor") } diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/bytecode/patch/SponsorBlockBytecodePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/bytecode/patch/SponsorBlockBytecodePatch.kt index 12d0ebc9f3..88d4489d4e 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/bytecode/patch/SponsorBlockBytecodePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/sponsorblock/bytecode/patch/SponsorBlockBytecodePatch.kt @@ -1,6 +1,6 @@ package app.revanced.patches.youtube.layout.sponsorblock.bytecode.patch -import app.revanced.extensions.toErrorResult +import app.revanced.extensions.exception import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.data.BytecodeContext @@ -64,8 +64,8 @@ class SponsorBlockBytecodePatch : BytecodePatch( override fun execute(context: BytecodeContext) { LayoutConstructorFingerprint.result?.let { if (!ControlsOverlayFingerprint.resolve(context, it.classDef)) - throw ControlsOverlayFingerprint.toErrorResult() - } ?: throw LayoutConstructorFingerprint.toErrorResult() + throw ControlsOverlayFingerprint.exception + } ?: throw LayoutConstructorFingerprint.exception /* * Hook the video time methods @@ -219,7 +219,7 @@ class SponsorBlockBytecodePatch : BytecodePatch( "invoke-static {v$frameLayoutRegister}, $INTEGRATIONS_SPONSORBLOCK_VIEW_CONTROLLER_CLASS_DESCRIPTOR->initialize(Landroid/view/ViewGroup;)V" ) } - } ?: throw ControlsOverlayFingerprint.toErrorResult() + } ?: throw ControlsOverlayFingerprint.exception // get rectangle field name RectangleFieldInvalidatorFingerprint.resolve(context, seekbarSignatureResult.classDef) @@ -258,13 +258,13 @@ class SponsorBlockBytecodePatch : BytecodePatch( // The vote and create segment buttons automatically change their visibility when appropriate, // but if buttons are showing when the end of the video is reached then they will not automatically hide. // Add a hook to forcefully hide when the end of the video is reached. - AutoRepeatParentFingerprint.result ?: throw AutoRepeatParentFingerprint.toErrorResult() + AutoRepeatParentFingerprint.result ?: throw AutoRepeatParentFingerprint.exception AutoRepeatFingerprint.also { it.resolve(context, AutoRepeatParentFingerprint.result!!.classDef) }.result?.mutableMethod?.addInstruction( 0, "invoke-static {}, $INTEGRATIONS_SPONSORBLOCK_VIEW_CONTROLLER_CLASS_DESCRIPTOR->endOfVideoReached()V" - ) ?: throw AutoRepeatFingerprint.toErrorResult() + ) ?: throw AutoRepeatFingerprint.exception // TODO: isSBChannelWhitelisting implementation } diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/spoofappversion/bytecode/patch/SpoofAppVersionPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/spoofappversion/bytecode/patch/SpoofAppVersionPatch.kt index bb67d77d37..135676df06 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/spoofappversion/bytecode/patch/SpoofAppVersionPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/spoofappversion/bytecode/patch/SpoofAppVersionPatch.kt @@ -1,6 +1,6 @@ package app.revanced.patches.youtube.layout.spoofappversion.bytecode.patch -import app.revanced.extensions.toErrorResult +import app.revanced.extensions.exception import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.data.BytecodeContext @@ -77,7 +77,7 @@ class SpoofAppVersionPatch : BytecodePatch( move-result-object v$buildOverrideNameRegister """ ) - } ?: throw SpoofAppVersionFingerprint.toErrorResult() + } ?: throw SpoofAppVersionFingerprint.exception } private companion object { diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/tabletminiplayer/patch/TabletMiniPlayerPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/tabletminiplayer/patch/TabletMiniPlayerPatch.kt index 9633ab962d..9e4cfe8dd0 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/tabletminiplayer/patch/TabletMiniPlayerPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/tabletminiplayer/patch/TabletMiniPlayerPatch.kt @@ -1,6 +1,6 @@ package app.revanced.patches.youtube.layout.tabletminiplayer.patch -import app.revanced.extensions.toErrorResult +import app.revanced.extensions.exception import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.data.BytecodeContext @@ -47,7 +47,7 @@ class TabletMiniPlayerPatch : BytecodePatch( ) // First resolve the fingerprints via the parent fingerprint. - MiniPlayerDimensionsCalculatorParentFingerprint.result ?: throw MiniPlayerDimensionsCalculatorParentFingerprint.toErrorResult() + MiniPlayerDimensionsCalculatorParentFingerprint.result ?: throw MiniPlayerDimensionsCalculatorParentFingerprint.exception val miniPlayerClass = MiniPlayerDimensionsCalculatorParentFingerprint.result!!.classDef /* @@ -89,7 +89,7 @@ class TabletMiniPlayerPatch : BytecodePatch( } return@let - } ?: throw MiniPlayerOverrideFingerprint.toErrorResult() + } ?: throw MiniPlayerOverrideFingerprint.exception /* * Size check return value override. diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/theme/bytecode/patch/LithoColorHookPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/theme/bytecode/patch/LithoColorHookPatch.kt index 826e155e5d..c253da7892 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/theme/bytecode/patch/LithoColorHookPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/theme/bytecode/patch/LithoColorHookPatch.kt @@ -1,6 +1,6 @@ package app.revanced.patches.youtube.layout.theme.bytecode.patch -import app.revanced.extensions.toErrorResult +import app.revanced.extensions.exception import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.data.BytecodeContext @@ -19,7 +19,7 @@ class LithoColorHookPatch : BytecodePatch(listOf(LithoThemeFingerprint)) { insertionIndex = it.scanResult.patternScanResult!!.endIndex - 1 colorRegister = "p1" insertionMethod = it.mutableMethod - } ?: throw LithoThemeFingerprint.toErrorResult() + } ?: throw LithoThemeFingerprint.exception } companion object { private var insertionIndex : Int = -1 diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/thumbnails/patch/AlternativeThumbnailsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/thumbnails/patch/AlternativeThumbnailsPatch.kt index 18ba5eb080..b841660112 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/thumbnails/patch/AlternativeThumbnailsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/thumbnails/patch/AlternativeThumbnailsPatch.kt @@ -1,6 +1,6 @@ package app.revanced.patches.youtube.layout.thumbnails.patch -import app.revanced.extensions.toErrorResult +import app.revanced.extensions.exception import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.data.BytecodeContext @@ -73,23 +73,23 @@ class AlternativeThumbnailsPatch : BytecodePatch( ) MessageDigestImageUrlParentFingerprint.result - ?: throw MessageDigestImageUrlParentFingerprint.toErrorResult() + ?: throw MessageDigestImageUrlParentFingerprint.exception MessageDigestImageUrlFingerprint.resolve(context, MessageDigestImageUrlParentFingerprint.result!!.classDef) MessageDigestImageUrlFingerprint.result?.apply { loadImageUrlMethod = mutableMethod - } ?: throw MessageDigestImageUrlFingerprint.toErrorResult() + } ?: throw MessageDigestImageUrlFingerprint.exception addImageUrlHook(INTEGRATIONS_CLASS_DESCRIPTOR, true) CronetURLRequestCallbackOnResponseStartedFingerprint.result - ?: throw CronetURLRequestCallbackOnResponseStartedFingerprint.toErrorResult() + ?: throw CronetURLRequestCallbackOnResponseStartedFingerprint.exception CronetURLRequestCallbackOnSucceededFingerprint.resolve( context, CronetURLRequestCallbackOnResponseStartedFingerprint.result!!.classDef ) CronetURLRequestCallbackOnSucceededFingerprint.result?.apply { loadImageSuccessCallbackMethod = mutableMethod - } ?: throw CronetURLRequestCallbackOnSucceededFingerprint.toErrorResult() + } ?: throw CronetURLRequestCallbackOnSucceededFingerprint.exception addImageUrlSuccessCallbackHook(INTEGRATIONS_CLASS_DESCRIPTOR) @@ -99,7 +99,7 @@ class AlternativeThumbnailsPatch : BytecodePatch( ) CronetURLRequestCallbackOnFailureFingerprint.result?.apply { loadImageErrorCallbackMethod = mutableMethod - } ?: throw CronetURLRequestCallbackOnFailureFingerprint.toErrorResult() + } ?: throw CronetURLRequestCallbackOnFailureFingerprint.exception } internal companion object { diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/bottomsheet/hook/patch/BottomSheetHookPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/bottomsheet/hook/patch/BottomSheetHookPatch.kt index f197c578d0..2084360aec 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/bottomsheet/hook/patch/BottomSheetHookPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/bottomsheet/hook/patch/BottomSheetHookPatch.kt @@ -1,6 +1,6 @@ package app.revanced.patches.youtube.misc.bottomsheet.hook.patch -import app.revanced.extensions.toErrorResult +import app.revanced.extensions.exception import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.InstructionExtensions.addInstruction import app.revanced.patcher.extensions.InstructionExtensions.getInstruction @@ -29,7 +29,7 @@ class BottomSheetHookPatch : BytecodePatch( ) } } - } ?: throw CreateBottomSheetFingerprint.toErrorResult() + } ?: throw CreateBottomSheetFingerprint.exception } internal companion object { diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/fix/backtoexitgesture/patch/FixBackToExitGesturePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/fix/backtoexitgesture/patch/FixBackToExitGesturePatch.kt index 81f46eedd2..19265655ba 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/fix/backtoexitgesture/patch/FixBackToExitGesturePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/fix/backtoexitgesture/patch/FixBackToExitGesturePatch.kt @@ -1,6 +1,6 @@ package app.revanced.patches.youtube.misc.fix.backtoexitgesture.patch -import app.revanced.extensions.toErrorResult +import app.revanced.extensions.exception import app.revanced.patcher.annotation.Description import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.InstructionExtensions.addInstruction @@ -27,7 +27,7 @@ class FixBackToExitGesturePatch : BytecodePatch( resolve( context, RecyclerViewTopScrollingParentFingerprint.result?.classDef - ?: throw RecyclerViewTopScrollingParentFingerprint.toErrorResult() + ?: throw RecyclerViewTopScrollingParentFingerprint.exception ) } @@ -68,6 +68,6 @@ class FixBackToExitGesturePatch : BytecodePatch( mutableMethod.addInstruction( scanResult.patternScanResult!!.endIndex, targetMethod.toString() ) - } ?: throw this.toErrorResult() + } ?: throw this.exception } } \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/fix/playback/patch/ClientSpoofPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/fix/playback/patch/ClientSpoofPatch.kt index 2135488cc3..5d8f76736b 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/fix/playback/patch/ClientSpoofPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/fix/playback/patch/ClientSpoofPatch.kt @@ -1,6 +1,6 @@ package app.revanced.patches.youtube.misc.fix.playback.patch -import app.revanced.extensions.toErrorResult +import app.revanced.extensions.exception import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.data.BytecodeContext @@ -30,7 +30,7 @@ class ClientSpoofPatch : BytecodePatch( addInstruction(insertIndex, "const-string v$packageNameRegister, \"$ORIGINAL_PACKAGE_NAME\"") } - } ?: throw UserAgentHeaderBuilderFingerprint.toErrorResult() + } ?: throw UserAgentHeaderBuilderFingerprint.exception } private companion object { diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/fix/playback/patch/SpoofSignatureVerificationPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/fix/playback/patch/SpoofSignatureVerificationPatch.kt index 4c8dee847e..a7b74c007a 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/fix/playback/patch/SpoofSignatureVerificationPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/fix/playback/patch/SpoofSignatureVerificationPatch.kt @@ -1,6 +1,6 @@ package app.revanced.patches.youtube.misc.fix.playback.patch -import app.revanced.extensions.toErrorResult +import app.revanced.extensions.exception import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.data.BytecodeContext @@ -52,14 +52,14 @@ class SpoofSignatureVerificationPatch : BytecodePatch( """ ) } - } ?: throw ProtobufParameterBuilderFingerprint.toErrorResult() + } ?: throw ProtobufParameterBuilderFingerprint.exception // When signature spoofing is enabled, the seekbar when tapped does not show // the video time, chapter names, or the video thumbnail. // Changing the value returned of this method forces all of these to show up, // except the thumbnails are blank, which is handled with the patch below. - StoryboardThumbnailParentFingerprint.result ?: throw StoryboardThumbnailParentFingerprint.toErrorResult() + StoryboardThumbnailParentFingerprint.result ?: throw StoryboardThumbnailParentFingerprint.exception StoryboardThumbnailFingerprint.resolve(context, StoryboardThumbnailParentFingerprint.result!!.classDef) StoryboardThumbnailFingerprint.result?.apply { val endIndex = scanResult.patternScanResult!!.endIndex @@ -81,7 +81,7 @@ class SpoofSignatureVerificationPatch : BytecodePatch( return v0 """ ) - } ?: throw StoryboardThumbnailFingerprint.toErrorResult() + } ?: throw StoryboardThumbnailFingerprint.exception // Seekbar thumbnail now show up but are always a blank image. @@ -99,7 +99,7 @@ class SpoofSignatureVerificationPatch : BytecodePatch( """ ) } - } ?: throw ScrubbedPreviewLayoutFingerprint.toErrorResult() + } ?: throw ScrubbedPreviewLayoutFingerprint.exception } private companion object { diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/links/open/patch/OpenLinksExternallyPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/links/open/patch/OpenLinksExternallyPatch.kt index 7323c0f418..ebcd823b3d 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/links/open/patch/OpenLinksExternallyPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/links/open/patch/OpenLinksExternallyPatch.kt @@ -1,6 +1,6 @@ package app.revanced.patches.youtube.misc.links.open.patch -import app.revanced.extensions.toErrorResult +import app.revanced.extensions.exception import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.data.BytecodeContext @@ -42,7 +42,7 @@ class OpenLinksExternallyPatch : BytecodePatch( BindSessionServiceFingerprint, InitializeCustomTabSupportFingerprint ).forEach { - val result = it.result ?: throw it.toErrorResult() + val result = it.result ?: throw it.exception val insertIndex = result.scanResult.patternScanResult!!.endIndex + 1 with(result.mutableMethod) { val register = (implementation!!.instructions[insertIndex - 1] as Instruction21c).registerA diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/litho/filter/patch/LithoFilterPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/litho/filter/patch/LithoFilterPatch.kt index ece9c0c029..99b2474e20 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/litho/filter/patch/LithoFilterPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/litho/filter/patch/LithoFilterPatch.kt @@ -1,6 +1,6 @@ package app.revanced.patches.youtube.misc.litho.filter.patch -import app.revanced.extensions.toErrorResult +import app.revanced.extensions.exception import app.revanced.patcher.annotation.Description import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.InstructionExtensions.addInstruction @@ -66,7 +66,7 @@ class LithoFilterPatch : BytecodePatch( ReadComponentIdentifierFingerprint ).forEach { fingerprint -> if (fingerprint.resolve(context, it.mutableMethod, it.mutableClass)) return@forEach - throw fingerprint.toErrorResult() + throw fingerprint.exception } }?.let { bytesToComponentContextMethod -> @@ -75,7 +75,7 @@ class LithoFilterPatch : BytecodePatch( ProtobufBufferReferenceFingerprint.result ?.mutableMethod?.addInstruction(0, " invoke-static { p2 }, $INTEGRATIONS_CLASS_DESCRIPTOR->setProtoBuffer(Ljava/nio/ByteBuffer;)V") - ?: throw ProtobufBufferReferenceFingerprint.toErrorResult() + ?: throw ProtobufBufferReferenceFingerprint.exception // endregion @@ -141,7 +141,7 @@ class LithoFilterPatch : BytecodePatch( } // endregion - } ?: throw ComponentContextParserFingerprint.toErrorResult() + } ?: throw ComponentContextParserFingerprint.exception LithoFilterFingerprint.result?.mutableMethod?.apply { removeInstructions(2, 4) // Remove dummy filter. @@ -157,7 +157,7 @@ class LithoFilterPatch : BytecodePatch( """ ) } - } ?: throw LithoFilterFingerprint.toErrorResult() + } ?: throw LithoFilterFingerprint.exception } override fun close() = LithoFilterFingerprint.result!! diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/minimizedplayback/patch/MinimizedPlaybackPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/minimizedplayback/patch/MinimizedPlaybackPatch.kt index 117e96b3c3..7c3cd333f4 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/minimizedplayback/patch/MinimizedPlaybackPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/minimizedplayback/patch/MinimizedPlaybackPatch.kt @@ -1,6 +1,6 @@ package app.revanced.patches.youtube.misc.minimizedplayback.patch -import app.revanced.extensions.toErrorResult +import app.revanced.extensions.exception import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.data.BytecodeContext @@ -54,10 +54,10 @@ class MinimizedPlaybackPatch : BytecodePatch( return v0 """ ) - } ?: throw MinimizedPlaybackManagerFingerprint.toErrorResult() + } ?: throw MinimizedPlaybackManagerFingerprint.exception // Enable minimized playback option in YouTube settings - MinimizedPlaybackSettingsParentFingerprint.result ?: throw MinimizedPlaybackSettingsParentFingerprint.toErrorResult() + MinimizedPlaybackSettingsParentFingerprint.result ?: throw MinimizedPlaybackSettingsParentFingerprint.exception MinimizedPlaybackSettingsFingerprint.resolve(context, MinimizedPlaybackSettingsParentFingerprint.result!!.classDef) MinimizedPlaybackSettingsFingerprint.result?.apply { val booleanCalls = method.implementation!!.instructions.withIndex() @@ -75,7 +75,7 @@ class MinimizedPlaybackPatch : BytecodePatch( return v0 """ ) - } ?: throw MinimizedPlaybackSettingsFingerprint.toErrorResult() + } ?: throw MinimizedPlaybackSettingsFingerprint.exception // Force allowing background play for videos labeled for kids. // Some regions and YouTube accounts do not require this patch. @@ -84,7 +84,7 @@ class MinimizedPlaybackPatch : BytecodePatch( 0, "return-void" ) - } ?: throw KidsMinimizedPlaybackPolicyControllerFingerprint.toErrorResult() + } ?: throw KidsMinimizedPlaybackPolicyControllerFingerprint.exception } private companion object { diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/playercontrols/bytecode/patch/PlayerControlsBytecodePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/playercontrols/bytecode/patch/PlayerControlsBytecodePatch.kt index 924e1b247a..095a510dec 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/playercontrols/bytecode/patch/PlayerControlsBytecodePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/playercontrols/bytecode/patch/PlayerControlsBytecodePatch.kt @@ -1,6 +1,6 @@ package app.revanced.patches.youtube.misc.playercontrols.bytecode.patch -import app.revanced.extensions.toErrorResult +import app.revanced.extensions.exception import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.data.BytecodeContext @@ -29,8 +29,8 @@ class PlayerControlsBytecodePatch : BytecodePatch( override fun execute(context: BytecodeContext) { LayoutConstructorFingerprint.result?.let { if (!PlayerControlsVisibilityFingerprint.resolve(context, it.classDef)) - throw LayoutConstructorFingerprint.toErrorResult() - } ?: throw LayoutConstructorFingerprint.toErrorResult() + throw LayoutConstructorFingerprint.exception + } ?: throw LayoutConstructorFingerprint.exception showPlayerControlsFingerprintResult = PlayerControlsVisibilityFingerprint.result!! inflateFingerprintResult = BottomControlsInflateFingerprint.result!! diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/playertype/patch/PlayerTypeHookPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/playertype/patch/PlayerTypeHookPatch.kt index 48026b53e8..c64ddfccdc 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/playertype/patch/PlayerTypeHookPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/playertype/patch/PlayerTypeHookPatch.kt @@ -1,6 +1,6 @@ package app.revanced.patches.youtube.misc.playertype.patch -import app.revanced.extensions.toErrorResult +import app.revanced.extensions.exception import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.data.BytecodeContext @@ -24,7 +24,7 @@ class PlayerTypeHookPatch : BytecodePatch( PlayerTypeFingerprint.result?.mutableMethod?.addInstruction( 0, "invoke-static {p1}, $INTEGRATIONS_CLASS_DESCRIPTOR->setPlayerType(Ljava/lang/Enum;)V" - ) ?: throw PlayerTypeFingerprint.toErrorResult() + ) ?: throw PlayerTypeFingerprint.exception VideoStateFingerprint.result?.let { it.mutableMethod.apply { @@ -39,7 +39,7 @@ class PlayerTypeHookPatch : BytecodePatch( """ ) } - } ?: throw VideoStateFingerprint.toErrorResult() + } ?: throw VideoStateFingerprint.exception } companion object { diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/settings/bytecode/patch/SettingsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/settings/bytecode/patch/SettingsPatch.kt index c583373f0d..6f3db49fd7 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/settings/bytecode/patch/SettingsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/settings/bytecode/patch/SettingsPatch.kt @@ -1,6 +1,6 @@ package app.revanced.patches.youtube.misc.settings.bytecode.patch -import app.revanced.extensions.toErrorResult +import app.revanced.extensions.exception import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.data.BytecodeContext @@ -55,7 +55,7 @@ class SettingsPatch : BytecodePatch( addInstruction(returnIndex + 1, "return-object v0") } } - } ?: throw SetThemeFingerprint.toErrorResult() + } ?: throw SetThemeFingerprint.exception // Modify the license activity and remove all existing layout code. diff --git a/src/main/kotlin/app/revanced/patches/youtube/video/information/patch/VideoInformationPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/video/information/patch/VideoInformationPatch.kt index 458aaf87f7..ea744ef5b3 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/video/information/patch/VideoInformationPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/video/information/patch/VideoInformationPatch.kt @@ -1,6 +1,6 @@ package app.revanced.patches.youtube.video.information.patch -import app.revanced.extensions.toErrorResult +import app.revanced.extensions.exception import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.data.BytecodeContext @@ -133,7 +133,7 @@ class VideoInformationPatch : BytecodePatch( getReference(speedSelectionMethodInstructions, 1, Opcode.IGET) setPlaybackSpeedMethodReference = getReference(speedSelectionMethodInstructions, 2, Opcode.IGET) - } ?: throw OnPlaybackSpeedItemClickFingerprint.toErrorResult() + } ?: throw OnPlaybackSpeedItemClickFingerprint.exception userSelectedPlaybackSpeedHook(INTEGRATIONS_CLASS_DESCRIPTOR, "userSelectedPlaybackSpeed") } diff --git a/src/main/kotlin/app/revanced/patches/youtube/video/quality/patch/RememberVideoQualityPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/video/quality/patch/RememberVideoQualityPatch.kt index f96b19c593..a90246bd74 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/video/quality/patch/RememberVideoQualityPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/video/quality/patch/RememberVideoQualityPatch.kt @@ -1,6 +1,6 @@ package app.revanced.patches.youtube.video.quality.patch -import app.revanced.extensions.toErrorResult +import app.revanced.extensions.exception import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.data.BytecodeContext @@ -158,7 +158,7 @@ class RememberVideoQualityPatch : BytecodePatch( move-result p2 """, ) - } ?: throw VideoQualitySetterFingerprint.toErrorResult() + } ?: throw VideoQualitySetterFingerprint.exception // Inject a call to remember the selected quality. @@ -173,7 +173,7 @@ class RememberVideoQualityPatch : BytecodePatch( "invoke-static {p$listItemIndexParameter}, $INTEGRATIONS_CLASS_DESCRIPTOR->userChangedQuality(I)V" ) } ?: throw PatchException("Failed to find onItemClick method") - } ?: throw VideoQualityItemOnClickParentFingerprint.toErrorResult() + } ?: throw VideoQualityItemOnClickParentFingerprint.exception // Remember video quality if not using old layout menu. @@ -187,7 +187,7 @@ class RememberVideoQualityPatch : BytecodePatch( "invoke-static {v$qualityRegister}, $INTEGRATIONS_CLASS_DESCRIPTOR->userChangedQualityInNewFlyout(I)V" ) } - } ?: throw NewVideoQualityChangedFingerprint.toErrorResult() + } ?: throw NewVideoQualityChangedFingerprint.exception } diff --git a/src/main/kotlin/app/revanced/patches/youtube/video/speed/custom/patch/CustomPlaybackSpeedPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/video/speed/custom/patch/CustomPlaybackSpeedPatch.kt index 74eb5f2474..befcebc3b5 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/video/speed/custom/patch/CustomPlaybackSpeedPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/video/speed/custom/patch/CustomPlaybackSpeedPatch.kt @@ -1,6 +1,6 @@ package app.revanced.patches.youtube.video.speed.custom.patch -import app.revanced.extensions.toErrorResult +import app.revanced.extensions.exception import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.data.BytecodeContext @@ -156,7 +156,7 @@ class CustomPlaybackSpeedPatch : BytecodePatch( // This is later called on the field INSTANCE. val showOldPlaybackSpeedMenuMethod = ShowOldPlaybackSpeedMenuFingerprint.also { if (!it.resolve(context, result.classDef)) - throw ShowOldPlaybackSpeedMenuFingerprint.toErrorResult() + throw ShowOldPlaybackSpeedMenuFingerprint.exception }.result!!.method.toString() // Insert the call to the "showOldPlaybackSpeedMenu" method on the field INSTANCE. @@ -171,8 +171,8 @@ class CustomPlaybackSpeedPatch : BytecodePatch( invoke-virtual { v0 }, $showOldPlaybackSpeedMenuMethod """ ) - } ?: throw ShowOldPlaybackSpeedMenuIntegrationsFingerprint.toErrorResult() - } ?: throw GetOldPlaybackSpeedsFingerprint.toErrorResult() + } ?: throw ShowOldPlaybackSpeedMenuIntegrationsFingerprint.exception + } ?: throw GetOldPlaybackSpeedsFingerprint.exception // endregion } diff --git a/src/main/kotlin/app/revanced/patches/youtube/video/speed/remember/patch/RememberPlaybackSpeedPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/video/speed/remember/patch/RememberPlaybackSpeedPatch.kt index 368aa18d97..5b274d461c 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/video/speed/remember/patch/RememberPlaybackSpeedPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/video/speed/remember/patch/RememberPlaybackSpeedPatch.kt @@ -1,6 +1,6 @@ package app.revanced.patches.youtube.video.speed.remember.patch -import app.revanced.extensions.toErrorResult +import app.revanced.extensions.exception import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.data.BytecodeContext @@ -103,7 +103,7 @@ class RememberPlaybackSpeedPatch : BytecodePatch( """.trimIndent(), ExternalLabel("do_not_override", mutableMethod.getInstruction(0)) ) - } ?: throw InitializePlaybackSpeedValuesFingerprint.toErrorResult() + } ?: throw InitializePlaybackSpeedValuesFingerprint.exception } private companion object { diff --git a/src/main/kotlin/app/revanced/patches/youtube/video/videoid/patch/VideoIdPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/video/videoid/patch/VideoIdPatch.kt index 2f13f5c620..adf5a6153d 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/video/videoid/patch/VideoIdPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/video/videoid/patch/VideoIdPatch.kt @@ -1,6 +1,6 @@ package app.revanced.patches.youtube.video.videoid.patch -import app.revanced.extensions.toErrorResult +import app.revanced.extensions.exception import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.data.BytecodeContext @@ -38,7 +38,7 @@ class VideoIdPatch : BytecodePatch( consumer(it, insertIndex, videoIdRegister) } - } ?: throw VideoIdFingerprint.toErrorResult() + } ?: throw VideoIdFingerprint.exception VideoIdFingerprint.setFields { method, insertIndex, videoIdRegister -> insertMethod = method diff --git a/src/main/kotlin/app/revanced/patches/youtubevanced/ad/general/patch/HideAdsPatch.kt b/src/main/kotlin/app/revanced/patches/youtubevanced/ad/general/patch/HideAdsPatch.kt index 2255c47539..bf96a84493 100644 --- a/src/main/kotlin/app/revanced/patches/youtubevanced/ad/general/patch/HideAdsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtubevanced/ad/general/patch/HideAdsPatch.kt @@ -1,6 +1,6 @@ package app.revanced.patches.youtubevanced.ad.general.patch -import app.revanced.extensions.toErrorResult +import app.revanced.extensions.exception import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Name import app.revanced.patcher.data.BytecodeContext @@ -54,6 +54,6 @@ class HideAdsPatch : BytecodePatch( ) } } - } ?: throw ContainsAdFingerprint.toErrorResult() + } ?: throw ContainsAdFingerprint.exception } } diff --git a/src/main/kotlin/app/revanced/util/microg/MicroGBytecodeHelper.kt b/src/main/kotlin/app/revanced/util/microg/MicroGBytecodeHelper.kt index a7606fca7f..d6d1bb9e04 100644 --- a/src/main/kotlin/app/revanced/util/microg/MicroGBytecodeHelper.kt +++ b/src/main/kotlin/app/revanced/util/microg/MicroGBytecodeHelper.kt @@ -1,6 +1,6 @@ package app.revanced.util.microg -import app.revanced.extensions.toErrorResult +import app.revanced.extensions.exception import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.InstructionExtensions.addInstruction import app.revanced.patcher.extensions.InstructionExtensions.addInstructions @@ -237,7 +237,7 @@ internal object MicroGBytecodeHelper { result.mutableMethod.addInstructions( 0, stringInstructions ) - } ?: throw fingerprint.toErrorResult() + } ?: throw fingerprint.exception } } } diff --git a/src/main/kotlin/app/revanced/util/resources/ResourceUtils.kt b/src/main/kotlin/app/revanced/util/resources/ResourceUtils.kt index 6bee9e6dce..03ec8e91a3 100644 --- a/src/main/kotlin/app/revanced/util/resources/ResourceUtils.kt +++ b/src/main/kotlin/app/revanced/util/resources/ResourceUtils.kt @@ -12,6 +12,7 @@ internal object ResourceUtils { /** * Merge strings. This manages [StringResource]s automatically. + * * @param host The hosting xml resource. Needs to be a valid strings.xml resource. */ internal fun ResourceContext.mergeStrings(host: String) {