From 7168e49121ca4ba2a995f43cf3e322f726575e6d Mon Sep 17 00:00:00 2001 From: inotia00 <108592928+inotia00@users.noreply.github.com> Date: Thu, 3 Apr 2025 10:18:02 +0900 Subject: [PATCH] fix(Reddit - Disable screenshot popup): No exception is thrown if no matching pattern is found --- .../reddit/layout/screenshotpopup/ScreenshotPopupPatch.kt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/patches/src/main/kotlin/app/revanced/patches/reddit/layout/screenshotpopup/ScreenshotPopupPatch.kt b/patches/src/main/kotlin/app/revanced/patches/reddit/layout/screenshotpopup/ScreenshotPopupPatch.kt index 4c4653142..096fa09be 100644 --- a/patches/src/main/kotlin/app/revanced/patches/reddit/layout/screenshotpopup/ScreenshotPopupPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/reddit/layout/screenshotpopup/ScreenshotPopupPatch.kt @@ -2,6 +2,7 @@ package app.revanced.patches.reddit.layout.screenshotpopup import app.revanced.patcher.extensions.InstructionExtensions.addInstructions import app.revanced.patcher.extensions.InstructionExtensions.getInstruction +import app.revanced.patcher.patch.PatchException import app.revanced.patcher.patch.bytecodePatch import app.revanced.patches.reddit.utils.compatibility.Constants.COMPATIBLE_PACKAGE import app.revanced.patches.reddit.utils.extension.Constants.PATCHES_PATH @@ -57,6 +58,8 @@ val screenshotPopupPatch = bytecodePatch( indexOfSetValueInstruction(this) >= 0 } + var hookCount = 0 + classes.forEach { classDef -> classDef.methods.forEach { method -> if (method.isScreenShotMethod()) { @@ -75,11 +78,16 @@ val screenshotPopupPatch = bytecodePatch( move-result-object v$booleanRegister """ ) + hookCount++ } } } } + if (hookCount == 0) { + throw PatchException("Failed to find hook method") + } + updatePatchStatus( "enableScreenshotPopup", DISABLE_SCREENSHOT_POPUP