package com.onething.xyvod; import android.util.Log; import com.huawei.hms.support.hianalytics.HiAnalyticsConstant; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; import java.net.HttpURLConnection; import java.net.MalformedURLException; import java.net.URL; import java.util.Timer; import java.util.TimerTask; public class XYVodSDK { /* renamed from: a reason: collision with root package name */ public static Timer f20999a = null; /* renamed from: b reason: collision with root package name */ public static boolean f21000b = true; public static int c; public static c d; public static final class a implements Runnable { /* renamed from: a reason: collision with root package name */ public final /* synthetic */ String f21001a; public a(String str) { this.f21001a = str; } public void run() { String[] a2 = XYVodSDK.d.a(this.f21001a); if (a2 != null && a2.length > 0) { StringBuilder sb = new StringBuilder(); for (String str : a2) { sb.append(str); sb.append(HiAnalyticsConstant.REPORT_VAL_SEPARATOR); } sb.delete(sb.length() - 1, sb.length()); try { XYVodSDK.setCDNIP(this.f21001a, sb.toString()); } catch (Throwable unused) { } } } } public static final class b extends TimerTask { public void run() { boolean unused = XYVodSDK.f21000b = XYVodSDK.m(); } } public interface c { String[] a(String str); } public static String a(String str) { try { return getInfoString(str); } catch (Throwable unused) { return ""; } } public static String b() { try { return getVersion(); } catch (Throwable unused) { return ""; } } public static int c(String str, String str2, boolean z, int i) { int i2 = -1; if (!z) { boolean z2 = false; try { cn.b("p2p_so"); z2 = true; } catch (UnsatisfiedLinkError e) { Log.e("XYVodSDK", "Can't load xyvodsdk library: " + e); } catch (SecurityException e2) { Log.e("XYVodSDK", "Encountered a security issue when loading xyvodsdk library: " + e2); } if (!z2) { return -1; } } if (i >= 0) { try { setLogLevel(i); } catch (Throwable unused) { } } if (str2 != null && !str2.isEmpty()) { setLocalPath(str2); } i2 = init(str); if (i2 == 0) { c = n(); q(); } return i2; } public static int d() { try { return networkChanged(-1); } catch (Throwable unused) { return 0; } } public static int e() { f21000b = false; r(); try { return release(); } catch (Throwable unused) { return -1; } } public static int f(String str, int i, long j) { try { return setLongValue(str, i, j); } catch (Throwable unused) { return -1; } } public static String g(String str, int i) { return h(str, i, 0); } private static native String getInfoString(String str); private static native String getVersion(); public static String h(String str, int i, int i2) { if (!f21000b) { return str; } try { String playUrlRewrite = playUrlRewrite(str, i, i2); String str2 = ""; if (str.startsWith("http://")) { str2 = str.substring(7); } else if (str.startsWith("https://")) { str2 = str.substring(8); } if (str2.length() > 0) { int indexOf = str2.indexOf(47); if (indexOf > 0) { str2 = str2.substring(0, indexOf); } p(str2); } return playUrlRewrite; } catch (Throwable unused) { return str; } } private static native int init(String str); private static native int isSDKUrl(String str); private static native int localTestInterval(); /* JADX WARNING: Removed duplicated region for block: B:31:0x0072 */ public static boolean m() { int n; MalformedURLException e; IOException e2; Exception e3; boolean z = true; boolean z2 = false; try { String playUrlRewrite = playUrlRewrite("http://get_sdk_version", 1, 0); String version = getVersion(); if ("http://get_sdk_version".equals(playUrlRewrite)) { return false; } try { HttpURLConnection httpURLConnection = (HttpURLConnection) new URL(playUrlRewrite).openConnection(); httpURLConnection.setRequestMethod("GET"); httpURLConnection.setConnectTimeout(500); httpURLConnection.setReadTimeout(500); if (httpURLConnection.getResponseCode() == 200) { InputStream inputStream = httpURLConnection.getInputStream(); if (httpURLConnection.getContentLength() > 50 || !o(inputStream).equals(version)) { z = false; } try { inputStream.close(); httpURLConnection.disconnect(); z2 = z; } catch (MalformedURLException e4) { e = e4; z2 = z; e.printStackTrace(); n = n(); if (c != n) { } return z2; } catch (IOException e5) { e2 = e5; z2 = z; e2.printStackTrace(); n = n(); if (c != n) { } return z2; } catch (Exception e6) { e3 = e6; z2 = z; e3.printStackTrace(); n = n(); if (c != n) { } return z2; } } } catch (MalformedURLException e7) { e = e7; e.printStackTrace(); n = n(); if (c != n) { } return z2; } catch (IOException e8) { e2 = e8; e2.printStackTrace(); n = n(); if (c != n) { } return z2; } catch (Exception e9) { e3 = e9; e3.printStackTrace(); n = n(); if (c != n) { } return z2; } n = n(); if (c != n) { r(); c = n; q(); } return z2; } catch (Throwable unused) { } } public static int n() { try { return localTestInterval(); } catch (Throwable unused) { return 0; } } private static native int networkChanged(int i); public static String o(InputStream inputStream) throws Exception { ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); byte[] bArr = new byte[1024]; while (true) { int read = inputStream.read(bArr); if (read != -1) { byteArrayOutputStream.write(bArr, 0, read); } else { inputStream.close(); return byteArrayOutputStream.toString(); } } } public static int p(String str) { synchronized (XYVodSDK.class) { if (d == null) { return 0; } d03 d03 = new d03(new a(str), "com.onething.xyvod.XYVodSDK"); d03.d(d03, "com.onething.xyvod.XYVodSDK"); d03.start(); return 0; } } private static native String playUrlRewrite(String str, int i, int i2); private static native String playUrlRewriteBack(String str); public static void q() { if (f20999a != null || c <= 0) { f21000b = true; return; } f03 f03 = new f03("com.onething.xyvod.XYVodSDK"); f20999a = f03; f03.schedule(new b(), 0, (long) c); } public static void r() { Timer timer = f20999a; if (timer != null) { timer.cancel(); f20999a = null; } } private static native int release(); /* access modifiers changed from: private */ public static native int setCDNIP(String str, String str2); private static native int setExperimentID(String str); private static native void setLocalPath(String str); private static native int setLogEnable(int i); private static native void setLogLevel(int i); private static native int setLongValue(String str, int i, long j); private static native int stopTask(String str); }