MD5 校验值:7186201fca2fa0bef90a85ec705a2523
o4.java 文件包含反编译后的源代码,请注意,该内容仅供学习和参考使用,不得用于非法用途。
package com.onesignal; import android.net.TrafficStats; import android.os.Build; import com.onesignal.a4; import java.io.InputStream; import java.lang.Thread; import java.net.ConnectException; import java.net.HttpURLConnection; import java.net.URL; import java.net.UnknownHostException; import java.util.Scanner; import org.json.JSONObject; public class o4 { public class a implements Runnable { final String f4453e; final JSONObject f4454f; final g f4455g; a(String str, JSONObject jSONObject, g gVar) { this.f4453e = str; this.f4454f = jSONObject; this.f4455g = gVar; } @Override public void run() { o4.h(this.f4453e, "PUT", this.f4454f, this.f4455g, 120000, null); } } public class b implements Runnable { final String f4456e; final JSONObject f4457f; final g f4458g; b(String str, JSONObject jSONObject, g gVar) { this.f4456e = str; this.f4457f = jSONObject; this.f4458g = gVar; } @Override public void run() { o4.h(this.f4456e, "POST", this.f4457f, this.f4458g, 120000, null); } } class c implements Runnable { final String f4459e; final g f4460f; final String f4461g; c(String str, g gVar, String str2) { this.f4459e = str; this.f4460f = gVar; this.f4461g = str2; } @Override public void run() { o4.h(this.f4459e, null, null, this.f4460f, 60000, this.f4461g); } } public class d implements Runnable { final Thread[] f4462e; final String f4463f; final String f4464g; final JSONObject f4465h; final g f4466i; final int f4467j; final String f4468k; d(Thread[] threadArr, String str, String str2, JSONObject jSONObject, g gVar, int i6, String str3) { this.f4462e = threadArr; this.f4463f = str; this.f4464g = str2; this.f4465h = jSONObject; this.f4466i = gVar; this.f4467j = i6; this.f4468k = str3; } @Override public void run() { this.f4462e[0] = o4.n(this.f4463f, this.f4464g, this.f4465h, this.f4466i, this.f4467j, this.f4468k); } } public class e implements Runnable { final g f4469e; final String f4470f; e(g gVar, String str) { this.f4469e = gVar; this.f4470f = str; } @Override public void run() { this.f4469e.b(this.f4470f); } } public class f implements Runnable { final g f4471e; final int f4472f; final String f4473g; final Throwable f4474h; f(g gVar, int i6, String str, Throwable th) { this.f4471e = gVar; this.f4472f = i6; this.f4473g = str; this.f4474h = th; } @Override public void run() { this.f4471e.a(this.f4472f, this.f4473g, this.f4474h); } } public static abstract class g { void a(int i6, String str, Throwable th) { } void b(String str) { } } private static Thread c(g gVar, int i6, String str, Throwable th) { if (gVar == null) { return null; } Thread thread = new Thread(new f(gVar, i6, str, th), "OS_REST_FAILURE_CALLBACK"); thread.start(); return thread; } private static Thread d(g gVar, String str) { if (gVar == null) { return null; } Thread thread = new Thread(new e(gVar, str), "OS_REST_SUCCESS_CALLBACK"); thread.start(); return thread; } public static void e(String str, g gVar, String str2) { new Thread(new c(str, gVar, str2), "OS_REST_ASYNC_GET").start(); } public static void f(String str, g gVar, String str2) { h(str, null, null, gVar, 60000, str2); } private static int g(int i6) { return i6 + 5000; } public static void h(String str, String str2, JSONObject jSONObject, g gVar, int i6, String str3) { if (OSUtils.H()) { throw new o3("Method: " + str2 + " was called from the Main Thread!"); } if (str2 == null || !a4.G2(null)) { Thread[] threadArr = new Thread[1]; Thread thread = new Thread(new d(threadArr, str, str2, jSONObject, gVar, i6, str3), "OS_HTTPConnection"); thread.start(); try { thread.join(g(i6)); if (thread.getState() != Thread.State.TERMINATED) { thread.interrupt(); } Thread thread2 = threadArr[0]; if (thread2 != null) { thread2.join(); } } catch (InterruptedException e6) { e6.printStackTrace(); } } } private static HttpURLConnection i(String str) { return (HttpURLConnection) new URL("https://api.onesignal.com/" + str).openConnection(); } public static void j(String str, JSONObject jSONObject, g gVar) { new Thread(new b(str, jSONObject, gVar), "OS_REST_ASYNC_POST").start(); } public static void k(String str, JSONObject jSONObject, g gVar) { h(str, "POST", jSONObject, gVar, 120000, null); } public static void l(String str, JSONObject jSONObject, g gVar) { new Thread(new a(str, jSONObject, gVar), "OS_REST_ASYNC_PUT").start(); } public static void m(String str, JSONObject jSONObject, g gVar) { h(str, "PUT", jSONObject, gVar, 120000, null); } public static Thread n(String str, String str2, JSONObject jSONObject, g gVar, int i6, String str3) { HttpURLConnection httpURLConnection; Thread c7; String next; String headerField; Throwable th; if (Build.VERSION.SDK_INT >= 26) { TrafficStats.setThreadStatsTag(10000); } int i7 = -1; try { a4.r0 r0Var = a4.r0.DEBUG; a4.a(r0Var, "OneSignalRestClient: Making request to: https://api.onesignal.com/" + str); httpURLConnection = i(str); try { httpURLConnection.setUseCaches(false); httpURLConnection.setConnectTimeout(i6); httpURLConnection.setReadTimeout(i6); httpURLConnection.setRequestProperty("SDK-Version", "onesignal/android/" + a4.H0()); httpURLConnection.setRequestProperty("Accept", "application/vnd.onesignal.v1+json"); if (jSONObject != null) { httpURLConnection.setDoInput(true); } if (str2 != null) { httpURLConnection.setRequestProperty("Content-Type", "application/json; charset=UTF-8"); httpURLConnection.setRequestMethod(str2); httpURLConnection.setDoOutput(true); } if (jSONObject != null) { String g6 = b0.g(jSONObject); a4.a(r0Var, "OneSignalRestClient: " + str2 + " SEND JSON: " + g6); byte[] bytes = g6.getBytes("UTF-8"); httpURLConnection.setFixedLengthStreamingMode(bytes.length); httpURLConnection.getOutputStream().write(bytes); } if (str3 != null) { String f6 = m4.f(m4.f4345a, "PREFS_OS_ETAG_PREFIX_" + str3, null); if (f6 != null) { httpURLConnection.setRequestProperty("if-none-match", f6); a4.a(r0Var, "OneSignalRestClient: Adding header if-none-match: " + f6); } } i7 = httpURLConnection.getResponseCode(); try { a4.a(a4.r0.VERBOSE, "OneSignalRestClient: After con.getResponseCode to: https://api.onesignal.com/" + str); String str4 = "GET"; if (i7 == 200 || i7 == 202) { StringBuilder sb = new StringBuilder(); try { sb.append("OneSignalRestClient: Successfully finished request to: https://api.onesignal.com/"); sb.append(str); a4.a(r0Var, sb.toString()); Scanner scanner = new Scanner(httpURLConnection.getInputStream(), "UTF-8"); next = scanner.useDelimiter("\\A").hasNext() ? scanner.next() : ""; scanner.close(); StringBuilder sb2 = new StringBuilder(); sb2.append("OneSignalRestClient: "); if (str2 != null) { str4 = str2; } sb2.append(str4); sb2.append(" RECEIVED JSON: "); sb2.append(next); a4.a(r0Var, sb2.toString()); if (str3 != null && (headerField = httpURLConnection.getHeaderField("etag")) != null) { a4.a(r0Var, "OneSignalRestClient: Response has etag of " + headerField + " so caching the response."); String str5 = m4.f4345a; m4.m(str5, "PREFS_OS_ETAG_PREFIX_" + str3, headerField); m4.m(str5, "PREFS_OS_HTTP_CACHE_PREFIX_" + str3, next); } c7 = d(gVar, next); } catch (Throwable th2) { th = th2; i7 = i7; try { if (!(th instanceof ConnectException) && !(th instanceof UnknownHostException)) { a4.b(a4.r0.WARN, "OneSignalRestClient: " + str2 + " Error thrown from network stack. ", th); c7 = c(gVar, i7, null, th); } a4.a(a4.r0.INFO, "OneSignalRestClient: Could not send last request, device is offline. Throwable: " + th.getClass().getName()); c7 = c(gVar, i7, null, th); } catch (Throwable th3) { if (httpURLConnection != null) { httpURLConnection.disconnect(); } throw th3; } } } else if (i7 != 304) { a4.a(r0Var, "OneSignalRestClient: Failed request to: https://api.onesignal.com/" + str); InputStream errorStream = httpURLConnection.getErrorStream(); if (errorStream == null) { errorStream = httpURLConnection.getInputStream(); } if (errorStream != null) { Scanner scanner2 = new Scanner(errorStream, "UTF-8"); next = scanner2.useDelimiter("\\A").hasNext() ? scanner2.next() : ""; scanner2.close(); a4.a(a4.r0.WARN, "OneSignalRestClient: " + str2 + " RECEIVED JSON: " + next); th = null; } else { a4.a(a4.r0.WARN, "OneSignalRestClient: " + str2 + " HTTP Code: " + i7 + " No response body!"); th = null; next = null; } c7 = c(gVar, i7, next, th); } else { String f7 = m4.f(m4.f4345a, "PREFS_OS_HTTP_CACHE_PREFIX_" + str3, null); StringBuilder sb3 = new StringBuilder(); sb3.append("OneSignalRestClient: "); if (str2 != null) { str4 = str2; } sb3.append(str4); sb3.append(" - Using Cached response due to 304: "); sb3.append(f7); a4.a(r0Var, sb3.toString()); c7 = d(gVar, f7); } } catch (Throwable th4) { th = th4; } } catch (Throwable th5) { th = th5; } } catch (Throwable th6) { th = th6; httpURLConnection = null; } httpURLConnection.disconnect(); return c7; } }