Youtube Vanced v版本的 MD5 值为:57364062cc5ff3b801f405013db252a6
以下内容为反编译后的 k4.java 源代码,内容仅作参考
package a.a;
import a.a.t3;
import android.net.TrafficStats;
import android.os.Build;
import java.io.InputStream;
import java.net.ConnectException;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.UnknownHostException;
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.json.JSONObject;
public class k4 implements Runnable {
public final Thread[] f290b;
public final String f291c;
public final String f292d;
public final JSONObject f293e;
public final n4 f294f;
public final int f295g;
public final String h;
public k4(Thread[] threadArr, String str, String str2, JSONObject jSONObject, n4 n4Var, int i, String str3) {
this.f290b = threadArr;
this.f291c = str;
this.f292d = str2;
this.f293e = jSONObject;
this.f294f = n4Var;
this.f295g = i;
this.h = str3;
}
@Override
public void run() {
Thread[] threadArr;
HttpURLConnection httpURLConnection;
int i;
String str;
Thread thread;
HttpURLConnection httpURLConnection2;
int i2;
int i3;
Thread thread2;
String headerField;
Throwable th;
String str2;
String group;
Thread[] threadArr2 = this.f290b;
String str3 = this.f291c;
String str4 = this.f292d;
JSONObject jSONObject = this.f293e;
n4 n4Var = this.f294f;
int i4 = this.f295g;
String str5 = this.h;
t3.v vVar = t3.v.WARN;
t3.v vVar2 = t3.v.DEBUG;
if (Build.VERSION.SDK_INT >= 26) {
TrafficStats.setThreadStatsTag(10000);
}
try {
t3.a(vVar2, "OneSignalRestClient: Making request to: https://api.onesignal.com/" + str3, null);
httpURLConnection2 = (HttpURLConnection) new URL("https://api.onesignal.com/" + str3).openConnection();
try {
httpURLConnection2.setUseCaches(false);
httpURLConnection2.setConnectTimeout(i4);
httpURLConnection2.setReadTimeout(i4);
httpURLConnection2.setRequestProperty("SDK-Version", "onesignal/android/040806");
httpURLConnection2.setRequestProperty("Accept", "application/vnd.onesignal.v1+json");
if (jSONObject != null) {
httpURLConnection2.setDoInput(true);
}
if (str4 != null) {
httpURLConnection2.setRequestProperty("Content-Type", "application/json; charset=UTF-8");
httpURLConnection2.setRequestMethod(str4);
httpURLConnection2.setDoOutput(true);
}
if (jSONObject != null) {
String jSONObject2 = jSONObject.toString();
if (jSONObject.has("external_user_id")) {
Matcher matcher = Pattern.compile("(?<=\"external_user_id\":\").*?(?=\")").matcher(jSONObject2);
if (matcher.find() && (group = matcher.group(0)) != null) {
jSONObject2 = matcher.replaceAll(Matcher.quoteReplacement(group.replace("\\/", "/")));
}
}
t3.a(vVar2, "OneSignalRestClient: " + str4 + " SEND JSON: " + jSONObject2, null);
byte[] bytes = jSONObject2.getBytes("UTF-8");
httpURLConnection2.setFixedLengthStreamingMode(bytes.length);
httpURLConnection2.getOutputStream().write(bytes);
}
if (str5 != null) {
String str6 = e4.f140a;
String f2 = e4.f(str6, "PREFS_OS_ETAG_PREFIX_" + str5, null);
if (f2 != null) {
httpURLConnection2.setRequestProperty("if-none-match", f2);
t3.a(vVar2, "OneSignalRestClient: Adding header if-none-match: " + f2, null);
}
}
i2 = httpURLConnection2.getResponseCode();
try {
t3.v vVar3 = t3.v.VERBOSE;
t3.a(vVar3, "OneSignalRestClient: After con.getResponseCode to: https://api.onesignal.com/" + str3, null);
threadArr = threadArr2;
if (i2 == 200 || i2 == 202) {
try {
StringBuilder sb = new StringBuilder();
i3 = i2;
try {
sb.append("OneSignalRestClient: Successfully finished request to: https://api.onesignal.com/");
sb.append(str3);
t3.a(vVar2, sb.toString(), null);
Scanner scanner = new Scanner(httpURLConnection2.getInputStream(), "UTF-8");
String next = scanner.useDelimiter("\\A").hasNext() ? scanner.next() : "";
scanner.close();
StringBuilder sb2 = new StringBuilder();
sb2.append("OneSignalRestClient: ");
sb2.append(str4 == null ? "GET" : str4);
sb2.append(" RECEIVED JSON: ");
sb2.append(next);
t3.a(vVar2, sb2.toString(), null);
if (str5 != null && (headerField = httpURLConnection2.getHeaderField("etag")) != null) {
t3.a(vVar2, "OneSignalRestClient: Response has etag of " + headerField + " so caching the response.", null);
String str7 = e4.f140a;
e4.h(str7, "PREFS_OS_ETAG_PREFIX_" + str5, headerField);
String str8 = e4.f140a;
e4.h(str8, "PREFS_OS_HTTP_CACHE_PREFIX_" + str5, next);
}
if (n4Var != null) {
thread2 = new Thread(new l4(n4Var, next), "OS_REST_SUCCESS_CALLBACK");
thread2.start();
thread = thread2;
}
thread = null;
} catch (Throwable th2) {
th = th2;
httpURLConnection = httpURLConnection2;
i = i3;
try {
if (!(th instanceof ConnectException)) {
t3.a(vVar, "OneSignalRestClient: " + str4 + " Error thrown from network stack. ", th);
str = 0;
if (n4Var == null) {
}
if (httpURLConnection != null) {
}
threadArr[0] = thread;
}
t3.v vVar4 = t3.v.INFO;
str = 0;
t3.a(vVar4, "OneSignalRestClient: Could not send last request, device is offline. Throwable: " + th.getClass().getName(), null);
if (n4Var == null) {
}
if (httpURLConnection != null) {
}
threadArr[0] = thread;
} catch (Throwable th3) {
if (httpURLConnection != null) {
httpURLConnection.disconnect();
}
throw th3;
}
}
} catch (Throwable th4) {
th = th4;
i3 = i2;
httpURLConnection = httpURLConnection2;
i = i3;
if (!(th instanceof ConnectException)) {
}
t3.v vVar42 = t3.v.INFO;
str = 0;
t3.a(vVar42, "OneSignalRestClient: Could not send last request, device is offline. Throwable: " + th.getClass().getName(), null);
if (n4Var == null) {
}
if (httpURLConnection != null) {
}
threadArr[0] = thread;
}
} else {
try {
if (i2 != 304) {
t3.a(vVar2, "OneSignalRestClient: Failed request to: https://api.onesignal.com/" + str3, null);
InputStream errorStream = httpURLConnection2.getErrorStream();
if (errorStream == null) {
errorStream = httpURLConnection2.getInputStream();
}
if (errorStream != null) {
Scanner scanner2 = new Scanner(errorStream, "UTF-8");
str2 = scanner2.useDelimiter("\\A").hasNext() ? scanner2.next() : "";
scanner2.close();
t3.a(vVar, "OneSignalRestClient: " + str4 + " RECEIVED JSON: " + str2, null);
th = null;
} else {
th = null;
t3.a(vVar, "OneSignalRestClient: " + str4 + " HTTP Code: " + i2 + " No response body!", null);
str2 = null;
}
if (n4Var != null) {
Thread thread3 = new Thread(new m4(n4Var, i2, str2, th), "OS_REST_FAILURE_CALLBACK");
thread3.start();
thread = thread3;
}
} else {
String str9 = e4.f140a;
String f3 = e4.f(str9, "PREFS_OS_HTTP_CACHE_PREFIX_" + str5, null);
StringBuilder sb3 = new StringBuilder();
sb3.append("OneSignalRestClient: ");
sb3.append(str4 == null ? "GET" : str4);
sb3.append(" - Using Cached response due to 304: ");
sb3.append(f3);
t3.a(vVar2, sb3.toString(), null);
if (n4Var != null) {
thread2 = new Thread(new l4(n4Var, f3), "OS_REST_SUCCESS_CALLBACK");
thread2.start();
thread = thread2;
}
}
thread = null;
} catch (Throwable th5) {
th = th5;
httpURLConnection = httpURLConnection2;
i = i2;
if (!(th instanceof ConnectException) && !(th instanceof UnknownHostException)) {
t3.a(vVar, "OneSignalRestClient: " + str4 + " Error thrown from network stack. ", th);
str = 0;
if (n4Var == null) {
thread = str;
} else {
Thread thread4 = new Thread(new m4(n4Var, i, str, th), "OS_REST_FAILURE_CALLBACK");
thread4.start();
thread = thread4;
}
if (httpURLConnection != null) {
httpURLConnection2 = httpURLConnection;
httpURLConnection2.disconnect();
}
threadArr[0] = thread;
}
t3.v vVar422 = t3.v.INFO;
str = 0;
t3.a(vVar422, "OneSignalRestClient: Could not send last request, device is offline. Throwable: " + th.getClass().getName(), null);
if (n4Var == null) {
}
if (httpURLConnection != null) {
}
threadArr[0] = thread;
}
}
} catch (Throwable th6) {
th = th6;
threadArr = threadArr2;
}
} catch (Throwable th7) {
th = th7;
threadArr = threadArr2;
i2 = -1;
}
} catch (Throwable th8) {
th = th8;
threadArr = threadArr2;
httpURLConnection = null;
i = -1;
}
httpURLConnection2.disconnect();
threadArr[0] = thread;
}
}