Puzzle King v2.3.8版本的 MD5 值为:1734eb975c9d2843afa462aec387292e
以下内容为反编译后的 InterstitialFinder.java 源代码,内容仅作参考
package com.safedk.android.analytics.brandsafety;
import android.R;
import android.app.Activity;
import android.graphics.Bitmap;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.os.SystemClock;
import android.text.TextUtils;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.WebView;
import com.applovin.communicator.AppLovinCommunicatorMessage;
import com.facebook.internal.security.CertificateUtil;
import com.safedk.android.SafeDK;
import com.safedk.android.analytics.AppLovinBridge;
import com.safedk.android.analytics.StatsCollector;
import com.safedk.android.analytics.StatsReporter;
import com.safedk.android.analytics.brandsafety.BrandSafetyUtils;
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.infos.CreativeInfo;
import com.safedk.android.analytics.brandsafety.creatives.infos.VungleCreativeInfo;
import com.safedk.android.analytics.events.BrandSafetyEvent;
import com.safedk.android.analytics.events.MaxEvent;
import com.safedk.android.analytics.reporters.CrashReporter;
import com.safedk.android.internal.SafeDKWebAppInterface;
import com.safedk.android.utils.Logger;
import com.safedk.android.utils.SdksMapping;
import java.io.File;
import java.lang.ref.WeakReference;
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 java.util.UUID;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
public class InterstitialFinder extends com.safedk.android.analytics.brandsafety.b {
private static final String G = "InterstitialFinder";
private static final long H = 500;
private static final long I = 1000;
private static final int J = 2;
private static final int K = 3;
FullScreenActivitiesCollection D;
boolean E;
protected String F;
private final InterstitialInfoCollection L;
private long M;
private final Map<String, List<n>> N;
private final Set<String> O;
public boolean h(String str) {
List<m> a2 = this.L.a(str);
com.safedk.android.utils.k.b(G, "activeImpressionExists current impressions are " + this.L);
return a2 != null && a2.size() > 0;
}
public InterstitialFinder() {
super(BrandSafetyUtils.AdType.INTERSTITIAL, Arrays.asList(BrandSafetyUtils.j, BrandSafetyUtils.k, BrandSafetyUtils.l), G, 120);
this.L = new InterstitialInfoCollection();
this.M = 0L;
this.N = new HashMap();
this.D = new FullScreenActivitiesCollection();
this.E = false;
this.F = "";
this.O = new HashSet(Arrays.asList(CreativeInfo.j, CreativeInfo.i));
}
@Override
protected c a(String str, String str2, String str3, BrandSafetyUtils.ScreenShotOrientation screenShotOrientation, String str4, String str5) {
return new m(str, str2, str3, screenShotOrientation, str4, str5);
}
public synchronized void a(String str, Object obj) {
Logger.d(G, "on video completed - sdk = " + str + ", source = " + obj);
m mVar = null;
if (obj != null) {
mVar = this.L.b(BrandSafetyUtils.a(obj));
Logger.d(G, "on video completed - sdk = " + str + ", found interstitialInfo : " + mVar);
}
if (mVar != null) {
d(mVar, str);
} else {
Iterator<m> it = this.L.values().iterator();
while (it.hasNext()) {
d(it.next(), str);
}
}
}
private void d(m mVar, String str) {
if (mVar != null) {
Logger.d(G, "on video completed - started, sdkPackageName = " + str + ", eventId = " + mVar.I);
if (mVar.u.equals(str) && !mVar.W) {
b(mVar, true);
mVar.W = true;
Logger.d(G, "on video completed - set to true, sdkPackageName = " + str + ", eventId = " + mVar.I);
}
}
}
@Override
public synchronized void a(String str, String str2, boolean z) {
if (str2 != null) {
m b2 = this.L.b(str2);
if (b2 != null) {
Logger.d(G, "on video completed triggered - for webview address : " + str2 + ", sdkPackageName : " + str + ", video completed: " + z);
a(b2, z);
}
}
for (m mVar : this.L.a(str)) {
Logger.d(G, "on video completed triggered - sdkPackageName : " + str + ", webView address: " + str2 + ", video completed: " + z);
a(mVar, z);
}
}
private void a(m mVar, boolean z) {
Logger.d(G, "set on video completed started, eventId : " + mVar.I);
if (!mVar.W && z) {
b(mVar, z);
CreativeInfo h = mVar.h();
if (h != null && !h.u()) {
h.d(true);
}
mVar.W = z;
return;
}
if (!z) {
mVar.W = false;
}
}
private void b(m mVar, boolean z) {
if (mVar == null) {
Logger.d(G, "clearImpressionScreenshotsIfNeeded interstitialInfo is null");
return;
}
if (z && !mVar.W && !mVar.X) {
Logger.d(G, "Video is marked as completed, clearing any images taken previously");
for (k kVar : mVar.f()) {
if (kVar.b != null && mVar.H != null && mVar.H.equals(kVar.b.ad())) {
b(kVar);
}
}
mVar.X = true;
return;
}
Logger.d(G, "avoid clearing any images taken previously: videoCompleted=" + z + " onVideoCompletedEventHasBeenTriggered=" + mVar.W + " impressionScreenshotsRemoved=" + mVar.X);
}
public void b(String str, String str2, boolean z) {
if (str2 != null && this.L.b(str2) != null) {
c(this.L.b(str2), z);
}
List<m> a2 = this.L.a(str);
if (a2 != null) {
Iterator<m> it = a2.iterator();
while (it.hasNext()) {
c(it.next(), z);
}
}
}
private void c(m mVar, boolean z) {
Logger.d(G, "stop taking screenshots for impression. starting. address = " + mVar.H);
if (mVar == null) {
Logger.d(G, "stop taking screenshots for impression. info is null.");
return;
}
if (z || this.E) {
mVar.Z = true;
b(mVar.g());
Logger.d(G, "stop taking screenshots for impression. attempting to clear image hash and files");
i k = mVar.k();
if (k != null && k.b != null) {
a(mVar, k);
return;
} else {
Logger.d(G, "stop taking screenshots for impression. no active ci or no image taken.");
return;
}
}
Logger.d(G, "stop taking screenshots for impression. Request to stop taking screenshots received when no max ad is active. ignoring");
}
private void a(m mVar, i iVar) {
Logger.d(G, "remove file and report event, file: " + iVar.b);
BrandSafetyUtils.c(iVar.b);
iVar.a = null;
iVar.b = null;
BrandSafetyUtils.c(mVar.b());
mVar.r = null;
f(mVar, "removeFileAndReportEvent");
}
private boolean a(View view, String str, String str2) {
String c;
AdNetworkDiscovery f = CreativeInfoManager.f(str);
if (f == null) {
Logger.d(G, "extract ad ID from view - no discovery object for: " + str);
return false;
}
boolean a2 = CreativeInfoManager.a(str, AdNetworkConfiguration.SHOULD_EXTRACT_AD_ID_FROM_BANNER_WEB_VIEW, false);
boolean a3 = CreativeInfoManager.a(str, AdNetworkConfiguration.AD_ID_EXTRACTED_FROM_BANNER_WEB_VIEW_IS_MAX_CREATIVE_ID, false);
Logger.d(G, "extract ad ID from view - should extract: " + a2);
if (!a2 || (c = f.c(view)) == null) {
return false;
}
Logger.d(G, "extract ad ID from view - ad ID extracted from view: " + c);
if (a3 && str2 != null && !str2.equals(c)) {
Logger.d(G, "extract ad ID from view - value extracted (" + c + ") from widget is not equal to creative ID (" + str2 + ")");
return true;
}
Logger.d(G, "extract ad ID from view - attempting to locate ci by ad ID value " + c);
CreativeInfo a4 = f.a((Object) c);
if (a4 != null) {
Logger.d(G, "extract ad ID from view - CI found, ad ID = " + c + ", view : " + view.toString() + ", ci : " + a4);
a4.a((Object) view);
a(new n(a4, CreativeInfo.n, c));
return false;
}
Logger.d(G, "extract ad ID from view - CI not found, adId = " + c);
return false;
}
private synchronized void a(m mVar, String str, ViewGroup viewGroup, List<WebView> list, List<String> list2, List<String> list3, int i) {
int i2 = i + 1;
for (int i3 = 0; i3 < viewGroup.getChildCount(); i3++) {
View childAt = viewGroup.getChildAt(i3);
list2.add(BrandSafetyUtils.a(childAt));
list3.add("h" + i2 + com.safedk.android.analytics.brandsafety.creatives.discoveries.h.s + (i3 + 1) + CertificateUtil.DELIMITER + childAt);
if (childAt instanceof WebView) {
list.add((WebView) childAt);
Logger.d(G, "find WebViews in view group - found: " + childAt + " , parent: " + childAt.getParent().toString());
} else if (childAt instanceof ViewGroup) {
a(mVar, str, (ViewGroup) childAt, list, list2, list3, i2);
}
if (a(str, childAt)) {
Logger.d(G, "find WebViews in view group - found AdView: " + childAt + " , parent: " + childAt.getParent().toString());
AdNetworkDiscovery f = CreativeInfoManager.f(str);
String c = f.c(childAt);
if (c != null) {
Logger.d(G, "find WebViews in view group - found adId: " + c);
CreativeInfo a2 = f.a((Object) c);
if (a2 != null) {
Logger.d(G, "find WebViews in view group - found CI for adId " + c + " : " + a2);
a2.a((Object) childAt);
if (mVar != null && mVar.z != null) {
String b2 = b(mVar.z);
Logger.d(G, "find WebViews in view group - setting ad format type to " + b2);
a2.n(b2);
mVar.e("ad_type_upd(fndWVUndrVGroup):" + b2);
}
a(new n(a2, CreativeInfo.n, BrandSafetyUtils.a(childAt)));
}
}
}
}
}
@Override
public synchronized void onMessageReceived(AppLovinCommunicatorMessage message) {
synchronized (this) {
if (SafeDK.getInstance().o()) {
Bundle messageData = message.getMessageData();
if (messageData.containsKey("revenue_event") && messageData.containsKey("ad_format") && this.b.contains(messageData.getString("ad_format"))) {
Logger.d(G, "Revenue event detected : " + messageData.toString());
a(messageData);
} else {
String string = messageData.getString("type");
String string2 = messageData.getString("ad_format");
String string3 = messageData.getString(BrandSafetyEvent.k);
String string4 = messageData.getString(BrandSafetyEvent.ad);
String string5 = messageData.getString("dsp_name");
String b2 = CreativeInfoManager.b(string4);
long b3 = com.safedk.android.utils.k.b(System.currentTimeMillis());
String string6 = messageData.containsKey("creative_id") ? messageData.getString("creative_id") : null;
MaxEvent maxEvent = new MaxEvent(string, b3, string2, string4, string6, string5);
o.a().a(maxEvent);
boolean contains = this.b.contains(string2);
String a2 = CreativeInfoManager.a(b2, AdNetworkConfiguration.AD_NETWORK_TO_IGNORE, (String) null);
if (contains && string4 != null && string4.equals(a2)) {
Logger.d(G, "full screen type but ad network not supported (" + a2 + ")");
} else {
String string7 = messageData.getString("id", null);
if (string7 == null) {
Logger.d(G, "No eventId in data bundle.");
}
if (contains) {
Logger.d(G, "Max message received, package: " + b2 + ", ts (seconds): " + b3 + ", message received: " + message.getMessageData());
if ("WILL_DISPLAY".equals(string)) {
com.safedk.android.utils.k.b(G, "adInfoCollectionForUpload count = " + this.z.size() + " : " + this.z);
this.d++;
if (b2 != null) {
o.a().b(maxEvent);
this.E = true;
BrandSafetyUtils.k(b2);
a(b2, new AtomicReference<>(messageData));
CreativeInfoManager.a(b2, string3, string6, (String) null, string2);
a aVar = new a(string3, string7);
Logger.d(G, "WILL_DISPLAY event for package " + b2 + " placement " + string3 + " ad_type " + string2 + ", activityFullScreenAdKey=" + aVar);
a(b2, aVar, string7);
}
} else if ("DID_CLICKED".equals(string)) {
m e = this.L.e(string7);
if (e != null) {
StringBuilder append = new StringBuilder().append("DID_CLICKED event for package ");
if (b2 != null) {
string4 = b2;
}
Logger.d(G, append.append(string4).toString());
b(e);
if (!TextUtils.isEmpty(e.e())) {
f(e, "onMessageReceived");
}
}
} else if ("WILL_LOAD".equals(string)) {
if (b2 != null) {
Logger.d(G, "WILL_LOAD event for package " + b2 + " placement " + string3);
com.safedk.android.analytics.brandsafety.creatives.e.b(b2, string3);
CreativeInfoManager.a(b2, string3, string6, (String) null, string2);
}
} else if ("DID_HIDE".equals(string)) {
if (b2 != null) {
BrandSafetyUtils.l(b2);
Logger.d(G, "DID_HIDE event for package " + b2 + " placement " + string3);
m e2 = this.L.e(string7);
if (e2 != null) {
a(e2, (String) null);
}
}
} else if ("DID_LOAD".equals(string)) {
if (b2 != null) {
Logger.d(G, "DID_LOAD event for package " + b2 + " placement " + string3);
}
} else if ("DID_DISPLAY".equals(string)) {
if (b2 != null) {
if (string6 != null) {
m e3 = this.L.e(string7);
Logger.d(G, "updateMaxCreativeId currentActivityInterstitial : " + e3);
if (e3 != null) {
if (e3.z != null && e3.z.containsKey("id") && e3.z.getString("id") != null && e3.z.getString("id").equals(string7)) {
Logger.d(G, "updateMaxCreativeId setting Max creativeId to : " + string6 + " for eventId " + string7);
e3.J = string6;
} else {
Logger.d(G, "updateMaxCreativeId cannot update Max creativeId. event Id check failed.");
}
}
}
Logger.d(G, "DID_DISPLAY event for package " + b2 + " placement " + string3);
}
} else if ("DID_FAIL_DISPLAY".equals(string)) {
Logger.d(G, "DID_FAIL_DISPLAY event for package " + b2 + " placement " + string3);
m e4 = this.L.e(string7);
if (e4 != null) {
e4.K = true;
e(e4, (String) null);
}
}
}
}
}
}
}
}
private synchronized void a(String str, a aVar, String str2) {
Logger.d(G, "match CI started, sdk = " + str + ", interstitial key = " + aVar);
if (aVar.b != null) {
Logger.d(G, "match CI - interstitial key: " + aVar);
AdNetworkDiscovery f = CreativeInfoManager.f(str);
if (f != null && f.d() != null && f.d().a(AdNetworkConfiguration.SUPPORTS_BIDDING_INTERSTITIAL_IMPRESSION_MATCHING_BY_MAX, false)) {
Logger.d(G, "match CI - discovery configuration: " + f.d());
String str3 = aVar.a + "_" + aVar.b + "_" + str;
CreativeInfo a2 = f.a((Object) str3);
if (a2 != null) {
Logger.d(G, "match CI - discovery class returned a ci: " + a2);
if (a2.l() == null) {
a2.d(aVar.b);
}
a2.n(BrandSafetyEvent.AdFormatType.INTER.name());
a2.r("ad_type_upd(matchCI):" + BrandSafetyEvent.AdFormatType.INTER.name());
a(new n(a2, CreativeInfo.n, str3));
} else {
Logger.d(G, "match CI - ci not found");
}
} else {
Logger.d(G, "match CI - sdk not configured to allow max events based matching");
}
}
}
public synchronized void a(String str, AtomicReference<Bundle> atomicReference) {
if (atomicReference != null) {
if (atomicReference.get() != null) {
Logger.d(G, "start ad monitoring - slot = " + this.d + ", max package name = " + str + ", AppLovin data bundle is " + atomicReference.get());
if (CreativeInfoManager.f(str) != null) {
m mVar = new m(str, this.d, atomicReference.get());
mVar.I = atomicReference.get().getString("id");
this.L.put(mVar.I, mVar);
Logger.d(G, "start ad monitoring - new interstitial info created : " + mVar);
d((Activity) null);
} else {
Logger.d(G, "start ad monitoring - slot = " + this.d + ", max package name = " + str + ", ad network is not supported");
}
}
}
}
@Override
public synchronized void a(Activity activity) {
com.safedk.android.utils.k.b(G, "start ad monitoring - activity : " + activity + ", current interstitial infos :" + this.L);
if (activity != null) {
if (!this.L.d(activity.toString())) {
this.D.put(activity.toString(), new WeakReference<>(activity));
if (!this.E) {
this.E = true;
}
Logger.d(G, "start ad monitoring - activity added : " + activity.toString());
} else {
Logger.d(G, "start ad monitoring - activity null or already registered.");
}
if (j(activity.toString())) {
Logger.d(G, "start ad monitoring - sdk: " + this.L.b() + ", activity " + activity + " started but this is not the start of impression. not starting ad monitoring");
} else {
Logger.d(G, "start ad monitoring calling 'start', activity is " + activity);
d(activity);
}
}
}
private boolean j(String str) {
m c = this.L.c(str);
if (str == null || c == null || c.c() == null) {
return false;
}
Logger.d(G, "instances of same activity - current activity class name = " + c.o() + ", current activity address = " + c.n());
AdNetworkDiscovery f = CreativeInfoManager.f(c.c());
if (f == null || f.d() == null || !f.d().a(AdNetworkConfiguration.AD_NETWORK_INTERNAL_BROWSER_OPENS_IN_SAME_ACTIVITY, false)) {
return false;
}
Logger.d(G, "instances of same activity - discovery configuration = " + f.d());
String str2 = c.o() + "@" + c.n();
Logger.d(G, "instances of same activity - current activity = " + str2);
if (str.equals(str2)) {
return false;
}
Logger.d(G, "instances of same activity - activityClass " + str2 + " is a different instance of the same activity");
return true;
}
@Override
protected boolean a(String str, View view) {
AdNetworkDiscovery f;
if (str == null || (f = CreativeInfoManager.f(str)) == null) {
return false;
}
return f.f(view);
}
private void b(m mVar) {
Logger.d(G, "handle DID_CLICKED started");
if (mVar != null) {
mVar.a(true);
if (mVar.e() == null && mVar.ad != null && mVar.ad.a != 0) {
Logger.d(G, "handle DID_CLICKED checking click url candidate");
if (System.currentTimeMillis() - mVar.ad.a < 20000) {
Logger.d(G, "handle DID_CLICKED setting click url");
mVar.c(mVar.ad.b);
}
}
}
}
@Override
public synchronized String getCommunicatorId() {
return AppLovinBridge.a;
}
public synchronized m b(Activity activity) {
m c;
if (activity == null) {
Logger.d(G, "get activity interstitial by activity, activity is null");
c = null;
} else {
c = this.L.c(activity.toString());
}
return c;
}
public synchronized m i(String str) {
m mVar = null;
synchronized (this) {
if (str == null) {
Logger.d(G, "get activity interstitial by package, package is null");
} else {
List<m> a2 = this.L.a(str);
if (a2.size() == 1) {
mVar = a2.get(0);
} else {
Logger.d(G, "there are " + a2.size() + " interstitial infos, exisitng");
}
}
}
return mVar;
}
private synchronized void d(Activity activity) {
String a2;
String b2;
String str;
m mVar;
Set<String> set;
m mVar2;
List<n> list;
WeakReference<Activity> b3;
if (activity != null) {
a2 = BrandSafetyUtils.a(activity.toString(), true);
String a3 = BrandSafetyUtils.a(activity.toString(), false);
b2 = BrandSafetyUtils.b(activity.getClass());
str = a3;
} else {
b2 = null;
str = null;
a2 = null;
}
Logger.d(G, "interstitial finder start - activity name = " + activity + ", sdk = " + b2);
if (activity != null) {
mVar = this.L.c(BrandSafetyUtils.a(activity));
Logger.d(G, "interstitial finder start - attempt to find by activity address, currentActivityInterstitial = " + mVar);
} else {
mVar = this.L.a(true) == 1 ? this.L.get(this.L.keySet().toArray()[0]) : null;
}
if (mVar != null && a2 != null && a2.equals(mVar.A)) {
i k = mVar.k();
if (k != null && !TextUtils.isEmpty(k.a) && a(k.d, k.c)) {
Logger.d(G, "interstitial finder start - Not starting timer on activity " + mVar.V + " -- impression already logged");
} else {
Logger.d(G, "interstitial finder start - Starting counter from previous value " + mVar.r());
mVar.y();
mVar2 = mVar;
if (c(mVar2)) {
}
}
} else {
Logger.d(G, "interstitial finder start - current activity interstitial = " + mVar);
if (mVar == null) {
set = null;
} else if (str != null && mVar.B.equals(str)) {
Logger.d(G, "interstitial finder start - current activity interstitial class name = " + mVar.B + ", activity class name = " + str);
set = null;
} else {
Set<String> set2 = mVar.O;
if (set2.contains(a2)) {
Logger.d(G, "interstitial finder start - Ignoring restart of suspected mediation " + mVar.V);
} else {
if (mVar.A != null) {
set2.add(mVar.A);
}
set = set2;
}
}
ArrayList arrayList = new ArrayList();
Logger.d(G, "interstitial finder start - start current activity interstitial is " + mVar);
if (mVar != null && !mVar.D && !mVar.i().isEmpty()) {
Logger.d(G, "interstitial finder start - current activity interstitial != null : " + mVar);
List<CreativeInfo> i = mVar.i();
if (!i.isEmpty()) {
for (CreativeInfo creativeInfo : i) {
if (creativeInfo != null) {
Logger.d(G, "interstitial finder start - setting current activity interstitials CI: " + creativeInfo);
arrayList.add(new n(creativeInfo, creativeInfo.S(), creativeInfo.R()));
} else {
Logger.d(G, "interstitial finder start - current CI matching method not equal, current CI: " + creativeInfo);
}
}
} else {
Logger.d(G, "interstitial finder start - current CI is null");
}
Logger.d(G, "interstitial finder start - current activity interstitial impression reported? " + mVar.D);
c(mVar, true);
}
Logger.d(G, "interstitial finder start - activity : " + activity + ", activities : " + this.D.a());
if (this.L.a(true) > 0 && this.D.size() > 0) {
m mVar3 = mVar;
for (m mVar4 : this.L.c()) {
if (activity == null && (b3 = this.D.b(mVar4.u)) != null && b3.get() != null) {
Activity activity2 = b3.get();
Logger.d(G, "interstitial finder start - activity set to " + activity2);
activity = activity2;
}
if (activity != null) {
String b4 = BrandSafetyUtils.b(activity.getClass());
Logger.d(G, "interstitial finder start - activity : " + activity + ", activitySdk : " + b4 + ", InterstitialInfo sdk : " + mVar4.u);
mVar4.Y = SystemClock.elapsedRealtime();
if (mVar4.u != null && b4 != null && b4.equals(mVar4.u)) {
a(activity, mVar4);
mVar3 = mVar4;
} else {
Logger.d(G, "interstitial finder start - maybe scar-admob");
}
}
a(mVar4, activity);
}
mVar = mVar3;
}
if (mVar != null) {
if (mVar.u != null) {
Logger.d(G, "interstitial finder start - current Max package name: " + mVar.u);
boolean a4 = CreativeInfoManager.a(mVar.u, AdNetworkConfiguration.SDK_INTERSTITIALS_RUN_ON_APP_ACTIVITY, false);
if (activity != null && !BrandSafetyUtils.c(activity.getClass()) && !a4) {
Logger.d(G, "interstitial finder start - current foreground activity is not a supported ad activity");
} else if (!a4) {
Logger.d(G, "interstitial finder start - checking pending ci for no activity sdk " + mVar.u);
List<n> a5 = a(mVar.u, mVar);
for (n nVar : a5) {
Logger.d(G, "interstitial finder start - found pending ci(s) for no activity sdk, mi : " + nVar);
a(nVar, mVar);
}
list = a5;
if (!TextUtils.isEmpty(this.F)) {
mVar.e(this.F);
Logger.d(G, "interstitial finder start - ci_debug_info set to " + this.F);
}
if (mVar.ah != null) {
e(mVar);
if (list.isEmpty()) {
list = a(b2, mVar);
}
mVar.R = 0L;
}
if (CreativeInfoManager.a(mVar.c(), AdNetworkConfiguration.SDK_INTERSTITIALS_RUN_ON_APP_ACTIVITY, false)) {
Logger.d(G, "interstitial finder inter runs on app activity, checking for pending CIs. sdk = " + mVar.c());
list = a(mVar.c(), mVar);
Logger.d(G, "interstitial finder inter runs on app activity, checking for pending CIs. found " + list.size() + " items");
}
for (n nVar2 : list) {
if (nVar2 != null && nVar2.a != null) {
a(nVar2, mVar);
}
}
if (set != null) {
mVar.O = set;
}
}
}
list = arrayList;
if (!TextUtils.isEmpty(this.F)) {
}
if (mVar.ah != null) {
}
if (CreativeInfoManager.a(mVar.c(), AdNetworkConfiguration.SDK_INTERSTITIALS_RUN_ON_APP_ACTIVITY, false)) {
}
while (r2.hasNext()) {
}
if (set != null) {
}
}
mVar2 = mVar;
if (c(mVar2)) {
Logger.d(G, "interstitial finder start - starting timer for InterstitialInfo with eventId " + mVar2.v());
mVar2.af = this.B.scheduleAtFixedRate(new b(mVar2.I), H, 1000L, TimeUnit.MILLISECONDS);
}
}
}
private boolean c(m mVar) {
Logger.d(G, "shouldStartTimer started, taskFuture = " + (mVar != null ? mVar.af : "") + ", isisCancelled = " + ((mVar == null || mVar.af == null) ? "" : Boolean.valueOf(mVar.af.isCancelled())));
return mVar != null && (mVar.af == null || mVar.af.isCancelled()) && !(mVar.ah == null && (mVar.h() == null || mVar.h().f() == null));
}
public void a(Activity activity, m mVar) {
if (activity != null) {
String[] strArr = {BrandSafetyUtils.a(activity.toString(), false), BrandSafetyUtils.a(activity.toString(), true)};
String obj = activity.toString();
mVar.V = obj;
mVar.ah = activity;
mVar.a(strArr);
this.D.remove((Object) activity.toString());
Logger.d(G, "interstitial info activity details set : " + activity.getClass() + ", sdk = " + mVar.u + ", activity name = " + obj + ", activities = " + this.D.a());
return;
}
Logger.d(G, "cannot set interstitial info activity details, activity is null");
}
public synchronized List<n> a(String str, m mVar) {
ArrayList arrayList;
arrayList = new ArrayList();
List<n> list = this.N.get(str);
com.safedk.android.utils.k.b(G, "pending ci check, number of pending CIs: " + (list != null ? list.size() : 0) + ", cis : " + (list != null ? list.toString() : "null"));
Logger.d(G, "pending ci check, pending object addresses are: " + a(list));
if (list != null) {
Iterator<n> it = list.iterator();
while (it.hasNext()) {
n next = it.next();
Logger.d(G, "pending ci check, matching method: " + next.b);
if (a(next.a, mVar)) {
if (next.a != null) {
next.a.r("pendingCIMatch|listSize=" + list.size() + "|info=" + next.c + ";" + next.b + "|object=" + next.a.ac() + ";" + next.a.ad());
}
it.remove();
Logger.d(G, "pending ci check, creative info is the pending creative info: " + next);
arrayList.add(next);
}
}
}
return arrayList;
}
private boolean a(CreativeInfo creativeInfo, m mVar) {
Logger.d(G, "verify matching - current activity interstitial: " + mVar);
if (mVar != null && mVar.I != null && creativeInfo.l() != null && !mVar.I.equals(creativeInfo.l())) {
Logger.d(G, "verify matching - incompatible event ID, ci: " + creativeInfo.l() + ", info: " + mVar.I);
return false;
}
AdNetworkDiscovery f = CreativeInfoManager.f(creativeInfo.O() == null ? creativeInfo.N() : creativeInfo.O());
if (mVar != null && f != null) {
if (f.b() == AdNetworkDiscovery.WebViewResourceMatchingMethod.DIRECT_CREATIVE_INFO) {
if (mVar.q() != null) {
String string = mVar.q().getString(BrandSafetyEvent.k);
String string2 = mVar.q().getString("ad_format");
if ((creativeInfo.C() == null || (string != null && string.equals(creativeInfo.C()))) && string2 != null && string2.startsWith(creativeInfo.F())) {
Logger.d(G, "verify matching DIRECT_CREATIVE_INFO, CI placement: " + creativeInfo.C() + ", CI format: " + creativeInfo.F());
return true;
}
Logger.d(G, "verify matching DIRECT_CREATIVE_INFO, verification failed for CI placement: " + creativeInfo.C() + ", CI format: " + creativeInfo.F());
return false;
}
} else {
return a(creativeInfo.ac(), creativeInfo.ad(), mVar);
}
}
Logger.d(G, "verify matching, no InterstitialInfo or no discovery for " + creativeInfo.N());
return false;
}
private boolean a(String str, String str2, m mVar) {
if (mVar == null) {
return false;
}
Logger.d(G, "verify matching object started, event ID: " + mVar.I + ", object address: " + str2 + ", webview address: " + mVar.H + ", object type: " + str + ", currentActivityInterstitial = " + mVar);
boolean a2 = CreativeInfoManager.a(mVar.u, AdNetworkConfiguration.SDK_INTERSTITIALS_RUN_ON_APP_ACTIVITY, false);
if (str2 == null || MediaPlayer.class.getCanonicalName().equals(str) || a2) {
Logger.d(G, "verify matching object skipped, event ID: " + mVar.I + ", object address: " + str2 + ", object type: " + str + ", sdkInterstitialsRunOnAppActivity: " + a2);
return true;
}
if (mVar.w() != null && mVar.w().contains(str2)) {
Logger.d(G, "verify matching object done, event ID: " + mVar.I + ", object address: " + str2 + ", views hierarchy: " + mVar.w());
return true;
}
Logger.d(G, "verify matching object failed, event ID: " + mVar.I + ", object address: " + str2 + ", views hierarchy: " + mVar.w());
return false;
}
@Override
public synchronized void a(String str) {
Logger.d(G, "stop timers - canceling timer for interstitials, eventId = " + str);
m e = this.L.e(str);
if (e != null) {
if (e != null && e.r() == 0) {
e.U = null;
}
if (this.L.size() < 1 || this.L.a()) {
this.M = 0L;
}
if (e.af != null) {
Logger.d(G, "stop timers - calling timer cancel.");
e.af.cancel(false);
}
}
}
@Override
public List<CreativeInfo> a(String str, String str2) {
for (m mVar : this.L.values()) {
if (mVar != null && mVar.H != null && mVar.H.equals(str2)) {
List<CreativeInfo> j = mVar.j();
if (!j.isEmpty()) {
Logger.d(G, "get current CIs for webview address: " + str2 + ", found " + j.size() + " matched CIs");
return j;
}
return j;
}
}
return null;
}
@Override
public synchronized List<CreativeInfo> c(String str, String str2) {
List arrayList;
List i;
Iterator<m> it = this.L.values().iterator();
while (true) {
if (it.hasNext()) {
m next = it.next();
if (next != null && (i = next.i()) != null && !i.isEmpty() && i.get(0) != null && ((CreativeInfo) i.get(0)).I().equals(str2)) {
arrayList = i;
break;
}
} else {
List<n> list = this.N.get(str);
if (list != null) {
List arrayList2 = new ArrayList();
for (n nVar : list) {
if (nVar.a != null && nVar.a.I().equals(str2)) {
arrayList2.add(nVar.a);
}
}
arrayList = arrayList2;
} else {
arrayList = new ArrayList();
}
}
}
return arrayList;
}
public synchronized void c(Activity activity) {
try {
Logger.d(G, "interstitial finder stop, activity = " + activity.toString());
m c = this.L.c(activity.toString());
if (c != null && (c.V == null || activity.toString().equals(c.V))) {
Logger.d(G, "Stopping interstitial finder for activity " + c.V);
a(c.I);
Logger.d(G, "interstitial finder, viewing time (ms) = " + c.R);
}
} catch (Throwable th) {
Logger.e(G, th.getMessage(), th);
new CrashReporter().caughtException(th);
}
}
@Override
public synchronized void b(String str) {
Logger.d(G, "Activity destroyed activity class: " + str + ", activities: " + this.D);
if (str != null) {
this.D.remove((Object) str);
String sdkPackageByClass = SdksMapping.getSdkPackageByClass(str);
m c = this.L.c(str);
if (c != null) {
if (sdkPackageByClass != null && c.u != null && !sdkPackageByClass.equals(c.u)) {
Logger.d(G, "Activity destroyed, activity SDK does not fit the WILL_DISPLAY msg: " + sdkPackageByClass);
} else if (c.V != null && !c.V.equals(str)) {
Logger.d(G, "Activity destroyed, activity address (" + str + " ) does not match the address of the ad's activity (" + c.V + ")");
} else {
Logger.d(G, "Activity destroyed, calling onAdHidden");
a(c, str);
}
}
}
}
public void a(Bundle bundle) {
m mVar;
Logger.d(G, "handle Revenue event started, data = " + bundle + ", info keys : " + this.L.keySet());
if (bundle.containsKey("id")) {
String string = bundle.getString("id");
if (this.L.containsKey(string) && (mVar = this.L.get(string)) != null) {
if (bundle.getString("revenue_event") != null) {
mVar.M = bundle.getString("revenue_event");
} else {
mVar.M = "unknown";
}
f(mVar, "handleRevenueEvent");
Logger.d(G, "Revenue event set to " + bundle.getString("revenue_event") + " for eventId " + string);
return;
}
Logger.d(G, "Revenue event - no interstitial info found for event " + string);
}
}
public synchronized void a(m mVar, String str) {
Logger.d(G, "Ad hidden started, activityClass=" + (str == null ? "null" : str) + ", interstitial infos=" + this.L.toString());
if (mVar != null && j(str)) {
Logger.d(G, "Ad hidden " + mVar.c() + " activity " + str + " unloaded but this is not the end of impression. not calling cleanAndReport");
} else {
e(mVar, str);
}
}
private synchronized void e(m mVar, String str) {
try {
if (mVar == null) {
Logger.d(G, "clean and report - current interstitial info is NULL, SKIPPING");
} else {
Logger.d(G, "clean and report started, activity class=" + str + ", eventId = " + mVar.I);
mVar.e(true);
if (str == null) {
str = mVar.V;
Logger.d(G, "clean and report - activity class set to (curr intractname) " + mVar.V);
}
String sdkPackageByClass = SdksMapping.getSdkPackageByClass(str);
for (k kVar : mVar.f()) {
if (kVar.b != null) {
Logger.d(G, "clean and report - activity SDK = " + sdkPackageByClass + ", CI SDK = " + kVar.b.N() + ", interstitial activity name=" + mVar.V);
Logger.d(G, "clean and report - currentMaxPackageName = " + mVar.u + ", activitySdk = " + sdkPackageByClass);
if (mVar.u != null && !mVar.u.equals(sdkPackageByClass) && !mVar.u.equals(kVar.b.N()) && !mVar.ae) {
Logger.d(G, "clean and report - skip reporting as no related WILL_DISPLAY message received, current Max package name: " + mVar.u + ", activity SDK: " + sdkPackageByClass + ", CI SDK: " + kVar.b.N());
kVar.b = null;
}
}
}
for (k kVar2 : mVar.f()) {
if (kVar2.c != null && kVar2.c.b != null) {
kVar2.d = kVar2.c.b;
} else if (mVar.b() != null) {
kVar2.d = mVar.b();
}
Logger.d(G, "clean and report - last impression screenshot filename set to " + kVar2.d);
}
if ((mVar.A != null && mVar.A.equals(BrandSafetyUtils.a(str, true))) || CreativeInfoManager.a(mVar.c(), AdNetworkConfiguration.SDK_INTERSTITIALS_RUN_ON_APP_ACTIVITY, false)) {
for (k kVar3 : mVar.f()) {
if (kVar3 != null && kVar3.c != null && kVar3.c.b != null && mVar.b() != null) {
if (this.z.size() < SafeDK.getInstance().H()) {
Logger.d(G, "clean and report - image files: " + kVar3.c.b + ", " + mVar.s);
Logger.d(G, "clean and report - waiting to report file: " + mVar.s + ", impression ID: " + kVar3.a);
a(mVar, kVar3);
com.safedk.android.utils.k.b(G, "adInfoCollectionForUpload addAdInfoCollectionForUpload count = " + this.z.size() + " : " + this.z);
} else if (!d(mVar.r, kVar3.a)) {
BrandSafetyUtils.c(mVar.s);
mVar.U = null;
mVar.s = null;
}
Logger.d(G, "clean and report - hash value: " + kVar3.c.a + " orientation: " + kVar3.c.f);
if (kVar3.c.a == null && !mVar.Z) {
Logger.d(G, "clean and report - assigning last captured hash to interstitial: " + mVar.U);
kVar3.c.a = mVar.U;
kVar3.c.f = mVar.t;
}
}
}
mVar.aa = SystemClock.elapsedRealtime();
mVar.R += mVar.aa - mVar.Y;
Logger.d(G, "clean and report - Viewing time (ms) = " + mVar.R);
for (CreativeInfo creativeInfo : mVar.i()) {
com.safedk.android.analytics.brandsafety.creatives.e.a(creativeInfo.ad());
com.safedk.android.analytics.brandsafety.creatives.e.a(creativeInfo);
if (!TextUtils.isEmpty(mVar.z())) {
creativeInfo.r(mVar.z());
}
}
Logger.d(G, "clean and report - number of CIs to report: " + mVar.i().size());
f(mVar, "onAdHidden");
} else {
Logger.d(G, "clean and report - DID NOT enter unload logic, current interstitial info=" + mVar);
}
if (str != null) {
Logger.d(G, "clean and report - removing from activities : " + str);
this.D.remove((Object) str);
}
}
} catch (Throwable th) {
Logger.e(G, "Exception in clean and report : " + th.getMessage(), th);
new CrashReporter().caughtException(th);
} finally {
a(mVar.I);
k(mVar.I);
}
}
private void k(String str) {
Logger.d(G, "clearing AppLovin bundle, eventId = " + str);
this.E = this.L.size() != 0;
Logger.d(G, "maxAdIsActive set to " + this.E);
if (str != null) {
this.L.keySet().remove(str);
Logger.d(G, "Removing " + str + " from currentInterstitialInfos");
}
}
public synchronized void f(m mVar, String str) {
String str2;
String str3;
synchronized (this) {
com.safedk.android.utils.k.b(G, "reporting event started, root= " + str + ", info=" + mVar);
if (mVar == null || !mVar.Q) {
Logger.d(G, "reporting event - info is not interstitial, don't report info");
} else {
boolean z = !mVar.D;
boolean z2 = !mVar.E && mVar.d();
if (mVar.z != null && mVar.z.containsKey("id")) {
str2 = mVar.z.getString("id");
Logger.d(G, "reporting event - event ID: " + str2);
} else {
Logger.d(G, "reporting event - no event ID");
str2 = null;
}
ArrayList arrayList = new ArrayList();
if (mVar.i().isEmpty()) {
arrayList.add(a(mVar, mVar.g(), z2, str2, (String) null));
} else {
Logger.d(G, "reporting event - number of CIs: " + mVar.i().size());
for (k kVar : mVar.f()) {
if (kVar.b != null && !mVar.c().equals(kVar.b.N())) {
Logger.d(G, "reporting event without CI - sdk: " + mVar.c() + ", CI sdk: " + kVar.b.N() + ", CI actual sdk: " + kVar.b.O());
kVar.b = null;
}
Logger.d(G, "reporting event (Check) root = " + str + ", ciDebugInfo = " + mVar.z());
List asList = Arrays.asList(com.safedk.android.utils.g.i, com.safedk.android.utils.g.b, "com.unity3d.ads");
if (!TextUtils.isEmpty(mVar.z()) && str.equals("onAdHidden") && kVar.b != null && asList.contains(kVar.b.N()) && mVar.z != null && mVar.z.containsKey("ad_format") && mVar.z.getString("ad_format") != null && mVar.z.getString("ad_format").equals(BrandSafetyUtils.l)) {
kVar.b.r(mVar.z());
String maxEvents = o.a().c().toString();
com.safedk.android.utils.k.b(G, "reporting event Invalid AppOpen impression detected ciDebugInfo = " + mVar.z() + " , lastMaxEvents = " + maxEvents);
kVar.b.r(maxEvents);
}
if (kVar.c != null) {
Logger.d(G, "reporting event - image uniformity: " + kVar.c.a(1000));
str3 = (kVar.c.a == null || mVar.Z) ? null : kVar.c.a + "_" + kVar.a;
g(mVar, str3);
} else {
str3 = null;
}
arrayList.add(a(mVar, kVar, z2, str2, str3));
}
}
Logger.d(G, "reporting event " + str2 + ", viewingTime = " + mVar.R);
if (StatsCollector.c() != null) {
StatsCollector.c().a(arrayList);
} else {
Logger.w(G, "reporting event - stats collector instance is null, cannot report brand safety event");
}
if (z) {
mVar.b(true);
}
if (z2) {
mVar.c(true);
}
}
}
}
private BrandSafetyEvent a(m mVar, k kVar, boolean z, String str, String str2) {
return new BrandSafetyEvent(mVar.c(), mVar.y, str2, z, mVar.d() ? mVar.e() : null, kVar.b, mVar.a(), mVar.B, kVar.a != null ? kVar.a : "", mVar.C, mVar.R, mVar.R > 0, mVar.z, kVar.c != null ? kVar.c.f : null, kVar.c != null ? kVar.c.g : false, kVar.c != null ? kVar.c.c : 0L, kVar.c != null ? kVar.c.a(1000) : 0.0f, mVar.x, SafeDK.getInstance().e(), str, mVar.J, mVar.K, mVar.M);
}
private void g(m mVar, String str) {
Logger.d(G, "add CI debug info started, hashValue " + str + ", info=" + mVar.toString());
for (k kVar : mVar.f()) {
if (kVar.b != null && kVar.c != null && str != null && kVar.c.a != null && kVar.c.f != null && mVar.m() != null) {
String a2 = BrandSafetyUtils.a(BrandSafetyUtils.AdType.INTERSTITIAL, kVar.c.a, mVar.c(), mVar.m(), kVar.c.f);
if (new File(a2).exists()) {
if (kVar.b.Y() == null || !kVar.b.Y().contains("screenshot_datetime")) {
long currentTimeMillis = System.currentTimeMillis();
kVar.b.r("screenshot_datetime" + CertificateUtil.DELIMITER + currentTimeMillis);
Logger.d(G, "add CI debug info: " + currentTimeMillis);
} else {
Logger.d(G, "add CI debug info - stats repo is null or already contains this event");
}
} else {
Logger.d(G, "add CI debug info - screenshot file path doesn't exist: " + a2);
}
} else {
Logger.d(G, "add CI debug info - no creative info or hash is null");
}
if (kVar != null && kVar.b != null && this.z.size() > 2) {
Logger.d(G, "add CI debug info - adding pending images info to ci_debug_info : image_id_pending : " + this.z.keySet());
kVar.b.r("image_id_pending : " + this.z.keySet());
}
}
}
public synchronized void a(m mVar) {
Logger.d(G, "take screenshot - started, interstitialInfo = " + mVar);
b(mVar, (String) null);
}
synchronized void b(final m mVar, final String str) {
Logger.d(G, "take screenshot - currentActivityInterstitial = " + mVar);
Activity activity = mVar.ah;
if (mVar != null && mVar.A()) {
Logger.d(G, "take screenshot - sdk Interstitials Run On App Activity = " + mVar.ae);
if (mVar.ah != null && !BrandSafetyUtils.c(activity.getClass()) && !mVar.ae) {
Logger.d(G, "take screenshot - The activity is not supported : " + activity.getClass());
} else {
final String str2 = mVar.u;
Activity d = d(mVar);
Logger.d(G, "take screenshot - activity = " + d);
d.runOnUiThread(new Runnable() {
@Override
public void run() {
boolean z = false;
try {
synchronized (InterstitialFinder.this) {
if (mVar != null) {
Logger.d(InterstitialFinder.G, "take screenshot - Run on UI thread in " + mVar.V);
View B = mVar.B();
CreativeInfo h = mVar.h();
String c = (h == null || h.O() == null) ? mVar.c() : h.O();
Logger.d(InterstitialFinder.G, "take screenshot - AdMob sdk package name is " + c);
boolean equals = com.safedk.android.utils.g.h.equals(c);
boolean equals2 = com.safedk.android.utils.g.f.equals(mVar.c());
if (h != null && VungleCreativeInfo.a.equals(h.h())) {
z = true;
}
if (z) {
Logger.d(InterstitialFinder.G, "take screenshot - This ad is a VUNGLE_MRAID_AD");
}
if (h != null) {
Logger.d(InterstitialFinder.G, "take screenshot - is video ad? " + h.u() + ", is vast video ad? " + h.x() + ", is multi ad? " + h.af());
}
boolean a2 = CreativeInfoManager.a(str2, AdNetworkConfiguration.DETECT_MULTIPLE_ADS_BY_WEB_VIEW_CHANGE, false);
if (!SafeDK.getInstance().G() && !equals && !equals2) {
if (h == null) {
Logger.d(InterstitialFinder.G, "don't take screenshot - no creative info yet");
} else if (h.v()) {
Logger.d(InterstitialFinder.G, "don't take screenshot - ad is playable");
} else if (h.af() && !a2) {
Logger.d(InterstitialFinder.G, "don't take screenshot - multi ad, sdk: " + str2);
} else if (!h.u()) {
Logger.d(InterstitialFinder.G, "take screenshot - ad is not a video/playable ad");
InterstitialFinder.this.a(mVar, B, str2, str);
} else if (!mVar.W && !CreativeInfoManager.a(h.N(), AdNetworkConfiguration.SHOULD_TAKE_INTERSTITIAL_SCREENSHOTS_THROUGHOUT_IMPRESSION, false)) {
if (InterstitialFinder.this.a(mVar, B)) {
Logger.d(InterstitialFinder.G, "take screenshot - native video player completed");
InterstitialFinder.this.a(mVar, B, str2, str);
} else {
Logger.d(InterstitialFinder.G, "don't take screenshot - video hasn't finished playing yet, waiting for video completed event");
}
} else {
Logger.d(InterstitialFinder.G, "take screenshot - video ad finished playing or sdk configured to take screenshots throughout the impression");
InterstitialFinder.this.a(mVar, B, str2, str);
}
} else if (SafeDK.getInstance().G()) {
Logger.d(InterstitialFinder.G, "take screenshot - SafeDK Config item 'AlwaysTakeScreenshot' is true");
InterstitialFinder.this.a(mVar, B, str2, str);
} else if (h == null) {
Logger.d(InterstitialFinder.G, "don't take screenshot - Admob/IronSource SDK but no ci yet");
} else if (h.af() && !a2) {
Logger.d(InterstitialFinder.G, "don't take screenshot - multi ad, sdk: " + str2);
} else {
Logger.d(InterstitialFinder.G, "take screenshot - Admob/IronSource SDK");
InterstitialFinder.this.a(mVar, B, str2, str);
}
}
}
} catch (Throwable th) {
Logger.e(InterstitialFinder.G, "Failed while taking screenshot", th);
new CrashReporter().caughtException(th);
}
}
});
}
}
}
public boolean a(m mVar, View view) {
AdNetworkDiscovery f = CreativeInfoManager.f(mVar.c());
if (f == null || !mVar.N) {
return false;
}
return f.a(view);
}
private Activity d(m mVar) {
if (mVar.ae) {
return com.safedk.android.internal.b.getInstance().getForegroundActivity();
}
return mVar.ah;
}
private String b(Bundle bundle) {
String string = bundle.getString("ad_format");
if (string == null) {
return null;
}
if (string.equals(BrandSafetyUtils.k)) {
return BrandSafetyEvent.AdFormatType.REWARD.name();
}
if (string.equals(BrandSafetyUtils.j)) {
return BrandSafetyEvent.AdFormatType.INTER.name();
}
if (!string.equals(BrandSafetyUtils.l)) {
return null;
}
return BrandSafetyEvent.AdFormatType.APPOPEN.name();
}
@Override
public synchronized boolean a(n nVar) {
m mVar;
boolean z;
BrandSafetyEvent.AdFormatType a2;
BrandSafetyEvent.AdFormatType a3;
Logger.d(G, "set CI details started, matchingInfo = " + nVar.toString());
CreativeInfo creativeInfo = nVar.a;
if (creativeInfo == null) {
z = false;
} else {
creativeInfo.g(BrandSafetyUtils.ScreenShotOrientation.PORTRAIT.equals(BrandSafetyUtils.c()));
m mVar2 = null;
if (creativeInfo.l() != null) {
mVar2 = this.L.e(creativeInfo.l());
Logger.d(G, "set CI details attempt to locate interstitial info by eventId " + creativeInfo.l() + ", success? " + (mVar2 != null));
}
if (mVar2 == null && creativeInfo.ad() != null) {
mVar2 = this.L.b(creativeInfo.ad());
Logger.d(G, "set CI details attempt to locate interstitial info by matching object address " + creativeInfo.ad() + ", success ? " + (mVar2 != null));
}
if (mVar2 == null) {
List<m> a4 = this.L.a(creativeInfo.N());
if (a4.size() == 1) {
m mVar3 = a4.get(0);
Logger.d(G, "set CI details found 1 InterstitialInfo object by sdk " + creativeInfo.N());
mVar = mVar3;
} else if (a4.size() > 1) {
Logger.d(G, "set CI details found " + a4.size() + " InterstitialInfo objects by sdk " + creativeInfo.N() + " : " + a4);
mVar = mVar2;
} else {
Logger.d(G, "set CI details no InterstitialInfo object not found");
}
Logger.d(G, "set CI details - ad info sdk: " + (mVar == null ? mVar.c() : "null") + ", CI sdk: " + creativeInfo.N() + " ad info webview address: " + (mVar == null ? mVar.H : "null") + ", ci matching object address: " + creativeInfo.ad());
if (mVar != null && mVar.z != null) {
Logger.d(G, "set CI details - CI ad format: " + creativeInfo.F() + ", max ad type: " + mVar.z.getString("ad_format"));
if ((creativeInfo.F() != null || !creativeInfo.F().equals(mVar.z.getString("ad_format"))) && (a3 = BrandSafetyUtils.a(mVar.z)) != null) {
Logger.d(G, "set CI details - updating ad format value to " + a3.name());
creativeInfo.n(a3.name());
mVar.e("ad_type_upd(sCrInfoDtls):" + a3.name());
}
}
if (mVar != null && mVar.u != null && (mVar.u.equals(creativeInfo.N()) || mVar.u.equals(creativeInfo.O()))) {
Logger.d(G, "set CI details - currentMaxPackageName: " + mVar.u);
if (a(creativeInfo, mVar)) {
Logger.d(G, "set CI details - setting as current CI for SDK: " + creativeInfo.N());
if (mVar.h() != null) {
Logger.d(G, "set CI details - replacing " + mVar.h());
}
if (creativeInfo.F() == null && (a2 = BrandSafetyUtils.a(mVar.z)) != null) {
Logger.d(G, "Start monitoring ad check, updating ad format value to " + a2.name());
creativeInfo.n(a2.name());
mVar.e("ad_type_upd(shldStrtMntrngAd):" + a2.name());
}
b(creativeInfo, mVar);
z = a(nVar, mVar);
}
}
Logger.d(G, "set CI details - adding as pending for SDK: " + creativeInfo.N() + " matching info: " + nVar);
a(nVar, creativeInfo.N());
b(creativeInfo, mVar);
z = false;
}
mVar = mVar2;
Logger.d(G, "set CI details - ad info sdk: " + (mVar == null ? mVar.c() : "null") + ", CI sdk: " + creativeInfo.N() + " ad info webview address: " + (mVar == null ? mVar.H : "null") + ", ci matching object address: " + creativeInfo.ad());
if (mVar != null) {
Logger.d(G, "set CI details - CI ad format: " + creativeInfo.F() + ", max ad type: " + mVar.z.getString("ad_format"));
if (creativeInfo.F() != null) {
}
Logger.d(G, "set CI details - updating ad format value to " + a3.name());
creativeInfo.n(a3.name());
mVar.e("ad_type_upd(sCrInfoDtls):" + a3.name());
}
if (mVar != null) {
Logger.d(G, "set CI details - currentMaxPackageName: " + mVar.u);
if (a(creativeInfo, mVar)) {
}
}
Logger.d(G, "set CI details - adding as pending for SDK: " + creativeInfo.N() + " matching info: " + nVar);
a(nVar, creativeInfo.N());
b(creativeInfo, mVar);
z = false;
}
return z;
}
private void b(CreativeInfo creativeInfo, m mVar) {
if (mVar != null) {
if (mVar.af == null || mVar.af.isCancelled()) {
if (!mVar.ag) {
Logger.d(G, "set CI details - starting timer for InterstitialInfo with event id: " + mVar.v());
e(mVar);
mVar.R = 0L;
mVar.af = this.B.scheduleAtFixedRate(new b(mVar.I), H, 1000L, TimeUnit.MILLISECONDS);
return;
}
Logger.d(G, "set CI details - avoid recursive call to web view scanning");
creativeInfo.r("avoidRecWebScan");
}
}
}
private synchronized void a(n nVar, String str) {
List<n> list = this.N.get(str);
if (list == null) {
list = new ArrayList<>();
this.N.put(str, list);
}
list.add(nVar);
}
public synchronized boolean a(n nVar, m mVar) {
boolean z = false;
synchronized (this) {
com.safedk.android.utils.k.b(G, "set CI started, matching info=" + (nVar == null ? "null" : nVar.toString()));
if (nVar == null) {
com.safedk.android.utils.k.b(G, "set CI, matching info is null");
} else {
CreativeInfo creativeInfo = nVar.a;
if (creativeInfo != null) {
Logger.d(G, "set CI, matching info is " + nVar);
if (mVar != null) {
if (mVar.h() != null && !mVar.h().af()) {
CreativeInfoManager.b(creativeInfo);
com.safedk.android.utils.k.b(G, "set CI, already matched! ignore matching attempt CI: " + creativeInfo);
} else {
if (creativeInfo.R() != null && !creativeInfo.R().contains("wv=" + mVar.H)) {
creativeInfo.r("wv=" + mVar.H);
}
creativeInfo.a(nVar.b, nVar.c);
Logger.d(G, "set CI: " + creativeInfo);
mVar.a(creativeInfo);
if (mVar.G == AdNetworkDiscovery.WebViewResourceMatchingMethod.WEBVIEW_LOOKUP && mVar.H != null) {
com.safedk.android.analytics.brandsafety.creatives.e.a(mVar.H, creativeInfo);
} else {
com.safedk.android.analytics.brandsafety.creatives.e.a(creativeInfo, (String) null);
}
if (nVar.b.startsWith(CreativeInfo.h)) {
mVar.t();
}
f(mVar, "setCreativeInfo");
if (creativeInfo.u()) {
mVar.W = false;
}
if (!mVar.ac) {
StatsReporter.b().a(creativeInfo, mVar.z);
mVar.ac = true;
}
z = true;
}
}
}
}
}
return z;
}
@Override
public synchronized void a(String str, String str2, String str3) {
Logger.d(G, "set ad click URL started, sdk: " + str2 + ", url: " + str + ", view address: " + str3);
String mainSdkPackage = SdksMapping.getMainSdkPackage(str2);
m b2 = this.L.b(str3);
if (b2 == null && this.L.a(mainSdkPackage).size() == 1) {
Logger.d(G, "InterstitialInfo not found by address, trying by SdkPackageName " + mainSdkPackage);
b2 = this.L.a(mainSdkPackage).get(0);
}
if (b2 != null && b2.c() != null && SdksMapping.isSameSdkByPackages(b2.c(), mainSdkPackage)) {
Logger.d(G, "set ad click URL - applying clickUrl candidate logic. url: " + str);
if (!b2.d()) {
Logger.d(G, "set ad click URL - current Activity Interstitial is not marked as clicked, setting click URL: " + str);
c(b2, str);
} else if (b2.e() == null) {
Logger.d(G, "set ad click URL - no click URL yet, setting clickUrl: " + str);
b2.c(str);
} else {
Logger.d(G, "set ad click URL - click URL already set: " + b2.e());
}
} else {
Logger.d(G, "set ad click URL skipped, SDK: " + (b2 != null ? b2.c() : "null"));
}
}
@Override
public synchronized void b(String str, String str2, String str3) {
m b2 = this.L.b(str3);
if (b2 != null && b2.d() && str2 != null && str2.equals(b2.c()) && b2.ah != null) {
String obj = b2.ah.toString();
Logger.d(G, "set previous activity click url, click activity: " + obj + ", ad activity: " + b2.V);
String a2 = BrandSafetyUtils.a(obj, true);
if (a2 != null && !a2.equals(b2.A)) {
Logger.d(G, "set previous activity click url - detected URL for click in previous activity (not yet destroyed), url: " + str);
if (b2.c(str)) {
f(b2, "setPreviousActivityClickUrl");
}
}
}
}
public synchronized void a(m mVar, View view, String str, String str2) {
if (mVar != null) {
try {
Logger.d(G, "taking screenshot started");
String c = mVar.c();
Bitmap a2 = new com.safedk.android.analytics.brandsafety.creatives.f().a(view, SafeDK.getInstance().D());
if (a2 != null) {
BrandSafetyUtils.a a3 = BrandSafetyUtils.a(c, a2);
int a4 = a3.a();
if (BrandSafetyUtils.a(c, a3)) {
String a5 = BrandSafetyUtils.a(a2);
Logger.d(G, "taking screenshot found interstitial, hash = " + a5);
if (mVar != null && mVar.m() != null) {
mVar.ab = BrandSafetyUtils.b(a2);
Logger.d(G, "taking screenshot impressionId is " + mVar.m());
} else {
Logger.d(G, "taking screenshot impressionId is null");
}
String m = (mVar == null || mVar.m() == null) ? "" : mVar.m();
String a6 = BrandSafetyUtils.a(a2, BrandSafetyUtils.AdType.INTERSTITIAL, a5, c, m, mVar.ab);
Logger.d(G, "taking screenshot screenshot file created, filename = " + a6);
long b2 = BrandSafetyUtils.b(a6);
AdNetworkDiscovery f = CreativeInfoManager.f(c);
if (f != null && b2 < f.a(mVar.h())) {
Logger.d(G, "taking screenshot file size too small " + b2 + " (bytes). This image will not be used");
BrandSafetyUtils.c(a6);
} else {
Logger.d(G, "taking screenshot stored file size is " + b2 + " bytes, counter is " + mVar.x + ", uniform pixel count is " + a4 + " (" + ((a4 / 1000.0f) * 100.0f) + "%)");
int size = this.z.size();
if (!e(a5, m)) {
boolean z = false;
if (size < SafeDK.getInstance().H()) {
Logger.d(G, "taking screenshot impressions to report size=" + size + ", max images to store=" + SafeDK.getInstance().H());
if (mVar != null && mVar.U == null) {
z = true;
} else if (mVar != null && mVar.U != null && !mVar.U.equals(a5)) {
Logger.d(G, "taking screenshot removing previous file : " + mVar.s);
BrandSafetyUtils.c(mVar.s);
z = true;
}
if (z) {
Logger.d(G, "taking screenshot keeping file of interstitial " + a5 + ". file size is " + b2 + " (bytes), orientation: " + mVar.ab);
mVar.U = a5;
mVar.s = a6;
mVar.t = mVar.ab;
BrandSafetyUtils.a(mVar.s(), BrandSafetyUtils.AdType.INTERSTITIAL, a5, c, m, mVar.ab);
}
} else if (!d(a5, m)) {
Logger.d(G, "taking screenshot no open slot for interstitial " + a5 + "; next hashes to be reported to server are " + this.z.keySet());
BrandSafetyUtils.c(a6);
a5 = null;
} else {
Logger.d(G, "taking screenshot image " + a5 + "_" + m + " is already scheduled for upload");
}
} else {
Logger.d(G, "taking screenshot not saving file for interstitial " + a5 + "_" + m);
BrandSafetyUtils.c(a6);
if (e(a5, m)) {
Logger.d(G, "taking screenshot interstitial " + a5 + "_" + m + " was already reported");
} else {
Logger.d(G, "taking screenshot waiting to report stored interstitial " + mVar.U);
}
if (mVar.U != null) {
if (d(mVar.U, mVar.m())) {
BrandSafetyUtils.c(mVar.s);
} else {
Logger.d(G, "taking screenshot not deleting not best image " + mVar.s);
}
}
}
boolean z2 = false;
if (mVar != null && a5 != null) {
Logger.d(G, "taking screenshot setting interstitial info data (previous hash = " + mVar.U + ", current hash = " + a5 + ")");
z2 = (a5 == null || mVar.U == null || a5.equals(mVar.U)) ? false : true;
}
if (mVar != null) {
if (mVar.ab.equals(BrandSafetyUtils.ScreenShotOrientation.NOT_INITIALIZED)) {
mVar.ab = BrandSafetyUtils.b(a2);
}
k g = mVar.g();
if (g != null) {
Logger.d(G, "taking screenshot setting image details: " + g.c);
g.c = new i(a5, a6, b2, a4, mVar.x, mVar.ab, z2);
}
}
if (mVar.U == null) {
Logger.d(G, "taking screenshot no previous hash to detect animation, keep sampling");
mVar.U = a5;
} else if (a(a4, b2)) {
i k = mVar.k();
if (k != null) {
k.g = z2;
Logger.d(G, "taking screenshot setting interstitial is_animated field to " + z2);
}
if (!TextUtils.isEmpty(a5)) {
if (mVar.ab.equals(BrandSafetyUtils.ScreenShotOrientation.NOT_INITIALIZED) && k != null) {
k.f = BrandSafetyUtils.b(a2);
}
f(mVar, "takeScreenshot");
mVar.d(true);
}
a(mVar.I);
} else {
mVar.U = a5;
}
}
} else {
Logger.d(G, "taking screenshot screenshot is not valid (uniform pixel count too high: " + a4 + "), try again...");
if (mVar != null && mVar.S && mVar.W) {
Logger.d(G, "taking screenshot back from background - reset video completed indication to false");
mVar.S = false;
mVar.W = false;
}
}
}
} catch (Throwable th) {
Logger.e(G, "taking screenshot taking screenshot exception:", th);
Logger.printStackTrace();
new CrashReporter().caughtException(th);
}
}
}
private synchronized String a(View view) {
return BrandSafetyUtils.b(view.getClass());
}
protected synchronized String a(ViewGroup viewGroup) {
String str;
if (viewGroup != null) {
int i = 0;
while (true) {
int i2 = i;
if (i2 >= viewGroup.getChildCount()) {
str = null;
break;
}
View childAt = viewGroup.getChildAt(i2);
if (childAt instanceof WebView) {
int width = childAt.getWidth();
int height = childAt.getHeight();
Logger.d(G, "View = " + childAt + ": width = " + width + " height = " + height);
if (childAt.getVisibility() == 0 && a(width, height)) {
str = a(childAt);
Logger.d(G, "Found full screen webview of SDK = " + str);
break;
}
i = i2 + 1;
} else if (!(childAt instanceof ViewGroup)) {
i = i2 + 1;
} else {
str = a((ViewGroup) childAt);
break;
}
}
} else {
str = null;
}
return str;
}
private boolean a(int i, int i2) {
return i == BrandSafetyUtils.a() && i2 == BrandSafetyUtils.b();
}
private synchronized boolean a(int i, long j) {
boolean z;
Logger.d(G, "should stop sampling started, maxUniformedPixelsCount=" + i + ", fileSize=" + j + " (bytes), stopSamplingFileSize=" + SafeDK.getInstance().I());
z = BrandSafetyUtils.a(i) && j > SafeDK.getInstance().I();
Logger.d(G, "should stop sampling returned " + z);
return z;
}
@Override
public void g() {
if (this.L != null) {
for (m mVar : this.L.values()) {
if (mVar != null && mVar.Q) {
f(mVar, "onBackground");
}
}
}
}
@Override
public synchronized void h() {
if (this.L != null) {
for (m mVar : this.L.values()) {
if (mVar != null) {
mVar.S = true;
}
}
}
}
public synchronized void e(final m mVar) {
if (mVar != null) {
if (!mVar.ag) {
Activity activity = mVar.ah;
Logger.d(G, "scan for webViews started, activity: " + (activity == null ? "null" : activity.toString()) + ", currentActivityInterstitial.resourceMatching: " + mVar.G);
if (activity == null || !BrandSafetyUtils.f(activity.getClass().getName())) {
try {
if (mVar.G == AdNetworkDiscovery.WebViewResourceMatchingMethod.DEFAULT) {
try {
Logger.d(G, "scan for webViews : resourceMatching DEFAULT");
if (mVar.h() != null) {
View f = mVar.h().f();
ArrayList arrayList = new ArrayList();
ArrayList arrayList2 = new ArrayList();
ArrayList arrayList3 = new ArrayList();
arrayList2.add(BrandSafetyUtils.a(f));
arrayList3.add("h1c1:" + f);
String c = mVar.c() != null ? mVar.c() : "";
a(mVar, c, (ViewGroup) f, arrayList, arrayList2, arrayList3, 1);
Logger.d(G, "scan for webViews resourceMatching DEFAULT found viewHierarchy " + arrayList3);
if (mVar != null && mVar.w() != null && arrayList2 != null) {
Logger.d(G, "scan for webViews resourceMatching DEFAULT previous ViewsHierarchy size : " + mVar.w().size() + " , current : " + arrayList2.size());
long a2 = CreativeInfoManager.a(c, AdNetworkConfiguration.NUMBER_OF_VIEWS_REMOVED_IN_FULL_SCREEN_AD_THAT_INDICATES_EOV, 0L);
if (a2 > 0 && mVar.w().size() >= a2 + arrayList2.size()) {
Logger.d(G, "scan for webViews resourceMatching DEFAULT End of video detected");
a(c, (Object) f);
}
}
mVar.a(arrayList2);
}
} catch (Throwable th) {
Logger.e(G, "scan for webViews resourceMatching DEFAULT exception : ", th);
Logger.d(G, "scan for webViews resourceMatching DEFAULT exit scanning");
mVar.ag = false;
}
}
} finally {
Logger.d(G, "scan for webViews resourceMatching DEFAULT exit scanning");
mVar.ag = false;
}
} else {
try {
try {
mVar.ag = true;
View findViewById = activity.getWindow().getDecorView().findViewById(R.id.content);
if (findViewById != null && mVar.G == AdNetworkDiscovery.WebViewResourceMatchingMethod.WEBVIEW_LOOKUP) {
final AdNetworkDiscovery f2 = CreativeInfoManager.f(mVar.c());
if (f2 != null) {
ArrayList arrayList4 = new ArrayList();
ArrayList arrayList5 = new ArrayList();
ArrayList arrayList6 = new ArrayList();
arrayList5.add(BrandSafetyUtils.a(findViewById));
arrayList6.add("h1c1:" + findViewById);
a(mVar, mVar.c() != null ? mVar.c() : "", (ViewGroup) findViewById, arrayList4, arrayList5, arrayList6, 1);
Logger.d(G, "scan for webViews found web views : " + arrayList4);
com.safedk.android.utils.k.b(G, "scan for webViews found views hierarchy : " + arrayList6);
final WebView b2 = f2.b((List<WebView>) arrayList4);
a(mVar, arrayList4);
mVar.a(arrayList5);
if (b2 != null) {
final String a3 = BrandSafetyUtils.a(b2);
if (mVar.H == null || !mVar.H.equals(a3)) {
Logger.d(G, "scan for webViews found " + b2);
SafeDKWebAppInterface.a(a3);
com.safedk.android.analytics.brandsafety.creatives.e.b(a3);
mVar.ah.runOnUiThread(new Runnable() {
@Override
public void run() {
Logger.d(InterstitialFinder.G, "scan for webViews will add js (if necessary) for : " + b2 + " with dummy ");
SafeDKWebAppInterface.a(mVar.c(), b2, "https://dummyurl");
}
});
boolean a4 = CreativeInfoManager.a(mVar.c(), AdNetworkConfiguration.DETECT_MULTIPLE_ADS_BY_WEB_VIEW_CHANGE, false);
Logger.d(G, "scan for webViews, should detect multiple ads by web view change? " + a4);
if (a4 && mVar.H != null && !mVar.H.equals(a3)) {
h(mVar, a3);
}
mVar.H = a3;
Logger.d(G, "scan for webViews address set to " + a3);
for (k kVar : mVar.f()) {
if (kVar.b == null || !arrayList5.contains(kVar.b.ad())) {
Logger.d(G, "scan for webViews will check for pending CIs for package " + mVar.c());
Iterator<n> it = a(mVar.c(), mVar).iterator();
while (it.hasNext()) {
a(it.next(), mVar);
}
} else {
Logger.d(G, "scan for webViews attempting to collect resources for " + a3 + ", CI : " + kVar.b);
com.safedk.android.analytics.brandsafety.creatives.e.a(a3, kVar.b);
}
}
if (f2.d() != null && f2.d().a(AdNetworkConfiguration.APP_OPEN_IMPRESSION_TRACKING_ENABLED, false) && mVar.z != null && mVar.z.containsKey("ad_format") && mVar.z.getString("ad_format").equals(BrandSafetyUtils.l)) {
this.B.execute(new Runnable() {
@Override
public void run() {
List<CreativeInfo> b3 = f2.b((View) b2);
if (b3 != null) {
for (CreativeInfo creativeInfo : b3) {
com.safedk.android.utils.k.b(InterstitialFinder.G, "scan for webViews ci returned : " + creativeInfo);
if (creativeInfo.l() == null) {
creativeInfo.d(mVar.I);
}
if (mVar.z != null && mVar.z.containsKey("ad_format")) {
String string = mVar.z.getString("ad_format");
creativeInfo.n(string);
mVar.e("ad_type_upd(scnFrWVs):" + string);
Logger.d(InterstitialFinder.G, "scan for webViews ad_format set to : " + string);
}
InterstitialFinder.this.a(new n(creativeInfo, CreativeInfo.n, a3));
}
return;
}
Logger.d(InterstitialFinder.G, "scan for webViews ci not found by View");
}
});
}
} else {
Logger.d(G, "scan for webViews - exit scanning");
mVar.ag = false;
}
} else {
Logger.d(G, "scan for webViews - WebView not found");
mVar.a(arrayList5);
}
}
}
Logger.d(G, "scan for webViews - exit scanning");
mVar.ag = false;
} finally {
Logger.d(G, "scan for webViews - exit scanning");
mVar.ag = false;
}
} catch (Throwable th2) {
Logger.e(G, "scan for webViews execution: ", th2);
Logger.d(G, "scan for webViews - exit scanning");
mVar.ag = false;
}
}
}
}
}
private void a(m mVar, List<WebView> list) {
AdNetworkDiscovery f = CreativeInfoManager.f(mVar.u);
if (f != null) {
mVar.N = f.a(list);
}
}
private void h(m mVar, String str) {
Logger.d(G, "handle web view change, web view change detected from: " + mVar.H + ", to: " + str);
k g = mVar.g();
if (g != null && g.b != null && !g.b.af()) {
g.b.ag();
String h = g.b.h();
if (h != null) {
g.b.c(h + CreativeInfo.aI);
}
}
mVar.f().add(new k(UUID.randomUUID().toString()));
if (mVar.C == null) {
mVar.C = UUID.randomUUID().toString();
}
mVar.Z = false;
}
private void a(final m mVar, final Activity activity) {
this.B.execute(new Runnable() {
@Override
public void run() {
List<CreativeInfo> b2;
ViewGroup viewGroup = (ViewGroup) activity.getWindow().getDecorView().findViewById(R.id.content);
String b3 = BrandSafetyUtils.b(activity.getClass());
Logger.d(InterstitialFinder.G, "try to find CI, ad format = " + mVar.z.get("ad_format") + ", activity sdk = " + b3);
try {
if (mVar != null && mVar.i().isEmpty() && CreativeInfoManager.a(b3) == AdNetworkDiscovery.WebViewResourceMatchingMethod.WEBVIEW_LOOKUP && mVar.z != null && mVar.z.containsKey("ad_format") && mVar.z.get("ad_format") != null && CreativeInfoManager.a(b3, AdNetworkConfiguration.SHOULD_SCAN_INTERSTITIAL_VIEW_HIERARCHY_FOR_CI, false) && (b2 = InterstitialFinder.this.b(viewGroup, b3)) != null) {
BrandSafetyEvent.AdFormatType a2 = BrandSafetyUtils.a(mVar.z);
Logger.d(InterstitialFinder.G, "try to find CI, updating ad format value to " + a2);
InterstitialFinder.this.a(activity, mVar);
for (CreativeInfo creativeInfo : b2) {
creativeInfo.n(a2 != null ? a2.name() : null);
mVar.e("ad_type_upd(tryTFndCI):" + a2.name());
creativeInfo.d(mVar.z.getString("id"));
creativeInfo.f(mVar.z.getString(BrandSafetyEvent.k));
Logger.d(InterstitialFinder.G, "try to find CI - ci event id : " + creativeInfo.l() + ", placement id : " + creativeInfo.C());
InterstitialFinder.this.a(new n(creativeInfo, CreativeInfo.n, ""));
}
}
} catch (Throwable th) {
Logger.d(InterstitialFinder.G, "Exception while attempting to find CI : " + th.getMessage(), th);
}
}
});
}
public void c(m mVar, String str) {
mVar.ad = new g(System.currentTimeMillis(), str);
}
public void f(String str, String str2) {
Logger.d(G, "setCurrentInterstitialDownstreamStruct started");
List<m> a2 = this.L.a(str);
if (a2.size() == 1) {
m mVar = a2.get(0);
if (mVar != null) {
List<CreativeInfo> i = mVar.i();
if (!i.isEmpty() && str2 != null) {
for (CreativeInfo creativeInfo : i) {
creativeInfo.c(creativeInfo.h() + "/" + str2);
}
return;
}
return;
}
return;
}
Logger.d(G, "setCurrentInterstitialDownstreamStruct number of Infos for " + str + " is " + a2.size() + ", cannot set downstream struct");
}
public class b implements Runnable {
private String b;
private b() {
this.b = null;
}
public b(String str) {
this.b = null;
this.b = str;
}
@Override
public void run() {
long currentTimeMillis = System.currentTimeMillis();
if (this.b != null) {
m mVar = InterstitialFinder.this.L.get(this.b);
if (mVar != null) {
Logger.d(InterstitialFinder.G, "InterstitialFinderTask Timer for Info " + mVar.I + ", isCancelled = " + (mVar.af != null ? Boolean.valueOf(mVar.af.isCancelled()) : "?") + ", isDone = " + (mVar.af != null ? Boolean.valueOf(mVar.af.isDone()) : "?"));
if (mVar.ah != null) {
Logger.d(InterstitialFinder.G, "InterstitialFinderTask activity sdk is " + BrandSafetyUtils.b(mVar.ah.getClass()));
}
if (!mVar.D && mVar.x == 2) {
InterstitialFinder.this.f(mVar, "timer task run");
}
if (InterstitialFinder.this.M == 0 || currentTimeMillis - InterstitialFinder.this.M >= 900.0d) {
InterstitialFinder.this.M = currentTimeMillis;
if (!mVar.Z) {
InterstitialFinder.this.a(mVar);
} else {
Logger.d(InterstitialFinder.G, "Request To Stop Taking Screenshots Has Been Received, skipping.");
}
int i = mVar.x + 1;
mVar.x = i;
if (i != 120) {
InterstitialFinder.this.e(mVar);
if (mVar.i().isEmpty()) {
Logger.d(InterstitialFinder.G, "InterstitialFinderTask checking for pending CIs");
for (n nVar : InterstitialFinder.this.a(mVar.u, mVar)) {
if (nVar != null && nVar.a != null) {
Logger.d(InterstitialFinder.G, "InterstitialFinderTask calling set CI");
InterstitialFinder.this.a(nVar, mVar);
}
}
return;
}
return;
}
Logger.d(InterstitialFinder.G, "Max number of screenshots threshold reached, no need to start timers");
InterstitialFinder.this.a(this.b);
return;
}
return;
}
return;
}
Logger.d(InterstitialFinder.G, "InterstitialFinderTask eventId is null, skipping.");
}
}
public class a {
String a;
String b;
public a(String str, String str2) {
this.a = str;
this.b = str2;
}
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
a aVar = (a) o;
boolean equals = this.a.equals(aVar.a);
return this.b != null ? equals && this.b.equals(aVar.b) : equals;
}
public int hashCode() {
return this.b != null ? this.a.hashCode() * this.b.hashCode() : this.a.hashCode();
}
public String toString() {
return "{placementId=" + this.a + ", eventId=" + this.b + com.safedk.android.analytics.brandsafety.creatives.discoveries.h.v;
}
public String a() {
return (this.a != null ? this.a : "") + "_" + (this.b != null ? this.b : "");
}
}
private static View a(ViewGroup viewGroup, String str) {
Logger.d(G, "find views " + viewGroup.toString());
int childCount = viewGroup.getChildCount();
for (int i = 0; i < childCount; i++) {
View childAt = viewGroup.getChildAt(i);
Logger.d(G, "find views child " + childAt.toString());
if (str != null && childAt.getClass().getName().equals(str)) {
Logger.d(G, "find views found " + str + " : " + childAt.toString());
return childAt;
}
if (childAt instanceof ViewGroup) {
return a((ViewGroup) childAt, str);
}
}
return null;
}
public List<CreativeInfo> b(ViewGroup viewGroup, String str) {
List<CreativeInfo> b2;
Logger.d(G, "get creative info from ad view started : " + viewGroup.toString());
int childCount = viewGroup.getChildCount();
for (int i = 0; i < childCount; i++) {
View childAt = viewGroup.getChildAt(i);
Logger.d(G, "get creative info from ad view - child " + childAt.toString());
AdNetworkDiscovery f = CreativeInfoManager.f(str);
if (f != null && (b2 = f.b(childAt)) != null) {
for (CreativeInfo creativeInfo : b2) {
creativeInfo.a((Object) childAt);
creativeInfo.r("ci_source_sdk_class=" + childAt.getClass().getName());
Logger.d(G, "get creative info from ad view - ci found, object : " + childAt.toString());
}
return b2;
}
if (childAt instanceof ViewGroup) {
return b((ViewGroup) childAt, str);
}
}
return null;
}
public static void a(View view, int i) {
Logger.d(G, "find views view : " + new String(new char[i * 2]).replace("\u0000", "-") + view.getClass().toString() + new StringBuilder().toString());
}
@Override
public void a(k kVar) {
b(kVar);
com.safedk.android.utils.k.b(G, "adInfoCollectionForUpload count = " + this.z.size() + " : " + this.z);
}
public synchronized void b(k kVar) {
Logger.d(G, "remove impression screenshots started");
if (kVar != null && kVar.d != null) {
Logger.d(G, "Calling remove ad files, filename = " + kVar.d);
BrandSafetyUtils.c(kVar.d);
kVar.d = null;
} else {
Logger.d(G, "no last activity impression screenshot filename");
}
this.A.clear();
}
@Override
public m a(String str, RedirectDetails redirectDetails, l lVar, boolean z, boolean z2) {
return null;
}
@Override
public boolean c(String str, String str2, String str3) {
return false;
}
}