Puzzle King v2.3.8版本的 MD5 值为:1734eb975c9d2843afa462aec387292e
以下内容为反编译后的 k.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.Base64;
import android.util.DisplayMetrics;
import android.view.View;
import android.view.ViewParent;
import android.webkit.MimeTypeMap;
import android.webkit.WebView;
import com.applovin.mediation.ads.MaxAdView;
import com.bytedance.sdk.openadsdk.api.init.PAGSdk;
import com.facebook.internal.security.CertificateUtil;
import com.mbridge.msdk.foundation.download.core.DownloadCommon;
import com.mbridge.msdk.playercommon.exoplayer2.C;
import com.mbridge.msdk.playercommon.exoplayer2.source.chunk.ChunkedTrackBlacklistUtil;
import com.mbridge.msdk.playercommon.exoplayer2.text.ttml.TtmlNode;
import com.safedk.android.SafeDK;
import com.safedk.android.analytics.brandsafety.BrandSafetyUtils;
import com.safedk.android.analytics.brandsafety.creatives.infos.CreativeInfo;
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.ref.WeakReference;
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.Collection;
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.concurrent.ConcurrentHashMap;
import java.util.regex.MatchResult;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import kotlin.UByte;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
public class k {
public static final String a = "UNKNOWN_PROCESS";
public static final String b = "Accept";
public static final String c = "text:";
public static final String d = "java.lang.String";
private static final String f = "Utils";
private static boolean g = false;
private static final String i = "com.applovin.sdk.AppLovinSdk";
private static final String j = "VERSION";
private static final String k = "video/";
private static final String p = "https://www.youtube.com/watch?v=";
private static String s = null;
private static final String w = "market://details?id=";
private static final String x = "amzn://apps/android?p=";
private static final String y = "samsungapps://ProductDetail/";
private static final String z = "http://play.google.com/store/apps/details?id=";
private static boolean h = false;
private static final String[] l = {"jpg", "jpeg", "gif", "png", "mp4", "m4v", "js", "css", CreativeInfo.al, "mkv", "3gp", "3gpp", "webm", "mp3", "htm", "svg", "3g2", "avi", "mpg", "mpeg", "mov", DownloadCommon.DOWNLOAD_REPORT_QUERY_TIMEOUT, "zip", "webp"};
private static final HashSet<String> m = new HashSet<>(Arrays.asList(l));
private static final String[] n = {"image"};
private static final HashSet<String> o = new HashSet<>(Arrays.asList(n));
private static final List<String> q = Arrays.asList("gif", "jpg", "jpeg", "png", "bmp");
private static final List<String> r = Arrays.asList("mp4", "m4v", "webm", "avi", "mpg", "mpeg", "mov", DownloadCommon.DOWNLOAD_REPORT_QUERY_TIMEOUT, "3gp", "3gpp");
static Map<String, String> e = 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[] t = {"expire", "ei", "sig", "lsig", "mt", "lmt", "cpn"};
private static final String[] u = {"mp4", "m4v", "mkv", "3gp", "3gpp", "webm", "mov", "webp"};
private static final String[] v = {"jpg", "jpeg", "gif", "png", "mp4", "m4v", "mkv", "3gp", "3gpp", "webm", "mp3", "htm", "js", "css", CreativeInfo.al, "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(w, "https://play.google.com/store/apps/details?id=");
A.put(x, "https://www.amazon.com/gp/mas/dl/android?p=");
A.put(y, "https://www.samsungapps.com/appquery/appDetail.as?appId=");
A.put(z, z);
}
public static String a() {
if (s == null) {
s = a(i, j);
}
return s;
}
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(f, "Failed to get reflection field:" + str);
return obj2;
} catch (Exception e3) {
Logger.e(f, "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(f, "Error retrieving field value. Class name :" + str + ", field name :" + str2, e2);
return null;
} catch (IllegalAccessException e3) {
Logger.e(f, "Error retrieving field value. Class name :" + str + ", field name :" + str2, e3);
return null;
} catch (IllegalArgumentException e4) {
Logger.e(f, "Error retrieving field value. Class name :" + str + ", field name :" + str2, e4);
return null;
} catch (NoSuchFieldException e5) {
Logger.e(f, "Error retrieving field value. Class name :" + str + ", field name :" + str2, e5);
return null;
} catch (SecurityException e6) {
Logger.e(f, "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(f, "failed sort. first: " + statsEvent + " second: " + statsEvent2);
Logger.e(f, "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, C.UTF8_NAME);
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(f, "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 a;
}
return str;
}
public static String a(String str) {
String str2 = e.get(str);
return TextUtils.isEmpty(str2) ? F(str) : str2;
}
private static String F(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(f, "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(f, "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(f, "exception while parsing map to JSON object", e2);
return null;
}
}
public static void b(String str, String str2) {
int length = str2.length() / PAGSdk.INIT_LOCAL_FAIL_CODE;
for (int i2 = 0; i2 <= length; i2++) {
int i3 = (i2 + 1) * PAGSdk.INIT_LOCAL_FAIL_CODE;
if (i3 >= str2.length()) {
i3 = str2.length();
}
Logger.v(str, str2.substring(i2 * PAGSdk.INIT_LOCAL_FAIL_CODE, i3));
}
}
public static String c(String str, String str2) {
try {
} catch (Throwable th) {
Logger.e(f, "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(f, "param " + str2 + " value is " + a2.get(str2));
return a2.get(str2);
}
Logger.d(f, "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(f, "param " + str2 + " value is " + a2.get(str2));
return a2.get(str2);
}
Logger.d(f, "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, C.UTF8_NAME) : substring;
if (indexOf + 1 < str3.length()) {
str2 = str3.substring(indexOf + 1);
if (z2) {
str2 = URLDecoder.decode(str2, C.UTF8_NAME);
}
} else {
str2 = null;
}
linkedHashMap.put(decode, str2);
}
}
return linkedHashMap;
} catch (UnsupportedEncodingException e2) {
e = e2;
Logger.e(f, "Exception in splitQuery, url = " + str, e);
return linkedHashMap;
} catch (Throwable th) {
th = th;
Logger.e(f, "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 m.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 (m.contains(fileExtensionFromUrl)) {
Logger.d(f, "should include resource url extension match:" + str);
return true;
}
} else {
if (str.toLowerCase().startsWith(p.toLowerCase()) || str.toLowerCase().startsWith("text:".toLowerCase())) {
Logger.d(f, "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(f, "should include resource url will be included (GENERAL_INCLUSION_LIST) : " + str);
return true;
}
}
}
if (str.startsWith("data:") || str.startsWith("about:")) {
Logger.d(f, "should include resource url excluded : " + str);
return false;
}
if (map != null) {
Logger.d(f, "should include resource url headers : " + map.keySet());
if (map.containsKey(b) && (str2 = map.get(b)) != null && str2.length() > 0 && (str2.contains(k) || H(str2) || I(str2))) {
Logger.d(f, "should include resource url 'Accept' header contains resource mime types. url = " + str + " , Accept header value = " + str2 + ", should excluded? " + G(str));
z2 = !G(str);
}
}
return z2;
}
private static boolean G(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(f, "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(f, "url will be excluded (ATTRIBUTION_URLS): " + str);
return true;
}
}
return false;
}
private static boolean H(String str) {
Logger.d(f, "header contains image mime type, list: " + SafeDK.getInstance().t().toString());
Iterator<String> it = SafeDK.getInstance().t().iterator();
while (it.hasNext()) {
if (str.contains("image/" + it.next())) {
Logger.d(f, "header contains the image mime type");
return true;
}
}
return false;
}
private static boolean I(String str) {
Logger.d(f, "header contains audio mime type, list: " + SafeDK.getInstance().u().toString());
Iterator<String> it = SafeDK.getInstance().u().iterator();
while (it.hasNext()) {
if (str.contains("audio/" + it.next())) {
Logger.d(f, "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(f, "extract Urls from source with unicode unescape started, source length " + str.length());
Matcher matcher = f.A().matcher(str);
while (matcher.find()) {
String substring = str.substring(matcher.start(), matcher.end());
b(f, "extract Urls from source with unicode unescape, encoded unicode found " + substring);
stringBuffer.replace(matcher.start(), matcher.end(), l(substring));
}
b(f, "extract Urls from source with unicode unescape, unescapeUnicode " + stringBuffer.toString());
return f(replaceAll);
} catch (Throwable th) {
Logger.d(f, "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 = f.B().matcher(str);
while (matcher.find()) {
String replace = matcher.group(1).replace("\\/", "/");
if (a((Object) replace)) {
b(f, "extract urls from html found url: " + replace);
hashSet.add(replace);
}
}
b(f, "extract urls from html found: " + hashSet);
}
return new ArrayList<>(hashSet);
}
public static ArrayList<String> g(String str) {
ArrayList<String> arrayList = new ArrayList<>();
if (str != null) {
b(f, "extract urls from source with special chars: , source: " + str);
Matcher matcher = f.z().matcher(str);
while (matcher.find()) {
String replace = matcher.group(1).replace("\\/", "/");
Logger.v(f, "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(f, "extract base64 encoded resource from source. regex pattern: " + f.x());
Matcher matcher = f.x().matcher(str);
while (matcher.find()) {
String group = matcher.group(2);
int J = J(group);
Logger.v(f, "base64 encoded resource from source found. Hash: " + J + " , resource: " + group);
arrayList.add(matcher.group(1) + CertificateUtil.DELIMITER + J);
}
} catch (Throwable th) {
Logger.d(f, "Exception in base64 encoded resource extraction " + th.getMessage());
}
}
return arrayList;
}
private static int J(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("&", "&").replace("\\/", "/");
while (replace.contains("&")) {
replace = replace.replace("&", "&");
}
while (replace.contains("'")) {
replace = replace.replace("'", "'");
}
while (replace.contains("'")) {
replace = replace.replace("'", "'");
}
while (replace.contains(" ")) {
replace = replace.replace(" ", " ");
}
if (replace.contains("[CDATA[") && replace.contains("<") && replace.contains(">") && replace.contains(""")) {
int indexOf = replace.indexOf(com.safedk.android.analytics.brandsafety.creatives.e.e);
int lastIndexOf = replace.lastIndexOf(""");
if (lastIndexOf != -1 && lastIndexOf > indexOf && !replace.substring(lastIndexOf).contains("[CDATA[")) {
replace = replace.substring(0, lastIndexOf);
}
}
return replace;
} catch (Throwable th) {
Logger.e(f, "exception in selective decode. input param is " + str + "' , error : " + th.getMessage());
return str;
}
}
return str;
}
public static String k(String str) {
Matcher matcher = f.w().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("&", "&");
} catch (Throwable th) {
Logger.e(f, "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<Integer> b(Pattern pattern, String str) {
ArrayList arrayList = new ArrayList();
Matcher matcher = pattern.matcher(str);
while (matcher.find()) {
arrayList.add(Integer.valueOf(matcher.start()));
}
return arrayList;
}
public static List<MatchResult> c(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 d(Pattern pattern, String str) {
Logger.d(f, "match exists for pattern: " + pattern.pattern());
return pattern.matcher(str).find();
}
public static String e(Pattern pattern, String str) {
Logger.d(f, "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(f, "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 d(f.y(), str);
}
public static String p(String str) {
if (o(str)) {
for (String str2 : t) {
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(f, "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 String a(String str, int i2) {
int i3 = 0;
int indexOf = str.indexOf("<div", i2);
int indexOf2 = str.indexOf("</div", i2);
int i4 = i2;
while (i4 < str.length()) {
if (indexOf < indexOf2) {
i3++;
i4 = indexOf + 1;
indexOf = str.indexOf("<div", i4);
} else {
i3--;
i4 = indexOf2 + 1;
if (i3 == 0) {
return str.substring(i2, indexOf2);
}
indexOf2 = str.indexOf("</div", i4);
}
}
return null;
}
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(f, "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 : u) {
str = n(str);
if (str.toLowerCase().endsWith("." + str2)) {
z2 = true;
}
}
Logger.d(f, "is video media uri returned " + z2 + " for url = " + str);
return z2;
}
public static boolean x(String str) {
Logger.d(f, "isBinaryUrlExtension started, url = " + str);
boolean z2 = false;
for (String str2 : v) {
if (str.endsWith(str2)) {
Logger.d(f, "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(f, "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 & UByte.MAX_VALUE);
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 = q.iterator();
while (it.hasNext()) {
if (str.endsWith(it.next())) {
return true;
}
}
return false;
}
public static boolean A(String str) {
Iterator<String> it = r.iterator();
while (it.hasNext()) {
if (str.endsWith(it.next())) {
return true;
}
}
return false;
}
public static boolean a(float f2, float f3) {
boolean z2 = false;
if (f3 == 0.0f || f2 == 0.0f) {
Logger.d(f, "Banner ratio height/width cannot be 0");
} else {
float f4 = f2 / f3;
if ((f4 >= 6.0d && f4 <= 8.4d) || (f4 >= 12.0d && f4 <= 15.0d)) {
z2 = true;
}
Logger.d(f, "Banner ratio: " + f4 + " " + z2);
}
return z2;
}
public static boolean b(float f2, float f3) {
boolean z2 = false;
if (f3 == 0.0f || f2 == 0.0f) {
Logger.d(f, "MREC ratio height/width cannot be 0");
} else {
float f4 = f2 / f3;
if (f4 >= 1.1d && f4 <= 1.3d) {
z2 = true;
}
Logger.d(f, "MREC ratio: " + f4 + " " + z2);
}
return z2;
}
public static boolean b(View view) {
Logger.d(f, "is webview inside max ad view: " + view);
if (view.getParent() != null) {
ViewParent parent = view.getParent();
while (parent != null) {
Logger.d(f, "is webview inside max ad view, view parent: " + parent);
if (parent instanceof MaxAdView) {
Logger.d(f, "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(f, "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(k)) {
Logger.d(f, "identified video header, url: " + str + ", headers: " + map);
return true;
}
if (str != null && A(str)) {
Logger.d(f, "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(f, "replacing text of matching group. removing : " + str.substring(intValue, intValue2));
sb.replace(intValue, intValue2, str2);
}
}
return sb.toString();
}
public static String B(String str) {
if (str != null) {
try {
String decode = URLDecoder.decode(str, C.UTF8_NAME);
if (decode.contains("?") && str.contains("%3F")) {
return decode.indexOf("?") <= str.indexOf("%3F") ? decode : str;
}
return str;
} catch (Throwable th) {
Logger.d(f, "Exception decoding url " + str + " : " + th.getMessage());
return str;
}
}
return str;
}
public static String C(String str) {
if (str != null && str.length() != 0) {
return str.replace(" ", " ").replace(""", "\"").replace("'", "'").replace("'", "'").replace("<", "<").replace(">", ">").replace("&", "&").replaceAll("<\\s*?" + TtmlNode.TAG_BR + "\\s*?/\\s*?>", "\n").replaceAll("<\\s*?" + TtmlNode.TAG_SPAN + "\\s+?style\\s*?=\\s*?\"white-space:pre\"\\s*?>	<\\s*?/\\s*?" + TtmlNode.TAG_SPAN + "\\s*?>", "\t");
}
return str;
}
public static String D(String str) {
if (str != null && str.length() != 0) {
try {
return new String(Base64.decode(str, 0));
} catch (IllegalArgumentException e2) {
Logger.d(f, "base64Decoder - failed to Base64 decode buffer (decoded): " + e2.getMessage());
return str;
}
}
return str;
}
public static boolean E(String str) {
if (str.contains(com.safedk.android.analytics.brandsafety.creatives.discoveries.h.u) && str.contains(com.safedk.android.analytics.brandsafety.creatives.discoveries.h.v) && str.contains(CertificateUtil.DELIMITER) && str.contains("\"")) {
return s(str);
}
return false;
}
public static boolean a(Collection<?> collection) {
return collection == null || collection.size() == 0;
}
public static String a(ConcurrentHashMap<?, WeakReference<WebView>> concurrentHashMap, boolean z2) {
StringBuilder sb = new StringBuilder(com.safedk.android.analytics.brandsafety.creatives.discoveries.h.u);
Iterator<Map.Entry<?, WeakReference<WebView>>> it = concurrentHashMap.entrySet().iterator();
int i2 = 0;
while (true) {
int i3 = i2;
if (i3 < concurrentHashMap.size()) {
Map.Entry<?, WeakReference<WebView>> next = it.next();
sb.append(next.getKey()).append("=");
if (next.getValue() != null && next.getValue().get() != null) {
if (z2) {
sb.append(BrandSafetyUtils.a(next.getValue().get()));
} else {
sb.append(next.getValue().get().toString());
}
} else {
sb.append("null");
}
if (i3 < concurrentHashMap.size() - 1) {
sb.append(", ");
}
i2 = i3 + 1;
} else {
return sb.append(com.safedk.android.analytics.brandsafety.creatives.discoveries.h.v).toString();
}
}
}
public static ArrayList<String> a(Collection<String> collection, int i2) {
return a(collection, 0, i2);
}
public static ArrayList<String> a(Collection<String> collection, int i2, int i3) {
ArrayList<String> arrayList = new ArrayList<>();
Iterator<String> it = collection.iterator();
while (it.hasNext()) {
arrayList.add(it.next().substring(i2, i3));
}
return arrayList;
}
}