安全中心 v4.9.2版本的 MD5 值为:d64c0ec7920c532fa6e6d9bb001cf9bf
以下内容为反编译后的 ajt.java 源代码,内容仅作参考
package tcs;
import android.content.Context;
import android.graphics.Bitmap;
import android.net.NetworkInfo;
import com.tencent.kingkong.database.SQLiteDatabase;
import java.io.ByteArrayOutputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.InetSocketAddress;
import java.net.MalformedURLException;
import java.net.ProtocolException;
import java.net.Proxy;
import java.net.URL;
import java.util.concurrent.atomic.AtomicReference;
import java.util.zip.InflaterInputStream;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.protocol.HTTP;
public class ajt {
public static final String TAG = "HttpUtil";
protected static final int aOh = 15000;
protected static final int aOi = 15000;
protected static final int aOj = 15000;
protected static final String aOv = "*/*";
protected static final String aOw = "application/octet-stream";
static String cJb = "10.0.0.172";
a cJa;
protected HttpURLConnection cIZ = null;
protected boolean aOu = false;
int responseCode = -1;
public enum a {
CONN_WIFI,
CONN_CMWAP,
CONN_CMNET,
CONN_NONE
}
public interface b {
void ik(String str);
void onSuccess();
}
public ajt(Context context) {
this.cJa = a.CONN_NONE;
this.cJa = aL(context);
}
int et(String str) {
if (this.cJa == a.CONN_NONE) {
return -1052;
}
try {
URL url = new URL(str);
if (this.cJa == a.CONN_CMWAP) {
this.cIZ = (HttpURLConnection) url.openConnection(new Proxy(Proxy.Type.HTTP, new InetSocketAddress(cJb, 80)));
} else {
this.cIZ = (HttpURLConnection) url.openConnection();
}
this.cIZ.setReadTimeout(15000);
this.cIZ.setConnectTimeout(15000);
return 0;
} catch (IOException e) {
e.printStackTrace();
return -1056;
} catch (IllegalArgumentException e2) {
e2.printStackTrace();
return -1057;
} catch (SecurityException e3) {
e3.printStackTrace();
return -1058;
} catch (UnsupportedOperationException e4) {
e4.printStackTrace();
return -1059;
} catch (MalformedURLException e5) {
e5.printStackTrace();
return -1053;
} catch (Exception e6) {
e6.printStackTrace();
return -1000;
}
}
public int a(boolean z, AtomicReference<byte[]> atomicReference) {
int i;
byte[] bArr;
if (this.cIZ == null || !this.aOu) {
return -4000;
}
try {
bArr = g(z ? new InflaterInputStream(this.cIZ.getInputStream()) : this.cIZ.getInputStream());
i = 0;
} catch (IOException e) {
e.printStackTrace();
i = -4056;
bArr = null;
} catch (Exception e2) {
e2.printStackTrace();
i = -4000;
bArr = null;
}
atomicReference.set(bArr);
if (this.cIZ != null) {
this.cIZ.disconnect();
this.cIZ = null;
return i;
}
return i;
}
static byte[] g(InputStream inputStream) throws IOException {
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
while (true) {
int read = inputStream.read();
if (read != -1) {
byteArrayOutputStream.write(read);
} else {
return byteArrayOutputStream.toByteArray();
}
}
}
public int b(String str, byte[] bArr) {
int et = et(str);
if (et != 0) {
return et;
}
this.aOu = false;
try {
int length = bArr.length;
this.cIZ.setDoOutput(true);
this.cIZ.setDoInput(true);
this.cIZ.setUseCaches(false);
this.cIZ.setRequestMethod("POST");
this.cIZ.setRequestProperty(HTTP.USER_AGENT, tw.TAG);
this.cIZ.setRequestProperty("Accept", aOv);
this.cIZ.setRequestProperty("Accept-Charset", "utf-8");
this.cIZ.setRequestProperty(HTTP.CONTENT_TYPE, "application/octet-stream");
this.cIZ.setRequestProperty("Content-length", SQLiteDatabase.KeyEmpty + length);
OutputStream outputStream = this.cIZ.getOutputStream();
outputStream.write(bArr);
outputStream.close();
int responseCode = this.cIZ.getResponseCode();
if (responseCode == 200) {
this.aOu = true;
return 0;
}
if (responseCode == -1) {
return -2000;
}
return (-2000) - responseCode;
} catch (IllegalAccessError e) {
e.printStackTrace();
return -2060;
} catch (IllegalStateException e2) {
e2.printStackTrace();
return -2061;
} catch (ProtocolException e3) {
e3.printStackTrace();
return -2051;
} catch (IOException e4) {
e4.printStackTrace();
return -2056;
} catch (Exception e5) {
e5.printStackTrace();
return -2000;
}
}
public int ew(String str) {
int et = et(str);
if (et != 0) {
return et;
}
try {
this.cIZ.setRequestMethod("GET");
this.cIZ.setRequestProperty(HTTP.USER_AGENT, tw.TAG);
this.cIZ.setRequestProperty("Accept", aOv);
this.cIZ.setRequestProperty("Accept-Charset", "utf-8");
this.cIZ.setRequestProperty(HTTP.CONTENT_TYPE, "application/octet-stream");
int responseCode = this.cIZ.getResponseCode();
if (responseCode == 200) {
this.aOu = true;
return 0;
}
if (responseCode != -1) {
return (-3000) - responseCode;
}
return -3000;
} catch (IOException e) {
e.printStackTrace();
return -3056;
} catch (IllegalStateException e2) {
e2.printStackTrace();
return -3061;
} catch (ProtocolException e3) {
e3.printStackTrace();
return -3051;
} catch (Exception e4) {
e4.printStackTrace();
return -3000;
}
}
public static a aL(Context context) {
NetworkInfo activeNetworkInfo = ((qz) bgm.nL(12)).getActiveNetworkInfo();
if (activeNetworkInfo == null || (activeNetworkInfo.getState() != NetworkInfo.State.CONNECTING && activeNetworkInfo.getState() != NetworkInfo.State.CONNECTED)) {
return a.CONN_NONE;
}
if (activeNetworkInfo.getType() == 1) {
return a.CONN_WIFI;
}
if (activeNetworkInfo.getType() == 0) {
if (android.net.Proxy.getDefaultHost() != null || android.net.Proxy.getHost(context) != null) {
cJb = android.net.Proxy.getDefaultHost();
return a.CONN_CMWAP;
}
return a.CONN_CMNET;
}
return a.CONN_NONE;
}
public int getResponseCode() {
return this.responseCode;
}
public static Bitmap ex(String str) throws qh {
DefaultHttpClient defaultHttpClient = new DefaultHttpClient();
try {
try {
HttpResponse execute = defaultHttpClient.execute(new HttpGet(str));
int statusCode = execute.getStatusLine().getStatusCode();
if (statusCode != 200) {
throw new qh(statusCode, "Network failed");
}
HttpEntity entity = execute.getEntity();
if (entity != null) {
try {
Bitmap a2 = ajg.a(entity.getContent());
} finally {
entity.consumeContent();
}
}
if (defaultHttpClient != null) {
defaultHttpClient.getConnectionManager().shutdown();
}
return null;
} catch (ClientProtocolException e) {
e.printStackTrace();
throw new qh(-1, "Network failed");
} catch (IOException e2) {
e2.printStackTrace();
throw new qh(-2, "Network failed");
}
} finally {
if (defaultHttpClient != null) {
defaultHttpClient.getConnectionManager().shutdown();
}
}
}
public static void R(String str, String str2) throws qh {
a(str, str2, null);
}
public static void a(String str, String str2, b bVar) throws qh {
DefaultHttpClient defaultHttpClient = new DefaultHttpClient();
try {
try {
try {
try {
HttpResponse execute = defaultHttpClient.execute(new HttpGet(str));
int statusCode = execute.getStatusLine().getStatusCode();
if (statusCode != 200) {
throw new qh(statusCode, "Network failed");
}
HttpEntity entity = execute.getEntity();
if (entity != null) {
InputStream content = entity.getContent();
FileOutputStream fileOutputStream = new FileOutputStream(str2, true);
try {
byte[] bArr = new byte[1024];
while (true) {
int read = content.read(bArr);
if (read == -1) {
break;
} else {
fileOutputStream.write(bArr, 0, read);
}
}
if (bVar != null) {
bVar.onSuccess();
}
} finally {
entity.consumeContent();
if (content != null) {
content.close();
}
if (fileOutputStream != null) {
fileOutputStream.close();
}
}
}
if (defaultHttpClient != null) {
defaultHttpClient.getConnectionManager().shutdown();
}
} catch (IOException e) {
e.printStackTrace();
throw new qh(-2, "Network failed");
}
} catch (ClientProtocolException e2) {
e2.printStackTrace();
throw new qh(-1, "Network failed");
}
} catch (Throwable th) {
if (bVar != null) {
bVar.ik(th.getMessage());
}
if (defaultHttpClient != null) {
defaultHttpClient.getConnectionManager().shutdown();
}
}
} catch (Throwable th2) {
if (defaultHttpClient != null) {
defaultHttpClient.getConnectionManager().shutdown();
}
throw th2;
}
}
public static boolean aM(Context context) {
NetworkInfo activeNetworkInfo = ((qz) bgm.nL(12)).getActiveNetworkInfo();
return activeNetworkInfo != null && activeNetworkInfo.getState() == NetworkInfo.State.CONNECTED;
}
public static boolean ai(String str, String str2) {
InputStream inputStream;
FileOutputStream fileOutputStream = null;
boolean z = false;
try {
inputStream = new URL(str).openConnection().getInputStream();
try {
byte[] bArr = new byte[1024];
FileOutputStream fileOutputStream2 = new FileOutputStream(str2);
while (true) {
try {
int read = inputStream.read(bArr);
if (read == -1) {
break;
}
fileOutputStream2.write(bArr, 0, read);
} catch (Throwable th) {
fileOutputStream = fileOutputStream2;
if (fileOutputStream != null) {
try {
fileOutputStream.close();
} catch (IOException e) {
}
}
if (inputStream != null) {
try {
inputStream.close();
} catch (IOException e2) {
}
}
return z;
}
}
z = true;
if (fileOutputStream2 != null) {
try {
fileOutputStream2.close();
} catch (IOException e3) {
}
}
if (inputStream != null) {
try {
inputStream.close();
} catch (IOException e4) {
}
}
} catch (Throwable th2) {
th = th2;
}
} catch (Throwable th3) {
th = th3;
inputStream = null;
}
return z;
}
}