Idle Egg Factory v2.1.5版本的 MD5 值为:7d2ba6677008ca521af0101bb927d72a

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


package com.safedk.android.utils;

import android.app.Activity;
import android.app.ActivityManager;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.Looper;
import android.os.Process;
import android.text.TextUtils;
import android.util.DisplayMetrics;
import android.view.View;
import android.view.ViewParent;
import android.webkit.MimeTypeMap;
import com.applovin.mediation.ads.MaxAdView;
import com.facebook.internal.security.CertificateUtil;
import com.mbridge.msdk.foundation.download.core.DownloadCommon;
import com.mbridge.msdk.playercommon.exoplayer2.source.chunk.ChunkedTrackBlacklistUtil;
import com.safedk.android.SafeDK;
import com.safedk.android.analytics.events.base.StatsEvent;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLDecoder;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.SortedMap;
import java.util.Stack;
import java.util.regex.MatchResult;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

public class j {

    public static final String f6891a = "UNKNOWN_PROCESS";
    public static final String b = "Accept";
    public static final String c = "text:";
    private static final String e = "Utils";
    private static boolean f = false;
    private static final String h = "com.applovin.sdk.AppLovinSdk";
    private static final String i = "VERSION";
    private static final String j = "video/";
    private static final String o = "https://www.youtube.com/watch?v=";
    private static String w;
    private static boolean g = false;
    private static final String[] k = {"jpg", "jpeg", "gif", "png", "mp4", "m4v", "js", "css", "html", "mkv", "3gp", "3gpp", "webm", "mp3", "htm", "svg", "3g2", "avi", "mpg", "mpeg", "mov", DownloadCommon.DOWNLOAD_REPORT_QUERY_TIMEOUT, "zip", "webp"};
    private static final HashSet<String> l = new HashSet<>(Arrays.asList(k));
    private static final String[] m = {"image"};
    private static final HashSet<String> n = new HashSet<>(Arrays.asList(m));
    private static final Pattern p = Pattern.compile("((http|https|gmsg)?:\\\\*\\/\\\\*\\/.*?)(?:;frame-src| alt|(?:\\\\+x22|%22|\\\\*\"|&amp;quot;|\\\\*&quot;|\\\\*u0026quot;|\\\\+x27|%27|\\\\*'|'|&amp;#39;|\\\\*&#39;)|(?:%3C|\\\\+x3c|<|&lt;|&amp;lt;)|(?:%3E|\\\\+x3e|>|&gt;|&amp;gt;|\\*&quot;)|(?:%5B|\\\\+x5B|\\[)|(?:%5D|\\\\+x5D|\\])|\\)|[\n\r\t\\x{0001}-\\x{001f}\\x{fffd}])");
    private static final Pattern q = Pattern.compile("\\\\x3c(?:!DOCTYPE(?:.?))html\\\\x3e(.*?)(\\\\x3c/html\\\\x3e)");
    private static final Pattern r = Pattern.compile("(https?:\\\\*\\/\\\\*\\/.*?)(?:;frame-src|(?:\\\\+x22|%22|\\\\*\"|&amp;quot;|\\\\*&quot;|\\\\*u0026quot;|\\\\+x27|%27|\\\\*'|'|&amp;#39;|\\\\*&#39;)|(?:%3C|\\\\+x3c|<|&lt;|&amp;lt;)|(?:%3E|\\\\+x3e|>|&gt;|&amp;gt;|\\*&quot;)|\\s?(?:%5D|\\\\+x5D|\\]){2})");
    private static final Pattern s = Pattern.compile("(https?:\\/\\/.*?).googlevideo.com\\/videoplayback");
    private static final Pattern t = Pattern.compile("data:([a-zA-Z]*\\/[a-zA-Z1-9]*);?([\\s\\S]*?;)base64,([^\\\"\\')]*)");
    private static final List<String> u = Arrays.asList("gif", "jpg", "jpeg", "png", "bmp");
    private static final List<String> v = Arrays.asList("mp4", "m4v", "webm", "avi", "mpg", "mpeg", "mov", DownloadCommon.DOWNLOAD_REPORT_QUERY_TIMEOUT, "3gp", "3gpp");
    static Map<String, String> d = new HashMap<String, String>() {
        {
            put("sms", "SMS MMS");
            put("calllog", "Call Log");
            put("packagemanager", "User Apps");
            put("advertising_identifier", "Identifier for Advertising");
        }
    };
    private static final String[] x = {"expire", "ei", "sig", "lsig", "mt", "lmt", "cpn"};
    private static final String[] y = {"mp4", "m4v", "mkv", "3gp", "3gpp", "webm", "mov", "webp"};
    private static final String[] z = {"jpg", "jpeg", "gif", "png", "mp4", "m4v", "mkv", "3gp", "3gpp", "webm", "mp3", "htm", "js", "css", "html", "svg", "3g2", "avi", "mpg", "mpeg", "mov", DownloadCommon.DOWNLOAD_REPORT_QUERY_TIMEOUT, "zip", "webp"};
    private static final Map<String, String> A = new HashMap();

