package com.vungle.warren; import android.annotation.SuppressLint; import android.app.UiModeManager; import android.content.ContentResolver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.content.pm.PackageManager; import android.media.AudioManager; import android.net.ConnectivityManager; import android.net.NetworkInfo; import android.os.Build; import android.os.Environment; import android.os.PowerManager; import android.provider.Settings; import android.security.NetworkSecurityPolicy; import android.telephony.TelephonyManager; import android.text.TextUtils; import android.util.DisplayMetrics; import android.view.WindowManager; import android.webkit.URLUtil; import androidx.annotation.Keep; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.annotation.VisibleForTesting; import androidx.core.content.PermissionChecker; import androidx.core.util.Consumer; import com.applovin.sdk.AppLovinEventTypes; import com.facebook.appevents.codeless.internal.Constants; import com.google.android.gms.ads.identifier.AdvertisingIdClient; import com.google.android.gms.appset.AppSet; import com.google.android.gms.appset.AppSetIdInfo; import com.google.android.gms.common.GoogleApiAvailabilityLight; import com.google.android.gms.common.GooglePlayServicesNotAvailableException; import com.google.android.gms.tasks.OnSuccessListener; import com.google.gson.JsonArray; import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.intsig.scanner.ScannerFormat; import com.microsoft.services.msa.OAuth; import com.umeng.analytics.pro.ak; import com.vungle.warren.PrivacyManager; import com.vungle.warren.error.VungleException; import com.vungle.warren.model.AdvertisementDBAdapter; import com.vungle.warren.model.CacheBust; import com.vungle.warren.model.CacheBustDBAdapter; import com.vungle.warren.model.Cookie; import com.vungle.warren.model.JsonUtil; import com.vungle.warren.model.SessionData; import com.vungle.warren.model.VisionDataDBAdapter; import com.vungle.warren.network.APIFactory; import com.vungle.warren.network.Call; import com.vungle.warren.network.VungleApi; import com.vungle.warren.omsdk.OMInjector; import com.vungle.warren.persistence.CacheManager; import com.vungle.warren.persistence.DatabaseHelper; import com.vungle.warren.persistence.Repository; import com.vungle.warren.session.SessionAttribute; import com.vungle.warren.session.SessionEvent; import com.vungle.warren.utility.TimeoutProvider; import com.vungle.warren.utility.platform.Platform; import java.io.File; import java.io.IOException; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.net.MalformedURLException; import java.net.URL; import java.util.Collection; import java.util.HashMap; import java.util.HashSet; import java.util.Locale; import java.util.Map; import java.util.Set; import java.util.TimeZone; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.TimeUnit; import okhttp3.HttpUrl; import okhttp3.Interceptor; import okhttp3.MediaType; import okhttp3.OkHttpClient; import okhttp3.Protocol; import okhttp3.Request; import okhttp3.RequestBody; import okhttp3.Response; import okhttp3.ResponseBody; import okio.Buffer; import okio.BufferedSink; import okio.GzipSink; import okio.Okio; public class VungleApiClient { private static final String AMAZON_ADVERTISING_ID = "amazon_advertising_id"; public static final String ANDROID_ID = "android_id"; private static String BASE_URL = "https://ads.api.vungle.com/"; public static final String GAID = "gaid"; private static final String ID = "id"; public static final String IFA = "ifa"; static final String MANUFACTURER_AMAZON = "Amazon"; private static final String TAG = "com.vungle.warren.VungleApiClient"; protected static WrapperFramework WRAPPER_FRAMEWORK_SELECTED; private static String headerUa; private static Set<Interceptor> logInterceptors = new HashSet(); private static Set<Interceptor> networkInterceptors = new HashSet(); private VungleApi api; private JsonObject appBody; private String appSetId = ""; private JsonObject baseDeviceInfo; private String biLoggingEndpoint; private String cacheBustEndpoint; private CacheManager cacheManager; private OkHttpClient client; private Context context; private boolean defaultIdFallbackDisabled; private boolean enableOm; private VungleApi gzipApi; private Boolean isGooglePlayServicesAvailable; private String logEndpoint; private String newEndpoint; private final OMInjector omInjector; private final Platform platform; private String reportAdEndpoint; private Repository repository; private String requestAdEndpoint; private Map<String, Long> retryAfterDataMap = new ConcurrentHashMap(); private String riEndpoint; private VungleApi timeoutApi; private TimeoutProvider timeoutProvider; private String uaString = System.getProperty("http.agent"); private boolean willPlayAdEnabled; private String willPlayAdEndpoint; private int willPlayAdTimeout; public static class ClearTextTrafficException extends IOException { ClearTextTrafficException(String str) { super(str); } } @Retention(RetentionPolicy.SOURCE) public @interface ConnectionTypeDetail { public static final String CDMA_1XRTT = "cdma_1xrtt"; public static final String CDMA_EVDO_0 = "cdma_evdo_0"; public static final String CDMA_EVDO_A = "cdma_evdo_a"; public static final String CDMA_EVDO_B = "cdma_evdo_b"; public static final String EDGE = "edge"; public static final String GPRS = "gprs"; public static final String HRPD = "hrpd"; public static final String HSDPA = "hsdpa"; public static final String HSUPA = "hsupa"; public static final String LTE = "LTE"; public static final String UNKNOWN = "unknown"; public static final String WCDMA = "wcdma"; } static class GzipRequestInterceptor implements Interceptor { private static final String CONTENT_ENCODING = "Content-Encoding"; private static final String GZIP = "gzip"; GzipRequestInterceptor() { } private RequestBody gzip(final RequestBody requestBody) throws IOException { final Buffer buffer = new Buffer(); BufferedSink buffer2 = Okio.buffer(new GzipSink(buffer)); requestBody.writeTo(buffer2); buffer2.close(); return new RequestBody() { /* class com.vungle.warren.VungleApiClient.GzipRequestInterceptor.AnonymousClass1 */ @Override // okhttp3.RequestBody public long contentLength() { return buffer.size(); } @Override // okhttp3.RequestBody public MediaType contentType() { return requestBody.contentType(); } @Override // okhttp3.RequestBody public void writeTo(@NonNull BufferedSink bufferedSink) throws IOException { bufferedSink.write(buffer.snapshot()); } }; } @Override // okhttp3.Interceptor @NonNull public Response intercept(@NonNull Interceptor.Chain chain) throws IOException { Request S = chain.S(); return (S.a() == null || S.d("Content-Encoding") != null) ? chain.b(S) : chain.b(S.i().g("Content-Encoding", "gzip").i(S.h(), gzip(S.a())).b()); } } @Keep public enum WrapperFramework { admob, air, cocos2dx, corona, dfp, heyzap, marmalade, mopub, unity, fyber, ironsource, upsight, appodeal, aerserv, adtoapp, tapdaq, vunglehbs, max, none } static { StringBuilder sb2 = new StringBuilder(); sb2.append(MANUFACTURER_AMAZON.equals(Build.MANUFACTURER) ? "VungleAmazon/" : "VungleDroid/"); sb2.append(BuildConfig.VERSION_NAME); headerUa = sb2.toString(); } VungleApiClient(@NonNull Context context2, @NonNull CacheManager cacheManager2, @NonNull Repository repository2, @NonNull OMInjector oMInjector, @NonNull Platform platform2) { this.cacheManager = cacheManager2; this.context = context2.getApplicationContext(); this.repository = repository2; this.omInjector = oMInjector; this.platform = platform2; OkHttpClient.Builder a10 = new OkHttpClient.Builder().a(new Interceptor() { /* class com.vungle.warren.VungleApiClient.AnonymousClass1 */ @Override // okhttp3.Interceptor public Response intercept(Interceptor.Chain chain) throws IOException { int p10; Request S = chain.S(); String d10 = S.l().d(); Long l10 = (Long) VungleApiClient.this.retryAfterDataMap.get(d10); if (l10 != null) { long seconds = TimeUnit.MILLISECONDS.toSeconds(l10.longValue() - System.currentTimeMillis()); if (seconds > 0) { return new Response.Builder().r(S).a("Retry-After", String.valueOf(seconds)).g(500).p(Protocol.HTTP_1_1).m("Server is busy").b(ResponseBody.create(MediaType.f("application/json; charset=utf-8"), "{\"Error\":\"Retry-After\"}")).c(); } VungleApiClient.this.retryAfterDataMap.remove(d10); } Response b10 = chain.b(S); if (b10 != null && ((p10 = b10.p()) == 429 || p10 == 500 || p10 == 502 || p10 == 503)) { String a10 = b10.x().a("Retry-After"); if (!TextUtils.isEmpty(a10)) { try { long parseLong = Long.parseLong(a10); if (parseLong > 0) { VungleApiClient.this.retryAfterDataMap.put(d10, Long.valueOf((parseLong * 1000) + System.currentTimeMillis())); } } catch (NumberFormatException unused) { String unused2 = VungleApiClient.TAG; } } } return b10; } }); this.client = a10.c(); OkHttpClient c9 = a10.a(new GzipRequestInterceptor()).c(); APIFactory aPIFactory = new APIFactory(this.client, BASE_URL); Vungle vungle = Vungle._instance; this.api = aPIFactory.createAPI(vungle.appID); this.gzipApi = new APIFactory(c9, BASE_URL).createAPI(vungle.appID); this.timeoutProvider = (TimeoutProvider) ServiceLocator.getInstance(context2).getService(TimeoutProvider.class); } private String getAppSetId() { if (TextUtils.isEmpty(this.appSetId)) { Cookie cookie = (Cookie) this.repository.load(Cookie.APP_SET_ID_COOKIE, Cookie.class).get(this.timeoutProvider.getTimeout(), TimeUnit.MILLISECONDS); this.appSetId = cookie != null ? cookie.getString(Cookie.APP_SET_ID) : null; } return this.appSetId; } private String getConnectionTypeDetail(int i10) { switch (i10) { case 1: return ConnectionTypeDetail.GPRS; case 2: return ConnectionTypeDetail.EDGE; case 3: case 10: case 11: default: return "unknown"; case 4: return ConnectionTypeDetail.WCDMA; case 5: return ConnectionTypeDetail.CDMA_EVDO_0; case 6: return ConnectionTypeDetail.CDMA_EVDO_A; case 7: return ConnectionTypeDetail.CDMA_1XRTT; case 8: return ConnectionTypeDetail.HSDPA; case 9: return ConnectionTypeDetail.HSUPA; case 12: return ConnectionTypeDetail.CDMA_EVDO_B; case 13: return ConnectionTypeDetail.LTE; case 14: return ConnectionTypeDetail.HRPD; } } @SuppressLint({"HardwareIds", "NewApi"}) private JsonObject getDeviceBody() throws IllegalStateException { return getDeviceBody(false); } /* JADX WARNING: Removed duplicated region for block: B:101:0x01a2 */ /* JADX WARNING: Removed duplicated region for block: B:107:0x01bf */ /* JADX WARNING: Removed duplicated region for block: B:141:0x0278 */ /* JADX WARNING: Removed duplicated region for block: B:153:0x02c8 */ /* JADX WARNING: Removed duplicated region for block: B:154:0x02d9 */ /* JADX WARNING: Removed duplicated region for block: B:166:0x033f */ /* JADX WARNING: Removed duplicated region for block: B:169:0x0354 A[SYNTHETIC, Splitter:B:169:0x0354] */ /* JADX WARNING: Removed duplicated region for block: B:173:0x036d A[Catch:{ SettingNotFoundException -> 0x037d }] */ /* JADX WARNING: Removed duplicated region for block: B:180:0x0395 */ /* JADX WARNING: Removed duplicated region for block: B:183:0x03d0 */ /* JADX WARNING: Removed duplicated region for block: B:184:0x03d3 */ /* JADX WARNING: Removed duplicated region for block: B:45:0x0094 */ /* JADX WARNING: Removed duplicated region for block: B:69:0x0103 */ /* JADX WARNING: Removed duplicated region for block: B:70:0x0105 */ /* JADX WARNING: Removed duplicated region for block: B:73:0x012a */ /* JADX WARNING: Removed duplicated region for block: B:76:0x0135 */ /* JADX WARNING: Removed duplicated region for block: B:79:0x0144 */ /* JADX WARNING: Removed duplicated region for block: B:98:0x018d */ @SuppressLint({"HardwareIds", "NewApi"}) private synchronized JsonObject getDeviceBody(boolean z10) throws IllegalStateException { JsonObject s10; boolean z11; String str; Context context2; String str2; AudioManager audioManager; int i10; boolean z12; NetworkInfo activeNetworkInfo; String str3; boolean z13; NoClassDefFoundError e10; GooglePlayServicesNotAvailableException e11; s10 = this.baseDeviceInfo.a(); JsonObject jsonObject = new JsonObject(); Intent intent = null; int i11 = 0; try { str3 = Build.MANUFACTURER; if (MANUFACTURER_AMAZON.equals(str3)) { try { ContentResolver contentResolver = this.context.getContentResolver(); z11 = Settings.Secure.getInt(contentResolver, "limit_ad_tracking") == 1; try { str = Settings.Secure.getString(contentResolver, "advertising_id"); } catch (Settings.SettingNotFoundException unused) { } catch (Exception unused2) { z13 = z11; str3 = null; } } catch (Settings.SettingNotFoundException unused3) { z11 = true; str = null; if (PrivacyManager.getInstance().shouldSendAdIds()) { } s10.z(IFA); jsonObject.z(ANDROID_ID); jsonObject.z(GAID); jsonObject.z(AMAZON_ADVERTISING_ID); s10.q("lmt", Integer.valueOf(z11 ? 1 : 0)); jsonObject.p("is_google_play_services_available", Boolean.valueOf(Boolean.TRUE.equals(isGooglePlayServicesAvailable()))); if (!TextUtils.isEmpty(getAppSetId())) { } context2 = this.context; if (context2 != null) { } if (intent != null) { } jsonObject.r("battery_state", str2); PowerManager powerManager = (PowerManager) this.context.getSystemService("power"); jsonObject.q("battery_saver_enabled", Integer.valueOf((powerManager != null || !powerManager.isPowerSaveMode()) ? 0 : 1)); if (PermissionChecker.checkCallingOrSelfPermission(this.context, "android.permission.ACCESS_NETWORK_STATE") == 0) { } jsonObject.r(OAuth.LOCALE, Locale.getDefault().toString()); jsonObject.r(ak.N, Locale.getDefault().getLanguage()); jsonObject.r("time_zone", TimeZone.getDefault().getID()); audioManager = (AudioManager) this.context.getSystemService("audio"); if (audioManager != null) { } File cache = this.cacheManager.getCache(); cache.getPath(); jsonObject.q("storage_bytes_available", Long.valueOf(this.cacheManager.getBytesAvailable())); jsonObject.p("is_tv", Boolean.valueOf(MANUFACTURER_AMAZON.equals(Build.MANUFACTURER) ? this.context.getApplicationContext().getPackageManager().hasSystemFeature("amazon.hardware.fire_tv") : Build.VERSION.SDK_INT < 23 ? this.context.getApplicationContext().getPackageManager().hasSystemFeature("com.google.android.tv") || !this.context.getApplicationContext().getPackageManager().hasSystemFeature("android.hardware.touchscreen") : ((UiModeManager) this.context.getSystemService("uimode")).getCurrentModeType() == 4)); i10 = Build.VERSION.SDK_INT; jsonObject.q("os_api_level", Integer.valueOf(i10)); jsonObject.q("app_target_sdk_version", Integer.valueOf(this.context.getApplicationInfo().targetSdkVersion)); if (i10 >= 24) { } if (i10 >= 26) { } z12 = false; jsonObject.p("is_sideload_enabled", Boolean.valueOf(z12)); if (Environment.getExternalStorageState().equals("mounted")) { } jsonObject.q("sd_card_available", Integer.valueOf(i11)); jsonObject.r("os_name", Build.FINGERPRINT); jsonObject.r("vduid", ""); s10.r("ua", this.uaString); JsonObject jsonObject2 = new JsonObject(); JsonObject jsonObject3 = new JsonObject(); jsonObject2.o("vungle", jsonObject3); s10.o("ext", jsonObject2); jsonObject3.o(MANUFACTURER_AMAZON.equals(Build.MANUFACTURER) ? "amazon" : Constants.PLATFORM, jsonObject); return s10; } if (PrivacyManager.getInstance().shouldSendAdIds()) { if (str != null) { jsonObject.r(MANUFACTURER_AMAZON.equals(Build.MANUFACTURER) ? AMAZON_ADVERTISING_ID : GAID, str); s10.r(IFA, str); } else { String string = Settings.Secure.getString(this.context.getContentResolver(), ANDROID_ID); s10.r(IFA, this.defaultIdFallbackDisabled ? "" : !TextUtils.isEmpty(string) ? string : ""); if (!TextUtils.isEmpty(string) && !this.defaultIdFallbackDisabled) { jsonObject.r(ANDROID_ID, string); } } } if (!PrivacyManager.getInstance().shouldSendAdIds() || z10) { s10.z(IFA); jsonObject.z(ANDROID_ID); jsonObject.z(GAID); jsonObject.z(AMAZON_ADVERTISING_ID); } s10.q("lmt", Integer.valueOf(z11 ? 1 : 0)); jsonObject.p("is_google_play_services_available", Boolean.valueOf(Boolean.TRUE.equals(isGooglePlayServicesAvailable()))); if (!TextUtils.isEmpty(getAppSetId())) { jsonObject.r("app_set_id", this.appSetId); } context2 = this.context; if (context2 != null) { intent = context2.registerReceiver(null, new IntentFilter("android.intent.action.BATTERY_CHANGED")); } if (intent != null) { int intExtra = intent.getIntExtra(AppLovinEventTypes.USER_COMPLETED_LEVEL, -1); int intExtra2 = intent.getIntExtra(ScannerFormat.TAG_SCALE, -1); if (intExtra > 0 && intExtra2 > 0) { jsonObject.q("battery_level", Float.valueOf(((float) intExtra) / ((float) intExtra2))); } int intExtra3 = intent.getIntExtra("status", -1); if (intExtra3 == -1) { str2 = "UNKNOWN"; } else if (intExtra3 == 2 || intExtra3 == 5) { int intExtra4 = intent.getIntExtra("plugged", -1); str2 = intExtra4 != 1 ? intExtra4 != 2 ? intExtra4 != 4 ? "BATTERY_PLUGGED_OTHERS" : "BATTERY_PLUGGED_WIRELESS" : "BATTERY_PLUGGED_USB" : "BATTERY_PLUGGED_AC"; } else { str2 = "NOT_CHARGING"; } } else { str2 = "UNKNOWN"; } jsonObject.r("battery_state", str2); PowerManager powerManager2 = (PowerManager) this.context.getSystemService("power"); jsonObject.q("battery_saver_enabled", Integer.valueOf((powerManager2 != null || !powerManager2.isPowerSaveMode()) ? 0 : 1)); if (PermissionChecker.checkCallingOrSelfPermission(this.context, "android.permission.ACCESS_NETWORK_STATE") == 0) { String str4 = "NONE"; String str5 = "unknown"; ConnectivityManager connectivityManager = (ConnectivityManager) this.context.getSystemService("connectivity"); if (!(connectivityManager == null || (activeNetworkInfo = connectivityManager.getActiveNetworkInfo()) == null)) { int type = activeNetworkInfo.getType(); if (type != 0) { str4 = (type == 1 || type == 6) ? "WIFI" : type != 7 ? type != 9 ? "UNKNOWN" : "ETHERNET" : "BLUETOOTH"; } else { str4 = "MOBILE"; str5 = getConnectionTypeDetail(activeNetworkInfo.getSubtype()); } } jsonObject.r("connection_type", str4); jsonObject.r("connection_type_detail", str5); if (Build.VERSION.SDK_INT >= 24) { if (connectivityManager.isActiveNetworkMetered()) { int restrictBackgroundStatus = connectivityManager.getRestrictBackgroundStatus(); jsonObject.r("data_saver_status", restrictBackgroundStatus != 1 ? restrictBackgroundStatus != 2 ? restrictBackgroundStatus != 3 ? "UNKNOWN" : "ENABLED" : "WHITELISTED" : "DISABLED"); jsonObject.q("network_metered", 1); } else { jsonObject.r("data_saver_status", "NOT_APPLICABLE"); jsonObject.q("network_metered", 0); } } } jsonObject.r(OAuth.LOCALE, Locale.getDefault().toString()); jsonObject.r(ak.N, Locale.getDefault().getLanguage()); jsonObject.r("time_zone", TimeZone.getDefault().getID()); audioManager = (AudioManager) this.context.getSystemService("audio"); if (audioManager != null) { int streamMaxVolume = audioManager.getStreamMaxVolume(3); int streamVolume = audioManager.getStreamVolume(3); jsonObject.q("volume_level", Float.valueOf(((float) streamVolume) / ((float) streamMaxVolume))); jsonObject.q("sound_enabled", Integer.valueOf(streamVolume > 0 ? 1 : 0)); } File cache2 = this.cacheManager.getCache(); cache2.getPath(); if (cache2.exists() && cache2.isDirectory()) { jsonObject.q("storage_bytes_available", Long.valueOf(this.cacheManager.getBytesAvailable())); } jsonObject.p("is_tv", Boolean.valueOf(MANUFACTURER_AMAZON.equals(Build.MANUFACTURER) ? this.context.getApplicationContext().getPackageManager().hasSystemFeature("amazon.hardware.fire_tv") : Build.VERSION.SDK_INT < 23 ? this.context.getApplicationContext().getPackageManager().hasSystemFeature("com.google.android.tv") || !this.context.getApplicationContext().getPackageManager().hasSystemFeature("android.hardware.touchscreen") : ((UiModeManager) this.context.getSystemService("uimode")).getCurrentModeType() == 4)); i10 = Build.VERSION.SDK_INT; jsonObject.q("os_api_level", Integer.valueOf(i10)); jsonObject.q("app_target_sdk_version", Integer.valueOf(this.context.getApplicationInfo().targetSdkVersion)); if (i10 >= 24) { jsonObject.q("app_min_sdk_version", Integer.valueOf(this.context.getApplicationInfo().minSdkVersion)); } if (i10 >= 26) { try { if (this.context.checkCallingOrSelfPermission("android.permission.REQUEST_INSTALL_PACKAGES") == 0) { z12 = this.context.getApplicationContext().getPackageManager().canRequestPackageInstalls(); jsonObject.p("is_sideload_enabled", Boolean.valueOf(z12)); if (Environment.getExternalStorageState().equals("mounted")) { i11 = 1; } jsonObject.q("sd_card_available", Integer.valueOf(i11)); jsonObject.r("os_name", Build.FINGERPRINT); jsonObject.r("vduid", ""); s10.r("ua", this.uaString); JsonObject jsonObject22 = new JsonObject(); JsonObject jsonObject32 = new JsonObject(); jsonObject22.o("vungle", jsonObject32); s10.o("ext", jsonObject22); jsonObject32.o(MANUFACTURER_AMAZON.equals(Build.MANUFACTURER) ? "amazon" : Constants.PLATFORM, jsonObject); } } catch (Settings.SettingNotFoundException unused4) { } } else if (Settings.Secure.getInt(this.context.getContentResolver(), "install_non_market_apps") == 1) { z12 = true; jsonObject.p("is_sideload_enabled", Boolean.valueOf(z12)); if (Environment.getExternalStorageState().equals("mounted")) { } jsonObject.q("sd_card_available", Integer.valueOf(i11)); jsonObject.r("os_name", Build.FINGERPRINT); jsonObject.r("vduid", ""); s10.r("ua", this.uaString); JsonObject jsonObject222 = new JsonObject(); JsonObject jsonObject322 = new JsonObject(); jsonObject222.o("vungle", jsonObject322); s10.o("ext", jsonObject222); jsonObject322.o(MANUFACTURER_AMAZON.equals(Build.MANUFACTURER) ? "amazon" : Constants.PLATFORM, jsonObject); } z12 = false; jsonObject.p("is_sideload_enabled", Boolean.valueOf(z12)); if (Environment.getExternalStorageState().equals("mounted")) { } jsonObject.q("sd_card_available", Integer.valueOf(i11)); jsonObject.r("os_name", Build.FINGERPRINT); jsonObject.r("vduid", ""); s10.r("ua", this.uaString); JsonObject jsonObject2222 = new JsonObject(); JsonObject jsonObject3222 = new JsonObject(); jsonObject2222.o("vungle", jsonObject3222); s10.o("ext", jsonObject2222); jsonObject3222.o(MANUFACTURER_AMAZON.equals(Build.MANUFACTURER) ? "amazon" : Constants.PLATFORM, jsonObject); } else { try { AdvertisingIdClient.Info advertisingIdInfo = AdvertisingIdClient.getAdvertisingIdInfo(this.context); if (advertisingIdInfo != null) { str3 = advertisingIdInfo.getId(); try { z13 = advertisingIdInfo.isLimitAdTrackingEnabled(); z11 = z13; str = str3; } catch (NoClassDefFoundError e12) { e10 = e12; } catch (GooglePlayServicesNotAvailableException e13) { e11 = e13; try { StringBuilder sb2 = new StringBuilder(); sb2.append("Play services Not available: "); sb2.append(e11.getLocalizedMessage()); str = str3; z11 = true; } catch (Exception unused5) { z13 = true; z11 = z13; str = str3; if (PrivacyManager.getInstance().shouldSendAdIds()) { } s10.z(IFA); jsonObject.z(ANDROID_ID); jsonObject.z(GAID); jsonObject.z(AMAZON_ADVERTISING_ID); s10.q("lmt", Integer.valueOf(z11 ? 1 : 0)); jsonObject.p("is_google_play_services_available", Boolean.valueOf(Boolean.TRUE.equals(isGooglePlayServicesAvailable()))); if (!TextUtils.isEmpty(getAppSetId())) { } context2 = this.context; if (context2 != null) { } if (intent != null) { } jsonObject.r("battery_state", str2); PowerManager powerManager22 = (PowerManager) this.context.getSystemService("power"); jsonObject.q("battery_saver_enabled", Integer.valueOf((powerManager22 != null || !powerManager22.isPowerSaveMode()) ? 0 : 1)); if (PermissionChecker.checkCallingOrSelfPermission(this.context, "android.permission.ACCESS_NETWORK_STATE") == 0) { } jsonObject.r(OAuth.LOCALE, Locale.getDefault().toString()); jsonObject.r(ak.N, Locale.getDefault().getLanguage()); jsonObject.r("time_zone", TimeZone.getDefault().getID()); audioManager = (AudioManager) this.context.getSystemService("audio"); if (audioManager != null) { } File cache22 = this.cacheManager.getCache(); cache22.getPath(); jsonObject.q("storage_bytes_available", Long.valueOf(this.cacheManager.getBytesAvailable())); jsonObject.p("is_tv", Boolean.valueOf(MANUFACTURER_AMAZON.equals(Build.MANUFACTURER) ? this.context.getApplicationContext().getPackageManager().hasSystemFeature("amazon.hardware.fire_tv") : Build.VERSION.SDK_INT < 23 ? this.context.getApplicationContext().getPackageManager().hasSystemFeature("com.google.android.tv") || !this.context.getApplicationContext().getPackageManager().hasSystemFeature("android.hardware.touchscreen") : ((UiModeManager) this.context.getSystemService("uimode")).getCurrentModeType() == 4)); i10 = Build.VERSION.SDK_INT; jsonObject.q("os_api_level", Integer.valueOf(i10)); jsonObject.q("app_target_sdk_version", Integer.valueOf(this.context.getApplicationInfo().targetSdkVersion)); if (i10 >= 24) { } if (i10 >= 26) { } z12 = false; jsonObject.p("is_sideload_enabled", Boolean.valueOf(z12)); if (Environment.getExternalStorageState().equals("mounted")) { } jsonObject.q("sd_card_available", Integer.valueOf(i11)); jsonObject.r("os_name", Build.FINGERPRINT); jsonObject.r("vduid", ""); s10.r("ua", this.uaString); JsonObject jsonObject22222 = new JsonObject(); JsonObject jsonObject32222 = new JsonObject(); jsonObject22222.o("vungle", jsonObject32222); s10.o("ext", jsonObject22222); jsonObject32222.o(MANUFACTURER_AMAZON.equals(Build.MANUFACTURER) ? "amazon" : Constants.PLATFORM, jsonObject); return s10; } if (PrivacyManager.getInstance().shouldSendAdIds()) { } s10.z(IFA); jsonObject.z(ANDROID_ID); jsonObject.z(GAID); jsonObject.z(AMAZON_ADVERTISING_ID); s10.q("lmt", Integer.valueOf(z11 ? 1 : 0)); jsonObject.p("is_google_play_services_available", Boolean.valueOf(Boolean.TRUE.equals(isGooglePlayServicesAvailable()))); if (!TextUtils.isEmpty(getAppSetId())) { } context2 = this.context; if (context2 != null) { } if (intent != null) { } jsonObject.r("battery_state", str2); PowerManager powerManager222 = (PowerManager) this.context.getSystemService("power"); jsonObject.q("battery_saver_enabled", Integer.valueOf((powerManager222 != null || !powerManager222.isPowerSaveMode()) ? 0 : 1)); if (PermissionChecker.checkCallingOrSelfPermission(this.context, "android.permission.ACCESS_NETWORK_STATE") == 0) { } jsonObject.r(OAuth.LOCALE, Locale.getDefault().toString()); jsonObject.r(ak.N, Locale.getDefault().getLanguage()); jsonObject.r("time_zone", TimeZone.getDefault().getID()); audioManager = (AudioManager) this.context.getSystemService("audio"); if (audioManager != null) { } File cache222 = this.cacheManager.getCache(); cache222.getPath(); jsonObject.q("storage_bytes_available", Long.valueOf(this.cacheManager.getBytesAvailable())); jsonObject.p("is_tv", Boolean.valueOf(MANUFACTURER_AMAZON.equals(Build.MANUFACTURER) ? this.context.getApplicationContext().getPackageManager().hasSystemFeature("amazon.hardware.fire_tv") : Build.VERSION.SDK_INT < 23 ? this.context.getApplicationContext().getPackageManager().hasSystemFeature("com.google.android.tv") || !this.context.getApplicationContext().getPackageManager().hasSystemFeature("android.hardware.touchscreen") : ((UiModeManager) this.context.getSystemService("uimode")).getCurrentModeType() == 4)); i10 = Build.VERSION.SDK_INT; jsonObject.q("os_api_level", Integer.valueOf(i10)); jsonObject.q("app_target_sdk_version", Integer.valueOf(this.context.getApplicationInfo().targetSdkVersion)); if (i10 >= 24) { } if (i10 >= 26) { } z12 = false; jsonObject.p("is_sideload_enabled", Boolean.valueOf(z12)); if (Environment.getExternalStorageState().equals("mounted")) { } jsonObject.q("sd_card_available", Integer.valueOf(i11)); jsonObject.r("os_name", Build.FINGERPRINT); jsonObject.r("vduid", ""); s10.r("ua", this.uaString); JsonObject jsonObject222222 = new JsonObject(); JsonObject jsonObject322222 = new JsonObject(); jsonObject222222.o("vungle", jsonObject322222); s10.o("ext", jsonObject222222); jsonObject322222.o(MANUFACTURER_AMAZON.equals(Build.MANUFACTURER) ? "amazon" : Constants.PLATFORM, jsonObject); return s10; } if (PrivacyManager.getInstance().shouldSendAdIds()) { } s10.z(IFA); jsonObject.z(ANDROID_ID); jsonObject.z(GAID); jsonObject.z(AMAZON_ADVERTISING_ID); s10.q("lmt", Integer.valueOf(z11 ? 1 : 0)); jsonObject.p("is_google_play_services_available", Boolean.valueOf(Boolean.TRUE.equals(isGooglePlayServicesAvailable()))); if (!TextUtils.isEmpty(getAppSetId())) { } context2 = this.context; if (context2 != null) { } if (intent != null) { } jsonObject.r("battery_state", str2); PowerManager powerManager2222 = (PowerManager) this.context.getSystemService("power"); jsonObject.q("battery_saver_enabled", Integer.valueOf((powerManager2222 != null || !powerManager2222.isPowerSaveMode()) ? 0 : 1)); if (PermissionChecker.checkCallingOrSelfPermission(this.context, "android.permission.ACCESS_NETWORK_STATE") == 0) { } jsonObject.r(OAuth.LOCALE, Locale.getDefault().toString()); jsonObject.r(ak.N, Locale.getDefault().getLanguage()); jsonObject.r("time_zone", TimeZone.getDefault().getID()); audioManager = (AudioManager) this.context.getSystemService("audio"); if (audioManager != null) { } File cache2222 = this.cacheManager.getCache(); cache2222.getPath(); jsonObject.q("storage_bytes_available", Long.valueOf(this.cacheManager.getBytesAvailable())); jsonObject.p("is_tv", Boolean.valueOf(MANUFACTURER_AMAZON.equals(Build.MANUFACTURER) ? this.context.getApplicationContext().getPackageManager().hasSystemFeature("amazon.hardware.fire_tv") : Build.VERSION.SDK_INT < 23 ? this.context.getApplicationContext().getPackageManager().hasSystemFeature("com.google.android.tv") || !this.context.getApplicationContext().getPackageManager().hasSystemFeature("android.hardware.touchscreen") : ((UiModeManager) this.context.getSystemService("uimode")).getCurrentModeType() == 4)); i10 = Build.VERSION.SDK_INT; jsonObject.q("os_api_level", Integer.valueOf(i10)); jsonObject.q("app_target_sdk_version", Integer.valueOf(this.context.getApplicationInfo().targetSdkVersion)); if (i10 >= 24) { } if (i10 >= 26) { } z12 = false; jsonObject.p("is_sideload_enabled", Boolean.valueOf(z12)); if (Environment.getExternalStorageState().equals("mounted")) { } jsonObject.q("sd_card_available", Integer.valueOf(i11)); jsonObject.r("os_name", Build.FINGERPRINT); jsonObject.r("vduid", ""); s10.r("ua", this.uaString); JsonObject jsonObject2222222 = new JsonObject(); JsonObject jsonObject3222222 = new JsonObject(); jsonObject2222222.o("vungle", jsonObject3222222); s10.o("ext", jsonObject2222222); jsonObject3222222.o(MANUFACTURER_AMAZON.equals(Build.MANUFACTURER) ? "amazon" : Constants.PLATFORM, jsonObject); } else { str = null; z11 = true; if (PrivacyManager.getInstance().shouldSendAdIds()) { } s10.z(IFA); jsonObject.z(ANDROID_ID); jsonObject.z(GAID); jsonObject.z(AMAZON_ADVERTISING_ID); s10.q("lmt", Integer.valueOf(z11 ? 1 : 0)); jsonObject.p("is_google_play_services_available", Boolean.valueOf(Boolean.TRUE.equals(isGooglePlayServicesAvailable()))); if (!TextUtils.isEmpty(getAppSetId())) { } context2 = this.context; if (context2 != null) { } if (intent != null) { } jsonObject.r("battery_state", str2); PowerManager powerManager22222 = (PowerManager) this.context.getSystemService("power"); jsonObject.q("battery_saver_enabled", Integer.valueOf((powerManager22222 != null || !powerManager22222.isPowerSaveMode()) ? 0 : 1)); if (PermissionChecker.checkCallingOrSelfPermission(this.context, "android.permission.ACCESS_NETWORK_STATE") == 0) { } jsonObject.r(OAuth.LOCALE, Locale.getDefault().toString()); jsonObject.r(ak.N, Locale.getDefault().getLanguage()); jsonObject.r("time_zone", TimeZone.getDefault().getID()); audioManager = (AudioManager) this.context.getSystemService("audio"); if (audioManager != null) { } File cache22222 = this.cacheManager.getCache(); cache22222.getPath(); jsonObject.q("storage_bytes_available", Long.valueOf(this.cacheManager.getBytesAvailable())); jsonObject.p("is_tv", Boolean.valueOf(MANUFACTURER_AMAZON.equals(Build.MANUFACTURER) ? this.context.getApplicationContext().getPackageManager().hasSystemFeature("amazon.hardware.fire_tv") : Build.VERSION.SDK_INT < 23 ? this.context.getApplicationContext().getPackageManager().hasSystemFeature("com.google.android.tv") || !this.context.getApplicationContext().getPackageManager().hasSystemFeature("android.hardware.touchscreen") : ((UiModeManager) this.context.getSystemService("uimode")).getCurrentModeType() == 4)); i10 = Build.VERSION.SDK_INT; jsonObject.q("os_api_level", Integer.valueOf(i10)); jsonObject.q("app_target_sdk_version", Integer.valueOf(this.context.getApplicationInfo().targetSdkVersion)); if (i10 >= 24) { } if (i10 >= 26) { } z12 = false; jsonObject.p("is_sideload_enabled", Boolean.valueOf(z12)); if (Environment.getExternalStorageState().equals("mounted")) { } jsonObject.q("sd_card_available", Integer.valueOf(i11)); jsonObject.r("os_name", Build.FINGERPRINT); jsonObject.r("vduid", ""); s10.r("ua", this.uaString); JsonObject jsonObject22222222 = new JsonObject(); JsonObject jsonObject32222222 = new JsonObject(); jsonObject22222222.o("vungle", jsonObject32222222); s10.o("ext", jsonObject22222222); jsonObject32222222.o(MANUFACTURER_AMAZON.equals(Build.MANUFACTURER) ? "amazon" : Constants.PLATFORM, jsonObject); } } catch (NoClassDefFoundError e14) { e10 = e14; StringBuilder sb3 = new StringBuilder(); sb3.append("Play services Not available: "); sb3.append(e10.getLocalizedMessage()); str = Settings.Secure.getString(this.context.getContentResolver(), "advertising_id"); z11 = true; if (PrivacyManager.getInstance().shouldSendAdIds()) { } s10.z(IFA); jsonObject.z(ANDROID_ID); jsonObject.z(GAID); jsonObject.z(AMAZON_ADVERTISING_ID); s10.q("lmt", Integer.valueOf(z11 ? 1 : 0)); jsonObject.p("is_google_play_services_available", Boolean.valueOf(Boolean.TRUE.equals(isGooglePlayServicesAvailable()))); if (!TextUtils.isEmpty(getAppSetId())) { } context2 = this.context; if (context2 != null) { } if (intent != null) { } jsonObject.r("battery_state", str2); PowerManager powerManager222222 = (PowerManager) this.context.getSystemService("power"); jsonObject.q("battery_saver_enabled", Integer.valueOf((powerManager222222 != null || !powerManager222222.isPowerSaveMode()) ? 0 : 1)); if (PermissionChecker.checkCallingOrSelfPermission(this.context, "android.permission.ACCESS_NETWORK_STATE") == 0) { } jsonObject.r(OAuth.LOCALE, Locale.getDefault().toString()); jsonObject.r(ak.N, Locale.getDefault().getLanguage()); jsonObject.r("time_zone", TimeZone.getDefault().getID()); audioManager = (AudioManager) this.context.getSystemService("audio"); if (audioManager != null) { } File cache222222 = this.cacheManager.getCache(); cache222222.getPath(); jsonObject.q("storage_bytes_available", Long.valueOf(this.cacheManager.getBytesAvailable())); jsonObject.p("is_tv", Boolean.valueOf(MANUFACTURER_AMAZON.equals(Build.MANUFACTURER) ? this.context.getApplicationContext().getPackageManager().hasSystemFeature("amazon.hardware.fire_tv") : Build.VERSION.SDK_INT < 23 ? this.context.getApplicationContext().getPackageManager().hasSystemFeature("com.google.android.tv") || !this.context.getApplicationContext().getPackageManager().hasSystemFeature("android.hardware.touchscreen") : ((UiModeManager) this.context.getSystemService("uimode")).getCurrentModeType() == 4)); i10 = Build.VERSION.SDK_INT; jsonObject.q("os_api_level", Integer.valueOf(i10)); jsonObject.q("app_target_sdk_version", Integer.valueOf(this.context.getApplicationInfo().targetSdkVersion)); if (i10 >= 24) { } if (i10 >= 26) { } z12 = false; jsonObject.p("is_sideload_enabled", Boolean.valueOf(z12)); if (Environment.getExternalStorageState().equals("mounted")) { } jsonObject.q("sd_card_available", Integer.valueOf(i11)); jsonObject.r("os_name", Build.FINGERPRINT); jsonObject.r("vduid", ""); s10.r("ua", this.uaString); JsonObject jsonObject222222222 = new JsonObject(); JsonObject jsonObject322222222 = new JsonObject(); jsonObject222222222.o("vungle", jsonObject322222222); s10.o("ext", jsonObject222222222); jsonObject322222222.o(MANUFACTURER_AMAZON.equals(Build.MANUFACTURER) ? "amazon" : Constants.PLATFORM, jsonObject); return s10; } catch (GooglePlayServicesNotAvailableException e15) { e11 = e15; str3 = null; StringBuilder sb22 = new StringBuilder(); sb22.append("Play services Not available: "); sb22.append(e11.getLocalizedMessage()); str = str3; z11 = true; if (PrivacyManager.getInstance().shouldSendAdIds()) { } s10.z(IFA); jsonObject.z(ANDROID_ID); jsonObject.z(GAID); jsonObject.z(AMAZON_ADVERTISING_ID); s10.q("lmt", Integer.valueOf(z11 ? 1 : 0)); jsonObject.p("is_google_play_services_available", Boolean.valueOf(Boolean.TRUE.equals(isGooglePlayServicesAvailable()))); if (!TextUtils.isEmpty(getAppSetId())) { } context2 = this.context; if (context2 != null) { } if (intent != null) { } jsonObject.r("battery_state", str2); PowerManager powerManager2222222 = (PowerManager) this.context.getSystemService("power"); jsonObject.q("battery_saver_enabled", Integer.valueOf((powerManager2222222 != null || !powerManager2222222.isPowerSaveMode()) ? 0 : 1)); if (PermissionChecker.checkCallingOrSelfPermission(this.context, "android.permission.ACCESS_NETWORK_STATE") == 0) { } jsonObject.r(OAuth.LOCALE, Locale.getDefault().toString()); jsonObject.r(ak.N, Locale.getDefault().getLanguage()); jsonObject.r("time_zone", TimeZone.getDefault().getID()); audioManager = (AudioManager) this.context.getSystemService("audio"); if (audioManager != null) { } File cache2222222 = this.cacheManager.getCache(); cache2222222.getPath(); jsonObject.q("storage_bytes_available", Long.valueOf(this.cacheManager.getBytesAvailable())); jsonObject.p("is_tv", Boolean.valueOf(MANUFACTURER_AMAZON.equals(Build.MANUFACTURER) ? this.context.getApplicationContext().getPackageManager().hasSystemFeature("amazon.hardware.fire_tv") : Build.VERSION.SDK_INT < 23 ? this.context.getApplicationContext().getPackageManager().hasSystemFeature("com.google.android.tv") || !this.context.getApplicationContext().getPackageManager().hasSystemFeature("android.hardware.touchscreen") : ((UiModeManager) this.context.getSystemService("uimode")).getCurrentModeType() == 4)); i10 = Build.VERSION.SDK_INT; jsonObject.q("os_api_level", Integer.valueOf(i10)); jsonObject.q("app_target_sdk_version", Integer.valueOf(this.context.getApplicationInfo().targetSdkVersion)); if (i10 >= 24) { } if (i10 >= 26) { } z12 = false; jsonObject.p("is_sideload_enabled", Boolean.valueOf(z12)); if (Environment.getExternalStorageState().equals("mounted")) { } jsonObject.q("sd_card_available", Integer.valueOf(i11)); jsonObject.r("os_name", Build.FINGERPRINT); jsonObject.r("vduid", ""); s10.r("ua", this.uaString); JsonObject jsonObject2222222222 = new JsonObject(); JsonObject jsonObject3222222222 = new JsonObject(); jsonObject2222222222.o("vungle", jsonObject3222222222); s10.o("ext", jsonObject2222222222); jsonObject3222222222.o(MANUFACTURER_AMAZON.equals(Build.MANUFACTURER) ? "amazon" : Constants.PLATFORM, jsonObject); return s10; } } } catch (Exception unused6) { str3 = null; z13 = true; z11 = z13; str = str3; if (PrivacyManager.getInstance().shouldSendAdIds()) { } s10.z(IFA); jsonObject.z(ANDROID_ID); jsonObject.z(GAID); jsonObject.z(AMAZON_ADVERTISING_ID); s10.q("lmt", Integer.valueOf(z11 ? 1 : 0)); jsonObject.p("is_google_play_services_available", Boolean.valueOf(Boolean.TRUE.equals(isGooglePlayServicesAvailable()))); if (!TextUtils.isEmpty(getAppSetId())) { } context2 = this.context; if (context2 != null) { } if (intent != null) { } jsonObject.r("battery_state", str2); PowerManager powerManager22222222 = (PowerManager) this.context.getSystemService("power"); jsonObject.q("battery_saver_enabled", Integer.valueOf((powerManager22222222 != null || !powerManager22222222.isPowerSaveMode()) ? 0 : 1)); if (PermissionChecker.checkCallingOrSelfPermission(this.context, "android.permission.ACCESS_NETWORK_STATE") == 0) { } jsonObject.r(OAuth.LOCALE, Locale.getDefault().toString()); jsonObject.r(ak.N, Locale.getDefault().getLanguage()); jsonObject.r("time_zone", TimeZone.getDefault().getID()); audioManager = (AudioManager) this.context.getSystemService("audio"); if (audioManager != null) { } File cache22222222 = this.cacheManager.getCache(); cache22222222.getPath(); jsonObject.q("storage_bytes_available", Long.valueOf(this.cacheManager.getBytesAvailable())); jsonObject.p("is_tv", Boolean.valueOf(MANUFACTURER_AMAZON.equals(Build.MANUFACTURER) ? this.context.getApplicationContext().getPackageManager().hasSystemFeature("amazon.hardware.fire_tv") : Build.VERSION.SDK_INT < 23 ? this.context.getApplicationContext().getPackageManager().hasSystemFeature("com.google.android.tv") || !this.context.getApplicationContext().getPackageManager().hasSystemFeature("android.hardware.touchscreen") : ((UiModeManager) this.context.getSystemService("uimode")).getCurrentModeType() == 4)); i10 = Build.VERSION.SDK_INT; jsonObject.q("os_api_level", Integer.valueOf(i10)); jsonObject.q("app_target_sdk_version", Integer.valueOf(this.context.getApplicationInfo().targetSdkVersion)); if (i10 >= 24) { } if (i10 >= 26) { } z12 = false; jsonObject.p("is_sideload_enabled", Boolean.valueOf(z12)); if (Environment.getExternalStorageState().equals("mounted")) { } jsonObject.q("sd_card_available", Integer.valueOf(i11)); jsonObject.r("os_name", Build.FINGERPRINT); jsonObject.r("vduid", ""); s10.r("ua", this.uaString); JsonObject jsonObject22222222222 = new JsonObject(); JsonObject jsonObject32222222222 = new JsonObject(); jsonObject22222222222.o("vungle", jsonObject32222222222); s10.o("ext", jsonObject22222222222); jsonObject32222222222.o(MANUFACTURER_AMAZON.equals(Build.MANUFACTURER) ? "amazon" : Constants.PLATFORM, jsonObject); return s10; } return s10; } private JsonObject getExtBody() { Cookie cookie = (Cookie) this.repository.load(Cookie.CONFIG_EXTENSION, Cookie.class).get(this.timeoutProvider.getTimeout(), TimeUnit.MILLISECONDS); String string = cookie != null ? cookie.getString(Cookie.CONFIG_EXTENSION) : ""; if (TextUtils.isEmpty(string)) { return null; } JsonObject jsonObject = new JsonObject(); jsonObject.r(Cookie.CONFIG_EXTENSION, string); return jsonObject; } public static String getHeaderUa() { return headerUa; } private String getUserAgentFromCookie() { Cookie cookie = (Cookie) this.repository.load(Cookie.USER_AGENT_ID_COOKIE, Cookie.class).get(); if (cookie == null) { return System.getProperty("http.agent"); } String string = cookie.getString(Cookie.USER_AGENT_ID_COOKIE); return TextUtils.isEmpty(string) ? System.getProperty("http.agent") : string; } private JsonObject getUserBody() { long j2; String str; String str2; String str3; JsonObject jsonObject = new JsonObject(); Cookie cookie = (Cookie) this.repository.load(Cookie.CONSENT_COOKIE, Cookie.class).get(this.timeoutProvider.getTimeout(), TimeUnit.MILLISECONDS); String str4 = ""; if (cookie != null) { str2 = cookie.getString("consent_status"); str = cookie.getString("consent_source"); j2 = cookie.getLong("timestamp").longValue(); str3 = cookie.getString("consent_message_version"); } else { j2 = 0; str2 = "unknown"; str = "no_interaction"; str3 = str4; } JsonObject jsonObject2 = new JsonObject(); jsonObject2.r("consent_status", str2); jsonObject2.r("consent_source", str); jsonObject2.q("consent_timestamp", Long.valueOf(j2)); if (!TextUtils.isEmpty(str3)) { str4 = str3; } jsonObject2.r("consent_message_version", str4); jsonObject.o("gdpr", jsonObject2); Cookie cookie2 = (Cookie) this.repository.load(Cookie.CCPA_COOKIE, Cookie.class).get(); String string = cookie2 != null ? cookie2.getString(Cookie.CCPA_CONSENT_STATUS) : "opted_in"; JsonObject jsonObject3 = new JsonObject(); jsonObject3.r("status", string); jsonObject.o("ccpa", jsonObject3); if (PrivacyManager.getInstance().getCoppaStatus() != PrivacyManager.COPPA.COPPA_NOTSET) { JsonObject jsonObject4 = new JsonObject(); jsonObject4.p(Cookie.COPPA_STATUS_KEY, Boolean.valueOf(PrivacyManager.getInstance().getCoppaStatus().getValue())); jsonObject.o(Cookie.COPPA_KEY, jsonObject4); } return jsonObject; } private void initUserAgentLazy() { this.platform.getUserAgentLazy(new Consumer<String>() { /* class com.vungle.warren.VungleApiClient.AnonymousClass2 */ public void accept(String str) { if (str == null) { String unused = VungleApiClient.TAG; } else { VungleApiClient.this.uaString = str; } } }); } private void setAppId(String str, JsonObject jsonObject) { jsonObject.r("id", str); } public static void setHeaderUa(String str) { headerUa = str; } private void updateAppSetID() { try { AppSet.getClient(this.context).getAppSetIdInfo().addOnSuccessListener(new OnSuccessListener<AppSetIdInfo>() { /* class com.vungle.warren.VungleApiClient.AnonymousClass3 */ public void onSuccess(@NonNull AppSetIdInfo appSetIdInfo) { if (appSetIdInfo != null) { VungleApiClient.this.appSetId = appSetIdInfo.getId(); if (!TextUtils.isEmpty(VungleApiClient.this.appSetId)) { Cookie cookie = new Cookie(Cookie.APP_SET_ID_COOKIE); cookie.putValue(Cookie.APP_SET_ID, VungleApiClient.this.appSetId); try { VungleApiClient.this.repository.save(cookie); } catch (DatabaseHelper.DBException e10) { String unused = VungleApiClient.TAG; StringBuilder sb2 = new StringBuilder(); sb2.append("error saving AppSetId in Cookie: "); sb2.append(e10.getLocalizedMessage()); } } } } }); } catch (NoClassDefFoundError e10) { StringBuilder sb2 = new StringBuilder(); sb2.append("Required libs to get AppSetID Not available: "); sb2.append(e10.getLocalizedMessage()); } } /* access modifiers changed from: package-private */ @VisibleForTesting public void addPlaySvcAvailabilityInCookie(boolean z10) throws DatabaseHelper.DBException { Cookie cookie = new Cookie(Cookie.IS_PLAY_SERVICE_AVAILABLE); cookie.putValue(Cookie.IS_PLAY_SERVICE_AVAILABLE, Boolean.valueOf(z10)); this.repository.save(cookie); } public Call<JsonObject> cacheBust(long j2) { if (this.cacheBustEndpoint != null) { JsonObject jsonObject = new JsonObject(); jsonObject.o("device", getDeviceBody()); jsonObject.o("app", this.appBody); jsonObject.o("user", getUserBody()); JsonObject jsonObject2 = new JsonObject(); jsonObject2.q(Cookie.LAST_CACHE_BUST, Long.valueOf(j2)); jsonObject.o("request", jsonObject2); return this.gzipApi.cacheBust(getHeaderUa(), this.cacheBustEndpoint, jsonObject); } throw new IllegalStateException("API Client not configured yet! Must call /config first."); } /* access modifiers changed from: package-private */ public boolean canCallWillPlayAd() { return this.willPlayAdEnabled && !TextUtils.isEmpty(this.willPlayAdEndpoint); } public com.vungle.warren.network.Response config() throws VungleException, IOException { JsonObject jsonObject = new JsonObject(); jsonObject.o("device", getDeviceBody(true)); jsonObject.o("app", this.appBody); jsonObject.o("user", getUserBody()); JsonObject extBody = getExtBody(); if (extBody != null) { jsonObject.o("ext", extBody); } com.vungle.warren.network.Response<JsonObject> execute = this.api.config(getHeaderUa(), jsonObject).execute(); if (!execute.isSuccessful()) { return execute; } JsonObject body = execute.body(); StringBuilder sb2 = new StringBuilder(); sb2.append("Config Response: "); sb2.append(body); if (JsonUtil.hasNonNull(body, "sleep")) { String j2 = JsonUtil.hasNonNull(body, "info") ? body.u("info").j() : ""; StringBuilder sb3 = new StringBuilder(); sb3.append("Error Initializing Vungle. Please try again. "); sb3.append(j2); throw new VungleException(3); } else if (JsonUtil.hasNonNull(body, "endpoints")) { JsonObject w10 = body.w("endpoints"); HttpUrl m10 = HttpUrl.m(w10.u("new").j()); HttpUrl m11 = HttpUrl.m(w10.u("ads").j()); HttpUrl m12 = HttpUrl.m(w10.u("will_play_ad").j()); HttpUrl m13 = HttpUrl.m(w10.u("report_ad").j()); HttpUrl m14 = HttpUrl.m(w10.u("ri").j()); HttpUrl m15 = HttpUrl.m(w10.u("log").j()); HttpUrl m16 = HttpUrl.m(w10.u(CacheBustDBAdapter.CacheBustColumns.TABLE_NAME).j()); HttpUrl m17 = HttpUrl.m(w10.u("sdk_bi").j()); if (m10 == null || m11 == null || m12 == null || m13 == null || m14 == null || m15 == null || m16 == null || m17 == null) { throw new VungleException(3); } this.newEndpoint = m10.toString(); this.requestAdEndpoint = m11.toString(); this.willPlayAdEndpoint = m12.toString(); this.reportAdEndpoint = m13.toString(); this.riEndpoint = m14.toString(); this.logEndpoint = m15.toString(); this.cacheBustEndpoint = m16.toString(); this.biLoggingEndpoint = m17.toString(); JsonObject w11 = body.w("will_play_ad"); this.willPlayAdTimeout = w11.u("request_timeout").e(); this.willPlayAdEnabled = w11.u("enabled").b(); this.enableOm = JsonUtil.getAsBoolean(body.w("viewability"), "om", false); if (this.willPlayAdEnabled) { this.timeoutApi = new APIFactory(this.client.x().O((long) this.willPlayAdTimeout, TimeUnit.MILLISECONDS).c(), "https://api.vungle.com/").createAPI(Vungle._instance.appID); } if (getOmEnabled()) { this.omInjector.init(); } else { SessionTracker.getInstance().trackEvent(new SessionData.Builder().setEvent(SessionEvent.OM_SDK).addData(SessionAttribute.ENABLED, false).build()); } return execute; } else { throw new VungleException(3); } } public boolean getOmEnabled() { return this.enableOm; } /* access modifiers changed from: package-private */ @VisibleForTesting public Boolean getPlayServicesAvailabilityFromAPI() { try { GoogleApiAvailabilityLight instance = GoogleApiAvailabilityLight.getInstance(); if (instance == null) { return null; } Boolean valueOf = Boolean.valueOf(instance.isGooglePlayServicesAvailable(this.context) == 0); addPlaySvcAvailabilityInCookie(valueOf.booleanValue()); return valueOf; } catch (NoClassDefFoundError unused) { Boolean bool = Boolean.FALSE; try { addPlaySvcAvailabilityInCookie(false); return bool; } catch (Exception unused2) { return bool; } } } /* access modifiers changed from: package-private */ @VisibleForTesting public Boolean getPlayServicesAvailabilityFromCookie() { Cookie cookie = (Cookie) this.repository.load(Cookie.IS_PLAY_SERVICE_AVAILABLE, Cookie.class).get(this.timeoutProvider.getTimeout(), TimeUnit.MILLISECONDS); if (cookie != null) { return cookie.getBoolean(Cookie.IS_PLAY_SERVICE_AVAILABLE); } return null; } public long getRetryAfterHeaderValue(com.vungle.warren.network.Response response) { try { return Long.parseLong(response.headers().a("Retry-After")) * 1000; } catch (NumberFormatException unused) { return 0; } } public void init() { init(this.context); } /* access modifiers changed from: package-private */ @VisibleForTesting public synchronized void init(Context context2) { JsonObject jsonObject = new JsonObject(); jsonObject.r("bundle", context2.getPackageName()); String str = null; try { str = context2.getPackageManager().getPackageInfo(context2.getPackageName(), 0).versionName; } catch (PackageManager.NameNotFoundException unused) { } if (str == null) { str = "1.0"; } jsonObject.r("ver", str); JsonObject jsonObject2 = new JsonObject(); String str2 = Build.MANUFACTURER; jsonObject2.r("make", str2); jsonObject2.r("model", Build.MODEL); jsonObject2.r("osv", Build.VERSION.RELEASE); jsonObject2.r(ak.P, ((TelephonyManager) context2.getSystemService("phone")).getNetworkOperatorName()); jsonObject2.r(ak.f45418x, MANUFACTURER_AMAZON.equals(str2) ? "amazon" : Constants.PLATFORM); DisplayMetrics displayMetrics = new DisplayMetrics(); ((WindowManager) context2.getSystemService("window")).getDefaultDisplay().getMetrics(displayMetrics); jsonObject2.q("w", Integer.valueOf(displayMetrics.widthPixels)); jsonObject2.q("h", Integer.valueOf(displayMetrics.heightPixels)); try { String userAgent = this.platform.getUserAgent(); this.uaString = userAgent; jsonObject2.r("ua", userAgent); initUserAgentLazy(); } catch (Exception e10) { StringBuilder sb2 = new StringBuilder(); sb2.append("Cannot Get UserAgent. Setting Default Device UserAgent."); sb2.append(e10.getLocalizedMessage()); } this.baseDeviceInfo = jsonObject2; this.appBody = jsonObject; this.isGooglePlayServicesAvailable = getPlayServicesAvailabilityFromAPI(); updateAppSetID(); } @VisibleForTesting public Boolean isGooglePlayServicesAvailable() { if (this.isGooglePlayServicesAvailable == null) { this.isGooglePlayServicesAvailable = getPlayServicesAvailabilityFromCookie(); } if (this.isGooglePlayServicesAvailable == null) { this.isGooglePlayServicesAvailable = getPlayServicesAvailabilityFromAPI(); } return this.isGooglePlayServicesAvailable; } /* access modifiers changed from: package-private */ @VisibleForTesting public void overrideApi(VungleApi vungleApi) { this.api = vungleApi; } public boolean pingTPAT(String str) throws ClearTextTrafficException, MalformedURLException { if (TextUtils.isEmpty(str) || HttpUrl.m(str) == null) { SessionTracker.getInstance().trackEvent(new SessionData.Builder().setEvent(SessionEvent.TPAT).addData(SessionAttribute.SUCCESS, false).addData(SessionAttribute.REASON, "Invalid URL").addData(SessionAttribute.URL, str).build()); throw new MalformedURLException("Invalid URL : " + str); } try { String host = new URL(str).getHost(); int i10 = Build.VERSION.SDK_INT; if ((i10 >= 24 ? NetworkSecurityPolicy.getInstance().isCleartextTrafficPermitted(host) : i10 >= 23 ? NetworkSecurityPolicy.getInstance().isCleartextTrafficPermitted() : true) || !URLUtil.isHttpUrl(str)) { try { com.vungle.warren.network.Response<Void> execute = this.api.pingTPAT(this.uaString, str).execute(); if (execute == null) { SessionTracker.getInstance().trackEvent(new SessionData.Builder().setEvent(SessionEvent.TPAT).addData(SessionAttribute.SUCCESS, false).addData(SessionAttribute.REASON, "Error on pinging TPAT").addData(SessionAttribute.URL, str).build()); } else if (!execute.isSuccessful()) { SessionTracker instance = SessionTracker.getInstance(); SessionData.Builder addData = new SessionData.Builder().setEvent(SessionEvent.TPAT).addData(SessionAttribute.SUCCESS, false); SessionAttribute sessionAttribute = SessionAttribute.REASON; instance.trackEvent(addData.addData(sessionAttribute, execute.code() + ": " + execute.message()).addData(SessionAttribute.URL, str).build()); } return true; } catch (IOException e10) { SessionTracker.getInstance().trackEvent(new SessionData.Builder().setEvent(SessionEvent.TPAT).addData(SessionAttribute.SUCCESS, false).addData(SessionAttribute.REASON, e10.getMessage()).addData(SessionAttribute.URL, str).build()); return false; } } else { SessionTracker.getInstance().trackEvent(new SessionData.Builder().setEvent(SessionEvent.TPAT).addData(SessionAttribute.SUCCESS, false).addData(SessionAttribute.REASON, "Clear Text Traffic is blocked").addData(SessionAttribute.URL, str).build()); throw new ClearTextTrafficException("Clear Text Traffic is blocked"); } } catch (MalformedURLException unused) { SessionTracker.getInstance().trackEvent(new SessionData.Builder().setEvent(SessionEvent.TPAT).addData(SessionAttribute.SUCCESS, false).addData(SessionAttribute.REASON, "Invalid URL").addData(SessionAttribute.URL, str).build()); throw new MalformedURLException("Invalid URL : " + str); } } public Call<JsonObject> reportAd(JsonObject jsonObject) { if (this.reportAdEndpoint != null) { JsonObject jsonObject2 = new JsonObject(); jsonObject2.o("device", getDeviceBody()); jsonObject2.o("app", this.appBody); jsonObject2.o("request", jsonObject); jsonObject2.o("user", getUserBody()); JsonObject extBody = getExtBody(); if (extBody != null) { jsonObject2.o("ext", extBody); } return this.gzipApi.reportAd(getHeaderUa(), this.reportAdEndpoint, jsonObject2); } throw new IllegalStateException("API Client not configured yet! Must call /config first."); } public Call<JsonObject> reportNew() throws IllegalStateException { if (this.newEndpoint != null) { HashMap hashMap = new HashMap(2); JsonElement u10 = this.appBody.u("id"); String str = ""; hashMap.put("app_id", u10 != null ? u10.j() : str); JsonObject deviceBody = getDeviceBody(); if (PrivacyManager.getInstance().shouldSendAdIds()) { JsonElement u11 = deviceBody.u(IFA); if (u11 != null) { str = u11.j(); } hashMap.put(IFA, str); } return this.api.reportNew(getHeaderUa(), this.newEndpoint, hashMap); } throw new IllegalStateException("API Client not configured yet! Must call /config first."); } public Call<JsonObject> requestAd(String str, String str2, boolean z10, @Nullable JsonObject jsonObject) throws IllegalStateException { if (this.requestAdEndpoint != null) { JsonObject jsonObject2 = new JsonObject(); jsonObject2.o("device", getDeviceBody()); jsonObject2.o("app", this.appBody); JsonObject userBody = getUserBody(); if (jsonObject != null) { userBody.o("vision", jsonObject); } jsonObject2.o("user", userBody); JsonObject extBody = getExtBody(); if (extBody != null) { jsonObject2.o("ext", extBody); } JsonObject jsonObject3 = new JsonObject(); JsonArray jsonArray = new JsonArray(); jsonArray.p(str); jsonObject3.o("placements", jsonArray); jsonObject3.p("header_bidding", Boolean.valueOf(z10)); if (!TextUtils.isEmpty(str2)) { jsonObject3.r("ad_size", str2); } jsonObject2.o("request", jsonObject3); return this.gzipApi.ads(getHeaderUa(), this.requestAdEndpoint, jsonObject2); } throw new IllegalStateException("API Client not configured yet! Must call /config first."); } public Call<JsonObject> ri(JsonObject jsonObject) { if (this.riEndpoint != null) { JsonObject jsonObject2 = new JsonObject(); jsonObject2.o("device", getDeviceBody()); jsonObject2.o("app", this.appBody); jsonObject2.o("request", jsonObject); jsonObject2.o("user", getUserBody()); JsonObject extBody = getExtBody(); if (extBody != null) { jsonObject2.o("ext", extBody); } return this.api.ri(getHeaderUa(), this.riEndpoint, jsonObject2); } throw new IllegalStateException("API Client not configured yet! Must call /config first."); } public Call<JsonObject> sendAnalytics(Collection<CacheBust> collection) { if (this.biLoggingEndpoint == null) { throw new IllegalStateException("API Client not configured yet! Must call /config first."); } else if (collection == null || collection.isEmpty()) { throw new IllegalArgumentException("Cannot send analytics when bust and session data is empty"); } else { JsonObject jsonObject = new JsonObject(); jsonObject.o("device", getDeviceBody()); jsonObject.o("app", this.appBody); JsonObject jsonObject2 = new JsonObject(); JsonArray jsonArray = new JsonArray(collection.size()); for (CacheBust cacheBust : collection) { for (int i10 = 0; i10 < cacheBust.getEventIds().length; i10++) { JsonObject jsonObject3 = new JsonObject(); jsonObject3.r("target", cacheBust.getIdType() == 1 ? "campaign" : VisionDataDBAdapter.VisionDataColumns.COLUMN_CREATIVE); jsonObject3.r("id", cacheBust.getId()); jsonObject3.r("event_id", cacheBust.getEventIds()[i10]); jsonArray.o(jsonObject3); } } if (jsonArray.size() > 0) { jsonObject2.o(CacheBustDBAdapter.CacheBustColumns.TABLE_NAME, jsonArray); } jsonObject.o("request", jsonObject2); return this.gzipApi.sendBiAnalytics(getHeaderUa(), this.biLoggingEndpoint, jsonObject); } } public Call<JsonObject> sendLog(JsonObject jsonObject) { if (this.logEndpoint != null) { return this.gzipApi.sendLog(getHeaderUa(), this.logEndpoint, jsonObject); } throw new IllegalStateException("API Client not configured yet! Must call /config first."); } public Call<JsonObject> sendSessionDataAnalytics(@NonNull JsonArray jsonArray) { if (this.biLoggingEndpoint != null) { JsonObject jsonObject = new JsonObject(); jsonObject.o("device", getDeviceBody()); jsonObject.o("app", this.appBody); JsonObject jsonObject2 = new JsonObject(); jsonObject2.o("session_events", jsonArray); jsonObject.o("request", jsonObject2); return this.gzipApi.sendBiAnalytics(getHeaderUa(), this.biLoggingEndpoint, jsonObject); } throw new IllegalStateException("API Client not configured yet! Must call /config first."); } /* access modifiers changed from: package-private */ public void setAppId(String str) { setAppId(str, this.appBody); } public void setDefaultIdFallbackDisabled(boolean z10) { this.defaultIdFallbackDisabled = z10; } /* access modifiers changed from: package-private */ public Call<JsonObject> willPlayAd(String str, boolean z10, String str2) { JsonObject jsonObject = new JsonObject(); jsonObject.o("device", getDeviceBody()); jsonObject.o("app", this.appBody); jsonObject.o("user", getUserBody()); JsonObject jsonObject2 = new JsonObject(); JsonObject jsonObject3 = new JsonObject(); jsonObject3.r("reference_id", str); jsonObject3.p("is_auto_cached", Boolean.valueOf(z10)); jsonObject2.o("placement", jsonObject3); jsonObject2.r(AdvertisementDBAdapter.AdvertisementColumns.COLUMN_AD_TOKEN, str2); jsonObject.o("request", jsonObject2); return this.timeoutApi.willPlayAd(getHeaderUa(), this.willPlayAdEndpoint, jsonObject); } }