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

以下内容为反编译后的 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.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;

public class InterstitialFinder extends com.safedk.android.analytics.brandsafety.b {
    private static final String A = "InterstitialFinder";
    private static final long B = 500;
    private static final long C = 1000;
    private static final int D = 120;
    private static final int E = 2;
    private static final int F = 3;
    private final InterstitialInfoCollection G;
    private long H;
    private final Map<String, List<k>> I;
    private final Set<String> J;
    FullScreenActivitiesCollection x;
    boolean y;
    protected String z;

    public boolean g(String str) {
        List<j> a2 = this.G.a(str);
        com.safedk.android.utils.j.b(A, "activeImpressionExists current impressions are " + this.G);
        return a2 != null && a2.size() > 0;
    }

    public InterstitialFinder() {
        super(BrandSafetyUtils.AdType.INTERSTITIAL, Arrays.asList(BrandSafetyUtils.h, BrandSafetyUtils.i, BrandSafetyUtils.j), A);
        this.G = new InterstitialInfoCollection();
        this.H = 0L;
        this.I = new HashMap();
        this.x = new FullScreenActivitiesCollection();
        this.y = false;
        this.z = "";
        this.J = 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 j(str, str2, str3, screenShotOrientation, str4, str5);
    }

    public synchronized void a(String str, Object obj) {
        Logger.d(A, "on video completed - sdk = " + str + ", source = " + obj);
        j jVar = null;
        if (obj != null) {
            jVar = this.G.b(BrandSafetyUtils.a(obj));
        }
        if (jVar != null) {
            c(jVar, str);
        } else {
            Iterator<j> it = this.G.values().iterator();
            while (it.hasNext()) {
                c(it.next(), str);
            }
        }
    }

    private void c(j jVar, String str) {
        if (jVar != null && jVar.w.equals(str) && !jVar.aa) {
            b(jVar, true);
            jVar.aa = true;
            Logger.d(A, "on video completed - set to true, sdkPackageName = " + str + ", eventId = " + jVar.N);
        }
    }

    public synchronized void a(String str, String str2, boolean z) {
        j b2;
        Logger.d(A, "on video completed triggered - sdkPackageName : " + str + ", webView address: " + str2 + ", video completed: " + z);
        if (str2 != null && (b2 = this.G.b(str2)) != null) {
            Logger.d(A, "on video completed triggered - for webview address  : " + str2);
            a(b2, z);
        } else {
            Iterator<j> it = this.G.a(str).iterator();
            while (it.hasNext()) {
                a(it.next(), z);
            }
        }
    }

    private void a(j jVar, boolean z) {
        Logger.d(A, "set on video completed started, eventId  : " + jVar.N);
        if (!jVar.aa && z) {
            b(jVar, z);
            if (jVar.H != null && !jVar.H.l()) {
                jVar.H.d(true);
            }
            jVar.aa = z;
        }
    }

    private void b(j jVar, boolean z) {
        if (z && !jVar.aa && !jVar.ab) {
            Logger.d(A, "Video is marked as completed, clearing any images taken previously");
            b(jVar);
            jVar.ab = true;
            return;
        }
        Logger.d(A, "avoid clearing any images taken previously: videoCompleted=" + z + " onVideoCompletedEventHasBeenTriggered=" + jVar.aa + " impressionScreenshotsRemoved=" + jVar.ab);
    }

    public void b(String str, String str2, boolean z) {
        if (str2 != null && this.G.b(str2) != null) {
            c(this.G.b(str2), z);
        }
        List<j> a2 = this.G.a(str);
        if (a2 != null) {
            Iterator<j> it = a2.iterator();
            while (it.hasNext()) {
                c(it.next(), z);
            }
        }
    }

    private void c(j jVar, boolean z) {
        Logger.d(A, "stop taking screenshots for impression. starting. address = " + jVar.M);
        if (jVar == null) {
            Logger.d(A, "stop taking screenshots for impression. info is null.");
            return;
        }
        if (z || this.y) {
            jVar.ad = true;
            b(jVar);
            Logger.d(A, "stop taking screenshots for impression. attempting to clear image hash and files");
            if (jVar != null && jVar.c() != null) {
                c(jVar);
                return;
            } else {
                Logger.d(A, "stop taking screenshots for impression. no active ci or no image taken.");
                return;
            }
        }
        Logger.d(A, "stop taking screenshots for impression. Request to stop taking screenshots received when no max ad is active. ignoring");
    }

    private void c(j jVar) {
        Logger.d(A, "remove file and report event, file: " + jVar.c());
        BrandSafetyUtils.c(jVar.c());
        jVar.r = null;
        jVar.c((String) null);
        BrandSafetyUtils.c(jVar.d());
        jVar.s = null;
        d(jVar, "removeFileAndReportEvent");
    }

    private boolean a(View view, String str, String str2) {
        String a2;
        AdNetworkDiscovery f = CreativeInfoManager.f(str);
        if (f == null) {
            Logger.d(A, "extract ad ID from view - no discovery object for: " + str);
            return false;
        }
        boolean a3 = CreativeInfoManager.a(str, AdNetworkConfiguration.SHOULD_EXTRACT_AD_ID_FROM_BANNER_WEB_VIEW, false);
        boolean a4 = CreativeInfoManager.a(str, AdNetworkConfiguration.AD_ID_EXTRACTED_FROM_BANNER_WEB_VIEW_IS_MAX_CREATIVE_ID, false);
        Logger.d(A, "extract ad ID from view - should extract: " + a3);
        if (!a3 || (a2 = f.a(view)) == null) {
            return false;
        }
        Logger.d(A, "extract ad ID from view - ad ID extracted from view: " + a2);
        if (a4 && str2 != null && !str2.equals(a2)) {
            Logger.d(A, "extract ad ID from view - value extracted (" + a2 + ") from widget is not equal to creative ID (" + str2 + ")");
            return true;
        }
        Logger.d(A, "extract ad ID from view - attempting to locate ci by ad ID value " + a2);
        CreativeInfo a5 = f.a((Object) a2);
        if (a5 != null) {
            Logger.d(A, "extract ad ID from view - CI found, ad ID = " + a2 + ", view : " + view.toString() + ", ci : " + a5);
            a5.a((Object) view);
            CreativeInfoManager.a(a5, CreativeInfo.n, a2);
            return false;
        }
        Logger.d(A, "extract ad ID from view - CI not found, adId = " + a2);
        return false;
    }

