feat: experimental native hooks

This commit is contained in:
rhunk
2023-08-25 19:44:42 +02:00
parent b004f92b9c
commit c0225919e9
17 changed files with 185 additions and 2 deletions

View File

@ -249,6 +249,10 @@
"name": "Disable Metrics",
"description": "Disables some analytics data sent to Snapchat"
},
"disable_bitmoji": {
"name": "Disable Bitmoji",
"description": "Disables friends profile bitmoji for the whole app"
},
"block_ads": {
"name": "Block Ads",
"description": "Prevent ads from being displayed"

View File

@ -21,6 +21,8 @@ import me.rhunk.snapenhance.database.DatabaseAccess
import me.rhunk.snapenhance.features.Feature
import me.rhunk.snapenhance.manager.impl.ActionManager
import me.rhunk.snapenhance.manager.impl.FeatureManager
import me.rhunk.snapenhance.nativelib.NativeConfig
import me.rhunk.snapenhance.nativelib.NativeLib
import me.rhunk.snapenhance.util.download.HttpServer
import java.util.concurrent.ExecutorService
import java.util.concurrent.Executors
@ -44,6 +46,7 @@ class ModContext {
val config by modConfig
val event = EventBus(this)
val eventDispatcher = EventDispatcher(this)
val native = NativeLib()
val translation = LocaleWrapper()
val features = FeatureManager(this)
@ -121,6 +124,16 @@ class ModContext {
fun reloadConfig() {
modConfig.loadFromBridge(bridgeClient)
runCatching {
native.loadConfig(
NativeConfig(
disableBitmoji = config.global.disableBitmoji.get(),
disableMetrics = config.global.disableMetrics.get()
)
)
}.onFailure {
Logger.xposedLog("Failed to load native config", it)
}
}
fun getConfigLocale(): String {

View File

@ -97,6 +97,12 @@ class SnapEnhance {
private suspend fun init() {
measureTime {
with(appContext) {
runCatching {
native.init()
}.onFailure {
Logger.xposedLog("Failed to init native", it)
return
}
reloadConfig()
withContext(appContext.coroutineDispatcher) {
translation.userLocale = getConfigLocale()

View File

@ -8,6 +8,7 @@ class Global : ConfigContainer() {
val snapchatPlus = boolean("snapchat_plus") { addNotices(FeatureNotice.MAY_BAN) }
val autoUpdater = unique("auto_updater", "EVERY_LAUNCH", "DAILY", "WEEKLY").apply { set("DAILY") }
val disableMetrics = boolean("disable_metrics")
val disableBitmoji = boolean("disable_bitmoji") { addNotices(FeatureNotice.UNSTABLE) }
val blockAds = boolean("block_ads")
val disableVideoLengthRestrictions = boolean("disable_video_length_restrictions") { addNotices(FeatureNotice.MAY_BAN) }
val disableGooglePlayDialogs = boolean("disable_google_play_dialogs")

View File

@ -56,7 +56,7 @@ class EventBus(
event.context = context
subscribers[event::class]?.forEach { listener ->
subscribers[event::class]?.toTypedArray()?.forEach { listener ->
@Suppress("UNCHECKED_CAST")
runCatching {
(listener as IListener<T>).handle(event)