VegeFruits v7.1版本的 MD5 值为:2ff167dfba698c783e879938fe00b9ce

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


package com.appodeal.ads;

import android.R;
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.PopupWindow;
import android.widget.Toast;
import com.applovin.sdk.AppLovinEventTypes;
import com.appodeal.ads.UserSettings;
import com.appodeal.ads.ba;
import com.appodeal.ads.utils.Log;
import com.google.android.gms.common.GoogleApiAvailability;
import com.ironsource.mediationsdk.utils.IronSourceConstants;
import com.ironsource.mediationsdk.utils.ServerResponseWrapper;
import com.ironsource.sdk.precache.DownloadManager;
import com.mopub.common.GpsHelper;
import com.tapjoy.TJAdUnitConstants;
import com.tapjoy.TapjoyConstants;
import com.vk.sdk.api.model.VKApiUserFull;
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.lang.reflect.Method;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLDecoder;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Date;
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 org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import org.nexage.sourcekit.vast.model.VASTModel;

public class az {
    private static long a = 0;
    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(Object obj, String str, boolean z, int i) {
        Field declaredField;
        if (z) {
            Class<?> cls = obj.getClass();
            if (i > 0) {
                int i2 = 0;
                while (i2 < i) {
                    i2++;
                    cls = cls.getSuperclass();
                }
            }
            declaredField = cls.getDeclaredField(str);
        } else {
            declaredField = obj.getClass().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, JSONArray jSONArray, Runnable runnable) {
        boolean z = false;
        if (jSONArray != null) {
            try {
                if (jSONArray.length() != 0) {
                    String str = "";
                    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) {
            return null;
        }
        switch (gender) {
            case MALE:
                return "M";
            case FEMALE:
                return "F";
            case OTHER:
                return "O";
            default:
                return null;
        }
    }

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

    static String a(String str) {
        URL url;
        HttpURLConnection httpURLConnection;
        HttpURLConnection httpURLConnection2 = null;
        try {
            try {
                url = new URL(str);
                httpURLConnection = (HttpURLConnection) url.openConnection();
            } catch (Exception e) {
                e = e;
            }
        } catch (Throwable th) {
            th = th;
        }
        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 307:
                    String headerField = httpURLConnection.getHeaderField("Location");
                    if (headerField == null) {
                        str = url.toString();
                        httpURLConnection = httpURLConnection;
                        if (httpURLConnection != null) {
                            try {
                                httpURLConnection.disconnect();
                                httpURLConnection = httpURLConnection;
                                break;
                            } catch (Exception e2) {
                                Appodeal.a((Throwable) e2);
                                httpURLConnection = e2;
                                break;
                            }
                        }
                    } else {
                        HttpURLConnection httpURLConnection3 = httpURLConnection;
                        if (!h(headerField)) {
                            if (httpURLConnection != null) {
                                try {
                                    httpURLConnection.disconnect();
                                    httpURLConnection3 = httpURLConnection;
                                } catch (Exception e3) {
                                    Appodeal.a((Throwable) e3);
                                    httpURLConnection3 = e3;
                                }
                            }
                            str = headerField;
                            httpURLConnection = httpURLConnection3;
                            break;
                        } else {
                            str = a(httpURLConnection.getHeaderField("Location"));
                            httpURLConnection = httpURLConnection;
                            if (httpURLConnection != null) {
                                try {
                                    httpURLConnection.disconnect();
                                    httpURLConnection = httpURLConnection;
                                    break;
                                } catch (Exception e4) {
                                    Appodeal.a((Throwable) e4);
                                    httpURLConnection = e4;
                                    break;
                                }
                            }
                        }
                    }
                    break;
                case 304:
                case 306:
                default:
                    str = url.toString();
                    httpURLConnection = httpURLConnection;
                    if (httpURLConnection != null) {
                        try {
                            httpURLConnection.disconnect();
                            httpURLConnection = httpURLConnection;
                            break;
                        } catch (Exception e5) {
                            Appodeal.a((Throwable) e5);
                            httpURLConnection = e5;
                            break;
                        }
                    }
                    break;
            }
        } catch (Exception e6) {
            httpURLConnection2 = httpURLConnection;
            e = e6;
            Appodeal.a(e);
            if (httpURLConnection2 != null) {
                try {
                    httpURLConnection2.disconnect();
                } catch (Exception e7) {
                    Appodeal.a(e7);
                }
            }
            return str;
        } catch (Throwable th2) {
            httpURLConnection2 = httpURLConnection;
            th = th2;
            if (httpURLConnection2 != null) {
                try {
                    httpURLConnection2.disconnect();
                } catch (Exception e8) {
                    Appodeal.a(e8);
                }
            }
            throw th;
        }
        return str;
    }

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

    public static void a(Activity activity, bb bbVar, int i) {
        Intent intent = new Intent(activity, (Class<?>) VideoActivity.class);
        intent.addFlags(268435456);
        intent.addFlags(8388608);
        intent.putExtra("type", ba.b.NON_REWARDED);
        intent.putExtra("videoClass", bbVar.a());
        intent.putExtra("requestId", i);
        try {
            activity.startActivity(intent);
        } catch (ActivityNotFoundException e) {
            Appodeal.a("VideoActivity not found - did you declare it in AndroidManifest.xml?");
            ar.a().a(true);
        }
    }

    public static void a(Activity activity, s sVar, int i) {
        Intent intent = new Intent(activity, (Class<?>) InterstitialActivity.class);
        intent.addFlags(268435456);
        intent.addFlags(8388608);
        intent.putExtra("interstitialClass", sVar.a());
        intent.putExtra("requestId", i);
        try {
            activity.startActivity(intent);
        } catch (ActivityNotFoundException e) {
            Appodeal.a("InterstitialActivity not found - did you declare it in AndroidManifest.xml?");
            q.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.remove(GpsHelper.ADVERTISING_ID_KEY);
        edit.remove("advertisingTracking");
        edit.apply();
    }

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

    public static void a(Context context, String str, String str2) {
        if (h.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 void a(PopupWindow popupWindow, int i) {
        try {
            Method declaredMethod = PopupWindow.class.getDeclaredMethod("setWindowLayoutType", Integer.TYPE);
            declaredMethod.setAccessible(true);
            declaredMethod.invoke(popupWindow, Integer.valueOf(i));
        } catch (Exception e) {
            Appodeal.a(e);
        }
    }

    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;
        try {
            bufferedOutputStream = new BufferedOutputStream(outputStream);
            try {
                try {
                    bufferedOutputStream.write(str.getBytes("UTF-8"));
                    bufferedOutputStream.flush();
                    if (bufferedOutputStream != null) {
                        try {
                            bufferedOutputStream.close();
                        } catch (Exception e) {
                            Appodeal.a(e);
                        }
                    }
                } catch (Exception e2) {
                    e = e2;
                    Appodeal.a(e);
                    if (bufferedOutputStream != null) {
                        try {
                            bufferedOutputStream.close();
                        } catch (Exception e3) {
                            Appodeal.a(e3);
                        }
                    }
                }
            } catch (Throwable th) {
                th = th;
                if (bufferedOutputStream != null) {
                    try {
                        bufferedOutputStream.close();
                    } catch (Exception e4) {
                        Appodeal.a(e4);
                    }
                }
                throw th;
            }
        } catch (Exception e5) {
            e = e5;
            bufferedOutputStream = null;
        } catch (Throwable th2) {
            th = th2;
            bufferedOutputStream = null;
            if (bufferedOutputStream != null) {
            }
            throw th;
        }
    }

    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) {
        if (Appodeal.getLogLevel() == Log.LogLevel.none) {
            return;
        }
        StringBuilder sb = new StringBuilder();
        sb.append(String.format("%s waterfall:", b(str)));
        if (list != null && !list.isEmpty()) {
            sb.append("\n  Precache:\n    ");
            for (JSONObject jSONObject2 : list) {
                if (jSONObject2.has("name")) {
                    sb.append(String.format(Locale.ENGLISH, "%s (%s), eCPM: %.2f; ", b(jSONObject2.optString("name")), b(jSONObject2.optString("status")), Double.valueOf(jSONObject2.optDouble("ecpm", 0.0d))));
                } else {
                    sb.append(String.format(Locale.ENGLISH, "%s, eCPM: %.2f; ", b(jSONObject2.optString("status")), Double.valueOf(jSONObject2.optDouble("ecpm", 0.0d))));
                }
            }
        }
        if (list2 == null || list2.isEmpty()) {
            sb.append("\n  Ads: Empty");
        } else {
            sb.append("\n  Ads:");
            int i = 100;
            Iterator<JSONObject> it = list2.iterator();
            while (true) {
                int i2 = i;
                if (!it.hasNext()) {
                    break;
                }
                JSONObject next = it.next();
                if (i2 >= 100) {
                    sb.append("\n    ");
                    i2 = 0;
                }
                String format = next.has("name") ? String.format(Locale.ENGLISH, "%s (%s), eCPM: %.2f; ", b(next.optString("name")), b(next.optString("status")), Double.valueOf(next.optDouble("ecpm", 0.0d))) : String.format(Locale.ENGLISH, "%s, eCPM: %.2f; ", b(next.optString("status")), Double.valueOf(next.optDouble("ecpm", 0.0d)));
                sb.append(format);
                i = format.length() + i2;
            }
        }
        if (jSONObject != null) {
            try {
                JSONArray jSONArray = jSONObject.getJSONArray("bidders");
                if (jSONArray != null && jSONArray.length() > 0) {
                    sb.append("\n  OpenRTB bidders:");
                    int i3 = 100;
                    int i4 = 0;
                    while (i4 < jSONArray.length()) {
                        if (i3 >= 100) {
                            sb.append("\n    ");
                            i3 = 0;
                        }
                        String format2 = String.format("%s; ", jSONArray.getJSONObject(i4).getString(TJAdUnitConstants.String.TITLE));
                        sb.append(format2);
                        i4++;
                        i3 = format2.length() + i3;
                    }
                }
            } catch (JSONException e) {
            }
        }
        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;
                HttpURLConnection httpURLConnection2 = null;
                HttpURLConnection httpURLConnection3 = null;
                try {
                    try {
                        httpURLConnection = (HttpURLConnection) new URL(str).openConnection();
                    } catch (Throwable th) {
                        th = th;
                    }
                } catch (Exception e) {
                    e = e;
                }
                try {
                    httpURLConnection.setConnectTimeout(DownloadManager.OPERATION_TIMEOUT);
                    httpURLConnection.setInstanceFollowRedirects(true);
                    httpURLConnection.setRequestProperty("Connection", "close");
                    ?? r1 = "GET";
                    httpURLConnection.setRequestMethod("GET");
                    httpURLConnection.getResponseCode();
                    httpURLConnection2 = r1;
                    if (httpURLConnection != null) {
                        try {
                            httpURLConnection.disconnect();
                            httpURLConnection2 = r1;
                        } catch (Exception e2) {
                            Appodeal.a(e2);
                            httpURLConnection2 = r1;
                        }
                    }
                } catch (Exception e3) {
                    httpURLConnection3 = httpURLConnection;
                    e = e3;
                    Appodeal.a(e);
                    httpURLConnection2 = httpURLConnection3;
                    if (httpURLConnection3 != null) {
                        try {
                            httpURLConnection3.disconnect();
                            httpURLConnection2 = httpURLConnection3;
                        } catch (Exception e4) {
                            Appodeal.a(e4);
                            httpURLConnection2 = httpURLConnection3;
                        }
                    }
                } catch (Throwable th2) {
                    httpURLConnection2 = httpURLConnection;
                    th = th2;
                    if (httpURLConnection2 != null) {
                        try {
                            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() {
                HttpURLConnection httpURLConnection;
                HttpURLConnection httpURLConnection2 = null;
                try {
                    try {
                        httpURLConnection = (HttpURLConnection) new URL(str).openConnection();
                    } catch (Exception e) {
                        e = e;
                    }
                } catch (Throwable th) {
                    th = th;
                }
                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) {
                        try {
                            httpURLConnection.disconnect();
                        } catch (Exception e2) {
                            Appodeal.a(e2);
                        }
                    }
                } catch (Exception e3) {
                    httpURLConnection2 = httpURLConnection;
                    e = e3;
                    if (runnable != null) {
                        runnable.run();
                    }
                    Appodeal.a(e);
                    if (httpURLConnection2 != null) {
                        try {
                            httpURLConnection2.disconnect();
                        } catch (Exception e4) {
                            Appodeal.a(e4);
                        }
                    }
                } catch (Throwable th2) {
                    httpURLConnection2 = httpURLConnection;
                    th = th2;
                    if (httpURLConnection2 != null) {
                        try {
                            httpURLConnection2.disconnect();
                        } catch (Exception e5) {
                            Appodeal.a(e5);
                        }
                    }
                    throw th;
                }
            }
        });
    }

    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;
        int i;
        try {
            rect = new Rect();
        } catch (Exception e) {
            Appodeal.a(e);
        }
        if (!(view.getGlobalVisibleRect(rect) && view.isShown() && (!h.o || view.hasWindowFocus()) && !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;
        }
        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;
        }
        View findViewById = activity.findViewById(R.id.content);
        Rect rect2 = new Rect();
        findViewById.getGlobalVisibleRect(rect2);
        if (h.o && !Rect.intersects(rect, rect2)) {
            Appodeal.a("Ad View is out of screen, show wasn't tracked", Log.LogLevel.verbose);
            return false;
        }
        ViewGroup viewGroup2 = (ViewGroup) view.getRootView();
        ?? r2 = (ViewGroup) view.getParent();
        int i2 = 0;
        View view2 = view;
        while (r2 != 0) {
            int indexOfChild = r2.indexOfChild(view2) + 1;
            while (indexOfChild < r2.getChildCount()) {
                View childAt = r2.getChildAt(indexOfChild);
                if (childAt.getVisibility() == 0) {
                    childAt.getLocationInWindow(new int[2]);
                    Rect b2 = b(childAt);
                    if (Rect.intersects(rect, b2)) {
                        if (a(rect, b2) < 80.0f) {
                            Appodeal.a("Ad View is covered by another view, show wasn't tracked", Log.LogLevel.verbose);
                            return false;
                        }
                        i = i2 + 1;
                        if (i >= 3) {
                            Appodeal.a("Ad View is covered by too many views, show wasn't tracked", Log.LogLevel.verbose);
                            return false;
                        }
                        indexOfChild++;
                        i2 = i;
                    }
                }
                i = i2;
                indexOfChild++;
                i2 = i;
            }
            if (r2 != viewGroup2) {
                viewGroup = (ViewGroup) r2.getParent();
            } else {
                viewGroup = null;
                r2 = view2;
            }
            view2 = r2;
            r2 = viewGroup;
        }
        return true;
    }

    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 c = c(str);
        if (f.l && h(c)) {
            com.appodeal.ads.utils.r.a.execute(new Runnable() {
                @Override
                public void run() {
                    az.f(context, az.a(c));
                    if (runnable != null) {
                        az.a(runnable);
                    }
                }
            });
            return true;
        }
        if (runnable != null) {
            a(runnable);
        }
        return f(context, c);
    }

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

    public static boolean a(String... strArr) {
        int length = strArr.length;
        for (String str : strArr) {
            if (b(str)) {
                length--;
            }
        }
        return length > 0 && strArr.length != length;
    }

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

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

    public static a b(Context context) {
        boolean z;
        String str;
        String str2;
        String str3;
        NetworkInfo activeNetworkInfo = ((ConnectivityManager) context.getSystemService("connectivity")).getActiveNetworkInfo();
        String str4 = "unknown";
        if (activeNetworkInfo != null && activeNetworkInfo.isConnected()) {
            String typeName = activeNetworkInfo.getTypeName();
            String subtypeName = activeNetworkInfo.getSubtypeName();
            switch (activeNetworkInfo.getType()) {
                case 0:
                    switch (activeNetworkInfo.getSubtype()) {
                        case 1:
                        case 2:
                        case 4:
                        case 7:
                        case 11:
                            str = subtypeName;
                            str4 = typeName;
                            z = false;
                            break;
                        case 3:
                        case 5:
                        case 6:
                        case 8:
                        case 9:
                        case 10:
                        case 12:
                        case 13:
                        case 14:
                        case 15:
                            str = subtypeName;
                            str4 = typeName;
                            z = true;
                            break;
                        default:
                            str = subtypeName;
                            str4 = typeName;
                            z = false;
                            break;
                    }
                case 1:
                    str = subtypeName;
                    str4 = typeName;
                    z = true;
                    break;
                case 2:
                case 3:
                case 4:
                case 5:
                case 8:
                default:
                    str = subtypeName;
                    str4 = typeName;
                    z = false;
                    break;
                case 6:
                    str = subtypeName;
                    str4 = typeName;
                    z = true;
                    break;
                case 7:
                    str = subtypeName;
                    str4 = typeName;
                    z = false;
                    break;
                case 9:
                    str = subtypeName;
                    str4 = typeName;
                    z = true;
                    break;
            }
        } else {
            z = false;
            str = null;
        }
        if (str4 != null) {
            if (str4.equals("CELLULAR")) {
                str4 = "MOBILE";
            }
            str2 = str4.toLowerCase(Locale.ENGLISH);
        } else {
            str2 = str4;
        }
        if (str != null) {
            str3 = str.toLowerCase(Locale.ENGLISH);
            if (str3.isEmpty()) {
                str3 = null;
            }
        } else {
            str3 = str;
        }
        return new a(str2, str3, z);
    }

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

    public static String b(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 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.j.a).toString(), 0));
            a(activity.getDir(com.appodeal.ads.utils.j.b, 0));
        }
    }

    public static void b(Activity activity, bb bbVar, int i) {
        Intent intent = new Intent(activity, (Class<?>) VideoActivity.class);
        intent.addFlags(268435456);
        intent.addFlags(8388608);
        intent.putExtra("type", ba.b.REWARDED);
        intent.putExtra("videoClass", bbVar.a());
        intent.putExtra("requestId", i);
        try {
            activity.startActivity(intent);
        } catch (ActivityNotFoundException e) {
            Appodeal.a("VideoActivity not found - did you declare it in AndroidManifest.xml?");
            av.a().a(true);
        }
    }

    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 e) {
            return false;
        }
    }

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

    public static long c() {
        RandomAccessFile randomAccessFile;
        if (a == 0) {
            RandomAccessFile randomAccessFile2 = null;
            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 e) {
                            a = 0L;
                        }
                        if (randomAccessFile != null) {
                            try {
                                randomAccessFile.close();
                            } catch (Exception e2) {
                                e2.printStackTrace();
                            }
                        }
                    } catch (Exception e3) {
                        e = e3;
                        Appodeal.a(e);
                        e.printStackTrace();
                        if (randomAccessFile != null) {
                            try {
                                randomAccessFile.close();
                            } catch (Exception e4) {
                                e4.printStackTrace();
                            }
                        }
                        return a;
                    }
                } catch (Throwable th) {
                    th = th;
                    if (0 != 0) {
                        try {
                            randomAccessFile2.close();
                        } catch (Exception e5) {
                            e5.printStackTrace();
                        }
                    }
                    throw th;
                }
            } catch (Exception e6) {
                e = e6;
                randomAccessFile = null;
            } catch (Throwable th2) {
                th = th2;
                if (0 != 0) {
                }
                throw th;
            }
        }
        return a;
    }

    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(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);
            }
            return null;
        } catch (Exception e) {
            Appodeal.a(e);
            return null;
        }
    }

    public static String c(String str) {
        try {
            new URL(str);
            return str;
        } catch (MalformedURLException e) {
            try {
                return URLDecoder.decode(str, "UTF-8");
            } catch (UnsupportedEncodingException e2) {
                return str;
            }
        }
    }

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

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

    public static int d(Activity activity) {
        int identifier;
        if (!e(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() {
        if (Build.VERSION.SDK_INT < 18) {
            StatFs statFs = new StatFs(Environment.getRootDirectory().getAbsolutePath());
            return ((statFs.getBlockCount() * statFs.getBlockSize()) - (statFs.getBlockSize() * statFs.getAvailableBlocks())) / PlaybackStateCompat.ACTION_SET_CAPTIONING_ENABLED;
        }
        StatFs statFs2 = new StatFs(Environment.getRootDirectory().getAbsolutePath());
        return ((statFs2.getBlockCountLong() * statFs2.getBlockSizeLong()) - (statFs2.getBlockSizeLong() * statFs2.getAvailableBlocksLong())) / PlaybackStateCompat.ACTION_SET_CAPTIONING_ENABLED;
    }

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

    public static String d(Context context, String str) {
        Uri parse = Uri.parse(str);
        Set<String> queryParameterNames = parse.getQueryParameterNames();
        LinkedHashMap linkedHashMap = new LinkedHashMap();
        for (String str2 : queryParameterNames) {
            linkedHashMap.put(str2, parse.getQueryParameter(str2));
        }
        Uri.Builder clearQuery = Uri.parse(str).buildUpon().clearQuery();
        if (!f.h) {
            Location e = e(context);
            if (e != null) {
                linkedHashMap.put("lat", String.valueOf(e.getLatitude()));
                linkedHashMap.put("lon", String.valueOf(e.getLongitude()));
                linkedHashMap.put("geo_type", "1");
            }
            UserSettings u = u(context);
            if (u.getGender() != null) {
                linkedHashMap.put("gender", a(u));
            }
            String b2 = u.b();
            if (b2 != null) {
                linkedHashMap.put("keywords", b2);
            }
            linkedHashMap.put("language", Locale.getDefault().getLanguage());
            Integer age = u.getAge();
            if (age != null) {
                linkedHashMap.put("age", String.valueOf(age));
            }
            UserSettings.Relation a2 = u.a();
            if (a2 != null) {
                linkedHashMap.put(VKApiUserFull.RELATION, String.valueOf(a2.getValue()));
            }
            String userId = u.getUserId();
            if (userId != null) {
                linkedHashMap.put(ServerResponseWrapper.USER_ID_FIELD, String.valueOf(userId));
            }
            linkedHashMap.put("connectiontype", String.valueOf(x(context)));
            String c = c(context);
            if (c != null) {
                linkedHashMap.put("carrier", c);
            }
        }
        if (Native.b) {
            linkedHashMap.put("native_ad_type", Native.A.toString());
        }
        for (String str3 : linkedHashMap.keySet()) {
            clearQuery.appendQueryParameter(str3, (String) linkedHashMap.get(str3));
        }
        clearQuery.appendQueryParameter("device_ext", y(context).toString());
        clearQuery.appendQueryParameter("app_ext", z(context).toString());
        DisplayMetrics displayMetrics = context.getResources().getDisplayMetrics();
        clearQuery.appendQueryParameter("ppi", String.valueOf(displayMetrics.densityDpi));
        clearQuery.appendQueryParameter("pxratio", String.valueOf(displayMetrics.density));
        if (f.i) {
            clearQuery.appendQueryParameter("corona", "1");
            clearQuery.appendQueryParameter("store_url", f.b);
            clearQuery.appendQueryParameter("bundle_id", context.getPackageName());
            clearQuery.appendQueryParameter("app_name", f.a);
        }
        clearQuery.appendQueryParameter("metadata_headers", "1");
        return clearQuery.build().toString();
    }

    public static Date d(String str) {
        try {
            return b.parse(str);
        } catch (ParseException e) {
            Appodeal.a(e);
            return null;
        }
    }

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

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

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

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

    @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 String f() {
        return b.format(Calendar.getInstance().getTime());
    }

    public static URL f(String str) {
        return (str.equals("banner") || 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("video") || str.equals("debug_video")) ? new URL("http://appodeal.herokuapp.com/android_waterfall_video") : new URL("http://appodeal.herokuapp.com/android_waterfall_rewarded_video");
    }

    public static boolean f(Context context, String str) {
        Intent intent;
        ComponentName a2;
        try {
            Appodeal.a(String.format("launch url: %s", str), Log.LogLevel.verbose);
            intent = new Intent("android.intent.action.VIEW", Uri.parse(str));
            intent.setFlags(268435456);
            a2 = a(context, intent);
        } catch (Exception e) {
            Appodeal.a(e);
        }
        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(268435456);
        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;
    }

    @SuppressLint({"NewApi"})
    public static float g(Context context) {
        Display defaultDisplay = ((WindowManager) context.getSystemService("window")).getDefaultDisplay();
        DisplayMetrics displayMetrics = context.getResources().getDisplayMetrics();
        defaultDisplay.getSize(new Point());
        return r2.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();
        defaultDisplay.getSize(new Point());
        return r2.y / displayMetrics.density;
    }

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

    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;
            }
        }
        if (i != 2) {
            Appodeal.a("Unknown screen orientation. Defaulting to portrait.");
            return 9;
        }
        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) {
                return -1.0f;
            }
            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, (Class<?>) LoaderActivity.class);
        intent.addFlags(268435456);
        intent.addFlags(8388608);
        try {
            context.startActivity(intent);
        } catch (ActivityNotFoundException e) {
            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((d2 * d2) + (d * d))).doubleValue() >= 6.6d;
    }

    public static int o(Context context) {
        FeatureInfo[] systemAvailableFeatures = context.getPackageManager().getSystemAvailableFeatures();
        if (systemAvailableFeatures == null || systemAvailableFeatures.length <= 0) {
            return 1;
        }
        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:
                return true;
            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("com.google.android.gms.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;
            }
        } catch (Exception e) {
        }
        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 e) {
            return null;
        }
    }

    public static String w(Context context) {
        return context.getSharedPreferences("appodeal", 0).getString("advertisingTracking", null);
    }

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

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

    public static JSONObject z(Context context) {
        JSONObject jSONObject = new JSONObject();
        try {
            SharedPreferences sharedPreferences = context.getSharedPreferences("appodeal", 0);
            jSONObject.put(TapjoyConstants.TJC_SESSION_ID, com.appodeal.ads.utils.e.a(sharedPreferences));
            jSONObject.put("session_uptime", com.appodeal.ads.utils.e.b());
            jSONObject.put("app_uptime", com.appodeal.ads.utils.e.b(sharedPreferences));
            jSONObject.put(TapjoyConstants.TJC_SDK_PLACEMENT, "2.1.7");
            int a2 = com.appodeal.ads.utils.n.a();
            int b2 = com.appodeal.ads.utils.n.b();
            int c = com.appodeal.ads.utils.n.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.n.d();
            if (d.length() > 0) {
                jSONObject.put("imp", d);
            }
            JSONObject e = com.appodeal.ads.utils.n.e();
            if (e.length() > 0) {
                jSONObject.put("click", e);
            }
            JSONObject f = com.appodeal.ads.utils.n.f();
            if (f.length() > 0) {
                jSONObject.put("finish", f);
            }
            jSONObject.put("timp", com.appodeal.ads.utils.n.a(context));
            jSONObject.put("tclick", com.appodeal.ads.utils.n.b(context));
            jSONObject.put("tfinish", com.appodeal.ads.utils.n.c(context));
            if (f.j != null) {
                Iterator<String> keys = f.j.keys();
                while (keys.hasNext()) {
                    String next = keys.next();
                    jSONObject.put(next, f.j.get(next));
                }
            }
        } catch (JSONException e2) {
        }
        return jSONObject;
    }
}