    static {
        A.put("market://details?id=", "https://play.google.com/store/apps/details?id=");
        A.put("amzn://apps/android?p=", "https://www.amazon.com/gp/mas/dl/android?p=");
        A.put("samsungapps://ProductDetail/", "https://www.samsungapps.com/appquery/appDetail.as?appId=");
        A.put("http://play.google.com/store/apps/details?id=", "http://play.google.com/store/apps/details?id=");
    }

    public static String a() {
        if (w == null) {
            w = a(h, i);
        }
        return w;
    }

    public static Object a(Object obj, String str) {
        Object obj2 = null;
        try {
            Field a2 = a((Class) obj.getClass(), str);
            a2.setAccessible(true);
            obj2 = a2.get(obj);
            Logger.d("reflection", str + " = " + obj2);
            return obj2;
        } catch (NoSuchFieldException e2) {
            Logger.w(e, "Failed to get reflection field:" + str);
            return obj2;
        } catch (Exception e3) {
            Logger.e(e, "Failed to get reflection field value", e3);
            return obj2;
        }
    }

    private static Field a(Class cls, String str) throws NoSuchFieldException {
        try {
            return cls.getDeclaredField(str);
        } catch (NoSuchFieldException e2) {
            Class superclass = cls.getSuperclass();
            if (superclass == null) {
                throw e2;
            }
            return a(superclass, str);
        }
    }

    public static String a(String str, String str2) {
        try {
            Field declaredField = Class.forName(str).getDeclaredField(str2);
            declaredField.setAccessible(true);
            return declaredField.isAccessible() ? (String) declaredField.get(null) : "";
        } catch (ClassNotFoundException e2) {
            Logger.d(e, "Error retrieving field value. Class name :" + str + ", field name :" + str2, e2);
            return null;
        } catch (IllegalAccessException e3) {
            Logger.e(e, "Error retrieving field value. Class name :" + str + ", field name :" + str2, e3);
            return null;
        } catch (IllegalArgumentException e4) {
            Logger.e(e, "Error retrieving field value. Class name :" + str + ", field name :" + str2, e4);
            return null;
        } catch (NoSuchFieldException e5) {
            Logger.e(e, "Error retrieving field value. Class name :" + str + ", field name :" + str2, e5);
            return null;
        } catch (SecurityException e6) {
            Logger.e(e, "Error retrieving field value. Class name :" + str + ", field name :" + str2, e6);
            return null;
        }
    }

    public static Object b(Object obj, String str) {
        Object obj2 = null;
        try {
            Method method = obj.getClass().getMethod(str, new Class[0]);
            method.setAccessible(true);
            obj2 = method.invoke(obj, new Object[0]);
            Logger.d("reflection", str + " " + obj2);
            return obj2;
        } catch (NoSuchMethodException e2) {
            e2.printStackTrace();
            return obj2;
        } catch (Exception e3) {
            e3.printStackTrace();
            return obj2;
        }
    }

    public static long b() {
        return a(System.currentTimeMillis());
    }

    public static long a(long j2) {
        return (j2 / ChunkedTrackBlacklistUtil.DEFAULT_TRACK_BLACKLIST_MS) * 60;
    }

    public static long b(long j2) {
        return j2 / 1000;
    }

    public static boolean a(ArrayList<StatsEvent> arrayList) {
        for (int i2 = 0; i2 < arrayList.size() - 1; i2++) {
            StatsEvent statsEvent = arrayList.get(i2);
            StatsEvent statsEvent2 = arrayList.get(i2 + 1);
            int compareTo = statsEvent.compareTo(statsEvent2);
            if (compareTo > 0) {
                Logger.e(e, "failed sort. first: " + statsEvent + " second: " + statsEvent2);
                Logger.e(e, "compare score: " + compareTo);
                return false;
            }
        }
        return true;
    }

    public static String a(InputStream inputStream) throws IOException {
        if (inputStream == null) {
            return null;
        }
        StringBuilder sb = new StringBuilder();
        try {
            InputStreamReader inputStreamReader = new InputStreamReader(inputStream, "UTF-8");
            char[] cArr = new char[65536];
            while (true) {
                int read = inputStreamReader.read(cArr);
                if (read == -1) {
                    break;
                }
                sb.append(cArr, 0, read);
            }
        } catch (ArrayIndexOutOfBoundsException e2) {
            Logger.e(e, "Failed to read configuration from input stream", e2);
        }
        return sb.toString();
    }

    public static long c(long j2) {
        return (j2 / 60) * ChunkedTrackBlacklistUtil.DEFAULT_TRACK_BLACKLIST_MS;
    }

