- 28,932 files - Full Java source code - Smali files - Resources Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
263 lines
7.4 KiB
Java
263 lines
7.4 KiB
Java
package com.iab.omid.library.unity3d.adsession;
|
|
|
|
import android.view.View;
|
|
import androidx.annotation.NonNull;
|
|
import androidx.annotation.Nullable;
|
|
import com.iab.omid.library.unity3d.internal.c;
|
|
import com.iab.omid.library.unity3d.internal.e;
|
|
import com.iab.omid.library.unity3d.internal.h;
|
|
import com.iab.omid.library.unity3d.publisher.AdSessionStatePublisher;
|
|
import com.iab.omid.library.unity3d.publisher.b;
|
|
import com.iab.omid.library.unity3d.utils.g;
|
|
import java.util.ArrayList;
|
|
import java.util.Collection;
|
|
import java.util.Iterator;
|
|
import java.util.List;
|
|
import java.util.UUID;
|
|
import java.util.regex.Pattern;
|
|
import org.json.JSONObject;
|
|
|
|
/* loaded from: classes2.dex */
|
|
public class a extends AdSession {
|
|
private static final Pattern l = Pattern.compile("^[a-zA-Z0-9 ]+$");
|
|
private final AdSessionContext a;
|
|
private final AdSessionConfiguration b;
|
|
private com.iab.omid.library.unity3d.weakreference.a d;
|
|
private AdSessionStatePublisher e;
|
|
private final String h;
|
|
private boolean i;
|
|
private boolean j;
|
|
private PossibleObstructionListener k;
|
|
private final List<e> c = new ArrayList();
|
|
private boolean f = false;
|
|
private boolean g = false;
|
|
|
|
public a(AdSessionConfiguration adSessionConfiguration, AdSessionContext adSessionContext) {
|
|
this.b = adSessionConfiguration;
|
|
this.a = adSessionContext;
|
|
String uuid = UUID.randomUUID().toString();
|
|
this.h = uuid;
|
|
d(null);
|
|
this.e = (adSessionContext.getAdSessionContextType() == AdSessionContextType.HTML || adSessionContext.getAdSessionContextType() == AdSessionContextType.JAVASCRIPT) ? new com.iab.omid.library.unity3d.publisher.a(uuid, adSessionContext.getWebView()) : new b(uuid, adSessionContext.getInjectedResourcesMap(), adSessionContext.getOmidJsScriptContent());
|
|
this.e.i();
|
|
c.c().a(this);
|
|
this.e.a(adSessionConfiguration);
|
|
}
|
|
|
|
private void a() {
|
|
if (this.i) {
|
|
throw new IllegalStateException("Impression event can only be sent once");
|
|
}
|
|
}
|
|
|
|
private static void a(View view) {
|
|
if (view == null) {
|
|
throw new IllegalArgumentException("FriendlyObstruction is null");
|
|
}
|
|
}
|
|
|
|
private void a(String str) {
|
|
if (str != null) {
|
|
if (str.length() > 50) {
|
|
throw new IllegalArgumentException("FriendlyObstruction has detailed reason over 50 characters in length");
|
|
}
|
|
if (!l.matcher(str).matches()) {
|
|
throw new IllegalArgumentException("FriendlyObstruction has detailed reason that contains characters not in [a-z][A-Z][0-9] or space");
|
|
}
|
|
}
|
|
}
|
|
|
|
private e b(View view) {
|
|
for (e eVar : this.c) {
|
|
if (eVar.c().get() == view) {
|
|
return eVar;
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
|
|
private void b() {
|
|
if (this.j) {
|
|
throw new IllegalStateException("Loaded event can only be sent once");
|
|
}
|
|
}
|
|
|
|
private void c(View view) {
|
|
Collection<a> b = c.c().b();
|
|
if (b == null || b.isEmpty()) {
|
|
return;
|
|
}
|
|
for (a aVar : b) {
|
|
if (aVar != this && aVar.c() == view) {
|
|
aVar.d.clear();
|
|
}
|
|
}
|
|
}
|
|
|
|
private void d(View view) {
|
|
this.d = new com.iab.omid.library.unity3d.weakreference.a(view);
|
|
}
|
|
|
|
public void a(List<com.iab.omid.library.unity3d.weakreference.a> list) {
|
|
if (e()) {
|
|
ArrayList arrayList = new ArrayList();
|
|
Iterator<com.iab.omid.library.unity3d.weakreference.a> it = list.iterator();
|
|
while (it.hasNext()) {
|
|
View view = it.next().get();
|
|
if (view != null) {
|
|
arrayList.add(view);
|
|
}
|
|
}
|
|
this.k.onPossibleObstructionsDetected(this.h, arrayList);
|
|
}
|
|
}
|
|
|
|
public void a(@NonNull JSONObject jSONObject) {
|
|
b();
|
|
getAdSessionStatePublisher().a(jSONObject);
|
|
this.j = true;
|
|
}
|
|
|
|
@Override // com.iab.omid.library.unity3d.adsession.AdSession
|
|
public void addFriendlyObstruction(View view, FriendlyObstructionPurpose friendlyObstructionPurpose, @Nullable String str) {
|
|
if (this.g) {
|
|
return;
|
|
}
|
|
a(view);
|
|
a(str);
|
|
if (b(view) == null) {
|
|
this.c.add(new e(view, friendlyObstructionPurpose, str));
|
|
}
|
|
}
|
|
|
|
public View c() {
|
|
return this.d.get();
|
|
}
|
|
|
|
public List<e> d() {
|
|
return this.c;
|
|
}
|
|
|
|
public boolean e() {
|
|
return this.k != null;
|
|
}
|
|
|
|
@Override // com.iab.omid.library.unity3d.adsession.AdSession
|
|
public void error(ErrorType errorType, String str) {
|
|
if (this.g) {
|
|
throw new IllegalStateException("AdSession is finished");
|
|
}
|
|
g.a(errorType, "Error type is null");
|
|
g.a(str, "Message is null");
|
|
getAdSessionStatePublisher().a(errorType, str);
|
|
}
|
|
|
|
public boolean f() {
|
|
return this.f && !this.g;
|
|
}
|
|
|
|
@Override // com.iab.omid.library.unity3d.adsession.AdSession
|
|
public void finish() {
|
|
if (this.g) {
|
|
return;
|
|
}
|
|
this.d.clear();
|
|
removeAllFriendlyObstructions();
|
|
this.g = true;
|
|
getAdSessionStatePublisher().f();
|
|
c.c().b(this);
|
|
getAdSessionStatePublisher().b();
|
|
this.e = null;
|
|
this.k = null;
|
|
}
|
|
|
|
public boolean g() {
|
|
return this.g;
|
|
}
|
|
|
|
@Override // com.iab.omid.library.unity3d.adsession.AdSession
|
|
public String getAdSessionId() {
|
|
return this.h;
|
|
}
|
|
|
|
@Override // com.iab.omid.library.unity3d.adsession.AdSession
|
|
public AdSessionStatePublisher getAdSessionStatePublisher() {
|
|
return this.e;
|
|
}
|
|
|
|
public boolean h() {
|
|
return this.b.isNativeImpressionOwner();
|
|
}
|
|
|
|
public boolean i() {
|
|
return this.b.isNativeMediaEventsOwner();
|
|
}
|
|
|
|
public boolean j() {
|
|
return this.f;
|
|
}
|
|
|
|
public void k() {
|
|
a();
|
|
getAdSessionStatePublisher().g();
|
|
this.i = true;
|
|
}
|
|
|
|
public void l() {
|
|
b();
|
|
getAdSessionStatePublisher().h();
|
|
this.j = true;
|
|
}
|
|
|
|
@Override // com.iab.omid.library.unity3d.adsession.AdSession
|
|
public void registerAdView(View view) {
|
|
if (this.g) {
|
|
return;
|
|
}
|
|
g.a(view, "AdView is null");
|
|
if (c() == view) {
|
|
return;
|
|
}
|
|
d(view);
|
|
getAdSessionStatePublisher().a();
|
|
c(view);
|
|
}
|
|
|
|
@Override // com.iab.omid.library.unity3d.adsession.AdSession
|
|
public void removeAllFriendlyObstructions() {
|
|
if (this.g) {
|
|
return;
|
|
}
|
|
this.c.clear();
|
|
}
|
|
|
|
@Override // com.iab.omid.library.unity3d.adsession.AdSession
|
|
public void removeFriendlyObstruction(View view) {
|
|
if (this.g) {
|
|
return;
|
|
}
|
|
a(view);
|
|
e b = b(view);
|
|
if (b != null) {
|
|
this.c.remove(b);
|
|
}
|
|
}
|
|
|
|
@Override // com.iab.omid.library.unity3d.adsession.AdSession
|
|
public void setPossibleObstructionListener(PossibleObstructionListener possibleObstructionListener) {
|
|
this.k = possibleObstructionListener;
|
|
}
|
|
|
|
@Override // com.iab.omid.library.unity3d.adsession.AdSession
|
|
public void start() {
|
|
if (this.f) {
|
|
return;
|
|
}
|
|
this.f = true;
|
|
c.c().c(this);
|
|
this.e.a(h.c().b());
|
|
this.e.a(com.iab.omid.library.unity3d.internal.a.a().b());
|
|
this.e.a(this, this.a);
|
|
}
|
|
}
|