mirror of
https://github.com/whitechi73/OpenShamrock.git
synced 2024-08-14 13:12:17 +08:00
Shamrock
: Using the NT kernel to upload resources
Signed-off-by: 白池 <whitechi73@outlook.com>
This commit is contained in:
parent
46ed966c18
commit
605f58da47
@ -17,7 +17,7 @@ android {
|
|||||||
minSdk = 27
|
minSdk = 27
|
||||||
targetSdk = 34
|
targetSdk = 34
|
||||||
versionCode = getVersionCode()
|
versionCode = getVersionCode()
|
||||||
versionName = "1.0.8" + ".r${getGitCommitCount()}." + getVersionName()
|
versionName = "1.0.9" + ".r${getGitCommitCount()}." + getVersionName()
|
||||||
|
|
||||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||||
vectorDrawables {
|
vectorDrawables {
|
||||||
|
@ -299,6 +299,16 @@ object ShamrockConfig {
|
|||||||
return preferences.getBoolean("enable_self_msg", false)
|
return preferences.getBoolean("enable_self_msg", false)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun enableOldBDH(ctx: Context): Boolean {
|
||||||
|
val preferences = ctx.getSharedPreferences("config", 0)
|
||||||
|
return preferences.getBoolean("enable_old_bdh", false)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun setEnableOldBDH(ctx: Context, v: Boolean) {
|
||||||
|
val preferences = ctx.getSharedPreferences("config", 0)
|
||||||
|
preferences.edit().putBoolean("enable_old_bdh", v).apply()
|
||||||
|
}
|
||||||
|
|
||||||
fun enableSyncMsgAsSentMsg(ctx: Context): Boolean {
|
fun enableSyncMsgAsSentMsg(ctx: Context): Boolean {
|
||||||
val preferences = ctx.getSharedPreferences("config", 0)
|
val preferences = ctx.getSharedPreferences("config", 0)
|
||||||
return preferences.getBoolean("enable_sync_msg_as_sent_msg", false)
|
return preferences.getBoolean("enable_sync_msg_as_sent_msg", false)
|
||||||
@ -334,7 +344,6 @@ object ShamrockConfig {
|
|||||||
"inject_packet" to preferences.getBoolean("inject_packet", false),
|
"inject_packet" to preferences.getBoolean("inject_packet", false),
|
||||||
"debug" to preferences.getBoolean("debug", false),
|
"debug" to preferences.getBoolean("debug", false),
|
||||||
"anti_qq_trace" to preferences.getBoolean("anti_qq_trace", true),
|
"anti_qq_trace" to preferences.getBoolean("anti_qq_trace", true),
|
||||||
//"auto_clear" to preferences.getBoolean("auto_clear", false),
|
|
||||||
"ssl_private_pwd" to preferences.getString("ssl_private_pwd", ""),
|
"ssl_private_pwd" to preferences.getString("ssl_private_pwd", ""),
|
||||||
"key_store" to preferences.getString("key_store", ""),
|
"key_store" to preferences.getString("key_store", ""),
|
||||||
"enable_self_msg" to preferences.getBoolean("enable_self_msg", false),
|
"enable_self_msg" to preferences.getBoolean("enable_self_msg", false),
|
||||||
@ -343,7 +352,8 @@ object ShamrockConfig {
|
|||||||
"alive_reply" to preferences.getBoolean("alive_reply", false),
|
"alive_reply" to preferences.getBoolean("alive_reply", false),
|
||||||
"enable_sync_msg_as_sent_msg" to preferences.getBoolean("enable_sync_msg_as_sent_msg", false),
|
"enable_sync_msg_as_sent_msg" to preferences.getBoolean("enable_sync_msg_as_sent_msg", false),
|
||||||
"disable_auto_sync_setting" to preferences.getBoolean("disable_auto_sync_setting", false),
|
"disable_auto_sync_setting" to preferences.getBoolean("disable_auto_sync_setting", false),
|
||||||
"forbid_useless_process" to preferences.getBoolean("forbid_useless_process", false)
|
"forbid_useless_process" to preferences.getBoolean("forbid_useless_process", false),
|
||||||
|
"enable_old_bdh" to preferences.getBoolean("enable_old_bdh", false),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -102,7 +102,7 @@ fun LabFragment() {
|
|||||||
|
|
||||||
Function(
|
Function(
|
||||||
title = "禁止无用进程",
|
title = "禁止无用进程",
|
||||||
desc = "禁止QQ生成无用进程浪费内存",
|
desc = "禁止QQ生成无用进程浪费内存,可能造成部分功能闪退。",
|
||||||
descColor = color,
|
descColor = color,
|
||||||
isSwitch = ShamrockConfig.isForbidUselessProcess(ctx)
|
isSwitch = ShamrockConfig.isForbidUselessProcess(ctx)
|
||||||
) {
|
) {
|
||||||
@ -221,7 +221,7 @@ fun LabFragment() {
|
|||||||
}.onSuccess {
|
}.onSuccess {
|
||||||
Function(
|
Function(
|
||||||
title = "反检测加强",
|
title = "反检测加强",
|
||||||
desc = "可能导致某些设备频繁闪退",
|
desc = "可能导致某些设备频繁闪退,将拦截环境包上报。",
|
||||||
descColor = color,
|
descColor = color,
|
||||||
isSwitch = it.getBoolean("super_anti", false)
|
isSwitch = it.getBoolean("super_anti", false)
|
||||||
) { v ->
|
) { v ->
|
||||||
@ -295,17 +295,16 @@ fun LabFragment() {
|
|||||||
return@Function true
|
return@Function true
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
Function(
|
Function(
|
||||||
title = "使用纯数字ECHO",
|
title = "启用旧版资源上传系统",
|
||||||
desc = "在部分强类型语言框架,需要打开此开关。",
|
desc = "如果NT内核无法上传资源,请打开本开关。",
|
||||||
descColor = it,
|
descColor = it,
|
||||||
isSwitch = ShamrockConfig.isEchoNumber(ctx)
|
isSwitch = ShamrockConfig.enableOldBDH(ctx)
|
||||||
) {
|
) {
|
||||||
ShamrockConfig.setEchoNumber(ctx, it)
|
ShamrockConfig.setEnableOldBDH(ctx, it)
|
||||||
ShamrockConfig.pushUpdate(ctx)
|
ShamrockConfig.pushUpdate(ctx)
|
||||||
return@Function true
|
return@Function true
|
||||||
}*/
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -37,6 +37,7 @@ import moe.fuqiuluo.shamrock.helper.LogicException
|
|||||||
import moe.fuqiuluo.shamrock.helper.MessageHelper
|
import moe.fuqiuluo.shamrock.helper.MessageHelper
|
||||||
import moe.fuqiuluo.shamrock.helper.MusicHelper
|
import moe.fuqiuluo.shamrock.helper.MusicHelper
|
||||||
import moe.fuqiuluo.shamrock.helper.ParamsException
|
import moe.fuqiuluo.shamrock.helper.ParamsException
|
||||||
|
import moe.fuqiuluo.shamrock.remote.service.config.ShamrockConfig
|
||||||
import moe.fuqiuluo.shamrock.tools.*
|
import moe.fuqiuluo.shamrock.tools.*
|
||||||
import moe.fuqiuluo.shamrock.utils.AudioUtils
|
import moe.fuqiuluo.shamrock.utils.AudioUtils
|
||||||
import moe.fuqiuluo.shamrock.utils.FileUtils
|
import moe.fuqiuluo.shamrock.utils.FileUtils
|
||||||
@ -714,11 +715,13 @@ internal object MsgElementMaker {
|
|||||||
AudioUtils.obtainVideoCover(file.absolutePath, thumbPath!!)
|
AudioUtils.obtainVideoCover(file.absolutePath, thumbPath!!)
|
||||||
}
|
}
|
||||||
|
|
||||||
Transfer with when (chatType) {
|
if (ShamrockConfig.enableOldBDH()) {
|
||||||
MsgConstant.KCHATTYPEGROUP -> Troop(peerId)
|
Transfer with when (chatType) {
|
||||||
MsgConstant.KCHATTYPEC2C -> Private(peerId)
|
MsgConstant.KCHATTYPEGROUP -> Troop(peerId)
|
||||||
else -> error("Not supported chatType($chatType) for VideoMsg")
|
MsgConstant.KCHATTYPEC2C -> Private(peerId)
|
||||||
} trans VideoResource(file, File(thumbPath.toString()))
|
else -> error("Not supported chatType($chatType) for VideoMsg")
|
||||||
|
} trans VideoResource(file, File(thumbPath.toString()))
|
||||||
|
}
|
||||||
|
|
||||||
video.fileTime = AudioUtils.getVideoTime(file)
|
video.fileTime = AudioUtils.getVideoTime(file)
|
||||||
video.fileSize = file.length()
|
video.fileSize = file.length()
|
||||||
@ -848,36 +851,53 @@ internal object MsgElementMaker {
|
|||||||
else -> {
|
else -> {
|
||||||
LogCenter.log({ "Audio To SILK: $file" }, Level.DEBUG)
|
LogCenter.log({ "Audio To SILK: $file" }, Level.DEBUG)
|
||||||
val result = AudioUtils.audioToSilk(file)
|
val result = AudioUtils.audioToSilk(file)
|
||||||
ptt.duration = result.first
|
ptt.duration = runCatching {
|
||||||
|
QRoute.api(IAIOPttApi::class.java)
|
||||||
|
.getPttFileDuration(result.second.absolutePath)
|
||||||
|
}.getOrElse {
|
||||||
|
result.first
|
||||||
|
}
|
||||||
file = result.second
|
file = result.second
|
||||||
ptt.formatType = MsgConstant.KPTTFORMATTYPESILK
|
ptt.formatType = MsgConstant.KPTTFORMATTYPESILK
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//val msgService = NTServiceFetcher.kernelService.msgService!!
|
|
||||||
//val originalPath = msgService.getRichMediaFilePathForMobileQQSend(RichMediaFilePathInfo(
|
|
||||||
// MsgConstant.KELEMTYPEPTT, 0, ptt.md5HexStr, file.name, 1, 0, null, "", true
|
|
||||||
//))!!
|
|
||||||
//if (!QQNTWrapperUtil.CppProxy.fileIsExist(originalPath) || QQNTWrapperUtil.CppProxy.getFileSize(originalPath) != file.length()) {
|
|
||||||
// QQNTWrapperUtil.CppProxy.copyFile(file.absolutePath, originalPath)
|
|
||||||
//}
|
|
||||||
|
|
||||||
if (!(Transfer with when (chatType) {
|
|
||||||
MsgConstant.KCHATTYPEGROUP -> Troop(peerId)
|
|
||||||
MsgConstant.KCHATTYPEC2C -> Private(peerId)
|
|
||||||
MsgConstant.KCHATTYPETEMPC2CFROMGROUP -> Private(peerId)
|
|
||||||
else -> error("Not supported chatType($chatType) for RecordMsg")
|
|
||||||
} trans VoiceResource(file))
|
|
||||||
) {
|
|
||||||
return Result.failure(RuntimeException("上传语音失败: $file"))
|
|
||||||
}
|
|
||||||
|
|
||||||
val elem = MsgElement()
|
val elem = MsgElement()
|
||||||
elem.elementType = MsgConstant.KELEMTYPEPTT
|
elem.elementType = MsgConstant.KELEMTYPEPTT
|
||||||
ptt.md5HexStr = QQNTWrapperUtil.CppProxy.genFileMd5Hex(file.absolutePath)
|
ptt.md5HexStr = QQNTWrapperUtil.CppProxy.genFileMd5Hex(file.absolutePath)
|
||||||
|
|
||||||
ptt.fileName = file.name
|
if (ShamrockConfig.enableOldBDH()) {
|
||||||
ptt.filePath = file.absolutePath
|
if (!(Transfer with when (chatType) {
|
||||||
ptt.fileSize = file.length()
|
MsgConstant.KCHATTYPEGROUP -> Troop(peerId)
|
||||||
|
MsgConstant.KCHATTYPEC2C -> Private(peerId)
|
||||||
|
MsgConstant.KCHATTYPETEMPC2CFROMGROUP -> Private(peerId)
|
||||||
|
else -> error("Not supported chatType($chatType) for RecordMsg")
|
||||||
|
} trans VoiceResource(file))
|
||||||
|
) {
|
||||||
|
return Result.failure(RuntimeException("上传语音失败: $file"))
|
||||||
|
}
|
||||||
|
|
||||||
|
ptt.filePath = file.absolutePath
|
||||||
|
} else {
|
||||||
|
val msgService = NTServiceFetcher.kernelService.msgService!!
|
||||||
|
|
||||||
|
val originalPath = msgService.getRichMediaFilePathForMobileQQSend(RichMediaFilePathInfo(
|
||||||
|
MsgConstant.KELEMTYPEPTT, 0, ptt.md5HexStr, file.name, 1, 0, null, "", true
|
||||||
|
))
|
||||||
|
if (!QQNTWrapperUtil.CppProxy.fileIsExist(originalPath) || QQNTWrapperUtil.CppProxy.getFileSize(originalPath) != file.length()) {
|
||||||
|
QQNTWrapperUtil.CppProxy.copyFile(file.absolutePath, originalPath)
|
||||||
|
}
|
||||||
|
if (originalPath != null) {
|
||||||
|
ptt.filePath = originalPath
|
||||||
|
} else {
|
||||||
|
ptt.filePath = file.absolutePath
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ptt.canConvert2Text = true
|
||||||
|
ptt.fileId = 0
|
||||||
|
ptt.fileUuid = ""
|
||||||
|
ptt.text = ""
|
||||||
|
|
||||||
if (!isMagic) {
|
if (!isMagic) {
|
||||||
ptt.voiceType = MsgConstant.KPTTVOICETYPESOUNDRECORD
|
ptt.voiceType = MsgConstant.KPTTVOICETYPESOUNDRECORD
|
||||||
@ -887,11 +907,6 @@ internal object MsgElementMaker {
|
|||||||
ptt.voiceChangeType = MsgConstant.KPTTVOICECHANGETYPEECHO
|
ptt.voiceChangeType = MsgConstant.KPTTVOICECHANGETYPEECHO
|
||||||
}
|
}
|
||||||
|
|
||||||
ptt.canConvert2Text = false
|
|
||||||
ptt.fileId = 0
|
|
||||||
ptt.fileUuid = ""
|
|
||||||
ptt.text = ""
|
|
||||||
|
|
||||||
elem.pttElement = ptt
|
elem.pttElement = ptt
|
||||||
|
|
||||||
return Result.success(elem)
|
return Result.success(elem)
|
||||||
@ -926,11 +941,13 @@ internal object MsgElementMaker {
|
|||||||
}
|
}
|
||||||
requireNotNull(file)
|
requireNotNull(file)
|
||||||
|
|
||||||
Transfer with when (chatType) {
|
if (ShamrockConfig.enableOldBDH()) {
|
||||||
MsgConstant.KCHATTYPEGROUP -> Troop(peerId)
|
Transfer with when (chatType) {
|
||||||
MsgConstant.KCHATTYPEC2C -> Private(peerId)
|
MsgConstant.KCHATTYPEGROUP -> Troop(peerId)
|
||||||
else -> error("Not supported chatType($chatType) for PictureMsg")
|
MsgConstant.KCHATTYPEC2C -> Private(peerId)
|
||||||
} trans PictureResource(file)
|
else -> error("Not supported chatType($chatType) for PictureMsg")
|
||||||
|
} trans PictureResource(file)
|
||||||
|
}
|
||||||
|
|
||||||
val elem = MsgElement()
|
val elem = MsgElement()
|
||||||
elem.elementType = MsgConstant.KELEMTYPEPIC
|
elem.elementType = MsgConstant.KELEMTYPEPIC
|
||||||
|
@ -77,6 +77,7 @@ internal object ShamrockConfig {
|
|||||||
putBoolean("shell", intent.getBooleanExtra("shell", false)) // 开启Shell接口
|
putBoolean("shell", intent.getBooleanExtra("shell", false)) // 开启Shell接口
|
||||||
putBoolean("enable_sync_msg_as_sent_msg", intent.getBooleanExtra("enable_sync_msg_as_sent_msg", false)) // 推送同步消息
|
putBoolean("enable_sync_msg_as_sent_msg", intent.getBooleanExtra("enable_sync_msg_as_sent_msg", false)) // 推送同步消息
|
||||||
putBoolean("forbid_useless_process", intent.getBooleanExtra("forbid_useless_process", false)) // 禁用QQ生成无用进程
|
putBoolean("forbid_useless_process", intent.getBooleanExtra("forbid_useless_process", false)) // 禁用QQ生成无用进程
|
||||||
|
putBoolean("enable_old_bdh", intent.getBooleanExtra("enable_old_bdh", false)) // 启用旧版BDH
|
||||||
}
|
}
|
||||||
Config.defaultToken = intent.getStringExtra("token")
|
Config.defaultToken = intent.getStringExtra("token")
|
||||||
Config.antiTrace = intent.getBooleanExtra("anti_qq_trace", true)
|
Config.antiTrace = intent.getBooleanExtra("anti_qq_trace", true)
|
||||||
@ -175,6 +176,10 @@ internal object ShamrockConfig {
|
|||||||
return mmkv.getBoolean("inject_packet", false)
|
return mmkv.getBoolean("inject_packet", false)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun enableOldBDH(): Boolean {
|
||||||
|
return mmkv.getBoolean("enable_old_bdh", false)
|
||||||
|
}
|
||||||
|
|
||||||
fun isDebug(): Boolean {
|
fun isDebug(): Boolean {
|
||||||
return mmkv.getBoolean("debug", false)
|
return mmkv.getBoolean("debug", false)
|
||||||
}
|
}
|
||||||
|
@ -117,6 +117,9 @@ internal class HookWrapperCodec: IAction {
|
|||||||
//from.serviceCmd = "ShamrockInjectedCmd_${from.serviceCmd}"
|
//from.serviceCmd = "ShamrockInjectedCmd_${from.serviceCmd}"
|
||||||
from.setBusinessFail(1)
|
from.setBusinessFail(1)
|
||||||
from.putWupBuffer(EMPTY_BYTE_ARRAY)
|
from.putWupBuffer(EMPTY_BYTE_ARRAY)
|
||||||
|
} else if (from.serviceCmd.startsWith("trpc.o3.") && ShamrockConfig.isInjectPacket()) {
|
||||||
|
from.setBusinessFail(1)
|
||||||
|
from.putWupBuffer(EMPTY_BYTE_ARRAY)
|
||||||
} else {
|
} else {
|
||||||
pushOnReceive(from)
|
pushOnReceive(from)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user