    public static String a(Context context) {
        String str;
        int myPid = Process.myPid();
        List<ActivityManager.RunningAppProcessInfo> runningAppProcesses = ((ActivityManager) context.getSystemService("activity")).getRunningAppProcesses();
        if (runningAppProcesses != null) {
            for (ActivityManager.RunningAppProcessInfo runningAppProcessInfo : runningAppProcesses) {
                if (runningAppProcessInfo.pid == myPid) {
                    str = runningAppProcessInfo.processName;
                    break;
                }
            }
        }
        str = "";
        if (str.equals("")) {
            return f6891a;
        }
        return str;
    }

    public static String a(String str) {
        String str2 = d.get(str);
        return TextUtils.isEmpty(str2) ? C(str) : str2;
    }

    private static String C(String str) {
        if (!TextUtils.isEmpty(str)) {
            return str.substring(0, 1).toUpperCase() + str.substring(1, str.length());
        }
        return str;
    }

    public static DisplayMetrics a(Activity activity) {
        DisplayMetrics displayMetrics = new DisplayMetrics();
        try {
            activity.getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
        } catch (Throwable th) {
            Logger.e(e, "error during display metrics extraction");
        }
        return displayMetrics;
    }

    public static Map<String, String> b(String str) {
        HashMap hashMap = new HashMap();
        if (!TextUtils.isEmpty(str)) {
            try {
                JSONObject jSONObject = new JSONObject(str);
                Iterator<String> keys = jSONObject.keys();
                while (keys.hasNext()) {
                    String next = keys.next();
                    hashMap.put(next, (String) jSONObject.get(next));
                }
            } catch (JSONException e2) {
                Logger.e(e, "exception while parsing json string to map", e2);
                return null;
            }
        }
        return hashMap;
    }

    public static JSONObject a(Map<String, String> map) {
        try {
            return new JSONObject(map.toString());
        } catch (JSONException e2) {
            Logger.e(e, "exception while parsing map to JSON object", e2);
            return null;
        }
    }

    public static void b(String str, String str2) {
        int length = str2.length() / 4000;
        for (int i2 = 0; i2 <= length; i2++) {
            int i3 = (i2 + 1) * 4000;
            if (i3 >= str2.length()) {
                i3 = str2.length();
            }
            Logger.v(str, str2.substring(i2 * 4000, i3));
        }
    }

    public static String c(String str, String str2) {
        try {
        } catch (Throwable th) {
            Logger.e(e, "Exception in getting query param decoded : " + th.getMessage(), th);
        }
        if (!TextUtils.isEmpty(str2) && !TextUtils.isEmpty(str)) {
            Map<String, String> a2 = a(str, true);
            if (a2 != null && a2.containsKey(str2)) {
                Logger.d(e, "param " + str2 + " value is " + a2.get(str2));
                return a2.get(str2);
            }
            Logger.d(e, "map is null or does not contain param '" + str2 + "', url = " + str);
            return null;
        }
        return null;
    }

    public static String d(String str, String str2) {
        if (TextUtils.isEmpty(str2) || TextUtils.isEmpty(str)) {
            return null;
        }
        Map<String, String> a2 = a(str, true);
        if (a2 != null && a2.containsKey(str2)) {
            Logger.d(e, "param " + str2 + " value is " + a2.get(str2));
            return a2.get(str2);
        }
        Logger.d(e, "map is null or does not contain param  " + str2 + ", url = " + str);
        return null;
    }

    public static Map<String, String> a(String str, boolean z2) {
        LinkedHashMap linkedHashMap;
        String str2;
        try {
            if (!str.contains("?")) {
                return null;
            }
            linkedHashMap = new LinkedHashMap();
            try {
                for (String str3 : str.substring(str.indexOf("?") + 1).split("&")) {
                    int indexOf = str3.indexOf("=");
                    if (indexOf != -1) {
                        String substring = str3.substring(0, indexOf);
                        String decode = z2 ? URLDecoder.decode(substring, "UTF-8") : substring;
                        if (indexOf + 1 < str3.length()) {
                            str2 = str3.substring(indexOf + 1);
                            if (z2) {
                                str2 = URLDecoder.decode(str2, "UTF-8");
                            }
                        } else {
                            str2 = null;
                        }
                        linkedHashMap.put(decode, str2);
                    }
                }
                return linkedHashMap;
            } catch (UnsupportedEncodingException e2) {
                e = e2;
                Logger.e(e, "Exception in splitQuery, url = " + str, e);
                return linkedHashMap;
            } catch (Throwable th) {
                th = th;
                Logger.e(e, "Exception in splitQuery, url = " + str, th);
                return linkedHashMap;
            }
        } catch (UnsupportedEncodingException e3) {
            e = e3;
            linkedHashMap = null;
        } catch (Throwable th2) {
            th = th2;
            linkedHashMap = null;
        }
    }

    public static boolean c(String str) {
        String fileExtensionFromUrl = MimeTypeMap.getFileExtensionFromUrl(str);
        if (TextUtils.isEmpty(fileExtensionFromUrl)) {
            return false;
        }
        return l.contains(fileExtensionFromUrl);
    }

