Cyber Surfer v5.2.5版本的 MD5 值为:db13c5fce988de393e52d2679f934b22
以下内容为反编译后的 l.java 源代码,内容仅作参考
package com.safedk.android.analytics.brandsafety.creatives.discoveries;
import android.net.Uri;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Base64;
import com.google.android.exoplayer2.text.ttml.TtmlNode;
import com.mbridge.msdk.foundation.entity.CampaignUnit;
import com.safedk.android.analytics.brandsafety.BrandSafetyUtils;
import com.safedk.android.analytics.brandsafety.RedirectDetails;
import com.safedk.android.analytics.brandsafety.creatives.AdNetworkConfiguration;
import com.safedk.android.analytics.brandsafety.creatives.AdNetworkDiscovery;
import com.safedk.android.analytics.brandsafety.creatives.CreativeInfoManager;
import com.safedk.android.analytics.brandsafety.creatives.discoveries.c;
import com.safedk.android.analytics.brandsafety.creatives.infos.CreativeInfo;
import com.safedk.android.analytics.brandsafety.creatives.infos.VungleCreativeInfo;
import com.safedk.android.analytics.events.BrandSafetyEvent;
import com.safedk.android.utils.Logger;
import com.safedk.android.utils.PersistentConcurrentHashMap;
import java.io.File;
import java.security.InvalidParameterException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
public class l extends d {
private static final String A = "id";
private static final String B = "campaign";
private static final String C = "callToActionDest";
private static final String D = "callToActionUrl";
private static final String E = "info";
private static final String F = "impression auctioned but unsold";
private static final String G = "url";
private static final String H = "showCloseIncentivized";
private static final int I = 9999;
private static final String J = "placement_reference_id";
private static final String K = "templateSettings";
private static final String L = "cacheable_replacements";
private static final String M = "MAIN_VIDEO";
private static final String N = "postBundle";
private static final String O = "templateURL";
private static final String P = "template_type";
private static final String Q = "expiry";
private static final String R = "com.applovin.mediation.adapters.VungleMediationAdapter";
private static final String S = "adType";
private static final String T = "banner";
private static final String U = "mrec";
private static final String V = "native";
private static final String W = "placements";
private static final String X = "reference_id";
private static final String Y = "is_incentivized";
private static final String Z = "tpat";
private static final String aa = "templateSettings";
private static final String ab = "normal_replacements";
private static final String ac = "clickUrl";
private static final String ad = "ad_market_id";
private static final String ae = "CTA_BUTTON_URL";
private static final String af = "EC_CTA_URL";
private static final String ag = "https://privacy.vungle.com/";
private static final String ah = "vungle.com";
private static final String ai = "adunit";
private static PersistentConcurrentHashMap<String, VungleCreativeInfo> aj = null;
private static PersistentConcurrentHashMap<Integer, VungleCreativeInfo> ak = null;
private static PersistentConcurrentHashMap<String, VungleCreativeInfo> al = null;
private static PersistentConcurrentHashMap<String, Boolean> am = null;
private static final long an = 259200000;
public static final String f9332b = "MAIN_VIDEO.mp4";
public static final String c = "ad_markup";
public static final String d = "com.vungle.warren.BuildConfig";
public static final String e = "VERSION_NAME";
public static final String f = "ADM_HTML";
public static final String g = "adx.ads.vungle.com/api/v5/ads";
public static final String h = "api.vungle.com/api/v4/requestAd";
public static final String i = "api.vungle.com/api/v5/ads";
public static final String u = "adx-stage.ads.vungle.com/api/v5/ads";
public static final String v = "api.vungle.com/config";
public static final String w = "(function(){var sdkId=\"{{SDK_ID}}\";var address=\"{{ADDRESS}}\";var log=function(message){try{console.log(\"log privacy policy sdkId : \"+sdkId+\",address = \"+address+\", msg : \"+message);window.webkit.messageHandlers.safedkDebug.postMessage(\"Vungle-Liftoff detect privacy ,address \"+address+\" : \"+message)}catch(error){console.log(\"log : \"+error)}};log(\"script started sdkId = \"+sdkId+\", address = \"+address);var addPrivacyObservers=function(){try{log(\"trying with DIALOGBOX\");var dialogboxElement=document.getElementById(\"DIALOGBOX\");if(!dialogboxElement){log(\"trying again with privacy-dialog\");dialogboxElement=document.getElementById(\"privacy-dialog\")}if(!dialogboxElement){log(\"trying again with privacy-popup\");dialogboxElement=document.getElementById(\"privacy-popup\")}if(!dialogboxElement){log(\"trying again with privacy-popup by class \");var elements=document.querySelectorAll(\"div#privacy-popup\");if(elements&&elements.length>0){log(\"found by class : \"+JSON.stringify(elements[0]));dialogboxElement=elements[0]}}log(\"dialogboxElement = \"+dialogboxElement);try{log(\"dialogboxElement = \"+JSON.stringify(dialogboxElement))}catch(error){log(\"dialogboxElement error \"+error)}if(dialogboxElement.hasAttribute(\"id\")){log(\"dialogboxElement.id ? \"+dialogboxElement.id)}if(dialogboxElement.hasAttribute(\"aria-hidden\")){log(\"dialogboxElement.aria-hidden ? \"+dialogboxElement.getAttribute(\"aria-hidden\"))}if(dialogboxElement&&(dialogboxElement.style&&dialogboxElement.style.visibility||dialogboxElement.hasAttribute(\"id\")&&dialogboxElement.id==\"privacy-popup\")){log(\"found element \"+JSON.stringify(dialogboxElement));var element_style_visibility=dialogboxElement.style&&dialogboxElement.style.visibility||dialogboxElement.hasAttribute(\"id\")&&dialogboxElement.id==\"privacy-popup\"&&dialogboxElement.classList.contains(\"ytoTpW_show\");if(element_style_visibility){window.webkit.messageHandlers.safedkNoSampling.postMessage(sdkId,address,window.outerHeight,window.outerWidth);log(\"element is visible\")}else{log(\"element is not visible\");{dialogboxElement.safedkPrivacyDialogObserver=true;try{var MutationObserver=window.WebKitMutationObserver||window.MutationObserver;var observer=new MutationObserver(function(mutations){mutations.forEach(function(mutation){switch(mutation.type){case\"attributes\":log(\"Attribute name \"+mutation.attributeName+\" changed to \"+getComputedStyle(mutation.target).visibility+\" (was \"+mutation.oldValue+\")\");if(getComputedStyle(mutation.target).visibility==\"visible\"||mutation.target.classList.contains(\"ytoTpW_show\")){log(\"privacy dialog is visible \");window.webkit.messageHandlers.safedkNoSampling.postMessage(sdkId,address,window.outerHeight,window.outerWidth)}break}})});var config={attributes:true,attributeOldValue:true};observer.observe(dialogboxElement,config)}catch(error){window.webkit.messageHandlers.safedkNoSamplingExc.postMessage(\"address = \"+address+\" \"+error.message+\"\\n\"+error.stack);log(\"Error : \"+\"address = \"+address+\" \"+error.message+\"\\n\"+error.stack)}}}}else{var privacyPageElement=document.getElementById(\"privacy-page\");if(privacyPageElement){var privacyPageParentElement=privacyPageElement.parentElement;if(privacyPageParentElement){var computedStyle=getComputedStyle(privacyPageParentElement);if(computedStyle){var displayState=computedStyle.display;if(displayState!=\"none\"){window.webkit.messageHandlers.safedkNoSampling.postMessage(sdkId,address,window.outerHeight,window.outerWidth)}else{{privacyPageParentElement.safedkPrivacyDialogObserver=true;try{var MutationObserver=window.WebKitMutationObserver||window.MutationObserver;var observer=new MutationObserver(function(mutations){mutations.forEach(function(mutation){switch(mutation.type){case\"attributes\":if(mutation.target.style.display!=\"none\"){window.webkit.messageHandlers.safedkNoSampling.postMessage(sdkId,address,window.outerHeight,window.outerWidth)}break}})});var config={attributes:true,attributeOldValue:true,childList:true,subtree:true};observer.observe(privacyPageParentElement,config)}catch(error){window.webkit.messageHandlers.safedkNoSamplingExc.postMessage(\"address = \"+address+\" \"+error.message+\"\\n\"+error.stack)}}}}}}}}catch(error){log(\"caught exception with error = \"+error+\", stack : \"+error.stack);window.webkit.messageHandlers.safedkNoSamplingExc.postMessage(\"address = \"+address+\" \"+error.message+\"\\n\"+error.stack)}};var addAdClosureObservers=function(){try{log(\"trying with incentivized-dialog\");var dialogboxElement=document.getElementById(\"incentivized-dialog\");if(dialogboxElement&&dialogboxElement.style&&dialogboxElement.style.visibility){log(\"found element \");var element_style_visibility=dialogboxElement.style.visibility;if(element_style_visibility==\"visible\"){window.webkit.messageHandlers.safedkNoSampling.postMessage(sdkId,address,window.outerHeight,window.outerWidth);log(\"element is visible\")}else{log(\"element is not visible\");if(dialogboxElement.safedkPrivacyDialogObserver!=true){dialogboxElement.safedkPrivacyDialogObserver=true;try{var MutationObserver=window.WebKitMutationObserver||window.MutationObserver;var observer=new MutationObserver(function(mutations){mutations.forEach(function(mutation){switch(mutation.type){case\"attributes\":if(getComputedStyle(mutation.target).visibility==\"visible\"){window.webkit.messageHandlers.safedkNoSampling.postMessage(sdkId,address,window.outerHeight,window.outerWidth)}log(\"Attribute name \"+mutation.attributeName+\" changed to \"+getComputedStyle(mutation.target).visibility+\" (was \"+mutation.oldValue+\")\");break}})});var config={attributes:true,attributeOldValue:true,attributeFilter:[\"style\"]};observer.observe(dialogboxElement,config)}catch(error){window.webkit.messageHandlers.safedkNoSamplingExc.postMessage(\"address = \"+address+\" \"+error.message+\"\\n\"+error.stack);log(\"Error : \"+\"address = \"+address+\" \"+error.message+\"\\n\"+error.stack)}}}}}catch(error){log(\"caught exception with error = \"+error);window.webkit.messageHandlers.safedkNoSamplingExc.postMessage(\"address = \"+address+\" \"+error.message+\"\\n\"+error.stack)}};var monitorNotifications=function(){try{var divIds=[\"ad-notification-modal\",\"gdpr-notification-view\"];for(var divId of divIds){var element=document.getElementById(divId);if(element){var className=element.className;if(element.className.endsWith(\"show\")){log(\"element.className = \"+element.className);window.webkit.messageHandlers.safedkNoSampling.postMessage(sdkId,address,window.outerHeight,window.outerWidth)}else{if(element.safedkVisibilityObserver!=true){element.safedkVisibilityObserver=true;try{var MutationObserver=window.WebKitMutationObserver||window.MutationObserver;var observer=new MutationObserver(function(mutations){mutations.forEach(function(mutation){if(mutation.type==\"attributes\"){if(mutation.target.className.endsWith(\"show\")){window.webkit.messageHandlers.safedkNoSampling.postMessage(sdkId,address,window.outerHeight,window.outerWidth)}}})});var config={attributes:true,attributeOldValue:true,attributeFilter:[\"class\"]};observer.observe(element,config)}catch(error){window.webkit.messageHandlers.safedkNoSamplingExc.postMessage(\"address = \"+address+\" \"+error.message+\"\\n\"+error.stack)}}}}}}catch(error){log(\"caught exception with error = \"+error);window.webkit.messageHandlers.safedkNoSamplingExc.postMessage(\"address = \"+address+\" \"+error.message+\"\\n\"+error.stack)}};addPrivacyObservers();addAdClosureObservers();monitorNotifications();try{var MutationObserver=window.WebKitMutationObserver||window.MutationObserver;var observer=new MutationObserver(function(mutations){for(const mutation of mutations){if(mutation.type===\"childList\"){log(\"A child node has been added or removed.\")}else if(mutation.type===\"attributes\"){log(mutation.attributeName+\" attribute was modified to \"+mutation.target.getAttribute(mutation.attributeName))}}mutations.forEach(function(mutation){for(var i=0;i<mutation.addedNodes.length;i++){var node=mutation.addedNodes[i];log(\"node iteration \"+i+\" : \"+JSON.stringify(node));if(node&&node.nodeName!=\"#text\"){addPrivacyObservers();addAdClosureObservers();monitorNotifications()}}})});var config={attributes:true,childList:true,subtree:true};observer.observe(document,config)}catch(error){window.webkit.messageHandlers.safedkNoSamplingExc.postMessage(\"address = \"+address+\" \"+error.message+\"\\n\"+error.stack)}})();\n";
public static final String x = "mraid://";
public static final String y = "url";
private static final String z = "VungleDiscovery";
public l() {
super(com.safedk.android.utils.h.d, z, true);
try {
aj = new PersistentConcurrentHashMap<>("VungleDiscoverycreativeToIdMap");
Logger.d(z, "CI to ID map loaded, key set: " + aj.keySet());
ak = new PersistentConcurrentHashMap<>("VungleDiscoverymediaPlayerIdToCreativeInfo");
Logger.d(z, "media player to CI loaded, key set: " + ak.keySet());
al = new PersistentConcurrentHashMap<>("VungleDiscoveryadToIdMap");
Logger.d(z, "ad to ID map loaded, key set: " + al.keySet());
am = new PersistentConcurrentHashMap<>("VungleDiscoveryplacementData");
Logger.d(z, "placement data loaded, key set: " + am.keySet());
} catch (InvalidParameterException e2) {
Logger.e(z, "Error initializing VungleDiscovery, caching will not be available", e2);
}
this.m.b(AdNetworkConfiguration.SUPPORTS_JAVASCRIPT_BASED_VIDEO_STATE_DETECTION, true);
this.m.b(AdNetworkConfiguration.SUPPORTS_JAVASCRIPT_BASED_PRIVACY_BUTTON_CLICK_DETECTION_IN_FULLSCREEN_ADS, true);
this.m.b(AdNetworkConfiguration.JS_PRIVACY_BUTTON_CLICK_DETECTION_SCRIPT, w);
this.m.a(AdNetworkConfiguration.SDK_SPECIFIC_CACHED_CI_MAX_AGE, an);
this.m.b(AdNetworkConfiguration.SUPPORTS_BANNER_IMPRESSION_TRACKING, true);
this.m.b(AdNetworkConfiguration.SUPPORTS_MREC_IMPRESSION_TRACKING, true);
this.m.b(AdNetworkConfiguration.SUPPORTS_JAVASCRIPT_BASED_VIDEO_STATE_DETECTION, true);
this.m.b(AdNetworkConfiguration.SUPPORTS_PREFETCH_RECEIVING_BY_APPLOVIN, true);
this.m.b(AdNetworkConfiguration.SUPPORTS_MREC_IMPRESSION_EOV, true);
this.m.b(AdNetworkConfiguration.AD_NETWORK_SUPPORTS_PREFETCH_REUSE, true);
this.m.b(AdNetworkConfiguration.SUPPORTS_AUTO_REDIRECTS_IDENTIFICATION, true);
this.m.b(AdNetworkConfiguration.SUPPORTS_EXPANDED_ADS_IDENTIFICATION, true);
this.m.b(AdNetworkConfiguration.USE_WEBVIEW_LOADURL_AS_RESOURCE_LOADED_INDICATION, true);
}
private CreativeInfo a(JSONObject jSONObject, String str) throws JSONException {
JSONObject jSONObject2;
ArrayList<String> arrayList;
JSONObject optJSONObject;
JSONObject jSONObject3;
try {
com.safedk.android.utils.l.b(z, "get CI from Json object started : " + jSONObject);
String string = jSONObject.getString("id");
Logger.d(z, "get CI from Json ad ID: " + string);
if (string.equals("") && jSONObject.has(E) && jSONObject.getString(E).equals(F)) {
Logger.d(z, "get CI from Json No fill, exiting");
return null;
}
String str2 = null;
ArrayList<String> arrayList2 = new ArrayList<>();
if (jSONObject.has("templateSettings") && (jSONObject3 = jSONObject.getJSONObject("templateSettings")) != null && jSONObject3.has(ab)) {
JSONObject jSONObject4 = jSONObject3.getJSONObject(ab);
if (jSONObject4.has(f)) {
String string2 = jSONObject4.getString(f);
if (!TextUtils.isEmpty(string2)) {
String str3 = new String(Base64.decode(string2, 0));
ArrayList<String> f2 = com.safedk.android.utils.l.f(str3);
com.safedk.android.utils.l.b(z, "get CI from Json ADM_HTML urls : " + f2);
str2 = n(str3);
com.safedk.android.utils.l.b(z, "get CI from Json ADM_HTML clickUrl : " + str2);
jSONObject2 = jSONObject4;
arrayList = f2;
}
}
jSONObject2 = jSONObject4;
arrayList = arrayList2;
} else {
jSONObject2 = null;
arrayList = arrayList2;
}
JSONObject jSONObject5 = jSONObject.has(Z) ? jSONObject.getJSONObject(Z) : null;
if (str2 == null && jSONObject2 != null && jSONObject2.has("CTA_BUTTON_URL")) {
str2 = jSONObject2.optString("CTA_BUTTON_URL", null);
}
if (str2 == null && jSONObject2 != null && jSONObject2.has(af)) {
str2 = jSONObject2.optString(af, null);
}
if (str2 == null && jSONObject.has(D)) {
str2 = jSONObject.getString(D);
}
if (str2 == null && jSONObject5 != null && jSONObject5.has(ac)) {
str2 = jSONObject5.optString(ac, null);
}
Logger.d(z, "get CI from Json clickUrl processing " + str2);
if (!TextUtils.isEmpty(str2) && com.safedk.android.utils.l.s(str2)) {
JSONArray jSONArray = new JSONArray(str2);
str2 = jSONArray.length() > 0 ? (String) jSONArray.get(0) : str2;
Logger.d(z, "get CI from Json clickUrl processing unescaped = " + str2);
}
String str4 = str2;
HashMap<String, String> b2 = b(jSONObject, string);
if (str4 == null && b2.containsKey("clickUrl_0")) {
b2.remove("clickUrl_0");
str4 = b2.get("clickUrl_0");
}
String string3 = jSONObject.getString("campaign");
if (string3 == null || (string3 != null && string3.equals("null"))) {
Logger.d(z, "get CI from Json Campaign is null, exiting");
return null;
}
Logger.d(z, "get CI from Json Campaign: " + string3);
String str5 = string3.split("\\|")[1];
String str6 = null;
String string4 = jSONObject.getString("url");
if (jSONObject.has(N)) {
str6 = jSONObject.getString(N);
Logger.d(z, "get CI from Json zip files bundle identified " + str6 + " in " + N);
} else if (jSONObject.has(O)) {
str6 = jSONObject.getString(O);
Logger.d(z, "get CI from Json zip files bundle identified " + str6 + " in " + O);
} else {
Logger.d(z, "get CI from Json zip files bundle not present in prefetch data.");
}
if (TextUtils.isEmpty(string4) && (optJSONObject = jSONObject.optJSONObject("templateSettings")) != null) {
JSONObject jSONObject6 = optJSONObject.getJSONObject(L);
if (jSONObject6.has(M)) {
string4 = jSONObject6.getJSONObject(M).getString("url");
}
}
long currentTimeMillis = System.currentTimeMillis() + this.m.e(AdNetworkConfiguration.SDK_SPECIFIC_CACHED_CI_MAX_AGE);
Logger.d(z, "get CI from Json expiration initial value (now + 1 week) = " + currentTimeMillis);
if (jSONObject.has(Q)) {
currentTimeMillis = jSONObject.getLong(Q) * 1000;
Logger.d(z, "get CI from Json expiration override , new values is " + currentTimeMillis);
}
BrandSafetyUtils.AdType adType = BrandSafetyUtils.AdType.INTERSTITIAL;
String optString = jSONObject.optString("template_type", null);
Logger.d(z, "get CI from Json templateType is " + optString);
if (optString != null && optString.equals("banner")) {
adType = BrandSafetyUtils.AdType.BANNER;
} else if (optString != null && optString.equals(U)) {
adType = BrandSafetyUtils.AdType.MREC;
} else if (optString != null && optString.equals("native")) {
adType = BrandSafetyUtils.AdType.NATIVE;
}
String str7 = null;
if (adType == BrandSafetyUtils.AdType.INTERSTITIAL) {
if (am.containsKey(str)) {
str7 = am.get(str).booleanValue() ? BrandSafetyEvent.AdFormatType.REWARD.toString() : BrandSafetyEvent.AdFormatType.INTER.toString();
Logger.d(z, "get CI from Json process placements placement " + str + " is " + str7);
} else {
Logger.d(z, "get CI from Json process placements data does not contain the placement " + str + ", will try to determine based on REWARDED_VALUE");
str7 = jSONObject.optInt(H) == I ? BrandSafetyEvent.AdFormatType.REWARD.toString() : BrandSafetyEvent.AdFormatType.INTER.toString();
}
} else if (adType.equals(BrandSafetyUtils.AdType.BANNER)) {
str7 = BrandSafetyEvent.AdFormatType.BANNER.toString();
} else if (adType.equals(BrandSafetyUtils.AdType.MREC)) {
str7 = BrandSafetyEvent.AdFormatType.MREC.toString();
}
ArrayList<String> f3 = com.safedk.android.utils.l.f(jSONObject.toString());
if (TextUtils.isEmpty(str4) || str4.contains(ah)) {
str4 = null;
com.safedk.android.utils.l.b(z, "get CI from Json clickUrl discarded : " + ((String) null));
} else {
com.safedk.android.utils.l.b(z, "get CI from Json clickUrl : " + str4);
}
String string5 = jSONObject.getString(S);
Logger.d(z, "get CI from Json struct : " + string5);
Logger.d(z, "get CI from Json adtype = " + (adType != null ? adType.name() : "null") + ", id: " + string + ", click url: " + str4 + ", creative id: " + str5 + ", video url: " + string4 + "postBundle = " + (str6 != null ? str6 : ""));
VungleCreativeInfo vungleCreativeInfo = new VungleCreativeInfo(adType, string, str5, str4, string4, str7, str, this.q, currentTimeMillis, string5);
vungleCreativeInfo.b(f3);
vungleCreativeInfo.b(arrayList);
al.put(string, vungleCreativeInfo);
if (string4 != null) {
vungleCreativeInfo.b(Arrays.asList(string4));
}
if (str6 != null) {
Logger.d(z, "get CI from Json adding zip files bundle " + str6 + " to prefetch resources");
vungleCreativeInfo.c(Arrays.asList(str6));
}
if (b2.size() > 0) {
for (String str8 : b2.values()) {
if (vungleCreativeInfo.u(str8)) {
Logger.d(z, "get CI from Json adding url to CI dsp domains: " + str8);
vungleCreativeInfo.v(str8);
}
}
}
if (vungleCreativeInfo.o() == null && jSONObject.has(C)) {
a(jSONObject.getString(C), vungleCreativeInfo);
}
if (vungleCreativeInfo.o() == null && jSONObject.has(D)) {
a(jSONObject.getString(D), vungleCreativeInfo);
}
if (vungleCreativeInfo.o() == null && jSONObject.has("ad_market_id")) {
a(jSONObject.getString("ad_market_id"), vungleCreativeInfo);
}
if (vungleCreativeInfo.o() == null && jSONObject2 != null && jSONObject2.has("CTA_BUTTON_URL")) {
a(jSONObject2.getString("CTA_BUTTON_URL"), vungleCreativeInfo);
}
if (vungleCreativeInfo.o() == null && jSONObject2 != null && jSONObject2.has(af)) {
a(jSONObject2.getString(af), vungleCreativeInfo);
}
if (vungleCreativeInfo.o() == null && jSONObject5 != null && jSONObject5.has(ac)) {
a(jSONObject5.getString(ac), vungleCreativeInfo);
return vungleCreativeInfo;
}
return vungleCreativeInfo;
} catch (Throwable th) {
Logger.e(z, "get CI from Json object exception: " + th.getMessage(), th);
return null;
}
}
private VungleCreativeInfo a(File file) {
if (file == null) {
Logger.d(z, "get ad ID by video file - file is null");
return null;
}
String r = r(file.getAbsolutePath());
Logger.d(z, "get ad ID by video file - creative to ID map iteration, looking for '" + r + "', key set: " + aj.keySet().toString());
if (aj != null && r != null) {
VungleCreativeInfo remove = aj.remove(r);
if (remove != null) {
Logger.d(z, "get ad ID by video file - CI MATCH! creative found: " + r);
return remove;
}
for (String str : aj.keySet()) {
VungleCreativeInfo vungleCreativeInfo = aj.get(str);
if (vungleCreativeInfo.L().equals(r)) {
Logger.d(z, "get ad ID by video file - CI MATCH! creative found: " + r);
return vungleCreativeInfo;
}
}
}
Logger.d(z, "get ad ID by video file - creative not found");
return null;
}
private void a(String str, VungleCreativeInfo vungleCreativeInfo) {
if (str == null || !com.safedk.android.utils.l.t(str)) {
Logger.d(z, "app package name value is " + str + ", not valid, skipping");
return;
}
vungleCreativeInfo.p(str);
Logger.d(z, "app package name will be updated to " + str);
}
private boolean a(JSONObject jSONObject) throws JSONException {
if (!((JSONObject) jSONObject.get(c)).has("template_type")) {
}
return true;
}
private HashMap<String, String> b(JSONObject jSONObject, String str) {
HashMap<String, String> hashMap = new HashMap<>();
try {
if (jSONObject.has(Z)) {
JSONObject jSONObject2 = jSONObject.getJSONObject(Z);
Iterator<String> keys = jSONObject2.keys();
while (keys.hasNext()) {
String obj = keys.next().toString();
if (jSONObject2.get(obj) instanceof JSONArray) {
JSONArray jSONArray = jSONObject2.getJSONArray(obj);
Logger.d(z, "iterating over key '" + obj + "' , content: " + jSONArray.toString());
if (jSONArray.length() > 0) {
for (int i2 = 0; i2 < jSONArray.length(); i2++) {
if (hashMap.values().contains(jSONArray.getString(i2))) {
Logger.d(z, "url already in map. skipping: " + jSONArray.getString(i2));
} else {
hashMap.put(obj + "_" + i2, jSONArray.getString(i2));
Logger.d(z, "collecting additional url: " + jSONArray.getString(i2));
}
}
}
} else {
Logger.d(z, "key '" + obj + "' is not a JSONArray, skipping");
}
}
} else {
Logger.d(z, "tpat key does not exist, exiting");
}
} catch (JSONException e2) {
Logger.e(z, "Error collecting urls under tpat key", e2);
}
return hashMap;
}
private void l(String str) throws JSONException {
com.safedk.android.utils.l.b(z, "process placements started, buffer = " + str);
JSONObject jSONObject = new JSONObject(str);
if (!jSONObject.has(W)) {
Logger.d(z, "process placements no placements array");
return;
}
JSONArray jSONArray = jSONObject.getJSONArray(W);
for (int i2 = 0; i2 < jSONArray.length() - 1; i2++) {
JSONObject jSONObject2 = jSONArray.getJSONObject(i2);
if (jSONObject2.has(X) && jSONObject2.has(Y)) {
am.put(jSONObject2.getString(X), Boolean.valueOf(jSONObject2.getBoolean(Y)));
Logger.d(z, "process placements added " + jSONObject2.getString(X) + " : " + jSONObject2.getBoolean(Y));
} else {
Logger.d(z, "process placements placement does not contains ref_id/is_incentivized data : " + jSONObject2);
}
}
}
private String r(String str) {
if (str.split("/").length <= 1) {
Logger.d(z, "file path is not according to the expected pattern: " + str + ", cannot extract CreativeId");
return null;
}
String str2 = str.split("/")[str.split("/").length - 2];
Logger.d(z, "ad ID to be searched: " + str2);
return str2;
}
@Override
protected String a(String str, CreativeInfo creativeInfo) {
return null;
}
@Override
public void a(Object obj, Object obj2) {
try {
Logger.d(z, "handle media player set data source call, media player: " + obj + ", video file: " + obj2);
Uri uri = (Uri) obj2;
Logger.d(z, "handle media player set data source call, uri: " + uri.toString());
VungleCreativeInfo a2 = a(new File(uri.getPath()));
if (a2 == null || ak.containsKey(Integer.valueOf(System.identityHashCode(obj)))) {
return;
}
Logger.d(z, "handle media player set data source call, adding CI to map");
ak.put(Integer.valueOf(System.identityHashCode(obj)), a2);
} catch (Exception e2) {
Logger.e(z, "exception when trying to add mediaPlayer id and VungleCreativeInfo " + e2.getMessage());
}
}
@Override
public AdNetworkDiscovery.WebViewResourceMatchingMethod b() {
return AdNetworkDiscovery.WebViewResourceMatchingMethod.WEBVIEW_LOOKUP;
}
@Override
public String b(Object obj) {
try {
Logger.d(z, "get CI after media player start call, media player: " + obj);
VungleCreativeInfo remove = ak.remove(Integer.valueOf(System.identityHashCode(obj)));
if (remove == null) {
Logger.d(z, "get CI after media player start call - cannot find creative in media player ID to CI map");
return null;
}
if (aj.remove(remove.L()) == null) {
Logger.d(z, "Cannot find " + remove.L() + " in creative to ID map");
} else {
Logger.d(z, "creative to ID map key '" + remove.L() + "'removed, key set: " + aj.keySet().toString());
}
Logger.d(z, "get CI after media player start call - returning " + remove.J() + " as ad ID");
return remove.J();
} catch (Exception e2) {
Logger.e(z, "exception when trying to remove from media player ID to CI map" + e2.getMessage());
return null;
}
}
@Override
public String b(String str, String str2) {
String r = r(str);
if (r != null) {
Logger.d(z, "get ad ID from resource returned ad ID: " + r);
return r;
}
return null;
}
@Override
protected List<CreativeInfo> b(String str, String str2, Map<String, List<String>> map, c.a aVar) throws JSONException {
JSONObject jSONObject;
JSONObject jSONObject2;
com.safedk.android.utils.l.b(z, "generate info started, url: " + str + ", buffer: " + str2 + ", maxParams: " + aVar);
ArrayList arrayList = new ArrayList();
try {
jSONObject = new JSONObject(str2);
} catch (Throwable th) {
Logger.d(z, "Exception parsing prefetch : " + th.getMessage(), th);
}
if (str.contains(v)) {
com.safedk.android.utils.l.b(z, "Config request intercepted: " + str2);
l(str2);
return null;
}
if (CreativeInfoManager.e(str) || str.equals("@!1:ad_fetch@!")) {
Logger.d(z, "Url is a mediation url");
if (jSONObject.has(ai)) {
Logger.d(z, "content contains an AdUnit field");
String a2 = com.safedk.android.utils.d.a(Base64.decode(jSONObject.getString(ai), 0));
Logger.d(z, "decodedAdUnitContent = " + a2);
if (com.safedk.android.utils.l.s(a2)) {
jSONObject2 = new JSONObject(a2);
Logger.d(z, "decodedAdUnitContent new JSONObject created");
if (!jSONObject2.has("id")) {
CreativeInfo a3 = a(jSONObject2, (String) null);
if (a3 != null) {
if (a3.I().equals(BrandSafetyUtils.AdType.NATIVE)) {
Logger.d(z, "ci is a native ad, skipping: " + a3);
} else {
arrayList.add(a3);
aj.put(a3.L(), (VungleCreativeInfo) a3);
Logger.d(z, "ci to ID map key added " + a3.L() + ", key set: " + aj.keySet().toString());
}
}
} else if (jSONObject2.has(CampaignUnit.JSON_KEY_ADS)) {
JSONArray jSONArray = jSONObject2.getJSONArray(CampaignUnit.JSON_KEY_ADS);
for (int i2 = 0; i2 < jSONArray.length(); i2++) {
JSONObject jSONObject3 = jSONArray.getJSONObject(i2);
JSONObject jSONObject4 = jSONObject3.getJSONObject(c);
String string = jSONObject3.getString(J);
if (a(jSONObject3)) {
CreativeInfo a4 = a(jSONObject4, string);
if (a4 == null || a4.I().equals(BrandSafetyUtils.AdType.NATIVE)) {
Logger.d(z, "ci is a native ad, skipping." + a4);
} else {
arrayList.add(a4);
aj.put(a4.L(), (VungleCreativeInfo) a4);
Logger.d(z, "ci to ID map key added " + a4.L() + ", key set: " + aj.keySet().toString());
}
}
}
}
return arrayList;
}
}
}
jSONObject2 = jSONObject;
if (!jSONObject2.has("id")) {
}
return arrayList;
}
@Override
protected boolean b(String str, Bundle bundle) {
boolean z2 = str.contains(g) || str.contains(h) || str.contains(i) || str.contains(u) || str.contains(v);
if (z2) {
Logger.d(z, "should follow input stream, url: " + str);
}
return z2;
}
@Override
public int c(String str) {
if (str != null) {
return str.hashCode();
}
return 0;
}
@Override
public Set<String> c() {
return new HashSet();
}
@Override
public String f() {
return R;
}
@Override
public RedirectDetails.RedirectType g(String str) {
if (str == null || !str.startsWith(x)) {
return RedirectDetails.RedirectType.REDIRECT;
}
if (str.contains(TtmlNode.TEXT_EMPHASIS_MARK_OPEN)) {
return RedirectDetails.RedirectType.REDIRECT;
}
return null;
}
@Override
public String h(String str) {
return (str == null || !str.contains(x)) ? str : com.safedk.android.utils.l.c(str, "url");
}
@Override
public void i() {
Logger.d(z, "clear old CIs started");
super.i();
com.safedk.android.utils.f.a(aj, "VungleDiscovery:creativeToIdMap", false, k());
com.safedk.android.utils.f.a(ak, "VungleDiscovery:mediaPlayerIdToCreativeInfo", false, k());
com.safedk.android.utils.f.a(al, "VungleDiscovery:adToIdMap", false, k());
}
@Override
protected boolean k(String str) {
Logger.d(z, "should follow get url: " + str);
if (str.toLowerCase().endsWith(f9332b.toLowerCase())) {
Logger.d(z, "should follow get url - returning true for url: " + str);
return true;
}
if (str.equals(ag)) {
Logger.d(z, "Vungle privacy policy url invoked");
CreativeInfoManager.b(com.safedk.android.utils.h.d, null);
}
String r = r(str);
if (r != null && r.length() > 0) {
if (al.containsKey(r)) {
Logger.d(z, "ad to ID map contains creative ID: " + r + ", returning true");
return true;
}
Logger.d(z, "ad to ID map does not contain creative ID: " + r);
}
return false;
}
}