fix(Reddit - Disable screenshot popup): No exception is thrown if no matching pattern is found

This commit is contained in:
inotia00 2025-04-03 10:18:02 +09:00
parent 2b52380294
commit 7168e49121

View File

@ -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