    public static boolean a(String str, Map<String, String> map) {
        String str2;
        boolean z2 = false;
        if (TextUtils.isEmpty(str) || str.startsWith("data:text/html")) {
            return false;
        }
        String fileExtensionFromUrl = MimeTypeMap.getFileExtensionFromUrl(str);
        if (fileExtensionFromUrl != null && fileExtensionFromUrl.length() > 0) {
            if (l.contains(fileExtensionFromUrl)) {
                Logger.d(e, "should include resource url extension match:" + str);
                return true;
            }
        } else {
            if (str.toLowerCase().startsWith(o.toLowerCase()) || str.toLowerCase().startsWith("text:".toLowerCase())) {
                Logger.d(e, "should include resource url prefix match :" + str);
                return true;
            }
            for (String str3 : com.safedk.android.analytics.brandsafety.creatives.e.a().get(com.safedk.android.analytics.brandsafety.creatives.e.d)) {
                if (str.contains(str3)) {
                    Logger.d(e, "should include resource url will be included (GENERAL_INCLUSION_LIST) : " + str);
                    return true;
                }
            }
        }
        if (str.startsWith("data:") || str.startsWith("about:")) {
            Logger.d(e, "should include resource url excluded : " + str);
            return false;
        }
        if (map != null) {
            Logger.d(e, "should include resource url headers : " + map.keySet());
            if (map.containsKey(b) && (str2 = map.get(b)) != null && str2.length() > 0 && (str2.contains(j) || E(str2) || F(str2))) {
                Logger.d(e, "should include resource url 'Accept' header contains resource mime types. url = " + str + " , Accept header value = " + str2 + ", should excluded? " + D(str));
                z2 = !D(str);
            }
        }
        return z2;
    }

    private static boolean D(String str) {
        for (String str2 : com.safedk.android.analytics.brandsafety.creatives.e.a().get(com.safedk.android.analytics.brandsafety.creatives.e.c)) {
            if (str.contains(str2)) {
                Logger.d(e, "url will be excluded (GENERAL_EXCLUSION_LIST) : " + str);
                return true;
            }
        }
        for (String str3 : com.safedk.android.analytics.brandsafety.creatives.e.a().get(com.safedk.android.analytics.brandsafety.creatives.e.b)) {
            if (str.contains(str3)) {
                Logger.d(e, "url will be excluded (ATTRIBUTION_URLS): " + str);
                return true;
            }
        }
        return false;
    }

    private static boolean E(String str) {
        Logger.d(e, "header contains image mime type, list: " + SafeDK.getInstance().p().toString());
        Iterator<String> it = SafeDK.getInstance().p().iterator();
        while (it.hasNext()) {
            if (str.contains("image/" + it.next())) {
                Logger.d(e, "header contains the image mime type");
                return true;
            }
        }
        return false;
    }

    private static boolean F(String str) {
        Logger.d(e, "header contains audio mime type, list: " + SafeDK.getInstance().q().toString());
        Iterator<String> it = SafeDK.getInstance().q().iterator();
        while (it.hasNext()) {
            if (str.contains("audio/" + it.next())) {
                Logger.d(e, "header contains the audio mime type");
                return true;
            }
        }
        return false;
    }

    public static String d(String str) {
        return String.format(Locale.ENGLISH, "https://www.youtube.com/watch?v=%s", str);
    }

    public static ArrayList<String> e(String str) {
        String replaceAll;
        new ArrayList();
        StringBuffer stringBuffer = new StringBuffer(str);
        try {
            b(e, "extract Urls from source with unicode unescape started, source length " + str.length());
            Matcher matcher = q.matcher(str);
            while (matcher.find()) {
                String substring = str.substring(matcher.start(), matcher.end());
                b(e, "extract Urls from source with unicode unescape, encoded unicode found  " + substring);
                stringBuffer.replace(matcher.start(), matcher.end(), l(substring));
            }
            b(e, "extract Urls from source with unicode unescape, unescapeUnicode  " + stringBuffer.toString());
            return f(replaceAll);
        } catch (Throwable th) {
            Logger.d(e, "Exception in extract Urls from source with unicode unescape, : " + th.getMessage(), th);
            return f(replaceAll);
        } finally {
            f(j(stringBuffer.toString()).replaceAll("\\/\\*(.*?)\\*\\/", ""));
        }
    }

    public static ArrayList<String> f(String str) {
        HashSet hashSet = new HashSet();
        if (str != null) {
            Matcher matcher = p.matcher(str);
            while (matcher.find()) {
                String replace = matcher.group(1).replace("\\/", "/");
                if (a((Object) replace)) {
                    b(e, "extract urls from html found url " + hashSet);
                    hashSet.add(replace);
                }
            }
            b(e, "extract urls from html found " + hashSet.toString());
        }
        return new ArrayList<>(hashSet);
    }

