refactor: NativeUnaryCallEvent

This commit is contained in:
rhunk 2023-12-20 23:44:19 +01:00
parent b925e8f546
commit 47e9a0e0b1
6 changed files with 10 additions and 10 deletions

View File

@ -299,7 +299,7 @@ class HomeSection : Section() {
.scale(1.75f)
)
Text(
text = ("\u0065" + "\u0063" + "\u006e" + "\u0061" + "\u0068" + "\u006e" + "\u0045" + "\u0070" + "\u0061" + "\u006e" + "\u0053").reversed(),
text = arrayOf("\u0065", "\u0063", "\u006e", "\u0061", "\u0068", "\u006e", "\u0045", "\u0070", "\u0061", "\u006e", "\u0053").reversed().joinToString(""),
fontSize = 30.sp,
modifier = Modifier.padding(16.dp),
)

View File

@ -18,7 +18,7 @@ import me.rhunk.snapenhance.core.bridge.BridgeClient
import me.rhunk.snapenhance.core.bridge.loadFromBridge
import me.rhunk.snapenhance.core.data.SnapClassCache
import me.rhunk.snapenhance.core.event.events.impl.SnapWidgetBroadcastReceiveEvent
import me.rhunk.snapenhance.core.event.events.impl.UnaryCallEvent
import me.rhunk.snapenhance.core.event.events.impl.NativeUnaryCallEvent
import me.rhunk.snapenhance.core.util.LSPatchUpdater
import me.rhunk.snapenhance.core.util.hook.HookStage
import me.rhunk.snapenhance.core.util.hook.hook
@ -165,7 +165,7 @@ class SnapEnhance {
if (appContext.config.experimental.nativeHooks.globalState != true) return@apply
initOnce(appContext.androidContext.classLoader)
nativeUnaryCallCallback = { request ->
appContext.event.post(UnaryCallEvent(request.uri, request.buffer)) {
appContext.event.post(NativeUnaryCallEvent(request.uri, request.buffer)) {
request.buffer = buffer
request.canceled = canceled
}

View File

@ -2,7 +2,7 @@ package me.rhunk.snapenhance.core.event.events.impl
import me.rhunk.snapenhance.core.event.events.AbstractHookEvent
class UnaryCallEvent(
class NativeUnaryCallEvent(
val uri: String,
var buffer: ByteArray
) : AbstractHookEvent()

View File

@ -22,7 +22,7 @@ import me.rhunk.snapenhance.core.event.events.impl.AddViewEvent
import me.rhunk.snapenhance.core.event.events.impl.BindViewEvent
import me.rhunk.snapenhance.core.event.events.impl.BuildMessageEvent
import me.rhunk.snapenhance.core.event.events.impl.SendMessageWithContentEvent
import me.rhunk.snapenhance.core.event.events.impl.UnaryCallEvent
import me.rhunk.snapenhance.core.event.events.impl.NativeUnaryCallEvent
import me.rhunk.snapenhance.core.features.FeatureLoadParams
import me.rhunk.snapenhance.core.features.MessagingRuleFeature
import me.rhunk.snapenhance.core.features.impl.messaging.Messaging
@ -417,7 +417,7 @@ class EndToEndEncryption : MessagingRuleFeature(
}
}
context.event.subscribe(UnaryCallEvent::class) { event ->
context.event.subscribe(NativeUnaryCallEvent::class) { event ->
if (event.uri != "/messagingcoreservice.MessagingCoreService/CreateContentMessage") return@subscribe
val protoReader = ProtoReader(event.buffer)
var hasStory = false

View File

@ -3,7 +3,7 @@ package me.rhunk.snapenhance.core.features.impl.messaging
import me.rhunk.snapenhance.common.data.NotificationType
import me.rhunk.snapenhance.common.util.protobuf.ProtoEditor
import me.rhunk.snapenhance.core.event.events.impl.SendMessageWithContentEvent
import me.rhunk.snapenhance.core.event.events.impl.UnaryCallEvent
import me.rhunk.snapenhance.core.event.events.impl.NativeUnaryCallEvent
import me.rhunk.snapenhance.core.features.Feature
import me.rhunk.snapenhance.core.features.FeatureLoadParams
import me.rhunk.snapenhance.core.util.hook.HookStage
@ -13,7 +13,7 @@ class PreventMessageSending : Feature("Prevent message sending", loadParams = Fe
override fun asyncOnActivityCreate() {
val preventMessageSending by context.config.messaging.preventMessageSending
context.event.subscribe(UnaryCallEvent::class, { preventMessageSending.contains("snap_replay") }) { event ->
context.event.subscribe(NativeUnaryCallEvent::class, { preventMessageSending.contains("snap_replay") }) { event ->
if (event.uri != "/messagingcoreservice.MessagingCoreService/UpdateContentMessage") return@subscribe
event.buffer = ProtoEditor(event.buffer).apply {
edit(3) {

View File

@ -4,7 +4,7 @@ import me.rhunk.snapenhance.common.data.ContentType
import me.rhunk.snapenhance.common.util.protobuf.ProtoEditor
import me.rhunk.snapenhance.common.util.protobuf.ProtoReader
import me.rhunk.snapenhance.core.event.events.impl.SendMessageWithContentEvent
import me.rhunk.snapenhance.core.event.events.impl.UnaryCallEvent
import me.rhunk.snapenhance.core.event.events.impl.NativeUnaryCallEvent
import me.rhunk.snapenhance.core.features.Feature
import me.rhunk.snapenhance.core.features.FeatureLoadParams
import me.rhunk.snapenhance.core.messaging.MessageSender
@ -29,7 +29,7 @@ class SendOverride : Feature("Send Override", loadParams = FeatureLoadParams.INI
}
override fun init() {
context.event.subscribe(UnaryCallEvent::class) { event ->
context.event.subscribe(NativeUnaryCallEvent::class) { event ->
if (event.uri != "/messagingcoreservice.MessagingCoreService/CreateContentMessage") return@subscribe
val protoEditor = ProtoEditor(event.buffer)