Apk Done v1.0版本的 MD5 值为:44cfb8e1ce639995aa7f0de6a3a6388b

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


package com.appodeal.ads;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.ComponentName;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.ActivityInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.content.res.TypedArray;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Matrix;
import android.graphics.Rect;
import android.graphics.Shader;
import android.graphics.drawable.BitmapDrawable;
import android.media.MediaMetadataRetriever;
import android.net.Uri;
import android.os.Build;
import android.os.Process;
import android.security.NetworkSecurityPolicy;
import android.text.TextUtils;
import android.util.Base64;
import android.util.Pair;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Toast;
import com.appodeal.ads.utils.EventsTracker;
import com.appodeal.ads.utils.Log;
import com.appodeal.ads.utils.LogConstants;
import com.google.android.gms.measurement.api.AppMeasurementSdk;
import com.ironsource.mediationsdk.utils.IronSourceConstants;
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.File;
import java.io.FileOutputStream;
import java.io.Flushable;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.math.BigInteger;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URL;
import java.net.URLDecoder;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
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;
public class z1 {
    static final boolean c = !z1.class.desiredAssertionStatus();
    private static Boolean a = null;
    private static final char[] b = "0123456789abcdef".toCharArray();

    public class a implements Runnable {
        final Context a;
        final String b;
        final Runnable c;

        a(Context context, String str, Runnable runnable) {
            this.a = context;
            this.b = str;
            this.c = runnable;
        }

        @Override
        public void run() {
            z1.g(this.a, z1.b(this.b));
            Runnable runnable = this.c;
            if (runnable != null) {
                w1.a(runnable);
            }
        }
    }

    public class b implements Runnable {
        final String a;

        b(String str) {
            this.a = str;
        }

        @Override
        public void run() {
            HttpURLConnection httpURLConnection;
            Throwable th;
            Exception e;
            try {
                try {
                    try {
                        httpURLConnection = (HttpURLConnection) new URL(this.a).openConnection();
                        try {
                            httpURLConnection.setConnectTimeout(5000);
                            httpURLConnection.setInstanceFollowRedirects(true);
                            httpURLConnection.setRequestProperty("Connection", "close");
                            httpURLConnection.setRequestMethod("GET");
                            httpURLConnection.getResponseCode();
                            httpURLConnection.getInputStream().close();
                            httpURLConnection.disconnect();
                        } catch (Exception e2) {
                            e = e2;
                            Log.log(e);
                            if (httpURLConnection != null) {
                                httpURLConnection.getInputStream().close();
                                httpURLConnection.disconnect();
                            }
                        }
                    } catch (Throwable th2) {
                        th = th2;
                        if (httpURLConnection != null) {
                            try {
                                httpURLConnection.getInputStream().close();
                                httpURLConnection.disconnect();
                            } catch (Exception e3) {
                                Log.log(e3);
                            }
                        }
                        throw th;
                    }
                } catch (Exception e4) {
                    httpURLConnection = null;
                    e = e4;
                } catch (Throwable th3) {
                    httpURLConnection = null;
                    th = th3;
                    if (httpURLConnection != null) {
                    }
                    throw th;
                }
            } catch (Exception e5) {
                Log.log(e5);
            }
        }
    }

    class c implements Runnable {
        final String a;
        final Runnable b;

        c(String str, Runnable runnable) {
            this.a = str;
            this.b = runnable;
        }

        @Override
        public void run() {
            HttpURLConnection httpURLConnection;
            Throwable th;
            Exception e;
            Runnable runnable;
            try {
                try {
                    httpURLConnection = (HttpURLConnection) new URL(this.a).openConnection();
                    try {
                        try {
                            httpURLConnection.setConnectTimeout(5000);
                            httpURLConnection.setInstanceFollowRedirects(true);
                            httpURLConnection.setRequestProperty("Connection", "close");
                            httpURLConnection.setRequestMethod("GET");
                            if ((httpURLConnection.getResponseCode() >= 300 || httpURLConnection.getResponseCode() < 200) && (runnable = this.b) != null) {
                                runnable.run();
                            }
                            httpURLConnection.getInputStream().close();
                            httpURLConnection.disconnect();
                        } catch (Exception e2) {
                            e = e2;
                            Runnable runnable2 = this.b;
                            if (runnable2 != null) {
                                runnable2.run();
                            }
                            Log.log(e);
                            if (httpURLConnection != null) {
                                httpURLConnection.getInputStream().close();
                                httpURLConnection.disconnect();
                            }
                        }
                    } catch (Throwable th2) {
                        th = th2;
                        if (httpURLConnection != null) {
                            try {
                                httpURLConnection.getInputStream().close();
                                httpURLConnection.disconnect();
                            } catch (Exception e3) {
                                Log.log(e3);
                            }
                        }
                        throw th;
                    }
                } catch (Exception e4) {
                    Log.log(e4);
                }
            } catch (Exception e5) {
                httpURLConnection = null;
                e = e5;
            } catch (Throwable th3) {
                httpURLConnection = null;
                th = th3;
                if (httpURLConnection != null) {
                }
                throw th;
            }
        }
    }