    public static ArrayList<String> g(String str) {
        ArrayList<String> arrayList = new ArrayList<>();
        if (str != null) {
            b(e, "extract urls from source with special chars " + r + ", source: " + str);
            Matcher matcher = r.matcher(str);
            while (matcher.find()) {
                String replace = matcher.group(1).replace("\\/", "/");
                Logger.v(e, "urls from source with special chars found " + replace);
                arrayList.add(replace);
            }
        }
        return arrayList;
    }

    public static ArrayList<String> h(String str) {
        ArrayList<String> arrayList = new ArrayList<>();
        if (str != null) {
            try {
                Logger.v(e, "extract base64 encoded resource from source. regex pattern : " + t);
                Matcher matcher = t.matcher(str);
                while (matcher.find()) {
                    String group = matcher.group(2);
                    int G = G(group);
                    Logger.v(e, "base64 encoded resource from source found. Hash =  " + G + " , resource = " + group);
                    arrayList.add(matcher.group(1) + CertificateUtil.DELIMITER + G);
                }
            } catch (Throwable th) {
                Logger.d(e, "Exception in base64 encoded resource extraction " + th.getMessage());
            }
        }
        return arrayList;
    }

    private static int G(String str) {
        int i2 = 0;
        if (str.length() == 0) {
            return 0;
        }
        int i3 = 0;
        while (true) {
            int i4 = i2;
            if (i3 >= str.length()) {
                return i4;
            }
            i2 = (str.charAt(i3) + ((i4 << 5) - i4)) | 0;
            i3++;
        }
    }

    public static String i(String str) {
        StringBuilder sb = new StringBuilder();
        int i2 = 0;
        while (i2 < str.length()) {
            char charAt = str.charAt(i2);
            i2++;
            if (charAt == '\\' && i2 < str.length()) {
                char charAt2 = str.charAt(i2);
                i2++;
                if (charAt2 == '\\' || charAt2 == '/' || charAt2 == '\"' || charAt2 == '\'') {
                    sb.append(charAt2);
                } else if (charAt2 == 'n') {
                    sb.append('\n');
                } else if (charAt2 == 'r') {
                    sb.append('\r');
                } else if (charAt2 == 't') {
                    sb.append('\t');
                } else if (charAt2 == 'b') {
                    sb.append('\b');
                } else if (charAt2 == 'f') {
                    sb.append('\f');
                } else if (charAt2 == 'u') {
                    StringBuilder sb2 = new StringBuilder();
                    if (i2 + 4 > str.length()) {
                        throw new RuntimeException("Not enough unicode digits! ");
                    }
                    for (char c2 : str.substring(i2, i2 + 4).toCharArray()) {
                        if (!Character.isLetterOrDigit(c2)) {
                            throw new RuntimeException("Bad character in unicode escape.");
                        }
                        sb2.append(Character.toLowerCase(c2));
                    }
                    i2 += 4;
                    sb.append((char) Integer.parseInt(sb2.toString(), 16));
                } else {
                    throw new RuntimeException("Illegal escape sequence: \\" + charAt2);
                }
            } else {
                sb.append(charAt);
            }
        }
        return sb.toString();
    }

    public static String j(String str) {
        if (!TextUtils.isEmpty(str)) {
            try {
                System.currentTimeMillis();
                String replace = m(k(str)).replace("&amp;", "&").replace("\\/", "/");
                while (replace.contains("&amp;")) {
                    replace = replace.replace("&amp;", "&");
                }
                while (replace.contains("&apos;")) {
                    replace = replace.replace("&apos;", "'");
                }
                while (replace.contains("&#39;")) {
                    replace = replace.replace("&#39;", "'");
                }
                while (replace.contains("&nbsp;")) {
                    replace = replace.replace("&nbsp;", " ");
                }
                if (replace.contains("[CDATA[") && replace.contains("&lt;") && replace.contains("&gt;") && replace.contains("&quot;")) {
                    int indexOf = replace.indexOf(com.safedk.android.analytics.brandsafety.creatives.e.e);
                    int lastIndexOf = replace.lastIndexOf("&quot;");
                    if (lastIndexOf != -1 && lastIndexOf > indexOf && !replace.substring(lastIndexOf).contains("[CDATA[")) {
                        replace = replace.substring(0, lastIndexOf);
                    }
                }
                return replace;
            } catch (Throwable th) {
                Logger.e(e, "exception in selective decode. input param is " + str + "' , error : " + th.getMessage());
                return str;
            }
        }
        return str;
    }

    public static String k(String str) {
        Matcher matcher = Pattern.compile("\\\\+u([0-9a-f]{4})").matcher(str);
        StringBuffer stringBuffer = new StringBuffer();
        while (matcher.find()) {
            matcher.appendReplacement(stringBuffer, String.valueOf((char) Integer.parseInt(matcher.group(1), 16)));
        }
        matcher.appendTail(stringBuffer);
        return stringBuffer.toString();
    }

