mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-05-02 07:34:31 +02:00
fix(Reddit - Disable screenshot popup): Screenshot popup not being completely removed https://github.com/inotia00/ReVanced_Extended/issues/1810
This commit is contained in:
parent
56d2f7c4ad
commit
21be41c2a9
@ -1,36 +1,15 @@
|
|||||||
package app.revanced.patches.reddit.layout.screenshotpopup
|
package app.revanced.patches.reddit.layout.screenshotpopup
|
||||||
|
|
||||||
import app.revanced.patches.reddit.utils.resourceid.screenShotShareBanner
|
|
||||||
import app.revanced.util.containsLiteralInstruction
|
|
||||||
import app.revanced.util.fingerprint.legacyFingerprint
|
import app.revanced.util.fingerprint.legacyFingerprint
|
||||||
import com.android.tools.smali.dexlib2.Opcode
|
import app.revanced.util.or
|
||||||
|
import com.android.tools.smali.dexlib2.AccessFlags
|
||||||
|
|
||||||
/**
|
internal val screenshotBannerContainerFingerprint = legacyFingerprint(
|
||||||
* Reddit 2025.06.0 ~
|
|
||||||
*/
|
|
||||||
internal val screenshotTakenBannerFingerprint = legacyFingerprint(
|
|
||||||
name = "screenshotTakenBannerFingerprint",
|
name = "screenshotTakenBannerFingerprint",
|
||||||
returnType = "L",
|
|
||||||
opcodes = listOf(
|
|
||||||
Opcode.CONST_4,
|
|
||||||
Opcode.IF_NE,
|
|
||||||
),
|
|
||||||
customFingerprint = { method, classDef ->
|
|
||||||
method.containsLiteralInstruction(screenShotShareBanner) &&
|
|
||||||
classDef.type.startsWith("Lcom/reddit/sharing/screenshot/composables/") &&
|
|
||||||
method.name == "invoke"
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ~ Reddit 2025.05.1
|
|
||||||
*/
|
|
||||||
internal val screenshotTakenBannerLegacyFingerprint = legacyFingerprint(
|
|
||||||
name = "screenshotTakenBannerLegacyFingerprint",
|
|
||||||
returnType = "V",
|
returnType = "V",
|
||||||
parameters = listOf("Landroidx/compose/runtime/", "I"),
|
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||||
customFingerprint = { method, classDef ->
|
strings = listOf(
|
||||||
classDef.type.endsWith("\$ScreenshotTakenBannerKt\$lambda-1\$1;") &&
|
"bannerContainer",
|
||||||
method.name == "invoke"
|
"scope",
|
||||||
}
|
)
|
||||||
)
|
)
|
||||||
|
@ -2,22 +2,26 @@ package app.revanced.patches.reddit.layout.screenshotpopup
|
|||||||
|
|
||||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels
|
import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels
|
||||||
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
||||||
|
import app.revanced.patcher.patch.PatchException
|
||||||
import app.revanced.patcher.patch.bytecodePatch
|
import app.revanced.patcher.patch.bytecodePatch
|
||||||
|
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
|
||||||
import app.revanced.patcher.util.smali.ExternalLabel
|
import app.revanced.patcher.util.smali.ExternalLabel
|
||||||
import app.revanced.patches.reddit.utils.compatibility.Constants.COMPATIBLE_PACKAGE
|
import app.revanced.patches.reddit.utils.compatibility.Constants.COMPATIBLE_PACKAGE
|
||||||
import app.revanced.patches.reddit.utils.extension.Constants.PATCHES_PATH
|
import app.revanced.patches.reddit.utils.extension.Constants.PATCHES_PATH
|
||||||
import app.revanced.patches.reddit.utils.patch.PatchList.DISABLE_SCREENSHOT_POPUP
|
import app.revanced.patches.reddit.utils.patch.PatchList.DISABLE_SCREENSHOT_POPUP
|
||||||
import app.revanced.patches.reddit.utils.resourceid.screenShotShareBanner
|
|
||||||
import app.revanced.patches.reddit.utils.resourceid.sharedResourceIdPatch
|
|
||||||
import app.revanced.patches.reddit.utils.settings.is_2025_06_or_greater
|
|
||||||
import app.revanced.patches.reddit.utils.settings.settingsPatch
|
import app.revanced.patches.reddit.utils.settings.settingsPatch
|
||||||
import app.revanced.patches.reddit.utils.settings.updatePatchStatus
|
import app.revanced.patches.reddit.utils.settings.updatePatchStatus
|
||||||
|
import app.revanced.util.findMutableMethodOf
|
||||||
|
import app.revanced.util.fingerprint.methodCall
|
||||||
import app.revanced.util.fingerprint.methodOrThrow
|
import app.revanced.util.fingerprint.methodOrThrow
|
||||||
|
import app.revanced.util.getReference
|
||||||
|
import app.revanced.util.indexOfFirstInstruction
|
||||||
import app.revanced.util.indexOfFirstInstructionOrThrow
|
import app.revanced.util.indexOfFirstInstructionOrThrow
|
||||||
import app.revanced.util.indexOfFirstInstructionReversedOrThrow
|
import app.revanced.util.indexOfFirstStringInstruction
|
||||||
import app.revanced.util.indexOfFirstLiteralInstructionOrThrow
|
|
||||||
import com.android.tools.smali.dexlib2.Opcode
|
import com.android.tools.smali.dexlib2.Opcode
|
||||||
|
import com.android.tools.smali.dexlib2.iface.Method
|
||||||
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
|
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
|
||||||
|
import com.android.tools.smali.dexlib2.iface.reference.MethodReference
|
||||||
|
|
||||||
private const val EXTENSION_METHOD_DESCRIPTOR =
|
private const val EXTENSION_METHOD_DESCRIPTOR =
|
||||||
"$PATCHES_PATH/ScreenshotPopupPatch;->disableScreenshotPopup()Z"
|
"$PATCHES_PATH/ScreenshotPopupPatch;->disableScreenshotPopup()Z"
|
||||||
@ -29,19 +33,47 @@ val screenshotPopupPatch = bytecodePatch(
|
|||||||
) {
|
) {
|
||||||
compatibleWith(COMPATIBLE_PACKAGE)
|
compatibleWith(COMPATIBLE_PACKAGE)
|
||||||
|
|
||||||
dependsOn(
|
dependsOn(settingsPatch)
|
||||||
settingsPatch,
|
|
||||||
sharedResourceIdPatch,
|
|
||||||
)
|
|
||||||
|
|
||||||
execute {
|
execute {
|
||||||
|
|
||||||
if (is_2025_06_or_greater) {
|
val screenshotTriggerSharingListenerMethodCall =
|
||||||
screenshotTakenBannerFingerprint.methodOrThrow().apply {
|
screenshotBannerContainerFingerprint.methodCall()
|
||||||
val literalIndex = indexOfFirstLiteralInstructionOrThrow(screenShotShareBanner)
|
|
||||||
val insertIndex = indexOfFirstInstructionReversedOrThrow(literalIndex, Opcode.CONST_4)
|
fun indexOfScreenshotTriggerInstruction(method: Method) =
|
||||||
val insertRegister = getInstruction<OneRegisterInstruction>(insertIndex).registerA
|
method.indexOfFirstInstruction {
|
||||||
val jumpIndex = indexOfFirstInstructionOrThrow(literalIndex, Opcode.SGET_OBJECT)
|
getReference<MethodReference>()?.toString() == screenshotTriggerSharingListenerMethodCall
|
||||||
|
}
|
||||||
|
|
||||||
|
val isScreenshotTriggerMethod: Method.() -> Boolean = {
|
||||||
|
indexOfScreenshotTriggerInstruction(this) >= 0
|
||||||
|
}
|
||||||
|
|
||||||
|
var hookCount = 0
|
||||||
|
|
||||||
|
fun MutableMethod.hook() {
|
||||||
|
if (returnType == "V") {
|
||||||
|
addInstructionsWithLabels(
|
||||||
|
0, """
|
||||||
|
invoke-static {}, $EXTENSION_METHOD_DESCRIPTOR
|
||||||
|
move-result v0
|
||||||
|
if-eqz v0, :shown
|
||||||
|
return-void
|
||||||
|
""", ExternalLabel("shown", getInstruction(0))
|
||||||
|
)
|
||||||
|
|
||||||
|
hookCount++
|
||||||
|
} else if (returnType.startsWith("L")) { // Reddit 2025.06+
|
||||||
|
val insertIndex =
|
||||||
|
indexOfFirstStringInstruction("screenshotTriggerSharingListener")
|
||||||
|
|
||||||
|
if (insertIndex >= 0) {
|
||||||
|
val insertRegister =
|
||||||
|
getInstruction<OneRegisterInstruction>(insertIndex).registerA
|
||||||
|
val triggerIndex =
|
||||||
|
indexOfScreenshotTriggerInstruction(this)
|
||||||
|
val jumpIndex =
|
||||||
|
indexOfFirstInstructionOrThrow(triggerIndex, Opcode.RETURN_OBJECT)
|
||||||
|
|
||||||
addInstructionsWithLabels(
|
addInstructionsWithLabels(
|
||||||
insertIndex, """
|
insertIndex, """
|
||||||
@ -50,20 +82,31 @@ val screenshotPopupPatch = bytecodePatch(
|
|||||||
if-nez v$insertRegister, :hidden
|
if-nez v$insertRegister, :hidden
|
||||||
""", ExternalLabel("hidden", getInstruction(jumpIndex))
|
""", ExternalLabel("hidden", getInstruction(jumpIndex))
|
||||||
)
|
)
|
||||||
|
|
||||||
|
hookCount++
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
screenshotTakenBannerLegacyFingerprint.methodOrThrow().apply {
|
|
||||||
addInstructionsWithLabels(
|
|
||||||
0, """
|
|
||||||
invoke-static {}, $EXTENSION_METHOD_DESCRIPTOR
|
|
||||||
move-result v0
|
|
||||||
if-eqz v0, :dismiss
|
|
||||||
return-void
|
|
||||||
""", ExternalLabel("dismiss", getInstruction(0))
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
screenshotBannerContainerFingerprint
|
||||||
|
.methodOrThrow()
|
||||||
|
.hook()
|
||||||
|
|
||||||
|
classes.forEach { classDef ->
|
||||||
|
classDef.methods.forEach { method ->
|
||||||
|
if (method.isScreenshotTriggerMethod()) {
|
||||||
|
proxy(classDef)
|
||||||
|
.mutableClass
|
||||||
|
.findMutableMethodOf(method)
|
||||||
|
.hook()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hookCount == 0) {
|
||||||
|
throw PatchException("Failed to find hook method")
|
||||||
|
}
|
||||||
|
|
||||||
updatePatchStatus(
|
updatePatchStatus(
|
||||||
"enableScreenshotPopup",
|
"enableScreenshotPopup",
|
||||||
DISABLE_SCREENSHOT_POPUP
|
DISABLE_SCREENSHOT_POPUP
|
||||||
|
@ -1,19 +0,0 @@
|
|||||||
package app.revanced.patches.reddit.utils.resourceid
|
|
||||||
|
|
||||||
import app.revanced.patcher.patch.resourcePatch
|
|
||||||
import app.revanced.patches.shared.mapping.ResourceType.STRING
|
|
||||||
import app.revanced.patches.shared.mapping.getResourceId
|
|
||||||
import app.revanced.patches.shared.mapping.resourceMappingPatch
|
|
||||||
|
|
||||||
var screenShotShareBanner = -1L
|
|
||||||
private set
|
|
||||||
|
|
||||||
internal val sharedResourceIdPatch = resourcePatch(
|
|
||||||
description = "sharedResourceIdPatch"
|
|
||||||
) {
|
|
||||||
dependsOn(resourceMappingPatch)
|
|
||||||
|
|
||||||
execute {
|
|
||||||
screenShotShareBanner = getResourceId(STRING, "screenshot_share_banner_title")
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user