    private synchronized void a(j jVar, 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.r + (i3 + 1) + CertificateUtil.DELIMITER + childAt);
            if (childAt instanceof WebView) {
                list.add((WebView) childAt);
                Logger.d(A, "find WebViews in view group - found: " + childAt + " , parent: " + childAt.getParent().toString());
            } else if (childAt instanceof ViewGroup) {
                a(jVar, str, (ViewGroup) childAt, list, list2, list3, i2);
            }
            if (a(str, childAt)) {
                Logger.d(A, "find WebViews in view group - found AdView: " + childAt + " , parent: " + childAt.getParent().toString());
                AdNetworkDiscovery f = CreativeInfoManager.f(str);
                String a2 = f.a(childAt);
                if (a2 != null) {
                    Logger.d(A, "find WebViews in view group - found adId: " + a2);
                    CreativeInfo a3 = f.a((Object) a2);
                    if (a3 != null) {
                        Logger.d(A, "find WebViews in view group - found CI for adId " + a2 + " : " + a3);
                        a3.a((Object) childAt);
                        if (jVar != null && jVar.E != null) {
                            String a4 = a(jVar.E);
                            Logger.d(A, "find WebViews in view group - setting ad format type to " + a4);
                            a3.m(a4);
                            jVar.f("ad_type_upd(fndWVUndrVGroup):" + a4);
                        }
                        a(new k(a3, CreativeInfo.n, BrandSafetyUtils.a(childAt)));
                    }
                }
            }
        }
    }

    @Override
    public synchronized void onMessageReceived(AppLovinCommunicatorMessage message) {
        synchronized (this) {
            if (SafeDK.getInstance().k()) {
                Bundle messageData = message.getMessageData();
                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.j.b(System.currentTimeMillis());
                String string6 = messageData.containsKey("creative_id") ? messageData.getString("creative_id") : null;
                MaxEvent maxEvent = new MaxEvent(string, b3, string2, string4, string6, string5);
                l.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(A, "full screen type but ad network not supported (" + a2 + ")");
                } else {
                    String string7 = messageData.getString("id", null);
                    if (string7 == null) {
                        Logger.d(A, "No eventId in data bundle.");
                    }
                    if (contains) {
                        Logger.d(A, "Max message received, package: " + b2 + ", ts (seconds): " + b3 + ", message received: " + message.getMessageData());
                        if ("WILL_DISPLAY".equals(string)) {
                            this.d++;
                            if (b2 != null) {
                                l.a().b(maxEvent);
                                this.y = 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(A, "WILL_DISPLAY event for package " + b2 + " placement " + string3 + " ad_type " + string2 + ", activityFullScreenAdKey=" + aVar);
                                a(b2, aVar, string7);
                            }
                        } else if ("DID_CLICKED".equals(string)) {
                            j e = this.G.e(string7);
                            if (e != null) {
                                StringBuilder append = new StringBuilder().append("DID_CLICKED event for package ");
                                if (b2 != null) {
                                    string4 = b2;
                                }
                                Logger.d(A, append.append(string4).toString());
                                d(e);
                                if (!TextUtils.isEmpty(e.h())) {
                                    d(e, "onMessageReceived");
                                }
                            }
                        } else if ("WILL_LOAD".equals(string)) {
                            if (b2 != null) {
                                Logger.d(A, "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(A, "DID_HIDE event for package " + b2 + " placement " + string3);
                                e(string7, (String) null);
                            }
                        } else if ("DID_LOAD".equals(string)) {
                            if (b2 != null) {
                                Logger.d(A, "DID_LOAD event for package " + b2 + " placement " + string3);
                            }
                        } else if ("DID_DISPLAY".equals(string)) {
                            if (b2 != null) {
                                if (string6 != null) {
                                    j e2 = this.G.e(string7);
                                    Logger.d(A, "updateMaxCreativeId currentActivityInterstitial : " + e2);
                                    if (e2 != null) {
                                        if (e2.E != null && e2.E.containsKey("id") && e2.E.getString("id") != null && e2.E.getString("id").equals(string7)) {
                                            Logger.d(A, "updateMaxCreativeId setting Max creativeId to : " + string6 + " for eventId " + string7);
                                            e2.O = string6;
                                        } else {
                                            Logger.d(A, "updateMaxCreativeId cannot update Max creativeId. event Id check failed.");
                                        }
                                    }
                                }
                                Logger.d(A, "DID_DISPLAY event for package " + b2 + " placement " + string3);
                            }
                        } else if ("DID_FAIL_DISPLAY".equals(string)) {
                            Logger.d(A, "DID_FAIL_DISPLAY event for package " + b2 + " placement " + string3);
                            j e3 = this.G.e(string7);
                            if (e3 != null) {
                                e3.P = true;
                            }
                            c(string7, null, true);
                        }
                    }
                }
            }
        }
    }

    private synchronized void a(String str, a aVar, String str2) {
        Logger.d(A, "match CI started, sdk = " + str + ", interstitial key = " + aVar);
        if (aVar.b != null) {
            Logger.d(A, "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(A, "match CI - discovery configuration: " + f.d());
                String str3 = aVar.f6783a + "_" + aVar.b + "_" + str;
                CreativeInfo a2 = f.a((Object) str3);
                if (a2 != null) {
                    Logger.d(A, "match CI - discovery class returned a ci: " + a2);
                    if (a2.g() == null) {
                        a2.d(aVar.b);
                    }
                    a2.m(BrandSafetyEvent.AdFormatType.INTER.name());
                    a2.q("ad_type_upd(matchCI):" + BrandSafetyEvent.AdFormatType.INTER.name());
                    a(new k(a2, CreativeInfo.n, str3));
                } else {
                    Logger.d(A, "match CI - ci not found");
                }
            } else {
                Logger.d(A, "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(A, "start ad monitoring - slot = " + this.d + ", maxPackageName = " + str + ", AppLovin data bundle is " + atomicReference.get());
                j jVar = new j(str, this.d, atomicReference.get());
                jVar.N = atomicReference.get().getString("id");
                this.G.put(jVar.N, jVar);
                Logger.d(A, "start ad monitoring - new interstitial info created : " + jVar);
                d((Activity) null);
            }
        }
    }

    public synchronized void a(Activity activity) {
        com.safedk.android.utils.j.b(A, "start ad monitoring - activity : " + activity + ", current interstitial infos :" + this.G);
        if (activity != null && !this.G.d(activity.toString())) {
            this.x.put(activity.toString(), new WeakReference<>(activity));
            if (!this.y) {
                this.y = true;
            }
            Logger.d(A, "start ad monitoring - activity added : " + activity.toString());
        } else {
            Logger.d(A, "start ad monitoring - activity null or already registered.");
        }
        if (activity != null && j(activity.toString())) {
            Logger.d(A, "start ad monitoring - sdk: " + this.G.b() + ", activity " + activity + " started but this is not the start of impression. not starting ad monitoring");
        } else {
            Logger.d(A, "start ad monitoring calling 'start', activity is " + activity);
            d(activity);
        }
    }

    private boolean j(String str) {
        j c = this.G.c(str);
        if (str == null || c == null || c.f() == null) {
            return false;
        }
        Logger.d(A, "instances of same activity - current activity class name = " + c.k() + ",  current activity address = " + c.j());
        AdNetworkDiscovery f = CreativeInfoManager.f(c.f());
        if (f == null || f.d() == null || !f.d().a(AdNetworkConfiguration.AD_NETWORK_INTERNAL_BROWSER_OPENS_IN_SAME_ACTIVITY, false)) {
            return false;
        }
        Logger.d(A, "instances of same activity - discovery configuration = " + f.d());
        String str2 = c.k() + "@" + c.j();
        Logger.d(A, "instances of same activity - current activity = " + str2);
        if (str.equals(str2)) {
            return false;
        }
        Logger.d(A, "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.d(view);
    }

    private void d(j jVar) {
        Logger.d(A, "handle DID_CLICKED started");
        if (jVar != null) {
            jVar.a(true);
            if (jVar.h() == null && jVar.ai != null && jVar.ai.f6840a != 0) {
                Logger.d(A, "handle DID_CLICKED checking click url candidate");
                if (System.currentTimeMillis() - jVar.ai.f6840a < 5000) {
                    Logger.d(A, "handle DID_CLICKED setting click url");
                    jVar.e(jVar.ai.b);
                }
            }
        }
    }

    @Override
    public synchronized String getCommunicatorId() {
        return AppLovinBridge.f6754a;
    }

    public synchronized j b(Activity activity) {
        j c;
        if (activity == null) {
            Logger.d(A, "get activity interstitial by activity, activity is null");
            c = null;
        } else {
            c = this.G.c(activity.toString());
        }
        return c;
    }

    public synchronized j h(String str) {
        j jVar = null;
        synchronized (this) {
            if (str == null) {
                Logger.d(A, "get activity interstitial by package, package is null");
            } else {
                List<j> a2 = this.G.a(str);
                if (a2.size() == 1) {
                    jVar = a2.get(0);
                } else {
                    Logger.d(A, "there are " + a2.size() + " interstitial infos, exisitng");
                }
            }
        }
        return jVar;
    }

    private synchronized void d(Activity activity) {
        String a2;
        String a3;
        String b2;
        j jVar;
        Set<String> set;
        j jVar2;
        k kVar;
        WeakReference<Activity> b3;
        k kVar2 = null;
        synchronized (this) {
            if (activity != null) {
                a2 = BrandSafetyUtils.a(activity.toString(), true);
                a3 = BrandSafetyUtils.a(activity.toString(), false);
                b2 = BrandSafetyUtils.b(activity.getClass());
            } else {
                b2 = null;
                a3 = null;
                a2 = null;
            }
            Logger.d(A, "interstitial finder start - activity name = " + activity + ", sdk = " + b2);
            if (activity != null) {
                jVar = this.G.c(BrandSafetyUtils.a(activity));
                Logger.d(A, "interstitial finder start - attempt to find by activity address, currentActivityInterstitial = " + jVar);
            } else {
                jVar = this.G.a(true) == 1 ? this.G.get(this.G.keySet().toArray()[0]) : null;
            }
            if (jVar != null && a2 != null && a2.equals(jVar.F)) {
                jVar.ac = SystemClock.elapsedRealtime();
                if (!TextUtils.isEmpty(jVar.b()) && a(jVar.C, jVar.e())) {
                    Logger.d(A, "interstitial finder start - Not starting timer on activity " + jVar.Z + " -- impression already logged");
                } else {
                    Logger.d(A, "interstitial finder start - Starting counter from previous value " + jVar.o());
                    jVar.w();
                    jVar2 = jVar;
                    if (e(jVar2)) {
                    }
                }
            } else {
                Logger.d(A, "interstitial finder start - current activity interstitial = " + jVar);
                if (jVar == null) {
                    set = null;
                } else if (a3 != null && jVar.G.equals(a3)) {
                    Logger.d(A, "interstitial finder start - current activity interstitial class name = " + jVar.G + ", activity class name = " + a3);
                    set = null;
                } else {
                    Set<String> set2 = jVar.R;
                    if (set2.contains(a2)) {
                        Logger.d(A, "interstitial finder start - Ignoring restart of suspected mediation " + jVar.Z);
                    } else {
                        if (jVar.F != null) {
                            set2.add(jVar.F);
                        }
                        set = set2;
                    }
                }
                Logger.d(A, "interstitial finder start - start current activity interstitial is " + jVar);
                if (jVar != null && !jVar.I && jVar.i() != null) {
                    Logger.d(A, "interstitial finder start - current activity interstitial != null : " + jVar);
                    CreativeInfo i = jVar.i();
                    if (i != null && !this.J.contains(i.J())) {
                        Logger.d(A, "interstitial finder start - setting current activity interstitials CI: " + i);
                        kVar2 = new k(i, i.J(), i.I());
                    } else {
                        Logger.d(A, "interstitial finder start - current CI is null or matching method not equal, current CI: " + i);
                    }
                    Logger.d(A, "interstitial finder start - current activity interstitial impression reported? " + jVar.I);
                    c(jVar, true);
                }
                Logger.d(A, "interstitial finder start - activity : " + activity + ", activities : " + this.x.a());
                if (this.G.a(true) > 0 && this.x.size() > 0) {
                    j jVar3 = jVar;
                    for (j jVar4 : this.G.c()) {
                        if (activity == null && (b3 = this.x.b(jVar4.w)) != null && b3.get() != null) {
                            Activity activity2 = b3.get();
                            Logger.d(A, "interstitial finder start - activity set to " + activity2);
                            activity = activity2;
                        }
                        if (activity != null) {
                            String b4 = BrandSafetyUtils.b(activity.getClass());
                            Logger.d(A, "interstitial finder start - activity : " + activity + ", activitySdk : " + b4 + ", InterstitialInfo sdk : " + jVar4.w);
                            if (jVar4.w != null && b4 != null && b4.equals(jVar4.w)) {
                                a(activity, jVar4);
                                jVar3 = jVar4;
                            } else {
                                Logger.d(A, "interstitial finder start - maybe scar-admob");
                            }
                        }
                        a(jVar4, activity);
                    }
                    jVar = jVar3;
                }
                if (jVar != null) {
                    if (jVar.w != null) {
                        Logger.d(A, "interstitial finder start - current Max package name: " + jVar.w);
                        boolean a4 = CreativeInfoManager.a(jVar.w, AdNetworkConfiguration.SDK_INTERSTITIALS_RUN_ON_APP_ACTIVITY, false);
                        if (!this.y) {
                            Logger.d(A, "interstitial finder start - MAX ad is not currently active (no WILL_DISPLAY msg received), interstitial info: " + this.G.toString());
                        } else if (activity != null && !BrandSafetyUtils.c(activity.getClass()) && !a4) {
                            Logger.d(A, "interstitial finder start - current foreground activity is not a supported ad activity");
                        }
                    }
                    if (!TextUtils.isEmpty(this.z)) {
                        jVar.f(this.z);
                        Logger.d(A, "interstitial finder start - ci_debug_info set to " + this.z);
                    }
                    if (jVar.am != null) {
                        g(jVar);
                        kVar = kVar2 == null ? a(b2, jVar) : kVar2;
                        jVar.U = 0L;
                    } else {
                        kVar = kVar2;
                    }
                    if (kVar != null && kVar.f6852a != null) {
                        a(kVar, jVar);
                    }
                    if (set != null) {
                        jVar.R = set;
                    }
                }
                jVar2 = jVar;
                if (e(jVar2)) {
                    Logger.d(A, "interstitial finder start - starting timer for InterstitialInfo with eventId  " + jVar2.t());
                    jVar2.ak = this.w.scheduleAtFixedRate(new b(jVar2.N), B, 1000L, TimeUnit.MILLISECONDS);
                }
            }
        }
    }

    private boolean e(j jVar) {
        return (jVar == null || (jVar.am == null && (jVar.i() == null || jVar.i().c() == null))) ? false : true;
    }

    public void a(Activity activity, j jVar) {
        if (activity != null) {
            String[] strArr = {BrandSafetyUtils.a(activity.toString(), false), BrandSafetyUtils.a(activity.toString(), true)};
            String obj = activity.toString();
            jVar.Z = obj;
            jVar.am = activity;
            jVar.a(strArr);
            this.x.remove((Object) activity.toString());
            Logger.d(A, "interstitial info activity details set : " + activity.getClass() + ", sdk = " + jVar.w + ", activity name = " + obj + ", activities = " + this.x.a());
            return;
        }
        Logger.d(A, "cannot set interstitial info activity details, activity is null");
    }

    public synchronized k a(String str, j jVar) {
        k kVar;
        List<k> list = this.I.get(str);
        com.safedk.android.utils.j.b(A, "pending ci check, number of pending CIs: " + (list != null ? list.size() : 0) + ", cis : " + (list != null ? list.toString() : "null"));
        if (list != null) {
            Iterator<k> it = list.iterator();
            while (it.hasNext()) {
                kVar = it.next();
                Logger.d(A, "pending ci check, matching method: " + kVar.b);
                if (kVar.b == null || !this.J.contains(kVar.b)) {
                    if (a(kVar.f6852a, jVar)) {
                        if (kVar.f6852a != null) {
                            kVar.f6852a.q("pendingCIMatch|listSize:" + list.size() + "|info:" + kVar.c + ";" + kVar.b + "|object:" + kVar.f6852a.S() + ";" + kVar.f6852a.T());
                        }
                        list.remove(kVar);
                        Logger.d(A, "pending ci check, creative info is the pending creative info: " + kVar);
                    }
                }
            }
        }
        kVar = null;
        return kVar;
    }

    private boolean a(CreativeInfo creativeInfo, j jVar) {
        Logger.d(A, "verify matching - current activity interstitial: " + jVar);
        if (jVar != null && jVar.N != null && creativeInfo.g() != null && !jVar.N.equals(creativeInfo.g())) {
            Logger.d(A, "verify matching - incompatible event ID, ci: " + creativeInfo.g() + ", info: " + jVar.N);
            return false;
        }
        AdNetworkDiscovery f = CreativeInfoManager.f(creativeInfo.F() == null ? creativeInfo.E() : creativeInfo.F());
        if (jVar != null && f != null) {
            if (f.b() == AdNetworkDiscovery.WebViewResourceMatchingMethod.DIRECT_CREATIVE_INFO) {
                if (jVar.n() != null) {
                    String string = jVar.n().getString(BrandSafetyEvent.k);
                    String string2 = jVar.n().getString("ad_format");
                    if (string != null && string.equals(creativeInfo.s()) && string2 != null && string2.startsWith(creativeInfo.v())) {
                        Logger.d(A, "verify matching DIRECT_CREATIVE_INFO, CI placement: " + creativeInfo.s() + ", CI format: " + creativeInfo.v());
                        return true;
                    }
                    Logger.d(A, "verify matching DIRECT_CREATIVE_INFO, verification failed for CI placement: " + creativeInfo.s() + ", CI format: " + creativeInfo.v());
                    return false;
                }
            } else {
                return a(creativeInfo.S(), creativeInfo.T(), jVar);
            }
        }
        Logger.d(A, "verify matching, no InterstitialInfo or no discovery for " + creativeInfo.E());
        return false;
    }

    private boolean a(String str, String str2, j jVar) {
        Logger.d(A, "verify matching object started, event ID: " + jVar.N + ", object address: " + str2 + ", object type: " + str + ", currentActivityInterstitial = " + jVar);
        if (jVar == null) {
            return false;
        }
        boolean a2 = CreativeInfoManager.a(jVar.w, AdNetworkConfiguration.SDK_INTERSTITIALS_RUN_ON_APP_ACTIVITY, false);
        if (str2 == null || MediaPlayer.class.getCanonicalName().equals(str) || a2) {
            Logger.d(A, "verify matching object skipped, event ID: " + jVar.N + ", object address: " + str2 + ", object type: " + str + ", sdkInterstitialsRunOnAppActivity: " + a2);
            return true;
        }
        if (jVar.u() != null && jVar.u().contains(str2)) {
            Logger.d(A, "verify matching object done, event ID: " + jVar.N + ", object address: " + str2 + ", views hierarchy: " + jVar.u());
            return true;
        }
        Logger.d(A, "verify matching object failed, event ID: " + jVar.N + ", object address: " + str2 + ", views hierarchy: " + jVar.u());
        return false;
    }

    @Override
    public synchronized void a(String str) {
        Logger.d(A, "stop timers - canceling timer for interstitials, eventId = " + str);
        j e = this.G.e(str);
        if (e != null) {
            if (e.ak != null) {
                e.ak.cancel(false);
                e.ak = null;
                Logger.d(A, "stop timers - timer cancelled");
            }
            if (e != null && e.o() == 0) {
                e.Y = null;
            }
        }
        if (this.G.size() < 1 || this.G.a()) {
            this.H = 0L;
        }
    }

    @Override
    public synchronized CreativeInfo a(String str, String str2) {
        CreativeInfo creativeInfo;
        Iterator<j> it = this.G.values().iterator();
        while (true) {
            if (!it.hasNext()) {
                creativeInfo = null;
                break;
            }
            j next = it.next();
            if (next != null && next.M != null && next.M.equals(str2)) {
                break;
            }
        }
        return creativeInfo;
    }

    @Override
    public synchronized CreativeInfo b(String str, String str2) {
        CreativeInfo creativeInfo;
        Iterator<j> it = this.G.values().iterator();
        loop0: while (true) {
            if (it.hasNext()) {
                j next = it.next();
                if (next != null) {
                    creativeInfo = next.i();
                    if (creativeInfo != null && creativeInfo.z().equals(str2)) {
                        break;
                    }
                } else {
                    List<k> list = this.I.get(str);
                    if (list != null) {
                        Iterator<k> it2 = list.iterator();
                        while (it2.hasNext()) {
                            k next2 = it2.next();
                            if (next2.f6852a != null && next2.f6852a.z().equals(str2)) {
                                break loop0;
                            }
                        }
                    } else {
                        continue;
                    }
                }
            } else {
                creativeInfo = null;
                break;
            }
        }
        return creativeInfo;
    }

    public synchronized void c(Activity activity) {
        try {
            Logger.d(A, "interstitial finder stop, activity = " + activity.toString());
            j c = this.G.c(activity.toString());
            if (c != null && (c.Z == null || activity.toString().equals(c.Z))) {
                Logger.d(A, "Stopping interstitial finder for activity " + c.Z);
                a(c.N);
                Logger.d(A, "interstitial finder, viewing time (ms) = " + c.U);
            }
        } catch (Throwable th) {
            Logger.e(A, th.getMessage(), th);
            new CrashReporter().caughtException(th);
        }
    }

    public synchronized void i(String str) {
        Logger.d(A, "Activity destroyed activity class = " + (str == null ? "" : str) + ", activities = " + this.x);
        this.x.remove((Object) str);
        String sdkPackageByClass = SdksMapping.getSdkPackageByClass(str);
        j c = this.G.c(str);
        if (c != null) {
            if (sdkPackageByClass != null && c.w != null && !sdkPackageByClass.equals(c.w)) {
                Logger.d(A, "Activity destroyed, activity SDK does not fit the WILL_DISPLAY msg: " + sdkPackageByClass);
            } else if (c.Z != null && str != null && !c.Z.equals(str)) {
                Logger.d(A, "Activity destroyed, activity address (" + str + " ) does not match the address of the ad's activity(" + c.Z + ")");
            }
        }
        Logger.d(A, "Activity destroyed, calling onAdHidden");
    }

    public synchronized void e(String str, String str2) {
        Logger.d(A, "Ad hidden started, activityClass=" + (str2 == null ? "null" : str2) + ", interstitial infos=" + this.G.toString());
        j jVar = null;
        if (str != null) {
            jVar = this.G.e(str);
        } else if (str2 != null) {
            jVar = this.G.c(str2);
        }
        if (jVar != null && j(str2)) {
            Logger.d(A, "Ad hidden " + jVar.f() + " activity " + str2 + " unloaded but this is not the end of impression. not calling cleanAndReport");
        } else {
            c(str, str2, true);
        }
    }

    private synchronized void c(String str, String str2, boolean z) {
        synchronized (this) {
            try {
                Logger.d(A, "clean and report started, activity class=" + str2 + ", eventId = " + str);
                j e = (str == null || this.G.e(str) == null) ? null : this.G.e(str);
                if (e == null) {
                    Logger.d(A, "clean and report - currentInterstitialInfos IS NULL, SKIPPING");
                } else {
                    e.e(true);
                    if (str2 == null && e != null) {
                        str2 = e.Z;
                        Logger.d(A, "clean and report - activity class set to (curr intractname) " + e.Z);
                    }
                    String sdkPackageByClass = SdksMapping.getSdkPackageByClass(str2);
                    if (e != null) {
                        String E2 = e.i() != null ? e.i().E() : null;
                        Logger.d(A, "clean and report - activity SDK = " + sdkPackageByClass + ", CI SDK = " + E2 + ", interstitial activity name=" + e.Z);
                        Logger.d(A, "clean and report - currentMaxPackageName = " + e.w + ", activitySdk = " + sdkPackageByClass);
                        if (e.w != null && !e.w.equals(sdkPackageByClass) && !e.w.equals(E2) && !e.aj) {
                            Logger.d(A, "clean and report - skip reporting as no related WILL_DISPLAY message received, current Max package name: " + e.w + ", activity SDK: " + sdkPackageByClass + ", CI SDK: " + E2);
                            e.H = null;
                        }
                    }
                    if (e != null && e.c() != null) {
                        e.ah = e.c();
                    } else if (e != null && e.d() != null) {
                        e.ah = e.d();
                    }
                    Logger.d(A, "clean and report - last impression screenshot filename set to " + e.ah);
                    if (e != null && e.M != null) {
                        com.safedk.android.analytics.brandsafety.creatives.e.b(e.M);
                    }
                    if ((e == null || e.F == null || !e.F.equals(BrandSafetyUtils.a(str2, true))) && (e.i() == null || (e.i().c() == null && !CreativeInfoManager.a(e.f(), AdNetworkConfiguration.SDK_INTERSTITIALS_RUN_ON_APP_ACTIVITY, false)))) {
                        Logger.d(A, "clean and report - DID NOT enter unload logic, current interstitial info=" + e);
                    } else {
                        if (e.d() != null) {
                            int size = this.u.size();
                            if (z && size < SafeDK.getInstance().C()) {
                                Logger.d(A, "clean and report - image files: " + e.t + ", " + e.u);
                                Logger.d(A, "clean and report - waiting to report file: " + e.u + ", impression ID: " + e.q);
                                a((c) e);
                            } else if (!c(e.s, e.q)) {
                                BrandSafetyUtils.c(e.u);
                                e.Y = null;
                                e.u = null;
                            }
                            Logger.d(A, "clean and report - hash value: " + e.r + " orientation: " + e.A);
                            if (e.r == null && !e.ad) {
                                Logger.d(A, "clean and report - assigning last captured hash to interstitial: " + e.Y);
                                e.r = e.Y;
                                e.A = e.B;
                            }
                        }
                        if (e != null) {
                            e.ae = SystemClock.elapsedRealtime();
                            e.U += e.ae - e.ac;
                            Logger.d(A, "clean and report - Viewing time (ms) = " + e.U);
                        }
                        if (e != null) {
                            com.safedk.android.analytics.brandsafety.creatives.e.a(e.i());
                            if (z) {
                                if (e.H != null && !TextUtils.isEmpty(e.X)) {
                                    e.H.q(e.x());
                                }
                                d(e, "onAdHidden");
                            } else if (StatsCollector.c() != null) {
                                StatsCollector.c().a(e.p());
                            } else {
                                Logger.w(A, "Stats collector instance is null, cannot remove brand safety event");
                            }
                        }
                    }
                    if (str2 != null) {
                        Logger.d(A, "clean and report - removing from activities : " + str2);
                        this.x.remove((Object) str2);
                    }
                    a(str);
                    k(str);
                }
            } catch (Throwable th) {
                Logger.e(A, "Exception in clean and report : " + th.getMessage(), th);
                new CrashReporter().caughtException(th);
            } finally {
                a(str);
                k(str);
            }
        }
    }

    private void k(String str) {
        Logger.d(A, "clearing AppLovin bundle, eventId = " + str);
        this.y = this.G.size() != 0;
        Logger.d(A, "maxAdIsActive set to " + this.y);
        if (str != null) {
            this.G.keySet().remove(str);
            Logger.d(A, "Removing " + str + " from currentInterstitialInfos");
        }
    }

    public synchronized void d(j jVar, String str) {
        com.safedk.android.utils.j.b(A, "reporting event started, root= " + str + ", info=" + jVar);
        if (jVar == null || !jVar.T) {
            Logger.d(A, "reporting event - info is not interstitial, don't report info");
        } else {
            boolean z = !jVar.I;
            boolean z2 = !jVar.J && jVar.g();
            float f = (jVar.C / 1000.0f) * 100.0f;
            Logger.d(A, "reporting event - image uniformity: " + f);
            String str2 = null;
            if (jVar.b() != null && !jVar.ad) {
                str2 = jVar.b() + "_" + jVar.p();
            }
            e(jVar, str2);
            String str3 = null;
            if (jVar.E != null && jVar.E.containsKey("id")) {
                str3 = jVar.E.getString("id");
                Logger.d(A, "reporting event - event ID: " + str3);
            } else {
                Logger.d(A, "reporting event - no event ID");
            }
            CreativeInfo i = jVar.i();
            String f2 = jVar.f();
            if (i != null && !f2.equals(i.E())) {
                Logger.d(A, "reporting event without CI - sdk: " + jVar.f() + ", CI sdk: " + i.E() + ", CI actual sdk: " + i.F());
                i = null;
            }
            Logger.d(A, "reporting event (Check) root = " + str + ", ciDebugInfo = " + jVar.x());
            List asList = Arrays.asList(com.safedk.android.utils.f.i, com.safedk.android.utils.f.b, "com.unity3d.ads");
            if (!TextUtils.isEmpty(jVar.x()) && str.equals("onAdHidden") && i != null && asList.contains(i.E()) && jVar != null && jVar.E != null && jVar.E.containsKey("ad_format") && jVar.E.getString("ad_format") != null && jVar.E.getString("ad_format").equals(BrandSafetyUtils.j)) {
                i.q(jVar.x());
                String maxEvents = l.a().c().toString();
                com.safedk.android.utils.j.b(A, "reporting event Invalid AppOpen impression detected ciDebugInfo = " + jVar.x() + " , lastMaxEvents = " + maxEvents);
                i.q(maxEvents);
            }
            Logger.d(A, "reporting event " + str3 + ", viewingTime = " + jVar.U);
            BrandSafetyEvent brandSafetyEvent = new BrandSafetyEvent(f2, jVar.D, str2, z2, jVar.g() ? jVar.h() : null, i, jVar.a(), jVar.G, jVar.p(), jVar.U, jVar.U > 0, jVar.E, jVar.A, jVar.V, jVar.v, f, jVar.z, SafeDK.getInstance().d(), str3, jVar.O, jVar.P);
            if (StatsCollector.c() != null) {
                StatsCollector.c().b(brandSafetyEvent);
                if (z) {
                    jVar.b(true);
                }
                if (z2) {
                    jVar.c(true);
                }
            } else {
                Logger.w(A, "reporting event - stats collector instance is null, cannot report brand safety event");
            }
        }
    }

    private void e(j jVar, String str) {
        Logger.d(A, "add CI debug info started, hashValue " + str + ", info=" + jVar.toString());
        if (jVar.i() != null && str != null) {
            String a2 = BrandSafetyUtils.a(BrandSafetyUtils.AdType.INTERSTITIAL, jVar.b(), jVar.f(), jVar.p(), jVar.A);
            if (new File(a2).exists()) {
                if (jVar.i().O() == null || !jVar.i().O().contains("screenshot_datetime")) {
                    long currentTimeMillis = System.currentTimeMillis();
                    jVar.i().q("screenshot_datetime" + CertificateUtil.DELIMITER + currentTimeMillis);
                    Logger.d(A, "add CI debug info: " + currentTimeMillis);
                    return;
                }
                Logger.d(A, "add CI debug info - stats repo is null or already contains this event");
                return;
            }
            Logger.d(A, "add CI debug info - screenshot file path doesn't exist: " + a2);
            return;
        }
        Logger.d(A, "add CI debug info - no creative info or hash is null");
    }

    public synchronized void a(j jVar) {
        Logger.d(A, "take screenshot - started, interstitialInfo = " + jVar);
        a(jVar, (String) null);
    }

    synchronized void a(final j jVar, final String str) {
        Logger.d(A, "take screenshot - currentActivityInterstitial = " + jVar);
        Activity activity = jVar.am;
        if (jVar != null && jVar.y()) {
            Logger.d(A, "take screenshot - sdk Interstitials Run On App Activity = " + jVar.aj);
            if (jVar.am != null && !BrandSafetyUtils.c(activity.getClass()) && !jVar.aj) {
                Logger.d(A, "take screenshot - The activity is not supported : " + activity.getClass());
            } else {
                final String str2 = jVar.w;
                Activity f = f(jVar);
                Logger.d(A, "take screenshot - activity = " + f);
                f.runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        try {
                            synchronized (InterstitialFinder.this) {
                                if (jVar != null) {
                                    Logger.d(InterstitialFinder.A, "take screenshot - Run on UI thread in " + jVar.Z);
                                    View z = jVar.z();
                                    CreativeInfo i = jVar.i();
                                    boolean equals = com.safedk.android.utils.f.h.equals(jVar.f());
                                    boolean equals2 = com.safedk.android.utils.f.f.equals(jVar.f());
                                    boolean z2 = i != null && com.safedk.android.analytics.brandsafety.creatives.discoveries.e.b.equals(i.e());
                                    if (i != null && VungleCreativeInfo.f6835a.equals(i.e())) {
                                        Logger.d(InterstitialFinder.A, "This ad is a VUNGLE_MRAID_AD");
                                    }
                                    if (i != null) {
                                        Logger.d(InterstitialFinder.A, "is video ad? " + i.l() + ", is vast video ad? " + i.o() + ", is Inmobi multi ad? " + z2);
                                    }
                                    if (!SafeDK.getInstance().B() && !equals && !equals2) {
                                        if (i == null) {
                                            Logger.d(InterstitialFinder.A, "no creative info yet");
                                        } else if (i.m() || z2) {
                                            Logger.d(InterstitialFinder.A, "ad is playable or multi ad");
                                        } else if (!i.l()) {
                                            Logger.d(InterstitialFinder.A, "ad is not a video/playable ad");
                                            InterstitialFinder.this.a(jVar, z, str2, str);
                                        } else if (jVar.aa || CreativeInfoManager.a(i.E(), AdNetworkConfiguration.SHOULD_TAKE_INTERSTITIAL_SCREENSHOTS_THROUGHOUT_IMPRESSION, false)) {
                                            Logger.d(InterstitialFinder.A, "video ad finished playing or sdk configured to take screenshots throughout the impression. ");
                                            InterstitialFinder.this.a(jVar, z, str2, str);
                                        } else {
                                            Logger.d(InterstitialFinder.A, "Video hasn't finished playing yet, waiting for onVideoCompleted event");
                                        }
                                    } else if (SafeDK.getInstance().B()) {
                                        Logger.d(InterstitialFinder.A, "SafeDK Config item 'AlwaysTakeScreenshot' is true. taking screenshot");
                                        InterstitialFinder.this.a(jVar, z, str2, str);
                                    } else if (i != null) {
                                        Logger.d(InterstitialFinder.A, "Admob/IronSource SDK. taking screenshot");
                                        InterstitialFinder.this.a(jVar, z, str2, str);
                                    } else {
                                        Logger.d(InterstitialFinder.A, "Admob/IronSource SDK but no ci yet. not taking screenshot");
                                    }
                                }
                            }
                        } catch (Throwable th) {
                            Logger.e(InterstitialFinder.A, "Failed while taking screenshot", th);
                            new CrashReporter().caughtException(th);
                        }
                    }
                });
            }
        }
    }

    private Activity f(j jVar) {
        if (jVar.aj) {
            return com.safedk.android.internal.b.getInstance().getForegroundActivity();
        }
        return jVar.am;
    }

    private String a(Bundle bundle) {
        String string = bundle.getString("ad_format");
        if (string == null) {
            return null;
        }
        if (string.equals(BrandSafetyUtils.i)) {
            return BrandSafetyEvent.AdFormatType.REWARD.name();
        }
        if (string.equals(BrandSafetyUtils.h)) {
            return BrandSafetyEvent.AdFormatType.INTER.name();
        }
        if (!string.equals(BrandSafetyUtils.j)) {
            return null;
        }
        return BrandSafetyEvent.AdFormatType.APPOPEN.name();
    }

    @Override
    public synchronized boolean a(k kVar) {
        j jVar;
        BrandSafetyEvent.AdFormatType a2;
        BrandSafetyEvent.AdFormatType a3;
        synchronized (this) {
            Logger.d(A, "set CI details started , matchingInfo = " + kVar.toString());
            CreativeInfo creativeInfo = kVar.f6852a;
            if (creativeInfo != null) {
                creativeInfo.f(BrandSafetyUtils.ScreenShotOrientation.PORTRAIT.equals(BrandSafetyUtils.c()));
                j jVar2 = null;
                if (kVar != null && kVar.f6852a != null && kVar.f6852a.g() != null) {
                    jVar2 = this.G.e(kVar.f6852a.g());
                    Logger.d(A, "set CI details attempt to locate interstitial info by eventId " + kVar.f6852a.g() + ", success ? " + (jVar2 != null));
                }
                if (jVar2 == null && kVar != null && kVar.f6852a != null && kVar.f6852a.T() != null) {
                    jVar2 = this.G.b(kVar.f6852a.T());
                    Logger.d(A, "set CI details attempt to locate interstitial info by matching object address " + kVar.f6852a.T() + ", success ? " + (jVar2 != null));
                }
                j jVar3 = jVar2;
                if (jVar3 == null) {
                    List<j> a4 = this.G.a(creativeInfo.E());
                    if (a4.size() == 1) {
                        j jVar4 = a4.get(0);
                        Logger.d(A, "set CI details found 1 InterstitialInfo object by sdk " + creativeInfo.E());
                        jVar = jVar4;
                    } else if (a4.size() > 1) {
                        Logger.d(A, "set CI details found " + a4.size() + " InterstitialInfo objects by sdk " + creativeInfo.E() + " : " + a4);
                        jVar = jVar3;
                    } else {
                        Logger.d(A, "set CI details no InterstitialInfo object not found");
                    }
                    Logger.d(A, "set CI details - ad info sdk: " + (jVar == null ? jVar.f() : "null") + ", CI sdk: " + creativeInfo.E() + " ad info webview address: " + (jVar == null ? jVar.M : "null") + ", ci matching object address: " + creativeInfo.T());
                    if (jVar != null && jVar.E != null) {
                        Logger.d(A, "set CI details - CI ad format: " + creativeInfo.v() + ", max ad type: " + jVar.E.getString("ad_format"));
                        if ((creativeInfo.v() != null || !creativeInfo.v().equals(jVar.E.getString("ad_format"))) && (a3 = BrandSafetyUtils.a(jVar.E)) != null) {
                            Logger.d(A, "set CI details - updating ad format value to " + a3.name());
                            creativeInfo.m(a3.name());
                            jVar.f("ad_type_upd(sCrInfoDtls):" + a3.name());
                        }
                    }
                    if (jVar != null && jVar.w != null && (jVar.w.equals(creativeInfo.E()) || jVar.w.equals(creativeInfo.F()))) {
                        Logger.d(A, "set CI details - currentMaxPackageName: " + jVar.w);
                        if (a(creativeInfo, jVar)) {
                            Logger.d(A, "set CI details - setting as current CI for SDK: " + creativeInfo.E());
                            if (jVar != null && jVar.i() != null) {
                                Logger.d(A, "set CI details - replacing  " + jVar.i());
                            }
                            if (creativeInfo.v() == null && (a2 = BrandSafetyUtils.a(jVar.E)) != null) {
                                Logger.d(A, "Start monitoring ad check, updating ad format value to " + a2.name());
                                creativeInfo.m(a2.name());
                                jVar.f("ad_type_upd(shldStrtMntrngAd):" + a2.name());
                            }
                            b(creativeInfo, jVar);
                            r0 = a(kVar, jVar);
                        }
                    }
                    Logger.d(A, "set CI details - adding as pending for SDK: " + creativeInfo.E() + " matching info: " + kVar);
                    a(kVar, creativeInfo.E());
                    b(creativeInfo, jVar);
                    r0 = true;
                }
                jVar = jVar3;
                Logger.d(A, "set CI details - ad info sdk: " + (jVar == null ? jVar.f() : "null") + ", CI sdk: " + creativeInfo.E() + " ad info webview address: " + (jVar == null ? jVar.M : "null") + ", ci matching object address: " + creativeInfo.T());
                if (jVar != null) {
                    Logger.d(A, "set CI details - CI ad format: " + creativeInfo.v() + ", max ad type: " + jVar.E.getString("ad_format"));
                    if (creativeInfo.v() != null) {
                    }
                    Logger.d(A, "set CI details - updating ad format value to " + a3.name());
                    creativeInfo.m(a3.name());
                    jVar.f("ad_type_upd(sCrInfoDtls):" + a3.name());
                }
                if (jVar != null) {
                    Logger.d(A, "set CI details - currentMaxPackageName: " + jVar.w);
                    if (a(creativeInfo, jVar)) {
                    }
                }
                Logger.d(A, "set CI details - adding as pending for SDK: " + creativeInfo.E() + " matching info: " + kVar);
                a(kVar, creativeInfo.E());
                b(creativeInfo, jVar);
                r0 = true;
            }
        }
        return r0;
    }

    private void b(CreativeInfo creativeInfo, j jVar) {
        if (jVar != null && jVar.ak == null) {
            if (!jVar.al) {
                Logger.d(A, "set CI details - starting timer for InterstitialInfo with event id: " + jVar.t());
                g(jVar);
                jVar.U = 0L;
                jVar.ak = this.w.scheduleAtFixedRate(new b(jVar.N), B, 1000L, TimeUnit.MILLISECONDS);
                return;
            }
            Logger.d(A, "set CI details - avoid recursive call to web view scanning");
            creativeInfo.q("avoidRecWebScan");
        }
    }

    private synchronized void a(k kVar, String str) {
        List<k> list = this.I.get(str);
        if (list == null) {
            list = new ArrayList<>();
            this.I.put(str, list);
        }
        list.add(kVar);
    }

    public synchronized boolean a(k kVar, j jVar) {
        boolean z = false;
        synchronized (this) {
            com.safedk.android.utils.j.b(A, "set CI started, matching info=" + (kVar == null ? "null" : kVar.toString()));
            if (kVar == null) {
                com.safedk.android.utils.j.b(A, "set CI, matching info is null");
            } else {
                CreativeInfo creativeInfo = kVar.f6852a;
                if (creativeInfo != null) {
                    Logger.d(A, "set CI, matching info is " + kVar.toString());
                    if (jVar != null) {
                        if (jVar.i() != null) {
                            CreativeInfoManager.a(creativeInfo);
                            com.safedk.android.utils.j.b(A, "set CI, already matched! ignore matching attempt CI: " + creativeInfo);
                        } else {
                            creativeInfo.a(kVar.b, kVar.c);
                            Logger.d(A, "set CI creativeInfo: " + creativeInfo);
                            jVar.a(creativeInfo);
                            creativeInfo.q("wv:" + jVar.M);
                            if (jVar.L == AdNetworkDiscovery.WebViewResourceMatchingMethod.WEBVIEW_LOOKUP && jVar.M != null) {
                                com.safedk.android.analytics.brandsafety.creatives.e.a(jVar.M, creativeInfo);
                            } else {
                                com.safedk.android.analytics.brandsafety.creatives.e.a(creativeInfo, (String) null);
                            }
                            if (kVar.b.startsWith(CreativeInfo.h)) {
                                jVar.r();
                            }
                            d(jVar, "setCreativeInfo");
                            if (creativeInfo.l()) {
                                jVar.aa = false;
                            }
                            if (!jVar.ag) {
                                StatsReporter.b().a(creativeInfo, jVar.E);
                                jVar.ag = true;
                            }
                            z = true;
                        }
                    }
                }
            }
        }
        return z;
    }

    @Override
    public synchronized void a(String str, String str2, String str3) {
        Logger.d(A, "set ad click URL started, sdk: " + str2 + ", url: " + str + ", view address: " + str3);
        String a2 = com.safedk.android.analytics.brandsafety.creatives.e.a(str2);
        j b2 = this.G.b(str3);
        if (b2 == null && this.G.a(a2).size() == 1) {
            Logger.d(A, "InterstitialInfo not found by address, trying by SdkPackageName " + a2);
            b2 = this.G.a(a2).get(0);
        }
        if (b2 != null && b2.f() != null && SdksMapping.isSameSdkByPackages(b2.f(), a2)) {
            Logger.d(A, "set ad click URL - applying clickUrl candidate logic. url: " + str);
            if (!b2.g()) {
                Logger.d(A, "set ad click URL - current Activity Interstitial is not marked as clicked, setting click URL: " + str);
                b(b2, str);
            } else if (b2.h() == null) {
                Logger.d(A, "set ad click URL - no click URL yet, setting clickUrl: " + str);
                b2.e(str);
            } else {
                Logger.d(A, "set ad click URL - click URL already set: " + b2.h());
            }
        } else {
            Logger.d(A, "set ad click URL skipped, SDK: " + (b2 != null ? b2.f() : "null"));
        }
    }

    @Override
    public synchronized void b(String str, String str2, String str3) {
        j b2 = this.G.b(str3);
        if (b2 != null && b2.g() && str2 != null && str2.equals(b2.f()) && b2.am != null) {
            String obj = b2.am.toString();
            Logger.d(A, "set previous activity click url, click activity: " + obj + ", ad activity: " + b2.Z);
            String a2 = BrandSafetyUtils.a(obj, true);
            if (a2 != null && !a2.equals(b2.F)) {
                Logger.d(A, "set previous activity click url - detected URL for click in previous activity (not yet destroyed), url: " + str);
                if (b2.e(str)) {
                    d(b2, "setPreviousActivityClickUrl");
                }
            }
        }
    }

    public synchronized void a(j jVar, View view, String str, String str2) {
        if (jVar != null) {
            try {
                Logger.d(A, "taking screenshot started");
                String f = jVar.f();
                Bitmap a2 = new com.safedk.android.analytics.brandsafety.creatives.f().a(view, SafeDK.getInstance().y());
                if (a2 != null) {
                    BrandSafetyUtils.a a3 = BrandSafetyUtils.a(f, a2);
                    int a4 = a3.a();
                    if (BrandSafetyUtils.a(f, a3)) {
                        String a5 = BrandSafetyUtils.a(a2);
                        Logger.d(A, "taking screenshot found interstitial, hash = " + a5);
                        if (jVar != null && jVar.p() != null) {
                            jVar.af = BrandSafetyUtils.b(a2);
                            Logger.d(A, "taking screenshot impressionId is " + jVar.p());
                        } else {
                            Logger.d(A, "taking screenshot impressionId is null");
                        }
                        String p = (jVar == null || jVar.p() == null) ? "" : jVar.p();
                        String a6 = BrandSafetyUtils.a(a2, BrandSafetyUtils.AdType.INTERSTITIAL, a5, f, p, jVar.af);
                        Logger.d(A, "taking screenshot screenshot file created, filename = " + a6);
                        long b2 = BrandSafetyUtils.b(a6);
                        if (b2 < SafeDK.getInstance().a(f)) {
                            Logger.d(A, "taking screenshot file size too small " + b2 + " (bytes). This image will not be used");
                            BrandSafetyUtils.c(a6);
                        } else {
                            Logger.d(A, "taking screenshot stored file size is " + b2 + " bytes, counter is " + jVar.z + ", uniform pixel count is " + a4 + " (" + ((a4 / 1000.0f) * 100.0f) + "%)");
                            int size = this.u.size();
                            if (!d(a5, p)) {
                                boolean z = false;
                                if (size < SafeDK.getInstance().C()) {
                                    Logger.d(A, "taking screenshot impressions to report size=" + size + ", max images to store=" + SafeDK.getInstance().C());
                                    if (jVar != null && jVar.Y == null) {
                                        z = true;
                                    } else if (jVar != null && jVar.Y != null && !jVar.Y.equals(a5)) {
                                        BrandSafetyUtils.c(jVar.Y);
                                        z = true;
                                    }
                                    if (z) {
                                        Logger.d(A, "taking screenshot keeping file of interstitial " + a5 + ". file size is " + b2 + " (bytes), orientation: " + jVar.af);
                                        jVar.Y = a5;
                                        jVar.u = a6;
                                        jVar.B = jVar.A;
                                        BrandSafetyUtils.a(jVar.q(), BrandSafetyUtils.AdType.INTERSTITIAL, a5, f, p, jVar.af);
                                    }
                                } else if (!c(a5, p)) {
                                    Logger.d(A, "taking screenshot no open slot for interstitial " + a5 + "; next hashes to be reported to server are " + this.u.keySet());
                                    BrandSafetyUtils.c(a6);
                                } else {
                                    Logger.d(A, "taking screenshot image " + a5 + "_" + p + " is already scheduled for upload");
                                }
                            } else {
                                Logger.d(A, "taking screenshot not saving file for interstitial " + a5 + "_" + p);
                                BrandSafetyUtils.c(a6);
                                if (d(a5, p)) {
                                    Logger.d(A, "taking screenshot interstitial " + a5 + "_" + p + " was already reported");
                                } else {
                                    Logger.d(A, "taking screenshot waiting to report stored interstitial " + jVar.Y);
                                }
                                if (jVar.Y != null) {
                                    if (c(jVar.Y, jVar.q)) {
                                        BrandSafetyUtils.c(jVar.u);
                                    } else {
                                        Logger.d(A, "taking screenshot not deleting not best image " + jVar.u);
                                    }
                                }
                            }
                            boolean z2 = false;
                            if (jVar != null && a5 != null) {
                                Logger.d(A, "taking screenshot setting interstitial info data (previous hash = " + jVar.Y + ", current hash = " + a5 + ")");
                                z2 = (a5 == null || jVar.Y == null || a5.equals(jVar.Y)) ? false : true;
                            }
                            if (jVar != null) {
                                if (jVar.af.equals(BrandSafetyUtils.ScreenShotOrientation.NOT_INITIALIZED)) {
                                    jVar.af = BrandSafetyUtils.b(a2);
                                }
                                jVar.a(a5, a6, b2, a4, jVar.z, jVar.af, z2);
                            }
                            if (jVar.Y == null) {
                                Logger.d(A, "taking screenshot no previous hash to detect animation, keep sampling");
                                jVar.Y = a5;
                            } else if (a(a4, b2)) {
                                jVar.f(z2);
                                Logger.d(A, "taking screenshot setting interstitial is_animated field to " + z2);
                                if (!TextUtils.isEmpty(a5)) {
                                    if (jVar.af.equals(BrandSafetyUtils.ScreenShotOrientation.NOT_INITIALIZED)) {
                                        jVar.A = BrandSafetyUtils.b(a2);
                                    }
                                    d(jVar, "takeScreenshot");
                                    jVar.d(true);
                                }
                                a(jVar.N);
                            } else {
                                jVar.Y = a5;
                            }
                        }
                    } else {
                        Logger.d(A, "taking screenshot screenshot is not valid (uniform pixel count too high: " + a4 + "), try again...");
                        if (jVar != null && jVar.W && jVar.aa) {
                            Logger.d(A, "taking screenshot back from background - reset video completed indication to false");
                            jVar.W = false;
                            jVar.aa = false;
                        }
                    }
                }
            } catch (Throwable th) {
                Logger.e(A, "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(A, "View = " + childAt + ": width = " + width + " height = " + height);
                    if (childAt.getVisibility() == 0 && a(width, height)) {
                        str = a(childAt);
                        Logger.d(A, "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(A, "should stop sampling started, maxUniformedPixelsCount=" + i + ", fileSize=" + j + " (bytes), stopSamplingFileSize=" + SafeDK.getInstance().D());
        z = BrandSafetyUtils.a(i) && j > SafeDK.getInstance().D();
        Logger.d(A, "should stop sampling returned " + z);
        return z;
    }

    @Override
    public void g() {
        if (this.G != null) {
            for (j jVar : this.G.values()) {
                if (jVar != null && jVar.T) {
                    d(jVar, "onBackground");
                }
            }
        }
    }

    @Override
    public synchronized void h() {
        if (this.G != null) {
            for (j jVar : this.G.values()) {
                if (jVar != null) {
                    jVar.W = true;
                }
            }
        }
    }

    public synchronized void g(final j jVar) {
        if (jVar != null) {
            if (!jVar.al) {
                Activity activity = jVar.am;
                Logger.d(A, "scan for webViews started, activity: " + activity);
                if (activity != null) {
                    try {
                        jVar.al = true;
                        View findViewById = activity.getWindow().getDecorView().findViewById(R.id.content);
                        try {
                            if (jVar.L == AdNetworkDiscovery.WebViewResourceMatchingMethod.WEBVIEW_LOOKUP && jVar.M == null) {
                                final AdNetworkDiscovery f = CreativeInfoManager.f(jVar.f());
                                if (f == null) {
                                    jVar.al = false;
                                } else {
                                    ArrayList arrayList = new ArrayList();
                                    ArrayList arrayList2 = new ArrayList();
                                    ArrayList arrayList3 = new ArrayList();
                                    arrayList2.add(BrandSafetyUtils.a(findViewById));
                                    arrayList3.add("h1c1:" + findViewById);
                                    a(jVar, jVar.f() != null ? jVar.f() : "", (ViewGroup) findViewById, arrayList, arrayList2, arrayList3, 1);
                                    Logger.d(A, "scan for webViews found web views : " + arrayList);
                                    com.safedk.android.utils.j.b(A, "scan for webViews found views hierarchy : " + arrayList3);
                                    final WebView a2 = f.a((List<WebView>) arrayList);
                                    jVar.a(arrayList2);
                                    if (a2 != null) {
                                        Logger.d(A, "scan for webViews found " + a2);
                                        final String a3 = BrandSafetyUtils.a(a2);
                                        SafeDKWebAppInterface.a(a3);
                                        com.safedk.android.analytics.brandsafety.creatives.e.c(a3);
                                        if (jVar.M == null && jVar.am != null) {
                                            jVar.am.runOnUiThread(new Runnable() {
                                                @Override
                                                public void run() {
                                                    Logger.d(InterstitialFinder.A, "scan for webViews will add js (if necessary) for : " + a2 + " with dummy ");
                                                    SafeDKWebAppInterface.a(jVar.f(), a2, "https://dummyurl");
                                                }
                                            });
                                        } else if (!jVar.M.equals(a3)) {
                                            Logger.d(A, "scan for webViews identified multi ads");
                                            jVar.ad = true;
                                            if (jVar.H != null) {
                                                jVar.H.a(true);
                                                jVar.H.c(jVar.H.e().concat("/multiple_ads"));
                                            }
                                        }
                                        jVar.M = a3;
                                        Logger.d(A, "scan for webViews address set to " + a3);
                                        CreativeInfo i = jVar.i();
                                        if (i != null) {
                                            Logger.d(A, "scan for webViews CI : " + i);
                                            com.safedk.android.analytics.brandsafety.creatives.e.a(a3, i);
                                        } else {
                                            Logger.d(A, "scan for webViews will check for pending CIs for package " + jVar.f());
                                            k a4 = a(jVar.f(), jVar);
                                            if (a4 != null) {
                                                a(a4, jVar);
                                            }
                                        }
                                        if (f.d() != null && f.d().a(AdNetworkConfiguration.APP_OPEN_IMPRESSION_TRACKING_ENABLED, false) && jVar.E != null && jVar.E.containsKey("ad_format") && jVar.E.getString("ad_format").equals(BrandSafetyUtils.j)) {
                                            this.w.execute(new Runnable() {
                                                @Override
                                                public void run() {
                                                    CreativeInfo a5 = f.a((Object) a2);
                                                    if (a5 != null) {
                                                        com.safedk.android.utils.j.b(InterstitialFinder.A, "scan for webViews ci returned : " + a5);
                                                        if (a5.g() == null) {
                                                            a5.d(jVar.N);
                                                        }
                                                        if (jVar.E != null && jVar.E.containsKey("ad_format")) {
                                                            String string = jVar.E.getString("ad_format");
                                                            a5.m(string);
                                                            jVar.f("ad_type_upd(scnFrWVs):" + string);
                                                            Logger.d(InterstitialFinder.A, "scan for webViews ad_format set to  : " + string);
                                                        }
                                                        InterstitialFinder.this.a(new k(a5, CreativeInfo.n, a3));
                                                        return;
                                                    }
                                                    Logger.d(InterstitialFinder.A, "scan for webViews ci not found by View");
                                                }
                                            });
                                        }
                                    } else {
                                        Logger.d(A, "scan for webViews - WebView not found");
                                    }
                                }
                            }
                            jVar.al = false;
                        } catch (Throwable th) {
                            Logger.e(A, "scan for webViews execution: ", th);
                            jVar.al = false;
                        }
                    } catch (Throwable th2) {
                        jVar.al = false;
                        throw th2;
                    }
                }
            }
        }
    }

    private void a(final j jVar, final Activity activity) {
        this.w.execute(new Runnable() {
            @Override
            public void run() {
                CreativeInfo b2;
                ViewGroup viewGroup = (ViewGroup) activity.getWindow().getDecorView().findViewById(R.id.content);
                String b3 = BrandSafetyUtils.b(activity.getClass());
                Logger.d(InterstitialFinder.A, "try to find CI, ad format = " + jVar.E.get("ad_format") + ", activity sdk = " + b3);
                try {
                    if (jVar != null && jVar.H == null && CreativeInfoManager.a(b3) == AdNetworkDiscovery.WebViewResourceMatchingMethod.WEBVIEW_LOOKUP && jVar.E != null && jVar.E.containsKey("ad_format") && jVar.E.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(jVar.E);
                        Logger.d(InterstitialFinder.A, "try to find CI, updating ad format value to " + a2);
                        b2.m(a2 != null ? a2.name() : null);
                        jVar.f("ad_type_upd(tryTFndCI):" + a2.name());
                        b2.d(jVar.E.getString("id"));
                        b2.e(jVar.E.getString(BrandSafetyEvent.k));
                        InterstitialFinder.this.a(activity, jVar);
                        Logger.d(InterstitialFinder.A, "try to find CI - ci event id : " + b2.g() + ", placement id : " + b2.s());
                        InterstitialFinder.this.a(new k(b2, CreativeInfo.n, ""));
                    }
                } catch (Throwable th) {
                    Logger.d(InterstitialFinder.A, "Exception while attempting to find CI : " + th.getMessage(), th);
                }
            }
        });
    }

    public void b(j jVar, String str) {
        jVar.ai = new g(System.currentTimeMillis(), str);
    }

    public void f(String str, String str2) {
        Logger.d(A, "setCurrentInterstitialDownstreamStruct started");
        List<j> a2 = this.G.a(str);
        if (a2.size() == 1) {
            j jVar = a2.get(0);
            if (jVar != null && jVar.H != null && str2 != null) {
                jVar.H.c(jVar.H.e() + "/" + str2);
                return;
            }
            return;
        }
        Logger.d(A, "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() {
            k a2;
            long currentTimeMillis = System.currentTimeMillis();
            if (this.b != null) {
                j jVar = InterstitialFinder.this.G.get(this.b);
                if (jVar != null) {
                    Logger.d(InterstitialFinder.A, "InterstitialFinderTask Timer for Info " + jVar.N);
                    if (jVar.am != null) {
                        Logger.d(InterstitialFinder.A, "InterstitialFinderTask activity sdk is " + BrandSafetyUtils.b(jVar.am.getClass()));
                    }
                    if (!jVar.I && jVar.z == 2) {
                        InterstitialFinder.this.d(jVar, "timer task run");
                    }
                    if (InterstitialFinder.this.H == 0 || currentTimeMillis - InterstitialFinder.this.H >= 900.0d) {
                        InterstitialFinder.this.H = currentTimeMillis;
                        if (!jVar.ad) {
                            InterstitialFinder.this.a(jVar);
                        } else {
                            Logger.d(InterstitialFinder.A, "Request To Stop Taking Screenshots Has Been Received, skipping.");
                        }
                        int i = jVar.z + 1;
                        jVar.z = i;
                        if (i != 120) {
                            InterstitialFinder.this.g(jVar);
                            if (jVar.H == null && (a2 = InterstitialFinder.this.a(jVar.w, jVar)) != null && a2.f6852a != null) {
                                InterstitialFinder.this.a(a2, jVar);
                                return;
                            }
                            return;
                        }
                        Logger.d(InterstitialFinder.A, "Max number of screenshots threshold reached, no need to start timers");
                        InterstitialFinder.this.a(this.b);
                        return;
                    }
                    return;
                }
                return;
            }
            Logger.d(InterstitialFinder.A, "InterstitialFinderTask eventId is null, skipping.");
        }
    }

    public class a {

        String f6783a;
        String b;

        public a(String str, String str2) {
            this.f6783a = 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.f6783a.equals(aVar.f6783a);
            return this.b != null ? equals && this.b.equals(aVar.b) : equals;
        }

        public int hashCode() {
            return this.b != null ? this.f6783a.hashCode() * this.b.hashCode() : this.f6783a.hashCode();
        }

        public String toString() {
            return "{placementId=" + this.f6783a + ", eventId=" + this.b + com.safedk.android.analytics.brandsafety.creatives.discoveries.h.u;
        }

        public String a() {
            return (this.f6783a != null ? this.f6783a : "") + "_" + (this.b != null ? this.b : "");
        }
    }

    private static View a(ViewGroup viewGroup, String str) {
        Logger.d(A, "find views " + viewGroup.toString());
        int childCount = viewGroup.getChildCount();
        for (int i = 0; i < childCount; i++) {
            View childAt = viewGroup.getChildAt(i);
            Logger.d(A, "find views child " + childAt.toString());
            if (str != null && childAt.getClass().getName().equals(str)) {
                Logger.d(A, "find views found " + str + " : " + childAt.toString());
                return childAt;
            }
            if (childAt instanceof ViewGroup) {
                return a((ViewGroup) childAt, str);
            }
        }
        return null;
    }

    public CreativeInfo b(ViewGroup viewGroup, String str) {
        Logger.d(A, "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(A, "get creative info from ad view - child " + childAt.toString());
            CreativeInfo a2 = CreativeInfoManager.f(str).a((Object) childAt);
            if (a2 != null) {
                a2.a((Object) childAt);
                a2.q("ci_source_sdk_class:" + childAt.getClass().getName());
                Logger.d(A, "get creative info from ad view - ci found, object : " + childAt.toString());
                return a2;
            }
            if (childAt instanceof ViewGroup) {
                return b((ViewGroup) childAt, str);
            }
        }
        return null;
    }

    public static void a(View view, int i) {
        Logger.d(A, "find views view : " + new String(new char[i * 2]).replace("\u0000", "-") + view.getClass().toString() + new StringBuilder().toString());
    }

    @Override
    public void b(c cVar) {
        if (cVar instanceof j) {
            b((j) cVar);
        }
    }

    public synchronized void b(j jVar) {
        Logger.d(A, "remove impression screenshots started");
        if (jVar.ah != null) {
            Logger.d(A, "Calling remove ad files, filename = " + jVar.ah);
            BrandSafetyUtils.c(jVar.ah);
            String e = e(jVar.ah);
            if (e != null && this.u.containsKey(e)) {
                Logger.d(A, "remove impression to report, key = " + e);
                this.u.remove(e);
            }
            jVar.ah = null;
        } else {
            Logger.d(A, "no last activity impression screenshot filename");
        }
        this.v.clear();
    }
}