    public static String l(String str) {
        if (!TextUtils.isEmpty(str)) {
            try {
                return str.replace("\\\\x21", "!").replace("\\\\x22", "\"").replace("\\\\x23", "#").replace("\\\\x24", "$").replace("\\\\x25", "%").replace("\\\\x26", "&").replace("\\\\x27", "'").replace("\\\\x28", "(").replace("\\\\x29", ")").replace("\\\\x2a", "*").replace("\\\\x2b", "+").replace("\\\\x2c", ",").replace("\\\\x2d", "-").replace("\\\\x2e", ".").replace("\\\\x2f", "/").replace("\\\\x3a", CertificateUtil.DELIMITER).replace("\\\\x3b", ";").replace("\\\\x3c", "<").replace("\\\\x3d", "=").replace("\\\\x3e", ">").replace("\\\\x3f", "?").replace("\\\\x40", "@").replace("\\\\x5b", "[").replace("\\\\x5d", "]").replace("\\x21", "!").replace("\\x22", "\"").replace("\\x23", "#").replace("\\x24", "$").replace("\\x25", "%").replace("\\x26", "&").replace("\\x27", "'").replace("\\x28", "(").replace("\\x29", ")").replace("\\x2a", "*").replace("\\x2b", "+").replace("\\x2c", ",").replace("\\x2f", "/").replace("\\x3a", CertificateUtil.DELIMITER).replace("\\x3b", ";").replace("\\x3c", "<").replace("\\x3d", "=").replace("\\x3e", ">").replace("\\x3f", "?").replace("\\x40", "@").replace("\\x5b", "[").replace("\\x5d", "]").replace("&amp;", "&");
            } catch (Throwable th) {
                Logger.e(e, "exception in unescapeUnicodeHex. input param is " + str + "' , error : " + th.getMessage());
                return str;
            }
        }
        return str;
    }

    public static String m(String str) {
        Matcher matcher = Pattern.compile("\\\\+x([0-9a-f]{2})").matcher(str);
        StringBuffer stringBuffer = new StringBuffer();
        while (matcher.find()) {
            matcher.appendReplacement(stringBuffer, String.valueOf((char) Integer.parseInt(matcher.group(1), 16)));
        }
        matcher.appendTail(stringBuffer);
        return stringBuffer.toString();
    }

    public static String a(Pattern pattern, String str, int i2) {
        Matcher matcher = pattern.matcher(str);
        if (!matcher.find() || matcher.groupCount() < i2) {
            return null;
        }
        return matcher.group(i2);
    }

    public static List<String> b(Pattern pattern, String str, int i2) {
        ArrayList arrayList = new ArrayList();
        Matcher matcher = pattern.matcher(str);
        while (matcher.find()) {
            arrayList.add(matcher.group(i2));
        }
        return arrayList;
    }

    public static List<String> a(Pattern pattern, String str) {
        ArrayList arrayList = new ArrayList();
        Matcher matcher = pattern.matcher(str);
        while (matcher.find()) {
            arrayList.add(matcher.group());
        }
        return arrayList;
    }

    public static List<MatchResult> b(Pattern pattern, String str) {
        ArrayList arrayList = new ArrayList();
        Matcher matcher = pattern.matcher(str);
        while (matcher.find()) {
            arrayList.add(matcher.toMatchResult());
        }
        return arrayList;
    }

    public static boolean c(Pattern pattern, String str) {
        Logger.d(e, "match exists for pattern: " + pattern.pattern());
        return pattern.matcher(str).find();
    }

    public static String d(Pattern pattern, String str) {
        Logger.d(e, "get match for pattern: " + pattern.pattern());
        Matcher matcher = pattern.matcher(str);
        if (!matcher.find() || matcher.groupCount() <= 0) {
            return null;
        }
        String group = matcher.group(1);
        Logger.d(e, "match for pattern: " + group);
        return group;
    }

    public static String e(String str, String str2) {
        return !str.contains("?") ? str : str.replaceFirst("(?<=[?&])" + str2 + "=.*?(&|$)", "").replaceFirst("[?&]$", "");
    }

    public static String n(String str) {
        return str.split("\\?")[0];
    }

    public static boolean o(String str) {
        return c(s, str);
    }

    public static String p(String str) {
        if (o(str)) {
            for (String str2 : x) {
                str = e(str, str2);
            }
        }
        return str;
    }

    public static View a(String str, String str2, View view) {
        View view2;
        try {
        } catch (Throwable th) {
            Logger.e(str, str2 + " exception in get absolute parent (input param is " + view + "' , error : " + th.getMessage());
            view2 = view;
        }
        if (view.getParent() != null) {
            ViewParent parent = view.getParent();
            Logger.d(str, str2 + " get absolute parent, new view parent : " + parent);
            ViewParent viewParent = parent;
            while (viewParent.getParent() != null) {
                ViewParent parent2 = viewParent.getParent();
                Logger.d(str, str2 + " get absolute parent, new parent : " + parent2);
                viewParent = parent2;
            }
            view2 = (View) viewParent;
            Logger.d(str, str2 + " get absolute parent returning " + view2);
            return view2;
        }
        return view;
    }

