Android 6.0及以上 权限适配

This commit is contained in:
kehaoyuan
2017-09-13 18:23:55 +08:00
parent 2e84aeaccf
commit 85031e89b6
10 changed files with 223 additions and 151 deletions

View File

@ -3,9 +3,11 @@ package com.gh.common.util;
import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.wifi.WifiManager;
import android.os.Build;
import android.provider.Settings;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import com.gh.gamecenter.kuaichuan.WifiMgr;
import com.lightgame.utils.Util_System_Phone_State;
@ -37,7 +39,7 @@ public class DeviceUtils {
JSONObject object = new JSONObject();
object.put("os", "Android");
object.put("imei", Util_System_Phone_State.getDeviceId(context));
object.put("mac", getMac());
object.put("mac", getMac(context));
object.put("model", MODEL);
object.put("manufacturer", MANUFACTURER);
object.put("android_id", Settings.Secure.getString(context.getContentResolver(), Settings.Secure.ANDROID_ID));
@ -54,7 +56,7 @@ public class DeviceUtils {
try {
object.put("IMEI", Util_System_Phone_State.getDeviceId(context));
object.put("ANDROID_ID", Settings.Secure.getString(context.getContentResolver(), Settings.Secure.ANDROID_ID));
object.put("MAC", getMac());
object.put("MAC", getMac(context));
object.put("MTA_ID", StatConfig.getMid(context));
object.put("MANUFACTURER", MANUFACTURER);
object.put("MODEL", MODEL);
@ -67,7 +69,7 @@ public class DeviceUtils {
return object;
}
private static String getMac() {
private static String getMac(Context context) {
String str = "";
String macSerial = "";
try {
@ -96,6 +98,9 @@ public class DeviceUtils {
}
}
if (TextUtils.isEmpty(macSerial)) { // 备用方案
macSerial = ((WifiManager) context.getSystemService(Context.WIFI_SERVICE)).getConnectionInfo().getMacAddress();
}
return macSerial;
}