正在查看: 95爱播免登录版 v3.1.9 应用的 LDNetDiagnoService.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: 95爱播免登录版 v3.1.9 应用的 LDNetDiagnoService.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.netease.LDNetDiagnoService;
import android.content.Context;
import android.os.Build;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import com.netease.LDNetDiagnoService.LDNetPing;
import com.netease.LDNetDiagnoService.LDNetSocket;
import com.netease.LDNetDiagnoService.LDNetTraceRoute;
import com.showself.ui.ShowSelfApp;
import com.showself.utils.j;
import com.showself.utils.p;
import com.tencent.mm.opensdk.constants.ConstantsAPI;
import com.tencent.mm.opensdk.modelmsg.WXMediaMessage;
import com.xiaomi.mipush.sdk.Constants;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.InetAddress;
import java.net.URL;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.TimeZone;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import org.apache.http.entity.mime.MIME;
public class LDNetDiagnoService extends LDNetAsyncTaskEx<String, String, String> implements LDNetPing.LDNetPingListener, LDNetTraceRoute.LDNetTraceRouteListener, LDNetSocket.LDNetSocketListener {
private static final int CORE_POOL_SIZE = 1;
private static final int KEEP_ALIVE = 10;
private static final int MAXIMUM_POOL_SIZE = 1;
private String _ISOCountryCode;
private String _MobileCountryCode;
private String _MobileNetCode;
private String _UID;
private String _appCode;
private String _appName;
private String _appVersion;
private String _carrierName;
private Context _context;
private String _deviceID;
private String _dns1;
private String _dns2;
private String _gateWay;
private boolean _isDomainParseOk;
private boolean _isNetConnected;
private boolean _isRunning;
private boolean _isSocketConnected;
private boolean _isUseJNICConn;
private boolean _isUseJNICTrace;
private String _localIp;
private final StringBuilder _logInfo;
private LDNetDiagnoListener _netDiagnolistener;
private LDNetPing _netPinger;
private LDNetSocket _netSocker;
private String _netType;
private InetAddress[] _remoteInet;
private List<String> _remoteIpList;
private TelephonyManager _telManager;
private LDNetTraceRoute _traceRouter;
private String javaUrl;
private ArrayList<String> urls;
private static final BlockingQueue<Runnable> sWorkQueue = new LinkedBlockingQueue(2);
private static final ThreadFactory sThreadFactory = new ThreadFactory() {
private final AtomicInteger mCount = new AtomicInteger(1);
@Override
public Thread newThread(Runnable runnable) {
Thread thread = new Thread(runnable, "Trace #" + this.mCount.getAndIncrement());
thread.setPriority(1);
return thread;
}
};
private static ThreadPoolExecutor sExecutor = null;
public LDNetDiagnoService() {
this._logInfo = new StringBuilder(256);
this._isUseJNICConn = false;
this._isUseJNICTrace = true;
this._telManager = null;
}
private void downLoadTaskTest(String str) {
StringBuilder sb = new StringBuilder();
sb.append(ShowSelfApp.h().getCacheDir().getAbsolutePath());
String str2 = File.separator;
sb.append(str2);
sb.append("fileTemp");
String sb2 = sb.toString();
File file = new File(sb2);
if (!file.exists()) {
file.mkdirs();
}
try {
HttpURLConnection httpURLConnection = (HttpURLConnection) new URL(str).openConnection();
httpURLConnection.setDoInput(true);
httpURLConnection.setConnectTimeout(5000);
httpURLConnection.setReadTimeout(5000);
httpURLConnection.connect();
saveStreamToFile(httpURLConnection.getInputStream(), new File(sb2 + str2 + "testFile"), httpURLConnection.getContentLength());
} catch (Exception e2) {
recordStepInfo("测速超时");
e2.printStackTrace();
}
}
private void onProgress(int i2) {
if (this._isRunning) {
this._netDiagnolistener.OnNetDialogProgrss(10, i2);
}
}
private boolean parseDomain(String str) {
Map<String, Object> domainIp = LDNetUtil.getDomainIp(str);
String str2 = (String) domainIp.get("useTime");
this._remoteInet = (InetAddress[]) domainIp.get("remoteInet");
String str3 = Integer.parseInt(str2) > 5000 ? " (" + (Integer.parseInt(str2) / 1000) + "s)" : " (" + str2 + "ms)";
InetAddress[] inetAddressArr = this._remoteInet;
String str4 = "";
if (inetAddressArr != null) {
int length = inetAddressArr.length;
for (int i2 = 0; i2 < length; i2++) {
this._remoteIpList.add(this._remoteInet[i2].getHostAddress());
str4 = str4 + this._remoteInet[i2].getHostAddress() + Constants.ACCEPT_TIME_SEPARATOR_SP;
}
recordStepInfo("DNS解析结果:\t" + str4.substring(0, str4.length() - 1) + str3);
} else {
if (Integer.parseInt(str2) <= 10000) {
recordStepInfo("DNS解析结果:\t解析失败" + str3);
return false;
}
Map<String, Object> domainIp2 = LDNetUtil.getDomainIp(str);
String str5 = (String) domainIp2.get("useTime");
this._remoteInet = (InetAddress[]) domainIp2.get("remoteInet");
String str6 = Integer.parseInt(str5) > 5000 ? " (" + (Integer.parseInt(str5) / 1000) + "s)" : " (" + str5 + "ms)";
InetAddress[] inetAddressArr2 = this._remoteInet;
if (inetAddressArr2 == null) {
recordStepInfo("DNS解析结果:\t解析失败" + str6);
return false;
}
int length2 = inetAddressArr2.length;
for (int i3 = 0; i3 < length2; i3++) {
this._remoteIpList.add(this._remoteInet[i3].getHostAddress());
str4 = str4 + this._remoteInet[i3].getHostAddress() + Constants.ACCEPT_TIME_SEPARATOR_SP;
}
recordStepInfo("DNS解析结果:\t" + str4.substring(0, str4.length() - 1) + str6);
}
return true;
}
private void recordCurrentAppVersion() {
recordStepInfo("应用名称:\t" + this._appName);
recordStepInfo("应用版本:\t" + this._appVersion);
Date date = new Date();
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.US);
simpleDateFormat.setTimeZone(TimeZone.getTimeZone("GMT+08:00"));
recordStepInfo("用户id:\t" + simpleDateFormat.format(date) + Constants.ACCEPT_TIME_SEPARATOR_SERVER + this._UID);
recordStepInfo("机器类型:\t" + Build.MANUFACTURER + Constants.COLON_SEPARATOR + Build.BRAND + Constants.COLON_SEPARATOR + Build.MODEL);
StringBuilder sb = new StringBuilder();
sb.append("系统版本:\t");
sb.append(Build.VERSION.RELEASE);
recordStepInfo(sb.toString());
try {
if (this._telManager != null && TextUtils.isEmpty(this._deviceID)) {
this._deviceID = this._telManager.getDeviceId();
}
recordStepInfo("机器ID:\t" + this._deviceID);
} catch (Exception unused) {
}
if (TextUtils.isEmpty(this._carrierName)) {
this._carrierName = LDNetUtil.getMobileOperator(this._context);
}
recordStepInfo("运营商:\t" + this._carrierName);
if (this._telManager != null && TextUtils.isEmpty(this._ISOCountryCode)) {
this._ISOCountryCode = this._telManager.getNetworkCountryIso();
}
recordStepInfo("ISOCountryCode:\t" + this._ISOCountryCode);
if (this._telManager != null && TextUtils.isEmpty(this._MobileCountryCode)) {
String networkOperator = this._telManager.getNetworkOperator();
if (networkOperator.length() >= 3) {
this._MobileCountryCode = networkOperator.substring(0, 3);
}
if (networkOperator.length() >= 5) {
this._MobileNetCode = networkOperator.substring(3, 5);
}
}
recordStepInfo("MobileCountryCode:\t" + this._MobileCountryCode);
recordStepInfo("MobileNetworkCode:\t" + this._MobileNetCode + "\n");
}
private void recordLocalNetEnvironmentInfo() {
recordStepInfo("诊断域名 " + this.javaUrl + "...");
if (LDNetUtil.isNetworkConnected(this._context).booleanValue()) {
this._isNetConnected = true;
recordStepInfo("当前是否联网:\t已联网");
if (j.f().h()) {
recordStepInfo("消息连接状态:\t已连接");
} else {
recordStepInfo("消息连接状态:\t未连接");
}
} else {
this._isNetConnected = false;
recordStepInfo("当前是否联网:\t未联网");
recordStepInfo("消息连接状态:\t未连接");
}
this._netType = LDNetUtil.getNetWorkType(this._context);
recordStepInfo("当前联网类型:\t" + this._netType);
if (this._isNetConnected) {
if (LDNetUtil.NETWORKTYPE_WIFI.equals(this._netType)) {
this._localIp = LDNetUtil.getLocalIpByWifi(this._context);
this._gateWay = LDNetUtil.pingGateWayInWifi(this._context);
} else {
this._localIp = LDNetUtil.getLocalIpBy3G();
}
recordStepInfo("本地IP:\t" + this._localIp);
} else {
recordStepInfo("本地IP:\t127.0.0.1");
}
if (this._gateWay != null) {
recordStepInfo("本地网关:\t" + this._gateWay);
}
if (this._isNetConnected) {
this._dns1 = LDNetUtil.getLocalDns("dns1");
this._dns2 = LDNetUtil.getLocalDns("dns2");
String[] servers = new DnsServersDetector(this._context).getServers();
if (servers != null && servers.length > 0) {
this._dns1 = servers[0];
}
if (!TextUtils.isEmpty(this._dns1)) {
recordStepInfo("本地DNS:\t" + this._dns1);
}
} else {
recordStepInfo("本地DNS:\t0.0.0.0,0.0.0.0");
}
if (this._isNetConnected) {
recordStepInfo("远端域名:\t" + this.javaUrl);
this._isDomainParseOk = parseDomain(this.javaUrl);
}
}
private void recordStepInfo(String str) {
this._logInfo.append(str + "\n");
publishProgress(str + "\n");
}
private java.lang.String requestOperatorInfo() {
throw new UnsupportedOperationException("Method not decompiled: com.netease.LDNetDiagnoService.LDNetDiagnoService.requestOperatorInfo():java.lang.String");
}
private void upLoadTaskTest(String str, String str2, long j2) {
try {
long currentTimeMillis = System.currentTimeMillis();
HttpURLConnection httpURLConnection = (HttpURLConnection) new URL(str).openConnection();
httpURLConnection.setDoInput(true);
httpURLConnection.setDoOutput(true);
httpURLConnection.setUseCaches(false);
httpURLConnection.setRequestMethod(com.tencent.connect.common.Constants.HTTP_POST);
httpURLConnection.setRequestProperty("Connection", "Keep-Alive");
httpURLConnection.setRequestProperty("Charset", "UTF-8");
httpURLConnection.setRequestProperty(MIME.CONTENT_TYPE, "multipart/form-data;boundary=*****");
httpURLConnection.setConnectTimeout(10000);
httpURLConnection.setReadTimeout(10000);
DataOutputStream dataOutputStream = new DataOutputStream(httpURLConnection.getOutputStream());
dataOutputStream.writeBytes("--*****/r/n");
dataOutputStream.writeBytes("Content-Disposition: form-data; name=\"file1\";filename=\"innerFile.zip\"/r/n");
dataOutputStream.writeBytes("/r/n");
FileInputStream fileInputStream = new FileInputStream(str2);
byte[] bArr = new byte[WXMediaMessage.DESCRIPTION_LENGTH_LIMIT];
while (true) {
int read = fileInputStream.read(bArr);
if (read == -1) {
break;
} else {
dataOutputStream.write(bArr, 0, read);
}
}
dataOutputStream.writeBytes("/r/n");
dataOutputStream.writeBytes("--*****--/r/n");
fileInputStream.close();
dataOutputStream.flush();
InputStream inputStream = httpURLConnection.getInputStream();
StringBuffer stringBuffer = new StringBuffer();
while (true) {
int read2 = inputStream.read();
if (read2 == -1) {
long currentTimeMillis2 = System.currentTimeMillis() - currentTimeMillis;
recordStepInfo("result: avg speed " + ((j2 * 1000) / (ConstantsAPI.AppSupportContentFlag.MMAPP_SUPPORT_XLS * currentTimeMillis2)) + "KB/s");
StringBuilder sb = new StringBuilder();
sb.append("上传成功");
sb.append(currentTimeMillis2);
p.a("ssssssssssssss", sb.toString());
dataOutputStream.close();
return;
}
stringBuffer.append((char) read2);
}
} catch (Exception e2) {
recordStepInfo("测速超时");
p.a("ssssssssssssss", "上传失败" + e2.getMessage());
}
}
@Override
public void OnNetPingFinished(String str) {
recordStepInfo(str);
}
@Override
public void OnNetSocketFinished(String str) {
this._logInfo.append(str);
publishProgress(str);
}
@Override
public void OnNetSocketUpdated(String str) {
this._logInfo.append(str);
publishProgress(str);
}
@Override
public void OnNetTraceFinished() {
}
@Override
public void OnNetTraceUpdated(String str) {
if (str == null) {
return;
}
LDNetTraceRoute lDNetTraceRoute = this._traceRouter;
if (lDNetTraceRoute == null || !lDNetTraceRoute.isCTrace) {
recordStepInfo(str);
return;
}
if (str.contains("ms") || str.contains("***")) {
str = str + "\n";
}
this._logInfo.append(str);
publishProgress(str);
}
@Override
protected ThreadPoolExecutor getThreadPoolExecutor() {
return sExecutor;
}
@Override
protected void onCancelled() {
stopNetDialogsis();
}
public void printLogInfo() {
System.out.print(this._logInfo);
}
public void saveStreamToFile(InputStream inputStream, File file, long j2) {
try {
long currentTimeMillis = System.currentTimeMillis();
FileOutputStream fileOutputStream = new FileOutputStream(file);
byte[] bArr = new byte[WXMediaMessage.DESCRIPTION_LENGTH_LIMIT];
while (true) {
int read = inputStream.read(bArr);
if (read == -1) {
long currentTimeMillis2 = System.currentTimeMillis();
fileOutputStream.close();
inputStream.close();
recordStepInfo("result: avg speed " + ((j2 * 1000) / ((currentTimeMillis2 - currentTimeMillis) * ConstantsAPI.AppSupportContentFlag.MMAPP_SUPPORT_XLS)) + "KB/s");
return;
}
fileOutputStream.write(bArr, 0, read);
}
} catch (IOException e2) {
recordStepInfo("测速超时");
e2.printStackTrace();
}
}
public void setIfUseJNICConn(boolean z) {
this._isUseJNICConn = z;
}
public void setIfUseJNICTrace(boolean z) {
this._isUseJNICTrace = z;
}
public String startNetDiagnosis() {
String b = com.showself.net.j.b();
this.javaUrl = b;
String replace = b.replace("https://", "");
this.javaUrl = replace;
String replace2 = replace.replace("http://", "");
this.javaUrl = replace2;
String replace3 = replace2.replace("/v2", "");
this.javaUrl = replace3;
if (TextUtils.isEmpty(replace3)) {
return "";
}
this._isRunning = true;
this._logInfo.setLength(0);
onProgress(1);
recordStepInfo("开始诊断...\n");
recordCurrentAppVersion();
onProgress(2);
recordLocalNetEnvironmentInfo();
if (!this._isNetConnected) {
recordStepInfo("\n\n当前主机未联网,请检查网络!");
return this._logInfo.toString();
}
onProgress(3);
recordStepInfo("\n开始ping...");
this._netPinger = new LDNetPing(this, 4);
if (this.urls != null) {
for (int i2 = 0; i2 < this.urls.size(); i2++) {
recordStepInfo("\nping..." + this.urls.get(i2));
this._netPinger.exec(this.urls.get(i2), false);
if (i2 < 6) {
onProgress(i2 + 4);
}
}
}
if (this._netPinger == null) {
this._netPinger = new LDNetPing(this, 4);
}
return traceRoute();
}
public void stopNetDialogsis() {
if (this._isRunning) {
LDNetSocket lDNetSocket = this._netSocker;
if (lDNetSocket != null) {
lDNetSocket.resetInstance();
this._netSocker = null;
}
if (this._netPinger != null) {
this._netPinger = null;
}
LDNetTraceRoute lDNetTraceRoute = this._traceRouter;
if (lDNetTraceRoute != null) {
lDNetTraceRoute.resetInstance();
this._traceRouter = null;
}
cancel(true);
ThreadPoolExecutor threadPoolExecutor = sExecutor;
if (threadPoolExecutor != null && !threadPoolExecutor.isShutdown()) {
sExecutor.shutdown();
sExecutor = null;
}
this._isRunning = false;
}
}
public String traceRoute() {
String sb;
synchronized (LDNetDiagnoService.class) {
boolean z = this._isRunning;
if (z && z) {
recordStepInfo("\n\n开始下载测速...");
recordStepInfo("Download https://pic.beeshow.tv/test");
downLoadTaskTest("https://pic.beeshow.tv/test");
StringBuilder sb2 = new StringBuilder();
sb2.append(ShowSelfApp.h().getCacheDir().getAbsolutePath());
String str = File.separator;
sb2.append(str);
sb2.append("fileTemp");
sb2.append(str);
sb2.append("testFile");
String sb3 = sb2.toString();
File file = new File(sb3);
if (file.exists() && file.isFile() && file.length() > 0) {
recordStepInfo("\n\n开始上传测速...");
recordStepInfo("UpLoad https://e2.beeshow.tv/error/upload");
upLoadTaskTest("https://e2.beeshow.tv/error/upload", sb3, file.length());
}
onProgress(10);
}
sb = this._logInfo.toString();
}
return sb;
}
@Override
public String doInBackground(String... strArr) {
if (isCancelled()) {
return null;
}
return startNetDiagnosis();
}
@Override
public void onPostExecute(String str) {
if (isCancelled()) {
return;
}
super.onPostExecute((LDNetDiagnoService) str);
recordStepInfo("\n网络诊断结束\n");
stopNetDialogsis();
LDNetDiagnoListener lDNetDiagnoListener = this._netDiagnolistener;
if (lDNetDiagnoListener != null) {
lDNetDiagnoListener.OnNetDiagnoFinished(this._logInfo.toString());
}
}
@Override
public void onProgressUpdate(String... strArr) {
if (isCancelled()) {
return;
}
super.onProgressUpdate((Object[]) strArr);
LDNetDiagnoListener lDNetDiagnoListener = this._netDiagnolistener;
if (lDNetDiagnoListener != null) {
lDNetDiagnoListener.OnNetDiagnoUpdated(strArr[0]);
}
}
public LDNetDiagnoService(Context context, String str, String str2, String str3, String str4, String str5, ArrayList<String> arrayList, String str6, String str7, String str8, String str9, LDNetDiagnoListener lDNetDiagnoListener) {
this._logInfo = new StringBuilder(256);
this._isUseJNICConn = false;
this._isUseJNICTrace = true;
this._telManager = null;
this._context = context;
this._appCode = str;
this._appName = str2;
this._appVersion = str3;
this._UID = str4;
this._deviceID = str5;
this.urls = arrayList;
this._carrierName = str6;
this._ISOCountryCode = str7;
this._MobileCountryCode = str8;
this._MobileNetCode = str9;
this._netDiagnolistener = lDNetDiagnoListener;
this._isRunning = false;
this._remoteIpList = new ArrayList();
this._telManager = (TelephonyManager) context.getSystemService("phone");
sExecutor = new ThreadPoolExecutor(1, 1, 10L, TimeUnit.SECONDS, sWorkQueue, sThreadFactory);
}
}