commit 1e17f48c6c06e939495aab7a667efc5e1bbdd1d6 parent debaecf91d7031f1797398be12fdfef28206bcc4 Author: rhunk <101876869+rhunk@users.noreply.github.com> Date: Fri, 26 Apr 2024 18:57:48 +0200 refactor: remove disable composer modules Diffstat:
10 files changed, 1 insertion(+), 68 deletions(-)
diff --git a/common/src/main/assets/lang/en_US.json b/common/src/main/assets/lang/en_US.json @@ -928,10 +928,6 @@ "name": "Custom Streaks Expiration Format", "description": "Customizes the Streaks Expiration format\n\nAvailable variables:\n - %c: Streaks Count\n - %e: Hourglass Emoji\n - %d: Days\n - %h: Hours\n - %m: Minutes\n - %s: Seconds\n - %w: Remaining Time" }, - "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 @@ -61,6 +61,5 @@ class Experimental : ConfigContainer() { "added_by_qr_code", "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/ModContext.kt b/core/src/main/kotlin/me/rhunk/snapenhance/core/ModContext.kt @@ -155,8 +155,7 @@ class ModContext( NativeConfig( disableBitmoji = config.experimental.nativeHooks.disableBitmoji.get(), disableMetrics = config.global.disableMetrics.get(), - hookAssetOpen = config.experimental.disableComposerModules.get().isNotEmpty(), - composerHooks = config.experimental.nativeHooks.composerHooks.globalState == true + composerHooks = config.experimental.nativeHooks.composerHooks.globalState == true, ) ) } diff --git a/core/src/main/kotlin/me/rhunk/snapenhance/core/features/FeatureManager.kt b/core/src/main/kotlin/me/rhunk/snapenhance/core/features/FeatureManager.kt @@ -104,7 +104,6 @@ class FeatureManager( HalfSwipeNotifier(), DisableConfirmationDialogs(), MixerStories(), - DisableComposerModules(), MessageIndicators(), EditTextOverride(), PreventForcedLogout(), diff --git a/core/src/main/kotlin/me/rhunk/snapenhance/core/features/impl/experiments/DisableComposerModules.kt b/core/src/main/kotlin/me/rhunk/snapenhance/core/features/impl/experiments/DisableComposerModules.kt @@ -1,22 +0,0 @@ -package me.rhunk.snapenhance.core.features.impl.experiments - -import me.rhunk.snapenhance.core.features.Feature -import me.rhunk.snapenhance.core.features.FeatureLoadParams - -class DisableComposerModules : Feature("Disable Composer Modules", FeatureLoadParams.INIT_SYNC) { - override fun init() { - val disabledComposerModules = context.config.experimental.disableComposerModules.get().takeIf { it.isNotEmpty() } - ?.replace(" ", "") - ?.split(",") - ?: return - - context.native.nativeShouldLoadAsset = callback@{ assetName -> - if (!assetName.endsWith(".composermodule")) return@callback true - val moduleName = assetName.replace(".composermodule", "") - disabledComposerModules.contains(moduleName).not().also { - if (it) context.log.debug("Loading $moduleName composer module") - else context.log.warn("Skipping $moduleName composer module") - } - } - } -}- \ No newline at end of file diff --git a/native/jni/src/common.h b/native/jni/src/common.h @@ -12,7 +12,6 @@ typedef struct { bool disable_bitmoji; bool disable_metrics; - bool hook_asset_open; bool composer_hooks; } native_config_t; diff --git a/native/jni/src/hooks/asset_hook.h b/native/jni/src/hooks/asset_hook.h @@ -1,25 +0,0 @@ -#pragma once - -#include <android/asset_manager.h> - -namespace AssetHook { - jmethodID native_lib_on_asset_load; - - HOOK_DEF(AAsset*, AAssetManager_open_hook, AAssetManager* mgr, const char* filename, int mode) { - if (common::native_config->hook_asset_open) { - JNIEnv *env = nullptr; - common::java_vm->GetEnv((void **)&env, JNI_VERSION_1_6); - - if (!env->CallBooleanMethod(common::native_lib_object, native_lib_on_asset_load, env->NewStringUTF(filename))) { - return nullptr; - } - } - - return AAssetManager_open_hook_original(mgr, filename, mode); - } - - void init(JNIEnv *env) { - native_lib_on_asset_load = env->GetMethodID(env->GetObjectClass(common::native_lib_object), "shouldLoadAsset", "(Ljava/lang/String;)Z"); - DobbyHook((void *) AAssetManager_open, (void *) AAssetManager_open_hook, (void **) &AAssetManager_open_hook_original); - } -}- \ No newline at end of file diff --git a/native/jni/src/library.cpp b/native/jni/src/library.cpp @@ -5,7 +5,6 @@ #include "logger.h" #include "common.h" -#include "hooks/asset_hook.h" #include "hooks/unary_call.h" #include "hooks/fstat_hook.h" #include "hooks/sqlite_mutex.h" @@ -33,7 +32,6 @@ bool JNICALL init(JNIEnv *env, jobject clazz) { util::remap_sections(BUILD_PACKAGE); UnaryCallHook::init(env); - AssetHook::init(env); FstatHook::init(); SqliteMutexHook::init(); DuplexHook::init(env); @@ -52,7 +50,6 @@ void JNICALL load_config(JNIEnv *env, jobject, jobject config_object) { native_config->disable_bitmoji = GET_CONFIG_BOOL("disableBitmoji"); native_config->disable_metrics = GET_CONFIG_BOOL("disableMetrics"); - native_config->hook_asset_open = GET_CONFIG_BOOL("hookAssetOpen"); native_config->composer_hooks = GET_CONFIG_BOOL("composerHooks"); } diff --git a/native/src/main/kotlin/me/rhunk/snapenhance/nativelib/NativeConfig.kt b/native/src/main/kotlin/me/rhunk/snapenhance/nativelib/NativeConfig.kt @@ -3,6 +3,5 @@ package me.rhunk.snapenhance.nativelib data class NativeConfig( val disableBitmoji: Boolean = false, val disableMetrics: Boolean = false, - val hookAssetOpen: Boolean = false, val composerHooks: Boolean = false, ) \ No newline at end of file diff --git a/native/src/main/kotlin/me/rhunk/snapenhance/nativelib/NativeLib.kt b/native/src/main/kotlin/me/rhunk/snapenhance/nativelib/NativeLib.kt @@ -5,7 +5,6 @@ import android.util.Log @Suppress("KotlinJniMissingFunction") class NativeLib { var nativeUnaryCallCallback: (NativeRequestData) -> Unit = {} - var nativeShouldLoadAsset: (String) -> Boolean = { true } companion object { var initialized = false @@ -39,11 +38,6 @@ class NativeLib { return null } - @Suppress("unused") - private fun shouldLoadAsset(name: String) = runCatching { - nativeShouldLoadAsset(name) - }.getOrNull() ?: true - fun loadNativeConfig(config: NativeConfig) { if (!initialized) return loadConfig(config)