九游游戏中心HD v4.6.8.1版本的 MD5 值为:78c397802cc5ffdcc7f5502ede90502e
以下内容为反编译后的 br.java 源代码,内容仅作参考
package com.b;
import android.content.Context;
import android.net.NetworkInfo;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import com.autonavi.aps.amapapi.model.AmapLoc;
import com.b.bl;
import com.b.bx;
import com.tmall.applink.BuildConfig;
import com.tmall.applink.util.TBAppLinkPhoneUtil;
import com.xiaomi.mipush.sdk.MiPushClient;
import java.io.BufferedOutputStream;
import java.io.EOFException;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.RandomAccessFile;
import java.net.HttpURLConnection;
import java.net.SocketException;
import java.net.SocketTimeoutException;
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.zip.GZIPInputStream;
import org.json.JSONObject;
public final class br {
private static volatile String c = null;
private static Hashtable<String, Long> d = new Hashtable<>();
private static cd e = new cd();
private static Hashtable<String, String> f = new Hashtable<>();
private static TelephonyManager g = null;
public static final int[] f3876a = {0, 0};
static int b = 213891;
private static int a(int i) {
int[] iArr = new int[32];
int i2 = 0;
for (int i3 = 0; i3 < 4; i3++) {
iArr[i3] = (i >> (i3 * 8)) & 255;
iArr[i3] = ((iArr[i3] << 4) & 240) + ((iArr[i3] >> 4) & 15);
i2 += (iArr[i3] & 255) << ((3 - i3) * 8);
}
return b + i2;
}
private static String a(int i, String str) {
String[] split = str.split("#");
switch (i) {
case 1:
return split[1] + "_" + split[2];
case 2:
return split[3];
default:
return null;
}
}
public static ArrayList<String> a(String str) {
ArrayList<String> arrayList;
ArrayList<String> arrayList2 = null;
if (!f.isEmpty()) {
int b2 = b(str);
String[] split = str.split("#");
switch (b2) {
case 1:
case 2:
for (String str2 : f.keySet()) {
if (f.get(str2).contains(MiPushClient.ACCEPT_TIME_SEPARATOR + split[3] + MiPushClient.ACCEPT_TIME_SEPARATOR)) {
arrayList = arrayList2 == null ? new ArrayList<>() : arrayList2;
arrayList.add(str2);
} else {
arrayList = arrayList2;
}
arrayList2 = arrayList;
}
break;
}
}
return arrayList2;
}
private static void a(String str, Hashtable<String, String> hashtable) {
String[] split;
if (TextUtils.isEmpty(str)) {
return;
}
for (String str2 : str.split("#")) {
if (str2.contains(MiPushClient.ACCEPT_TIME_SEPARATOR)) {
String[] split2 = str2.split(MiPushClient.ACCEPT_TIME_SEPARATOR);
hashtable.put(split2[0], split2[1]);
}
}
}
private static boolean a(Context context, String str, String str2) {
Throwable th;
InputStream inputStream;
HttpURLConnection httpURLConnection;
GZIPInputStream gZIPInputStream;
boolean z;
GZIPInputStream gZIPInputStream2;
UnknownHostException unknownHostException;
HttpURLConnection httpURLConnection2;
GZIPInputStream gZIPInputStream3;
InputStream inputStream2;
SocketTimeoutException socketTimeoutException;
InputStream inputStream3;
SocketException socketException;
InputStream inputStream4;
EOFException eOFException;
InputStream inputStream5;
String str3;
String str4;
InputStream inputStream6;
GZIPInputStream gZIPInputStream4;
int i;
boolean z2;
boolean z3 = false;
String[] strArr = new String[2];
if (a(str, str2, 1, strArr)) {
if (d.containsKey(strArr[1])) {
if (cm.a() - d.get(strArr[1]).longValue() < 86400000) {
return false;
}
d.remove(strArr[1]);
}
InputStream inputStream7 = null;
?? r4 = 0;
try {
try {
cm.b();
HashMap hashMap = new HashMap();
hashMap.put("v", BuildConfig.VERSION_NAME);
cf.a(context);
httpURLConnection = cf.a(context, "https://offline.aps.amap.com/LoadOfflineData/getData", hashMap, strArr[0].getBytes("UTF-8"));
} catch (Throwable th2) {
th = th2;
}
} catch (EOFException e2) {
eOFException = e2;
inputStream5 = null;
httpURLConnection = null;
gZIPInputStream = null;
z = false;
} catch (SocketException e3) {
socketException = e3;
inputStream4 = null;
httpURLConnection = null;
gZIPInputStream = null;
z = false;
} catch (SocketTimeoutException e4) {
socketTimeoutException = e4;
inputStream3 = null;
httpURLConnection = null;
gZIPInputStream = null;
z = false;
} catch (UnknownHostException e5) {
unknownHostException = e5;
httpURLConnection2 = null;
gZIPInputStream3 = null;
z = false;
inputStream2 = null;
} catch (Throwable th3) {
th = th3;
inputStream = null;
httpURLConnection = null;
gZIPInputStream = null;
z = false;
}
if (httpURLConnection == null) {
if (0 != 0) {
try {
r4.close();
} catch (Throwable th4) {
dr.a(th4, "Off", "c 2 part7");
}
}
if (0 != 0) {
try {
inputStream7.close();
} catch (Throwable th5) {
dr.a(th5, "Off", "c 2 part8");
}
}
if (httpURLConnection != null) {
try {
httpURLConnection.disconnect();
return false;
} catch (Throwable th6) {
dr.a(th6, "Off", "c 2 part9");
return false;
}
}
return false;
}
try {
if (httpURLConnection.getResponseCode() == 200) {
Iterator<Map.Entry<String, List<String>>> it = httpURLConnection.getHeaderFields().entrySet().iterator();
while (true) {
if (!it.hasNext()) {
i = 0;
break;
}
Map.Entry<String, List<String>> next = it.next();
if ("code".equals(next.getKey())) {
i = Integer.parseInt(next.getValue().get(0));
break;
}
}
if (i == 260) {
c = strArr[1];
r4 = httpURLConnection.getInputStream();
try {
gZIPInputStream = new GZIPInputStream(r4);
try {
File file = new File(strArr[1]);
if ((!file.exists() || file.delete()) && dr.n) {
File parentFile = file.getParentFile();
if (!parentFile.exists()) {
parentFile.mkdirs();
}
BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(new FileOutputStream(file), 2048);
byte[] bArr = new byte[2048];
while (true) {
int read = gZIPInputStream.read(bArr, 0, 2048);
if (read == -1) {
break;
}
bufferedOutputStream.write(bArr, 0, read);
}
bufferedOutputStream.flush();
bufferedOutputStream.close();
try {
d.put(strArr[1], Long.valueOf(cm.a()));
String a2 = cm.a(0L, "yyyyMMdd");
if (a2.equals(String.valueOf(f3876a[0]))) {
f3876a[1] = f3876a[1] + 1;
z3 = true;
inputStream6 = r4;
gZIPInputStream4 = gZIPInputStream;
} else {
try {
f3876a[0] = Integer.parseInt(a2);
} catch (Throwable th7) {
f3876a[0] = 0;
f3876a[1] = 0;
dr.a(th7, "Off", "c 2 part1");
}
f3876a[1] = 1;
z2 = true;
}
} catch (EOFException e6) {
z = true;
eOFException = e6;
inputStream5 = r4;
dr.a(eOFException, "Off", "c 2 part5");
if (gZIPInputStream != null) {
try {
gZIPInputStream.close();
} catch (Throwable th8) {
dr.a(th8, "Off", "c 2 part7");
}
}
if (inputStream5 != null) {
try {
inputStream5.close();
} catch (Throwable th9) {
dr.a(th9, "Off", "c 2 part8");
}
}
if (httpURLConnection != null) {
try {
httpURLConnection.disconnect();
} catch (Throwable th10) {
th = th10;
str3 = "Off";
str4 = "c 2 part9";
dr.a(th, str3, str4);
if (!TextUtils.isEmpty(c)) {
}
return z;
}
}
if (!TextUtils.isEmpty(c)) {
}
return z;
} catch (SocketException e7) {
z = true;
socketException = e7;
inputStream4 = r4;
dr.a(socketException, "Off", "c 2 part3");
if (gZIPInputStream != null) {
try {
gZIPInputStream.close();
} catch (Throwable th11) {
dr.a(th11, "Off", "c 2 part7");
}
}
if (inputStream4 != null) {
try {
inputStream4.close();
} catch (Throwable th12) {
dr.a(th12, "Off", "c 2 part8");
}
}
if (httpURLConnection != null) {
try {
httpURLConnection.disconnect();
} catch (Throwable th13) {
th = th13;
str3 = "Off";
str4 = "c 2 part9";
dr.a(th, str3, str4);
if (!TextUtils.isEmpty(c)) {
}
return z;
}
}
if (!TextUtils.isEmpty(c)) {
}
return z;
} catch (SocketTimeoutException e8) {
z = true;
socketTimeoutException = e8;
inputStream3 = r4;
dr.a(socketTimeoutException, "Off", "c 2 part4");
if (gZIPInputStream != null) {
try {
gZIPInputStream.close();
} catch (Throwable th14) {
dr.a(th14, "Off", "c 2 part7");
}
}
if (inputStream3 != null) {
try {
inputStream3.close();
} catch (Throwable th15) {
dr.a(th15, "Off", "c 2 part8");
}
}
if (httpURLConnection != null) {
try {
httpURLConnection.disconnect();
} catch (Throwable th16) {
th = th16;
str3 = "Off";
str4 = "c 2 part9";
dr.a(th, str3, str4);
if (!TextUtils.isEmpty(c)) {
}
return z;
}
}
if (!TextUtils.isEmpty(c)) {
}
return z;
} catch (UnknownHostException e9) {
inputStream2 = r4;
httpURLConnection2 = httpURLConnection;
gZIPInputStream3 = gZIPInputStream;
z = true;
unknownHostException = e9;
try {
dr.a(unknownHostException, "Off", "c 2 part2");
if (gZIPInputStream3 != null) {
try {
gZIPInputStream3.close();
} catch (Throwable th17) {
dr.a(th17, "Off", "c 2 part7");
}
}
if (inputStream2 != null) {
try {
inputStream2.close();
} catch (Throwable th18) {
dr.a(th18, "Off", "c 2 part8");
}
}
if (httpURLConnection2 != null) {
try {
httpURLConnection2.disconnect();
} catch (Throwable th19) {
th = th19;
str3 = "Off";
str4 = "c 2 part9";
dr.a(th, str3, str4);
if (!TextUtils.isEmpty(c)) {
}
return z;
}
}
if (!TextUtils.isEmpty(c)) {
}
return z;
} catch (Throwable th20) {
th = th20;
gZIPInputStream2 = gZIPInputStream3;
httpURLConnection = httpURLConnection2;
r4 = inputStream2;
if (gZIPInputStream2 != null) {
try {
gZIPInputStream2.close();
} catch (Throwable th21) {
dr.a(th21, "Off", "c 2 part7");
}
}
if (r4 != 0) {
try {
r4.close();
} catch (Throwable th22) {
dr.a(th22, "Off", "c 2 part8");
}
}
if (httpURLConnection != null) {
try {
httpURLConnection.disconnect();
} catch (Throwable th23) {
dr.a(th23, "Off", "c 2 part9");
}
}
throw th;
}
} catch (Throwable th24) {
z = true;
th = th24;
inputStream = r4;
dr.a(th, "Off", "c 2 part6");
if (gZIPInputStream != null) {
try {
gZIPInputStream.close();
} catch (Throwable th25) {
dr.a(th25, "Off", "c 2 part7");
}
}
if (inputStream != null) {
try {
inputStream.close();
} catch (Throwable th26) {
dr.a(th26, "Off", "c 2 part8");
}
}
if (httpURLConnection != null) {
try {
httpURLConnection.disconnect();
} catch (Throwable th27) {
th = th27;
str3 = "Off";
str4 = "c 2 part9";
dr.a(th, str3, str4);
if (!TextUtils.isEmpty(c)) {
}
return z;
}
}
if (!TextUtils.isEmpty(c)) {
}
return z;
}
} else {
z2 = false;
}
inputStream6 = r4;
z3 = z2;
gZIPInputStream4 = gZIPInputStream;
} catch (EOFException e10) {
eOFException = e10;
z = false;
inputStream5 = r4;
} catch (SocketException e11) {
socketException = e11;
z = false;
inputStream4 = r4;
} catch (SocketTimeoutException e12) {
socketTimeoutException = e12;
z = false;
inputStream3 = r4;
} catch (UnknownHostException e13) {
unknownHostException = e13;
z = false;
inputStream2 = r4;
httpURLConnection2 = httpURLConnection;
gZIPInputStream3 = gZIPInputStream;
} catch (Throwable th28) {
th = th28;
z = false;
inputStream = r4;
}
} catch (EOFException e14) {
eOFException = e14;
gZIPInputStream = null;
z = false;
inputStream5 = r4;
} catch (SocketException e15) {
socketException = e15;
gZIPInputStream = null;
z = false;
inputStream4 = r4;
} catch (SocketTimeoutException e16) {
socketTimeoutException = e16;
gZIPInputStream = null;
z = false;
inputStream3 = r4;
} catch (UnknownHostException e17) {
unknownHostException = e17;
z = false;
inputStream2 = r4;
httpURLConnection2 = httpURLConnection;
gZIPInputStream3 = null;
} catch (Throwable th29) {
th = th29;
gZIPInputStream = null;
z = false;
inputStream = r4;
}
} else {
if (dr.n) {
d.put(strArr[1], Long.valueOf(cm.a()));
}
inputStream6 = null;
gZIPInputStream4 = null;
}
try {
c(strArr[1]);
z = z3;
} catch (EOFException e18) {
gZIPInputStream = gZIPInputStream4;
inputStream5 = inputStream6;
eOFException = e18;
z = z3;
dr.a(eOFException, "Off", "c 2 part5");
if (gZIPInputStream != null) {
}
if (inputStream5 != null) {
}
if (httpURLConnection != null) {
}
if (!TextUtils.isEmpty(c)) {
}
return z;
} catch (SocketException e19) {
gZIPInputStream = gZIPInputStream4;
inputStream4 = inputStream6;
socketException = e19;
z = z3;
dr.a(socketException, "Off", "c 2 part3");
if (gZIPInputStream != null) {
}
if (inputStream4 != null) {
}
if (httpURLConnection != null) {
}
if (!TextUtils.isEmpty(c)) {
}
return z;
} catch (SocketTimeoutException e20) {
gZIPInputStream = gZIPInputStream4;
inputStream3 = inputStream6;
socketTimeoutException = e20;
z = z3;
dr.a(socketTimeoutException, "Off", "c 2 part4");
if (gZIPInputStream != null) {
}
if (inputStream3 != null) {
}
if (httpURLConnection != null) {
}
if (!TextUtils.isEmpty(c)) {
}
return z;
} catch (UnknownHostException e21) {
z = z3;
inputStream2 = inputStream6;
unknownHostException = e21;
gZIPInputStream3 = gZIPInputStream4;
httpURLConnection2 = httpURLConnection;
dr.a(unknownHostException, "Off", "c 2 part2");
if (gZIPInputStream3 != null) {
}
if (inputStream2 != null) {
}
if (httpURLConnection2 != null) {
}
if (!TextUtils.isEmpty(c)) {
}
return z;
} catch (Throwable th30) {
gZIPInputStream = gZIPInputStream4;
inputStream = inputStream6;
th = th30;
z = z3;
dr.a(th, "Off", "c 2 part6");
if (gZIPInputStream != null) {
}
if (inputStream != null) {
}
if (httpURLConnection != null) {
}
if (!TextUtils.isEmpty(c)) {
}
return z;
}
} else {
inputStream6 = null;
z = false;
gZIPInputStream4 = null;
}
if (gZIPInputStream4 != null) {
try {
gZIPInputStream4.close();
} catch (Throwable th31) {
dr.a(th31, "Off", "c 2 part7");
}
}
if (inputStream6 != null) {
try {
inputStream6.close();
} catch (Throwable th32) {
dr.a(th32, "Off", "c 2 part8");
}
}
if (httpURLConnection != null) {
try {
httpURLConnection.disconnect();
} catch (Throwable th33) {
th = th33;
str3 = "Off";
str4 = "c 2 part9";
dr.a(th, str3, str4);
if (!TextUtils.isEmpty(c)) {
}
return z;
}
}
} catch (EOFException e22) {
eOFException = e22;
inputStream5 = null;
gZIPInputStream = null;
z = false;
} catch (SocketException e23) {
socketException = e23;
inputStream4 = null;
gZIPInputStream = null;
z = false;
} catch (SocketTimeoutException e24) {
socketTimeoutException = e24;
inputStream3 = null;
gZIPInputStream = null;
z = false;
} catch (UnknownHostException e25) {
unknownHostException = e25;
httpURLConnection2 = httpURLConnection;
z = false;
gZIPInputStream3 = null;
inputStream2 = null;
} catch (Throwable th34) {
th = th34;
inputStream = null;
gZIPInputStream = null;
z = false;
}
if (!TextUtils.isEmpty(c)) {
c = null;
}
return z;
}
return false;
}
private static boolean a(String str, String str2, int i, String[] strArr) {
RandomAccessFile isFile;
String str3;
String str4;
long j = 0;
if (TextUtils.isEmpty(str) || TextUtils.isEmpty(str2)) {
return false;
}
StringBuilder c2 = c();
String a2 = a(b(str), str);
c2.append(a2).append(File.separator);
if (str2.startsWith("-")) {
c2.append(str2.substring(0, 4));
} else {
c2.append(str2.substring(0, 3));
}
c2.append(MiPushClient.ACCEPT_TIME_SEPARATOR);
int indexOf = str2.indexOf(MiPushClient.ACCEPT_TIME_SEPARATOR) + 1;
if (str2.substring(indexOf, indexOf + 1).startsWith("-")) {
c2.append(str2.substring(indexOf, indexOf + 4));
} else {
c2.append(str2.substring(indexOf, indexOf + 3));
}
c2.append(File.separator).append(str2);
strArr[1] = c2.toString();
c2.delete(0, c2.length());
File file = new File(strArr[1]);
if (file.exists() && (isFile = file.isFile()) != 0) {
RandomAccessFile randomAccessFile = null;
try {
try {
try {
isFile = new RandomAccessFile(file, "r");
try {
isFile.seek(0L);
j = isFile.readLong();
isFile = isFile;
if (isFile != 0) {
try {
isFile.close();
isFile = isFile;
} catch (Throwable th) {
th = th;
str3 = "Off";
str4 = "getRequestParams part3";
dr.a(th, str3, str4);
JSONObject jSONObject = new JSONObject();
jSONObject.put("v", BuildConfig.VERSION_NAME);
jSONObject.put("geohash", str2);
jSONObject.put("t", String.valueOf(j));
jSONObject.put("type", a2);
jSONObject.put("imei", dr.b);
jSONObject.put(TBAppLinkPhoneUtil.IMSI, dr.c);
jSONObject.put("src", dr.e);
jSONObject.put("license", dr.f);
strArr[0] = jSONObject.toString();
return true;
}
}
} catch (FileNotFoundException e2) {
e = e2;
dr.a(e, "Off", "getRequestParams part1");
if (isFile != null) {
try {
isFile.close();
} catch (Throwable th2) {
th = th2;
str3 = "Off";
str4 = "getRequestParams part3";
dr.a(th, str3, str4);
JSONObject jSONObject2 = new JSONObject();
jSONObject2.put("v", BuildConfig.VERSION_NAME);
jSONObject2.put("geohash", str2);
jSONObject2.put("t", String.valueOf(j));
jSONObject2.put("type", a2);
jSONObject2.put("imei", dr.b);
jSONObject2.put(TBAppLinkPhoneUtil.IMSI, dr.c);
jSONObject2.put("src", dr.e);
jSONObject2.put("license", dr.f);
strArr[0] = jSONObject2.toString();
return true;
}
}
JSONObject jSONObject22 = new JSONObject();
jSONObject22.put("v", BuildConfig.VERSION_NAME);
jSONObject22.put("geohash", str2);
jSONObject22.put("t", String.valueOf(j));
jSONObject22.put("type", a2);
jSONObject22.put("imei", dr.b);
jSONObject22.put(TBAppLinkPhoneUtil.IMSI, dr.c);
jSONObject22.put("src", dr.e);
jSONObject22.put("license", dr.f);
strArr[0] = jSONObject22.toString();
return true;
} catch (Throwable th3) {
th = th3;
randomAccessFile = isFile;
String str5 = "Off";
dr.a(th, "Off", "getRequestParams part2");
isFile = str5;
if (randomAccessFile != null) {
try {
randomAccessFile.close();
isFile = str5;
} catch (Throwable th4) {
th = th4;
str3 = "Off";
str4 = "getRequestParams part3";
dr.a(th, str3, str4);
JSONObject jSONObject222 = new JSONObject();
jSONObject222.put("v", BuildConfig.VERSION_NAME);
jSONObject222.put("geohash", str2);
jSONObject222.put("t", String.valueOf(j));
jSONObject222.put("type", a2);
jSONObject222.put("imei", dr.b);
jSONObject222.put(TBAppLinkPhoneUtil.IMSI, dr.c);
jSONObject222.put("src", dr.e);
jSONObject222.put("license", dr.f);
strArr[0] = jSONObject222.toString();
return true;
}
}
JSONObject jSONObject2222 = new JSONObject();
jSONObject2222.put("v", BuildConfig.VERSION_NAME);
jSONObject2222.put("geohash", str2);
jSONObject2222.put("t", String.valueOf(j));
jSONObject2222.put("type", a2);
jSONObject2222.put("imei", dr.b);
jSONObject2222.put(TBAppLinkPhoneUtil.IMSI, dr.c);
jSONObject2222.put("src", dr.e);
jSONObject2222.put("license", dr.f);
strArr[0] = jSONObject2222.toString();
return true;
}
} catch (Throwable th5) {
th = th5;
if (randomAccessFile != null) {
try {
randomAccessFile.close();
} catch (Throwable th6) {
dr.a(th6, "Off", "getRequestParams part3");
}
}
throw th;
}
} catch (FileNotFoundException e3) {
e = e3;
isFile = null;
} catch (Throwable th7) {
th = th7;
}
} catch (Throwable th8) {
th = th8;
randomAccessFile = isFile;
}
}
JSONObject jSONObject22222 = new JSONObject();
try {
jSONObject22222.put("v", BuildConfig.VERSION_NAME);
jSONObject22222.put("geohash", str2);
jSONObject22222.put("t", String.valueOf(j));
jSONObject22222.put("type", a2);
jSONObject22222.put("imei", dr.b);
jSONObject22222.put(TBAppLinkPhoneUtil.IMSI, dr.c);
jSONObject22222.put("src", dr.e);
jSONObject22222.put("license", dr.f);
} catch (Throwable th9) {
dr.a(th9, "Off", "getRequestParams part4");
}
strArr[0] = jSONObject22222.toString();
return true;
}
private static String[] a(double d2, double d3, String str) {
String a2;
String[] strArr = new String[50];
if (TextUtils.isEmpty(str)) {
str = bq.a(d2, d3);
a2 = bq.a(d2, d3);
} else {
a2 = str;
}
strArr[0] = str;
strArr[25] = a2;
String[] a3 = bq.a(str);
for (int i = 1; i < 25; i++) {
strArr[i] = a3[i - 1];
}
String[] a4 = bq.a(a2);
for (int i2 = 26; i2 < 50; i2++) {
strArr[i2] = a4[i2 - 26];
}
return strArr;
}
private static int b(String str) {
if (TextUtils.isEmpty(str) || !str.contains("cgi")) {
return 9;
}
String[] split = str.split("#");
if (split.length == 7) {
return 1;
}
return split.length == 8 ? 2 : 9;
}
public static boolean b() {
return !f.isEmpty();
}
private static StringBuilder c() {
StringBuilder sb = new StringBuilder();
sb.append(cm.d());
sb.append("offline").append(File.separator);
sb.append(cm.i()).append(File.separator).append("s").append(File.separator);
return sb;
}
private static void c(String str) {
RandomAccessFile isFile;
RandomAccessFile randomAccessFile;
String str2;
String str3;
if (f.containsKey(str) && !TextUtils.isEmpty(f.get(str))) {
return;
}
File file = new File(str);
if (!file.exists() || (isFile = file.isFile()) == 0) {
return;
}
try {
try {
randomAccessFile = new RandomAccessFile(file, "r");
try {
randomAccessFile.seek(8L);
int readUnsignedShort = randomAccessFile.readUnsignedShort();
StringBuilder sb = new StringBuilder();
for (int i = 0; i < readUnsignedShort; i++) {
int readInt = randomAccessFile.readInt();
if (sb.indexOf(MiPushClient.ACCEPT_TIME_SEPARATOR + readInt) == -1) {
sb.append(MiPushClient.ACCEPT_TIME_SEPARATOR).append(readInt);
}
if (i == readUnsignedShort - 1) {
sb.append(MiPushClient.ACCEPT_TIME_SEPARATOR);
}
}
f.put(str, sb.toString());
sb.delete(0, sb.length());
if (randomAccessFile != null) {
try {
randomAccessFile.close();
} catch (Throwable th) {
th = th;
str2 = "Off";
str3 = "loadFcFea part3";
dr.a(th, str2, str3);
}
}
} catch (FileNotFoundException e2) {
e = e2;
dr.a(e, "Off", "loadFcFea part1");
if (randomAccessFile != null) {
try {
randomAccessFile.close();
} catch (Throwable th2) {
th = th2;
str2 = "Off";
str3 = "loadFcFea part3";
dr.a(th, str2, str3);
}
}
} catch (Throwable th3) {
th = th3;
dr.a(th, "Off", "loadFcFea part2");
if (randomAccessFile != null) {
try {
randomAccessFile.close();
} catch (Throwable th4) {
th = th4;
str2 = "Off";
str3 = "loadFcFea part3";
dr.a(th, str2, str3);
}
}
}
} catch (Throwable th5) {
th = th5;
if (isFile != 0) {
try {
isFile.close();
} catch (Throwable th6) {
dr.a(th6, "Off", "loadFcFea part3");
}
}
throw th;
}
} catch (FileNotFoundException e3) {
e = e3;
randomAccessFile = null;
} catch (Throwable th7) {
th = th7;
isFile = 0;
if (isFile != 0) {
}
throw th;
}
}
public static AmapLoc a(double[] dArr, String str, String str2, String str3, int[] iArr) {
int i;
boolean z;
bx bxVar;
long b2;
double[] a2;
int i2;
double[] a3;
if (TextUtils.isEmpty(str2) || str2.contains("gps")) {
return null;
}
int b3 = b(str2);
String a4 = a(b3, str2);
Hashtable hashtable = new Hashtable();
String[] split = str2.split("#");
switch (b3) {
case 1:
hashtable.put(split[3] + "|" + split[4], "access");
if (!TextUtils.isEmpty(str3)) {
str3.split("#");
break;
}
break;
case 2:
hashtable.put(split[3] + "|" + split[4] + "|" + split[5], "access");
break;
}
Hashtable hashtable2 = new Hashtable();
a(str3, hashtable2);
StringBuilder c2 = c();
String[] a5 = dArr == null ? a(0.0d, 0.0d, str) : a(dArr[0], dArr[1], str);
int i3 = 0;
int i4 = 0;
dr.o = hashtable.size();
int i5 = 0;
while (i5 < 50 && dr.n) {
if ((i5 >= 25 || (i3 <= 0 && !hashtable.isEmpty())) && i5 >= 25 && i4 <= 0) {
hashtable2.isEmpty();
}
if (i5 == 0) {
String sb = c2.toString();
if (i5 < 25) {
switch (b3) {
case 1:
iArr[0] = 0;
iArr[1] = 0;
case 2:
String str4 = sb + a4 + File.separator;
String str5 = a5[i5].startsWith("-") ? str4 + a5[i5].substring(0, 4) + MiPushClient.ACCEPT_TIME_SEPARATOR : str4 + a5[i5].substring(0, 3) + MiPushClient.ACCEPT_TIME_SEPARATOR;
int indexOf = a5[i5].indexOf(MiPushClient.ACCEPT_TIME_SEPARATOR) + 1;
if (a5[i5].substring(indexOf, indexOf + 1).startsWith("-")) {
sb = str5 + a5[i5].substring(indexOf, indexOf + 4);
break;
} else {
sb = str5 + a5[i5].substring(indexOf, indexOf + 3);
break;
}
default:
iArr[0] = 0;
iArr[1] = 0;
break;
}
String str6 = (sb + File.separator) + a5[i5];
if (!str6.equals(c)) {
cd cdVar = e;
bx b4 = cdVar.b(str6);
File file = new File(str6);
if (b4 != null) {
z = true;
bxVar = b4;
} else if (file.getParentFile().exists() && !file.isDirectory() && file.exists()) {
bx.a aVar = new bx.a();
try {
z = false;
bxVar = new bx(file, aVar);
} catch (FileNotFoundException e2) {
dr.a(e2, "Off", "search part1");
i = i3;
} catch (Throwable th) {
dr.a(th, "Off", "search part2");
aVar.f3884a = false;
try {
z = false;
bxVar = new bx(file, aVar);
} catch (Throwable th2) {
dr.a(th2, "Off", "search part3");
z = false;
bxVar = null;
}
}
}
if (bxVar != null) {
try {
bxVar.a(0L);
bxVar.e();
if (bxVar.b) {
b2 = bxVar.c.readLong();
} else {
bxVar.f3883a.read(bxVar.d);
b2 = cm.b(bxVar.d);
}
int b5 = i5 < 25 ? bxVar.b() : 0;
try {
long d2 = bxVar.d();
int i6 = i5 < 25 ? (b5 * 4) + 2 + 8 : 8;
if (7776000000L + b2 < cm.a()) {
if (bxVar != null) {
if (z) {
try {
cdVar.c(str6);
} catch (Throwable th3) {
dr.a(th3, "Off", "search part6");
}
} else {
bxVar.a();
}
}
file.delete();
d.remove(a5[i5]);
i = i3;
} else if (d2 <= 8 || (d2 - i6) % 16 != 0) {
if (bxVar != null) {
try {
bxVar.a();
} catch (Throwable th4) {
dr.a(th4, "Off", "search part7");
}
}
file.delete();
d.remove(a5[i5]);
i = i3;
} else {
boolean z2 = i5 < 25 && !hashtable.isEmpty() && i3 < dr.o;
boolean z3 = i5 >= 25 && !hashtable2.isEmpty() && i4 < 15;
if (z2) {
try {
for (Map.Entry entry : hashtable.entrySet()) {
if (a(i6, bxVar, ((String) entry.getKey()).toString(), 0) != null) {
i3++;
hashtable.put(((String) entry.getKey()).toString(), ((a2[0] + "|" + a2[1]) + "|" + a2[2] + "|") + ((String) hashtable.get(((String) entry.getKey()).toString())));
if (i3 < dr.o) {
}
}
i3 = i3;
}
} catch (Throwable th5) {
th = th5;
dr.a(th, "Off", "search part8");
i = i3;
if (bxVar != null) {
}
i5++;
i3 = i;
}
}
if (z3) {
Iterator it = hashtable2.entrySet().iterator();
i2 = i4;
while (it != null) {
try {
if (it.hasNext()) {
Map.Entry entry2 = (Map.Entry) it.next();
if (a(i6, bxVar, ((String) entry2.getKey()).toString(), 1) != null) {
i2++;
hashtable2.put(((String) entry2.getKey()).toString(), ((a3[0] + "|" + a3[1]) + "|" + a3[2] + "|") + ((String) hashtable2.get(((String) entry2.getKey()).toString())));
if (i2 < 15) {
}
}
i2 = i2;
}
} catch (Throwable th6) {
th = th6;
i4 = i2;
dr.a(th, "Off", "search part8");
i = i3;
if (bxVar != null) {
}
i5++;
i3 = i;
}
}
} else {
i2 = i4;
}
i4 = i2;
i = i3;
if (bxVar != null) {
if (!(bxVar.e == null ? false : bxVar.e.f3884a)) {
try {
bxVar.a();
} catch (Throwable th7) {
dr.a(th7, "Off", "search part9");
}
} else if (!z) {
cdVar.a(str6, bxVar);
}
}
}
} catch (Throwable th8) {
dr.a(th8, "Off", "search part5");
if (z) {
cdVar.c(str6);
}
i = i3;
}
} catch (Throwable th9) {
dr.a(th9, "Off", "search part4");
if (z) {
cdVar.c(str6);
}
i = i3;
}
i5++;
i3 = i;
}
}
}
i = i3;
i5++;
i3 = i;
}
}
c2.delete(0, c2.length());
AmapLoc a6 = a(hashtable, hashtable2, iArr[0], iArr[1]);
if (cm.a(a6)) {
return a6;
}
return null;
}
private static AmapLoc a(Hashtable<String, String> hashtable, Hashtable<String, String> hashtable2, int i, int i2) {
ArrayList arrayList;
ArrayList arrayList2;
double d2;
double d3;
bl blVar = new bl();
try {
if (!hashtable.isEmpty()) {
for (Map.Entry<String, String> entry : hashtable.entrySet()) {
String value = entry.getValue();
boolean z = value.contains("access");
if (value.contains("|")) {
blVar.a(z ? 1 : 2, value.substring(0, value.lastIndexOf("|")));
}
}
}
if (!hashtable2.isEmpty()) {
for (Map.Entry<String, String> entry2 : hashtable2.entrySet()) {
String value2 = entry2.getValue();
if (value2.contains("|")) {
blVar.a(0, value2.substring(0, value2.lastIndexOf("|")));
}
}
}
} catch (Throwable th) {
dr.a(th, "Off", "calLoc part3");
}
double d4 = i2;
double d5 = i;
try {
bl.b bVar = blVar.d;
int size = bl.this.b.size();
for (int i3 = 0; i3 < size; i3++) {
for (int i4 = 0; i4 < size; i4++) {
if (bl.this.c[i3][i4] > 0) {
ArrayList<Integer> arrayList3 = new ArrayList<>();
arrayList3.add(Integer.valueOf(i3));
arrayList3.add(Integer.valueOf(i4));
bl.this.c[i3][i4] = -1;
bl.this.c[i4][i3] = -1;
ArrayList arrayList4 = new ArrayList();
for (int i5 = 0; i5 < bl.this.b.size(); i5++) {
if (bl.this.c[i3][i5] != 0 && bl.this.c[i4][i5] != 0) {
arrayList4.add(Integer.valueOf(i5));
}
}
while (!arrayList4.isEmpty()) {
int intValue = ((Integer) arrayList4.get(0)).intValue();
arrayList4.remove(0);
Iterator<Integer> it = arrayList3.iterator();
while (it.hasNext()) {
Integer next = it.next();
bl.this.c[intValue][next.intValue()] = -1;
bl.this.c[next.intValue()][intValue] = -1;
}
arrayList3.add(Integer.valueOf(intValue));
int i6 = 0;
while (i6 < arrayList4.size()) {
if (bl.this.c[intValue][((Integer) arrayList4.get(i6)).intValue()] == 0) {
arrayList4.remove(i6);
} else {
i6++;
}
}
}
bVar.f3868a.add(arrayList3);
}
}
}
for (int i7 = 0; i7 < size; i7++) {
boolean z2 = true;
int i8 = 0;
while (true) {
if (i8 >= size) {
break;
} else if (bl.this.c[i7][i8] > 0) {
throw new Exception("non visited edge");
} else {
if (bl.this.c[i7][i8] < 0) {
z2 = false;
break;
}
i8++;
}
}
if (z2) {
ArrayList<Integer> arrayList5 = new ArrayList<>();
arrayList5.add(Integer.valueOf(i7));
bVar.f3868a.add(arrayList5);
}
}
ArrayList arrayList6 = new ArrayList();
Iterator<ArrayList<Integer>> it2 = blVar.d.f3868a.iterator();
while (it2.hasNext()) {
bl.a aVar = new bl.a();
Iterator<Integer> it3 = it2.next().iterator();
while (it3.hasNext()) {
bl.c cVar = blVar.b.get(it3.next().intValue());
if (cVar.e == 0) {
aVar.b.add(cVar);
} else if (cVar.e > 0) {
aVar.f3867a.add(cVar);
}
if ("0".equals(aVar.c)) {
aVar.c = cVar.d;
}
}
aVar.a();
blVar.f3866a.add(aVar);
}
if (blVar.f3866a.isEmpty()) {
arrayList2 = null;
} else {
Collections.sort(blVar.f3866a);
if (d4 != 0.0d && d5 != 0.0d) {
bl.c cVar2 = new bl.c(d5, d4);
for (int i9 = 0; i9 < blVar.f3866a.size(); i9++) {
bl.c b2 = blVar.f3866a.get(i9).b();
double a2 = cVar2.a(b2);
if (b2.e > 0) {
if (a2 < 7000.0d && a2 > 2.0d) {
d3 = blVar.f3866a.get(i9).e;
blVar.f3866a.get(i9).e = d3 * 5.0d;
}
} else if (a2 < 10000.0d && a2 > 2.0d) {
d2 = blVar.f3866a.get(i9).e;
blVar.f3866a.get(i9).e = d2 * 5.0d;
}
}
Collections.sort(blVar.f3866a);
}
int i10 = 0;
while (true) {
int i11 = i10;
if (i11 >= blVar.f3866a.size() || arrayList6.size() >= 5) {
break;
}
arrayList6.add(blVar.f3866a.get(i11).b());
i10 = i11 + 1;
}
arrayList2 = arrayList6;
}
arrayList = arrayList2;
} catch (Throwable th2) {
dr.a(th2, "Off", "calLoc part4");
arrayList = null;
}
AmapLoc amapLoc = null;
if (arrayList != null && !arrayList.isEmpty()) {
bl.c cVar3 = (bl.c) arrayList.get(0);
AmapLoc amapLoc2 = new AmapLoc();
amapLoc2.c("network");
amapLoc2.b(cVar3.f3869a);
amapLoc2.a(cVar3.b);
amapLoc2.a(cVar3.c);
amapLoc2.k(cVar3.d);
amapLoc2.x("0");
amapLoc2.a(cm.a());
arrayList.clear();
amapLoc = amapLoc2;
}
if (cm.a(amapLoc)) {
amapLoc.f("file");
return amapLoc;
}
return null;
}
public static boolean a(Context context, String str, String str2, boolean z) {
boolean z2;
if (str.contains("cgi")) {
str.contains("wifi");
if (f3876a[1] > 2000) {
z2 = false;
} else {
NetworkInfo c2 = cm.c(context);
if (cf.a(c2) == -1) {
z2 = false;
} else if (c2.getType() == 1 || !z) {
if (c2.getType() != 1 && !z && g == null) {
g = (TelephonyManager) cm.a(context, "phone");
}
z2 = true;
} else {
z2 = false;
}
}
} else {
z2 = false;
}
if (z2) {
return a(context, str, str2);
}
return false;
}
public static void a() {
e.a(-1);
d.clear();
f.clear();
f3876a[0] = 0;
f3876a[1] = 0;
}
private static double[] a(int i, bx bxVar, String str, int i2) {
String str2;
double[] dArr;
Throwable th;
int[] iArr = null;
if (i2 == 0) {
String[] split = str.split("\\|");
iArr = new int[split.length];
for (int i3 = 0; i3 < split.length; i3++) {
iArr[i3] = Integer.parseInt(split[i3]);
}
str2 = split.length == 2 ? "gsm" : "cdma";
} else {
str2 = "wifi";
}
try {
if (bxVar.d() > i) {
bxVar.a(i);
int d2 = ((int) bxVar.d()) - 16;
int[] iArr2 = iArr;
int i4 = 0;
int i5 = i;
while (true) {
int i6 = i4 + 1;
if (i6 > 25) {
i5 = -1;
break;
}
int i7 = (((((i5 + d2) / 2) - i) / 16) * 16) + i;
int a2 = a(bxVar, str, iArr2, i7, str2);
if (i5 == i7 && i7 == d2) {
if (a2 != 0) {
i5 = -1;
}
} else if (a2 == Integer.MAX_VALUE) {
i5 = -1;
break;
} else if (a2 == 0) {
i5 = i7;
break;
} else if (a2 < 0) {
d2 = i7;
i4 = i6;
} else {
i5 = i7 + 16;
i4 = i6;
}
}
if (i5 != -1) {
bxVar.a(i5 + 6);
dArr = new double[3];
try {
dArr[0] = a(bxVar.c()) / 1000000.0d;
dArr[1] = a(bxVar.c()) / 1000000.0d;
dArr[2] = bxVar.b();
if (cm.a(dArr[1])) {
if (cm.b(dArr[0])) {
return dArr;
}
return null;
}
return null;
} catch (Throwable th2) {
th = th2;
dr.a(th, "Off", "binS");
return dArr;
}
}
}
return null;
} catch (Throwable th3) {
dArr = null;
th = th3;
}
}
private static int a(bx bxVar, String str, int[] iArr, int i, String str2) {
try {
bxVar.a(i);
} catch (Throwable th) {
dr.a(th, "Off", "cmpItem");
}
if (str2.equals("gsm")) {
int i2 = iArr[0];
int i3 = iArr[1];
int b2 = bxVar.b();
int c2 = bxVar.c();
if (i2 < b2) {
return -1;
}
if (i2 > b2) {
return 1;
}
if (i3 >= c2) {
return i3 > c2 ? 1 : 0;
}
return -1;
} else if (str2.equals("cdma")) {
int[] iArr2 = {iArr[0], iArr[1], iArr[2]};
int[] iArr3 = new int[3];
for (int i4 = 0; i4 < 3; i4++) {
iArr3[i4] = bxVar.b();
if (iArr2[i4] < iArr3[i4]) {
return -1;
}
if (iArr2[i4] > iArr3[i4]) {
return 1;
}
}
return 0;
} else {
if (str2.equals("wifi")) {
byte[] b3 = cm.b(str);
int[] iArr4 = new int[6];
for (int i5 = 0; i5 < 6; i5++) {
iArr4[i5] = b3[i5] < 0 ? b3[i5] + 256 : b3[i5];
}
int[] iArr5 = new int[6];
for (int i6 = 0; i6 < 6; i6++) {
bxVar.e();
iArr5[i6] = bxVar.b ? bxVar.c.readUnsignedByte() : bxVar.f3883a.read();
if (iArr4[i6] < iArr5[i6]) {
return -1;
}
if (iArr4[i6] > iArr5[i6]) {
return 1;
}
}
return 0;
}
return Integer.MAX_VALUE;
}
}
public static boolean a(String str, String str2) {
String str3;
if (TextUtils.isEmpty(str2)) {
return false;
}
if (TextUtils.isEmpty(str) || TextUtils.isEmpty(str2)) {
str3 = null;
} else {
StringBuilder c2 = c();
c2.append(a(b(str), str)).append(File.separator);
if (str2.startsWith("-")) {
c2.append(str2.substring(0, 4));
} else {
c2.append(str2.substring(0, 3));
}
c2.append(MiPushClient.ACCEPT_TIME_SEPARATOR);
int indexOf = str2.indexOf(MiPushClient.ACCEPT_TIME_SEPARATOR) + 1;
if (str2.substring(indexOf, indexOf + 1).startsWith("-")) {
c2.append(str2.substring(indexOf, indexOf + 4));
} else {
c2.append(str2.substring(indexOf, indexOf + 3));
}
c2.append(File.separator).append(str2);
str3 = c2.toString();
}
if (str3 != null) {
File file = new File(str3);
if (file.exists() && file.isFile()) {
file.delete();
}
if (f.containsKey(str3)) {
f.remove(str3);
}
if (d.containsKey(str3)) {
d.remove(str3);
}
}
return true;
}
}