Wolves Themes v1.0版本的 MD5 值为:cddc92b47f6b7c4a195c9625507eb51c

以下内容为反编译后的 bf.java 源代码,内容仅作参考


package com.appodeal.ads;

import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.app.Activity;
import android.app.ActivityManager;
import android.app.AlertDialog;
import android.content.ActivityNotFoundException;
import android.content.ComponentName;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.content.pm.FeatureInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Point;
import android.graphics.Rect;
import android.graphics.Shader;
import android.graphics.drawable.BitmapDrawable;
import android.location.Criteria;
import android.location.Location;
import android.location.LocationManager;
import android.media.AudioManager;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.Uri;
import android.os.Build;
import android.os.Environment;
import android.os.Handler;
import android.os.Looper;
import android.os.StatFs;
import android.support.v4.internal.view.SupportMenu;
import android.support.v4.media.session.PlaybackStateCompat;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import android.util.Base64;
import android.util.DisplayMetrics;
import android.util.Pair;
import android.view.Display;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.Toast;
import com.applovin.sdk.AppLovinEventTypes;
import com.appodeal.ads.UserSettings;
import com.appodeal.ads.bg;
import com.appodeal.ads.utils.Log;
import com.flurry.android.AdCreative;
import com.google.android.gms.common.GoogleApiAvailability;
import com.google.android.gms.common.GooglePlayServicesUtilLight;
import com.google.android.gms.common.util.CrashUtils;
import com.ironsource.mediationsdk.IronSourceSegment;
import com.ironsource.mediationsdk.utils.IronSourceConstants;
import com.ironsource.mediationsdk.utils.ServerResponseWrapper;
import com.ironsource.sdk.precache.DownloadManager;
import com.mobvista.msdk.base.entity.CampaignEx;
import com.tapjoy.TJAdUnitConstants;
import com.tapjoy.TapjoyConstants;
import com.vungle.warren.model.Advertisement;
import io.presage.ads.NewAd;
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.RandomAccessFile;
import java.io.UnsupportedEncodingException;
import java.lang.reflect.Field;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URL;
import java.net.URLDecoder;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Locale;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.Executor;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import okhttp3.internal.http.StatusLine;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import org.nexage.sourcekit.vast.model.VASTModel;
public class bf {
    private static long a;
    private static SimpleDateFormat b = new SimpleDateFormat("yyyy-MM-dd", Locale.ENGLISH);

    public static class a {
        public final String a;
        public final String b;
        public final boolean c;

        a(String str, String str2, boolean z) {
            this.a = str;
            this.b = str2;
            this.c = z;
        }
    }

    private static float a(Rect rect, Rect rect2) {
        int width = rect.width() * rect.height();
        if (width == 0) {
            return 0.0f;
        }
        return ((width - (Math.max(0, Math.min(rect.right, rect2.right) - Math.max(rect.left, rect2.left)) * Math.max(0, Math.min(rect.bottom, rect2.bottom) - Math.max(rect.top, rect2.top)))) / width) * 100.0f;
    }

    public static ComponentName a(Context context, Intent intent) {
        List<ResolveInfo> queryIntentActivities = context.getPackageManager().queryIntentActivities(intent, 0);
        if (queryIntentActivities.isEmpty()) {
            return null;
        }
        for (ResolveInfo resolveInfo : queryIntentActivities) {
            if (resolveInfo.activityInfo.packageName.equals("com.android.vending")) {
                return new ComponentName(resolveInfo.activityInfo.packageName, resolveInfo.activityInfo.name);
            }
        }
        return new ComponentName(queryIntentActivities.get(0).activityInfo.packageName, queryIntentActivities.get(0).activityInfo.name);
    }

    public static BitmapDrawable a(Context context, String str, boolean z, int i) {
        byte[] decode = Base64.decode(str, 0);
        BitmapDrawable bitmapDrawable = new BitmapDrawable(context.getResources(), BitmapFactory.decodeByteArray(decode, 0, decode.length));
        if (z) {
            bitmapDrawable.setTileModeXY(Shader.TileMode.MIRROR, Shader.TileMode.MIRROR);
        }
        if (i > 0) {
            bitmapDrawable.setAlpha(i);
        }
        return bitmapDrawable;
    }

    public static Object a(Class cls, String str) {
        Field declaredField = cls.getDeclaredField(str);
        declaredField.setAccessible(true);
        if (declaredField.isAccessible()) {
            return declaredField.get(null);
        }
        return null;
    }

    public static Object a(Object obj, String str, boolean z, int i) {
        Class<?> cls;
        if (z) {
            cls = obj.getClass();
            if (i > 0) {
                for (int i2 = 0; i2 < i; i2++) {
                    cls = cls.getSuperclass();
                }
            }
        } else {
            cls = obj.getClass();
        }
        Field declaredField = cls.getDeclaredField(str);
        declaredField.setAccessible(true);
        return declaredField.get(obj);
    }

    public static String a(int i) {
        StringBuilder sb = new StringBuilder();
        if ((i & 1) > 0) {
            sb.append("Interstitial");
        }
        if ((i & 2) > 0) {
            if (sb.length() > 0) {
                sb.append(", ");
            }
            sb.append("Video");
        }
        if ((i & 128) > 0) {
            if (sb.length() > 0) {
                sb.append(", ");
            }
            sb.append("Rewarded video");
        }
        if ((i & 92) > 0) {
            if (sb.length() > 0) {
                sb.append(", ");
            }
            sb.append(IronSourceConstants.BANNER_AD_UNIT);
        }
        if ((i & 256) > 0) {
            if (sb.length() > 0) {
                sb.append(", ");
            }
            sb.append("MREC");
        }
        if ((i & 512) > 0) {
            if (sb.length() > 0) {
                sb.append(", ");
            }
            sb.append("NativeAd");
        }
        return sb.toString();
    }

