diff --git a/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/io/serialization/JceNew.kt b/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/io/serialization/JceNew.kt index ddbf8ac06..d5c7a00b8 100644 --- a/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/io/serialization/JceNew.kt +++ b/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/io/serialization/JceNew.kt @@ -191,12 +191,12 @@ private class JceInput( /** * 跳过 [JceHead] 和对应的数据值, 直到找到 [tag], 否则抛出异常 */ - inline fun skipToTagAndUseIfPossibleOrFail( + inline fun skipToTagAndUseIfPossibleOrFail( tag: Int, crossinline message: () -> String = { "tag not found: $tag" }, crossinline block: (JceHead) -> R ): R { - return checkNotNull(skipToTagAndUseIfPossibleOrNull(tag, block), message) + return checkNotNull(skipToTagAndUseIfPossibleOrNull(tag, block), message) } tailrec fun skipToHeadOrNull(tag: Int): JceHead? { diff --git a/mirai-core/src/androidMain/kotlin/net/mamoe/mirai/utils/ExternalImageAndroid.kt b/mirai-core/src/androidMain/kotlin/net/mamoe/mirai/utils/ExternalImageAndroid.kt index 328af2a50..285a37cbe 100644 --- a/mirai-core/src/androidMain/kotlin/net/mamoe/mirai/utils/ExternalImageAndroid.kt +++ b/mirai-core/src/androidMain/kotlin/net/mamoe/mirai/utils/ExternalImageAndroid.kt @@ -30,8 +30,9 @@ import java.net.URL /** - * 读取 [BufferedImage] 的属性, 然后构造 [ExternalImage] + * 读取 [Bitmap] 的属性, 然后构造 [ExternalImage] */ +@Suppress("UNUSED_PARAMETER") @Throws(IOException::class) fun Bitmap.toExternalImage(formatName: String = "gif"): Nothing { TODO() diff --git a/mirai-core/src/androidMain/kotlin/net/mamoe/mirai/utils/SystemDeviceInfo.kt b/mirai-core/src/androidMain/kotlin/net/mamoe/mirai/utils/SystemDeviceInfo.kt index ba502818c..523aef15f 100644 --- a/mirai-core/src/androidMain/kotlin/net/mamoe/mirai/utils/SystemDeviceInfo.kt +++ b/mirai-core/src/androidMain/kotlin/net/mamoe/mirai/utils/SystemDeviceInfo.kt @@ -7,6 +7,8 @@ * https://github.com/mamoe/mirai/blob/master/LICENSE */ +@file:Suppress("unused") + package net.mamoe.mirai.utils import android.annotation.SuppressLint @@ -18,6 +20,7 @@ import kotlinx.serialization.Serializable import kotlinx.serialization.Transient import kotlinx.serialization.UnstableDefault import kotlinx.serialization.json.Json +import kotlinx.serialization.json.JsonConfiguration import java.io.File /** @@ -27,14 +30,17 @@ import java.io.File fun File.loadAsDeviceInfo(context: Context): DeviceInfo { if (!this.exists() || this.length() == 0L) { return SystemDeviceInfo(context).also { - this.writeText(Json.plain.stringify(SystemDeviceInfo.serializer(), it)) + this.writeText(JSON.stringify(SystemDeviceInfo.serializer(), it)) } } - return Json.nonstrict.parse(DeviceInfoData.serializer(), this.readText()).also { + return JSON.parse(DeviceInfoData.serializer(), this.readText()).also { it.context = context } } +@OptIn(UnstableDefault::class) +private val JSON = Json(JsonConfiguration.Default) + /** * 部分引用指向 [Build]. * 部分需要权限, 若无权限则会使用默认值. diff --git a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/utils/ExternalImage.kt b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/utils/ExternalImage.kt index 527c76ec5..b14b5b137 100644 --- a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/utils/ExternalImage.kt +++ b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/utils/ExternalImage.kt @@ -15,6 +15,7 @@ import io.ktor.utils.io.ByteReadChannel import io.ktor.utils.io.core.ByteReadPacket import io.ktor.utils.io.core.Input import kotlinx.io.InputStream +import kotlinx.serialization.InternalSerializationApi import net.mamoe.mirai.contact.Contact import net.mamoe.mirai.contact.Group import net.mamoe.mirai.contact.QQ @@ -69,6 +70,7 @@ class ExternalImage private constructor( filename: String ) : this(width, height, md5, imageFormat, input as Any, input.remaining, filename) + @OptIn(InternalSerializationApi::class) constructor( width: Int, height: Int,