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
ee45ad63
Commit
ee45ad63
authored
Mar 17, 2020
by
Him188
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix #141
parent
d5168b7e
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
15 deletions
+26
-15
mirai-core/src/androidMain/kotlin/net/mamoe/mirai/utils/SystemDeviceInfo.kt
...roidMain/kotlin/net/mamoe/mirai/utils/SystemDeviceInfo.kt
+26
-15
No files found.
mirai-core/src/androidMain/kotlin/net/mamoe/mirai/utils/SystemDeviceInfo.kt
View file @
ee45ad63
...
...
@@ -77,39 +77,42 @@ actual open class SystemDeviceInfo actual constructor() : DeviceInfo() {
override
val
fingerprint
:
ByteArray
get
()
=
Build
.
FINGERPRINT
.
toByteArray
()
override
val
procVersion
:
ByteArray
get
()
=
kotlin
.
runCatching
{
File
(
"/proc/version"
).
useLines
{
it
.
firstOrNull
()
?:
""
}.
toByteArray
()
}.
getOrElse
{
byteArrayOf
()
}
get
()
=
kotlin
.
runCatching
{
File
(
"/proc/version"
).
useLines
{
it
.
firstOrNull
()
?:
""
}.
toByteArray
()
}
.
getOrElse
{
byteArrayOf
()
}
override
val
bootId
:
ByteArray
get
()
=
File
(
"/proc/sys/kernel/random/boot_id"
).
useLines
{
it
.
firstOrNull
()
?:
""
}.
toByteArray
()
get
()
=
kotlin
.
runCatching
{
File
(
"/proc/sys/kernel/random/boot_id"
).
useLines
{
it
.
firstOrNull
()
?:
""
}.
toByteArray
()
}.
getOrEmpty
()
override
val
version
:
DeviceInfo
.
Version
get
()
=
Version
override
val
simInfo
:
ByteArray
get
()
{
return
kotlin
.
runCatching
{
val
telephonyManager
=
context
.
applicationContext
.
getSystemService
(
Context
.
TELEPHONY_SERVICE
)
as
TelephonyManager
get
()
=
kotlin
.
runCatching
{
val
telephonyManager
=
context
.
applicationContext
.
getSystemService
(
Context
.
TELEPHONY_SERVICE
)
as
TelephonyManager
if
(
telephonyManager
.
simState
==
5
)
{
telephonyManager
.
simOperatorName
.
toByteArray
()
}
else
byteArrayOf
()
}.
getOrElse
{
byteArrayOf
()
}
}
}.
getOrEmpty
()
override
val
osType
:
ByteArray
=
"android"
.
toByteArray
()
override
val
macAddress
:
ByteArray
get
()
=
"02:00:00:00:00:00"
.
toByteArray
()
override
val
wifiBSSID
:
ByteArray
?
get
()
=
kotlin
.
runCatching
{
(
context
.
applicationContext
.
getSystemService
(
Context
.
WIFI_SERVICE
)
as
WifiManager
).
connectionInfo
.
bssid
.
toByteArray
()
}.
getOrE
lse
{
byteArrayOf
()
}
}.
getOrE
mpty
()
override
val
wifiSSID
:
ByteArray
?
get
()
=
kotlin
.
runCatching
{
(
context
.
applicationContext
.
getSystemService
(
Context
.
WIFI_SERVICE
)
as
WifiManager
).
connectionInfo
.
ssid
.
toByteArray
()
}.
getOrE
lse
{
byteArrayOf
()
}
}.
getOrE
mpty
()
@OptIn
(
MiraiInternalAPI
::
class
)
override
val
imsiMd5
:
ByteArray
@SuppressLint
(
"HardwareIds"
)
get
()
=
md5
(
kotlin
.
runCatching
{
(
context
.
applicationContext
.
getSystemService
(
Context
.
TELEPHONY_SERVICE
)
as
TelephonyManager
).
subscriberId
.
toByteArray
()
}.
getOrElse
{
byteArrayOf
()
})
}.
getOrEmpty
())
override
val
imei
:
String
@SuppressLint
(
"HardwareIds"
)
get
()
=
kotlin
.
runCatching
{
...
...
@@ -122,7 +125,10 @@ actual open class SystemDeviceInfo actual constructor() : DeviceInfo() {
}.
getOrElse
{
""
}
@OptIn
(
MiraiInternalAPI
::
class
)
override
val
ipAddress
:
ByteArray
get
()
=
localIpAddress
().
split
(
"."
).
map
{
it
.
toByte
()
}.
takeIf
{
it
.
size
==
4
}
?.
toByteArray
()
?:
byteArrayOf
()
override
val
ipAddress
:
ByteArray
get
()
=
kotlin
.
runCatching
{
localIpAddress
().
split
(
"."
).
map
{
it
.
toByte
()
}.
takeIf
{
it
.
size
==
4
}
?.
toByteArray
()
?:
ByteArray
(
4
)
}.
getOrElse
{
ByteArray
(
4
)
}
override
val
androidId
:
ByteArray
get
()
=
Build
.
ID
.
toByteArray
()
override
val
apn
:
ByteArray
get
()
=
"wifi"
.
toByteArray
()
...
...
@@ -134,3 +140,8 @@ actual open class SystemDeviceInfo actual constructor() : DeviceInfo() {
override
val
sdk
:
Int
get
()
=
Build
.
VERSION
.
SDK_INT
}
}
private
val
EMPTY_BYTE_ARRAY
:
ByteArray
=
ByteArray
(
0
)
@Suppress
(
"NOTHING_TO_INLINE"
)
private
inline
fun
Result
<
ByteArray
>.
getOrEmpty
()
=
this
.
getOrNull
()
?:
EMPTY_BYTE_ARRAY
\ No newline at end of file
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