mirror of
https://github.com/rhunk/SnapEnhance.git
synced 2025-06-13 05:37:48 +02:00
refactor: remove disable composer modules
This commit is contained in:
@ -928,10 +928,6 @@
|
|||||||
"name": "Custom Streaks Expiration Format",
|
"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"
|
"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": {
|
"prevent_forced_logout": {
|
||||||
"name": "Prevent Forced Logout",
|
"name": "Prevent Forced Logout",
|
||||||
"description": "Prevents Snapchat from logging you out when you login on another device"
|
"description": "Prevents Snapchat from logging you out when you login on another device"
|
||||||
|
@ -61,6 +61,5 @@ class Experimental : ConfigContainer() {
|
|||||||
"added_by_qr_code",
|
"added_by_qr_code",
|
||||||
"added_by_community",
|
"added_by_community",
|
||||||
) { addNotices(FeatureNotice.BAN_RISK) }
|
) { 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); }
|
val preventForcedLogout = boolean("prevent_forced_logout") { requireRestart(); addNotices(FeatureNotice.BAN_RISK, FeatureNotice.INTERNAL_BEHAVIOR); }
|
||||||
}
|
}
|
@ -155,8 +155,7 @@ class ModContext(
|
|||||||
NativeConfig(
|
NativeConfig(
|
||||||
disableBitmoji = config.experimental.nativeHooks.disableBitmoji.get(),
|
disableBitmoji = config.experimental.nativeHooks.disableBitmoji.get(),
|
||||||
disableMetrics = config.global.disableMetrics.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
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -104,7 +104,6 @@ class FeatureManager(
|
|||||||
HalfSwipeNotifier(),
|
HalfSwipeNotifier(),
|
||||||
DisableConfirmationDialogs(),
|
DisableConfirmationDialogs(),
|
||||||
MixerStories(),
|
MixerStories(),
|
||||||
DisableComposerModules(),
|
|
||||||
MessageIndicators(),
|
MessageIndicators(),
|
||||||
EditTextOverride(),
|
EditTextOverride(),
|
||||||
PreventForcedLogout(),
|
PreventForcedLogout(),
|
||||||
|
@ -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")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -12,7 +12,6 @@
|
|||||||
typedef struct {
|
typedef struct {
|
||||||
bool disable_bitmoji;
|
bool disable_bitmoji;
|
||||||
bool disable_metrics;
|
bool disable_metrics;
|
||||||
bool hook_asset_open;
|
|
||||||
bool composer_hooks;
|
bool composer_hooks;
|
||||||
} native_config_t;
|
} native_config_t;
|
||||||
|
|
||||||
|
@ -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);
|
|
||||||
}
|
|
||||||
}
|
|
@ -5,7 +5,6 @@
|
|||||||
|
|
||||||
#include "logger.h"
|
#include "logger.h"
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "hooks/asset_hook.h"
|
|
||||||
#include "hooks/unary_call.h"
|
#include "hooks/unary_call.h"
|
||||||
#include "hooks/fstat_hook.h"
|
#include "hooks/fstat_hook.h"
|
||||||
#include "hooks/sqlite_mutex.h"
|
#include "hooks/sqlite_mutex.h"
|
||||||
@ -33,7 +32,6 @@ bool JNICALL init(JNIEnv *env, jobject clazz) {
|
|||||||
util::remap_sections(BUILD_PACKAGE);
|
util::remap_sections(BUILD_PACKAGE);
|
||||||
|
|
||||||
UnaryCallHook::init(env);
|
UnaryCallHook::init(env);
|
||||||
AssetHook::init(env);
|
|
||||||
FstatHook::init();
|
FstatHook::init();
|
||||||
SqliteMutexHook::init();
|
SqliteMutexHook::init();
|
||||||
DuplexHook::init(env);
|
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_bitmoji = GET_CONFIG_BOOL("disableBitmoji");
|
||||||
native_config->disable_metrics = GET_CONFIG_BOOL("disableMetrics");
|
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");
|
native_config->composer_hooks = GET_CONFIG_BOOL("composerHooks");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,6 +3,5 @@ package me.rhunk.snapenhance.nativelib
|
|||||||
data class NativeConfig(
|
data class NativeConfig(
|
||||||
val disableBitmoji: Boolean = false,
|
val disableBitmoji: Boolean = false,
|
||||||
val disableMetrics: Boolean = false,
|
val disableMetrics: Boolean = false,
|
||||||
val hookAssetOpen: Boolean = false,
|
|
||||||
val composerHooks: Boolean = false,
|
val composerHooks: Boolean = false,
|
||||||
)
|
)
|
@ -5,7 +5,6 @@ import android.util.Log
|
|||||||
@Suppress("KotlinJniMissingFunction")
|
@Suppress("KotlinJniMissingFunction")
|
||||||
class NativeLib {
|
class NativeLib {
|
||||||
var nativeUnaryCallCallback: (NativeRequestData) -> Unit = {}
|
var nativeUnaryCallCallback: (NativeRequestData) -> Unit = {}
|
||||||
var nativeShouldLoadAsset: (String) -> Boolean = { true }
|
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
var initialized = false
|
var initialized = false
|
||||||
@ -39,11 +38,6 @@ class NativeLib {
|
|||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
@Suppress("unused")
|
|
||||||
private fun shouldLoadAsset(name: String) = runCatching {
|
|
||||||
nativeShouldLoadAsset(name)
|
|
||||||
}.getOrNull() ?: true
|
|
||||||
|
|
||||||
fun loadNativeConfig(config: NativeConfig) {
|
fun loadNativeConfig(config: NativeConfig) {
|
||||||
if (!initialized) return
|
if (!initialized) return
|
||||||
loadConfig(config)
|
loadConfig(config)
|
||||||
|
Reference in New Issue
Block a user