weakRef context

This commit is contained in:
Him188 2020-01-10 23:09:04 +08:00
parent db214d948d
commit d1419824a9
2 changed files with 6 additions and 3 deletions

View File

@ -32,7 +32,7 @@ import net.mamoe.mirai.utils.unsafeWeakRef
@PublishedApi
internal open class QQAndroidClient(
val context: Context,
context: Context,
@MiraiInternalAPI("Be careful. Do not use the id in BotAccount. use client.uin instead")
val account: BotAccount,
@ -40,6 +40,7 @@ internal open class QQAndroidClient(
val device: DeviceInfo = SystemDeviceInfo(context),
bot: QQAndroidBot
) {
val context by context.unsafeWeakRef()
val bot: QQAndroidBot by bot.unsafeWeakRef()
val tgtgtKey: ByteArray = ByteArray(16) // generateTgtgtKey(device.guid)

View File

@ -3,10 +3,13 @@ package net.mamoe.mirai.qqandroid.utils
import kotlinx.serialization.SerialId
import kotlinx.serialization.Serializable
import kotlinx.serialization.protobuf.ProtoBuf
import net.mamoe.mirai.utils.unsafeWeakRef
abstract class DeviceInfo(
val context: Context
context: Context
) {
val context: Context by context.unsafeWeakRef()
abstract val display: ByteArray
abstract val product: ByteArray
abstract val device: ByteArray
@ -34,7 +37,6 @@ abstract class DeviceInfo(
abstract val imsiMd5: ByteArray
abstract val imei: String
abstract val ksid: String
abstract val ipAddress: String