    public static String a(Context context, String str, String str2) {
        Uri parse = Uri.parse(str2);
        Set<String> queryParameterNames = parse.getQueryParameterNames();
        LinkedHashMap linkedHashMap = new LinkedHashMap();
        for (String str3 : queryParameterNames) {
            linkedHashMap.put(str3, parse.getQueryParameter(str3));
        }
        Uri.Builder clearQuery = Uri.parse(str2).buildUpon().clearQuery();
        if (h.h) {
            linkedHashMap.put("coppa", "1");
        } else {
            Location a2 = az.a(context);
            if (a2 != null) {
                linkedHashMap.put(TJAdUnitConstants.String.LAT, String.valueOf(a2.getLatitude()));
                linkedHashMap.put("lon", String.valueOf(a2.getLongitude()));
                linkedHashMap.put("geo_type", "1");
            }
            UserSettings b2 = az.b(context);
            if (b2 != null) {
                if (b2.getGender() != null) {
                    linkedHashMap.put("gender", a(b2));
                }
                String b3 = b2.b();
                if (b3 != null) {
                    linkedHashMap.put("keywords", b3);
                }
                Integer age = b2.getAge();
                if (age != null) {
                    linkedHashMap.put(IronSourceSegment.AGE, String.valueOf(age));
                }
                UserSettings.Relation a3 = b2.a();
                if (a3 != null) {
                    linkedHashMap.put("relation", String.valueOf(a3.getValue()));
                }
                String userId = b2.getUserId();
                if (userId != null) {
                    linkedHashMap.put("userId", String.valueOf(userId));
                }
            }
            linkedHashMap.put("language", Locale.getDefault().getLanguage());
            linkedHashMap.put("connectiontype", String.valueOf(w(context)));
            String c = c(context);
            if (c != null) {
                linkedHashMap.put("carrier", c);
            }
        }
        if (!az.c()) {
            if (Native.a) {
                linkedHashMap.put("native_ad_type", Native.v.toString());
            }
            linkedHashMap.put("device_ext", x(context).toString());
            linkedHashMap.put("app_ext", y(context).toString());
            DisplayMetrics displayMetrics = context.getResources().getDisplayMetrics();
            linkedHashMap.put("ppi", String.valueOf(displayMetrics.densityDpi));
            linkedHashMap.put("pxratio", String.valueOf(displayMetrics.density));
            if (h.i) {
                linkedHashMap.put("corona", "1");
                linkedHashMap.put("store_url", h.b);
                linkedHashMap.put("bundle_id", context.getPackageName());
                linkedHashMap.put("app_name", h.a);
            }
        }
        linkedHashMap.put("impid", str);
        linkedHashMap.put("metadata_headers", "1");
        for (String str4 : linkedHashMap.keySet()) {
            clearQuery.appendQueryParameter(str4, (String) linkedHashMap.get(str4));
        }
        return clearQuery.build().toString();
    }

    public static String a(Context context, JSONArray jSONArray, Runnable runnable) {
        if (jSONArray != null) {
            try {
                if (jSONArray.length() != 0) {
                    String str = "";
                    boolean z = false;
                    for (int i = 0; i < jSONArray.length() && !z; i++) {
                        str = jSONArray.getString(i);
                        z = a(context, str, runnable);
                    }
                    return str;
                }
            } catch (Exception e) {
                Appodeal.a(e);
                a(runnable);
                return "";
            }
        }
        a(runnable);
        return "";
    }

    public static String a(UserSettings userSettings) {
        UserSettings.Gender gender = userSettings.getGender();
        if (gender != null) {
            switch (gender) {
                case MALE:
                    return "M";
                case FEMALE:
                    return "F";
                case OTHER:
                    return "O";
                default:
                    return null;
            }
        }
        return null;
    }

    public static String a(InputStream inputStream) {
        BufferedReader bufferedReader;
        BufferedReader bufferedReader2 = null;
        try {
            try {
                StringBuilder sb = new StringBuilder(inputStream.available());
                bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
                while (true) {
                    try {
                        String readLine = bufferedReader.readLine();
                        if (readLine == null) {
                            break;
                        }
                        sb.append(readLine);
                        sb.append('\n');
                    } catch (Exception e) {
                        e = e;
                        Appodeal.a(e);
                        if (bufferedReader != null) {
                            try {
                                bufferedReader.close();
                                return null;
                            } catch (Exception e2) {
                                Appodeal.a(e2);
                                return null;
                            }
                        }
                        return null;
                    }
                }
                if (sb.length() > 0) {
                    sb.setLength(sb.length() - 1);
                }
                String sb2 = sb.toString();
                if (bufferedReader != null) {
                    try {
                        bufferedReader.close();
                        return sb2;
                    } catch (Exception e3) {
                        Appodeal.a(e3);
                    }
                }
                return sb2;
            } catch (Throwable th) {
                th = th;
                if (0 != 0) {
                    try {
                        bufferedReader2.close();
                    } catch (Exception e4) {
                        Appodeal.a(e4);
                    }
                }
                throw th;
            }
        } catch (Exception e5) {
            e = e5;
            bufferedReader = null;
        } catch (Throwable th2) {
            th = th2;
            if (0 != 0) {
            }
            throw th;
        }
    }

    public static void a(Activity activity) {
        h.h = activity.getSharedPreferences("appodeal", 0).getBoolean("for_kids", h.h);
    }

    public static void a(Activity activity, int i) {
        Intent intent = new Intent(activity, InterstitialActivity.class);
        intent.addFlags(CrashUtils.ErrorDialogData.BINDER_CRASH);
        intent.addFlags(8388608);
        intent.putExtra("requestId", i);
        try {
            activity.startActivity(intent);
        } catch (ActivityNotFoundException unused) {
            Appodeal.a("InterstitialActivity not found - did you declare it in AndroidManifest.xml?");
            t.a().a(true);
        }
    }

    public static void a(Activity activity, String str) {
        SharedPreferences.Editor edit = activity.getSharedPreferences("appodeal", 0).edit();
        edit.putString(ServerResponseWrapper.APP_KEY_FIELD, str);
        edit.apply();
    }

    public static void a(final Context context, final String str) {
        if (k.a(context)) {
            a(new Runnable() {
                @Override
                public void run() {
                    Toast.makeText(context, str, 1).show();
                }
            });
        }
    }

    public static void a(File file) {
        if (file.isDirectory()) {
            for (File file2 : file.listFiles()) {
                a(file2);
            }
        }
        file.delete();
    }

    public static void a(OutputStream outputStream, String str) {
        BufferedOutputStream bufferedOutputStream;
        BufferedOutputStream bufferedOutputStream2 = null;
        try {
            try {
                try {
                    bufferedOutputStream = new BufferedOutputStream(outputStream);
                } catch (Exception e) {
                    e = e;
                }
            } catch (Throwable th) {
                th = th;
                bufferedOutputStream = bufferedOutputStream2;
            }
            try {
                bufferedOutputStream.write(str.getBytes("UTF-8"));
                bufferedOutputStream.flush();
                if (bufferedOutputStream != null) {
                    bufferedOutputStream.close();
                }
            } catch (Exception e2) {
                e = e2;
                bufferedOutputStream2 = bufferedOutputStream;
                Appodeal.a(e);
                if (bufferedOutputStream2 != null) {
                    bufferedOutputStream2.close();
                }
            } catch (Throwable th2) {
                th = th2;
                if (bufferedOutputStream != null) {
                    try {
                        bufferedOutputStream.close();
                    } catch (Exception e3) {
                        Appodeal.a(e3);
                    }
                }
                throw th;
            }
        } catch (Exception e4) {
            Appodeal.a(e4);
        }
    }

    public static void a(Runnable runnable) {
        new Handler(Looper.getMainLooper()).post(runnable);
    }

    public static void a(Runnable runnable, long j) {
        new Handler(Looper.getMainLooper()).postDelayed(runnable, j);
    }

