From 5fe23800f060bd8d39d77b66563ffd28f0ab73b5 Mon Sep 17 00:00:00 2001 From: Him188 <Him188@mamoe.net> Date: Mon, 6 Jan 2020 16:53:30 +0800 Subject: [PATCH] Use actual imei --- .../mamoe/mirai/qqandroid/utils/SystemDeviceInfo.kt | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/mirai-core-qqandroid/src/androidMain/kotlin/net/mamoe/mirai/qqandroid/utils/SystemDeviceInfo.kt b/mirai-core-qqandroid/src/androidMain/kotlin/net/mamoe/mirai/qqandroid/utils/SystemDeviceInfo.kt index 952654967..e522c17d7 100644 --- a/mirai-core-qqandroid/src/androidMain/kotlin/net/mamoe/mirai/qqandroid/utils/SystemDeviceInfo.kt +++ b/mirai-core-qqandroid/src/androidMain/kotlin/net/mamoe/mirai/qqandroid/utils/SystemDeviceInfo.kt @@ -66,8 +66,17 @@ actual class SystemDeviceInfo actual constructor(context: Context) : DeviceInfo( get() = md5(kotlin.runCatching { (context.applicationContext.getSystemService(Context.TELEPHONY_SERVICE) as TelephonyManager).subscriberId.toByteArray() }.getOrElse { byteArrayOf() }) - override val imei: String get() = "858414369211993" // TODO: 2020/1/5 get actual imei and ksid - override val ksid: String get() = "|454001228437590|A8.2.0.27f6ea96" + override val imei: String + @SuppressLint("HardwareIds") + get() = kotlin.runCatching { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + (context.applicationContext.getSystemService(Context.TELEPHONY_SERVICE) as TelephonyManager).imei + } else { + @Suppress("DEPRECATION") + (context.applicationContext.getSystemService(Context.TELEPHONY_SERVICE) as TelephonyManager).deviceId + } + }.getOrElse { "" } + override val ksid: String get() = "|454001228437590|A8.2.0.27f6ea96" // get from T108 override val ipAddress: String get() = localIpAddress() override val androidId: ByteArray get() = Build.ID.toByteArray() override val apn: ByteArray get() = "wifi".toByteArray()