commit b120b6a27d198a8fbc03991db9c8d888016190ea
parent 9365528c7477dc62b560f5dfa750b0fed6b6707d
Author: rhunk <101876869+rhunk@users.noreply.github.com>
Date:   Fri, 10 Nov 2023 19:21:19 +0100

feat: bypass screenshot detection

Diffstat:
Mcommon/src/main/assets/lang/en_US.json | 4++++
Mcommon/src/main/kotlin/me/rhunk/snapenhance/common/config/impl/MessagingTweaks.kt | 1+
Acore/src/main/kotlin/me/rhunk/snapenhance/core/features/impl/tweaks/BypassScreenshotDetection.kt | 24++++++++++++++++++++++++
Mcore/src/main/kotlin/me/rhunk/snapenhance/core/manager/impl/FeatureManager.kt | 2++
4 files changed, 31 insertions(+), 0 deletions(-)

diff --git a/common/src/main/assets/lang/en_US.json b/common/src/main/assets/lang/en_US.json @@ -312,6 +312,10 @@ "name": "Messaging", "description": "Change how you interact with friends", "properties": { + "bypass_screenshot_detection": { + "name": "Bypass Screenshot Detection", + "description": "Prevents Snapchat from detecting when you take a screenshot" + }, "anonymous_story_viewing": { "name": "Anonymous Story Viewing", "description": "Prevents anyone from knowing you've seen their story" diff --git a/common/src/main/kotlin/me/rhunk/snapenhance/common/config/impl/MessagingTweaks.kt b/common/src/main/kotlin/me/rhunk/snapenhance/common/config/impl/MessagingTweaks.kt @@ -5,6 +5,7 @@ import me.rhunk.snapenhance.common.config.FeatureNotice import me.rhunk.snapenhance.common.data.NotificationType class MessagingTweaks : ConfigContainer() { + val bypassScreenshotDetection = boolean("bypass_screenshot_detection") { requireRestart() } val anonymousStoryViewing = boolean("anonymous_story_viewing") val hideBitmojiPresence = boolean("hide_bitmoji_presence") val hideTypingNotifications = boolean("hide_typing_notifications") diff --git a/core/src/main/kotlin/me/rhunk/snapenhance/core/features/impl/tweaks/BypassScreenshotDetection.kt b/core/src/main/kotlin/me/rhunk/snapenhance/core/features/impl/tweaks/BypassScreenshotDetection.kt @@ -0,0 +1,23 @@ +package me.rhunk.snapenhance.core.features.impl.tweaks + +import android.content.ContentResolver +import android.database.ContentObserver +import android.net.Uri +import me.rhunk.snapenhance.core.features.Feature +import me.rhunk.snapenhance.core.features.FeatureLoadParams +import me.rhunk.snapenhance.core.util.hook.HookStage +import me.rhunk.snapenhance.core.util.hook.hook + +class BypassScreenshotDetection : Feature("BypassScreenshotDetection", loadParams = FeatureLoadParams.ACTIVITY_CREATE_SYNC) { + override fun onActivityCreate() { + if (!context.config.messaging.bypassScreenshotDetection.get()) return + ContentResolver::class.java.methods.first { + it.name == "registerContentObserver" && + it.parameterTypes.contentEquals(arrayOf(android.net.Uri::class.java, Boolean::class.javaPrimitiveType, ContentObserver::class.java)) + }.hook(HookStage.BEFORE) { param -> + val uri = param.arg<Uri>(0) + if (uri.host != "media") return@hook + param.setResult(null) + } + } +}+ \ No newline at end of file diff --git a/core/src/main/kotlin/me/rhunk/snapenhance/core/manager/impl/FeatureManager.kt b/core/src/main/kotlin/me/rhunk/snapenhance/core/manager/impl/FeatureManager.kt @@ -17,6 +17,7 @@ import me.rhunk.snapenhance.core.features.impl.messaging.* import me.rhunk.snapenhance.core.features.impl.spying.MessageLogger import me.rhunk.snapenhance.core.features.impl.spying.StealthMode import me.rhunk.snapenhance.core.features.impl.tweaks.CameraTweaks +import me.rhunk.snapenhance.core.features.impl.tweaks.BypassScreenshotDetection import me.rhunk.snapenhance.core.features.impl.ui.* import me.rhunk.snapenhance.core.logger.CoreLogger import me.rhunk.snapenhance.core.manager.Manager @@ -103,6 +104,7 @@ class FeatureManager( CallStartConfirmation::class, SnapPreview::class, InstantDelete::class, + BypassScreenshotDetection::class, ) initializeFeatures()