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
4fd579a7
Commit
4fd579a7
authored
Dec 30, 2019
by
Him188
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add default values
parent
42828cbe
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
23 deletions
+42
-23
mirai-core-qqandroid/src/androidMain/kotlin/net/mamoe/mirai/qqandroid/utils/SystemDeviceInfo.kt
...otlin/net/mamoe/mirai/qqandroid/utils/SystemDeviceInfo.kt
+17
-22
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/utils/NetworkType.kt
...ain/kotlin/net/mamoe/mirai/qqandroid/utils/NetworkType.kt
+22
-0
mirai-core/src/androidMain/kotlin/net/mamoe/mirai/utils/PlatformUtilsAndroid.kt
...Main/kotlin/net/mamoe/mirai/utils/PlatformUtilsAndroid.kt
+3
-1
No files found.
mirai-core-qqandroid/src/androidMain/kotlin/net/mamoe/mirai/qqandroid/utils/SystemDeviceInfo.kt
View file @
4fd579a7
package
net.mamoe.mirai.qqandroid.utils
package
net.mamoe.mirai.qqandroid.utils
import
android.annotation.SuppressLint
import
android.annotation.SuppressLint
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
...
@@ -33,16 +34,15 @@ actual class SystemDeviceInfo actual constructor(context: Context) : DeviceInfo(
...
@@ -33,16 +34,15 @@ actual class SystemDeviceInfo actual constructor(context: Context) : DeviceInfo(
override
val
fingerprint
:
ByteArray
get
()
=
Build
.
FINGERPRINT
.
toByteArray
()
override
val
fingerprint
:
ByteArray
get
()
=
Build
.
FINGERPRINT
.
toByteArray
()
override
val
procVersion
:
ByteArray
override
val
procVersion
:
ByteArray
get
()
=
File
(
"/proc/version"
).
useLines
{
it
.
firstOrNull
()
?:
""
}.
toByteArray
()
get
()
=
kotlin
.
runCatching
{
File
(
"/proc/version"
).
useLines
{
it
.
firstOrNull
()
?:
""
}.
toByteArray
()
}.
getOrElse
{
byteArrayOf
()
}
override
val
bootId
:
ByteArray
override
val
bootId
:
ByteArray
get
()
=
File
(
"/proc/sys/kernel/random/boot_id"
).
useLines
{
it
.
firstOrNull
()
?:
""
}.
toByteArray
()
get
()
=
File
(
"/proc/sys/kernel/random/boot_id"
).
useLines
{
it
.
firstOrNull
()
?:
""
}.
toByteArray
()
override
val
version
:
DeviceInfo
.
Version
get
()
=
Version
override
val
version
:
DeviceInfo
.
Version
get
()
=
Version
override
val
simInfo
:
ByteArray
override
val
simInfo
:
ByteArray
@SuppressLint
(
"WrongConstant"
)
get
()
{
get
()
{
return
kotlin
.
runCatching
{
return
kotlin
.
runCatching
{
val
telephonyManager
=
context
.
getSystemService
(
"phone"
)
as
TelephonyManager
val
telephonyManager
=
context
.
applicationContext
.
getSystemService
(
Context
.
TELEPHONY_SERVICE
)
as
TelephonyManager
if
(
telephonyManager
.
simState
==
5
)
{
if
(
telephonyManager
.
simState
==
5
)
{
telephonyManager
.
simOperatorName
.
toByteArray
()
telephonyManager
.
simOperatorName
.
toByteArray
()
}
else
byteArrayOf
()
}
else
byteArrayOf
()
...
@@ -52,26 +52,21 @@ actual class SystemDeviceInfo actual constructor(context: Context) : DeviceInfo(
...
@@ -52,26 +52,21 @@ actual class SystemDeviceInfo actual constructor(context: Context) : DeviceInfo(
override
val
osType
:
ByteArray
=
"android"
.
toByteArray
()
override
val
osType
:
ByteArray
=
"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
()
=
TODO
(
"not implemented"
)
get
()
=
kotlin
.
runCatching
{
(
context
.
applicationContext
.
getSystemService
(
Context
.
WIFI_SERVICE
)
as
WifiManager
).
connectionInfo
.
bssid
.
toByteArray
()
}.
getOrElse
{
byteArrayOf
()
}
override
val
wifiSSID
:
ByteArray
?
override
val
wifiSSID
:
ByteArray
?
get
()
=
TODO
(
"not implemented"
)
get
()
=
kotlin
.
runCatching
{
override
val
imsiMd5
:
ByteArray
// null due to permission READ_PHONE_STATE required
(
context
.
applicationContext
.
getSystemService
(
Context
.
WIFI_SERVICE
)
as
WifiManager
).
connectionInfo
.
ssid
.
toByteArray
()
get
()
=
md5
(
byteArrayOf
())
/*{
}.
getOrElse
{
byteArrayOf
()
}
val telephonyManager = context.getSystemService("phone") as TelephonyManager
if (telephonyManager != null) {
override
val
imsiMd5
:
ByteArray
val subscriberId = telephonyManager.subscriberId
@SuppressLint
(
"HardwareIds"
)
if (subscriberId != null) {
get
()
=
md5
(
kotlin
.
runCatching
{
return subscriberId.toByteArray()
(
context
.
applicationContext
.
getSystemService
(
Context
.
TELEPHONY_SERVICE
)
as
TelephonyManager
).
subscriberId
.
toByteArray
()
}
}.
getOrElse
{
byteArrayOf
()
})
}
override
val
ipAddress
:
String
get
()
=
localIpAddress
()
return kotlin.runCatching {
val telephonyManager = context.getSystemService("phone") as TelephonyManager
if (telephonyManager != null) {
telephonyManager.subscriberId.toByteArray()
} else byteArrayOf()
}.getOrElse { byteArrayOf() }
}*/
override
val
ipAddress
:
ByteArray
get
()
=
localIpAddress
().
toByteArray
()
override
val
androidId
:
ByteArray
get
()
=
Build
.
ID
.
toByteArray
()
override
val
androidId
:
ByteArray
get
()
=
Build
.
ID
.
toByteArray
()
override
val
apn
:
ByteArray
get
()
=
"wifi"
.
toByteArray
()
override
val
apn
:
ByteArray
get
()
=
"wifi"
.
toByteArray
()
...
...
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/utils/NetworkType.kt
0 → 100644
View file @
4fd579a7
package
net.mamoe.mirai.qqandroid.utils
/**
* 连接类型
*/
inline
class
NetworkType
(
val
value
:
Int
)
{
companion
object
{
/**
* 移动网络
*/
val
MOBILE
=
NetworkType
(
1
)
/**
* Wifi
*/
val
WIFI
=
NetworkType
(
2
)
/**
* 其他任何类型
*/
val
OTHER
=
NetworkType
(
0
)
}
}
\ No newline at end of file
mirai-core/src/androidMain/kotlin/net/mamoe/mirai/utils/PlatformUtilsAndroid.kt
View file @
4fd579a7
...
@@ -28,7 +28,9 @@ actual val Http: HttpClient
...
@@ -28,7 +28,9 @@ actual val Http: HttpClient
/**
/**
* Localhost 解析
* Localhost 解析
*/
*/
actual
fun
localIpAddress
():
String
=
InetAddress
.
getLocalHost
().
hostAddress
actual
fun
localIpAddress
():
String
=
runCatching
{
InetAddress
.
getLocalHost
().
hostAddress
}.
getOrElse
{
"192.168.1.123"
}
/**
/**
* MD5 算法
* MD5 算法
...
...
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