    public static boolean a(View view) {
        try {
        } catch (Throwable th) {
            Logger.e(e, "exception in get absolute parent (input param is " + view + "' , error : " + th.getMessage());
        }
        if (view.getParent() == null) {
            return false;
        }
        if (view instanceof MaxAdView) {
            return true;
        }
        ViewParent parent = view.getParent();
        if (parent instanceof MaxAdView) {
            return true;
        }
        while (parent.getParent() != null) {
            parent = parent.getParent();
            if (parent instanceof MaxAdView) {
                return true;
            }
        }
        return false;
    }

    public static void a(SortedMap<Integer, List<String>> sortedMap, int i2, String str) {
        if (!sortedMap.containsKey(Integer.valueOf(i2))) {
            ArrayList arrayList = new ArrayList();
            arrayList.add(str);
            sortedMap.put(Integer.valueOf(i2), arrayList);
            return;
        }
        sortedMap.get(Integer.valueOf(i2)).add(str);
    }

    public static boolean q(String str) {
        if (str == null) {
            return false;
        }
        try {
            Double.parseDouble(str);
            return true;
        } catch (NumberFormatException e2) {
            return false;
        } catch (Throwable th) {
            return false;
        }
    }

    public static boolean a(Object obj) {
        if (obj == null) {
            return false;
        }
        if (obj instanceof URL) {
            return true;
        }
        try {
            new URL((String) obj);
            return true;
        } catch (MalformedURLException e2) {
            return false;
        } catch (Throwable th) {
            return false;
        }
    }

    public static boolean r(String str) {
        String lowerCase = str.toLowerCase();
        return (lowerCase.contains("<div") && lowerCase.contains("</div>")) || (lowerCase.contains("<script>") && lowerCase.contains("</script>"));
    }

    public static boolean c() {
        return Looper.getMainLooper().getThread() == Thread.currentThread();
    }

    public static JSONObject a(Bundle bundle) {
        JSONObject jSONObject = new JSONObject();
        for (String str : bundle.keySet()) {
            try {
                Object obj = bundle.get(str);
                if (obj instanceof Bundle) {
                    jSONObject.put(str, a((Bundle) obj));
                } else {
                    jSONObject.put(str, obj);
                }
            } catch (JSONException e2) {
            }
        }
        return jSONObject;
    }

    public static String a(Intent intent) {
        if (intent == null) {
            return "";
        }
        StringBuilder append = new StringBuilder("action: ").append(intent.getAction()).append(" data: ").append(intent.getDataString()).append(" extras: ");
        if (intent.getExtras() != null) {
            for (String str : intent.getExtras().keySet()) {
                append.append(str).append("=").append(intent.getExtras().get(str)).append(" ");
            }
        }
        return append.toString();
    }

    public static boolean s(String str) {
        try {
            new JSONObject(str);
        } catch (JSONException e2) {
            try {
                new JSONArray(str);
            } catch (JSONException e3) {
                return false;
            }
        }
        return true;
    }

    public static String a(String str, String[] strArr) {
        if (strArr != null) {
            String str2 = str;
            for (String str3 : strArr) {
                Logger.d(e, "removing query param '" + str3 + "' from url " + str);
                str2 = e(str2, str3);
            }
            return str2;
        }
        return str;
    }

    public static boolean t(String str) {
        if (str == null) {
            return false;
        }
        for (String str2 : A.keySet()) {
            if (str.startsWith(str2) || str.startsWith(A.get(str2))) {
                return true;
            }
        }
        return false;
    }

    public static String u(String str) {
        for (String str2 : A.keySet()) {
            if (str.startsWith(str2)) {
                return str.replace(str2, A.get(str2));
            }
        }
        return str;
    }

    public static String v(String str) {
        int indexOf;
        for (String str2 : A.keySet()) {
            if (str.startsWith(str2)) {
                String replace = str.replace(str2, "");
                int indexOf2 = replace.indexOf(63);
                if (indexOf2 < 0) {
                    indexOf2 = replace.indexOf(38);
                }
                if (indexOf2 > 0) {
                    return str2 + replace.substring(0, indexOf2);
                }
                return str;
            }
            if (str.startsWith(A.get(str2)) && (indexOf = str.indexOf(38)) > 0) {
                str = str.substring(0, indexOf);
            }
        }
        return str;
    }

    public static boolean w(String str) {
        if (str == null) {
            return false;
        }
        boolean z2 = false;
        for (String str2 : y) {
            if (str.toLowerCase().endsWith(str2)) {
                z2 = true;
            }
        }
        Logger.d(e, "is video media uri returned " + z2 + " for url = " + str);
        return z2;
    }

