|
|
@@ -6,9 +6,12 @@ import java.io.IOException;
|
|
|
import java.io.InputStream;
|
|
|
import java.io.OutputStream;
|
|
|
import java.net.HttpURLConnection;
|
|
|
+import java.net.NetworkInterface;
|
|
|
+import java.net.SocketException;
|
|
|
import java.net.URL;
|
|
|
import java.security.PrivateKey;
|
|
|
import java.security.PublicKey;
|
|
|
+import java.util.Enumeration;
|
|
|
import java.util.regex.Matcher;
|
|
|
import java.util.regex.Pattern;
|
|
|
import org.json.JSONObject;
|
|
|
@@ -813,17 +816,29 @@ public class LoginActivity extends Activity implements OnClickListener {
|
|
|
params.put("userPassword",
|
|
|
Md5Utils.encode(login_mima.getText().toString().trim()));
|
|
|
}
|
|
|
- String phoneCode="";
|
|
|
- String IMEI="";
|
|
|
- try{
|
|
|
- phoneCode=Installation.id(LoginActivity.this);
|
|
|
- TelephonyManager telephonyManager = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
|
|
|
- IMEI=telephonyManager.getDeviceId();
|
|
|
- Ip = CommonUtil.getIpAddress(LoginActivity.this);
|
|
|
- Mac = CommonUtil.getMacFromWifi(LoginActivity.this);
|
|
|
- }catch(Exception ex) {
|
|
|
-
|
|
|
- }
|
|
|
+ String phoneCode = "";
|
|
|
+ String IMEI = "";
|
|
|
+ try {
|
|
|
+ phoneCode = Installation.id(LoginActivity.this);
|
|
|
+ } catch (Exception ex) {
|
|
|
+
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ TelephonyManager telephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
|
|
|
+ IMEI = telephonyManager.getDeviceId();
|
|
|
+ } catch (Exception ex) {
|
|
|
+
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ Ip = CommonUtil.getIpAddress(LoginActivity.this);
|
|
|
+ } catch (Exception ex) {
|
|
|
+
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ Mac = macAddress();
|
|
|
+ } catch (Exception ex) {
|
|
|
+
|
|
|
+ }
|
|
|
params.put("macAddress", Mac);
|
|
|
params.put("ipAddress", Ip);
|
|
|
params.put("phoneCode", phoneCode);
|
|
|
@@ -844,7 +859,35 @@ public class LoginActivity extends Activity implements OnClickListener {
|
|
|
}
|
|
|
|
|
|
}
|
|
|
-
|
|
|
+ public static String macAddress() throws SocketException {
|
|
|
+ String address = null;
|
|
|
+ // 把当前机器上的访问网络接口的存入 Enumeration集合中
|
|
|
+ Enumeration<NetworkInterface> interfaces = NetworkInterface.getNetworkInterfaces();
|
|
|
+ //Log.d("TEST_BUG", " interfaceName = " + interfaces );
|
|
|
+ while (interfaces.hasMoreElements()) {
|
|
|
+ NetworkInterface netWork = interfaces.nextElement();
|
|
|
+ // 如果存在硬件地址并可以使用给定的当前权限访问,则返回该硬件地址(通常是 MAC)。
|
|
|
+ byte[] by = netWork.getHardwareAddress();
|
|
|
+ if (by == null || by.length == 0) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ StringBuilder builder = new StringBuilder();
|
|
|
+ for (byte b : by) {
|
|
|
+ builder.append(String.format("%02X:", b));
|
|
|
+ }
|
|
|
+ if (builder.length() > 0) {
|
|
|
+ builder.deleteCharAt(builder.length() - 1);
|
|
|
+ }
|
|
|
+ String mac = builder.toString();
|
|
|
+ //Log.d("TEST_BUG", "interfaceName="+netWork.getName()+", mac="+mac);
|
|
|
+ // 从路由器上在线设备的MAC地址列表,可以印证设备Wifi的 name 是 wlan0
|
|
|
+ if (netWork.getName().equals("wlan0")) {
|
|
|
+ //Log.d("TEST_BUG", " interfaceName ="+netWork.getName()+", mac="+mac);
|
|
|
+ address = mac;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return address;
|
|
|
+ }
|
|
|
public class LoginRunnable implements Runnable {
|
|
|
private JSONObject param;
|
|
|
private boolean autologinflag;
|