秦华影视 v1.0.0版本的 MD5 值为:90520322e40df4849cf4989ab6339524
以下内容为反编译后的 ik2.java 源代码,内容仅作参考
package p.a.y.e.a.s.e.net;
import android.app.ActivityManager;
import android.content.Context;
import android.content.pm.PackageInfo;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.Uri;
import android.net.wifi.WifiManager;
import android.os.Process;
import android.text.TextUtils;
import com.xiaomi.push.service.module.PushChannelRegion;
import io.netty.handler.codec.memcache.binary.BinaryMemcacheOpcodes;
import io.netty.handler.codec.rtsp.RtspHeaders;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.UnsupportedEncodingException;
import java.net.URL;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
public class ik2 {
public static Context lite_else;
private static ik2 lite_goto;
private static a lite_long;
private static String lite_this;
private static String lite_void;
private long lite_byte;
private String lite_case;
public Map<String, fk2> lite_do;
public b lite_for;
private hk2 lite_if;
private String lite_int;
private long lite_new;
private final long lite_try;
public static Map<String, ek2> lite_char = new HashMap();
public static boolean lite_break = false;
public interface a {
ik2 lite_do(Context context, hk2 hk2Var, b bVar, String str);
}
public interface b {
String a(String str);
}
public ik2(Context context, hk2 hk2Var, b bVar, String str) {
this(context, hk2Var, bVar, str, null, null);
}
public ik2(Context context, hk2 hk2Var, b bVar, String str, String str2, String str3) {
this.lite_do = new HashMap();
this.lite_int = "0";
this.lite_new = 0L;
this.lite_try = 15L;
this.lite_byte = 0L;
this.lite_case = "isp_prov_city_country_ip";
this.lite_for = bVar;
this.lite_if = hk2Var == null ? new jk2(this) : hk2Var;
this.lite_int = str;
lite_this = str2 == null ? context.getPackageName() : str2;
lite_void = str3 == null ? lite_native() : str3;
}
private ArrayList<ek2> lite_byte(ArrayList<String> arrayList) {
JSONObject jSONObject;
JSONObject jSONObject2;
lite_double();
synchronized (this.lite_do) {
lite_break();
for (String str : this.lite_do.keySet()) {
if (!arrayList.contains(str)) {
arrayList.add(str);
}
}
}
boolean isEmpty = lite_char.isEmpty();
synchronized (lite_char) {
for (Object obj : lite_char.values().toArray()) {
ek2 ek2Var = (ek2) obj;
if (!ek2Var.lite_short()) {
lite_char.remove(ek2Var.lite_int);
isEmpty = true;
}
}
}
if (!arrayList.contains(lite_class())) {
arrayList.add(lite_class());
}
ArrayList<ek2> arrayList2 = new ArrayList<>(arrayList.size());
for (int i = 0; i < arrayList.size(); i++) {
arrayList2.add(null);
}
try {
String str2 = hi2.lite_const(lite_else) ? "wifi" : "wap";
String lite_try = lite_try(arrayList, str2, this.lite_int, isEmpty);
if (!TextUtils.isEmpty(lite_try)) {
JSONObject jSONObject3 = new JSONObject(lite_try);
ud2.lite_long(lite_try);
if ("OK".equalsIgnoreCase(jSONObject3.getString("S"))) {
JSONObject jSONObject4 = jSONObject3.getJSONObject("R");
String string = jSONObject4.getString("province");
String string2 = jSONObject4.getString("city");
String string3 = jSONObject4.getString("isp");
String string4 = jSONObject4.getString("ip");
String string5 = jSONObject4.getString("country");
JSONObject jSONObject5 = jSONObject4.getJSONObject(str2);
ud2.lite_this("get bucket: net=" + string3 + ", hosts=" + jSONObject5.toString());
int i2 = 0;
while (i2 < arrayList.size()) {
String str3 = arrayList.get(i2);
JSONArray optJSONArray = jSONObject5.optJSONArray(str3);
if (optJSONArray == null) {
ud2.lite_char("no bucket found for " + str3);
jSONObject = jSONObject5;
} else {
ek2 ek2Var2 = new ek2(str3);
int i3 = 0;
while (i3 < optJSONArray.length()) {
String string6 = optJSONArray.getString(i3);
if (TextUtils.isEmpty(string6)) {
jSONObject2 = jSONObject5;
} else {
jSONObject2 = jSONObject5;
ek2Var2.lite_char(new nk2(string6, optJSONArray.length() - i3));
}
i3++;
jSONObject5 = jSONObject2;
}
jSONObject = jSONObject5;
arrayList2.set(i2, ek2Var2);
ek2Var2.lite_char = string5;
ek2Var2.lite_new = string;
ek2Var2.lite_byte = string3;
ek2Var2.lite_case = string4;
ek2Var2.lite_try = string2;
if (jSONObject4.has("stat-percent")) {
ek2Var2.lite_byte(jSONObject4.getDouble("stat-percent"));
}
if (jSONObject4.has("stat-domain")) {
ek2Var2.lite_const(jSONObject4.getString("stat-domain"));
}
if (jSONObject4.has(RtspHeaders.Values.TTL)) {
ek2Var2.lite_case(jSONObject4.getInt(RtspHeaders.Values.TTL) * 1000);
}
lite_long(ek2Var2.lite_if());
}
i2++;
jSONObject5 = jSONObject;
}
JSONObject optJSONObject = jSONObject4.optJSONObject("reserved");
if (optJSONObject != null) {
long j = jSONObject4.has("reserved-ttl") ? jSONObject4.getInt("reserved-ttl") * 1000 : 604800000L;
Iterator<String> keys = optJSONObject.keys();
while (keys.hasNext()) {
String next = keys.next();
JSONArray optJSONArray2 = optJSONObject.optJSONArray(next);
if (optJSONArray2 == null) {
ud2.lite_char("no bucket found for " + next);
} else {
ek2 ek2Var3 = new ek2(next);
ek2Var3.lite_case(j);
for (int i4 = 0; i4 < optJSONArray2.length(); i4++) {
String string7 = optJSONArray2.getString(i4);
if (!TextUtils.isEmpty(string7)) {
ek2Var3.lite_char(new nk2(string7, optJSONArray2.length() - i4));
}
}
synchronized (lite_char) {
if (this.lite_if.a(next)) {
lite_char.put(next, ek2Var3);
}
}
}
}
}
}
}
} catch (Exception e) {
StringBuilder b2 = r5.b("failed to get bucket ");
b2.append(e.getMessage());
ud2.lite_char(b2.toString());
}
for (int i5 = 0; i5 < arrayList.size(); i5++) {
ek2 ek2Var4 = arrayList2.get(i5);
if (ek2Var4 != null) {
lite_this(arrayList.get(i5), ek2Var4);
}
}
lite_super();
return arrayList2;
}
public static synchronized void lite_else(Context context, hk2 hk2Var, b bVar, String str, String str2, String str3) {
synchronized (ik2.class) {
Context applicationContext = context.getApplicationContext();
lite_else = applicationContext;
if (applicationContext == null) {
lite_else = context;
}
if (lite_goto == null) {
a aVar = lite_long;
if (aVar == null) {
lite_goto = new ik2(context, hk2Var, bVar, str, str2, str3);
} else {
lite_goto = aVar.lite_do(context, hk2Var, bVar, str);
}
}
}
}
public static synchronized ik2 lite_for() {
ik2 ik2Var;
synchronized (ik2.class) {
ik2Var = lite_goto;
if (ik2Var == null) {
throw new IllegalStateException("the host manager is not initialized yet.");
}
}
return ik2Var;
}
public static synchronized void lite_goto(a aVar) {
synchronized (ik2.class) {
lite_long = aVar;
lite_goto = null;
}
}
public static String lite_int() {
ConnectivityManager connectivityManager;
NetworkInfo activeNetworkInfo;
Context context = lite_else;
if (context == null) {
return "unknown";
}
try {
connectivityManager = (ConnectivityManager) context.getSystemService("connectivity");
} catch (Throwable unused) {
}
if (connectivityManager == null || (activeNetworkInfo = connectivityManager.getActiveNetworkInfo()) == null) {
return "unknown";
}
if (activeNetworkInfo.getType() != 1) {
return activeNetworkInfo.getTypeName() + ue2.lite_final + activeNetworkInfo.getSubtypeName();
}
WifiManager wifiManager = (WifiManager) lite_else.getSystemService("wifi");
if (wifiManager != null && wifiManager.getConnectionInfo() != null) {
return "WIFI-" + wifiManager.getConnectionInfo().getSSID();
}
return "unknown";
}
private String lite_native() {
try {
PackageInfo packageInfo = lite_else.getPackageManager().getPackageInfo(lite_else.getPackageName(), 16384);
return packageInfo != null ? packageInfo.versionName : "0";
} catch (Exception unused) {
return "0";
}
}
public static String lite_new(String str) {
try {
int length = str.length();
byte[] bytes = str.getBytes("UTF-8");
for (int i = 0; i < bytes.length; i++) {
byte b2 = bytes[i];
int i2 = b2 & 240;
if (i2 != 240) {
bytes[i] = (byte) (((b2 & BinaryMemcacheOpcodes.PREPEND) ^ ((byte) (((b2 >> 4) + length) & 15))) | i2);
}
}
return new String(bytes);
} catch (UnsupportedEncodingException unused) {
return str;
}
}
public static void lite_void(String str, String str2) {
ek2 ek2Var = lite_char.get(str);
synchronized (lite_char) {
if (ek2Var == null) {
ek2 ek2Var2 = new ek2(str);
ek2Var2.lite_case(604800000L);
ek2Var2.lite_else(str2);
lite_char.put(str, ek2Var2);
} else {
ek2Var.lite_else(str2);
}
}
}
public boolean lite_break() {
synchronized (this.lite_do) {
if (lite_break) {
return true;
}
lite_break = true;
this.lite_do.clear();
try {
String lite_while = lite_while();
if (!TextUtils.isEmpty(lite_while)) {
lite_final(lite_while);
ud2.lite_long("loading the new hosts succeed");
return true;
}
} catch (Throwable th) {
ud2.lite_char("load bucket failure: " + th.getMessage());
}
return false;
}
}
public JSONObject lite_case() {
JSONObject jSONObject;
synchronized (this.lite_do) {
jSONObject = new JSONObject();
jSONObject.put("ver", 2);
JSONArray jSONArray = new JSONArray();
Iterator<fk2> it = this.lite_do.values().iterator();
while (it.hasNext()) {
jSONArray.put(it.next().lite_new());
}
jSONObject.put("data", jSONArray);
JSONArray jSONArray2 = new JSONArray();
Iterator<ek2> it2 = lite_char.values().iterator();
while (it2.hasNext()) {
jSONArray2.put(it2.next().lite_try());
}
jSONObject.put("reserved", jSONArray2);
}
return jSONObject;
}
public ek2 lite_catch(String str) {
return lite_if(str, true);
}
public void lite_char() {
synchronized (this.lite_do) {
this.lite_do.clear();
}
}
public String lite_class() {
String lite_if = up2.lite_do(lite_else).lite_if();
return (TextUtils.isEmpty(lite_if) || PushChannelRegion.China.name().equals(lite_if)) ? "resolver.msg.xiaomi.net" : "resolver.msg.global.xiaomi.net";
}
public void lite_const() {
ArrayList<String> arrayList;
synchronized (this.lite_do) {
lite_break();
arrayList = new ArrayList<>(this.lite_do.keySet());
for (int size = arrayList.size() - 1; size >= 0; size--) {
fk2 fk2Var = this.lite_do.get(arrayList.get(size));
if (fk2Var != null && fk2Var.lite_do() != null) {
arrayList.remove(size);
}
}
}
ArrayList<ek2> lite_byte = lite_byte(arrayList);
for (int i = 0; i < arrayList.size(); i++) {
if (lite_byte.get(i) != null) {
lite_this(arrayList.get(i), lite_byte.get(i));
}
}
}
public ek2 lite_do(String str) {
if (TextUtils.isEmpty(str)) {
throw new IllegalArgumentException("the url is empty");
}
return lite_if(new URL(str).getHost(), true);
}
public void lite_double() {
String next;
synchronized (this.lite_do) {
Iterator<fk2> it = this.lite_do.values().iterator();
while (it.hasNext()) {
it.next().lite_byte(true);
}
while (true) {
for (boolean z = false; !z; z = true) {
Iterator<String> it2 = this.lite_do.keySet().iterator();
while (it2.hasNext()) {
next = it2.next();
if (this.lite_do.get(next).lite_int().isEmpty()) {
break;
}
}
}
this.lite_do.remove(next);
}
}
}
public void lite_final(String str) {
synchronized (this.lite_do) {
this.lite_do.clear();
JSONObject jSONObject = new JSONObject(str);
if (jSONObject.optInt("ver") != 2) {
throw new JSONException("Bad version");
}
JSONArray optJSONArray = jSONObject.optJSONArray("data");
for (int i = 0; i < optJSONArray.length(); i++) {
fk2 lite_if = new fk2().lite_if(optJSONArray.getJSONObject(i));
this.lite_do.put(lite_if.lite_for(), lite_if);
}
JSONArray optJSONArray2 = jSONObject.optJSONArray("reserved");
for (int i2 = 0; i2 < optJSONArray2.length(); i2++) {
ek2 lite_do = new ek2("").lite_do(optJSONArray2.getJSONObject(i2));
lite_char.put(lite_do.lite_int, lite_do);
}
}
}
public ek2 lite_float(String str) {
fk2 fk2Var;
ek2 lite_do;
synchronized (this.lite_do) {
lite_break();
fk2Var = this.lite_do.get(str);
}
if (fk2Var == null || (lite_do = fk2Var.lite_do()) == null) {
return null;
}
return lite_do;
}
public ek2 lite_if(String str, boolean z) {
ek2 lite_throw;
if (TextUtils.isEmpty(str)) {
throw new IllegalArgumentException("the host is empty");
}
if (!this.lite_if.a(str)) {
return null;
}
ek2 lite_float = lite_float(str);
return (lite_float == null || !lite_float.lite_short()) ? (z && hi2.lite_catch(lite_else) && (lite_throw = lite_throw(str)) != null) ? lite_throw : new kk2(this, str, lite_float) : lite_float;
}
public String lite_import() {
List<ActivityManager.RunningAppProcessInfo> runningAppProcesses = ((ActivityManager) lite_else.getSystemService("activity")).getRunningAppProcesses();
if (runningAppProcesses == null) {
return "com.xiaomi";
}
for (ActivityManager.RunningAppProcessInfo runningAppProcessInfo : runningAppProcesses) {
if (runningAppProcessInfo.pid == Process.myPid()) {
return runningAppProcessInfo.processName;
}
}
return "com.xiaomi";
}
public void lite_long(String str) {
this.lite_case = str;
}
public String lite_short() {
StringBuilder sb = new StringBuilder();
synchronized (this.lite_do) {
for (Map.Entry<String, fk2> entry : this.lite_do.entrySet()) {
sb.append(entry.getKey());
sb.append(":\n");
sb.append(entry.getValue().toString());
sb.append("\n");
}
}
return sb.toString();
}
public void lite_super() {
synchronized (this.lite_do) {
try {
BufferedWriter bufferedWriter = new BufferedWriter(new OutputStreamWriter(lite_else.openFileOutput(lite_import(), 0)));
String jSONObject = lite_case().toString();
if (!TextUtils.isEmpty(jSONObject)) {
bufferedWriter.write(jSONObject);
}
bufferedWriter.close();
} catch (Exception e) {
ud2.lite_char("persist bucket failure: " + e.getMessage());
}
}
}
public void lite_this(String str, ek2 ek2Var) {
if (TextUtils.isEmpty(str) || ek2Var == null) {
throw new IllegalArgumentException("the argument is invalid " + str + ", " + ek2Var);
}
if (this.lite_if.a(str)) {
synchronized (this.lite_do) {
lite_break();
if (this.lite_do.containsKey(str)) {
this.lite_do.get(str).lite_try(ek2Var);
} else {
fk2 fk2Var = new fk2(str);
fk2Var.lite_try(ek2Var);
this.lite_do.put(str, fk2Var);
}
}
}
}
public ek2 lite_throw(String str) {
if (System.currentTimeMillis() - this.lite_byte <= this.lite_new * 60 * 1000) {
return null;
}
this.lite_byte = System.currentTimeMillis();
ArrayList<String> arrayList = new ArrayList<>();
arrayList.add(str);
ek2 ek2Var = lite_byte(arrayList).get(0);
if (ek2Var != null) {
this.lite_new = 0L;
return ek2Var;
}
long j = this.lite_new;
if (j >= 15) {
return null;
}
this.lite_new = j + 1;
return null;
}
public String lite_try(ArrayList<String> arrayList, String str, String str2, boolean z) {
ArrayList<String> arrayList2 = new ArrayList<>();
ArrayList arrayList3 = new ArrayList();
arrayList3.add(new ei2("type", str));
if (str.equals("wap")) {
arrayList3.add(new ei2("conpt", lite_new(hi2.lite_byte(lite_else))));
}
if (z) {
arrayList3.add(new ei2("reserved", "1"));
}
arrayList3.add(new ei2("uuid", str2));
arrayList3.add(new ei2("list", oi2.lite_int(arrayList, ue2.lite_const)));
arrayList3.add(new ei2("countrycode", up2.lite_do(lite_else).lite_try()));
ek2 lite_float = lite_float(lite_class());
String format = String.format(Locale.US, "http://%1$s/gslb/?ver=4.0", lite_class());
if (lite_float == null) {
arrayList2.add(format);
synchronized (lite_char) {
ek2 ek2Var = lite_char.get("resolver.msg.xiaomi.net");
if (ek2Var != null) {
Iterator<String> it = ek2Var.lite_new(true).iterator();
while (it.hasNext()) {
arrayList2.add(String.format(Locale.US, "http://%1$s/gslb/?ver=4.0", it.next()));
}
}
}
} else {
arrayList2 = lite_float.lite_int(format);
}
Iterator<String> it2 = arrayList2.iterator();
IOException e = null;
while (it2.hasNext()) {
Uri.Builder buildUpon = Uri.parse(it2.next()).buildUpon();
Iterator it3 = arrayList3.iterator();
while (it3.hasNext()) {
gi2 gi2Var = (gi2) it3.next();
buildUpon.appendQueryParameter(gi2Var.a(), gi2Var.b());
}
try {
b bVar = this.lite_for;
return bVar == null ? hi2.lite_case(lite_else, new URL(buildUpon.toString())) : bVar.a(buildUpon.toString());
} catch (IOException e2) {
e = e2;
}
}
if (e == null) {
return null;
}
StringBuilder b2 = r5.b("network exception: ");
b2.append(e.getMessage());
ud2.lite_char(b2.toString());
throw e;
}
public String lite_while() {
BufferedReader bufferedReader;
File file;
try {
file = new File(lite_else.getFilesDir(), lite_import());
} catch (Throwable th) {
th = th;
bufferedReader = null;
}
if (!file.isFile()) {
xs2.lite_if(null);
return null;
}
bufferedReader = new BufferedReader(new InputStreamReader(new FileInputStream(file)));
try {
StringBuilder sb = new StringBuilder();
while (true) {
String readLine = bufferedReader.readLine();
if (readLine == null) {
return sb.toString();
}
sb.append(readLine);
}
} catch (Throwable th2) {
th = th2;
try {
ud2.lite_char("load host exception " + th.getMessage());
return null;
} finally {
xs2.lite_if(bufferedReader);
}
}
}
}