|
@@ -5,6 +5,7 @@ import android.content.Context
|
|
|
import android.content.Context.WIFI_SERVICE
|
|
|
import android.net.wifi.WifiManager
|
|
|
import android.os.Build
|
|
|
+import android.text.TextUtils
|
|
|
import com.wdkl.ncs.android.lib.base.BaseApplication
|
|
|
import com.enation.javashop.utils.base.cache.ACache
|
|
|
|
|
@@ -37,20 +38,30 @@ class UUID {
|
|
|
//refreshUUID("abcd1234")
|
|
|
var macAddress = ACache.get(BaseApplication.appContext).getAsString("UUID")
|
|
|
if (macAddress == null){
|
|
|
- val wifiManager :WifiManager? = BaseApplication.appContext.getSystemService(Context.WIFI_SERVICE) as WifiManager
|
|
|
- val info = wifiManager?.connectionInfo
|
|
|
- //3128不支持WiFi
|
|
|
- if (!Build.MODEL.equals("rk3128")) {
|
|
|
- if (!wifiManager!!.isWifiEnabled) {
|
|
|
- //必须先打开,才能获取到MAC地址
|
|
|
- wifiManager.isWifiEnabled = true
|
|
|
- wifiManager.isWifiEnabled = false
|
|
|
+ val wifiManager :WifiManager = BaseApplication.appContext.getSystemService(Context.WIFI_SERVICE) as WifiManager
|
|
|
+ val info = wifiManager.connectionInfo
|
|
|
+ try {
|
|
|
+ //3128不支持WiFi
|
|
|
+ if (!Build.MODEL.equals("rk3128")) {
|
|
|
+ if (!wifiManager.isWifiEnabled) {
|
|
|
+ //必须先打开,才能获取到MAC地址
|
|
|
+ wifiManager.isWifiEnabled = true
|
|
|
+ wifiManager.isWifiEnabled = false
|
|
|
+ }
|
|
|
}
|
|
|
+ } catch (e: Exception) {
|
|
|
+ //e.printStackTrace()
|
|
|
}
|
|
|
+
|
|
|
if (null != info) {
|
|
|
macAddress = info.macAddress
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ if (TextUtils.isEmpty(macAddress)) {
|
|
|
+ macAddress = "10" + System.currentTimeMillis()
|
|
|
+ }
|
|
|
+
|
|
|
return macAddress
|
|
|
}
|
|
|
|