    public static boolean x(String str) {
        Logger.d(e, "isBinaryUrlExtension started, url = " + str);
        boolean z2 = false;
        for (String str2 : z) {
            if (str.endsWith(str2)) {
                Logger.d(e, "is binary url extension returned true for url = " + str);
                z2 = true;
            }
        }
        return z2;
    }

    public static String d() {
        return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS", Locale.getDefault()).format(new Date());
    }

    public static String e() {
        return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS", Locale.getDefault()).format(new Date());
    }

    public static String a(Date date) {
        return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS", Locale.getDefault()).format(date);
    }

    public static String y(String str) {
        try {
            Date date = new Date(new File(str).lastModified());
            if (date != null) {
                return a(date);
            }
        } catch (Throwable th) {
            Logger.d(e, "Error extracting file last modified date from file " + str + " : " + th.getMessage(), th);
        }
        return "NA";
    }

    public static String a(byte[] bArr) {
        StringBuffer stringBuffer = new StringBuffer();
        for (byte b2 : bArr) {
            String hexString = Integer.toHexString(b2 & 255);
            if (hexString.length() == 1) {
                stringBuffer.append('0');
            }
            stringBuffer.append(hexString);
        }
        return stringBuffer.toString();
    }

    public static boolean a(String str, List<String> list) {
        if (str != null && list != null) {
            Iterator<String> it = list.iterator();
            while (it.hasNext()) {
                if (str.contains(it.next())) {
                    return true;
                }
            }
        }
        return false;
    }

    public static boolean z(String str) {
        Iterator<String> it = u.iterator();
        while (it.hasNext()) {
            if (str.endsWith(it.next())) {
                return true;
            }
        }
        return false;
    }

    public static boolean A(String str) {
        Iterator<String> it = v.iterator();
        while (it.hasNext()) {
            if (str.endsWith(it.next())) {
                return true;
            }
        }
        return false;
    }

    public static boolean a(float f2, float f3) {
        if (f3 == 0.0f || f2 == 0.0f) {
            Logger.d(e, "Banner ratio height/width cannot be 0");
            return false;
        }
        float f4 = f2 / f3;
        Logger.d(e, "Banner ratio: " + f4);
        return (((double) f4) >= 6.0d && ((double) f4) <= 8.4d) || (((double) f4) >= 12.0d && ((double) f4) <= 15.0d);
    }

    public static boolean b(float f2, float f3) {
        if (f3 == 0.0f || f2 == 0.0f) {
            Logger.d(e, "MREC ratio height/width cannot be 0");
            return false;
        }
        float f4 = f2 / f3;
        Logger.d(e, "MREC ratio: " + f4);
        return ((double) f4) >= 1.1d && ((double) f4) <= 1.3d;
    }

    public static boolean b(View view) {
        Logger.d(e, "is webview inside max ad view: " + view);
        if (view.getParent() != null) {
            ViewParent parent = view.getParent();
            while (parent != null) {
                Logger.d(e, "is webview inside max ad view, view parent: " + parent);
                if (parent instanceof MaxAdView) {
                    Logger.d(e, "is webview inside max ad view, max ad view found: " + parent);
                    return true;
                }
                if (parent.getParent() != null) {
                    parent = parent.getParent();
                }
            }
        }
        return false;
    }

    public static boolean b(String str, Map<String, String> map) {
        String str2;
        Logger.d(e, "contains accept video header or has video extension, url: " + str + ", headers: " + map);
        if (map != null && map.containsKey(b) && (str2 = map.get(b)) != null && str2.length() > 0 && str2.contains(j)) {
            Logger.d(e, "identified video header, url: " + str + ", headers: " + map);
            return true;
        }
        if (str != null && A(str)) {
            Logger.d(e, "identified video extension, url: " + str);
            return true;
        }
        return false;
    }

    public static String a(String str, Pattern pattern, int i2, String str2) {
        Stack stack = new Stack();
        Stack stack2 = new Stack();
        Matcher matcher = pattern.matcher(str);
        while (matcher.find()) {
            stack.push(Integer.valueOf(matcher.start(i2)));
            stack2.push(Integer.valueOf(matcher.end(i2)));
        }
        StringBuilder sb = new StringBuilder(str);
        while (!stack.isEmpty()) {
            int intValue = ((Integer) stack.pop()).intValue();
            int intValue2 = ((Integer) stack2.pop()).intValue();
            if (intValue >= 0 && intValue2 >= 0) {
                Logger.d(e, "replacing text of matching group. removing :  " + str.substring(intValue, intValue2));
                sb.replace(intValue, intValue2, str2);
            }
        }
        return sb.toString();
    }

    public static String B(String str) {
        try {
            String decode = URLDecoder.decode(str, "UTF-8");
            if (!decode.contains("?") || str.indexOf("%3F") <= -1) {
                return str;
            }
            return decode.indexOf("?") <= str.indexOf("%3F") ? decode : str;
        } catch (Throwable th) {
            Logger.d(e, "Exception decoding url " + str + " : " + th.getMessage(), th);
            return str;
        }
    }
}