光速虚拟机 v3.8.2版本的 MD5 值为:68970fb34f75fa0f2632de9e93032f55
以下内容为反编译后的 InterstitialFinder.java 源代码,内容仅作参考
package com.safedk.android.analytics.brandsafety;
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.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;
import net.lingala.zip4j.util.InternalZipConstants;
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;
public final InterstitialInfoCollection C;
FullScreenActivitiesCollection D;
boolean E;
protected String F;
private long L;
private final Map<String, List<o>> M;
private final Set<String> N;
public class a {
String a;
String b;
public a(String str, String str2) {
this.a = str;
this.b = str2;
}
public String a() {
return (this.a != null ? this.a : "") + "_" + (this.b != null ? this.b : "");
}
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null || getClass() != obj.getClass()) {
return false;
}
a aVar = (a) obj;
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 + "}";
}
}
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) {
Logger.d(InterstitialFinder.G, "InterstitialFinderTask eventId is null, skipping.");
return;
}
n nVar = InterstitialFinder.this.C.get(this.b);
if (nVar != null) {
Logger.d(InterstitialFinder.G, "InterstitialFinderTask Timer for Info " + nVar.K + ", isCancelled = " + (nVar.ah != null ? Boolean.valueOf(nVar.ah.isCancelled()) : "?") + ", isDone = " + (nVar.ah != null ? Boolean.valueOf(nVar.ah.isDone()) : "?"));
if (nVar.aj != null) {
Logger.d(InterstitialFinder.G, "InterstitialFinderTask activity sdk is " + BrandSafetyUtils.b(nVar.aj.getClass()));
}
if (!nVar.D && nVar.x == 2) {
InterstitialFinder.this.e(nVar, "timer task run");
}
if (InterstitialFinder.this.L == 0 || currentTimeMillis - InterstitialFinder.this.L >= 900.0d) {
InterstitialFinder.this.L = currentTimeMillis;
if (nVar.ab) {
Logger.d(InterstitialFinder.G, "Request To Stop Taking Screenshots Has Been Received, skipping.");
} else {
InterstitialFinder.this.a(nVar);
}
int i = nVar.x + 1;
nVar.x = i;
if (i == 120) {
Logger.d(InterstitialFinder.G, "Max number of screenshots threshold reached, no need to start timers");
InterstitialFinder.this.a(this.b);
return;
}
InterstitialFinder.this.e(nVar);
if (nVar.i().isEmpty()) {
Logger.d(InterstitialFinder.G, "InterstitialFinderTask checking for pending CIs");
for (o oVar : InterstitialFinder.this.a(nVar.u, nVar)) {
if (oVar != null && oVar.a != null) {
Logger.d(InterstitialFinder.G, "InterstitialFinderTask calling set CI");
InterstitialFinder.this.a(oVar, nVar);
}
}
}
}
}
}
}
public InterstitialFinder() {
super(BrandSafetyUtils.AdType.INTERSTITIAL, Arrays.asList(BrandSafetyUtils.k, BrandSafetyUtils.l, BrandSafetyUtils.m), G, 120);
this.C = new InterstitialInfoCollection();
this.L = 0L;
this.M = new HashMap();
this.D = new FullScreenActivitiesCollection();
this.E = false;
this.F = "";
this.N = new HashSet(Arrays.asList(CreativeInfo.j, CreativeInfo.i));
}
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;
} else if (childAt instanceof ViewGroup) {
return a((ViewGroup) childAt, str);
}
}
return null;
}
private BrandSafetyEvent a(n nVar, l lVar, boolean z, String str, String str2) {
return new BrandSafetyEvent(nVar.c(), nVar.y, str2, z, nVar.d() ? nVar.e() : null, lVar.c(), nVar.a(), nVar.B, lVar.a != null ? lVar.a : "", nVar.C, nVar.W, nVar.W > 0, nVar.z, lVar.b != null ? lVar.b.f : null, lVar.b != null ? lVar.b.g : false, lVar.b != null ? lVar.b.c : 0L, lVar.b != null ? lVar.b.a(1000) : 0.0f, nVar.x, SafeDK.getInstance().e(), str, nVar.L, nVar.M, nVar.O, nVar.P, lVar.e, lVar.f);
}
private synchronized String a(View view) {
return BrandSafetyUtils.b(view.getClass());
}
public synchronized List<o> a(String str, n nVar) {
ArrayList arrayList;
arrayList = new ArrayList();
List<o> list = this.M.get(str);
com.safedk.android.utils.l.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<o> it = list.iterator();
while (it.hasNext()) {
o next = it.next();
Logger.d(G, "pending ci check, matching method: " + next.b);
if (a(next.a, nVar)) {
if (next.a != null) {
nVar.e("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);
}
}
AdNetworkDiscovery g = CreativeInfoManager.g(str);
if (g != null && g.b() == AdNetworkDiscovery.WebViewResourceMatchingMethod.DIRECT_CREATIVE_INFO) {
list.clear();
}
}
return arrayList;
}
public void a(Activity activity, n nVar) {
if (activity == null) {
Logger.d(G, "cannot set interstitial info activity details, activity is null");
return;
}
String[] strArr = {BrandSafetyUtils.a(activity.toString(), false), BrandSafetyUtils.a(activity.toString(), true)};
String obj = activity.toString();
nVar.Z = obj;
nVar.aj = activity;
nVar.a(strArr);
this.D.remove((Object) activity.toString());
Logger.d(G, "interstitial info activity details set : " + activity.getClass() + ", sdk = " + nVar.u + ", activity name = " + obj + ", activities = " + this.D.a());
}
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());
}
private void a(final n nVar, final Activity activity) {
this.A.execute(new Runnable() {
@Override
public void run() {
List<CreativeInfo> b2;
ViewGroup viewGroup = (ViewGroup) activity.getWindow().getDecorView().findViewById(16908290);
String b3 = BrandSafetyUtils.b(activity.getClass());
Logger.d(InterstitialFinder.G, "try to find CI, ad format = " + nVar.z.get("ad_format") + ", activity sdk = " + b3);
try {
if (nVar == null || !nVar.i().isEmpty() || CreativeInfoManager.a(b3) != AdNetworkDiscovery.WebViewResourceMatchingMethod.WEBVIEW_LOOKUP || nVar.z == null || !nVar.z.containsKey("ad_format") || nVar.z.get("ad_format") == null || !CreativeInfoManager.a(b3, AdNetworkConfiguration.SHOULD_SCAN_INTERSTITIAL_VIEW_HIERARCHY_FOR_CI, false) || (b2 = InterstitialFinder.this.b(viewGroup, b3)) == null) {
return;
}
BrandSafetyEvent.AdFormatType a2 = BrandSafetyUtils.a(nVar.z);
Logger.d(InterstitialFinder.G, "try to find CI, updating ad format value to " + a2);
InterstitialFinder.this.a(activity, nVar);
for (CreativeInfo creativeInfo : b2) {
creativeInfo.o(a2 != null ? a2.name() : null);
nVar.e("ad_type_upd(tryTFndCI):" + a2.name());
creativeInfo.e(nVar.z.getString("id"));
creativeInfo.g(nVar.z.getString(BrandSafetyEvent.k));
Logger.d(InterstitialFinder.G, "try to find CI - ci event id : " + creativeInfo.m() + ", placement id : " + creativeInfo.D());
InterstitialFinder.this.a(new o(creativeInfo, CreativeInfo.n, ""));
}
} catch (Throwable th) {
Logger.d(InterstitialFinder.G, "Exception while attempting to find CI : " + th.getMessage(), th);
}
}
});
}
private void a(n nVar, j jVar) {
Logger.d(G, "remove file and report event, file: " + jVar.b);
BrandSafetyUtils.c(jVar.b);
jVar.a = null;
jVar.b = null;
BrandSafetyUtils.c(nVar.b());
nVar.r = null;
e(nVar, "removeFileAndReportEvent");
}
private synchronized void a(n nVar, 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 + "c" + (i3 + 1) + ":" + 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(nVar, 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 g = CreativeInfoManager.g(str);
String b2 = g.b(childAt);
if (b2 != null) {
Logger.d(G, "find WebViews in view group - found adId: " + b2);
CreativeInfo a2 = g.a((Object) b2);
if (a2 != null) {
Logger.d(G, "find WebViews in view group - found CI for adId " + b2 + " : " + a2);
a2.a((Object) childAt);
if (nVar != null && nVar.z != null) {
String b3 = b(nVar.z);
Logger.d(G, "find WebViews in view group - setting ad format type to " + b3);
a2.o(b3);
nVar.e("ad_type_upd(fndWVUndrVGroup):" + b3);
}
a(new o(a2, CreativeInfo.n, BrandSafetyUtils.a(childAt)));
}
}
}
}
}
private void a(n nVar, List<WebView> list) {
AdNetworkDiscovery g = CreativeInfoManager.g(nVar.u);
if (g != null) {
nVar.S = g.a(list);
}
}
private void a(n nVar, boolean z) {
Logger.d(G, "set on video completed started, eventId : " + nVar.K);
if (nVar.G || !z) {
if (z) {
return;
}
nVar.G = false;
return;
}
a((c) nVar, z);
CreativeInfo h = nVar.h();
if (h != null && !h.v()) {
h.d(true);
}
nVar.G = z;
}
private synchronized void a(o oVar, String str) {
ArrayList arrayList;
if (oVar != null) {
if (oVar.a != null) {
List<o> list = this.M.get(str);
if (list == null) {
ArrayList arrayList2 = new ArrayList();
this.M.put(str, arrayList2);
arrayList = arrayList2;
} else {
arrayList = list;
}
HashSet hashSet = new HashSet();
for (o oVar2 : arrayList) {
if (oVar2.a != null) {
hashSet.add(oVar2.a.J());
}
}
if (hashSet.contains(oVar.a.J())) {
Logger.d(G, "add as pending - CI with ad id: " + oVar.a.J() + " already in pending list, not adding");
} else {
arrayList.add(oVar);
}
}
}
}
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 g = CreativeInfoManager.g(str);
if (g == null || g.d() == null || !g.d().a(AdNetworkConfiguration.SUPPORTS_BIDDING_INTERSTITIAL_IMPRESSION_MATCHING_BY_MAX, false)) {
Logger.d(G, "match CI - sdk not configured to allow max events based matching");
} else {
Logger.d(G, "match CI - discovery configuration: " + g.d());
String str3 = aVar.a + "_" + aVar.b + "_" + str;
CreativeInfo a2 = g.a((Object) str3);
if (a2 != null) {
Logger.d(G, "match CI - discovery class returned a ci: " + a2);
if (a2.m() == null) {
a2.e(aVar.b);
}
a2.o(BrandSafetyEvent.AdFormatType.INTER.name());
a2.s("ad_type_upd(matchCI):" + BrandSafetyEvent.AdFormatType.INTER.name());
a(new o(a2, CreativeInfo.n, str3));
} else {
Logger.d(G, "match CI - ci not found");
}
}
}
}
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().K());
z = BrandSafetyUtils.a(i) && j > SafeDK.getInstance().K();
Logger.d(G, "should stop sampling returned " + z);
return z;
}
private boolean a(CreativeInfo creativeInfo, n nVar) {
if (creativeInfo == null || nVar == null) {
return false;
}
Logger.d(G, "verify matching - current activity interstitial: " + nVar);
if (nVar.K != null && creativeInfo.m() != null && !nVar.K.equals(creativeInfo.m())) {
Logger.d(G, "verify matching - incompatible event ID, ci: " + creativeInfo.m() + ", info: " + nVar.K);
return false;
}
AdNetworkDiscovery g = CreativeInfoManager.g(creativeInfo.P() == null ? creativeInfo.O() : creativeInfo.P());
if (g != null) {
if (g.b() != AdNetworkDiscovery.WebViewResourceMatchingMethod.DIRECT_CREATIVE_INFO) {
return a(creativeInfo.ac(), creativeInfo.ad(), nVar);
}
if (nVar.q() != null) {
String string = nVar.q().getString(BrandSafetyEvent.k);
String string2 = nVar.q().getString("ad_format");
if ((creativeInfo.D() == null || (string != null && string.equals(creativeInfo.D()))) && string2 != null && string2.startsWith(creativeInfo.G())) {
Logger.d(G, "verify matching DIRECT_CREATIVE_INFO, CI placement: " + creativeInfo.D() + ", CI format: " + creativeInfo.G());
return true;
}
Logger.d(G, "verify matching DIRECT_CREATIVE_INFO, verification failed for CI placement: " + creativeInfo.D() + ", CI format: " + creativeInfo.G());
nVar.e("verifyMatchingFailed|placement=(" + string + "," + creativeInfo.D() + ")|format=(" + string2 + "," + creativeInfo.D() + ")");
return false;
}
}
Logger.d(G, "verify matching, no InterstitialInfo or no discovery for " + creativeInfo.O());
return false;
}
public boolean a(n nVar, View view) {
AdNetworkDiscovery g = CreativeInfoManager.g(nVar.c());
if (g == null || !nVar.S) {
return false;
}
return g.a(view);
}
public synchronized boolean a(o oVar, n nVar) {
boolean z = false;
synchronized (this) {
com.safedk.android.utils.l.b(G, "set CI started, matching info=" + (oVar == null ? "null" : oVar.toString()));
if (oVar == null) {
com.safedk.android.utils.l.b(G, "set CI, matching info is null");
} else {
CreativeInfo creativeInfo = oVar.a;
if (creativeInfo != null) {
Logger.d(G, "set CI, matching info is " + oVar);
if (nVar != null) {
if (nVar.h() == null || nVar.h().af()) {
if (creativeInfo.S() != null && nVar.J != null && !creativeInfo.S().contains("wv=" + nVar.J)) {
creativeInfo.s("wv=" + nVar.J);
}
creativeInfo.a(oVar.b, oVar.c);
Logger.d(G, "set CI: " + creativeInfo);
nVar.a(creativeInfo);
if (nVar.I != AdNetworkDiscovery.WebViewResourceMatchingMethod.WEBVIEW_LOOKUP || nVar.J == null) {
com.safedk.android.analytics.brandsafety.creatives.e.a(creativeInfo, (String) null);
} else {
com.safedk.android.analytics.brandsafety.creatives.e.a(nVar.J, creativeInfo);
}
if (oVar.b.startsWith(CreativeInfo.h)) {
nVar.t();
}
b(nVar, creativeInfo);
e(nVar, "setCreativeInfo");
if (creativeInfo.v()) {
nVar.G = false;
}
if (!nVar.ae && StatsReporter.b().a(creativeInfo, nVar)) {
nVar.ae = true;
}
z = true;
} else {
CreativeInfoManager.b(creativeInfo);
com.safedk.android.utils.l.b(G, "set CI, already matched! ignore matching attempt CI: " + creativeInfo);
}
}
}
}
}
return z;
}
private boolean a(String str, String str2, n nVar) {
if (nVar == null) {
return false;
}
Logger.d(G, "verify matching object started, event ID: " + nVar.K + ", object address: " + str2 + ", webview address: " + nVar.J + ", object type: " + str + ", currentActivityInterstitial = " + nVar);
boolean a2 = CreativeInfoManager.a(nVar.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: " + nVar.K + ", object address: " + str2 + ", object type: " + str + ", sdkInterstitialsRunOnAppActivity: " + a2);
return true;
} else if (nVar.w() != null && nVar.w().contains(str2)) {
Logger.d(G, "verify matching object done, event ID: " + nVar.K + ", object address: " + str2 + ", views hierarchy: " + nVar.w());
return true;
} else {
Logger.d(G, "verify matching object failed, event ID: " + nVar.K + ", object address: " + str2 + ", views hierarchy: " + nVar.w());
nVar.e("verifyMatchingFailed|type=" + str + "|address=matchingObjectAddress|hierarchy=" + nVar.w());
return false;
}
}
private String b(Bundle bundle) {
String string = bundle.getString("ad_format");
if (string != null) {
if (string.equals(BrandSafetyUtils.l)) {
return BrandSafetyEvent.AdFormatType.REWARD.name();
}
if (string.equals(BrandSafetyUtils.k)) {
return BrandSafetyEvent.AdFormatType.INTER.name();
}
if (string.equals(BrandSafetyUtils.m)) {
return BrandSafetyEvent.AdFormatType.APPOPEN.name();
}
return null;
}
return null;
}
public List<CreativeInfo> b(ViewGroup viewGroup, String str) {
List<CreativeInfo> a2;
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 g = CreativeInfoManager.g(str);
if (g != null && (a2 = g.a(childAt, (String) null)) != null) {
for (CreativeInfo creativeInfo : a2) {
creativeInfo.a((Object) childAt);
creativeInfo.s("ci_source_sdk_class=" + childAt.getClass().getName());
Logger.d(G, "get creative info from ad view - ci found, object : " + childAt.toString());
}
return a2;
} else if (childAt instanceof ViewGroup) {
return b((ViewGroup) childAt, str);
}
}
return null;
}
private void b(CreativeInfo creativeInfo, n nVar) {
if (nVar != null) {
if (nVar.ah == null || nVar.ah.isCancelled()) {
if (nVar.ai) {
Logger.d(G, "set CI details - avoid recursive call to web view scanning");
creativeInfo.s("avoidRecWebScan");
return;
}
Logger.d(G, "set CI details - starting timer for InterstitialInfo with event id: " + nVar.v());
e(nVar);
nVar.W = 0L;
nVar.ah = this.A.scheduleAtFixedRate(new b(nVar.K), H, 1000L, TimeUnit.MILLISECONDS);
}
}
}
private void b(n nVar) {
Logger.d(G, "handle DID_CLICKED started");
if (nVar == null) {
Logger.d(G, "current activity interstitial is null");
return;
}
nVar.a(true);
if (nVar.e() != null) {
Logger.d(G, "current activity interstitial already have click url");
} else if (nVar.af == null) {
Logger.d(G, "current activity interstitial doesn't have click url candidate");
} else if (nVar.af.a == 0) {
Logger.d(G, "current click url candidate has zero timestamp");
} else {
Logger.d(G, "handle DID_CLICKED checking click url candidate");
if (System.currentTimeMillis() - nVar.af.a >= 20000) {
Logger.d(G, "click url candidate's timestamp is not within the time range");
return;
}
Logger.d(G, "handle DID_CLICKED setting click url");
nVar.c(nVar.af.b);
}
}
public synchronized void b(n nVar, View view) {
if (nVar != null) {
try {
Logger.d(G, "Taking screenshot, view=" + view);
String c = nVar.c();
long currentTimeMillis = System.currentTimeMillis();
Bitmap a2 = com.safedk.android.analytics.brandsafety.creatives.f.a(view, SafeDK.getInstance().F());
a(nVar, System.currentTimeMillis() - currentTimeMillis, a2);
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);
nVar.ad = BrandSafetyUtils.b(a2);
String m = nVar.m();
Logger.d(G, "taking screenshot impressionId is " + m);
String a6 = BrandSafetyUtils.a(a2, BrandSafetyUtils.AdType.INTERSTITIAL, a5, c, m, nVar.ad);
Logger.d(G, "taking screenshot screenshot file created, filename = " + a6);
long b2 = BrandSafetyUtils.b(a6);
AdNetworkDiscovery g = CreativeInfoManager.g(c);
if (g == null || b2 >= g.a(nVar.h())) {
Logger.d(G, "taking screenshot stored file size is " + b2 + " bytes, counter is " + nVar.x + ", uniform pixel count is " + a4 + " (" + ((a4 / 1000.0f) * 100.0f) + "%)");
int size = this.y.size();
if (e(a5, m)) {
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 " + nVar.Y);
}
if (nVar.Y != null) {
if (d(nVar.Y, nVar.m())) {
BrandSafetyUtils.c(nVar.s);
} else {
Logger.d(G, "taking screenshot not deleting not best image " + nVar.s);
}
}
} else {
boolean z = false;
if (size < SafeDK.getInstance().J()) {
Logger.d(G, "taking screenshot impressions to report size=" + size + ", max images to store=" + SafeDK.getInstance().J());
if (nVar.Y == null) {
z = true;
} else if (!nVar.Y.equals(a5)) {
Logger.d(G, "taking screenshot removing previous file : " + nVar.s);
BrandSafetyUtils.c(nVar.s);
z = true;
}
if (z) {
Logger.d(G, "taking screenshot keeping file of interstitial " + a5 + ". file size is " + b2 + " (bytes), orientation: " + nVar.ad);
nVar.Y = a5;
nVar.s = a6;
nVar.t = nVar.ad;
BrandSafetyUtils.a(nVar.s(), BrandSafetyUtils.AdType.INTERSTITIAL, a5, c, m, nVar.ad);
}
} else if (d(a5, m)) {
Logger.d(G, "taking screenshot image " + a5 + "_" + m + " is already scheduled for upload");
} else {
Logger.d(G, "taking screenshot no open slot for interstitial " + a5 + "; next hashes to be reported to server are " + this.y.keySet());
BrandSafetyUtils.c(a6);
a5 = null;
}
}
boolean z2 = false;
if (a5 != null) {
Logger.d(G, "taking screenshot setting interstitial info data (previous hash = " + nVar.Y + ", current hash = " + a5 + ")");
z2 = (nVar.Y == null || a5.equals(nVar.Y)) ? false : true;
}
if (nVar.ad.equals(BrandSafetyUtils.ScreenShotOrientation.NOT_INITIALIZED)) {
nVar.ad = BrandSafetyUtils.b(a2);
}
l g2 = nVar.g();
if (g2 != null) {
Logger.d(G, "taking screenshot setting image details: " + g2.b);
g2.b = new j(a5, a6, b2, a4, nVar.x, nVar.ad, z2);
}
if (nVar.Y == null) {
Logger.d(G, "taking screenshot no previous hash to detect animation, keep sampling");
nVar.Y = a5;
} else if (a(a4, b2)) {
j k = nVar.k();
if (k != null) {
k.g = z2;
Logger.d(G, "taking screenshot setting interstitial is_animated field to " + z2);
}
if (!TextUtils.isEmpty(a5)) {
if (nVar.ad.equals(BrandSafetyUtils.ScreenShotOrientation.NOT_INITIALIZED) && k != null) {
k.f = BrandSafetyUtils.b(a2);
}
Logger.d(G, "taking screenshot - before reporting, debug info is: " + nVar.A());
e(nVar, "takeScreenshot");
nVar.d(true);
}
a(nVar.K);
} else {
nVar.Y = a5;
}
} else {
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 screenshot is not valid (uniform pixel count too high: " + a4 + "), try again...");
if (nVar.X && nVar.G) {
Logger.d(G, "taking screenshot back from background - reset video completed indication to false");
nVar.X = false;
nVar.G = false;
}
}
}
} catch (Throwable th) {
Logger.e(G, "taking screenshot taking screenshot exception:", th);
Logger.printStackTrace();
new CrashReporter().caughtException(th);
}
}
}
private void b(n nVar, boolean z) {
Logger.d(G, "stop taking screenshots for impression. starting. address = " + nVar.J);
if (nVar == null) {
Logger.d(G, "stop taking screenshots for impression. info is null.");
} else if (!z && !this.E) {
Logger.d(G, "stop taking screenshots for impression. Request to stop taking screenshots received when no max ad is active. ignoring");
} else {
nVar.ab = true;
a(nVar.g());
Logger.d(G, "stop taking screenshots for impression. attempting to clear image hash and files");
j k = nVar.k();
if (k == null || k.b == null) {
Logger.d(G, "stop taking screenshots for impression. no active ci or no image taken.");
} else {
a(nVar, k);
}
}
}
private void c(n nVar, String str) {
if (nVar != null) {
Logger.d(G, "on video completed - started, sdkPackageName = " + str + ", eventId = " + nVar.K);
if (!nVar.u.equals(str) || nVar.G) {
return;
}
a((c) nVar, true);
nVar.G = true;
Logger.d(G, "on video completed - set to true, sdkPackageName = " + str + ", eventId = " + nVar.K);
}
}
private boolean c(n nVar) {
Logger.d(G, "shouldStartTimer started, taskFuture = " + (nVar != null ? nVar.ah : "") + ", isisCancelled = " + ((nVar == null || nVar.ah == null) ? "" : Boolean.valueOf(nVar.ah.isCancelled())));
return nVar != null && (nVar.ah == null || nVar.ah.isCancelled()) && !(nVar.aj == null && (nVar.h() == null || nVar.h().f() == null));
}
private Activity d(n nVar) {
return nVar.ag ? com.safedk.android.internal.b.getInstance().getForegroundActivity() : nVar.aj;
}
private synchronized void d(n nVar, String str) {
if (nVar == 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 = " + nVar.K);
nVar.e(true);
if (str == null) {
str = nVar.Z;
Logger.d(G, "clean and report - activity class set to (curr intractname) " + nVar.Z);
}
String sdkPackageByClass = SdksMapping.getSdkPackageByClass(str);
for (l lVar : nVar.f()) {
if (lVar.c() != null) {
Logger.d(G, "clean and report - activity SDK = " + sdkPackageByClass + ", CI SDK = " + lVar.c().O() + ", interstitial activity name=" + nVar.Z);
Logger.d(G, "clean and report - currentMaxPackageName = " + nVar.u + ", activitySdk = " + sdkPackageByClass);
if (nVar.u != null && !nVar.u.equals(sdkPackageByClass) && !nVar.u.equals(lVar.c().O()) && !nVar.ag) {
Logger.d(G, "clean and report - skip reporting as no related WILL_DISPLAY message received, current Max package name: " + nVar.u + ", activity SDK: " + sdkPackageByClass + ", CI SDK: " + lVar.c().O());
lVar.a((CreativeInfo) null);
}
}
}
for (l lVar2 : nVar.f()) {
if (lVar2.b != null && lVar2.b.b != null) {
lVar2.c = lVar2.b.b;
} else if (nVar.b() != null) {
lVar2.c = nVar.b();
}
Logger.d(G, "clean and report - last impression screenshot filename set to " + lVar2.c);
}
if ((nVar.A == null || !nVar.A.equals(BrandSafetyUtils.a(str, true))) && !CreativeInfoManager.a(nVar.c(), AdNetworkConfiguration.SDK_INTERSTITIALS_RUN_ON_APP_ACTIVITY, false)) {
Logger.d(G, "clean and report - DID NOT enter unload logic, current interstitial info=" + nVar);
} else {
for (l lVar3 : nVar.f()) {
if (lVar3 != null && lVar3.b != null && lVar3.b.b != null && nVar.b() != null) {
if (this.y.size() < SafeDK.getInstance().J()) {
Logger.d(G, "clean and report - image files: " + lVar3.b.b + ", " + nVar.s);
Logger.d(G, "clean and report - waiting to report file: " + nVar.s + ", impression ID: " + lVar3.a);
a(nVar, lVar3);
com.safedk.android.utils.l.b(G, "adInfoCollectionForUpload addAdInfoCollectionForUpload count = " + this.y.size() + " : " + this.y);
} else if (!d(nVar.r, lVar3.a)) {
BrandSafetyUtils.c(nVar.s);
nVar.Y = null;
nVar.s = null;
}
Logger.d(G, "clean and report - hash value: " + lVar3.b.a + " orientation: " + lVar3.b.f);
if (lVar3.b.a == null && !nVar.ab) {
Logger.d(G, "clean and report - assigning last captured hash to interstitial: " + nVar.Y);
lVar3.b.a = nVar.Y;
lVar3.b.f = nVar.t;
}
}
}
nVar.ac = SystemClock.elapsedRealtime();
nVar.W += nVar.ac - nVar.aa;
Logger.d(G, "clean and report - Viewing time (ms) = " + nVar.W);
for (CreativeInfo creativeInfo : nVar.i()) {
com.safedk.android.analytics.brandsafety.creatives.e.a(creativeInfo.ad());
com.safedk.android.analytics.brandsafety.creatives.e.a(creativeInfo);
}
Logger.d(G, "clean and report - number of CIs to report: " + nVar.i().size());
e(nVar, "onAdHidden");
}
if (str != null) {
Logger.d(G, "clean and report - removing from activities : " + str);
this.D.remove((Object) str);
}
a(nVar.K);
l(nVar.K);
}
}
private synchronized void e(Activity activity) {
String a2;
String b2;
String str;
n nVar;
Set<String> set;
n nVar2;
n nVar3;
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) {
nVar = this.C.c(BrandSafetyUtils.a(activity));
Logger.d(G, "interstitial finder start - attempt to find by activity address, currentActivityInterstitial = " + nVar);
} else {
nVar = this.C.a(true) == 1 ? this.C.get(this.C.keySet().toArray()[0]) : null;
}
if (nVar == null || a2 == null || !a2.equals(nVar.A)) {
Logger.d(G, "interstitial finder start - current activity interstitial = " + nVar);
if (nVar == null) {
set = null;
} else if (str == null || !nVar.B.equals(str)) {
Set<String> set2 = nVar.T;
if (set2.contains(a2)) {
Logger.d(G, "interstitial finder start - Ignoring restart of suspected mediation " + nVar.Z);
} else {
if (nVar.A != null) {
set2.add(nVar.A);
}
set = set2;
}
} else {
Logger.d(G, "interstitial finder start - current activity interstitial class name = " + nVar.B + ", activity class name = " + str);
set = null;
}
List<o> arrayList = new ArrayList<>();
Logger.d(G, "interstitial finder start - start current activity interstitial is " + nVar);
if (nVar != null && !nVar.D && !nVar.i().isEmpty()) {
Logger.d(G, "interstitial finder start - current activity interstitial != null : " + nVar);
List<CreativeInfo> i = nVar.i();
if (i.isEmpty()) {
Logger.d(G, "interstitial finder start - current CI is null");
} else {
for (CreativeInfo creativeInfo : i) {
if (creativeInfo != null) {
Logger.d(G, "interstitial finder start - setting current activity interstitials CI: " + creativeInfo);
arrayList.add(new o(creativeInfo, creativeInfo.T(), creativeInfo.S()));
} else {
Logger.d(G, "interstitial finder start - current CI matching method not equal, current CI: " + creativeInfo);
}
}
}
Logger.d(G, "interstitial finder start - current activity interstitial impression reported? " + nVar.D);
b(nVar, true);
}
Logger.d(G, "interstitial finder start - activity : " + activity + ", activities : " + this.D.a());
if (this.C.a(true) <= 0 || this.D.size() <= 0) {
nVar2 = nVar;
} else {
n nVar4 = nVar;
for (n nVar5 : this.C.c()) {
if (activity == null && (b3 = this.D.b(nVar5.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 : " + nVar5.u);
nVar5.aa = SystemClock.elapsedRealtime();
if (nVar5.u == null || b4 == null || !b4.equals(nVar5.u)) {
Logger.d(G, "interstitial finder start - maybe scar-admob");
} else {
a(activity, nVar5);
nVar4 = nVar5;
}
}
a(nVar5, activity);
}
nVar2 = nVar4;
}
for (n nVar6 : this.C.c()) {
if (nVar6.u != null) {
Logger.d(G, "interstitial finder start - current Max package name: " + nVar6.u);
boolean a4 = CreativeInfoManager.a(nVar6.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");
break;
} else if (!a4) {
Logger.d(G, "interstitial finder start - checking pending ci for no activity sdk " + nVar6.u);
arrayList = a(nVar6.u, nVar6);
for (o oVar : arrayList) {
Logger.d(G, "interstitial finder start - found pending ci(s) for no activity sdk, mi : " + oVar);
a(oVar, nVar6);
}
}
}
if (!TextUtils.isEmpty(this.F)) {
nVar6.e(this.F);
Logger.d(G, "interstitial finder start - ci_debug_info set to " + this.F);
}
if (nVar6.aj != null) {
e(nVar6);
if (arrayList.isEmpty()) {
arrayList = a(b2, nVar6);
}
nVar6.W = 0L;
}
if (CreativeInfoManager.a(nVar6.c(), AdNetworkConfiguration.SDK_INTERSTITIALS_RUN_ON_APP_ACTIVITY, false)) {
nVar6.aa = SystemClock.elapsedRealtime();
Logger.d(G, "interstitial finder inter runs on app activity, checking for pending CIs. sdk = " + nVar6.c());
arrayList = a(nVar6.c(), nVar6);
Logger.d(G, "interstitial finder inter runs on app activity, checking for pending CIs. found " + arrayList.size() + " items");
}
for (o oVar2 : arrayList) {
if (oVar2 != null && oVar2.a != null) {
a(oVar2, nVar6);
}
}
if (set != null) {
nVar6.T = set;
}
nVar2 = nVar6;
}
nVar3 = nVar2;
if (c(nVar3)) {
Logger.d(G, "interstitial finder start - starting timer for InterstitialInfo with eventId " + nVar3.v());
nVar3.ah = this.A.scheduleAtFixedRate(new b(nVar3.K), H, 1000L, TimeUnit.MILLISECONDS);
}
} else {
j k = nVar.k();
if (k == null || TextUtils.isEmpty(k.a) || !a(k.d, k.c)) {
Logger.d(G, "interstitial finder start - Starting counter from previous value " + nVar.r());
nVar.D();
nVar3 = nVar;
if (c(nVar3)) {
}
} else {
Logger.d(G, "interstitial finder start - Not starting timer on activity " + nVar.Z + " -- impression already logged");
}
}
}
public synchronized void e(final n nVar) {
if (nVar != null) {
if (!nVar.ai) {
Activity activity = nVar.aj;
Logger.d(G, "scan for webViews started, activity: " + (activity == null ? "null" : activity.toString()) + ", currentActivityInterstitial.resourceMatching: " + nVar.I);
if (activity != null && BrandSafetyUtils.f(activity.getClass().getName())) {
nVar.ai = true;
View findViewById = activity.getWindow().getDecorView().findViewById(16908290);
final AdNetworkDiscovery g = CreativeInfoManager.g(nVar.c());
String c = nVar.c() != null ? nVar.c() : "";
if (g == null) {
Logger.d(G, "scan for webViews - exit scanning");
nVar.ai = false;
} else {
ArrayList arrayList = new ArrayList();
ArrayList arrayList2 = new ArrayList();
ArrayList arrayList3 = new ArrayList();
if (findViewById != null) {
arrayList2.add(BrandSafetyUtils.a(findViewById));
arrayList3.add("h1c1:" + findViewById);
a(nVar, c, (ViewGroup) findViewById, arrayList, arrayList2, arrayList3, 1);
Logger.d(G, "scan for webViews found web views : " + arrayList);
com.safedk.android.utils.l.b(G, "scan for webViews found views hierarchy : " + arrayList3);
}
if (nVar.I == AdNetworkDiscovery.WebViewResourceMatchingMethod.WEBVIEW_LOOKUP) {
final WebView b2 = g.b((List<WebView>) arrayList);
a(nVar, arrayList);
nVar.a(arrayList2);
if (b2 != null) {
final String a2 = BrandSafetyUtils.a(b2);
SafeDKWebAppInterface.a(a2);
com.safedk.android.analytics.brandsafety.creatives.e.b(a2);
a((c) nVar);
if (nVar.J == null || !nVar.J.equals(a2)) {
Logger.d(G, "scan for webViews found " + b2);
nVar.aj.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(nVar.c(), b2, "https://dummyurl");
}
});
boolean a3 = CreativeInfoManager.a(nVar.c(), AdNetworkConfiguration.DETECT_MULTIPLE_ADS_BY_WEB_VIEW_CHANGE, false);
Logger.d(G, "scan for webViews, should detect multiple ads by web view change? " + a3);
if (a3 && nVar.J != null && !nVar.J.equals(a2)) {
g(nVar, a2);
}
nVar.J = a2;
Logger.d(G, "scan for webViews address set to " + a2);
for (l lVar : nVar.f()) {
if (lVar.c() == null || !arrayList2.contains(lVar.c().ad())) {
Logger.d(G, "scan for webViews will check for pending CIs for package " + nVar.c());
for (o oVar : a(nVar.c(), nVar)) {
a(oVar, nVar);
}
} else {
Logger.d(G, "scan for webViews attempting to collect resources for " + a2 + ", CI : " + lVar.c());
com.safedk.android.analytics.brandsafety.creatives.e.a(a2, lVar.c());
}
}
if (g.d() != null && g.d().a(AdNetworkConfiguration.APP_OPEN_IMPRESSION_TRACKING_ENABLED, false) && nVar.z != null && nVar.z.containsKey("ad_format") && nVar.z.getString("ad_format").equals(BrandSafetyUtils.m)) {
this.A.execute(new Runnable() {
@Override
public void run() {
List<CreativeInfo> a4 = g.a((View) b2, (String) null);
if (a4 == null) {
Logger.d(InterstitialFinder.G, "scan for webViews ci not found by View");
return;
}
for (CreativeInfo creativeInfo : a4) {
com.safedk.android.utils.l.b(InterstitialFinder.G, "scan for webViews ci returned : " + creativeInfo);
if (creativeInfo.m() == null) {
creativeInfo.e(nVar.K);
}
if (nVar.z != null && nVar.z.containsKey("ad_format")) {
String string = nVar.z.getString("ad_format");
creativeInfo.o(string);
nVar.e("ad_type_upd(scnFrWVs):" + string);
Logger.d(InterstitialFinder.G, "scan for webViews ad_format set to : " + string);
}
InterstitialFinder.this.a(new o(creativeInfo, CreativeInfo.n, a2));
}
}
});
}
} else {
Logger.d(G, "scan for webViews - exit scanning");
nVar.ai = false;
}
} else {
Logger.d(G, "scan for webViews - WebView not found");
nVar.a(arrayList2);
}
} else if (findViewById != null && nVar.I == AdNetworkDiscovery.WebViewResourceMatchingMethod.DIRECT_CREATIVE_INFO) {
WebView b3 = g.b((List<WebView>) arrayList);
if (b3 != null) {
String a4 = BrandSafetyUtils.a(b3);
Logger.d(G, "scan for webViews (DIRECT_CREATIVE_INFO) webViewAddress = " + a4);
nVar.J = a4;
a((c) nVar);
} else {
Logger.d(G, "scan for webViews (DIRECT_CREATIVE_INFO) empty WebView List returned");
}
}
CreativeInfo h = nVar.h();
if (h != null && h.S() != null && !h.S().contains("wv=" + nVar.J)) {
h.s("wv=" + nVar.J);
}
Logger.d(G, "scan for webViews - exit scanning");
nVar.ai = false;
}
} else if (nVar.I == AdNetworkDiscovery.WebViewResourceMatchingMethod.DEFAULT) {
Logger.d(G, "scan for webViews : resourceMatching DEFAULT");
if (nVar.h() != null) {
View f = nVar.h().f();
ArrayList arrayList4 = new ArrayList();
ArrayList arrayList5 = new ArrayList();
ArrayList arrayList6 = new ArrayList();
arrayList5.add(BrandSafetyUtils.a(f));
arrayList6.add("h1c1:" + f);
String c2 = nVar.c() != null ? nVar.c() : "";
a(nVar, c2, (ViewGroup) f, arrayList4, arrayList5, arrayList6, 1);
Logger.d(G, "scan for webViews resourceMatching DEFAULT found viewHierarchy " + arrayList6);
if (nVar != null && nVar.w() != null && arrayList5 != null) {
Logger.d(G, "scan for webViews resourceMatching DEFAULT previous ViewsHierarchy size : " + nVar.w().size() + " , current : " + arrayList5.size());
long a5 = CreativeInfoManager.a(c2, AdNetworkConfiguration.NUMBER_OF_VIEWS_REMOVED_IN_FULL_SCREEN_AD_THAT_INDICATES_EOV, 0L);
if (a5 > 0 && nVar.w().size() >= a5 + arrayList5.size()) {
Logger.d(G, "scan for webViews resourceMatching DEFAULT End of video detected");
a(c2, (Object) f);
}
}
nVar.a(arrayList5);
}
Logger.d(G, "scan for webViews resourceMatching DEFAULT exit scanning");
nVar.ai = false;
}
}
}
}
public synchronized void e(n nVar, String str) {
String str2;
String str3;
boolean z = true;
synchronized (this) {
com.safedk.android.utils.l.b(G, "reporting event started, root= " + str + ", info=" + nVar);
if (nVar == null || !nVar.V) {
Logger.d(G, "reporting event - info is not interstitial, don't report info");
} else {
boolean z2 = !nVar.D;
z = (nVar.E || !nVar.d()) ? false : false;
if (nVar.z == null || !nVar.z.containsKey("id")) {
Logger.d(G, "reporting event - no event ID");
str2 = null;
} else {
str2 = nVar.z.getString("id");
Logger.d(G, "reporting event - event ID: " + str2);
}
ArrayList arrayList = new ArrayList();
if (nVar.i().isEmpty()) {
arrayList.add(a(nVar, nVar.g(), z, str2, null));
a((c) nVar);
} else {
Logger.d(G, "reporting event - number of CIs: " + nVar.i().size());
for (l lVar : nVar.f()) {
if (lVar.c() != null && !nVar.c().equals(lVar.c().O())) {
Logger.d(G, "reporting event without CI - sdk: " + nVar.c() + ", CI sdk: " + lVar.c().O() + ", CI actual sdk: " + lVar.c().P());
lVar.a((CreativeInfo) null);
}
Logger.d(G, "reporting event (Check) root = " + str + ", debug info = " + nVar.A());
List asList = Arrays.asList(com.safedk.android.utils.h.i, com.safedk.android.utils.h.b, com.safedk.android.utils.h.k);
if (!TextUtils.isEmpty(nVar.A()) && str.equals("onAdHidden") && lVar.c() != null && asList.contains(lVar.c().O()) && nVar.z != null && nVar.z.containsKey("ad_format") && nVar.z.getString("ad_format") != null && nVar.z.getString("ad_format").equals(BrandSafetyUtils.m)) {
lVar.c().s(nVar.A());
String maxEvents = p.a().c().toString();
com.safedk.android.utils.l.b(G, "reporting event Invalid AppOpen impression detected ciDebugInfo = " + nVar.A() + " , lastMaxEvents = " + maxEvents);
lVar.c().s(maxEvents);
}
if (lVar.b != null) {
Logger.d(G, "reporting event - image uniformity: " + lVar.b.a(1000));
str3 = (lVar.b.a == null || nVar.ab) ? null : lVar.b.a + "_" + lVar.a;
f(nVar, str3);
} else {
str3 = null;
}
arrayList.add(a(nVar, lVar, z, str2, str3));
}
}
Logger.d(G, "reporting event " + str2 + ", viewingTime = " + nVar.W);
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 (z2) {
nVar.b(true);
}
if (z) {
nVar.c(true);
}
}
}
}
private void f(n nVar, String str) {
Logger.d(G, "add CI debug info started, hashValue " + str + ", info=" + nVar.toString());
for (l lVar : nVar.f()) {
if (lVar.c() == null || lVar.b == null || str == null || lVar.b.a == null || lVar.b.f == null || nVar.m() == null) {
Logger.d(G, "add CI debug info - no creative info or hash is null");
} else {
String a2 = BrandSafetyUtils.a(BrandSafetyUtils.AdType.INTERSTITIAL, lVar.b.a, nVar.c(), nVar.m(), lVar.b.f);
if (!new File(a2).exists()) {
Logger.d(G, "add CI debug info - screenshot file path doesn't exist: " + a2);
} else if (lVar.c().S() == null || !lVar.c().S().contains("screenshot_datetime")) {
long currentTimeMillis = System.currentTimeMillis();
lVar.c().s("screenshot_datetime:" + 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");
}
}
if (lVar != null && lVar.c() != null && this.y.size() > 2) {
Logger.d(G, "add CI debug info - adding pending images info to ci_debug_info : image_id_pending : " + this.y.keySet());
lVar.c().s("image_id_pending : " + this.y.keySet());
}
}
}
private void g(n nVar, String str) {
Logger.d(G, "handle web view change, web view change detected from: " + nVar.J + ", to: " + str);
l g = nVar.g();
if (g != null && g.c() != null && !g.c().af()) {
g.c().ag();
String h = g.c().h();
if (h != null) {
g.c().c(h + CreativeInfo.aI);
}
}
nVar.f().add(new l(UUID.randomUUID().toString()));
Logger.d(G, "handle WebView Change - new Impression info object created. number of impressions in ad : " + nVar.f().size());
if (nVar.C == null) {
nVar.C = UUID.randomUUID().toString();
}
nVar.ab = false;
}
private boolean k(String str) {
n c = this.C.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 g = CreativeInfoManager.g(c.c());
if (g == null || g.d() == null || !g.d().a(AdNetworkConfiguration.AD_NETWORK_INTERNAL_BROWSER_OPENS_IN_SAME_ACTIVITY, false)) {
return false;
}
Logger.d(G, "instances of same activity - discovery configuration = " + g.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;
}
private void l(String str) {
Logger.d(G, "clearing AppLovin bundle, eventId = " + str);
this.E = this.C.size() != 0;
Logger.d(G, "maxAdIsActive set to " + this.E);
if (str != null) {
this.C.keySet().remove(str);
Logger.d(G, "Removing " + str + " from currentInterstitialInfos");
}
}
@Override
protected c a(String str, String str2, String str3, BrandSafetyUtils.ScreenShotOrientation screenShotOrientation, String str4, String str5) {
return new n(str, str2, str3, screenShotOrientation, str4, str5);
}
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) {
str = a((ViewGroup) childAt);
break;
} else {
i = i2 + 1;
}
}
} else {
str = null;
}
return str;
}
@Override
public List<CreativeInfo> a(String str, String str2) {
for (n nVar : this.C.values()) {
if (nVar != null && nVar.J != null && nVar.J.equals(str2)) {
return nVar.j();
}
}
return null;
}
@Override
public synchronized void a(Activity activity) {
com.safedk.android.utils.l.b(G, "start ad monitoring - activity : " + activity + ", current interstitial infos :" + this.C);
if (activity != null) {
if (this.C.d(activity.toString())) {
Logger.d(G, "start ad monitoring - activity null or already registered.");
} else {
this.D.put(activity.toString(), new WeakReference<>(activity));
if (!this.E) {
this.E = true;
}
Logger.d(G, "start ad monitoring - activity added : " + activity.toString());
}
if (k(activity.toString())) {
Logger.d(G, "start ad monitoring - sdk: " + this.C.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);
e(activity);
}
}
}
public void a(Bundle bundle) {
n nVar;
Logger.d(G, "handle Revenue event started, data = " + bundle + ", info keys : " + this.C.keySet());
if (bundle.containsKey("id")) {
String string = bundle.getString("id");
if (!this.C.containsKey(string) || (nVar = this.C.get(string)) == null) {
Logger.d(G, "Revenue event - no interstitial info found for event " + string);
return;
}
if (bundle.getString("revenue_event") != null) {
nVar.O = bundle.getString("revenue_event");
} else {
nVar.O = "unknown";
}
e(nVar, "handleRevenueEvent");
Logger.d(G, "Revenue event set to " + bundle.getString("revenue_event") + " for eventId " + string);
}
}
@Override
public synchronized void a(l lVar) {
Logger.d(G, "remove impression screenshots started");
if (lVar == null || lVar.c == null) {
Logger.d(G, "no last activity impression screenshot filename");
} else {
Logger.d(G, "Calling remove ad files, filename = " + lVar.c);
BrandSafetyUtils.c(lVar.c);
lVar.c = null;
}
this.z.clear();
}
public synchronized void a(final n nVar) {
if (nVar != null) {
Logger.d(G, "take screenshot - currentActivityInterstitial = " + nVar);
Activity activity = nVar.aj;
if (nVar.E()) {
Logger.d(G, "take screenshot - sdk Interstitials Run On App Activity = " + nVar.ag);
if (nVar.aj == null || BrandSafetyUtils.c(activity.getClass()) || nVar.ag) {
final String str = nVar.u;
Activity d = d(nVar);
Logger.d(G, "take screenshot - activity = " + d);
d.runOnUiThread(new Runnable() {
@Override
public void run() {
boolean z = false;
try {
synchronized (InterstitialFinder.this) {
if (nVar != null) {
Logger.d(InterstitialFinder.G, "take screenshot - Run on UI thread in " + nVar.Z);
View F = nVar.F();
CreativeInfo h = nVar.h();
String c = (h == null || h.P() == null) ? nVar.c() : h.P();
Logger.d(InterstitialFinder.G, "take screenshot - AdMob sdk package name is " + c);
boolean equals = com.safedk.android.utils.h.h.equals(c);
boolean equals2 = com.safedk.android.utils.h.f.equals(nVar.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.v() + ", is vast video ad? " + h.y() + ", is multi ad? " + h.af());
}
boolean a2 = CreativeInfoManager.a(str, AdNetworkConfiguration.DETECT_MULTIPLE_ADS_BY_WEB_VIEW_CHANGE, false);
if (SafeDK.getInstance().I() || equals || equals2) {
if (SafeDK.getInstance().I()) {
Logger.d(InterstitialFinder.G, "take screenshot - SafeDK Config item 'AlwaysTakeScreenshot' is true");
InterstitialFinder.this.b(nVar, F);
} 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, "take screenshot - Admob/IronSource SDK");
InterstitialFinder.this.b(nVar, F);
} else {
Logger.d(InterstitialFinder.G, "don't take screenshot - multi ad, sdk: " + str);
}
} else if (h == null) {
Logger.d(InterstitialFinder.G, "don't take screenshot - no creative info yet");
} else if (h.w()) {
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: " + str);
} else if (!h.v()) {
Logger.d(InterstitialFinder.G, "take screenshot - ad is not a video/playable ad");
InterstitialFinder.this.b(nVar, F);
} else if (nVar.G || CreativeInfoManager.a(h.O(), AdNetworkConfiguration.SHOULD_TAKE_INTERSTITIAL_SCREENSHOTS_THROUGHOUT_IMPRESSION, false)) {
Logger.d(InterstitialFinder.G, "take screenshot - video ad finished playing or sdk configured to take screenshots throughout the impression");
InterstitialFinder.this.b(nVar, F);
} else if (InterstitialFinder.this.a(nVar, F)) {
Logger.d(InterstitialFinder.G, "take screenshot - native video player completed");
InterstitialFinder.this.b(nVar, F);
} else {
Logger.d(InterstitialFinder.G, "don't take screenshot - video hasn't finished playing yet, waiting for video completed event");
}
}
}
} catch (Throwable th) {
Logger.e(InterstitialFinder.G, "Failed while taking screenshot", th);
new CrashReporter().caughtException(th);
}
}
});
} else {
Logger.d(G, "take screenshot - The activity is not supported : " + activity.getClass());
}
}
}
}
public synchronized void a(n nVar, String str) {
Logger.d(G, "Ad hidden started, activityClass=" + (str == null ? "null" : str) + ", interstitial infos=" + this.C.toString());
if (nVar == null || !k(str)) {
d(nVar, str);
} else {
Logger.d(G, "Ad hidden " + nVar.c() + " activity " + str + " unloaded but this is not the end of impression. not calling cleanAndReport");
}
}
@Override
public synchronized void a(String str) {
Logger.d(G, "stop timers - canceling timer for interstitials, eventId = " + str);
n e = this.C.e(str);
if (e != null) {
if (e != null && e.r() == 0) {
e.Y = null;
}
if (this.C.size() < 1 || this.C.a()) {
this.L = 0L;
}
if (e.ah != null) {
Logger.d(G, "stop timers - calling timer cancel.");
e.ah.cancel(false);
}
}
}
public synchronized void a(String str, Object obj) {
Logger.d(G, "on video completed - sdk = " + str + ", source = " + obj);
n nVar = null;
if (obj != null) {
nVar = this.C.b(BrandSafetyUtils.a(obj));
Logger.d(G, "on video completed - sdk = " + str + ", found interstitialInfo : " + nVar);
}
if (nVar != null) {
c(nVar, str);
} else {
for (n nVar2 : this.C.values()) {
c(nVar2, str);
}
}
}
@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);
n b2 = this.C.b(str3);
if (b2 == null && this.C.a(mainSdkPackage).size() == 1) {
Logger.d(G, "InterstitialInfo not found by address, trying by SdkPackageName " + mainSdkPackage);
b2 = this.C.a(mainSdkPackage).get(0);
}
if (b2 == null || b2.c() == null || !SdksMapping.isSameSdkByPackages(b2.c(), mainSdkPackage)) {
Logger.d(G, "set ad click URL skipped, SDK: " + (b2 != null ? b2.c() : "null"));
} else {
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);
b(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());
}
}
}
@Override
public synchronized void a(String str, String str2, boolean z) {
if (str2 != null) {
n b2 = this.C.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 (n nVar : this.C.a(str)) {
Logger.d(G, "on video completed triggered - sdkPackageName : " + str + ", webView address: " + str2 + ", video completed: " + z);
a(nVar, z);
}
}
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.g(str) != null) {
n nVar = new n(str, this.d, atomicReference.get());
nVar.K = atomicReference.get().getString("id");
this.C.put(nVar.K, nVar);
Logger.d(G, "start ad monitoring - new interstitial info created : " + nVar);
e((Activity) null);
} else {
Logger.d(G, "start ad monitoring - slot = " + this.d + ", max package name = " + str + ", ad network is not supported");
}
}
}
}
@Override
public synchronized boolean a(o oVar) {
n nVar;
boolean z;
BrandSafetyEvent.AdFormatType a2;
BrandSafetyEvent.AdFormatType a3;
Logger.d(G, "set CI details started, matchingInfo = " + oVar.toString());
CreativeInfo creativeInfo = oVar.a;
if (creativeInfo == null) {
z = false;
} else {
creativeInfo.g(BrandSafetyUtils.ScreenShotOrientation.PORTRAIT.equals(BrandSafetyUtils.c()));
n nVar2 = null;
if (creativeInfo.m() != null) {
nVar2 = this.C.e(creativeInfo.m());
Logger.d(G, "set CI details attempt to locate interstitial info by eventId " + creativeInfo.m() + ", success? " + (nVar2 != null));
}
if (nVar2 == null && creativeInfo.ad() != null) {
nVar2 = this.C.b(creativeInfo.ad());
Logger.d(G, "set CI details attempt to locate interstitial info by matching object address " + creativeInfo.ad() + ", success ? " + (nVar2 != null));
}
if (nVar2 == null) {
List<n> a4 = this.C.a(creativeInfo.O());
if (a4.size() == 1) {
Logger.d(G, "set CI details found 1 InterstitialInfo object by sdk " + creativeInfo.O());
nVar = a4.get(0);
} else if (a4.size() > 1) {
Logger.d(G, "set CI details found " + a4.size() + " InterstitialInfo objects by sdk " + creativeInfo.O() + " : " + a4);
nVar = nVar2;
} else {
Logger.d(G, "set CI details no InterstitialInfo object not found");
}
Logger.d(G, "set CI details - ad info sdk: " + (nVar == null ? nVar.c() : "null") + ", CI sdk: " + creativeInfo.O() + " ad info webview address: " + (nVar == null ? nVar.J : "null") + ", ci matching object address: " + creativeInfo.ad());
if (nVar != null && nVar.z != null) {
Logger.d(G, "set CI details - CI ad format: " + creativeInfo.G() + ", max ad type: " + nVar.z.getString("ad_format"));
if ((creativeInfo.G() != null || !creativeInfo.G().equals(nVar.z.getString("ad_format"))) && (a3 = BrandSafetyUtils.a(nVar.z)) != null) {
Logger.d(G, "set CI details - updating ad format value to " + a3.name());
creativeInfo.o(a3.name());
nVar.e("ad_type_upd(sCrInfoDtls):" + a3.name());
}
}
if (nVar != null && nVar.u != null && (nVar.u.equals(creativeInfo.O()) || nVar.u.equals(creativeInfo.P()))) {
Logger.d(G, "set CI details - currentMaxPackageName: " + nVar.u);
if (a(creativeInfo, nVar)) {
Logger.d(G, "set CI details - setting as current CI for SDK: " + creativeInfo.O());
if (nVar.h() != null) {
Logger.d(G, "set CI details - replacing " + nVar.h());
}
if (creativeInfo.G() == null && (a2 = BrandSafetyUtils.a(nVar.z)) != null) {
Logger.d(G, "set CI details - Start monitoring ad check, updating ad format value to " + a2.name());
creativeInfo.o(a2.name());
nVar.e("ad_type_upd(shldStrtMntrngAd):" + a2.name());
}
b(creativeInfo, nVar);
if (CreativeInfoManager.a(creativeInfo.O(), AdNetworkConfiguration.SDK_USES_PLACEMENT_ID_ARRAY, false) && creativeInfo != null && creativeInfo.D() != null && nVar.x() != null && creativeInfo.D().contains(nVar.x())) {
Logger.d(G, "set CI details - replacing ci placement " + creativeInfo.D() + " with Max placement " + nVar.x());
creativeInfo.g(nVar.x());
}
z = a(oVar, nVar);
}
}
Logger.d(G, "set CI details - adding as pending for SDK: " + creativeInfo.O() + " matching info: " + oVar);
a(oVar, creativeInfo.O());
if (nVar != null) {
nVar.e("addToPendingCIs|info=" + oVar.c + ";" + oVar.b + "|object=" + oVar.a.ac() + ";" + oVar.a.ad());
}
b(creativeInfo, nVar);
z = false;
}
nVar = nVar2;
Logger.d(G, "set CI details - ad info sdk: " + (nVar == null ? nVar.c() : "null") + ", CI sdk: " + creativeInfo.O() + " ad info webview address: " + (nVar == null ? nVar.J : "null") + ", ci matching object address: " + creativeInfo.ad());
if (nVar != null) {
Logger.d(G, "set CI details - CI ad format: " + creativeInfo.G() + ", max ad type: " + nVar.z.getString("ad_format"));
if (creativeInfo.G() != null) {
}
Logger.d(G, "set CI details - updating ad format value to " + a3.name());
creativeInfo.o(a3.name());
nVar.e("ad_type_upd(sCrInfoDtls):" + a3.name());
}
if (nVar != null) {
Logger.d(G, "set CI details - currentMaxPackageName: " + nVar.u);
if (a(creativeInfo, nVar)) {
}
}
Logger.d(G, "set CI details - adding as pending for SDK: " + creativeInfo.O() + " matching info: " + oVar);
a(oVar, creativeInfo.O());
if (nVar != null) {
}
b(creativeInfo, nVar);
z = false;
}
return z;
}
@Override
public boolean a(String str, View view) {
AdNetworkDiscovery g;
if (str == null || (g = CreativeInfoManager.g(str)) == null) {
return false;
}
return g.e(view);
}
@Override
public n a(String str, RedirectDetails redirectDetails, m mVar, boolean z, boolean z2, boolean z3) {
return null;
}
@Override
public void b(l lVar) {
a(lVar);
com.safedk.android.utils.l.b(G, "adInfoCollectionForUpload count = " + this.y.size() + " : " + this.y);
}
public void b(n nVar, String str) {
nVar.af = new h(System.currentTimeMillis(), str);
}
@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);
n c = this.C.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.Z == null || c.Z.equals(str)) {
Logger.d(G, "Activity destroyed, calling onAdHidden");
a(c, str);
} else {
Logger.d(G, "Activity destroyed, activity address (" + str + " ) does not match the address of the ad's activity (" + c.Z + ")");
}
}
}
}
@Override
public synchronized void b(String str, String str2, String str3) {
n b2 = this.C.b(str3);
if (b2 != null && b2.d() && str2 != null && str2.equals(b2.c()) && b2.aj != null) {
String obj = b2.aj.toString();
Logger.d(G, "set previous activity click url, click activity: " + obj + ", ad activity: " + b2.Z);
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)) {
e(b2, "setPreviousActivityClickUrl");
}
}
}
}
public void b(String str, String str2, boolean z) {
if (str2 != null && this.C.b(str2) != null) {
b(this.C.b(str2), z);
}
List<n> a2 = this.C.a(str);
if (a2 != null) {
for (n nVar : a2) {
b(nVar, z);
}
}
}
public synchronized n c(Activity activity) {
n c;
if (activity == null) {
Logger.d(G, "get activity interstitial by activity, activity is null");
c = null;
} else {
c = this.C.c(activity.toString());
}
return c;
}
@Override
public synchronized List<CreativeInfo> c(String str, String str2) {
ArrayList arrayList;
List<CreativeInfo> i;
Iterator<n> it = this.C.values().iterator();
while (true) {
if (it.hasNext()) {
n next = it.next();
if (next != null && (i = next.i()) != null && !i.isEmpty() && i.get(0) != null && i.get(0).J() != null && i.get(0).J().equals(str2)) {
arrayList = i;
break;
}
} else {
List<o> list = this.M.get(str);
if (list != null) {
ArrayList arrayList2 = new ArrayList();
for (o oVar : list) {
if (oVar.a != null && oVar.a.J() != null && oVar.a.J().equals(str2)) {
arrayList2.add(oVar.a);
}
}
arrayList = arrayList2;
} else {
arrayList = new ArrayList();
}
}
}
return arrayList;
}
@Override
public boolean c(String str, String str2, String str3) {
return false;
}
public synchronized void d(Activity activity) {
try {
Logger.d(G, "interstitial finder stop, activity = " + activity.toString());
n c = this.C.c(activity.toString());
if (c != null && (c.Z == null || activity.toString().equals(c.Z))) {
Logger.d(G, "Stopping interstitial finder for activity " + c.Z);
a(c.K);
Logger.d(G, "interstitial finder, viewing time (ms) = " + c.W);
}
} finally {
}
}
public void f(String str, String str2) {
Logger.d(G, "setCurrentInterstitialDownstreamStruct started");
List<n> a2 = this.C.a(str);
if (a2.size() != 1) {
Logger.d(G, "setCurrentInterstitialDownstreamStruct number of Infos for " + str + " is " + a2.size() + ", cannot set downstream struct");
return;
}
n nVar = a2.get(0);
if (nVar != null) {
List<CreativeInfo> i = nVar.i();
if (i.isEmpty() || str2 == null) {
return;
}
for (CreativeInfo creativeInfo : i) {
creativeInfo.c(creativeInfo.h() + InternalZipConstants.ZIP_FILE_SEPARATOR + str2);
}
}
}
@Override
public void g() {
if (this.C != null) {
for (n nVar : this.C.values()) {
if (nVar != null && nVar.V) {
e(nVar, "onBackground");
}
}
}
}
@Override
public synchronized String getCommunicatorId() {
return AppLovinBridge.a;
}
@Override
public synchronized void h() {
if (this.C != null) {
for (n nVar : this.C.values()) {
if (nVar != null) {
nVar.X = true;
}
}
}
}
public boolean h(String str) {
List<n> a2 = this.C.a(str);
com.safedk.android.utils.l.b(G, "activeImpressionExists current impressions are " + this.C);
return a2 != null && a2.size() > 0;
}
public synchronized n i(String str) {
n nVar = null;
synchronized (this) {
if (str == null) {
Logger.d(G, "get activity interstitial by package, package is null");
} else {
List<n> a2 = this.C.a(str);
if (a2.size() == 1) {
nVar = a2.get(0);
} else {
Logger.d(G, "there are " + a2.size() + " interstitial infos, exisitng");
}
}
}
return nVar;
}
public void j(String str) {
List<CreativeInfo> i;
Logger.d(G, "setStopCollectingResources started");
List<n> a2 = this.C.a(str);
if (a2.size() != 1) {
Logger.d(G, "setStopCollectingResources number of Infos for " + str + " is " + a2.size() + ", cannot stop collecting resources");
return;
}
n nVar = a2.get(0);
if (nVar == null || (i = nVar.i()) == null || i.isEmpty()) {
return;
}
for (CreativeInfo creativeInfo : i) {
String h = creativeInfo.h();
if (h != null && h.contains(com.safedk.android.analytics.brandsafety.creatives.discoveries.i.c)) {
creativeInfo.a(true);
}
}
}
@Override
public synchronized void onMessageReceived(AppLovinCommunicatorMessage appLovinCommunicatorMessage) {
synchronized (this) {
if (SafeDK.getInstance().o()) {
Bundle messageData = appLovinCommunicatorMessage.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.l.b(System.currentTimeMillis());
String string6 = messageData.containsKey("creative_id") ? messageData.getString("creative_id") : null;
MaxEvent maxEvent = new MaxEvent(string, b3, string2, string4, string6, string5);
p.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: " + appLovinCommunicatorMessage.getMessageData());
if ("WILL_DISPLAY".equals(string)) {
com.safedk.android.utils.l.b(G, "adInfoCollectionForUpload count = " + this.y.size() + " : " + this.y);
this.d++;
if (b2 != null) {
p.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)) {
n e = this.C.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())) {
e(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);
n e2 = this.C.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) {
n e3 = this.C.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 cannot update Max creativeId. event Id check failed.");
} else {
Logger.d(G, "updateMaxCreativeId setting Max creativeId to : " + string6 + " for eventId " + string7);
e3.L = string6;
}
}
}
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);
n e4 = this.C.e(string7);
if (e4 != null) {
e4.M = true;
d(e4, (String) null);
}
}
}
}
}
}
}
}
}