public class DeviceUtil {
private static final String LOGTAG = DeviceUtil.class.getSimpleName();
private static TelephonyManager telMgr;
private static WifiManager wifiMgr;
public static String getDeviceId(Context context) {
initManager(context);
if (telMgr != null) {
String str5 = telMgr.getDeviceId();
LogcatUtils.i("INFO1", "deviceId:" + str5);
LogcatUtils.i("INFO1", "deviceIdMD5:" + str5);
if (isInvalid(str5))
return str5;
}
if (wifiMgr != null) {
WifiInfo localWifiInfo = wifiMgr.getConnectionInfo();
if (localWifiInfo != null) {
String str4 = localWifiInfo.getMacAddress();
LogcatUtils.i("INFO1", "str4:" + str4);
if (isInvalid(str4))
return "MAC:" + str4;
}
}
String str2 = telMgr.getSimSerialNumber();
if (isInvalid(str2)) {
String str3 = "SIMSN:" + str2;
LogcatUtils.i("INFO1", "SIMSN:" + str3);
return str3;
}
return null;
}
private static void initManager(Context paramContext) {
if (wifiMgr == null) {
Object localObject2 = paramContext.getSystemService(Context.WIFI_SERVICE);
if (localObject2 != null)
wifiMgr = (WifiManager) localObject2;
}
if (telMgr == null) {
Object localObject1 = paramContext.getSystemService(Context.TELEPHONY_SERVICE);
if (localObject1 != null)
telMgr = (TelephonyManager) localObject1;
}
}
private static boolean isInvalid(String paramString) {
boolean isInvalid = false;
if ((paramString != null) && !(paramString.trim().equals(""))) {
isInvalid = true;
}
return isInvalid;
}
}
獲取手機設備id
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.