mirror of
https://github.com/HighCapable/YukiHookAPI.git
synced 2025-09-04 09:45:19 +08:00
Modify move createWrapperId function to RandomSeed.createString function in ChannelDataWrapper, YukiHookDataChannel, UtilsFactory
This commit is contained in:
@@ -218,4 +218,22 @@ internal fun <T> T.value() = ModifyValue(value = this)
|
|||||||
* 可修改变量实现类
|
* 可修改变量实现类
|
||||||
* @param value 变量自身实例
|
* @param value 变量自身实例
|
||||||
*/
|
*/
|
||||||
internal data class ModifyValue<T>(var value: T)
|
internal data class ModifyValue<T>(var value: T)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 随机种子工具类
|
||||||
|
*/
|
||||||
|
internal object RandomSeed {
|
||||||
|
|
||||||
|
/** 随机字母和数字定义 */
|
||||||
|
private const val RANDOM_LETTERS_NUMBERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生成随机字符串
|
||||||
|
* @param length 生成长度 - 默认 15
|
||||||
|
* @return [String]
|
||||||
|
*/
|
||||||
|
internal fun createString(length: Int = 15) = StringBuilder().apply {
|
||||||
|
for (i in 1..length) append(RANDOM_LETTERS_NUMBERS[(0..RANDOM_LETTERS_NUMBERS.lastIndex).random()])
|
||||||
|
}.toString()
|
||||||
|
}
|
@@ -47,6 +47,7 @@ import com.highcapable.yukihookapi.hook.log.YukiHookLogger
|
|||||||
import com.highcapable.yukihookapi.hook.log.YukiLoggerData
|
import com.highcapable.yukihookapi.hook.log.YukiLoggerData
|
||||||
import com.highcapable.yukihookapi.hook.log.yLoggerE
|
import com.highcapable.yukihookapi.hook.log.yLoggerE
|
||||||
import com.highcapable.yukihookapi.hook.log.yLoggerW
|
import com.highcapable.yukihookapi.hook.log.yLoggerW
|
||||||
|
import com.highcapable.yukihookapi.hook.utils.RandomSeed
|
||||||
import com.highcapable.yukihookapi.hook.xposed.application.ModuleApplication
|
import com.highcapable.yukihookapi.hook.xposed.application.ModuleApplication
|
||||||
import com.highcapable.yukihookapi.hook.xposed.bridge.YukiXposedModule
|
import com.highcapable.yukihookapi.hook.xposed.bridge.YukiXposedModule
|
||||||
import com.highcapable.yukihookapi.hook.xposed.channel.data.ChannelData
|
import com.highcapable.yukihookapi.hook.xposed.channel.data.ChannelData
|
||||||
@@ -402,12 +403,12 @@ class YukiHookDataChannel private constructor() {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* [ChannelData]<[T]> 转换为 [ChannelDataWrapper]<[T]> 实例
|
* [ChannelData]<[T]> 转换为 [ChannelDataWrapper]<[T]> 实例
|
||||||
* @param id 包装实例 ID - 默认为 [ChannelDataWrapper.createWrapperId]
|
* @param id 包装实例 ID - 默认为 [RandomSeed.createString]
|
||||||
* @param size 分段数据总大小 (长度) - 默认为 -1
|
* @param size 分段数据总大小 (长度) - 默认为 -1
|
||||||
* @param index 分段数据当前接收到的下标 - 默认为 -1
|
* @param index 分段数据当前接收到的下标 - 默认为 -1
|
||||||
* @return [ChannelDataWrapper]<[T]>
|
* @return [ChannelDataWrapper]<[T]>
|
||||||
*/
|
*/
|
||||||
private fun <T> ChannelData<T>.toWrapper(id: String = ChannelDataWrapper.createWrapperId(), size: Int = -1, index: Int = -1) =
|
private fun <T> ChannelData<T>.toWrapper(id: String = RandomSeed.createString(), size: Int = -1, index: Int = -1) =
|
||||||
ChannelDataWrapper(id, size > 0, size, index, this)
|
ChannelDataWrapper(id, size > 0, size, index, this)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -513,7 +514,7 @@ class YukiHookDataChannel private constructor() {
|
|||||||
private fun parseSendingData(wrapper: ChannelDataWrapper<*>) {
|
private fun parseSendingData(wrapper: ChannelDataWrapper<*>) {
|
||||||
if (YukiHookAPI.Configs.isEnableDataChannel.not()) return
|
if (YukiHookAPI.Configs.isEnableDataChannel.not()) return
|
||||||
/** 当前包装实例 ID */
|
/** 当前包装实例 ID */
|
||||||
val wrapperId = ChannelDataWrapper.createWrapperId()
|
val wrapperId = RandomSeed.createString()
|
||||||
|
|
||||||
/** 当前需要发送的数据字节大小 */
|
/** 当前需要发送的数据字节大小 */
|
||||||
val dataByteSize = wrapper.instance.calDataByteSize()
|
val dataByteSize = wrapper.instance.calDataByteSize()
|
||||||
|
@@ -29,7 +29,6 @@ package com.highcapable.yukihookapi.hook.xposed.channel.data.wrapper
|
|||||||
|
|
||||||
import com.highcapable.yukihookapi.hook.xposed.channel.data.ChannelData
|
import com.highcapable.yukihookapi.hook.xposed.channel.data.ChannelData
|
||||||
import java.io.Serializable
|
import java.io.Serializable
|
||||||
import java.util.*
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 数据通讯桥键值数据包装类
|
* 数据通讯桥键值数据包装类
|
||||||
@@ -45,18 +44,4 @@ internal data class ChannelDataWrapper<T>(
|
|||||||
val segmentsSize: Int,
|
val segmentsSize: Int,
|
||||||
val segmentsIndex: Int,
|
val segmentsIndex: Int,
|
||||||
val instance: ChannelData<T>
|
val instance: ChannelData<T>
|
||||||
) : Serializable {
|
) : Serializable
|
||||||
|
|
||||||
internal companion object {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 创建新的包装实例 ID
|
|
||||||
* @return [String]
|
|
||||||
*/
|
|
||||||
internal fun createWrapperId() = Random().let { random ->
|
|
||||||
var randomId = ""
|
|
||||||
for (i in 0..5) randomId += ((if (random.nextInt(2) % 2 == 0) 65 else 97) + random.nextInt(26)).toChar()
|
|
||||||
"$randomId${System.currentTimeMillis()}"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Reference in New Issue
Block a user