手机管家 v6.0.0版本的 MD5 值为:bf0bca2cb03f766137fe9ecf7383a634
以下内容为反编译后的 ajt.java 源代码,内容仅作参考
package tcs;
import android.content.Context;
import android.graphics.Bitmap;
import android.net.NetworkInfo;
import com.tencent.kingkong.database.SQLiteDatabase;
import com.tencent.mm.dbsupport.newcursor.CursorDataWindow;
import java.io.ByteArrayOutputStream;
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;
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 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(CursorDataWindow.PAGE_SIZE_MAX);
this.cIZ.setConnectTimeout(CursorDataWindow.PAGE_SIZE_MAX);
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("User-Agent", tw.TAG);
this.cIZ.setRequestProperty("Accept", aOv);
this.cIZ.setRequestProperty("Accept-Charset", "utf-8");
this.cIZ.setRequestProperty("Content-Type", aOw);
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("User-Agent", tw.TAG);
this.cIZ.setRequestProperty("Accept", aOv);
this.cIZ.setRequestProperty("Accept-Charset", "utf-8");
this.cIZ.setRequestProperty("Content-Type", aOw);
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 = ((aif) com.meri.service.s.kD(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 boolean aM(Context context) {
NetworkInfo activeNetworkInfo = ((aif) com.meri.service.s.kD(12)).getActiveNetworkInfo();
return activeNetworkInfo != null && activeNetworkInfo.getState() == NetworkInfo.State.CONNECTED;
}
}