    public static void a(String str, b bVar, JSONObject jSONObject) {
        a(str, bVar.c(), bVar.b(), jSONObject);
    }

    static void a(String str, List<JSONObject> list, List<JSONObject> list2, JSONObject jSONObject) {
        Iterator<JSONObject> it;
        String format;
        Locale locale;
        String str2;
        Object[] objArr;
        if (Appodeal.getLogLevel() == Log.LogLevel.none) {
            return;
        }
        StringBuilder sb = new StringBuilder();
        sb.append(String.format("%s waterfall:", c(str)));
        if (list != null && !list.isEmpty()) {
            sb.append("\n  Precache:\n    ");
            for (JSONObject jSONObject2 : list) {
                if (jSONObject2.has("name")) {
                    locale = Locale.ENGLISH;
                    str2 = "%s (%s), eCPM: %.2f; ";
                    objArr = new Object[]{c(jSONObject2.optString("name")), c(jSONObject2.optString("status")), Double.valueOf(jSONObject2.optDouble("ecpm", 0.0d))};
                } else {
                    locale = Locale.ENGLISH;
                    str2 = "%s, eCPM: %.2f; ";
                    objArr = new Object[]{c(jSONObject2.optString("status")), Double.valueOf(jSONObject2.optDouble("ecpm", 0.0d))};
                }
                sb.append(String.format(locale, str2, objArr));
            }
        }
        int i = 100;
        if (list2 == null || list2.isEmpty()) {
            sb.append("\n  Ads: Empty");
        } else {
            sb.append("\n  Ads:");
            Iterator<JSONObject> it2 = list2.iterator();
            int i2 = 100;
            while (it2.hasNext()) {
                JSONObject next = it2.next();
                if (i2 >= i) {
                    sb.append("\n    ");
                    i2 = 0;
                }
                if (next.has("name")) {
                    it = it2;
                    format = String.format(Locale.ENGLISH, "%s (%s), eCPM: %.2f; ", c(next.optString("name")), c(next.optString("status")), Double.valueOf(next.optDouble("ecpm", 0.0d)));
                } else {
                    it = it2;
                    format = String.format(Locale.ENGLISH, "%s, eCPM: %.2f; ", c(next.optString("status")), Double.valueOf(next.optDouble("ecpm", 0.0d)));
                }
                sb.append(format);
                i2 += format.length();
                it2 = it;
                i = 100;
            }
        }
        if (jSONObject != null) {
            try {
                JSONArray jSONArray = jSONObject.getJSONArray("bidders");
                if (jSONArray != null && jSONArray.length() > 0) {
                    sb.append("\n  OpenRTB bidders:");
                    int i3 = 100;
                    for (int i4 = 0; i4 < jSONArray.length(); i4++) {
                        if (i3 >= 100) {
                            sb.append("\n    ");
                            i3 = 0;
                        }
                        String format2 = String.format("%s; ", jSONArray.getJSONObject(i4).getString("title"));
                        sb.append(format2);
                        i3 += format2.length();
                    }
                }
            } catch (JSONException unused) {
            }
        }
        Appodeal.a(sb.toString());
    }

    public static void a(final String str, Executor executor) {
        if (TextUtils.isEmpty(str) || executor == null) {
            return;
        }
        executor.execute(new Runnable() {
            @Override
            public void run() {
                HttpURLConnection httpURLConnection;
                Exception e;
                HttpURLConnection httpURLConnection2 = null;
                try {
                } catch (Throwable th) {
                    th = th;
                }
                try {
                    try {
                        httpURLConnection = (HttpURLConnection) new URL(str).openConnection();
                        try {
                            httpURLConnection.setConnectTimeout(DownloadManager.OPERATION_TIMEOUT);
                            httpURLConnection.setInstanceFollowRedirects(true);
                            httpURLConnection.setRequestProperty("Connection", "close");
                            httpURLConnection.setRequestMethod("GET");
                            httpURLConnection.getResponseCode();
                            if (httpURLConnection != null) {
                                httpURLConnection.getInputStream().close();
                                httpURLConnection.disconnect();
                            }
                        } catch (Exception e2) {
                            e = e2;
                            Appodeal.a(e);
                            if (httpURLConnection != null) {
                                httpURLConnection.getInputStream().close();
                                httpURLConnection.disconnect();
                            }
                        }
                    } catch (Exception e3) {
                        Appodeal.a(e3);
                    }
                } catch (Exception e4) {
                    httpURLConnection = null;
                    e = e4;
                } catch (Throwable th2) {
                    th = th2;
                    if (0 != 0) {
                        try {
                            httpURLConnection2.getInputStream().close();
                            httpURLConnection2.disconnect();
                        } catch (Exception e5) {
                            Appodeal.a(e5);
                        }
                    }
                    throw th;
                }
            }
        });
    }

    public static void a(final String str, Executor executor, final Runnable runnable) {
        if (TextUtils.isEmpty(str) || executor == null) {
            return;
        }
        executor.execute(new Runnable() {
            @Override
            public void run() {
                Throwable th;
                HttpURLConnection httpURLConnection;
                Exception e;
                HttpURLConnection httpURLConnection2 = null;
                try {
                    try {
                        try {
                            httpURLConnection = (HttpURLConnection) new URL(str).openConnection();
                            try {
                                httpURLConnection.setConnectTimeout(DownloadManager.OPERATION_TIMEOUT);
                                httpURLConnection.setInstanceFollowRedirects(true);
                                httpURLConnection.setRequestProperty("Connection", "close");
                                httpURLConnection.setRequestMethod("GET");
                                if ((httpURLConnection.getResponseCode() >= 300 || httpURLConnection.getResponseCode() < 200) && runnable != null) {
                                    runnable.run();
                                }
                                if (httpURLConnection != null) {
                                    httpURLConnection.getInputStream().close();
                                    httpURLConnection.disconnect();
                                }
                            } catch (Exception e2) {
                                e = e2;
                                if (runnable != null) {
                                    runnable.run();
                                }
                                Appodeal.a(e);
                                if (httpURLConnection != null) {
                                    httpURLConnection.getInputStream().close();
                                    httpURLConnection.disconnect();
                                }
                            }
                        } catch (Throwable th2) {
                            th = th2;
                            if (0 != 0) {
                                try {
                                    httpURLConnection2.getInputStream().close();
                                    httpURLConnection2.disconnect();
                                } catch (Exception e3) {
                                    Appodeal.a(e3);
                                }
                            }
                            throw th;
                        }
                    } catch (Exception e4) {
                        httpURLConnection = null;
                        e = e4;
                    } catch (Throwable th3) {
                        th = th3;
                        if (0 != 0) {
                        }
                        throw th;
                    }
                } catch (Exception e5) {
                    Appodeal.a(e5);
                }
            }
        });
    }

