package com.applovin.impl; import android.os.SystemClock; import com.applovin.mediation.MaxAdFormat; import java.util.HashMap; import java.util.Map; /* loaded from: classes.dex */ public class xj { private final com.applovin.impl.sdk.j a; private final Map b = new HashMap(); private final Object c = new Object(); public static /* synthetic */ class a { static final /* synthetic */ int[] a; static { int[] iArr = new int[b.values().length]; a = iArr; try { iArr[b.AD_FORMAT.ordinal()] = 1; } catch (NoSuchFieldError unused) { } try { a[b.AD_UNIT_ID.ordinal()] = 2; } catch (NoSuchFieldError unused2) { } try { a[b.ALL.ordinal()] = 3; } catch (NoSuchFieldError unused3) { } } } public enum b { AD_FORMAT, AD_UNIT_ID, ALL } public xj(com.applovin.impl.sdk.j jVar) { this.a = jVar; } public static class c { private final yj a; private final long b; private final long c; /* JADX INFO: Access modifiers changed from: private */ public boolean d() { return SystemClock.elapsedRealtime() - this.c > this.b; } public long a() { return this.c; } public long b() { return this.b; } public yj c() { return this.a; } public String toString() { return "SignalCacheManager.SignalWrapper(signal=" + c() + ", expirationTimeMillis=" + b() + ", cacheTimestampMillis=" + a() + ")"; } public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof c)) { return false; } c cVar = (c) obj; if (!cVar.a((Object) this) || b() != cVar.b() || a() != cVar.a()) { return false; } yj c = c(); yj c2 = cVar.c(); return c != null ? c.equals(c2) : c2 == null; } public int hashCode() { long b = b(); long a = a(); yj c = c(); return ((((((int) (b ^ (b >>> 32))) + 59) * 59) + ((int) ((a >>> 32) ^ a))) * 59) + (c == null ? 43 : c.hashCode()); } private c(yj yjVar, long j) { this.a = yjVar; this.b = j; this.c = SystemClock.elapsedRealtime(); } public boolean a(Object obj) { return obj instanceof c; } public /* synthetic */ c(yj yjVar, long j, a aVar) { this(yjVar, j); } } public yj b(zj zjVar, String str, MaxAdFormat maxAdFormat) { String a2 = a(zjVar, str, maxAdFormat); synchronized (this.c) { try { c cVar = (c) this.b.get(a2); if (cVar == null) { return null; } if (cVar.d()) { this.b.remove(a2); return null; } this.a.J(); if (com.applovin.impl.sdk.n.a()) { this.a.J().a("SignalCacheManager", "Returning cached signal for: " + zjVar); } return cVar.a; } catch (Throwable th) { throw th; } } } private String a(zj zjVar, String str, MaxAdFormat maxAdFormat) { String c2 = zjVar.c(); int i = a.a[zjVar.t().ordinal()]; if (i == 1) { return c2 + "_" + maxAdFormat.getLabel(); } if (i != 2) { return c2; } return c2 + "_" + str; } public void a(yj yjVar, zj zjVar, String str, MaxAdFormat maxAdFormat) { if (yjVar == null) { return; } long u = zjVar.u(); if (u <= 0) { return; } this.a.J(); if (com.applovin.impl.sdk.n.a()) { this.a.J().a("SignalCacheManager", "Caching signal for: " + zjVar); } String a2 = a(zjVar, str, maxAdFormat); c cVar = new c(yjVar, u, null); synchronized (this.c) { this.b.put(a2, cVar); } } }