mirror of
https://github.com/lifegpc/eh_downloader_flutter.git
synced 2026-06-06 05:49:03 +08:00
feat: 修改获取设备名称
This commit is contained in:
@@ -3,6 +3,7 @@ package com.lifegpc.ehf
|
||||
import android.app.Activity
|
||||
import android.content.Intent
|
||||
import android.os.Build
|
||||
import android.provider.Settings
|
||||
import android.view.WindowManager
|
||||
import com.lifegpc.ehf.annotation.ChannelMethod
|
||||
import com.lifegpc.ehf.eventbus.SAFAuthEvent
|
||||
@@ -68,5 +69,11 @@ class MainActivity : FlutterActivity() {
|
||||
|
||||
@ChannelMethod(methodName = "deviceName")
|
||||
@Suppress("unused")
|
||||
private fun getDeviceName(): String = Build.MODEL
|
||||
private fun getDeviceName(): String {
|
||||
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1) {
|
||||
Settings.Global.getString(contentResolver, Settings.Global.DEVICE_NAME) ?: Build.MODEL
|
||||
} else {
|
||||
Build.MODEL
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user