The getSerial function is not executed by the system application and an error is reported

This commit is contained in:
Jtun-coder 2024-11-28 09:24:18 +08:00
parent 9b1d2e1e25
commit c5163fe939
3 changed files with 8 additions and 5 deletions

View File

@ -11,9 +11,9 @@
"type": "SINGLE", "type": "SINGLE",
"filters": [], "filters": [],
"attributes": [], "attributes": [],
"versionCode": 2, "versionCode": 3,
"versionName": "1.0.02", "versionName": "1.0.03",
"outputFile": "JtunRouter_v1.0.02.apk" "outputFile": "JtunRouter_v1.0.03.apk"
} }
], ],
"elementType": "File" "elementType": "File"

View File

@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:sharedUserId="android.uid.system"
> >
<uses-feature <uses-feature

View File

@ -62,7 +62,11 @@ object DeviceUtil {
fun getDeviceSerial():String{ fun getDeviceSerial():String{
var serial = "" var serial = ""
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
try {
//不是系统应用会报错
serial = Build.getSerial() serial = Build.getSerial()
}catch (_:Exception){
}
if(serial.isEmpty()){ if(serial.isEmpty()){
WifiApControl.getInstance().getImei()?.let { WifiApControl.getInstance().getImei()?.let {
serial = it serial = it