Warkop v5.73.0版本的 MD5 值为:a4330ec2d6f5e146f59fc7622f3cdb45
以下内容为反编译后的 b.java 源代码,内容仅作参考
package re;
import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.Handler;
import android.os.Looper;
import com.google.firebase.perf.network.FirebasePerfUrlConnection;
import com.inappstory.sdk.network.NetworkHandler;
import java.io.OutputStream;
import java.lang.reflect.Method;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.Date;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.Locale;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.Semaphore;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import javax.net.ssl.HttpsURLConnection;
import org.json.JSONObject;
import re.a;
public class b {
private static b f123233i;
private static final Object f123234j = new Object();
private int f123235a;
private boolean f123236b;
protected String f123237c;
private int f123238d = 0;
private int f123239e = 15000;
private f f123240f = f.COLLECT;
private Context f123241g = null;
private ExecutorService f123242h;
public class a implements Runnable {
final Boolean f123243c;
final Object f123244d;
final String f123245e;
final d f123246f;
final e f123247g;
a(Boolean bool, Object obj, String str, d dVar, e eVar) {
this.f123243c = bool;
this.f123244d = obj;
this.f123245e = str;
this.f123246f = dVar;
this.f123247g = eVar;
}
@Override
public void run() {
if (this.f123243c.booleanValue()) {
b.this.o(this.f123244d, String.format(Locale.US, "(%s) Collector completed successfully.", this.f123245e));
this.f123246f.b(this.f123245e);
} else {
this.f123246f.a(this.f123245e, this.f123247g);
}
}
}
public class RunnableC3398b implements Runnable {
final Object f123249c;
final String f123250d;
final d f123251e;
class a implements Runnable {
final re.a f123253c;
final Hashtable f123254d;
final Hashtable f123255e;
final ArrayList f123256f;
class C3399a implements a.InterfaceC3397a {
final Semaphore f123258a;
C3399a(Semaphore semaphore) {
this.f123258a = semaphore;
}
@Override
public void a(Boolean bool, e eVar, Hashtable<String, String> hashtable, Hashtable<String, String> hashtable2) {
synchronized (b.f123234j) {
try {
for (String str : hashtable.keySet()) {
a.this.f123254d.put(str, hashtable.get(str));
}
for (String str2 : hashtable2.keySet()) {
a.this.f123255e.put(str2, hashtable2.get(str2));
}
if (eVar != null) {
a.this.f123256f.add(eVar);
}
} catch (Throwable th4) {
throw th4;
}
}
this.f123258a.release();
}
}
a(re.a aVar, Hashtable hashtable, Hashtable hashtable2, ArrayList arrayList) {
this.f123253c = aVar;
this.f123254d = hashtable;
this.f123255e = hashtable2;
this.f123256f = arrayList;
}
@Override
public void run() {
Semaphore semaphore = new Semaphore(1);
try {
semaphore.acquire();
} catch (InterruptedException e15) {
e15.printStackTrace();
}
this.f123253c.e(RunnableC3398b.this.f123250d, new C3399a(semaphore));
try {
semaphore.tryAcquire(b.this.f123239e, TimeUnit.MILLISECONDS);
} catch (InterruptedException e16) {
e16.printStackTrace();
}
}
}
RunnableC3398b(Object obj, String str, d dVar) {
this.f123249c = obj;
this.f123250d = str;
this.f123251e = dVar;
}
@Override
public void run() {
Date date = new Date();
b.this.o(this.f123249c, String.format(Locale.US, "(%s) Starting collection", this.f123250d));
String str = b.this.f123237c;
if (str == null || !str.matches("^https?://[\\w-]+(\\.[\\w-]+)+(/[^?]*)?$")) {
b.this.k(this.f123251e, this.f123249c, this.f123250d, Boolean.FALSE, e.INVALID_ENVIRONMENT);
return;
}
if (b.this.f123238d != 2 && b.this.f123238d != 1 && b.this.f123238d != 999999) {
b.this.k(this.f123251e, this.f123249c, this.f123250d, Boolean.FALSE, e.INVALID_ENVIRONMENT);
return;
}
if (b.this.f123235a <= 0 || b.this.f123235a > 999999) {
b.this.k(this.f123251e, this.f123249c, this.f123250d, Boolean.FALSE, e.INVALID_MERCHANT);
return;
}
String str2 = this.f123250d;
if (str2 == null || !str2.matches("^[\\w-]{1,32}$")) {
b.this.k(this.f123251e, this.f123249c, this.f123250d, Boolean.FALSE, e.INVALID_SESSION);
return;
}
b bVar = b.this;
if (bVar.r(bVar.f123241g)) {
b.this.k(this.f123251e, this.f123249c, this.f123250d, Boolean.FALSE, e.NO_NETWORK);
return;
}
Hashtable hashtable = new Hashtable();
Hashtable hashtable2 = new Hashtable();
ArrayList arrayList = new ArrayList();
ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(10, 10, 1000L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue());
ArrayList arrayList2 = new ArrayList();
if (b.this.f123240f == f.COLLECT) {
arrayList2.add(b.this.n(this.f123249c));
} else {
hashtable2.put(re.e.l(), g.SKIPPED.toString());
}
arrayList2.add(new h(this.f123249c, b.this.f123241g));
arrayList2.add(new re.c(this.f123249c, b.this.f123241g));
Iterator it = arrayList2.iterator();
while (it.hasNext()) {
threadPoolExecutor.execute(new a((re.a) it.next(), hashtable, hashtable2, arrayList));
}
threadPoolExecutor.shutdown();
try {
threadPoolExecutor.awaitTermination(b.this.f123239e, TimeUnit.MILLISECONDS);
} catch (InterruptedException e15) {
b.this.o(this.f123249c, String.format(Locale.US, "(%s) Exception encountered waiting for threads: %s", this.f123250d, e15.getMessage()));
}
if (arrayList.size() > 0) {
b.this.k(this.f123251e, this.f123249c, this.f123250d, Boolean.FALSE, (e) arrayList.get(0));
return;
}
long time = new Date().getTime() - date.getTime();
b.this.o(this.f123249c, String.format(Locale.US, "(%s) Collection time: %d ms.", this.f123250d, Long.valueOf(time)));
hashtable.put(re.f.ELAPSED.toString(), Long.toString(time));
hashtable.put(re.f.SDK_TYPE.toString(), "A");
hashtable.put(re.f.SDK_VERSION.toString(), "3.2");
String p15 = b.this.p(hashtable, hashtable2, this.f123250d);
if (p15 == null) {
b.this.k(this.f123251e, this.f123249c, this.f123250d, Boolean.FALSE, e.RUNTIME_FAILURE);
return;
}
try {
String format = String.format("https://%s", new URI(b.this.f123237c).getHost());
b.this.o(this.f123249c, String.format("Collection host is: %s", format));
b.this.s(this.f123249c, this.f123250d, format, p15);
b.this.k(this.f123251e, this.f123249c, this.f123250d, Boolean.TRUE, null);
} catch (URISyntaxException unused) {
b.this.o(this.f123249c, "Error parsing collection host name");
b.this.k(this.f123251e, this.f123249c, this.f123250d, Boolean.FALSE, e.INVALID_ENVIRONMENT);
}
}
}
static class c {
static final int[] f123260a;
static {
int[] iArr = new int[f.values().length];
f123260a = iArr;
try {
iArr[f.COLLECT.ordinal()] = 1;
} catch (NoSuchFieldError unused) {
}
try {
f123260a[f.SKIP.ordinal()] = 2;
} catch (NoSuchFieldError unused2) {
}
}
}
public interface d {
void a(String str, e eVar);
void b(String str);
}
public enum e {
NO_NETWORK(0, "No network"),
INVALID_ENVIRONMENT(1, "Invalid Environment"),
INVALID_MERCHANT(2, "Invalid Merchant ID"),
INVALID_SESSION(3, "Invalid Session ID"),
RUNTIME_FAILURE(4, "Runtime Failure"),
VALIDATION_FAILURE(5, "Validation Failure"),
TIMEOUT(6, "Timeout"),
CONTEXT_NOT_SET(7, "Context Not Set");
private final int f123270c;
private final String f123271d;
e(int i15, String str) {
this.f123270c = i15;
this.f123271d = str;
}
@Override
public String toString() {
return this.f123270c + ": " + this.f123271d;
}
}
public enum f {
COLLECT,
SKIP
}
protected b() {
this.f123242h = null;
this.f123242h = Executors.newSingleThreadExecutor();
}
public void k(d dVar, Object obj, String str, Boolean bool, e eVar) {
if (dVar != null) {
new Handler(Looper.getMainLooper()).post(new a(bool, obj, str, dVar, eVar));
}
}
public void o(Object obj, String str) {
if (this.f123236b) {
String.format("<Data Collector> %s", str);
}
if (obj != null) {
try {
Method declaredMethod = obj.getClass().getDeclaredMethod("collectorDebugMessage", String.class);
declaredMethod.setAccessible(true);
declaredMethod.invoke(obj, str);
} catch (Exception e15) {
String.format("Exception: %s", e15.getMessage());
}
}
}
public String p(Hashtable<String, String> hashtable, Hashtable<String, String> hashtable2, String str) {
StringBuilder sb5 = new StringBuilder();
try {
sb5.append(String.format(Locale.US, "%s=%d&%s=%s", URLEncoder.encode(re.f.MERCHANT_ID.toString(), "UTF-8"), Integer.valueOf(this.f123235a), URLEncoder.encode(re.f.SESSION_ID.toString(), "UTF-8"), URLEncoder.encode(str, "UTF-8")));
for (String str2 : hashtable.keySet()) {
sb5.append(String.format("&%s=%s", URLEncoder.encode(str2, "UTF-8"), URLEncoder.encode(hashtable.get(str2), "UTF-8")));
}
if (hashtable2.size() > 0) {
sb5.append(String.format(Locale.US, "&%s=%s", URLEncoder.encode(re.f.SOFT_ERRORS.toString(), "UTF-8"), URLEncoder.encode(new JSONObject(hashtable2).toString(), "UTF-8")));
}
return sb5.toString();
} catch (Exception unused) {
return null;
}
}
public static b q() {
if (f123233i == null) {
f123233i = new b();
}
return f123233i;
}
public void s(Object obj, String str, String str2, String str3) {
String format;
Locale locale;
URL url;
HttpsURLConnection httpsURLConnection;
if (str2 != null) {
HttpsURLConnection httpsURLConnection2 = null;
try {
try {
locale = Locale.US;
o(obj, String.format(locale, "(%s) Posting data:\n%s", str, str3));
url = new URL(str2 + "/m.html");
httpsURLConnection = (HttpsURLConnection) ((URLConnection) FirebasePerfUrlConnection.instrument(url.openConnection()));
} catch (Exception e15) {
e = e15;
}
} catch (Throwable th4) {
th = th4;
}
try {
httpsURLConnection.setRequestMethod(NetworkHandler.POST);
httpsURLConnection.setDoOutput(true);
OutputStream outputStream = httpsURLConnection.getOutputStream();
outputStream.write(str3.getBytes());
outputStream.flush();
outputStream.close();
if (httpsURLConnection.getResponseCode() == 200) {
o(obj, String.format(locale, "(%s) Sent data to %s.", str, url));
} else {
o(obj, String.format(locale, "(%s) Failed to send data to %s: Response code: %d", str, url, Integer.valueOf(httpsURLConnection.getResponseCode())));
}
try {
httpsURLConnection.disconnect();
return;
} catch (Exception e16) {
format = String.format(Locale.US, "(%s) Exception encountered sending data: %s", str, e16.getMessage());
o(obj, format);
return;
}
} catch (Exception e17) {
e = e17;
httpsURLConnection2 = httpsURLConnection;
o(obj, String.format(Locale.US, "(%s) Exception encountered sending data: %s", str, e.getMessage()));
if (httpsURLConnection2 != null) {
try {
httpsURLConnection2.disconnect();
return;
} catch (Exception e18) {
format = String.format(Locale.US, "(%s) Exception encountered sending data: %s", str, e18.getMessage());
o(obj, format);
return;
}
}
return;
} catch (Throwable th5) {
th = th5;
httpsURLConnection2 = httpsURLConnection;
if (httpsURLConnection2 != null) {
try {
httpsURLConnection2.disconnect();
} catch (Exception e19) {
o(obj, String.format(Locale.US, "(%s) Exception encountered sending data: %s", str, e19.getMessage()));
}
}
throw th;
}
}
o(obj, String.format("(%s) No server URL to send data to, skipping send.", str));
}
public void l(String str, d dVar) {
m(str, dVar, null);
}
protected void m(String str, d dVar, Object obj) {
if (this.f123241g == null) {
k(dVar, obj, str, Boolean.FALSE, e.CONTEXT_NOT_SET);
} else {
o(obj, String.format(Locale.US, "(%s) Adding to queue", str));
this.f123242h.execute(new RunnableC3398b(obj, str, dVar));
}
}
protected re.e n(Object obj) {
return new re.e(obj, this.f123241g);
}
protected boolean r(Context context) {
try {
NetworkInfo activeNetworkInfo = ((ConnectivityManager) context.getSystemService("connectivity")).getActiveNetworkInfo();
if (activeNetworkInfo == null) {
return true;
}
if (!activeNetworkInfo.isConnectedOrConnecting()) {
return true;
}
return false;
} catch (Exception unused) {
return true;
}
}
public void t(Context context) {
this.f123241g = context;
}
public void u(int i15) {
if (i15 != 1) {
if (i15 != 2) {
if (i15 != 999999) {
this.f123238d = 0;
o(null, "Invalid Environment");
this.f123237c = null;
return;
}
o(null, "Setting Environment to QA");
x("https://mqa.kaptcha.com/m.html");
} else {
o(null, "Setting Environment to Production");
x("https://ssl.kaptcha.com/m.html");
}
} else {
o(null, "Setting Environment to Test");
x("https://tst.kaptcha.com/m.html");
}
this.f123238d = i15;
}
public void v(f fVar) {
int i15 = c.f123260a[fVar.ordinal()];
if (i15 != 1) {
if (i15 == 2) {
o(null, "Skipping location collection.");
}
} else {
o(null, "Location collection enabled.");
}
this.f123240f = fVar;
}
public void w(int i15) {
o(null, String.format(Locale.US, "Setting Merchant ID to %d.", Integer.valueOf(i15)));
this.f123235a = i15;
}
protected void x(String str) {
o(null, String.format("Setting Collection URL to %s.", str));
this.f123237c = str;
}
}