mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
bug 768957 - Make SUTAgent able to get MAC address from ethernet connection. r=ctalbert
This commit is contained in:
parent
5901f88712
commit
21550e8d33
@ -10,7 +10,9 @@ import java.net.InetAddress;
|
||||
import org.apache.http.conn.util.InetAddressUtils;
|
||||
import java.net.NetworkInterface;
|
||||
import java.net.SocketException;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.Enumeration;
|
||||
import java.util.Formatter;
|
||||
import java.util.List;
|
||||
import java.util.Timer;
|
||||
|
||||
@ -122,19 +124,26 @@ public class SUTAgentAndroid extends Activity
|
||||
if (getLocalIpAddress() == null)
|
||||
setUpNetwork(sIniFile);
|
||||
|
||||
WifiInfo wifi;
|
||||
WifiManager wifiMan = (WifiManager)getSystemService(Context.WIFI_SERVICE);
|
||||
String macAddress = "Unknown";
|
||||
if (wifiMan != null)
|
||||
{
|
||||
wifi = wifiMan.getConnectionInfo();
|
||||
if (wifi != null)
|
||||
try {
|
||||
NetworkInterface iface = NetworkInterface.getByInetAddress(InetAddress.getAllByName(getLocalIpAddress())[0]);
|
||||
if (iface != null)
|
||||
{
|
||||
macAddress = wifi.getMacAddress();
|
||||
if (macAddress != null)
|
||||
sUniqueID = macAddress;
|
||||
byte[] mac = iface.getHardwareAddress();
|
||||
if (mac != null)
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
Formatter f = new Formatter(sb);
|
||||
for (int i = 0; i < mac.length; i++)
|
||||
{
|
||||
f.format("%02x%s", mac[i], (i < mac.length - 1) ? ":" : "");
|
||||
}
|
||||
macAddress = sUniqueID = sb.toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (UnknownHostException ex) {}
|
||||
catch (SocketException ex) {}
|
||||
|
||||
if (sUniqueID == null)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user