package com.fyber.inneractive.sdk.util; import android.annotation.SuppressLint; import android.app.Application; import android.content.Context; import android.content.pm.Signature; import android.content.res.Resources; import android.graphics.Point; import android.graphics.drawable.Drawable; import android.provider.Settings; import android.text.TextUtils; import android.util.DisplayMetrics; import android.util.TypedValue; import android.view.Display; import android.view.View; import android.view.WindowManager; import com.fyber.inneractive.sdk.config.IAConfigManager; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.security.MessageDigest; import java.util.HashMap; import java.util.List; /* loaded from: classes2.dex */ public class o { public static Application a; public static class a { public static final HashMap a = new HashMap(); } public static void a() { } public static Application b() { return a; } public static int d() { return ((WindowManager) IAConfigManager.L.u.a().getSystemService("window")).getDefaultDisplay().getRotation(); } public static void h() { } public static void i() { } @SuppressLint({"NewApi"}) public static Drawable c(int i) { return IAConfigManager.L.u.a().getDrawable(i); } public static int e() { Application application = a; int i = (application == null || application.getResources() == null || application.getResources().getConfiguration() == null) ? 1 : application.getResources().getConfiguration().orientation; try { if (Settings.System.getInt(application.getContentResolver(), "accelerometer_rotation", 0) != 1) { i = 1; } } catch (Throwable th) { IAlog.a("failed getOrientation. returning portrait orientation", th, new Object[0]); } Object[] objArr = new Object[1]; objArr[0] = i == 1 ? "portrait" : "landscape"; IAlog.a("The device orientation: %s", objArr); return i; } public static int f() { int i; WindowManager windowManager; Display defaultDisplay; if (a == null || (windowManager = (WindowManager) IAConfigManager.L.u.a().getSystemService("window")) == null || (defaultDisplay = windowManager.getDefaultDisplay()) == null) { i = -1; } else { Point point = new Point(); defaultDisplay.getSize(point); i = point.y; } if (i != -1) { return i; } try { DisplayMetrics displayMetrics = Resources.getSystem().getDisplayMetrics(); if (displayMetrics != null) { i = displayMetrics.heightPixels; } } catch (Throwable unused) { } if (i == -1) { return 480; } return i; } /* JADX WARN: Removed duplicated region for block: B:11:0x002b A[EXC_TOP_SPLITTER, SYNTHETIC] */ /* JADX WARN: Removed duplicated region for block: B:21:? A[RETURN, SYNTHETIC] */ /* Code decompiled incorrectly, please refer to instructions dump. To view partially-correct add '--show-bad-code' argument */ public static int g() { /* r0 = -1 android.app.Application r1 = com.fyber.inneractive.sdk.util.o.a // Catch: java.lang.Throwable -> L28 if (r1 == 0) goto L28 com.fyber.inneractive.sdk.config.IAConfigManager r1 = com.fyber.inneractive.sdk.config.IAConfigManager.L // Catch: java.lang.Throwable -> L28 com.fyber.inneractive.sdk.config.e r1 = r1.u // Catch: java.lang.Throwable -> L28 android.content.Context r1 = r1.a() // Catch: java.lang.Throwable -> L28 java.lang.String r2 = "window" java.lang.Object r1 = r1.getSystemService(r2) // Catch: java.lang.Throwable -> L28 android.view.WindowManager r1 = (android.view.WindowManager) r1 // Catch: java.lang.Throwable -> L28 if (r1 == 0) goto L28 android.view.Display r1 = r1.getDefaultDisplay() // Catch: java.lang.Throwable -> L28 if (r1 == 0) goto L28 android.graphics.Point r2 = new android.graphics.Point // Catch: java.lang.Throwable -> L28 r2.() // Catch: java.lang.Throwable -> L28 r1.getSize(r2) // Catch: java.lang.Throwable -> L28 int r1 = r2.x // Catch: java.lang.Throwable -> L28 goto L29 L28: r1 = r0 L29: if (r1 != r0) goto L3b android.content.res.Resources r2 = android.content.res.Resources.getSystem() // Catch: java.lang.Throwable -> L37 android.util.DisplayMetrics r2 = r2.getDisplayMetrics() // Catch: java.lang.Throwable -> L37 if (r2 == 0) goto L37 int r1 = r2.widthPixels // Catch: java.lang.Throwable -> L37 L37: if (r1 != r0) goto L3b r1 = 320(0x140, float:4.48E-43) L3b: return r1 */ throw new UnsupportedOperationException("Method not decompiled: com.fyber.inneractive.sdk.util.o.g():int"); } public static boolean b(String str) { try { return a.checkCallingOrSelfPermission(str) == 0; } catch (Throwable unused) { return false; } } public static int b(int i) { try { return (int) ((i / c()) + 0.5f); } catch (Exception unused) { return -1; } } public static float c() { return IAConfigManager.L.u.a().getResources().getConfiguration().densityDpi / 160.0f; } public static String c(String str) { String str2 = (String) a.a.get(str); if (TextUtils.isEmpty(str2)) { IAlog.a("Assets cache: reading file: %s", str); try { InputStream open = a.getAssets().open(str, 3); StringBuffer stringBuffer = new StringBuffer(); byte[] bArr = new byte[4096]; for (int i = 0; i != -1; i = open.read(bArr)) { stringBuffer.append(new String(bArr, 0, i)); } open.close(); str2 = stringBuffer.toString(); IAlog.a("Assets cache: success - %s", str); } catch (IOException e) { IAlog.a("Assets cache: Could not read response from file", new Object[0]); IAlog.e(t.a(e), new Object[0]); } if (!TextUtils.isEmpty(str2)) { a.a.put(str, str2); } } else { IAlog.a("Assets cache: returning cached assets for %s", str); } return str2; } public static String a(List list) { return String.join(",", list); } public static void a(Application application, byte[] bArr) { FileOutputStream fileOutputStream; try { fileOutputStream = application.openFileOutput("session_details.json", 0); } catch (Throwable unused) { fileOutputStream = null; } try { fileOutputStream.write(bArr); fileOutputStream.flush(); } catch (Throwable unused2) { try { IAlog.a("writeFileWithContext failed writing %s", "session_details.json"); } finally { t.a(fileOutputStream); } } } public static int a(int i) { return (int) ((c() * i) + 0.5f); } public static boolean a(String str) { try { Class.forName(str); return true; } catch (ClassNotFoundException unused) { return false; } } public static boolean a(String... strArr) { for (String str : strArr) { if (!a(str)) { return false; } } return true; } public static void a(View view, Drawable drawable) { view.setBackground(drawable); } public static int a(float f) { return (int) (TypedValue.applyDimension(1, f, IAConfigManager.L.u.a().getResources().getDisplayMetrics()) + 0.5f); } public static String a(Context context) { if (context == null) { return ""; } try { Signature[] signatureArr = context.getPackageManager().getPackageInfo(context.getPackageName(), 64).signatures; if (signatureArr.length <= 0) { return ""; } Signature signature = signatureArr[0]; MessageDigest messageDigest = MessageDigest.getInstance("SHA-256"); messageDigest.update(signature.toByteArray()); byte[] digest = messageDigest.digest(); StringBuilder sb = new StringBuilder(); for (byte b : digest) { String hexString = Integer.toHexString(b & 255); if (hexString.length() == 1) { sb.append("0"); } sb.append(hexString); } return sb.toString(); } catch (Exception unused) { return ""; } } public static void a(View view, int i, int i2) { if (view == null || view.getLayoutParams() == null) { return; } view.getLayoutParams().width = a(i); view.getLayoutParams().height = a(i2); } }