commit d70fb0f193888b146a31faa4802990a188afd5cd parent 614d629f07f84d3ac51294b915f3f517fedadb80 Author: rhunk <101876869+rhunk@users.noreply.github.com> Date: Sun, 17 Dec 2023 03:15:22 +0100 feat(experimental): prevent forced logout Diffstat:
4 files changed, 26 insertions(+), 0 deletions(-)
diff --git a/common/src/main/assets/lang/en_US.json b/common/src/main/assets/lang/en_US.json @@ -650,6 +650,10 @@ "disable_composer_modules": { "name": "Disable Composer Modules", "description": "Prevents selected composer modules from being loaded\nNames must be separated by a comma" + }, + "prevent_forced_logout": { + "name": "Prevent Forced Logout", + "description": "Prevents Snapchat from logging you out when you login on another device" } } }, diff --git a/common/src/main/kotlin/me/rhunk/snapenhance/common/config/impl/Experimental.kt b/common/src/main/kotlin/me/rhunk/snapenhance/common/config/impl/Experimental.kt @@ -32,4 +32,5 @@ class Experimental : ConfigContainer() { "added_by_community", ) { addNotices(FeatureNotice.BAN_RISK) } val disableComposerModules = string("disable_composer_modules") { requireRestart(); nativeHooks() } + val preventForcedLogout = boolean("prevent_forced_logout") { requireRestart(); addNotices(FeatureNotice.BAN_RISK, FeatureNotice.INTERNAL_BEHAVIOR); } } \ No newline at end of file diff --git a/core/src/main/kotlin/me/rhunk/snapenhance/core/features/impl/experiments/PreventForcedLogout.kt b/core/src/main/kotlin/me/rhunk/snapenhance/core/features/impl/experiments/PreventForcedLogout.kt @@ -0,0 +1,19 @@ +package me.rhunk.snapenhance.core.features.impl.experiments + +import android.content.Intent +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 PreventForcedLogout : Feature("Prevent Forced Logout", loadParams = FeatureLoadParams.INIT_SYNC) { + override fun init() { + if (!context.config.experimental.preventForcedLogout.get()) return + findClass("com.snap.identity.service.ForcedLogoutBroadcastReceiver").hook("onReceive", HookStage.BEFORE) { param -> + val intent = param.arg<Intent>(1) + if (!intent.getBooleanExtra("forced", false)) return@hook + context.log.verbose("Prevent forced logout, reason=${intent.getStringExtra("reason")}") + 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 @@ -114,6 +114,7 @@ class FeatureManager( DisableComposerModules::class, FideliusIndicator::class, EditTextOverride::class, + PreventForcedLogout::class, ) initializeFeatures()