fix: stealth mode (#156)

* fix: stealth mod
---------

Co-authored-by: RevealedSoulEven <anshumaurya000@gmail.com>
This commit is contained in:
rhunk
2023-07-27 15:57:18 +02:00
committed by GitHub
parent ce9833f2c3
commit 4e8dff949f
3 changed files with 10 additions and 6 deletions

View File

@@ -1,6 +1,5 @@
package me.rhunk.snapenhance.features.impl
import me.rhunk.snapenhance.Logger
import me.rhunk.snapenhance.config.ConfigProperty
import me.rhunk.snapenhance.data.wrapper.impl.SnapUUID
import me.rhunk.snapenhance.features.Feature
@@ -9,6 +8,7 @@ import me.rhunk.snapenhance.hook.HookStage
import me.rhunk.snapenhance.hook.Hooker
import me.rhunk.snapenhance.hook.hook
import me.rhunk.snapenhance.util.getObjectField
import me.rhunk.snapenhance.features.impl.spying.StealthMode;
class Messaging : Feature("Messaging", loadParams = FeatureLoadParams.ACTIVITY_CREATE_SYNC or FeatureLoadParams.INIT_ASYNC or FeatureLoadParams.INIT_SYNC) {
lateinit var conversationManager: Any
@@ -59,8 +59,12 @@ class Messaging : Feature("Messaging", loadParams = FeatureLoadParams.ACTIVITY_C
}
override fun asyncInit() {
val stealthMode = context.feature(StealthMode::class)
arrayOf("activate", "deactivate", "processTypingActivity").forEach { hook ->
Hooker.hook(context.classCache.presenceSession, hook, HookStage.BEFORE, { context.config.bool(ConfigProperty.HIDE_BITMOJI_PRESENCE) }) {
Hooker.hook(context.classCache.presenceSession, hook, HookStage.BEFORE, {
context.config.bool(ConfigProperty.HIDE_BITMOJI_PRESENCE) || stealthMode.isStealth(openedConversationUUID.toString())
}) {
it.setResult(null)
}
}
@@ -76,8 +80,9 @@ class Messaging : Feature("Messaging", loadParams = FeatureLoadParams.ACTIVITY_C
lastFocusedMessageId = param.arg(1)
}
Hooker.hook(context.classCache.conversationManager, "sendTypingNotification", HookStage.BEFORE,
{context.config.bool(ConfigProperty.HIDE_TYPING_NOTIFICATION)}) {
Hooker.hook(context.classCache.conversationManager, "sendTypingNotification", HookStage.BEFORE, {
context.config.bool(ConfigProperty.HIDE_TYPING_NOTIFICATION) || stealthMode.isStealth(openedConversationUUID.toString())
}) {
it.setResult(null)
}
}

View File

@@ -25,4 +25,4 @@ class PreventReadReceipts : Feature("PreventReadReceipts", loadParams = FeatureL
}
}
}
}
}

View File

@@ -4,7 +4,6 @@ import me.rhunk.snapenhance.bridge.types.BridgeFileType
import me.rhunk.snapenhance.features.BridgeFileFeature
import me.rhunk.snapenhance.features.FeatureLoadParams
class StealthMode : BridgeFileFeature("StealthMode", BridgeFileType.STEALTH, loadParams = FeatureLoadParams.ACTIVITY_CREATE_SYNC) {
override fun onActivityCreate() {
readFile()