    class d implements Runnable {
        final Context a;
        final String b;

        d(Context context, String str) {
            this.a = context;
            this.b = str;
        }

        @Override
        public void run() {
            Toast.makeText(this.a, this.b, 1).show();
            Log.log(LogConstants.KEY_SDK, LogConstants.EVENT_SHOW_TOAST, this.b);
        }
    }

    class e implements Runnable {
        final Context a;
        final String b;
        final String c;

        class a implements DialogInterface.OnClickListener {
            a(e eVar) {
            }

            @Override
            public void onClick(DialogInterface dialogInterface, int i) {
                dialogInterface.cancel();
            }
        }

        e(Context context, String str, String str2) {
            this.a = context;
            this.b = str;
            this.c = str2;
        }

        @Override
        public void run() {
            new AlertDialog.Builder(this.a).setTitle(this.b).setMessage(this.c).setCancelable(true).setNegativeButton("OK", new a(this)).create().show();
        }
    }

    public static Activity a() {
        Activity a2 = com.appodeal.ads.a.a();
        return a2 == null ? r1.d : a2;
    }

    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")) {
                ActivityInfo activityInfo = resolveInfo.activityInfo;
                return new ComponentName(activityInfo.packageName, activityInfo.name);
            }
        }
        return new ComponentName(queryIntentActivities.get(0).activityInfo.packageName, queryIntentActivities.get(0).activityInfo.name);
    }

    private static Bitmap a(Bitmap bitmap, float f) {
        Matrix matrix = new Matrix();
        matrix.postRotate(f);
        try {
            return Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true);
        } finally {
            bitmap.recycle();
        }
    }

    public static Rect a(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 BitmapDrawable a(Context context, String str, boolean z, int i) {
        return a(context, str, z, i, 0.0f);
    }

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

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

    @SafeVarargs
    public static Object a(Object obj, Class<?> cls, String str, Pair<Class, Object>... pairArr) throws Exception {
        Class<?>[] clsArr;
        Object[] objArr;
        if (pairArr != null) {
            clsArr = new Class[pairArr.length];
            objArr = new Object[pairArr.length];
            for (int i = 0; i < pairArr.length; i++) {
                clsArr[i] = (Class) pairArr[i].first;
                objArr[i] = pairArr[i].second;
            }
        } else {
            clsArr = null;
            objArr = null;
        }
        for (int i2 = 10; i2 > 0 && cls != null; i2--) {
            try {
                Method declaredMethod = cls.getDeclaredMethod(str, clsArr);
                declaredMethod.setAccessible(true);
                return declaredMethod.invoke(obj, objArr);
            } catch (IllegalAccessException | InvocationTargetException unused) {
            } catch (NoSuchMethodException unused2) {
                cls = cls.getSuperclass();
            }
        }
        return null;
    }

    public static Object a(Object obj, String str) throws Exception {
        Class<?> cls = obj.getClass();
        for (int i = 10; i > 0 && cls != null; i--) {
            try {
                Field declaredField = cls.getDeclaredField(str);
                declaredField.setAccessible(true);
                return declaredField.get(obj);
            } catch (IllegalAccessException unused) {
                return null;
            } catch (NoSuchFieldException unused2) {
                cls = cls.getSuperclass();
            }
        }
        return null;
    }

    @SafeVarargs
    public static Object a(Object obj, String str, Pair<Class, Object>... pairArr) throws Exception {
        return a(obj, obj.getClass(), str, pairArr);
    }

    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 & 3164) > 0) {
            if (sb.length() > 0) {
                sb.append(", ");
            }
            sb.append("Banner");
        }
        if ((i & Appodeal.MREC) > 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) {
        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 e2) {
                Log.log(e2);
                w1.a(runnable);
                return "";
            }
        }
        w1.a(runnable);
        return "";
    }

    public static String a(Uri uri, String str) {
        Throwable th;
        FileOutputStream fileOutputStream;
        File file;
        MediaMetadataRetriever mediaMetadataRetriever = new MediaMetadataRetriever();
        mediaMetadataRetriever.setDataSource(r1.e, uri);
        Bitmap frameAtTime = mediaMetadataRetriever.getFrameAtTime(Long.parseLong(mediaMetadataRetriever.extractMetadata(9)), 2);
        FileOutputStream fileOutputStream2 = null;
        if (frameAtTime != null) {
            try {
                file = new File(c(r1.e, str), c(uri.toString()));
                fileOutputStream = new FileOutputStream(file);
            } catch (Exception e2) {
                e = e2;
                fileOutputStream = null;
            } catch (Throwable th2) {
                th = th2;
                fileOutputStream = fileOutputStream2;
                a((Flushable) fileOutputStream);
                a((Closeable) fileOutputStream);
                throw th;
            }
            try {
                frameAtTime.compress(Bitmap.CompressFormat.JPEG, 100, fileOutputStream);
                String absolutePath = file.getAbsolutePath();
                a((Flushable) fileOutputStream);
                a((Closeable) fileOutputStream);
                return absolutePath;
            } catch (Exception e3) {
                e = e3;
                try {
                    Log.log(e);
                    a((Flushable) fileOutputStream);
                    a((Closeable) fileOutputStream);
                    return null;
                } catch (Throwable th3) {
                    th = th3;
                    fileOutputStream2 = fileOutputStream;
                    fileOutputStream = fileOutputStream2;
                    a((Flushable) fileOutputStream);
                    a((Closeable) fileOutputStream);
                    throw th;
                }
            } catch (Throwable th4) {
                th = th4;
                a((Flushable) fileOutputStream);
                a((Closeable) fileOutputStream);
                throw th;
            }
        }
        return null;
    }

    public static String a(InputStream inputStream) {
        BufferedReader bufferedReader;
        BufferedReader bufferedReader2 = null;
        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 e2) {
                    e = e2;
                    try {
                        Log.log(e);
                        if (bufferedReader != null) {
                            try {
                                bufferedReader.close();
                            } catch (Exception e3) {
                                Log.log(e3);
                            }
                        }
                        return null;
                    } catch (Throwable th) {
                        th = th;
                        bufferedReader2 = bufferedReader;
                        bufferedReader = bufferedReader2;
                        if (bufferedReader != null) {
                            try {
                                bufferedReader.close();
                            } catch (Exception e4) {
                                Log.log(e4);
                            }
                        }
                        throw th;
                    }
                } catch (Throwable th2) {
                    th = th2;
                    if (bufferedReader != null) {
                    }
                    throw th;
                }
            }
            if (sb.length() > 0) {
                sb.setLength(sb.length() - 1);
            }
            String sb2 = sb.toString();
            try {
                bufferedReader.close();
            } catch (Exception e5) {
                Log.log(e5);
            }
            return sb2;
        } catch (Exception e6) {
            e = e6;
            bufferedReader = null;
        } catch (Throwable th3) {
            th = th3;
            bufferedReader = bufferedReader2;
            if (bufferedReader != null) {
            }
            throw th;
        }
    }

    public static String a(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 String a(JSONObject jSONObject, String str) {
        return a(jSONObject, str, (String) null);
    }

    public static String a(JSONObject jSONObject, String str, String str2) {
        return (jSONObject == null || str == null || jSONObject.isNull(str)) ? str2 : jSONObject.optString(str, str2);
    }

    public static String a(byte[] bArr) {
        char[] cArr = new char[bArr.length * 2];
        for (int i = 0; i < bArr.length; i++) {
            int i2 = i * 2;
            char[] cArr2 = b;
            cArr[i2] = cArr2[(bArr[i] >> 4) & 15];
            cArr[i2 + 1] = cArr2[bArr[i] & 15];
        }
        return new String(cArr);
    }

    public static void a(Context context, String str, String str2) {
        if (a0.a(context) && j(context)) {
            w1.a(new e(context, str, str2));
            Log.log(LogConstants.KEY_SDK, LogConstants.EVENT_SHOW_DIALOG, str2);
        }
    }

    public static void a(AdType adType, com.appodeal.ads.waterfall_filter.a aVar) {
        a(adType.getDisplayName(), aVar.b(), aVar.a());
    }

    public static void a(Closeable closeable) {
        if (closeable != null) {
            try {
                closeable.close();
            } catch (Exception e2) {
                Log.log(e2);
            }
        }
    }

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

    public static void a(Flushable flushable) {
        if (flushable != null) {
            try {
                flushable.flush();
            } catch (Exception e2) {
                Log.log(e2);
            }
        }
    }

    public static void a(Object obj, String str, Object obj2) throws Exception {
        Class<?> cls = obj.getClass();
        for (int i = 10; i > 0 && cls != null; i--) {
            try {
                Field declaredField = cls.getDeclaredField(str);
                declaredField.setAccessible(true);
                declaredField.set(obj, obj2);
            } catch (IllegalAccessException unused) {
            } catch (NoSuchFieldException unused2) {
                cls = cls.getSuperclass();
            }
        }
    }

    private static void a(String str, List<JSONObject> list, List<JSONObject> list2) {
        if (r1.i() == Log.LogLevel.none) {
            return;
        }
        StringBuilder sb = new StringBuilder();
        sb.append(String.format("%s waterfall:", a(str)));
        int i = 3;
        if (list != null && !list.isEmpty()) {
            ArrayList<JSONObject> arrayList = new ArrayList(list);
            sb.append("\n  Precache:\n    ");
            for (JSONObject jSONObject : arrayList) {
                if (jSONObject.has(AppMeasurementSdk.ConditionalUserProperty.NAME)) {
                    Locale locale = Locale.ENGLISH;
                    Object[] objArr = new Object[i];
                    objArr[0] = a(jSONObject.optString(AppMeasurementSdk.ConditionalUserProperty.NAME));
                    objArr[1] = a(jSONObject.optString(IronSourceConstants.EVENTS_STATUS));
                    objArr[2] = Double.valueOf(jSONObject.optDouble("ecpm", 0.0d));
                    sb.append(String.format(locale, "%s (%s), eCPM: %.2f; ", objArr));
                } else {
                    sb.append(String.format(Locale.ENGLISH, "%s, eCPM: %.2f; ", a(jSONObject.optString(IronSourceConstants.EVENTS_STATUS)), Double.valueOf(jSONObject.optDouble("ecpm", 0.0d))));
                }
                i = 3;
            }
        }
        if (list2 == null || list2.isEmpty()) {
            sb.append("\n  Ads: Empty");
        } else {
            ArrayList<JSONObject> arrayList2 = new ArrayList(list2);
            sb.append("\n  Ads:");
            int i2 = 100;
            int i3 = 100;
            for (JSONObject jSONObject2 : arrayList2) {
                if (i3 >= i2) {
                    sb.append("\n    ");
                    i3 = 0;
                }
                String format = jSONObject2.has(AppMeasurementSdk.ConditionalUserProperty.NAME) ? String.format(Locale.ENGLISH, "%s (%s), eCPM: %.2f; ", a(jSONObject2.optString(AppMeasurementSdk.ConditionalUserProperty.NAME)), a(jSONObject2.optString(IronSourceConstants.EVENTS_STATUS)), Double.valueOf(jSONObject2.optDouble("ecpm", 0.0d))) : String.format(Locale.ENGLISH, "%s, eCPM: %.2f; ", a(jSONObject2.optString(IronSourceConstants.EVENTS_STATUS)), Double.valueOf(jSONObject2.optDouble("ecpm", 0.0d)));
                sb.append(format);
                i3 += format.length();
                i2 = 100;
            }
        }
        Log.log(LogConstants.KEY_SDK, LogConstants.EVENT_DUMP, sb.toString());
    }

    public static void a(String str, Executor executor) {
        if (TextUtils.isEmpty(str) || executor == null) {
            return;
        }
        executor.execute(new b(str));
    }

    public static void a(String str, Executor executor, Runnable runnable) {
        if (TextUtils.isEmpty(str) || executor == null) {
            return;
        }
        executor.execute(new c(str, runnable));
    }

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

    public static boolean a(Context context) {
        return (Build.VERSION.SDK_INT >= 19 || com.appodeal.ads.utils.c.f(context)) && j0.l();
    }

    public static boolean a(Context context, int i, int i2) {
        try {
            TypedArray obtainStyledAttributes = context.getTheme().obtainStyledAttributes(i, new int[]{i2});
            boolean z = obtainStyledAttributes.getBoolean(0, false);
            obtainStyledAttributes.recycle();
            return z;
        } catch (Exception e2) {
            Log.log(e2);
            return false;
        }
    }

    public static boolean a(Context context, String str, Runnable runnable) {
        if (TextUtils.isEmpty(str)) {
            if (runnable != null) {
                w1.a(runnable);
                return false;
            }
            return false;
        } else if (c || str != null) {
            String e2 = e(str);
            if (v.f && g(e2)) {
                com.appodeal.ads.utils.s.f.execute(new a(context, e2, runnable));
                return true;
            }
            if (runnable != null) {
                w1.a(runnable);
            }
            return g(context, e2);
        } else {
            throw new AssertionError();
        }
    }

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

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

    private static byte[] a(String str, byte[] bArr) {
        try {
            MessageDigest messageDigest = MessageDigest.getInstance(str);
            messageDigest.update(bArr);
            return messageDigest.digest();
        } catch (NoSuchAlgorithmException e2) {
            Log.log(e2);
            return null;
        }
    }

    public static int b(Context context, String str) {
        if (str != null) {
            return context.checkPermission(str, Process.myPid(), Process.myUid());
        }
        throw new IllegalArgumentException("permission is null");
    }

    static String b(String str) {
        HttpURLConnection httpURLConnection = null;
        try {
            try {
                URL url = new URL(str);
                HttpURLConnection httpURLConnection2 = (HttpURLConnection) url.openConnection();
                try {
                    try {
                        httpURLConnection2.setInstanceFollowRedirects(false);
                        httpURLConnection2.setConnectTimeout(500);
                        httpURLConnection2.setReadTimeout(500);
                        switch (httpURLConnection2.getResponseCode()) {
                            case 301:
                            case IronSourceConstants.OFFERWALL_AVAILABLE:
                            case 303:
                            case IronSourceConstants.OFFERWALL_OPENED:
                            case 307:
                                String headerField = httpURLConnection2.getHeaderField(LogConstants.EVENT_LOCATION);
                                if (headerField == null) {
                                    String url2 = url.toString();
                                    try {
                                        httpURLConnection2.getInputStream().close();
                                        httpURLConnection2.disconnect();
                                    } catch (Exception e2) {
                                        Log.log(e2);
                                    }
                                    return url2;
                                } else if (g(headerField)) {
                                    String b2 = b(httpURLConnection2.getHeaderField(LogConstants.EVENT_LOCATION));
                                    try {
                                        httpURLConnection2.getInputStream().close();
                                        httpURLConnection2.disconnect();
                                    } catch (Exception e3) {
                                        Log.log(e3);
                                    }
                                    return b2;
                                } else if (new URI(headerField).getScheme() != null) {
                                    try {
                                        httpURLConnection2.getInputStream().close();
                                        httpURLConnection2.disconnect();
                                    } catch (Exception e4) {
                                        Log.log(e4);
                                    }
                                    return headerField;
                                } else {
                                    try {
                                        String url3 = new URL(url, headerField).toString();
                                        if (url3.trim().length() <= 0) {
                                            try {
                                                httpURLConnection2.getInputStream().close();
                                                httpURLConnection2.disconnect();
                                            } catch (Exception e5) {
                                                Log.log(e5);
                                            }
                                            return headerField;
                                        }
                                        String b3 = b(url3);
                                        try {
                                            httpURLConnection2.getInputStream().close();
                                            httpURLConnection2.disconnect();
                                        } catch (Exception e6) {
                                            Log.log(e6);
                                        }
                                        return b3;
                                    } catch (Exception e7) {
                                        Log.log(e7);
                                        try {
                                            httpURLConnection2.getInputStream().close();
                                            httpURLConnection2.disconnect();
                                        } catch (Exception e8) {
                                            Log.log(e8);
                                        }
                                        return headerField;
                                    }
                                }
                            case 304:
                            case 306:
                            default:
                                String url4 = url.toString();
                                try {
                                    httpURLConnection2.getInputStream().close();
                                    httpURLConnection2.disconnect();
                                } catch (Exception e9) {
                                    Log.log(e9);
                                }
                                return url4;
                        }
                    } catch (Exception e10) {
                        e = e10;
                        httpURLConnection = httpURLConnection2;
                        Log.log(e);
                        if (httpURLConnection != null) {
                            try {
                                httpURLConnection.getInputStream().close();
                                httpURLConnection.disconnect();
                            } catch (Exception e11) {
                                Log.log(e11);
                            }
                        }
                        return str;
                    }
                } catch (Throwable th) {
                    th = th;
                    httpURLConnection = httpURLConnection2;
                    if (httpURLConnection != null) {
                        try {
                            httpURLConnection.getInputStream().close();
                            httpURLConnection.disconnect();
                        } catch (Exception e12) {
                            Log.log(e12);
                        }
                    }
                    throw th;
                }
            } catch (Exception e13) {
                e = e13;
            }
        } catch (Throwable th2) {
            th = th2;
        }
    }

    public static boolean b() {
        return Build.VERSION.SDK_INT < 23 || NetworkSecurityPolicy.getInstance().isCleartextTrafficPermitted();
    }

    public static boolean b(Context context) {
        int i;
        Boolean bool = a;
        if (bool != null) {
            return bool.booleanValue();
        }
        try {
            String[] strArr = context.getPackageManager().getPackageInfo(context.getPackageName(), 1024).applicationInfo.sharedLibraryFiles;
            if (strArr != null) {
                int length = strArr.length;
                while (i < length) {
                    String str = strArr[i];
                    i = (str.equalsIgnoreCase("/system/framework/org.apache.http.legacy.boot.jar") || str.equalsIgnoreCase("/system/framework/org.apache.http.legacy.jar")) ? 0 : i + 1;
                    a = Boolean.TRUE;
                    return true;
                }
            }
        } catch (Exception e2) {
            Log.log(e2);
        }
        a = Boolean.FALSE;
        return false;
    }

    public static boolean b(Context context, int i, int i2) {
        try {
            TypedArray obtainStyledAttributes = context.getTheme().obtainStyledAttributes(i, new int[]{i2});
            boolean hasValue = obtainStyledAttributes.hasValue(0);
            obtainStyledAttributes.recycle();
            return hasValue;
        } catch (Exception e2) {
            Log.log(e2);
            return false;
        }
    }

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

    public static byte[] b(byte[] bArr) {
        return a("MD5", bArr);
    }

    public static File c(Context context, String str) {
        File externalFilesDir = context.getExternalFilesDir(null);
        if (externalFilesDir != null) {
            File file = new File(externalFilesDir.getPath() + "/" + str + "/");
            if (file.exists() || file.mkdirs()) {
                return file;
            }
        }
        return null;
    }

    public static String c(String str) {
        return new BigInteger(b(str.getBytes())).abs().toString(36);
    }

    public static void c(Context context) {
        SharedPreferences b2 = s1.a(context).b();
        String string = b2.getString("appodealVersion", null);
        if (string == null || !string.equals(r1.r())) {
            SharedPreferences.Editor edit = b2.edit();
            edit.putString("appodealVersion", r1.r());
            edit.apply();
            com.appodeal.ads.utils.k.a(context);
        }
    }

    public static boolean c() {
        return a("android.support.multidex.MultiDex") || a("androidx.multidex.MultiDex");
    }

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

    public static byte[] c(byte[] bArr) {
        return a("SHA-224", bArr);
    }

    public static String d(String str) {
        char c2;
        str.hashCode();
        switch (str.hashCode()) {
            case -1907025354:
                if (str.equals("banner_mrec")) {
                    c2 = 0;
                    break;
                }
                c2 = 65535;
                break;
            case -1840422033:
                if (str.equals("debug_mrec")) {
                    c2 = 1;
                    break;
                }
                c2 = 65535;
                break;
            case -1396342996:
                if (str.equals("banner")) {
                    c2 = 2;
                    break;
                }
                c2 = 65535;
                break;
            case -1210465393:
                if (str.equals("debug_video")) {
                    c2 = 3;
                    break;
                }
                c2 = 65535;
                break;
            case -1052618729:
                if (str.equals("native")) {
                    c2 = 4;
                    break;
                }
                c2 = 65535;
                break;
            case -1031406050:
                if (str.equals("banner_320")) {
                    c2 = 5;
                    break;
                }
                c2 = 65535;
                break;
            case 95458899:
                if (str.equals("debug")) {
                    c2 = 6;
                    break;
                }
                c2 = 65535;
                break;
            case 112202875:
                if (str.equals("video")) {
                    c2 = 7;
                    break;
                }
                c2 = 65535;
                break;
            case 624073610:
                if (str.equals("debug_banner_320")) {
                    c2 = '\b';
                    break;
                }
                c2 = 65535;
                break;
            case 894337923:
                if (str.equals("debug_native")) {
                    c2 = '\t';
                    break;
                }
                c2 = 65535;
                break;
            default:
                c2 = 65535;
                break;
        }
        switch (c2) {
            case 0:
            case 1:
                return "http://herokuapp.appodeal.com/android_waterfall_mrec";
            case 2:
            case 6:
                return "http://herokuapp.appodeal.com/android_waterfall_interstitial";
            case 3:
            case 7:
                return "http://herokuapp.appodeal.com/android_waterfall_video";
            case 4:
            case '\t':
                return "http://herokuapp.appodeal.com/android_waterfall_native";
            case 5:
            case '\b':
                return "http://herokuapp.appodeal.com/android_waterfall_banner";
            default:
                return "http://herokuapp.appodeal.com/android_waterfall_rewarded_video";
        }
    }

    public static JSONObject d(Context context) {
        JSONObject jSONObject = new JSONObject();
        try {
            com.appodeal.ads.utils.x n = r1.n();
            jSONObject.put("session_id", n.e());
            jSONObject.put("session_uptime", n.i());
            jSONObject.put("session_uptime_m", n.j());
            jSONObject.put("app_uptime", n.b(context));
            jSONObject.put("app_uptime_m", n.c(context));
            jSONObject.put("sdk", "2.11.1");
            EventsTracker eventsTracker = EventsTracker.get();
            EventsTracker.EventType eventType = EventsTracker.EventType.Impression;
            jSONObject.put("imp_count", eventsTracker.a(eventType));
            EventsTracker.EventType eventType2 = EventsTracker.EventType.Click;
            jSONObject.put("click_count", eventsTracker.a(eventType2));
            EventsTracker.EventType eventType3 = EventsTracker.EventType.Finish;
            jSONObject.put("finish_count", eventsTracker.a(eventType3));
            jSONObject.put("imp", eventsTracker.b(eventType));
            jSONObject.put("click", eventsTracker.b(eventType2));
            jSONObject.put("finish", eventsTracker.b(eventType3));
            jSONObject.put("timp", eventsTracker.a(context, eventType));
            jSONObject.put("tclick", eventsTracker.a(context, eventType2));
            jSONObject.put("tfinish", eventsTracker.a(context, eventType3));
            JSONObject jSONObject2 = v.d;
            if (jSONObject2 != null) {
                Iterator<String> keys = jSONObject2.keys();
                while (keys.hasNext()) {
                    String next = keys.next();
                    jSONObject.put(next, v.d.get(next));
                }
            }
        } catch (JSONException unused) {
        }
        return jSONObject;
    }

    public static void d(View view) {
        if (view.getParent() == null || !(view.getParent() instanceof ViewGroup)) {
            return;
        }
        ((ViewGroup) view.getParent()).removeView(view);
    }

    public static boolean d(Context context, String str) {
        try {
            if (com.appodeal.ads.utils.k.d == null) {
                com.appodeal.ads.utils.k.d = Arrays.asList(context.getResources().getAssets().list("dex"));
            }
            return com.appodeal.ads.utils.k.d.contains(String.format("%s.dx", str));
        } catch (Exception e2) {
            Log.log(e2);
            return false;
        }
    }

    public static String e(Context context) {
        return s1.a(context).b().getString("appKey", null);
    }

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

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

    public static String f(Context context) {
        Object a2;
        try {
            int intValue = (!a("com.google.android.gms.common.GoogleApiAvailabilityLight") || (a2 = a((Class) Class.forName("com.google.android.gms.common.GoogleApiAvailabilityLight"), "GOOGLE_PLAY_SERVICES_VERSION_CODE")) == null) ? -1 : ((Integer) a2).intValue();
            if (intValue == -1) {
                intValue = context.getPackageManager().getApplicationInfo(context.getPackageName(), 128).metaData.getInt("com.google.android.gms.version");
            }
            return String.valueOf(intValue);
        } catch (Throwable th) {
            Log.log(th);
            return "not-found";
        }
    }

    public static void f(String str) {
        a(str, com.appodeal.ads.utils.s.f);
    }

    public static boolean f(Context context, String str) {
        return b(context, str) == 0;
    }

    public static String g(Context context) {
        SharedPreferences b2 = s1.a(context).b();
        String string = b2.contains("uuid") ? b2.getString("uuid", null) : null;
        if (string == null) {
            String uuid = UUID.randomUUID().toString();
            SharedPreferences.Editor edit = b2.edit();
            edit.putString("uuid", uuid);
            edit.apply();
            return uuid;
        }
        return string;
    }

    public static boolean g(Context context, String str) {
        try {
            Log.log(LogConstants.KEY_SDK, "Launch", String.format("url - %s", str), Log.LogLevel.verbose);
            Intent intent = new Intent("android.intent.action.VIEW", Uri.parse(str));
            intent.setFlags(268435456);
            ComponentName a2 = a(context, intent);
            if (a2 == null) {
                String decode = URLDecoder.decode(str, "UTF-8");
                intent = new Intent("android.intent.action.VIEW", Uri.parse(decode));
                intent.setFlags(268435456);
                a2 = a(context, intent);
                if (a2 == null) {
                    Log.log(LogConstants.KEY_SDK, LogConstants.EVENT_LAUNCH_ERROR, String.format("component not found to handle intent: %s", decode));
                    context.startActivity(intent);
                    return true;
                }
            }
            intent.setComponent(a2);
            context.startActivity(intent);
            return true;
        } catch (Exception e2) {
            Log.log(e2);
            return false;
        }
    }

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

    @Deprecated
    public static UserData h(Context context) {
        return x1.a();
    }

    public static void h(Context context, String str) {
        s1.a(context).a().putString("appKey", str).apply();
    }

    public static String i(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 void i(Context context, String str) {
        if (a0.a(context) && j(context)) {
            w1.a(new d(context, str));
        }
    }

    public static boolean j(Context context) {
        try {
            try {
                Object a2 = a((Class) Class.forName(context.getPackageName() + ".BuildConfig"), "DEBUG");
                if (a2 instanceof Boolean) {
                    return ((Boolean) a2).booleanValue();
                }
            } catch (Throwable th) {
                Log.log(th);
            }
            return true;
        } catch (Throwable unused) {
            return (context.getApplicationInfo().flags & 2) != 0;
        }
    }

    public static boolean k(Context context) {
        Object a2;
        try {
            if (a("com.google.android.gms.common.GoogleApiAvailability")) {
                Object a3 = a((Object) null, Class.forName("com.google.android.gms.common.GoogleApiAvailability"), "getInstance", new Pair[0]);
                if (a3 == null) {
                    return false;
                }
                Object a4 = a(a3, "isGooglePlayServicesAvailable", (Pair<Class, Object>[]) new Pair[]{new Pair(Context.class, context)});
                if (a4 instanceof Integer) {
                    return ((Integer) a4).intValue() == 0;
                }
            }
        } catch (Throwable th) {
            Log.log(th);
        }
        try {
        } catch (Throwable th2) {
            Log.log(th2);
        }
        if (!a("com.google.android.gms.common.GoogleApiAvailabilityLight") || (a2 = a((Object) null, Class.forName("com.google.android.gms.common.GoogleApiAvailabilityLight"), "getInstance", new Pair[0])) == null) {
            return false;
        }
        Object a5 = a(a2, "isGooglePlayServicesAvailable", (Pair<Class, Object>[]) new Pair[]{new Pair(Context.class, context)});
        if (a5 instanceof Integer) {
            return ((Integer) a5).intValue() == 0;
        }
        return false;
    }

    public static boolean l(Context context) {
        return s1.a(context).b().contains("appKey");
    }
}