360手机助手 v3.3.0版本的 MD5 值为:127c345ad16bbebee6e347381328afd0
以下内容为反编译后的 ax.java 源代码,内容仅作参考
package com.aps;
import android.content.Context;
import android.database.Cursor;
import android.net.NetworkInfo;
import android.net.Proxy;
import android.net.Uri;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import com.qihoo.speedometer.Config;
import com.qihoo.speedometer.measurements.HttpTask;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.SocketException;
import java.net.SocketTimeoutException;
import java.net.UnknownHostException;
import java.util.Locale;
import java.util.zip.GZIPInputStream;
import org.apache.http.Header;
import org.apache.http.HttpHost;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.conn.ConnectTimeoutException;
import org.apache.http.conn.scheme.PlainSocketFactory;
import org.apache.http.conn.scheme.Scheme;
import org.apache.http.conn.scheme.SchemeRegistry;
import org.apache.http.entity.ByteArrayEntity;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager;
import org.apache.http.params.BasicHttpParams;
import org.apache.http.params.HttpProtocolParams;
import org.json.JSONException;
import org.json.JSONObject;
public class ax {
private static ax f383a = null;
private ax() {
}
public static int a(NetworkInfo networkInfo) {
if (networkInfo != null && networkInfo.isAvailable() && networkInfo.isConnected()) {
return networkInfo.getType();
}
return -1;
}
public static ax a() {
if (f383a == null) {
f383a = new ax();
}
return f383a;
}
public static String a(TelephonyManager telephonyManager) {
return (String) an.l.get(telephonyManager != null ? telephonyManager.getNetworkType() : 0, "UNKNOWN");
}
public static HttpClient a(Context context, NetworkInfo networkInfo) {
int i;
String str;
Exception exc;
Cursor cursor;
String str2;
String str3;
boolean z;
boolean z2;
boolean z3;
boolean z4 = true;
Cursor cursor2 = null;
BasicHttpParams basicHttpParams = new BasicHttpParams();
if (networkInfo.getType() == 0) {
Cursor cursor3 = null;
try {
try {
cursor = context.getContentResolver().query(Uri.parse("content://telephony/carriers/preferapn"), null, null, null, null);
if (cursor != null) {
try {
if (cursor.moveToFirst()) {
String string = cursor.getString(cursor.getColumnIndex("apn"));
if (string != null) {
string = string.toLowerCase(Locale.US);
bl.a("nm|found apn:", string);
}
if (string != null && string.contains("ctwap")) {
String b2 = b();
if (TextUtils.isEmpty(b2) || b2.equals("null")) {
z3 = false;
b2 = null;
} else {
z3 = true;
}
if (!z3) {
b2 = "10.0.0.200";
}
str = b2;
i = 80;
} else if (string != null && string.contains("wap")) {
String b3 = b();
if (TextUtils.isEmpty(b3) || b3.equals("null")) {
z2 = false;
b3 = null;
} else {
z2 = true;
}
if (!z2) {
b3 = "10.0.0.172";
}
str = b3;
i = 80;
}
if (cursor != null) {
cursor.close();
}
}
} catch (SecurityException e) {
str3 = null;
cursor2 = cursor;
try {
if (networkInfo.getExtraInfo() != null) {
String lowerCase = networkInfo.getExtraInfo().toLowerCase(Locale.US);
String b4 = b();
if (lowerCase.indexOf("ctwap") != -1) {
if (TextUtils.isEmpty(b4) || b4.equals("null")) {
z4 = false;
} else {
str3 = b4;
}
if (!z4) {
str3 = "10.0.0.200";
}
str = str3;
i = 80;
} else if (lowerCase.indexOf("wap") != -1) {
if (TextUtils.isEmpty(b4) || b4.equals("null")) {
z = false;
} else {
str3 = b4;
z = true;
}
if (!z) {
str3 = "10.0.0.200";
}
str = str3;
i = 80;
}
if (cursor2 != null) {
cursor2.close();
}
if (a(str, i)) {
}
bl.a(basicHttpParams, 30000);
HttpProtocolParams.setUseExpectContinue(basicHttpParams, false);
SchemeRegistry schemeRegistry = new SchemeRegistry();
schemeRegistry.register(new Scheme(HttpTask.TYPE, PlainSocketFactory.getSocketFactory(), 80));
return new DefaultHttpClient(new ThreadSafeClientConnManager(basicHttpParams, schemeRegistry), basicHttpParams);
}
str = str3;
i = -1;
if (cursor2 != null) {
}
if (a(str, i)) {
}
bl.a(basicHttpParams, 30000);
HttpProtocolParams.setUseExpectContinue(basicHttpParams, false);
SchemeRegistry schemeRegistry2 = new SchemeRegistry();
schemeRegistry2.register(new Scheme(HttpTask.TYPE, PlainSocketFactory.getSocketFactory(), 80));
return new DefaultHttpClient(new ThreadSafeClientConnManager(basicHttpParams, schemeRegistry2), basicHttpParams);
} catch (Throwable th) {
th = th;
cursor3 = cursor2;
if (cursor3 != null) {
}
throw th;
}
} catch (Exception e2) {
exc = e2;
str2 = null;
bl.a(exc);
if (cursor != null) {
cursor.close();
}
str = str2;
i = -1;
if (a(str, i)) {
}
bl.a(basicHttpParams, 30000);
HttpProtocolParams.setUseExpectContinue(basicHttpParams, false);
SchemeRegistry schemeRegistry22 = new SchemeRegistry();
schemeRegistry22.register(new Scheme(HttpTask.TYPE, PlainSocketFactory.getSocketFactory(), 80));
return new DefaultHttpClient(new ThreadSafeClientConnManager(basicHttpParams, schemeRegistry22), basicHttpParams);
}
}
i = -1;
str = null;
if (cursor != null) {
}
} catch (Throwable th2) {
th = th2;
if (cursor3 != null) {
cursor3.close();
}
throw th;
}
} catch (SecurityException e3) {
str3 = null;
} catch (Exception e4) {
exc = e4;
cursor = null;
str2 = null;
} catch (Throwable th3) {
th = th3;
cursor3 = null;
if (cursor3 != null) {
}
throw th;
}
} else {
i = -1;
str = null;
}
if (a(str, i)) {
basicHttpParams.setParameter("http.route.default-proxy", new HttpHost(str, i, HttpTask.TYPE));
}
bl.a(basicHttpParams, 30000);
HttpProtocolParams.setUseExpectContinue(basicHttpParams, false);
SchemeRegistry schemeRegistry222 = new SchemeRegistry();
schemeRegistry222.register(new Scheme(HttpTask.TYPE, PlainSocketFactory.getSocketFactory(), 80));
return new DefaultHttpClient(new ThreadSafeClientConnManager(basicHttpParams, schemeRegistry222), basicHttpParams);
}
private static boolean a(String str, int i) {
return (str == null || str.length() <= 0 || i == -1) ? false : true;
}
private static boolean a(HttpResponse httpResponse) {
Header firstHeader = httpResponse.getFirstHeader("Content-Encoding");
return firstHeader != null && firstHeader.getValue().equalsIgnoreCase("gzip");
}
public static String[] a(JSONObject jSONObject) {
String[] strArr = {null, null, null, null, null};
if (jSONObject == null || com.amap.api.location.core.d.j().length() == 0) {
strArr[0] = "false";
} else {
try {
String string = jSONObject.getString("key");
String string2 = jSONObject.getString("X-INFO");
String string3 = jSONObject.getString("X-BIZ");
String string4 = jSONObject.getString("User-Agent");
if (!TextUtils.isEmpty(string) && !TextUtils.isEmpty(string4)) {
strArr[0] = "true";
strArr[1] = string;
strArr[2] = string2;
strArr[3] = string3;
strArr[4] = string4;
}
} catch (JSONException e) {
}
if (strArr[0] == null || !strArr[0].equals("true")) {
strArr[0] = "true";
}
}
return strArr;
}
private static String b() {
String str;
try {
str = Proxy.getDefaultHost();
} catch (Throwable th) {
th.printStackTrace();
str = null;
}
return str == null ? "null" : str;
}
public String a(Context context, String str, byte[] bArr, String str2) {
Throwable th;
Throwable th2;
InputStream inputStream;
InputStreamReader inputStreamReader;
String str3;
if (TextUtils.isEmpty(str) || bArr == null) {
return null;
}
?? b2 = bl.b(context);
if (a((NetworkInfo) b2) == -1) {
return null;
}
HttpPost httpPost = null;
HttpPost httpPost2 = null;
httpPost2 = null;
?? r5 = 0;
GZIPInputStream gZIPInputStream = null;
GZIPInputStream gZIPInputStream2 = null;
gZIPInputStream2 = null;
gZIPInputStream2 = null;
gZIPInputStream2 = null;
?? r3 = 0;
BufferedReader bufferedReader = null;
BufferedReader bufferedReader2 = null;
StringBuffer stringBuffer = new StringBuffer();
try {
try {
try {
b2 = a(context, (NetworkInfo) b2);
try {
httpPost = new HttpPost(str);
try {
ByteArrayEntity byteArrayEntity = new ByteArrayEntity(bArr);
httpPost.addHeader("Content-Type", "application/x-www-form-urlencoded");
httpPost.addHeader("User-Agent", "AMAP Location SDK Android 1.3.0");
httpPost.addHeader("Accept-Encoding", "gzip");
httpPost.addHeader("Connection", "Keep-Alive");
httpPost.addHeader("X-INFO", com.amap.api.location.core.d.a((Context) null).a(str2));
httpPost.addHeader("ia", "1");
httpPost.addHeader("key", com.amap.api.location.core.d.a());
stringBuffer.delete(0, stringBuffer.length());
httpPost.setEntity(byteArrayEntity);
HttpResponse execute = b2.execute(httpPost);
int statusCode = execute.getStatusLine().getStatusCode();
if (statusCode == 200) {
r5 = execute.getEntity().getContent();
try {
String value = execute.getEntity().getContentType().getValue();
String str4 = Config.INVALID_IP;
int indexOf = value.indexOf("charset=");
if (indexOf != -1) {
str4 = value.substring(indexOf + 8);
}
String str5 = TextUtils.isEmpty(str4) ? "UTF-8" : str4;
gZIPInputStream = a(execute) ? new GZIPInputStream(r5) : null;
try {
r3 = gZIPInputStream != null ? new InputStreamReader(gZIPInputStream, str5) : new InputStreamReader((InputStream) r5, str5);
} catch (SocketException e) {
} catch (SocketTimeoutException e2) {
} catch (UnknownHostException e3) {
gZIPInputStream2 = gZIPInputStream;
gZIPInputStream = r5;
httpPost2 = httpPost;
httpPost = b2;
} catch (ConnectTimeoutException e4) {
} catch (Throwable th3) {
th2 = th3;
}
} catch (SocketException e5) {
} catch (SocketTimeoutException e6) {
} catch (UnknownHostException e7) {
gZIPInputStream = r5;
httpPost2 = httpPost;
httpPost = b2;
} catch (ConnectTimeoutException e8) {
} catch (Throwable th4) {
th2 = th4;
}
try {
bufferedReader = new BufferedReader(r3, 2048);
while (true) {
try {
String readLine = bufferedReader.readLine();
if (readLine == null) {
break;
}
stringBuffer.append(readLine);
} catch (SocketException e9) {
throw new com.amap.api.location.core.a("socket 连接异常 - SocketException");
} catch (SocketTimeoutException e10) {
throw new com.amap.api.location.core.a("socket 连接超时 - SocketTimeoutException");
} catch (UnknownHostException e11) {
bufferedReader2 = bufferedReader;
bufferedReader = r3;
gZIPInputStream2 = gZIPInputStream;
gZIPInputStream = r5;
httpPost2 = httpPost;
httpPost = b2;
try {
throw new com.amap.api.location.core.a("未知主机 - UnKnowHostException");
} catch (Throwable th5) {
b2 = httpPost;
httpPost = httpPost2;
r5 = gZIPInputStream;
gZIPInputStream = gZIPInputStream2;
r3 = bufferedReader;
bufferedReader = bufferedReader2;
th = th5;
if (httpPost != null) {
httpPost.abort();
}
if (b2 != 0) {
b2.getConnectionManager().shutdown();
}
if (gZIPInputStream != null) {
try {
gZIPInputStream.close();
} catch (Throwable th6) {
}
}
if (r5 != 0) {
try {
r5.close();
} catch (Throwable th7) {
th7.printStackTrace();
}
}
if (r3 != 0) {
try {
r3.close();
} catch (Throwable th8) {
th8.printStackTrace();
}
}
if (bufferedReader != null) {
throw th;
}
try {
bufferedReader.close();
throw th;
} catch (Throwable th9) {
th9.printStackTrace();
throw th;
}
}
} catch (ConnectTimeoutException e12) {
throw new com.amap.api.location.core.a("http连接失败 - ConnectionException");
} catch (Throwable th10) {
th2 = th10;
th2.printStackTrace();
throw new com.amap.api.location.core.a("未知的错误");
}
}
str3 = stringBuffer.toString();
stringBuffer.delete(0, stringBuffer.length());
inputStreamReader = r3;
inputStream = r5;
} catch (SocketException e13) {
} catch (SocketTimeoutException e14) {
} catch (UnknownHostException e15) {
bufferedReader = r3;
gZIPInputStream2 = gZIPInputStream;
gZIPInputStream = r5;
httpPost2 = httpPost;
httpPost = b2;
} catch (ConnectTimeoutException e16) {
} catch (Throwable th11) {
th2 = th11;
}
} else {
if (statusCode == 404) {
throw new com.amap.api.location.core.a("服务器连接失败 - UnknownServiceException");
}
inputStream = null;
gZIPInputStream = null;
inputStreamReader = null;
bufferedReader = null;
str3 = Config.INVALID_IP;
}
if (httpPost != null) {
httpPost.abort();
}
if (b2 != 0) {
b2.getConnectionManager().shutdown();
}
if (gZIPInputStream != null) {
try {
gZIPInputStream.close();
} catch (Throwable th12) {
}
}
if (inputStream != null) {
try {
inputStream.close();
} catch (Throwable th13) {
th13.printStackTrace();
}
}
if (inputStreamReader != null) {
try {
inputStreamReader.close();
} catch (Throwable th14) {
th14.printStackTrace();
}
}
if (bufferedReader != null) {
try {
bufferedReader.close();
} catch (Throwable th15) {
th15.printStackTrace();
}
}
if (TextUtils.isEmpty(str3)) {
return null;
}
return str3;
} catch (SocketException e17) {
} catch (SocketTimeoutException e18) {
} catch (UnknownHostException e19) {
httpPost2 = httpPost;
httpPost = b2;
} catch (ConnectTimeoutException e20) {
} catch (Throwable th16) {
th2 = th16;
}
} catch (SocketException e21) {
} catch (SocketTimeoutException e22) {
} catch (UnknownHostException e23) {
httpPost = b2;
} catch (ConnectTimeoutException e24) {
} catch (Throwable th17) {
httpPost = null;
r5 = 0;
gZIPInputStream = null;
r3 = 0;
bufferedReader = null;
th = th17;
}
} catch (Throwable th18) {
th = th18;
}
} catch (SocketException e25) {
} catch (SocketTimeoutException e26) {
} catch (UnknownHostException e27) {
} catch (ConnectTimeoutException e28) {
} catch (Throwable th19) {
b2 = 0;
httpPost = null;
r5 = 0;
gZIPInputStream = null;
r3 = 0;
bufferedReader = null;
th = th19;
}
} catch (Throwable th20) {
r5 = 0;
gZIPInputStream = null;
r3 = 0;
bufferedReader = null;
th = th20;
}
}
public String a(byte[] bArr, Context context) {
HttpPost httpPost;
HttpClient httpClient;
String str;
BufferedReader bufferedReader;
InputStream inputStream;
HttpPost httpPost2;
HttpClient httpClient2;
NetworkInfo b2 = bl.b(context);
if (a(b2) == -1) {
return null;
}
HttpClient httpClient3 = null;
HttpPost httpPost3 = null;
InputStream inputStream2 = null;
InputStreamReader inputStreamReader = null;
BufferedReader bufferedReader2 = null;
StringBuffer stringBuffer = new StringBuffer();
StringBuffer stringBuffer2 = new StringBuffer();
stringBuffer2.append("http://cgicol.amap.com/collection/writedata?ver=v1.0_ali&");
stringBuffer2.append("zei=").append(an.f369a);
stringBuffer2.append("&zsi=").append(an.f370b);
int i = 0;
boolean z = false;
StringBuffer stringBuffer3 = stringBuffer;
String str2 = Config.INVALID_IP;
while (i < 1 && !z) {
try {
httpClient = a(context, b2);
try {
httpPost = new HttpPost(stringBuffer2.toString());
try {
stringBuffer3.delete(0, stringBuffer3.length());
stringBuffer3.append("application/soap+xml;charset=");
stringBuffer3.append("UTF-8");
stringBuffer3.delete(0, stringBuffer3.length());
httpPost.addHeader("gzipped", "1");
ByteArrayEntity byteArrayEntity = new ByteArrayEntity(bl.a(bArr));
byteArrayEntity.setContentType("application/octet-stream");
httpPost.setEntity(byteArrayEntity);
HttpResponse execute = httpClient.execute(httpPost);
if (execute.getStatusLine().getStatusCode() == 200) {
InputStream content = execute.getEntity().getContent();
try {
InputStreamReader inputStreamReader2 = new InputStreamReader(content, "UTF-8");
try {
BufferedReader bufferedReader3 = new BufferedReader(inputStreamReader2, 2048);
while (true) {
try {
String readLine = bufferedReader3.readLine();
if (readLine == null) {
break;
}
stringBuffer3.append(readLine);
} catch (SocketException e) {
inputStream = content;
str = str2;
bufferedReader = bufferedReader3;
inputStreamReader = inputStreamReader2;
if (httpPost != null) {
httpPost.abort();
httpPost2 = null;
} else {
httpPost2 = httpPost;
}
if (httpClient != null) {
httpClient.getConnectionManager().shutdown();
httpClient2 = null;
} else {
httpClient2 = httpClient;
}
if (inputStream != null) {
inputStream.close();
inputStream = null;
}
if (inputStreamReader != null) {
inputStreamReader.close();
inputStreamReader = null;
}
if (bufferedReader != null) {
bufferedReader.close();
bufferedReader = null;
i++;
BufferedReader bufferedReader4 = bufferedReader;
str2 = str;
httpClient3 = httpClient2;
httpPost3 = httpPost2;
inputStream2 = inputStream;
bufferedReader2 = bufferedReader4;
} else {
i++;
BufferedReader bufferedReader42 = bufferedReader;
str2 = str;
httpClient3 = httpClient2;
httpPost3 = httpPost2;
inputStream2 = inputStream;
bufferedReader2 = bufferedReader42;
}
} catch (SocketTimeoutException e2) {
inputStream = content;
str = str2;
bufferedReader = bufferedReader3;
inputStreamReader = inputStreamReader2;
if (httpPost != null) {
httpPost.abort();
httpPost2 = null;
} else {
httpPost2 = httpPost;
}
if (httpClient != null) {
httpClient.getConnectionManager().shutdown();
httpClient2 = null;
} else {
httpClient2 = httpClient;
}
if (inputStream != null) {
inputStream.close();
inputStream = null;
}
if (inputStreamReader != null) {
inputStreamReader.close();
inputStreamReader = null;
}
if (bufferedReader != null) {
bufferedReader.close();
bufferedReader = null;
i++;
BufferedReader bufferedReader422 = bufferedReader;
str2 = str;
httpClient3 = httpClient2;
httpPost3 = httpPost2;
inputStream2 = inputStream;
bufferedReader2 = bufferedReader422;
} else {
i++;
BufferedReader bufferedReader4222 = bufferedReader;
str2 = str;
httpClient3 = httpClient2;
httpPost3 = httpPost2;
inputStream2 = inputStream;
bufferedReader2 = bufferedReader4222;
}
} catch (UnknownHostException e3) {
inputStream = content;
str = str2;
bufferedReader = bufferedReader3;
httpClient2 = httpClient;
inputStreamReader = inputStreamReader2;
httpPost2 = httpPost;
if (httpPost2 != null) {
httpPost2.abort();
httpPost2 = null;
}
if (httpClient2 != null) {
httpClient2.getConnectionManager().shutdown();
httpClient2 = null;
}
if (inputStream != null) {
inputStream.close();
inputStream = null;
}
if (inputStreamReader != null) {
inputStreamReader.close();
inputStreamReader = null;
}
if (bufferedReader != null) {
bufferedReader.close();
bufferedReader = null;
i++;
BufferedReader bufferedReader42222 = bufferedReader;
str2 = str;
httpClient3 = httpClient2;
httpPost3 = httpPost2;
inputStream2 = inputStream;
bufferedReader2 = bufferedReader42222;
} else {
i++;
BufferedReader bufferedReader422222 = bufferedReader;
str2 = str;
httpClient3 = httpClient2;
httpPost3 = httpPost2;
inputStream2 = inputStream;
bufferedReader2 = bufferedReader422222;
}
} catch (ConnectTimeoutException e4) {
inputStream = content;
str = str2;
bufferedReader = bufferedReader3;
inputStreamReader = inputStreamReader2;
if (httpPost != null) {
httpPost.abort();
httpPost2 = null;
} else {
httpPost2 = httpPost;
}
if (httpClient != null) {
httpClient.getConnectionManager().shutdown();
httpClient2 = null;
} else {
httpClient2 = httpClient;
}
if (inputStream != null) {
inputStream.close();
inputStream = null;
}
if (inputStreamReader != null) {
inputStreamReader.close();
inputStreamReader = null;
}
if (bufferedReader != null) {
bufferedReader.close();
bufferedReader = null;
i++;
BufferedReader bufferedReader4222222 = bufferedReader;
str2 = str;
httpClient3 = httpClient2;
httpPost3 = httpPost2;
inputStream2 = inputStream;
bufferedReader2 = bufferedReader4222222;
} else {
i++;
BufferedReader bufferedReader42222222 = bufferedReader;
str2 = str;
httpClient3 = httpClient2;
httpPost3 = httpPost2;
inputStream2 = inputStream;
bufferedReader2 = bufferedReader42222222;
}
} catch (Throwable th) {
th = th;
bufferedReader2 = bufferedReader3;
inputStreamReader = inputStreamReader2;
inputStream2 = content;
if (httpPost != null) {
httpPost.abort();
}
if (httpClient != null) {
httpClient.getConnectionManager().shutdown();
}
if (inputStream2 != null) {
inputStream2.close();
}
if (inputStreamReader != null) {
inputStreamReader.close();
}
if (bufferedReader2 != null) {
bufferedReader2.close();
}
throw th;
}
}
String stringBuffer4 = stringBuffer3.toString();
stringBuffer3.delete(0, stringBuffer3.length());
stringBuffer3 = null;
z = true;
inputStream = content;
str = stringBuffer4;
bufferedReader = bufferedReader3;
inputStreamReader = inputStreamReader2;
} catch (SocketException e5) {
inputStreamReader = inputStreamReader2;
str = str2;
bufferedReader = bufferedReader2;
inputStream = content;
} catch (SocketTimeoutException e6) {
inputStreamReader = inputStreamReader2;
str = str2;
bufferedReader = bufferedReader2;
inputStream = content;
} catch (UnknownHostException e7) {
inputStreamReader = inputStreamReader2;
str = str2;
httpPost2 = httpPost;
bufferedReader = bufferedReader2;
inputStream = content;
httpClient2 = httpClient;
} catch (ConnectTimeoutException e8) {
inputStreamReader = inputStreamReader2;
str = str2;
bufferedReader = bufferedReader2;
inputStream = content;
} catch (Throwable th2) {
th = th2;
inputStreamReader = inputStreamReader2;
inputStream2 = content;
}
} catch (SocketException e9) {
str = str2;
bufferedReader = bufferedReader2;
inputStream = content;
} catch (SocketTimeoutException e10) {
str = str2;
bufferedReader = bufferedReader2;
inputStream = content;
} catch (UnknownHostException e11) {
httpPost2 = httpPost;
str = str2;
bufferedReader = bufferedReader2;
inputStream = content;
httpClient2 = httpClient;
} catch (ConnectTimeoutException e12) {
str = str2;
bufferedReader = bufferedReader2;
inputStream = content;
} catch (Throwable th3) {
th = th3;
inputStream2 = content;
}
} else {
str = str2;
bufferedReader = bufferedReader2;
inputStream = inputStream2;
}
if (httpPost != null) {
httpPost.abort();
httpPost2 = null;
} else {
httpPost2 = httpPost;
}
if (httpClient != null) {
httpClient.getConnectionManager().shutdown();
httpClient2 = null;
} else {
httpClient2 = httpClient;
}
if (inputStream != null) {
inputStream.close();
inputStream = null;
}
if (inputStreamReader != null) {
inputStreamReader.close();
inputStreamReader = null;
}
} catch (SocketException e13) {
str = str2;
bufferedReader = bufferedReader2;
inputStream = inputStream2;
} catch (SocketTimeoutException e14) {
str = str2;
bufferedReader = bufferedReader2;
inputStream = inputStream2;
} catch (UnknownHostException e15) {
httpClient2 = httpClient;
str = str2;
bufferedReader = bufferedReader2;
inputStream = inputStream2;
httpPost2 = httpPost;
} catch (ConnectTimeoutException e16) {
str = str2;
bufferedReader = bufferedReader2;
inputStream = inputStream2;
} catch (Throwable th4) {
th = th4;
}
} catch (SocketException e17) {
httpPost = httpPost3;
str = str2;
bufferedReader = bufferedReader2;
inputStream = inputStream2;
} catch (SocketTimeoutException e18) {
httpPost = httpPost3;
str = str2;
bufferedReader = bufferedReader2;
inputStream = inputStream2;
} catch (UnknownHostException e19) {
str = str2;
bufferedReader = bufferedReader2;
inputStream = inputStream2;
httpPost2 = httpPost3;
httpClient2 = httpClient;
} catch (ConnectTimeoutException e20) {
httpPost = httpPost3;
str = str2;
bufferedReader = bufferedReader2;
inputStream = inputStream2;
} catch (Throwable th5) {
th = th5;
httpPost = httpPost3;
}
} catch (SocketException e21) {
httpPost = httpPost3;
httpClient = httpClient3;
str = str2;
bufferedReader = bufferedReader2;
inputStream = inputStream2;
} catch (SocketTimeoutException e22) {
httpPost = httpPost3;
httpClient = httpClient3;
str = str2;
bufferedReader = bufferedReader2;
inputStream = inputStream2;
} catch (UnknownHostException e23) {
BufferedReader bufferedReader5 = bufferedReader2;
inputStream = inputStream2;
httpPost2 = httpPost3;
httpClient2 = httpClient3;
str = str2;
bufferedReader = bufferedReader5;
} catch (ConnectTimeoutException e24) {
httpPost = httpPost3;
httpClient = httpClient3;
str = str2;
bufferedReader = bufferedReader2;
inputStream = inputStream2;
} catch (Throwable th6) {
th = th6;
httpPost = httpPost3;
httpClient = httpClient3;
}
if (bufferedReader != null) {
bufferedReader.close();
bufferedReader = null;
i++;
BufferedReader bufferedReader422222222 = bufferedReader;
str2 = str;
httpClient3 = httpClient2;
httpPost3 = httpPost2;
inputStream2 = inputStream;
bufferedReader2 = bufferedReader422222222;
} else {
i++;
BufferedReader bufferedReader4222222222 = bufferedReader;
str2 = str;
httpClient3 = httpClient2;
httpPost3 = httpPost2;
inputStream2 = inputStream;
bufferedReader2 = bufferedReader4222222222;
}
}
stringBuffer2.delete(0, stringBuffer2.length());
if (str2.equals(Config.INVALID_IP)) {
return null;
}
return str2;
}
public String a(byte[] bArr, Context context, JSONObject jSONObject) {
HttpClient httpClient;
HttpPost httpPost;
BufferedReader bufferedReader;
InputStreamReader inputStreamReader;
GZIPInputStream gZIPInputStream;
InputStream inputStream;
HttpPost httpPost2;
GZIPInputStream gZIPInputStream2;
StringBuffer stringBuffer;
boolean z;
InputStream inputStream2;
InputStreamReader inputStreamReader2;
String str;
NetworkInfo b2 = bl.b(context);
if (a(b2) == -1) {
throw new com.amap.api.location.core.a("http连接失败 - ConnectionException");
}
HttpPost httpPost3 = null;
GZIPInputStream gZIPInputStream3 = null;
BufferedReader bufferedReader2 = null;
StringBuffer stringBuffer2 = new StringBuffer();
boolean z2 = false;
int i = 0;
String str2 = Config.INVALID_IP;
InputStreamReader inputStreamReader3 = null;
InputStream inputStream3 = null;
HttpClient httpClient2 = null;
while (i < 1 && !z2) {
try {
httpClient = a(context, b2);
try {
String[] a2 = a(jSONObject);
httpPost = new HttpPost(com.amap.api.location.core.d.j());
try {
try {
ByteArrayEntity byteArrayEntity = new ByteArrayEntity(bl.a(bArr));
byteArrayEntity.setContentType("application/octet-stream");
httpPost.addHeader("Accept-Encoding", "gzip");
httpPost.addHeader("gzipped", "1");
httpPost.addHeader("X-INFO", a2[2]);
httpPost.addHeader("X-BIZ", a2[3]);
httpPost.addHeader("KEY", a2[1]);
httpPost.addHeader("ec", "1");
if (a2[4] != null && a2[4].length() > 0) {
httpPost.addHeader("User-Agent", a2[4]);
}
String a3 = com.amap.api.location.core.e.a();
String a4 = com.amap.api.location.core.e.a(a3, "key=" + a2[1]);
httpPost.addHeader("ts", a3);
httpPost.addHeader("scode", a4);
stringBuffer2.delete(0, stringBuffer2.length());
httpPost.setEntity(byteArrayEntity);
HttpResponse execute = httpClient.execute(httpPost);
int statusCode = execute.getStatusLine().getStatusCode();
if (statusCode == 200) {
inputStream3 = execute.getEntity().getContent();
String value = execute.getEntity().getContentType().getValue();
String str3 = Config.INVALID_IP;
int indexOf = value.indexOf("charset=");
if (indexOf != -1) {
str3 = value.substring(indexOf + 8);
}
String str4 = TextUtils.isEmpty(str3) ? "UTF-8" : str3;
if (a(execute)) {
gZIPInputStream3 = new GZIPInputStream(inputStream3);
}
inputStreamReader3 = gZIPInputStream3 != null ? new InputStreamReader(gZIPInputStream3, str4) : new InputStreamReader(inputStream3, str4);
bufferedReader = new BufferedReader(inputStreamReader3, 2048);
while (true) {
try {
String readLine = bufferedReader.readLine();
if (readLine == null) {
break;
}
stringBuffer2.append(readLine);
} catch (SocketException e) {
throw new com.amap.api.location.core.a("socket 连接异常 - SocketException");
} catch (SocketTimeoutException e2) {
throw new com.amap.api.location.core.a("socket 连接超时 - SocketTimeoutException");
} catch (UnknownHostException e3) {
inputStreamReader = inputStreamReader3;
gZIPInputStream = gZIPInputStream3;
inputStream = inputStream3;
httpPost2 = httpPost;
httpClient2 = httpClient;
try {
throw new com.amap.api.location.core.a("未知主机 - UnKnowHostException");
} catch (Throwable th) {
httpClient = httpClient2;
httpPost = httpPost2;
inputStream3 = inputStream;
gZIPInputStream3 = gZIPInputStream;
inputStreamReader3 = inputStreamReader;
bufferedReader2 = bufferedReader;
th = th;
if (httpPost != null) {
httpPost.abort();
}
if (httpClient != null) {
httpClient.getConnectionManager().shutdown();
}
if (gZIPInputStream3 != null) {
try {
gZIPInputStream3.close();
} catch (Throwable th2) {
th2.printStackTrace();
}
}
if (inputStream3 != null) {
try {
inputStream3.close();
} catch (Throwable th3) {
th3.printStackTrace();
}
}
if (inputStreamReader3 != null) {
inputStreamReader3.close();
}
if (bufferedReader2 != null) {
throw th;
}
bufferedReader2.close();
throw th;
}
} catch (ConnectTimeoutException e4) {
throw new com.amap.api.location.core.a("http连接失败 - ConnectionException");
} catch (Throwable th4) {
throw new com.amap.api.location.core.a("http连接失败 - ConnectionException");
}
}
String stringBuffer3 = stringBuffer2.toString();
stringBuffer2.delete(0, stringBuffer2.length());
z = true;
gZIPInputStream2 = gZIPInputStream3;
stringBuffer = null;
inputStream2 = inputStream3;
inputStreamReader2 = inputStreamReader3;
str = stringBuffer3;
} else {
if (statusCode == 404) {
throw new com.amap.api.location.core.a("服务器连接失败 - UnknownServiceException");
}
gZIPInputStream2 = gZIPInputStream3;
stringBuffer = stringBuffer2;
String str5 = str2;
bufferedReader = bufferedReader2;
z = z2;
inputStream2 = inputStream3;
inputStreamReader2 = inputStreamReader3;
str = str5;
}
if (httpPost != null) {
httpPost.abort();
httpPost = null;
}
if (httpClient != null) {
httpClient.getConnectionManager().shutdown();
httpClient = null;
}
if (gZIPInputStream2 != null) {
try {
gZIPInputStream2.close();
} catch (Throwable th5) {
th5.printStackTrace();
}
gZIPInputStream2 = null;
}
if (inputStream2 != null) {
try {
inputStream2.close();
} catch (Throwable th6) {
th6.printStackTrace();
}
inputStream2 = null;
}
if (inputStreamReader2 != null) {
inputStreamReader2.close();
inputStreamReader2 = null;
}
if (bufferedReader != null) {
bufferedReader.close();
bufferedReader = null;
}
i++;
stringBuffer2 = stringBuffer;
gZIPInputStream3 = gZIPInputStream2;
httpPost3 = httpPost;
httpClient2 = httpClient;
InputStreamReader inputStreamReader4 = inputStreamReader2;
inputStream3 = inputStream2;
z2 = z;
bufferedReader2 = bufferedReader;
str2 = str;
inputStreamReader3 = inputStreamReader4;
} catch (Throwable th7) {
th = th7;
}
} catch (SocketException e5) {
} catch (SocketTimeoutException e6) {
} catch (UnknownHostException e7) {
bufferedReader = bufferedReader2;
inputStreamReader = inputStreamReader3;
gZIPInputStream = gZIPInputStream3;
inputStream = inputStream3;
httpPost2 = httpPost;
httpClient2 = httpClient;
} catch (ConnectTimeoutException e8) {
} catch (Throwable th8) {
}
} catch (SocketException e9) {
} catch (SocketTimeoutException e10) {
} catch (UnknownHostException e11) {
bufferedReader = bufferedReader2;
httpClient2 = httpClient;
inputStreamReader = inputStreamReader3;
gZIPInputStream = gZIPInputStream3;
inputStream = inputStream3;
httpPost2 = httpPost3;
} catch (ConnectTimeoutException e12) {
} catch (Throwable th9) {
th = th9;
httpPost = httpPost3;
}
} catch (SocketException e13) {
} catch (SocketTimeoutException e14) {
} catch (UnknownHostException e15) {
bufferedReader = bufferedReader2;
inputStreamReader = inputStreamReader3;
gZIPInputStream = gZIPInputStream3;
inputStream = inputStream3;
httpPost2 = httpPost3;
} catch (ConnectTimeoutException e16) {
} catch (Throwable th10) {
}
}
if (TextUtils.isEmpty(str2)) {
return null;
}
return str2;
}
}