4399游戏盒 v7.2.1.31版本的 MD5 值为:951717f45e3fda95c8a358caf4ca93e1
以下内容为反编译后的 f.java 源代码,内容仅作参考
package com.m4399.stat.a;
import android.content.Context;
import android.os.Build;
import android.text.TextUtils;
import com.framework.net.HttpHeaderKey;
import com.loopj.android.http.AsyncHttpClient;
import com.m4399.stat.StatisticsConfig;
import com.m4399.stat.usecase.DeviceConfig;
import com.tencent.bugly.Bugly;
import java.io.ByteArrayOutputStream;
import java.io.EOFException;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.InetSocketAddress;
import java.net.Proxy;
import java.net.URL;
import java.net.URLEncoder;
import java.util.zip.GZIPOutputStream;
public class f {
private String b = "10.0.0.172";
private int c = 80;
private com.m4399.stat.model.c fYM;
private a fYN;
private Context mContext;
public interface a {
void handleRefresh();
}
public f(Context context) {
this.mContext = context;
}
public void setIRequestStat(com.m4399.stat.model.c cVar) {
this.fYM = cVar;
}
private byte[] c(byte[] bArr, boolean z) {
byte[] bArr2;
int i = 0;
while (true) {
bArr2 = null;
if (i >= 3) {
break;
}
try {
String eL = eL(z);
if (!StatisticsConfig.isOpenHttps()) {
eL = eL.replace("https://", com.m4399.gamecenter.plugin.main.manager.i.d.MIME_TYPE_HTTP);
}
bArr2 = request(bArr, eL);
break;
} catch (IOException e) {
e.printStackTrace();
if (i == 2) {
if (z) {
return null;
}
return c(bArr, true);
}
e.e("retry to send data");
i++;
}
}
return bArr2;
}
public byte[] request(byte[] bArr) {
com.m4399.stat.model.c cVar;
byte[] c = c(bArr, false);
if (c != null && (cVar = this.fYM) != null) {
cVar.onRequestSuccess();
}
com.m4399.stat.model.c cVar2 = this.fYM;
if (cVar2 != null) {
cVar2.onRequestFailed();
}
return c;
}
private byte[] eK(boolean z) {
byte[] bArr;
String[] eM = eM(z);
int i = 0;
while (true) {
bArr = null;
if (i >= 3) {
break;
}
try {
String str = eM[0];
if (!StatisticsConfig.isOpenHttps()) {
str = str.replace("https://", com.m4399.gamecenter.plugin.main.manager.i.d.MIME_TYPE_HTTP);
}
bArr = request(new byte[]{0}, str);
break;
} catch (IOException e) {
e.printStackTrace();
if (i == 2) {
if (z) {
return null;
}
return eK(true);
}
e.e("retry to send data");
i++;
}
}
if (bArr != null) {
g.getSendConfigSharedPreferences(this.mContext).edit().putString("online_config_url", eM[1]).apply();
}
return bArr;
}
public byte[] requestOnlineConfig() {
byte[] eK = eK(false);
if (eK != null) {
com.m4399.stat.model.c cVar = this.fYM;
if (cVar != null) {
cVar.onRequestSuccess();
}
} else {
com.m4399.stat.model.c cVar2 = this.fYM;
if (cVar2 != null) {
cVar2.onRequestFailed();
}
}
return eK;
}
public byte[] request(byte[] bArr, String str) throws IOException {
HttpURLConnection httpURLConnection;
String safeGetNetAPNType;
String str2;
int responseCode;
byte[] readInputStream;
try {
try {
if (this.fYM != null) {
this.fYM.setTs();
}
safeGetNetAPNType = DeviceConfig.safeGetNetAPNType(this.mContext);
} catch (Throwable th) {
th = th;
httpURLConnection = null;
}
} catch (EOFException e) {
e = e;
} catch (Exception e2) {
e = e2;
}
try {
if (!safeGetNetAPNType.equals("cmwap") && !safeGetNetAPNType.equals("3gwap") && !safeGetNetAPNType.equals("uniwap")) {
httpURLConnection = (HttpURLConnection) new URL(str).openConnection();
long currentTimeMillis = System.currentTimeMillis();
httpURLConnection.setRequestProperty("User-Agent", aju());
httpURLConnection.setRequestProperty("msign", f(new String(bArr), currentTimeMillis));
httpURLConnection.setRequestProperty("mts", "" + currentTimeMillis);
httpURLConnection.setRequestProperty(AsyncHttpClient.HEADER_CONTENT_TYPE, "application/json;charset=UTF-8");
str2 = StatisticsConfig.DEVICEID;
if (TextUtils.isEmpty(str2)) {
str2 = DeviceConfig.getDeviceId(this.mContext);
}
httpURLConnection.setRequestProperty(HttpHeaderKey.DEVICEID, str2);
httpURLConnection.setRequestProperty(HttpHeaderKey.ANDROID_ID, URLEncoder.encode(DeviceConfig.getSysId().getAndroid_id(this.mContext), "UTF-8"));
httpURLConnection.setRequestProperty(HttpHeaderKey.IMEI, URLEncoder.encode(DeviceConfig.getSysId().getImei(this.mContext), "UTF-8"));
httpURLConnection.setRequestProperty(HttpHeaderKey.IMSI, URLEncoder.encode(DeviceConfig.getSysId().getImsi(this.mContext), "UTF-8"));
httpURLConnection.setRequestProperty(HttpHeaderKey.MAC_ADDRESS, URLEncoder.encode(DeviceConfig.getSysId().getMac(this.mContext), "UTF-8"));
if (!StatisticsConfig.isOnline()) {
httpURLConnection.setRequestProperty(HttpHeaderKey.HTTPS_ENV, "trace/offline");
}
if (StatisticsConfig.pauth == null) {
httpURLConnection.setRequestProperty(HttpHeaderKey.PAUTH, StatisticsConfig.pauth);
} else {
httpURLConnection.setRequestProperty(HttpHeaderKey.PAUTH, "");
}
if (StatisticsConfig.mauth == null) {
httpURLConnection.setRequestProperty(HttpHeaderKey.TOKEN, StatisticsConfig.mauth);
} else {
httpURLConnection.setRequestProperty(HttpHeaderKey.TOKEN, "");
}
httpURLConnection.setConnectTimeout(10000);
httpURLConnection.setReadTimeout(20000);
httpURLConnection.setRequestMethod(com.tencent.connect.common.b.HTTP_POST);
httpURLConnection.setDoOutput(true);
httpURLConnection.setDoInput(true);
httpURLConnection.setUseCaches(false);
httpURLConnection.setChunkedStreamingMode(0);
if (Build.VERSION.SDK_INT < 8) {
System.setProperty("http.keepAlive", Bugly.SDK_IS_DEV);
}
OutputStream outputStream = httpURLConnection.getOutputStream();
if (g.getSharedPreferences(this.mContext).getInt("gzip", 0) != 1) {
httpURLConnection.setRequestProperty(AsyncHttpClient.HEADER_CONTENT_ENCODING, "gzip");
outputStream.write(m(bArr));
} else {
outputStream.write(bArr);
}
outputStream.flush();
outputStream.close();
if (this.fYM != null) {
this.fYM.setLastRequestSpentMillis();
}
responseCode = httpURLConnection.getResponseCode();
if (!TextUtils.isEmpty(httpURLConnection.getHeaderField("x-action")) && this.fYN != null) {
this.fYN.handleRefresh();
}
if (responseCode == 200) {
e.e("response code: " + responseCode);
if (httpURLConnection != null) {
httpURLConnection.disconnect();
}
return null;
}
e.b("response code: " + responseCode);
e.c("request to " + str);
InputStream inputStream = httpURLConnection.getInputStream();
try {
if (!TextUtils.isEmpty(httpURLConnection.getContentEncoding()) && httpURLConnection.getContentEncoding().equalsIgnoreCase("gzip")) {
readInputStream = c.readGZIPInputStream(inputStream);
} else {
readInputStream = c.readInputStream(inputStream);
}
if (httpURLConnection != null) {
httpURLConnection.disconnect();
}
return readInputStream;
} finally {
c.closeInputStream(inputStream);
}
}
long currentTimeMillis2 = System.currentTimeMillis();
httpURLConnection.setRequestProperty("User-Agent", aju());
httpURLConnection.setRequestProperty("msign", f(new String(bArr), currentTimeMillis2));
httpURLConnection.setRequestProperty("mts", "" + currentTimeMillis2);
httpURLConnection.setRequestProperty(AsyncHttpClient.HEADER_CONTENT_TYPE, "application/json;charset=UTF-8");
str2 = StatisticsConfig.DEVICEID;
if (TextUtils.isEmpty(str2)) {
}
httpURLConnection.setRequestProperty(HttpHeaderKey.DEVICEID, str2);
httpURLConnection.setRequestProperty(HttpHeaderKey.ANDROID_ID, URLEncoder.encode(DeviceConfig.getSysId().getAndroid_id(this.mContext), "UTF-8"));
httpURLConnection.setRequestProperty(HttpHeaderKey.IMEI, URLEncoder.encode(DeviceConfig.getSysId().getImei(this.mContext), "UTF-8"));
httpURLConnection.setRequestProperty(HttpHeaderKey.IMSI, URLEncoder.encode(DeviceConfig.getSysId().getImsi(this.mContext), "UTF-8"));
httpURLConnection.setRequestProperty(HttpHeaderKey.MAC_ADDRESS, URLEncoder.encode(DeviceConfig.getSysId().getMac(this.mContext), "UTF-8"));
if (!StatisticsConfig.isOnline()) {
}
if (StatisticsConfig.pauth == null) {
}
if (StatisticsConfig.mauth == null) {
}
httpURLConnection.setConnectTimeout(10000);
httpURLConnection.setReadTimeout(20000);
httpURLConnection.setRequestMethod(com.tencent.connect.common.b.HTTP_POST);
httpURLConnection.setDoOutput(true);
httpURLConnection.setDoInput(true);
httpURLConnection.setUseCaches(false);
httpURLConnection.setChunkedStreamingMode(0);
if (Build.VERSION.SDK_INT < 8) {
}
OutputStream outputStream2 = httpURLConnection.getOutputStream();
if (g.getSharedPreferences(this.mContext).getInt("gzip", 0) != 1) {
}
outputStream2.flush();
outputStream2.close();
if (this.fYM != null) {
}
responseCode = httpURLConnection.getResponseCode();
if (!TextUtils.isEmpty(httpURLConnection.getHeaderField("x-action"))) {
this.fYN.handleRefresh();
}
if (responseCode == 200) {
}
} catch (EOFException e3) {
e = e3;
e.e("Failed to send data.", e);
throw e;
} catch (Exception e4) {
e = e4;
e.e("Failed to send data.", e);
throw e;
} catch (Throwable th2) {
th = th2;
if (httpURLConnection != null) {
httpURLConnection.disconnect();
}
throw th;
}
httpURLConnection = (HttpURLConnection) new URL(str).openConnection(new Proxy(Proxy.Type.HTTP, new InetSocketAddress(this.b, this.c)));
}
private byte[] m(byte[] bArr) {
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(bArr.length);
try {
GZIPOutputStream gZIPOutputStream = new GZIPOutputStream(byteArrayOutputStream);
gZIPOutputStream.write(bArr);
gZIPOutputStream.close();
byteArrayOutputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
return byteArrayOutputStream.toByteArray();
}
private String aju() {
if (StatisticsConfig.UA != null) {
return StatisticsConfig.UA;
}
StringBuilder sb = new StringBuilder();
sb.append(getAppName());
sb.append("/");
sb.append(DeviceConfig.getVersionName(this.mContext));
sb.append("(android;");
sb.append(DeviceConfig.getDeviceModel() + ";");
sb.append(Build.VERSION.RELEASE + ";");
sb.append(DeviceConfig.getSimpleResolution(this.mContext) + ";");
sb.append(DeviceConfig.getNetworkType(this.mContext) + ";");
sb.append(DeviceConfig.getVersionCode(this.mContext));
sb.append(")");
e.e(getAppName());
return sb.toString();
}
private String getAppName() {
return StatisticsConfig.APP_NAME == null ? DeviceConfig.getApplicationPackageName(this.mContext) : StatisticsConfig.APP_NAME;
}
private String eL(boolean z) {
StringBuilder sb = new StringBuilder();
if (StatisticsConfig.isOnline()) {
sb.append(com.m4399.stat.e.servers[z ? (char) 2 : (char) 0]);
} else {
sb.append(com.m4399.stat.e.servers[1]);
}
sb.append(StatisticsConfig.getAppKey(this.mContext));
sb.append("/");
sb.append("1.0");
sb.append("/");
sb.append(StatisticsConfig.getChannel(this.mContext));
sb.append("/");
sb.append(StatisticsConfig.getUDID(this.mContext));
return sb.toString();
}
private String[] eM(boolean z) {
StringBuilder sb = new StringBuilder();
if (StatisticsConfig.isOnline()) {
sb.append(com.m4399.stat.e.servers[z ? (char) 2 : (char) 0]);
} else {
sb.append(com.m4399.stat.e.servers[1]);
}
sb.append(StatisticsConfig.getAppKey(this.mContext));
sb.append("/");
sb.append("1.0");
sb.append("/");
sb.append(StatisticsConfig.getChannel(this.mContext));
sb.append("/");
sb.append(StatisticsConfig.getUDID(this.mContext));
sb.append(".config");
sb.append("?version=");
String sb2 = sb.toString();
if (sb2.equalsIgnoreCase(g.getSendConfigSharedPreferences(this.mContext).getString("online_config_url", ""))) {
sb.append(com.m4399.stat.usecase.j.getPolicyHandler(this.mContext).getEventPolicy().mVersion);
} else {
sb.append("0");
}
return new String[]{sb.toString(), sb2};
}
private String f(String str, long j) {
return c.getMD5(str + DeviceConfig.get_app_signature(this.mContext) + j);
}
public void setConfigRefreshListener(a aVar) {
this.fYN = aVar;
}
}