package com.applovin.sdk; import android.content.Context; import android.content.pm.PackageManager; import android.content.res.Configuration; import android.content.res.Resources; import android.graphics.Point; import android.net.Uri; import android.os.Build; import android.os.Handler; import android.os.Looper; import android.text.TextUtils; import android.util.TypedValue; import android.widget.ImageView; import androidx.annotation.Dimension; import com.applovin.impl.sdk.utils.CollectionUtils; import com.applovin.impl.sdk.utils.ImageViewUtils; import com.applovin.impl.sdk.utils.JsonUtils; import com.applovin.impl.sdk.utils.StringUtils; import com.applovin.impl.yp; import com.applovin.impl.z3; import java.util.Map; import org.json.JSONException; import org.json.JSONObject; /* loaded from: classes2.dex */ public class AppLovinSdkUtils { private static final Handler a = new Handler(Looper.getMainLooper()); public static final class Size { public static final Size ZERO = new Size(0, 0); private int a; private int b; public Size(int i, int i2) { this.a = i; this.b = i2; } public boolean equals(Object obj) { if (this == obj) { return true; } if (!(obj instanceof Size)) { return false; } Size size = (Size) obj; return this.a == size.getWidth() && this.b == size.getHeight(); } public int getHeight() { return this.b; } public int getWidth() { return this.a; } public int hashCode() { int i = this.b; int i2 = this.a; return i ^ ((i2 >>> 16) | (i2 << 16)); } public String toString() { return this.a + "x" + this.b; } } private static boolean a(String str, String str2) { return StringUtils.startsWithAtLeastOnePrefix(str, CollectionUtils.explode(str2)); } @Dimension(unit = 1) public static int dpToPx(Context context, @Dimension(unit = 0) int i) { return (int) TypedValue.applyDimension(1, i, context.getResources().getDisplayMetrics()); } public static int getOrientation(Context context) { Resources resources; Configuration configuration; if (context == null || (resources = context.getResources()) == null || (configuration = resources.getConfiguration()) == null) { return 0; } return configuration.orientation; } public static boolean isEmulator() { return a(Build.DEVICE, "goldfish,vbox") || a(Build.HARDWARE, "ranchu,generic,vbox") || a(Build.MANUFACTURER, "Genymotion") || a(Build.MODEL, "Android SDK built for x86"); } public static boolean isFireOS(Context context) { return "amazon".equalsIgnoreCase(Build.MANUFACTURER) || isFireTv(context); } public static boolean isFireTv(Context context) { return context.getPackageManager().hasSystemFeature("amazon.hardware.fire_tv"); } public static boolean isSdkVersionGreaterThanOrEqualTo(String str) { return AppLovinSdk.VERSION_CODE >= yp.e(str); } public static boolean isTablet(Context context) { Point b = z3.b(context); return Math.min(b.x, b.y) >= dpToPx(context, 600); } public static boolean isTv(Context context) { if (isFireTv(context)) { return true; } PackageManager packageManager = context.getPackageManager(); return z3.f() ? packageManager.hasSystemFeature("android.software.leanback") : packageManager.hasSystemFeature("android.hardware.type.television"); } public static boolean isValidString(String str) { return !TextUtils.isEmpty(str); } @Dimension(unit = 0) public static int pxToDp(Context context, @Dimension(unit = 1) int i) { return (int) Math.ceil(i / context.getResources().getDisplayMetrics().density); } public static void runOnUiThread(Runnable runnable) { runOnUiThread(false, runnable); } public static void runOnUiThreadDelayed(Runnable runnable, long j) { runOnUiThreadDelayed(runnable, j, a); } public static void setImageUrl(String str, ImageView imageView, AppLovinSdk appLovinSdk) { ImageViewUtils.setImageUri(imageView, Uri.parse(str), appLovinSdk.a()); } public static Map toMap(JSONObject jSONObject) throws JSONException { return JsonUtils.toStringMap(jSONObject); } public static void runOnUiThread(boolean z, Runnable runnable) { if (z || !yp.h()) { a.post(runnable); } else { runnable.run(); } } public static void runOnUiThreadDelayed(Runnable runnable, long j, Handler handler) { if (j > 0) { handler.postDelayed(runnable, j); } else if (yp.h()) { runnable.run(); } else { handler.post(runnable); } } }