    public static boolean a() {
        try {
            for (String str : new String[]{"/sbin/su", "/system/bin/su", "/system/xbin/su", "/data/local/xbin/su", "/data/local/bin/su", "/system/sd/xbin/su", "/system/bin/failsafe/su", "/data/local/su"}) {
                if (new File(str).exists()) {
                    return true;
                }
            }
        } catch (Exception e) {
            Appodeal.a(e);
        }
        return false;
    }

    public static boolean a(Activity activity, View view) {
        Rect rect;
        ViewGroup viewGroup;
        boolean globalVisibleRect;
        boolean isShown;
        boolean z;
        try {
            rect = new Rect();
            viewGroup = view;
            globalVisibleRect = viewGroup.getGlobalVisibleRect(rect);
            isShown = view.isShown();
        } catch (Exception e) {
            Appodeal.a(e);
        }
        if (k.n && !view.hasWindowFocus()) {
            z = false;
            if (!globalVisibleRect && isShown && z && !a(view)) {
                Appodeal.a("Ad View is out of screen, show wasn't tracked", Log.LogLevel.verbose);
                return false;
            }
            float width = view.getWidth() * view.getHeight();
            if (width == 0.0f) {
                Appodeal.a("Ad View width or height is zero, show wasn't tracked", Log.LogLevel.verbose);
                return false;
            } else if (((rect.width() * rect.height()) / width) * 100.0f < 80.0f) {
                Appodeal.a("Ad View is not completely visible, show wasn't tracked", Log.LogLevel.verbose);
                return false;
            } else {
                View findViewById = activity.findViewById(16908290);
                Rect rect2 = new Rect();
                findViewById.getGlobalVisibleRect(rect2);
                if (k.n && !Rect.intersects(rect, rect2)) {
                    Appodeal.a("Ad View is out of current window, show wasn't tracked", Log.LogLevel.verbose);
                    return false;
                }
                ViewGroup viewGroup2 = (ViewGroup) view.getRootView();
                ViewGroup viewGroup3 = (ViewGroup) view.getParent();
                int i = 0;
                while (viewGroup3 != null) {
                    for (int indexOfChild = viewGroup3.indexOfChild(viewGroup) + 1; indexOfChild < viewGroup3.getChildCount(); indexOfChild++) {
                        View childAt = viewGroup3.getChildAt(indexOfChild);
                        if (childAt.getVisibility() == 0 && !(childAt instanceof com.appodeal.ads.utils.b.c)) {
                            childAt.getLocationInWindow(new int[2]);
                            Rect c = c(childAt);
                            if (Rect.intersects(rect, c)) {
                                float a2 = a(rect, c);
                                String valueOf = String.valueOf(childAt.getId());
                                try {
                                    valueOf = viewGroup.getContext().getResources().getResourceEntryName(childAt.getId());
                                } catch (Exception unused) {
                                }
                                Appodeal.a(String.format("Ad view is overlapped by another visible view (type: %s, id: %s), visible percent: %s", childAt.getClass().getSimpleName(), valueOf, Float.valueOf(a2)), Log.LogLevel.verbose);
                                if (a2 < 80.0f) {
                                    Appodeal.a("Ad View is covered by another view, show wasn't tracked", Log.LogLevel.verbose);
                                    return false;
                                }
                                i++;
                                if (i >= 3) {
                                    Appodeal.a("Ad View is covered by too many views, show wasn't tracked", Log.LogLevel.verbose);
                                    return false;
                                }
                            } else {
                                continue;
                            }
                        }
                    }
                    if (viewGroup3 != viewGroup2) {
                        ViewGroup viewGroup4 = viewGroup3;
                        viewGroup3 = (ViewGroup) viewGroup3.getParent();
                        viewGroup = viewGroup4;
                    } else {
                        viewGroup3 = null;
                    }
                }
                return true;
            }
        }
        z = true;
        if (!globalVisibleRect && isShown && z && !a(view)) {
        }
    }

    public static boolean a(Context context) {
        NetworkInfo activeNetworkInfo = ((ConnectivityManager) context.getSystemService("connectivity")).getActiveNetworkInfo();
        boolean z = activeNetworkInfo != null && activeNetworkInfo.isConnected();
        if (!z) {
            Appodeal.a("No Internet");
        }
        return z;
    }

    public static boolean a(final Context context, String str, final Runnable runnable) {
        final String d = d(str);
        if (h.l && a(d)) {
            com.appodeal.ads.utils.t.a.execute(new Runnable() {
                @Override
                public void run() {
                    bf.e(context, bf.b(d));
                    if (runnable != null) {
                        bf.a(runnable);
                    }
                }
            });
            return true;
        }
        if (runnable != null) {
            a(runnable);
        }
        return e(context, d);
    }

    public static boolean a(Rect rect, View view) {
        return rect.contains(c(view));
    }

    public static boolean a(View view) {
        return view.getAlpha() == 0.0f;
    }

    public static boolean a(String str) {
        return str.startsWith("http://") || str.startsWith("https://");
    }

    public static boolean a(String... strArr) {
        int length = strArr.length;
        int length2 = strArr.length;
        int i = length;
        for (int i2 = 0; i2 < length2; i2++) {
            if (b(strArr[i2])) {
                i--;
            }
        }
        return i > 0 && strArr.length != i;
    }

    public static Pair<String, Integer> b(InputStream inputStream) {
        BufferedReader bufferedReader;
        StringBuilder sb = new StringBuilder();
        BufferedReader bufferedReader2 = null;
        try {
            try {
                long currentTimeMillis = System.currentTimeMillis();
                bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
                int i = 0;
                while (true) {
                    try {
                        String readLine = bufferedReader.readLine();
                        if (readLine == null) {
                            break;
                        }
                        sb.append(readLine);
                        i += readLine.getBytes().length;
                    } catch (Exception e) {
                        e = e;
                        Appodeal.a(e);
                        if (bufferedReader != null) {
                            try {
                                bufferedReader.close();
                                return null;
                            } catch (Exception e2) {
                                Appodeal.a(e2);
                                return null;
                            }
                        }
                        return null;
                    }
                }
                long currentTimeMillis2 = System.currentTimeMillis();
                if (currentTimeMillis2 == currentTimeMillis) {
                    currentTimeMillis2 = currentTimeMillis + 1;
                }
                Pair<String, Integer> pair = new Pair<>(sb.toString(), Integer.valueOf(Math.round((float) (i / (currentTimeMillis2 - currentTimeMillis)))));
                if (bufferedReader != null) {
                    try {
                        bufferedReader.close();
                        return pair;
                    } catch (Exception e3) {
                        Appodeal.a(e3);
                    }
                }
                return pair;
            } catch (Throwable th) {
                th = th;
                if (0 != 0) {
                    try {
                        bufferedReader2.close();
                    } catch (Exception e4) {
                        Appodeal.a(e4);
                    }
                }
                throw th;
            }
        } catch (Exception e5) {
            e = e5;
            bufferedReader = null;
        } catch (Throwable th2) {
            th = th2;
            if (0 != 0) {
            }
            throw th;
        }
    }

