Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
M
Mirai
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MyCard
Mirai
Commits
e1162241
Commit
e1162241
authored
Feb 09, 2020
by
Him188
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move DeviceInfo
parent
23adcf6d
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
38 additions
and
36 deletions
+38
-36
mirai-core/src/androidMain/kotlin/net/mamoe/mirai/utils/SystemDeviceInfo.kt
...roidMain/kotlin/net/mamoe/mirai/utils/SystemDeviceInfo.kt
+4
-6
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/utils/BotConfiguration.kt
...mmonMain/kotlin/net.mamoe.mirai/utils/BotConfiguration.kt
+4
-0
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/utils/DeviceInfo.kt
...src/commonMain/kotlin/net.mamoe.mirai/utils/DeviceInfo.kt
+12
-11
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/utils/SystemDeviceInfo.kt
...mmonMain/kotlin/net.mamoe.mirai/utils/SystemDeviceInfo.kt
+7
-3
mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/utils/SystemDeviceInfo.kt
.../jvmMain/kotlin/net/mamoe/mirai/utils/SystemDeviceInfo.kt
+11
-16
No files found.
mirai-core
-qqandroid/src/androidMain/kotlin/net/mamoe/mirai/qqandroid
/utils/SystemDeviceInfo.kt
→
mirai-core
/src/androidMain/kotlin/net/mamoe/mirai
/utils/SystemDeviceInfo.kt
View file @
e1162241
...
@@ -7,22 +7,20 @@
...
@@ -7,22 +7,20 @@
* https://github.com/mamoe/mirai/blob/master/LICENSE
* https://github.com/mamoe/mirai/blob/master/LICENSE
*/
*/
package
net.mamoe.mirai.
qqandroid.
utils
package
net.mamoe.mirai.utils
import
android.annotation.SuppressLint
import
android.annotation.SuppressLint
import
android.net.wifi.WifiManager
import
android.net.wifi.WifiManager
import
android.os.Build
import
android.os.Build
import
android.telephony.TelephonyManager
import
android.telephony.TelephonyManager
import
kotlinx.io.core.toByteArray
import
kotlinx.io.core.toByteArray
import
net.mamoe.mirai.utils.Context
import
net.mamoe.mirai.utils.localIpAddress
import
net.mamoe.mirai.utils.md5
import
java.io.File
import
java.io.File
/**
/**
* Delegated by [Build]
* 部分引用指向 [Build].
* 部分需要权限, 若无权限则会使用默认值.
*/
*/
actual
class
SystemDeviceInfo
actual
constructor
(
context
:
Context
)
:
DeviceInfo
(
context
)
{
actual
open
class
SystemDeviceInfo
actual
constructor
(
context
:
Context
)
:
DeviceInfo
(
context
)
{
override
val
display
:
ByteArray
get
()
=
Build
.
DISPLAY
.
toByteArray
()
override
val
display
:
ByteArray
get
()
=
Build
.
DISPLAY
.
toByteArray
()
override
val
product
:
ByteArray
get
()
=
Build
.
PRODUCT
.
toByteArray
()
override
val
product
:
ByteArray
get
()
=
Build
.
PRODUCT
.
toByteArray
()
override
val
device
:
ByteArray
get
()
=
Build
.
DEVICE
.
toByteArray
()
override
val
device
:
ByteArray
get
()
=
Build
.
DEVICE
.
toByteArray
()
...
...
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/utils/BotConfiguration.kt
View file @
e1162241
...
@@ -39,6 +39,10 @@ class BotConfiguration {
...
@@ -39,6 +39,10 @@ class BotConfiguration {
* 日志记录器
* 日志记录器
*/
*/
var
logger
:
MiraiLogger
?
=
null
var
logger
:
MiraiLogger
?
=
null
/**
* 设备信息覆盖
*/
var
deviceInfo
:
((
Context
)
->
DeviceInfo
)?
=
null
/**
/**
* 父 [CoroutineContext]
* 父 [CoroutineContext]
...
...
mirai-core
-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid
/utils/DeviceInfo.kt
→
mirai-core
/src/commonMain/kotlin/net.mamoe.mirai
/utils/DeviceInfo.kt
View file @
e1162241
...
@@ -7,17 +7,17 @@
...
@@ -7,17 +7,17 @@
* https://github.com/mamoe/mirai/blob/master/LICENSE
* https://github.com/mamoe/mirai/blob/master/LICENSE
*/
*/
package
net.mamoe.mirai.
qqandroid.
utils
package
net.mamoe.mirai.utils
import
kotlinx.serialization.SerialId
import
kotlinx.serialization.SerialId
import
kotlinx.serialization.Serializable
import
kotlinx.serialization.Serializable
import
net.mamoe.mirai.qqandroid.io.serialization.ProtoBufWithNullableSupport
import
kotlinx.serialization.protobuf.ProtoBuf
import
net.mamoe.mirai.utils.Context
import
net.mamoe.mirai.utils.cryptor.contentToString
import
net.mamoe.mirai.utils.cryptor.contentToString
import
net.mamoe.mirai.utils.getValue
import
net.mamoe.mirai.utils.unsafeWeakRef
abstract
class
DeviceInfo
(
/**
* 设备信息. 可通过继承 [SystemDeviceInfo] 来在默认的基础上修改
*/
abstract
class
DeviceInfo
internal
constructor
(
context
:
Context
context
:
Context
)
{
)
{
val
context
:
Context
by
context
.
unsafeWeakRef
()
val
context
:
Context
by
context
.
unsafeWeakRef
()
...
@@ -72,7 +72,7 @@ abstract class DeviceInfo(
...
@@ -72,7 +72,7 @@ abstract class DeviceInfo(
@SerialId
(
9
)
val
innerVersion
:
ByteArray
@SerialId
(
9
)
val
innerVersion
:
ByteArray
)
)
return
ProtoBuf
WithNullableSupport
.
dump
(
return
ProtoBuf
.
dump
(
DevInfo
.
serializer
(),
DevInfo
(
DevInfo
.
serializer
(),
DevInfo
(
bootloader
,
bootloader
,
procVersion
,
procVersion
,
...
@@ -87,10 +87,6 @@ abstract class DeviceInfo(
...
@@ -87,10 +87,6 @@ abstract class DeviceInfo(
)
)
}
}
override
fun
toString
():
String
{
// net.mamoe.mirai.utils.cryptor.ProtoKt.contentToString
return
"DeviceInfo(display=${display.contentToString()}, product=${product.contentToString()}, device=${device.contentToString()}, board=${board.contentToString()}, brand=${brand.contentToString()}, model=${model.contentToString()}, bootloader=${bootloader.contentToString()}, fingerprint=${fingerprint.contentToString()}, bootId=${bootId.contentToString()}, procVersion=${procVersion.contentToString()}, baseBand=${baseBand.contentToString()}, version=$version, simInfo=${simInfo.contentToString()}, osType=${osType.contentToString()}, macAddress=${macAddress.contentToString()}, wifiBSSID=${wifiBSSID?.contentToString()}, wifiSSID=${wifiSSID?.contentToString()}, imsiMd5=${imsiMd5.contentToString()}, imei='$imei', ipAddress='$ipAddress', androidId=${androidId.contentToString()}, apn=${apn.contentToString()})"
}
interface
Version
{
interface
Version
{
val
incremental
:
ByteArray
val
incremental
:
ByteArray
val
release
:
ByteArray
val
release
:
ByteArray
...
@@ -99,6 +95,11 @@ abstract class DeviceInfo(
...
@@ -99,6 +95,11 @@ abstract class DeviceInfo(
}
}
}
}
/**
* Defaults "%4;7t>;28<fc.5*6".toByteArray()
*/
fun
generateGuid
(
androidId
:
ByteArray
,
macAddress
:
ByteArray
):
ByteArray
=
md5
(
androidId
+
macAddress
)
/*
/*
fun DeviceInfo.toOidb0x769DeviceInfo() : Oidb0x769.DeviceInfo = Oidb0x769.DeviceInfo(
fun DeviceInfo.toOidb0x769DeviceInfo() : Oidb0x769.DeviceInfo = Oidb0x769.DeviceInfo(
brand = brand.encodeToString(),
brand = brand.encodeToString(),
...
...
mirai-core
-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid
/utils/SystemDeviceInfo.kt
→
mirai-core
/src/commonMain/kotlin/net.mamoe.mirai
/utils/SystemDeviceInfo.kt
View file @
e1162241
...
@@ -7,11 +7,15 @@
...
@@ -7,11 +7,15 @@
* https://github.com/mamoe/mirai/blob/master/LICENSE
* https://github.com/mamoe/mirai/blob/master/LICENSE
*/
*/
package
net.mamoe.mirai.
qqandroid.
utils
package
net.mamoe.mirai.utils
import
net.mamoe.mirai.utils.Context
import
net.mamoe.mirai.utils.Context
import
net.mamoe.mirai.utils.DeviceInfo
/**
/**
* System default values
* 通过本机信息来获取设备信息.
*
* Android: 获取手机信息, 与 QQ 官方相同.
* JVM: 部分为常量, 部分为随机
*/
*/
expect
class
SystemDeviceInfo
(
context
:
Context
)
:
DeviceInfo
open
expect
class
SystemDeviceInfo
(
context
:
Context
)
:
DeviceInfo
\ No newline at end of file
\ No newline at end of file
mirai-core
-qqandroid/src/jvmMain/kotlin/net/mamoe/mirai/qqandroid
/utils/SystemDeviceInfo.kt
→
mirai-core
/src/jvmMain/kotlin/net/mamoe/mirai
/utils/SystemDeviceInfo.kt
View file @
e1162241
...
@@ -7,13 +7,14 @@
...
@@ -7,13 +7,14 @@
* https://github.com/mamoe/mirai/blob/master/LICENSE
* https://github.com/mamoe/mirai/blob/master/LICENSE
*/
*/
package
net.mamoe.mirai.
qqandroid.
utils
package
net.mamoe.mirai.utils
import
kotlinx.io.core.toByteArray
import
kotlinx.io.core.toByteArray
import
net.mamoe.mirai.utils.
Context
import
net.mamoe.mirai.utils.
io.getRandomByteArray
import
net.mamoe.mirai.utils.
localIpAddress
import
net.mamoe.mirai.utils.
io.getRandomString
actual
class
SystemDeviceInfo
actual
constructor
(
context
:
Context
)
:
DeviceInfo
(
context
)
{
@UseExperimental
(
ExperimentalUnsignedTypes
::
class
)
actual
open
class
SystemDeviceInfo
actual
constructor
(
context
:
Context
)
:
DeviceInfo
(
context
)
{
override
val
display
:
ByteArray
get
()
=
"MIRAI.200122.001"
.
toByteArray
()
override
val
display
:
ByteArray
get
()
=
"MIRAI.200122.001"
.
toByteArray
()
override
val
product
:
ByteArray
get
()
=
"mirai"
.
toByteArray
()
override
val
product
:
ByteArray
get
()
=
"mirai"
.
toByteArray
()
override
val
device
:
ByteArray
get
()
=
"mirai"
.
toByteArray
()
override
val
device
:
ByteArray
get
()
=
"mirai"
.
toByteArray
()
...
@@ -22,24 +23,18 @@ actual class SystemDeviceInfo actual constructor(context: Context) : DeviceInfo(
...
@@ -22,24 +23,18 @@ actual class SystemDeviceInfo actual constructor(context: Context) : DeviceInfo(
override
val
model
:
ByteArray
get
()
=
"mirai"
.
toByteArray
()
override
val
model
:
ByteArray
get
()
=
"mirai"
.
toByteArray
()
override
val
bootloader
:
ByteArray
get
()
=
"unknown"
.
toByteArray
()
override
val
bootloader
:
ByteArray
get
()
=
"unknown"
.
toByteArray
()
override
val
fingerprint
:
ByteArray
get
()
=
"mamoe/mirai/mirai:10/MIRAI.200122.001/5891938:user/release-keys"
.
toByteArray
()
override
val
fingerprint
:
ByteArray
get
()
=
"mamoe/mirai/mirai:10/MIRAI.200122.001/5891938:user/release-keys"
.
toByteArray
()
override
val
bootId
:
ByteArray
get
()
=
"5974cb66-bb69-4e82-a436-836b98ebd88c"
.
toByteArray
()
override
val
bootId
:
ByteArray
=
ExternalImage
.
generateUUID
(
md5
(
getRandomByteArray
(
16
)))
.
toByteArray
()
override
val
procVersion
:
ByteArray
get
()
=
"Linux version 3.0.31-g6fb96c9 (android-build@xxx.xxx.xxx.xxx.com)"
.
toByteArray
()
override
val
procVersion
:
ByteArray
get
()
=
"Linux version 3.0.31-g6fb96c9 (android-build@xxx.xxx.xxx.xxx.com)"
.
toByteArray
()
override
val
baseBand
:
ByteArray
get
()
=
byteArrayOf
()
override
val
baseBand
:
ByteArray
get
()
=
byteArrayOf
()
override
val
version
:
DeviceInfo
.
Version
get
()
=
Version
override
val
version
:
DeviceInfo
.
Version
get
()
=
Version
override
val
simInfo
:
ByteArray
get
()
=
"T-Mobile"
.
toByteArray
()
override
val
simInfo
:
ByteArray
get
()
=
"T-Mobile"
.
toByteArray
()
override
val
osType
:
ByteArray
get
()
=
"android"
.
toByteArray
()
override
val
osType
:
ByteArray
get
()
=
"android"
.
toByteArray
()
override
val
macAddress
:
ByteArray
get
()
=
"02:00:00:00:00:00"
.
toByteArray
()
override
val
macAddress
:
ByteArray
get
()
=
"02:00:00:00:00:00"
.
toByteArray
()
override
val
wifiBSSID
:
ByteArray
?
override
val
wifiBSSID
:
ByteArray
?
get
()
=
"02:00:00:00:00:00"
.
toByteArray
()
get
()
=
"02:00:00:00:00:00"
.
toByteArray
()
override
val
wifiSSID
:
ByteArray
?
get
()
=
"<unknown ssid>"
.
toByteArray
()
override
val
wifiSSID
:
ByteArray
?
override
val
imsiMd5
:
ByteArray
get
()
=
md5
(
getRandomByteArray
(
16
))
get
()
=
"<unknown ssid>"
.
toByteArray
()
override
val
imei
:
String
get
()
=
getRandomString
(
15
,
'0'
..
'9'
)
@UseExperimental
(
ExperimentalUnsignedTypes
::
class
)
override
val
ipAddress
:
ByteArray
get
()
=
localIpAddress
().
split
(
"."
).
map
{
it
.
toUByte
().
toByte
()
}.
takeIf
{
it
.
size
==
4
}
?.
toByteArray
()
?:
byteArrayOf
()
override
val
imsiMd5
:
ByteArray
get
()
=
ubyteArrayOf
(
0
xD4u
,
0
x1Du
,
0
x8Cu
,
0
xD9u
,
0
x8Fu
,
0
x00u
,
0
xB2u
,
0
x04u
,
0
xE9u
,
0
x80u
,
0
x09u
,
0
x98u
,
0
xECu
,
0
xF8u
,
0
x42u
,
0
x7Eu
).
toByteArray
()
override
val
imei
:
String
get
()
=
"858414524711993"
@UseExperimental
(
ExperimentalUnsignedTypes
::
class
)
override
val
ipAddress
:
ByteArray
get
()
=
localIpAddress
().
split
(
"."
).
map
{
it
.
toUByte
().
toByte
()
}.
takeIf
{
it
.
size
==
4
}
?.
toByteArray
()
?:
byteArrayOf
()
override
val
androidId
:
ByteArray
get
()
=
display
override
val
androidId
:
ByteArray
get
()
=
display
override
val
apn
:
ByteArray
get
()
=
"wifi"
.
toByteArray
()
override
val
apn
:
ByteArray
get
()
=
"wifi"
.
toByteArray
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment