Commit ec67148a by sikang

add mac header

parent c6ac2f2e
......@@ -20,6 +20,7 @@ import okhttp3.internal.Util;
import tech.starwin.LibConfig;
import tech.starwin.utils.LoginManager;
import tech.starwin.utils.context_utils.AppInfoUtils;
import tech.starwin.utils.context_utils.DeviceUtils;
/**
* Created by XLEO on 2018/1/30.
......@@ -79,6 +80,7 @@ public class DefaultHeaderAddInterceptor implements Interceptor {
.header("X-APP-SOURCE", LibConfig.XH_CHANNEL_NAME == null ? "" : LibConfig.XH_CHANNEL_NAME)
.header("thirdpartyDataFlag", String.valueOf(!TextUtils.isEmpty(LibConfig.TONGDUN_PARENT_KEY)))
// .header("X-APP-SIM-MOBILE", getSimInfo())
.header("X-MAC_ADDRESS", DeviceUtils.getInstance().getMacAddress())
.header("X-AF-ID", LibConfig.APPSFLYER_DEV_KEY == null ? "" : LibConfig.APPSFLYER_DEV_KEY)
.header("X-GA-ID", getGAId())
.header("X-GP-PKG-FLAG", String.valueOf(!LibConfig.IS_COLLECT_MODE))
......
......@@ -489,8 +489,10 @@ public class DeviceUtils {
*
* @return
*/
String MAC = "NULL";
public String getMacAddress() {
String macAddress = null;
if (MAC == "NULL") {
StringBuffer buf = new StringBuffer();
NetworkInterface networkInterface = null;
try {
......@@ -499,7 +501,7 @@ public class DeviceUtils {
networkInterface = NetworkInterface.getByName("wlan0");
}
if (networkInterface == null) {
return "";
MAC = "";
}
byte[] addr = networkInterface.getHardwareAddress();
for (byte b : addr) {
......@@ -508,11 +510,13 @@ public class DeviceUtils {
if (buf.length() > 0) {
buf.deleteCharAt(buf.length() - 1);
}
macAddress = buf.toString();
MAC = buf.toString();
} catch (SocketException e) {
MAC = "";
e.printStackTrace();
}
return macAddress == null ? "" : macAddress;
}
return MAC;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment