package com.applovin.impl.mediation; import android.app.Activity; import android.os.Bundle; import com.applovin.impl.ie; import com.applovin.impl.p; import com.applovin.impl.q; import com.applovin.impl.sdk.j; import com.applovin.impl.sdk.n; import com.applovin.impl.yp; /* loaded from: classes2.dex */ public class a extends p { private final q a; private final n b; private final String c = yp.l(j.l()); private InterfaceC0025a d; private ie e; private boolean f; private int g; private boolean h; /* renamed from: com.applovin.impl.mediation.a$a, reason: collision with other inner class name */ public interface InterfaceC0025a { void b(ie ieVar); } public a(j jVar) { this.b = jVar.J(); this.a = jVar.e(); } public void a(boolean z) { this.f = z; } @Override // com.applovin.impl.p, android.app.Application.ActivityLifecycleCallbacks public void onActivityCreated(Activity activity, Bundle bundle) { if (activity.getClass().getName().equals(this.c) && (this.e.v0() || this.f)) { if (n.a()) { this.b.a("AdActivityObserver", "App relaunched via launcher without an ad hidden callback, manually invoking ad hidden"); } if (this.d != null) { if (n.a()) { this.b.a("AdActivityObserver", "Invoking callback..."); } this.d.b(this.e); } a(); return; } if (!this.h) { this.h = true; } this.g++; if (n.a()) { this.b.a("AdActivityObserver", "Created Activity: " + activity + ", counter is " + this.g); } } public void a(ie ieVar, InterfaceC0025a interfaceC0025a) { if (n.a()) { this.b.a("AdActivityObserver", "Starting for ad " + ieVar.getAdUnitId() + "..."); } a(); this.d = interfaceC0025a; this.e = ieVar; this.a.a(this); } @Override // com.applovin.impl.p, android.app.Application.ActivityLifecycleCallbacks public void onActivityDestroyed(Activity activity) { if (this.h) { this.g--; if (n.a()) { this.b.a("AdActivityObserver", "Destroyed Activity: " + activity + ", counter is " + this.g); } if (this.g <= 0) { if (n.a()) { this.b.a("AdActivityObserver", "Last ad Activity destroyed"); } if (this.d != null) { if (n.a()) { this.b.a("AdActivityObserver", "Invoking callback..."); } this.d.b(this.e); } a(); } } } public void a() { if (n.a()) { this.b.a("AdActivityObserver", "Cancelling..."); } this.a.b(this); this.d = null; this.e = null; this.g = 0; this.h = false; } }