| | |
| | | return info.totalMem; |
| | | } |
| | | |
| | | public static String getAndroidId() { |
| | | String ANDROID_ID = Settings.System.getString(GameAppProxy.app.getContentResolver(), Settings.System.ANDROID_ID); |
| | | if (ANDROID_ID == null || ANDROID_ID.equals("9774d56d682e549c")) |
| | | return ""; |
| | | return ANDROID_ID; |
| | | } |
| | | |
| | | /** |
| | | * 唯一标识 |
| | |
| | | String uniqueID = SPUtils.get().getString(SPUtils.UNIQUE_ID, ""); |
| | | if (!uniqueID.trim().isEmpty()) |
| | | return uniqueID; |
| | | uniqueID = getAndroidId() + getLocalMac(); |
| | | //自己生成的uid |
| | | if (uniqueID.trim().isEmpty()) |
| | | uniqueID = UUID.randomUUID().toString(); |
| | |
| | | |
| | | return uniqueID; |
| | | } |
| | | |
| | | /** |
| | | * mac 地址 |
| | | * |
| | | * @return |
| | | */ |
| | | public static String getLocalMac() { |
| | | String mac = SPUtils.get().getString(SPUtils.MAC, ""); |
| | | if (!mac.trim().isEmpty()) |
| | | return mac; |
| | | try { |
| | | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { |
| | | String interfaceName = "wlan0"; |
| | | Enumeration<NetworkInterface> interfaces = NetworkInterface.getNetworkInterfaces(); |
| | | NetworkInterface intf = null; |
| | | while (interfaces.hasMoreElements()) { |
| | | intf = interfaces.nextElement(); |
| | | if (!intf.getName().equalsIgnoreCase(interfaceName)) |
| | | continue; |
| | | byte[] addresses = intf.getHardwareAddress(); |
| | | if (mac != null) { |
| | | StringBuilder buf = new StringBuilder(); |
| | | for (byte aMac : addresses) { |
| | | buf.append(String.format("%02X:", aMac)); |
| | | } |
| | | if (buf.length() > 0) { |
| | | buf.deleteCharAt(buf.length() - 1); |
| | | } |
| | | mac = buf.toString(); |
| | | } |
| | | break; |
| | | } |
| | | } else { |
| | | WifiManager wifi = (WifiManager) GameAppProxy.app.getSystemService(Context.WIFI_SERVICE); |
| | | if (wifi != null) { |
| | | WifiInfo wifiInfo = wifi.getConnectionInfo(); |
| | | if (wifiInfo != null) { |
| | | mac = wifiInfo.getMacAddress(); |
| | | } |
| | | } |
| | | } |
| | | } catch (Throwable e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | mac = mac.toUpperCase(Locale.ENGLISH); |
| | | |
| | | if (mac.equals(FAKE_MAC)) |
| | | mac = ""; |
| | | |
| | | SPUtils.get() |
| | | .edit() |
| | | .putString(SPUtils.MAC, mac.trim()) |
| | | .apply(); |
| | | |
| | | return mac; |
| | | } |
| | | |
| | | |
| | | } |