package com.appsflyer.internal; import X.AbstractC37955EvQ; import X.C37912Euj; import android.os.Build; import com.android.billingclient.api.Purchase; import com.appsflyer.AFLogger; import com.appsflyer.AppsFlyerProperties; import com.appsflyer.internal.c; import com.bytedance.covode.number.Covode; import java.io.IOException; import java.lang.ref.WeakReference; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.concurrent.ExecutorService; import org.json.JSONObject; public final class av implements Runnable { public bh AFInAppEventParameterName; public AbstractC37955EvQ AFInAppEventType; public final bd AFKeystoreWrapper; public final bg AFVersionDeclaration; public final ba valueOf; public final ExecutorService values; static { Covode.recordClassIndex(2668); } public av(bd bdVar, bh bhVar, ba baVar, ExecutorService executorService, bg bgVar) { this.AFKeystoreWrapper = bdVar; this.AFInAppEventParameterName = bhVar; this.valueOf = baVar; this.values = executorService; this.AFVersionDeclaration = bgVar; } public static /* synthetic */ void AFKeystoreWrapper(av avVar, final boolean z, List list) { boolean z2; String str; final ad valueOf2 = avVar.AFKeystoreWrapper.valueOf(); Map<String, String> map = null; if (valueOf2 != null) { z2 = valueOf2.init; if (valueOf2.values != null) { map = valueOf2.values.apply(list); } } else { z2 = false; } ac acVar = new ac(z2, z, list, map); bg bgVar = avVar.AFVersionDeclaration; HashMap hashMap = new HashMap(); hashMap.put("app_id", bgVar.valueOf.valueOf.getPackageName()); String string = AppsFlyerProperties.getInstance().getString("AppUserId"); if (string != null) { hashMap.put("cuid", string); } o oVar = bgVar.valueOf; hashMap.put("app_version_name", ac.values(oVar.valueOf, oVar.valueOf.getPackageName())); HashMap hashMap2 = new HashMap(); c.d.b AFInAppEventType2 = ad.AFInAppEventType(bgVar.valueOf.valueOf, new HashMap()); if (!(AFInAppEventType2 == null || (str = AFInAppEventType2.values) == null)) { hashMap2.put("advertising_id", str); } hashMap2.put("appsflyer_id", ak.AFInAppEventParameterName(new WeakReference(bgVar.valueOf.valueOf))); hashMap2.put("os_version", new StringBuilder().append(Build.VERSION.SDK_INT).toString()); hashMap2.put("sdk_version", ai.valueOf); hashMap.put("device_data", hashMap2); hashMap.put("is_cached", Boolean.valueOf(acVar.AFInAppEventType())); hashMap.put("environment", acVar.AFKeystoreWrapper() ? "SANDBOX" : "PRODUCTION"); hashMap.put("additional_parameters", acVar.AFInAppEventParameterName); ArrayList arrayList = new ArrayList(); for (Purchase purchase : acVar.AFInAppEventType) { HashMap hashMap3 = new HashMap(); hashMap3.put("token", purchase.LIZJ()); hashMap3.put("subscription_id", purchase.LIZIZ()); arrayList.add(hashMap3); } hashMap.put("subscriptions", arrayList); v vVar = new v("https://ars.appsflyer.com/api/v1/android/validate_subscription", new JSONObject(hashMap).toString().getBytes(), "POST", Collections.emptyMap()); y yVar = bgVar.AFInAppEventParameterName; bi biVar = new bi(vVar, yVar.AFKeystoreWrapper, yVar.AFInAppEventType, new bl()); AnonymousClass1 r2 = new bk<String>() { /* class com.appsflyer.internal.av.AnonymousClass1 */ static { Covode.recordClassIndex(2669); } @Override // com.appsflyer.internal.bk public final void valueOf(bm<String> bmVar) { if (bmVar.valueOf()) { if (z) { av.this.valueOf.AFKeystoreWrapper("ars_history_sent"); } ad adVar = valueOf2; if (adVar != null && adVar.AFInAppEventType != null) { valueOf2.AFInAppEventType.accept(bmVar.AFKeystoreWrapper); return; } return; } ad adVar2 = valueOf2; if (adVar2 != null && adVar2.valueOf != null) { valueOf2.valueOf.accept(bmVar.AFKeystoreWrapper); } } @Override // com.appsflyer.internal.bk public final void valueOf(Throwable th) { ad adVar = valueOf2; if (!(adVar == null || adVar.valueOf == null)) { valueOf2.valueOf.accept(th.getMessage()); } AFLogger.valueOf(th); } }; if (!biVar.AFInAppEventParameterName.getAndSet(true)) { biVar.values.submit(new Runnable(r2) { /* class com.appsflyer.internal.bi.AnonymousClass1 */ public /* synthetic */ bk AFInAppEventType; static { Covode.recordClassIndex(2686); } { this.AFInAppEventType = r2; } public final void run() { try { bm<String> valueOf = bi.this.AFInAppEventType.valueOf(bi.this.valueOf); this.AFInAppEventType.valueOf(new bm(bi.this.AFKeystoreWrapper.AFInAppEventType(valueOf.AFKeystoreWrapper), valueOf.AFInAppEventParameterName, valueOf.valueOf())); } catch (IOException e) { this.AFInAppEventType.valueOf(e); } } }); return; } throw new IllegalStateException("Http call is already executed"); } public final void run() { try { if (this.AFInAppEventType == null) { bh bhVar = this.AFInAppEventParameterName; at atVar = new at(this); C37912Euj LIZ = AbstractC37955EvQ.LIZ(bhVar.values); LIZ.LIZIZ = atVar; LIZ.LIZ = true; AbstractC37955EvQ LIZ2 = LIZ.LIZ(); this.AFInAppEventType = LIZ2; LIZ2.LIZ(new aw(this)); } } catch (Throwable th) { if ((th instanceof NoSuchMethodError) || (th instanceof NoClassDefFoundError)) { AFLogger.AFLogger$LogLevel("It seems your app uses different Play Billing library version than the SDK. Please use v.3.0.3"); } AFLogger.values("Failed to setup Play billing", th); } } }