    public static a b(Context context) {
        String str;
        String str2;
        NetworkInfo activeNetworkInfo = ((ConnectivityManager) context.getSystemService("connectivity")).getActiveNetworkInfo();
        String str3 = "unknown";
        boolean z = false;
        if (activeNetworkInfo != null && activeNetworkInfo.isConnected()) {
            str3 = activeNetworkInfo.getTypeName();
            str = activeNetworkInfo.getSubtypeName();
            switch (activeNetworkInfo.getType()) {
                case 0:
                    switch (activeNetworkInfo.getSubtype()) {
                    }
                case 1:
                case 6:
                case 9:
                    z = true;
                    break;
            }
        } else {
            str = null;
        }
        if (str3 != null) {
            if (str3.equals("CELLULAR")) {
                str3 = "MOBILE";
            }
            str3 = str3.toLowerCase(Locale.ENGLISH);
        }
        if (str != null) {
            str2 = str.toLowerCase(Locale.ENGLISH);
            if (str2.isEmpty()) {
                str2 = null;
            }
        } else {
            str2 = str;
        }
        return new a(str3, str2, z);
    }

    @TargetApi(21)
    public static String b() {
        return Build.VERSION.SDK_INT < 21 ? Build.CPU_ABI : Build.SUPPORTED_ABIS[0];
    }

    static String b(String str) {
        HttpURLConnection httpURLConnection;
        Exception e;
        HttpURLConnection httpURLConnection2 = null;
        try {
            try {
                URL url = new URL(str);
                httpURLConnection = (HttpURLConnection) url.openConnection();
                try {
                    httpURLConnection.setInstanceFollowRedirects(false);
                    httpURLConnection.setConnectTimeout(TJAdUnitConstants.DEFAULT_VOLUME_CHECK_INTERVAL);
                    httpURLConnection.setReadTimeout(TJAdUnitConstants.DEFAULT_VOLUME_CHECK_INTERVAL);
                    switch (httpURLConnection.getResponseCode()) {
                        case VASTModel.ERROR_CODE_BAD_URI:
                        case 302:
                        case 303:
                        case IronSourceConstants.OFFERWALL_OPENED:
                        case StatusLine.HTTP_TEMP_REDIRECT:
                            String headerField = httpURLConnection.getHeaderField("Location");
                            if (headerField == null) {
                                String url2 = url.toString();
                                if (httpURLConnection != null) {
                                    try {
                                        httpURLConnection.getInputStream().close();
                                        httpURLConnection.disconnect();
                                        return url2;
                                    } catch (Exception e2) {
                                        Appodeal.a(e2);
                                    }
                                }
                                return url2;
                            } else if (a(headerField)) {
                                String b2 = b(httpURLConnection.getHeaderField("Location"));
                                if (httpURLConnection != null) {
                                    try {
                                        httpURLConnection.getInputStream().close();
                                        httpURLConnection.disconnect();
                                        return b2;
                                    } catch (Exception e3) {
                                        Appodeal.a(e3);
                                    }
                                }
                                return b2;
                            } else if (new URI(headerField).getScheme() != null) {
                                if (httpURLConnection != null) {
                                    try {
                                        httpURLConnection.getInputStream().close();
                                        httpURLConnection.disconnect();
                                        return headerField;
                                    } catch (Exception e4) {
                                        Appodeal.a(e4);
                                    }
                                }
                                return headerField;
                            } else {
                                try {
                                    String url3 = new URL(url, headerField).toString();
                                    if (url3.trim().length() <= 0) {
                                        if (httpURLConnection != null) {
                                            try {
                                                httpURLConnection.getInputStream().close();
                                                httpURLConnection.disconnect();
                                                return headerField;
                                            } catch (Exception e5) {
                                                Appodeal.a(e5);
                                            }
                                        }
                                        return headerField;
                                    }
                                    String b3 = b(url3);
                                    if (httpURLConnection != null) {
                                        try {
                                            httpURLConnection.getInputStream().close();
                                            httpURLConnection.disconnect();
                                            return b3;
                                        } catch (Exception e6) {
                                            Appodeal.a(e6);
                                        }
                                    }
                                    return b3;
                                } catch (Exception e7) {
                                    Appodeal.a(e7);
                                    if (httpURLConnection != null) {
                                        try {
                                            httpURLConnection.getInputStream().close();
                                            httpURLConnection.disconnect();
                                            return headerField;
                                        } catch (Exception e8) {
                                            Appodeal.a(e8);
                                            return headerField;
                                        }
                                    }
                                    return headerField;
                                }
                            }
                        case 304:
                        case 306:
                        default:
                            String url4 = url.toString();
                            if (httpURLConnection != null) {
                                try {
                                    httpURLConnection.getInputStream().close();
                                    httpURLConnection.disconnect();
                                    return url4;
                                } catch (Exception e9) {
                                    Appodeal.a(e9);
                                }
                            }
                            return url4;
                    }
                } catch (Exception e10) {
                    e = e10;
                    Appodeal.a(e);
                    if (httpURLConnection != null) {
                        try {
                            httpURLConnection.getInputStream().close();
                            httpURLConnection.disconnect();
                            return str;
                        } catch (Exception e11) {
                            Appodeal.a(e11);
                            return str;
                        }
                    }
                    return str;
                }
            } catch (Throwable th) {
                th = th;
                if (0 != 0) {
                    try {
                        httpURLConnection2.getInputStream().close();
                        httpURLConnection2.disconnect();
                    } catch (Exception e12) {
                        Appodeal.a(e12);
                    }
                }
                throw th;
            }
        } catch (Exception e13) {
            httpURLConnection = null;
            e = e13;
        } catch (Throwable th2) {
            th = th2;
            if (0 != 0) {
            }
            throw th;
        }
    }

    public static void b(Activity activity) {
        SharedPreferences sharedPreferences = activity.getSharedPreferences("appodeal", 0);
        String string = sharedPreferences.getString("appodealVersion", null);
        if (string == null || !string.equals(Appodeal.getVersion())) {
            SharedPreferences.Editor edit = sharedPreferences.edit();
            edit.putString("appodealVersion", Appodeal.getVersion());
            edit.apply();
            a(activity.getDir(new File(com.appodeal.ads.utils.l.a).toString(), 0));
            a(activity.getDir(com.appodeal.ads.utils.l.b, 0));
        }
    }

    public static void b(Activity activity, int i) {
        Intent intent = new Intent(activity, VideoActivity.class);
        intent.addFlags(CrashUtils.ErrorDialogData.BINDER_CRASH);
        intent.addFlags(8388608);
        intent.putExtra("type", bg.b.NON_REWARDED);
        intent.putExtra("requestId", i);
        try {
            activity.startActivity(intent);
        } catch (ActivityNotFoundException unused) {
            Appodeal.a("VideoActivity not found - did you declare it in AndroidManifest.xml?");
            au.a().a(true);
        }
    }

