mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-04-30 06:34:37 +02:00
fix(Reddit - Disable screenshot popup): Patch does not work in certain environments https://github.com/inotia00/ReVanced_Extended/issues/2891
This commit is contained in:
parent
1c58c6a36e
commit
7f85e802c2
@ -1,5 +1,8 @@
|
|||||||
package app.revanced.patches.reddit.layout.screenshotpopup
|
package app.revanced.patches.reddit.layout.screenshotpopup
|
||||||
|
|
||||||
|
import app.revanced.patches.reddit.utils.resourceid.actionShare
|
||||||
|
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 app.revanced.util.or
|
import app.revanced.util.or
|
||||||
import com.android.tools.smali.dexlib2.AccessFlags
|
import com.android.tools.smali.dexlib2.AccessFlags
|
||||||
@ -13,3 +16,45 @@ internal val screenshotBannerContainerFingerprint = legacyFingerprint(
|
|||||||
"scope",
|
"scope",
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reddit 2025.06.0 ~
|
||||||
|
*/
|
||||||
|
internal val screenshotTakenBannerComposableFingerprint = legacyFingerprint(
|
||||||
|
name = "screenshotTakenBannerComposableFingerprint",
|
||||||
|
returnType = "L",
|
||||||
|
customFingerprint = { method, classDef ->
|
||||||
|
method.containsLiteralInstruction(actionShare) &&
|
||||||
|
method.containsLiteralInstruction(screenShotShareBanner) &&
|
||||||
|
classDef.type.startsWith("Lcom/reddit/sharing/screenshot/composables/") &&
|
||||||
|
method.name == "invoke"
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ~ Reddit 2025.05.1
|
||||||
|
*/
|
||||||
|
internal val screenshotTakenBannerLambdaActionFingerprint = legacyFingerprint(
|
||||||
|
name = "screenshotTakenBannerLambdaFingerprint",
|
||||||
|
returnType = "V",
|
||||||
|
parameters = listOf("Landroidx/compose/runtime/", "I"),
|
||||||
|
customFingerprint = { method, _ ->
|
||||||
|
method.containsLiteralInstruction(actionShare) &&
|
||||||
|
method.name == "invoke"
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ~ Reddit 2025.05.1
|
||||||
|
*/
|
||||||
|
internal val screenshotTakenBannerLambdaBannerFingerprint = legacyFingerprint(
|
||||||
|
name = "screenshotTakenBannerLambdaFingerprint",
|
||||||
|
returnType = "V",
|
||||||
|
parameters = listOf("Landroidx/compose/runtime/", "I"),
|
||||||
|
customFingerprint = { method, _ ->
|
||||||
|
method.containsLiteralInstruction(screenShotShareBanner) &&
|
||||||
|
method.name == "invoke"
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -9,6 +9,10 @@ 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.actionShare
|
||||||
|
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.findMutableMethodOf
|
||||||
@ -17,6 +21,8 @@ import app.revanced.util.fingerprint.methodOrThrow
|
|||||||
import app.revanced.util.getReference
|
import app.revanced.util.getReference
|
||||||
import app.revanced.util.indexOfFirstInstruction
|
import app.revanced.util.indexOfFirstInstruction
|
||||||
import app.revanced.util.indexOfFirstInstructionOrThrow
|
import app.revanced.util.indexOfFirstInstructionOrThrow
|
||||||
|
import app.revanced.util.indexOfFirstInstructionReversedOrThrow
|
||||||
|
import app.revanced.util.indexOfFirstLiteralInstructionOrThrow
|
||||||
import app.revanced.util.indexOfFirstStringInstruction
|
import app.revanced.util.indexOfFirstStringInstruction
|
||||||
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.Method
|
||||||
@ -33,7 +39,10 @@ val screenshotPopupPatch = bytecodePatch(
|
|||||||
) {
|
) {
|
||||||
compatibleWith(COMPATIBLE_PACKAGE)
|
compatibleWith(COMPATIBLE_PACKAGE)
|
||||||
|
|
||||||
dependsOn(settingsPatch)
|
dependsOn(
|
||||||
|
settingsPatch,
|
||||||
|
sharedResourceIdPatch,
|
||||||
|
)
|
||||||
|
|
||||||
execute {
|
execute {
|
||||||
|
|
||||||
@ -107,6 +116,44 @@ val screenshotPopupPatch = bytecodePatch(
|
|||||||
throw PatchException("Failed to find hook method")
|
throw PatchException("Failed to find hook method")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (is_2025_06_or_greater) {
|
||||||
|
screenshotTakenBannerComposableFingerprint.methodOrThrow().apply {
|
||||||
|
arrayOf(
|
||||||
|
actionShare,
|
||||||
|
screenShotShareBanner
|
||||||
|
).forEach { literal ->
|
||||||
|
val literalIndex = indexOfFirstLiteralInstructionOrThrow(literal)
|
||||||
|
val insertIndex = indexOfFirstInstructionReversedOrThrow(literalIndex, Opcode.CONST_4)
|
||||||
|
val insertRegister = getInstruction<OneRegisterInstruction>(insertIndex).registerA
|
||||||
|
val jumpIndex = indexOfFirstInstructionOrThrow(literalIndex, Opcode.SGET_OBJECT)
|
||||||
|
|
||||||
|
addInstructionsWithLabels(
|
||||||
|
insertIndex, """
|
||||||
|
invoke-static {}, $EXTENSION_METHOD_DESCRIPTOR
|
||||||
|
move-result v$insertRegister
|
||||||
|
if-nez v$insertRegister, :hidden
|
||||||
|
""", ExternalLabel("hidden", getInstruction(jumpIndex))
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
arrayOf(
|
||||||
|
screenshotTakenBannerLambdaActionFingerprint,
|
||||||
|
screenshotTakenBannerLambdaBannerFingerprint
|
||||||
|
).forEach { fingerprint ->
|
||||||
|
fingerprint.methodOrThrow().addInstructionsWithLabels(
|
||||||
|
0, """
|
||||||
|
invoke-static {}, $EXTENSION_METHOD_DESCRIPTOR
|
||||||
|
move-result v0
|
||||||
|
if-eqz v0, :ignore
|
||||||
|
return-void
|
||||||
|
:ignore
|
||||||
|
nop
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
updatePatchStatus(
|
updatePatchStatus(
|
||||||
"enableScreenshotPopup",
|
"enableScreenshotPopup",
|
||||||
DISABLE_SCREENSHOT_POPUP
|
DISABLE_SCREENSHOT_POPUP
|
||||||
|
@ -0,0 +1,25 @@
|
|||||||
|
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 actionShare = -1L
|
||||||
|
private set
|
||||||
|
var nsfwDialogTitle = -1L
|
||||||
|
private set
|
||||||
|
var screenShotShareBanner = -1L
|
||||||
|
private set
|
||||||
|
|
||||||
|
internal val sharedResourceIdPatch = resourcePatch(
|
||||||
|
description = "sharedResourceIdPatch"
|
||||||
|
) {
|
||||||
|
dependsOn(resourceMappingPatch)
|
||||||
|
|
||||||
|
execute {
|
||||||
|
actionShare = getResourceId(STRING, "action_share")
|
||||||
|
nsfwDialogTitle = getResourceId(STRING, "nsfw_dialog_title")
|
||||||
|
screenShotShareBanner = getResourceId(STRING, "screenshot_share_banner_title")
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user