    public static void b(Context context, String str, String str2) {
        if (k.a(context)) {
            new AlertDialog.Builder(context).setTitle(str).setMessage(str2).setCancelable(true).setNegativeButton("OK", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialogInterface, int i) {
                    dialogInterface.cancel();
                }
            }).create().show();
        }
    }

    public static boolean b(int i) {
        return (i & 1) > 0 || (i & 2) > 0 || (i & 128) > 0;
    }

    public static boolean b(Context context, String str) {
        try {
            context.getPackageManager().getApplicationInfo(str, 0);
            return true;
        } catch (PackageManager.NameNotFoundException unused) {
            return false;
        }
    }

    public static boolean b(View view) {
        return view.getMeasuredHeight() > 0 && view.getMeasuredWidth() > 0;
    }

    public static boolean b(String... strArr) {
        try {
            for (String str : strArr) {
                Class.forName(str, false, Appodeal.class.getClassLoader());
            }
            return true;
        } catch (ClassNotFoundException unused) {
            return false;
        }
    }

    public static long c() {
        RandomAccessFile randomAccessFile;
        Exception e;
        if (a == 0) {
            RandomAccessFile randomAccessFile2 = null;
            try {
            } catch (Throwable th) {
                th = th;
            }
            try {
                try {
                    randomAccessFile = new RandomAccessFile("/proc/meminfo", "r");
                    try {
                        Matcher matcher = Pattern.compile("(\\d+)").matcher(randomAccessFile.readLine());
                        String str = "";
                        while (matcher.find()) {
                            str = matcher.group(1);
                        }
                        try {
                            a = Long.parseLong(str) / PlaybackStateCompat.ACTION_PLAY_FROM_MEDIA_ID;
                        } catch (NumberFormatException unused) {
                            a = 0L;
                        }
                    } catch (Exception e2) {
                        e = e2;
                        Appodeal.a(e);
                        e.printStackTrace();
                        if (randomAccessFile != null) {
                            randomAccessFile.close();
                        }
                        return a;
                    }
                } catch (Exception e3) {
                    e3.printStackTrace();
                }
            } catch (Exception e4) {
                randomAccessFile = null;
                e = e4;
            } catch (Throwable th2) {
                th = th2;
                if (0 != 0) {
                    try {
                        randomAccessFile2.close();
                    } catch (Exception e5) {
                        e5.printStackTrace();
                    }
                }
                throw th;
            }
            if (randomAccessFile != null) {
                randomAccessFile.close();
            }
        }
        return a;
    }

    public static Rect c(View view) {
        int[] iArr = new int[2];
        view.getLocationInWindow(iArr);
        return new Rect(iArr[0], iArr[1], view.getWidth() + iArr[0], view.getHeight() + iArr[1]);
    }

    public static String c(Context context) {
        String networkOperator = ((TelephonyManager) context.getSystemService("phone")).getNetworkOperator();
        if (networkOperator == null || networkOperator.length() < 3) {
            return null;
        }
        return networkOperator.substring(0, 3) + '-' + networkOperator.substring(3);
    }

    public static String c(String str) {
        if (str == null) {
            return "";
        }
        Matcher matcher = Pattern.compile("_(.)").matcher(str);
        StringBuffer stringBuffer = new StringBuffer(str.length());
        while (matcher.find()) {
            matcher.appendReplacement(stringBuffer, matcher.group(1).toUpperCase(Locale.ENGLISH));
        }
        matcher.appendTail(stringBuffer);
        stringBuffer.setCharAt(0, Character.toUpperCase(str.charAt(0)));
        return stringBuffer.toString();
    }

    public static void c(Activity activity) {
        activity.startActivity(new Intent(activity, TestActivity.class));
    }

    public static void c(Activity activity, int i) {
        Intent intent = new Intent(activity, VideoActivity.class);
        intent.addFlags(CrashUtils.ErrorDialogData.BINDER_CRASH);
        intent.addFlags(8388608);
        intent.putExtra("type", bg.b.REWARDED);
        intent.putExtra("requestId", i);
        try {
            activity.startActivity(intent);
        } catch (ActivityNotFoundException unused) {
            Appodeal.a("VideoActivity not found - did you declare it in AndroidManifest.xml?");
            ba.a().a(true);
        }
    }

    public static boolean c(Context context, String str) {
        try {
            if (com.appodeal.ads.utils.l.c == null) {
                com.appodeal.ads.utils.l.c = Arrays.asList(context.getResources().getAssets().list("dex"));
            }
            return com.appodeal.ads.utils.l.c.contains(String.format("%s.dx", str));
        } catch (IOException e) {
            Appodeal.a(e);
            return false;
        }
    }

    public static int d(Activity activity) {
        int identifier;
        if (!f(activity) && (identifier = activity.getResources().getIdentifier("status_bar_height", "dimen", TapjoyConstants.TJC_DEVICE_PLATFORM_TYPE)) > 0) {
            return activity.getResources().getDimensionPixelSize(identifier);
        }
        return 0;
    }

    @TargetApi(18)
    public static long d() {
        long blockCountLong;
        long availableBlocksLong;
        long blockSizeLong;
        if (Build.VERSION.SDK_INT < 18) {
            StatFs statFs = new StatFs(Environment.getRootDirectory().getAbsolutePath());
            blockCountLong = statFs.getBlockCount() * statFs.getBlockSize();
            availableBlocksLong = statFs.getAvailableBlocks();
            blockSizeLong = statFs.getBlockSize();
        } else {
            StatFs statFs2 = new StatFs(Environment.getRootDirectory().getAbsolutePath());
            blockCountLong = statFs2.getBlockCountLong() * statFs2.getBlockSizeLong();
            availableBlocksLong = statFs2.getAvailableBlocksLong();
            blockSizeLong = statFs2.getBlockSizeLong();
        }
        return (blockCountLong - (availableBlocksLong * blockSizeLong)) / PlaybackStateCompat.ACTION_SET_CAPTIONING_ENABLED;
    }

    public static Pair<Integer, Pair<String, String>> d(Context context) {
        int i;
        String str;
        Location e = e(context);
        String str2 = null;
        if (e != null) {
            String valueOf = String.valueOf(e.getLatitude());
            str = String.valueOf(e.getLongitude());
            i = 1;
            str2 = valueOf;
        } else {
            i = 0;
            str = null;
        }
        return new Pair<>(Integer.valueOf(i), new Pair(str2, str));
    }

    public static String d(View view) {
        try {
            Bitmap createBitmap = Bitmap.createBitmap(view.getWidth(), view.getHeight(), Bitmap.Config.ARGB_8888);
            view.draw(new Canvas(createBitmap));
            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
            if (createBitmap.compress(Bitmap.CompressFormat.JPEG, 50, byteArrayOutputStream)) {
                return Base64.encodeToString(byteArrayOutputStream.toByteArray(), 2);
            }
        } catch (Exception e) {
            Appodeal.a(e);
        }
        return null;
    }

    public static String d(String str) {
        try {
            try {
                new URL(str);
                return str;
            } catch (MalformedURLException unused) {
                return URLDecoder.decode(str, "UTF-8");
            }
        } catch (UnsupportedEncodingException | IllegalArgumentException unused2) {
            return str;
        }
    }

    @TargetApi(18)
    public static long e() {
        long blockCountLong;
        long blockSizeLong;
        if (Build.VERSION.SDK_INT < 18) {
            StatFs statFs = new StatFs(Environment.getRootDirectory().getAbsolutePath());
            blockCountLong = statFs.getBlockCount();
            blockSizeLong = statFs.getBlockSize();
        } else {
            StatFs statFs2 = new StatFs(Environment.getRootDirectory().getAbsolutePath());
            blockCountLong = statFs2.getBlockCountLong();
            blockSizeLong = statFs2.getBlockSizeLong();
        }
        return (blockCountLong * blockSizeLong) / PlaybackStateCompat.ACTION_SET_CAPTIONING_ENABLED;
    }

    public static Location e(Context context) {
        String str;
        LocationManager locationManager = (LocationManager) context.getSystemService("location");
        String bestProvider = locationManager.getBestProvider(new Criteria(), false);
        if (bestProvider != null) {
            try {
                return locationManager.getLastKnownLocation(bestProvider);
            } catch (IllegalArgumentException unused) {
                str = "Failed to retrieve GPS location: device has no GPS provider";
                Appodeal.a(str);
                return null;
            } catch (SecurityException unused2) {
                str = "Failed to retrieve GPS location: permission not granted";
                Appodeal.a(str);
                return null;
            }
        }
        return null;
    }

    public static String e(String str) {
        return "<MediaFile type=\"video/mp4\">" + str + "</MediaFile>";
    }

    public static boolean e(Activity activity) {
        return (activity == null || activity.getWindow() == null || !activity.getWindow().isActive() || activity.getWindow().getDecorView().getWindowToken() == null) ? false : true;
    }

    public static boolean e(Context context, String str) {
        try {
            Appodeal.a(String.format("launch url: %s", str), Log.LogLevel.verbose);
            Intent intent = new Intent("android.intent.action.VIEW", Uri.parse(str));
            intent.setFlags(CrashUtils.ErrorDialogData.BINDER_CRASH);
            ComponentName a2 = a(context, intent);
            if (a2 != null) {
                intent.setComponent(a2);
                context.startActivity(intent);
                return true;
            }
            String decode = URLDecoder.decode(str, "UTF-8");
            Intent intent2 = new Intent("android.intent.action.VIEW", Uri.parse(decode));
            intent2.setFlags(CrashUtils.ErrorDialogData.BINDER_CRASH);
            ComponentName a3 = a(context, intent2);
            if (a3 == null) {
                Appodeal.a(String.format("No activities to handle intent: %s", decode));
                return false;
            }
            intent2.setComponent(a3);
            context.startActivity(intent2);
            return true;
        } catch (Exception e) {
            Appodeal.a(e);
            return false;
        }
    }

    @SuppressLint({"NewApi"})
    public static Pair<Integer, Integer> f(Context context) {
        Display defaultDisplay = ((WindowManager) context.getSystemService("window")).getDefaultDisplay();
        Point point = new Point();
        defaultDisplay.getSize(point);
        return new Pair<>(Integer.valueOf(point.x), Integer.valueOf(point.y));
    }

    public static URL f(String str) {
        return (str.equals(AdCreative.kFormatBanner) || str.equals("debug")) ? new URL("http://appodeal.herokuapp.com/android_waterfall_interstitial") : (str.equals("banner_320") || str.equals("debug_banner_320")) ? new URL("http://appodeal.herokuapp.com/android_waterfall_banner") : (str.equals("banner_mrec") || str.equals("debug_mrec")) ? new URL("http://appodeal.herokuapp.com/android_waterfall_mrec") : (str.equals(TapjoyConstants.TJC_PLUGIN_NATIVE) || str.equals("debug_native")) ? new URL("http://appodeal.herokuapp.com/android_waterfall_native") : (str.equals(Advertisement.KEY_VIDEO) || str.equals("debug_video")) ? new URL("http://appodeal.herokuapp.com/android_waterfall_video") : new URL("http://appodeal.herokuapp.com/android_waterfall_rewarded_video");
    }

    private static boolean f(Activity activity) {
        return (activity.getWindow().getAttributes().flags & 1024) == 1024;
    }

    @SuppressLint({"NewApi"})
    public static float g(Context context) {
        Display defaultDisplay = ((WindowManager) context.getSystemService("window")).getDefaultDisplay();
        DisplayMetrics displayMetrics = context.getResources().getDisplayMetrics();
        Point point = new Point();
        defaultDisplay.getSize(point);
        return point.x / displayMetrics.density;
    }

    public static Bitmap g(String str) {
        byte[] decode = Base64.decode(str, 0);
        return BitmapFactory.decodeByteArray(decode, 0, decode.length);
    }

    @SuppressLint({"NewApi"})
    public static float h(Context context) {
        Display defaultDisplay = ((WindowManager) context.getSystemService("window")).getDefaultDisplay();
        DisplayMetrics displayMetrics = context.getResources().getDisplayMetrics();
        Point point = new Point();
        defaultDisplay.getSize(point);
        return point.y / displayMetrics.density;
    }

    public static float i(Context context) {
        Display defaultDisplay = ((WindowManager) context.getSystemService("window")).getDefaultDisplay();
        DisplayMetrics displayMetrics = new DisplayMetrics();
        defaultDisplay.getMetrics(displayMetrics);
        return displayMetrics.density;
    }

    public static int j(Context context) {
        int rotation = ((WindowManager) context.getSystemService("window")).getDefaultDisplay().getRotation();
        int i = context.getResources().getConfiguration().orientation;
        if (i == 1) {
            switch (rotation) {
                case 2:
                case 3:
                    return 9;
                default:
                    return 1;
            }
        } else if (i != 2) {
            Appodeal.a("Unknown screen orientation. Defaulting to portrait.");
            return 9;
        } else {
            switch (rotation) {
                case 2:
                case 3:
                    return 8;
                default:
                    return 0;
            }
        }
    }

    public static float k(Context context) {
        try {
            Intent registerReceiver = context.registerReceiver(null, new IntentFilter("android.intent.action.BATTERY_CHANGED"));
            if (registerReceiver != null) {
                int intExtra = registerReceiver.getIntExtra(AppLovinEventTypes.USER_COMPLETED_LEVEL, -1);
                int intExtra2 = registerReceiver.getIntExtra("scale", -1);
                if (intExtra == -1 || intExtra2 == -1) {
                    return -1.0f;
                }
                return (intExtra / intExtra2) * 100.0f;
            }
        } catch (Exception e) {
            Appodeal.a(e);
        }
        return -1.0f;
    }

    public static String l(Context context) {
        SharedPreferences sharedPreferences = context.getSharedPreferences("appodeal", 0);
        if (sharedPreferences.contains("uuid")) {
            return sharedPreferences.getString("uuid", null);
        }
        String uuid = UUID.randomUUID().toString();
        SharedPreferences.Editor edit = sharedPreferences.edit();
        edit.putString("uuid", uuid);
        edit.apply();
        return uuid;
    }

    public static void m(Context context) {
        Intent intent = new Intent(context, LoaderActivity.class);
        intent.addFlags(CrashUtils.ErrorDialogData.BINDER_CRASH);
        intent.addFlags(8388608);
        try {
            context.startActivity(intent);
        } catch (ActivityNotFoundException unused) {
            Appodeal.a("LoaderActivity not found - did you declare it in AndroidManifest.xml?");
        }
    }

    public static boolean n(Context context) {
        DisplayMetrics displayMetrics = context.getResources().getDisplayMetrics();
        double d = displayMetrics.widthPixels / displayMetrics.xdpi;
        double d2 = displayMetrics.heightPixels / displayMetrics.ydpi;
        return Double.valueOf(Math.sqrt((d * d) + (d2 * d2))).doubleValue() >= 6.6d;
    }

    public static int o(Context context) {
        FeatureInfo[] systemAvailableFeatures = context.getPackageManager().getSystemAvailableFeatures();
        if (systemAvailableFeatures != null && systemAvailableFeatures.length > 0) {
            for (FeatureInfo featureInfo : systemAvailableFeatures) {
                if (featureInfo.name == null) {
                    if (featureInfo.reqGlEsVersion != 0) {
                        return (featureInfo.reqGlEsVersion & SupportMenu.CATEGORY_MASK) >> 16;
                    }
                    return 1;
                }
            }
        }
        return 1;
    }

    public static long p(Context context) {
        ActivityManager.MemoryInfo memoryInfo = new ActivityManager.MemoryInfo();
        ((ActivityManager) context.getSystemService("activity")).getMemoryInfo(memoryInfo);
        return c() - (memoryInfo.availMem / PlaybackStateCompat.ACTION_SET_CAPTIONING_ENABLED);
    }

    public static String q(Context context) {
        switch (context.getResources().getConfiguration().orientation) {
            case 0:
                return "Unknown";
            case 1:
                return "Portrait";
            case 2:
                return "Landscape";
            default:
                return null;
        }
    }

    public static boolean r(Context context) {
        switch (((AudioManager) context.getSystemService("audio")).getRingerMode()) {
            case 0:
            case 1:
                return true;
            default:
                return false;
        }
    }

    public static String s(Context context) {
        try {
            return String.valueOf(b("com.google.android.gms.common.GoogleApiAvailability") ? GoogleApiAvailability.GOOGLE_PLAY_SERVICES_VERSION_CODE : context.getPackageManager().getApplicationInfo(context.getPackageName(), 128).metaData.getInt(GooglePlayServicesUtilLight.KEY_METADATA_GOOGLE_PLAY_SERVICES_VERSION));
        } catch (Throwable th) {
            Appodeal.a(th);
            return "not-found";
        }
    }

    public static String t(Context context) {
        try {
            PackageInfo packageInfo = context.getPackageManager().getPackageInfo("com.google.android.webview", 0);
            if (packageInfo != null) {
                return packageInfo.versionName;
            }
            return null;
        } catch (Exception unused) {
            return null;
        }
    }

    public static UserSettings u(Context context) {
        return new UserSettings(context);
    }

    public static String v(Context context) {
        try {
            return context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionName;
        } catch (PackageManager.NameNotFoundException unused) {
            return null;
        }
    }

    public static int w(Context context) {
        NetworkInfo activeNetworkInfo = ((ConnectivityManager) context.getSystemService("connectivity")).getActiveNetworkInfo();
        if (activeNetworkInfo == null || !activeNetworkInfo.isConnected()) {
            return 0;
        }
        int type = activeNetworkInfo.getType();
        if (type != 9) {
            switch (type) {
                case 0:
                    return 3;
                case 1:
                    return 2;
                default:
                    return 0;
            }
        }
        return 1;
    }

    public static JSONObject x(Context context) {
        JSONObject jSONObject = new JSONObject();
        try {
            jSONObject.put("battery", k(context));
            jSONObject.put("rooted", a());
        } catch (JSONException unused) {
        }
        return jSONObject;
    }

    public static JSONObject y(Context context) {
        JSONObject jSONObject = new JSONObject();
        try {
            SharedPreferences sharedPreferences = context.getSharedPreferences("appodeal", 0);
            jSONObject.put("session_id", com.appodeal.ads.utils.f.a(sharedPreferences));
            jSONObject.put("session_uptime", com.appodeal.ads.utils.f.b());
            jSONObject.put("app_uptime", com.appodeal.ads.utils.f.b(sharedPreferences));
            jSONObject.put(TapjoyConstants.TJC_SDK_PLACEMENT, "2.4.2");
            int a2 = com.appodeal.ads.utils.p.a();
            int b2 = com.appodeal.ads.utils.p.b();
            int c = com.appodeal.ads.utils.p.c();
            if (a2 > 0) {
                jSONObject.put("imp_count", a2);
            }
            if (b2 > 0) {
                jSONObject.put("click_count", b2);
            }
            if (c > 0) {
                jSONObject.put("finish_count", c);
            }
            JSONObject d = com.appodeal.ads.utils.p.d();
            if (d.length() > 0) {
                jSONObject.put("imp", d);
            }
            JSONObject e = com.appodeal.ads.utils.p.e();
            if (e.length() > 0) {
                jSONObject.put(CampaignEx.JSON_NATIVE_VIDEO_CLICK, e);
            }
            JSONObject f = com.appodeal.ads.utils.p.f();
            if (f.length() > 0) {
                jSONObject.put(NewAd.EVENT_FINISH, f);
            }
            jSONObject.put("timp", com.appodeal.ads.utils.p.a(context));
            jSONObject.put("tclick", com.appodeal.ads.utils.p.b(context));
            jSONObject.put("tfinish", com.appodeal.ads.utils.p.c(context));
            if (h.j != null) {
                Iterator<String> keys = h.j.keys();
                while (keys.hasNext()) {
                    String next = keys.next();
                    jSONObject.put(next, h.j.get(next));
                }
            }
        } catch (JSONException unused) {
        }
        return jSONObject;
    }

    public static boolean z(Context context) {
        return (Build.VERSION.SDK_INT >= 19 || com.appodeal.ads.utils.e.a(context)) && com.appodeal.ads.utils.j.e();
    }
}