Video Downloader for FB v3.5.1版本的 MD5 值为:1db7d4aa9fc4356831f5521f52585a52

以下内容为反编译后的 VungleApiClient.java 源代码,内容仅作参考


package com.vungle.warren;

import android.app.Application;
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.Handler;
import android.os.Looper;
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.util.Log;
import android.view.WindowManager;
import android.webkit.URLUtil;
import android.webkit.WebSettings;
import androidx.core.content.PermissionChecker;
import com.appodeal.ads.AppodealNetworks;
import com.appodealx.sdk.utils.RequestInfoKeys;
import com.google.android.exoplayer2.util.MimeTypes;
import com.google.android.gms.ads.identifier.AdvertisingIdClient;
import com.google.android.gms.common.GoogleApiAvailabilityLight;
import com.google.firebase.crashlytics.internal.settings.model.AppSettingsData;
import com.google.firebase.iid.ServiceStarter;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.ironsource.sdk.constants.Constants;
import com.ironsource.sdk.constants.Events;
import com.moat.analytics.mobile.vng.MoatAnalytics;
import com.moat.analytics.mobile.vng.MoatOptions;
import com.vungle.warren.error.VungleException;
import com.vungle.warren.model.AdvertisementDBAdapter;
import com.vungle.warren.model.Cookie;
import com.vungle.warren.model.JsonUtil;
import com.vungle.warren.network.APIFactory;
import com.vungle.warren.network.Call;
import com.vungle.warren.network.VungleApi;
import com.vungle.warren.persistence.CacheManager;
import com.vungle.warren.persistence.DatabaseHelper;
import com.vungle.warren.persistence.Repository;
import com.vungle.warren.utility.ViewUtility;
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.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.CountDownLatch;
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 String BASE_URL = null;
    private static final String ID = "id";
    static final String MANUFACTURER_AMAZON = "Amazon";
    private static final String TAG = VungleApiClient.class.getCanonicalName();
    protected static WrapperFramework WRAPPER_FRAMEWORK_SELECTED;
    private static String headerUa;
    private static Set<Interceptor> logInterceptors;
    private static Set<Interceptor> networkInterceptors;
    private VungleApi api;
    private JsonObject appBody;
    private CacheManager cacheManager;
    private OkHttpClient client;
    private Context context;
    private boolean defaultIdFallbackDisabled;
    private JsonObject deviceBody;
    private boolean enableMoat;
    private VungleApi gzipApi;
    private String logEndpoint;
    private String newEndpoint;
    private final boolean okHttpSupported;
    private String reportAdEndpoint;
    private Repository repository;
    private String requestAdEndpoint;
    private String riEndpoint;
    private VungleApi timeoutApi;
    private JsonObject userBody;
    private boolean willPlayAdEnabled;
    private String willPlayAdEndpoint;
    private int willPlayAdTimeout;
    private Map<String, Long> retryAfterDataMap = new ConcurrentHashMap();
    private String uaString = System.getProperty("http.agent");

    @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";
    }

    public enum WrapperFramework {
        admob,
        air,
        cocos2dx,
        corona,
        dfp,
        heyzap,
        marmalade,
        mopub,
        unity,
        fyber,
        ironsource,
        upsight,
        appodeal,
        aerserv,
        adtoapp,
        tapdaq,
        vunglehbs,
        max,
        none
    }

    private String getConnectionTypeDetail(int i) {
        switch (i) {
            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;
        }
    }

    static {
        StringBuilder sb = new StringBuilder();
        sb.append(MANUFACTURER_AMAZON.equals(Build.MANUFACTURER) ? "VungleAmazon/" : "VungleDroid/");
        sb.append(BuildConfig.VERSION_NAME);
        headerUa = sb.toString();
        BASE_URL = "https://ads.api.vungle.com/";
        networkInterceptors = new HashSet();
        logInterceptors = new HashSet();
    }

    public VungleApiClient(Context context, CacheManager cacheManager, Repository repository) {
        this.cacheManager = cacheManager;
        this.context = context.getApplicationContext();
        this.repository = repository;
        OkHttpClient.Builder addInterceptor = new OkHttpClient.Builder().addInterceptor(new Interceptor() {
            @Override
            public Response intercept(Interceptor.Chain chain) throws IOException {
                int code;
                Request request = chain.request();
                String encodedPath = request.url().encodedPath();
                Long l = (Long) VungleApiClient.this.retryAfterDataMap.get(encodedPath);
                if (l != null) {
                    long seconds = TimeUnit.MILLISECONDS.toSeconds(l.longValue() - System.currentTimeMillis());
                    if (seconds <= 0) {
                        VungleApiClient.this.retryAfterDataMap.remove(encodedPath);
                    } else {
                        return new Response.Builder().request(request).addHeader("Retry-After", String.valueOf(seconds)).code(ServiceStarter.ERROR_UNKNOWN).protocol(Protocol.HTTP_1_1).message("Server is busy").body(ResponseBody.create(MediaType.parse("application/json; charset=utf-8"), "{\"Error\":\"Retry-After\"}")).build();
                    }
                }
                Response proceed = chain.proceed(request);
                if (proceed != null && ((code = proceed.code()) == 429 || code == 500 || code == 502 || code == 503)) {
                    String str = proceed.headers().get("Retry-After");
                    if (!TextUtils.isEmpty(str)) {
                        try {
                            long parseLong = Long.parseLong(str);
                            if (parseLong > 0) {
                                VungleApiClient.this.retryAfterDataMap.put(encodedPath, Long.valueOf((parseLong * 1000) + System.currentTimeMillis()));
                            }
                        } catch (NumberFormatException unused) {
                            Log.d(VungleApiClient.TAG, "Retry-After value is not an valid value");
                        }
                    }
                }
                return proceed;
            }
        });
        try {
            this.client = addInterceptor.build();
            this.okHttpSupported = true;
            OkHttpClient build = addInterceptor.addInterceptor(new GzipRequestInterceptor()).build();
            this.api = new APIFactory(this.client, BASE_URL).createAPI();
            this.gzipApi = new APIFactory(build, BASE_URL).createAPI();
        } catch (ExceptionInInitializerError | NoClassDefFoundError e) {
            Log.e(TAG, "Can't init OKHttp", e);
            this.okHttpSupported = false;
        }
    }

    public static String getHeaderUa() {
        return headerUa;
    }

    public static void setHeaderUa(String str) {
        headerUa = str;
    }

    public boolean platformIsNotSupported() {
        return !this.okHttpSupported;
    }

    public void init() {
        init(this.context);
    }

    static class GzipRequestInterceptor implements Interceptor {
        private static final String CONTENT_ENCODING = "Content-Encoding";
        private static final String GZIP = "gzip";

        GzipRequestInterceptor() {
        }

        @Override
        public Response intercept(Interceptor.Chain chain) throws IOException {
            Request request = chain.request();
            if (request.body() == null || request.header("Content-Encoding") != null) {
                return chain.proceed(request);
            }
            return chain.proceed(request.newBuilder().header("Content-Encoding", GZIP).method(request.method(), gzip(request.body())).build());
        }

        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() {
                @Override
                public MediaType contentType() {
                    return requestBody.contentType();
                }

                @Override
                public long contentLength() {
                    return buffer.size();
                }

                @Override
                public void writeTo(BufferedSink bufferedSink) throws IOException {
                    bufferedSink.write(buffer.snapshot());
                }
            };
        }
    }

    public void setDefaultIdFallbackDisabled(boolean z) {
        this.defaultIdFallbackDisabled = z;
    }

    private synchronized void init(final Context context) {
        JsonObject jsonObject = new JsonObject();
        jsonObject.addProperty("bundle", context.getPackageName());
        String str = null;
        try {
            str = context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionName;
        } catch (PackageManager.NameNotFoundException unused) {
        }
        if (str == null) {
            str = "1.0";
        }
        jsonObject.addProperty("ver", str);
        JsonObject jsonObject2 = new JsonObject();
        jsonObject2.addProperty("make", Build.MANUFACTURER);
        jsonObject2.addProperty("model", Build.MODEL);
        jsonObject2.addProperty("osv", Build.VERSION.RELEASE);
        jsonObject2.addProperty("carrier", ((TelephonyManager) context.getSystemService("phone")).getNetworkOperatorName());
        jsonObject2.addProperty("os", MANUFACTURER_AMAZON.equals(Build.MANUFACTURER) ? "amazon" : "android");
        DisplayMetrics displayMetrics = new DisplayMetrics();
        ((WindowManager) context.getSystemService("window")).getDefaultDisplay().getMetrics(displayMetrics);
        jsonObject2.addProperty("w", Integer.valueOf(displayMetrics.widthPixels));
        jsonObject2.addProperty("h", Integer.valueOf(displayMetrics.heightPixels));
        JsonObject jsonObject3 = new JsonObject();
        jsonObject3.add(AppodealNetworks.VUNGLE, new JsonObject());
        jsonObject2.add(RequestInfoKeys.EXT, jsonObject3);
        try {
            if (Build.VERSION.SDK_INT >= 17) {
                this.uaString = getUserAgentFromCookie();
                initUserAgentLazy();
            } else if (Looper.getMainLooper() == Looper.myLooper()) {
                this.uaString = ViewUtility.getWebView(context.getApplicationContext()).getSettings().getUserAgentString();
            } else {
                final CountDownLatch countDownLatch = new CountDownLatch(1);
                new Handler(Looper.getMainLooper()).post(new Runnable() {
                    @Override
                    public void run() {
                        try {
                            VungleApiClient.this.uaString = ViewUtility.getWebView(context.getApplicationContext()).getSettings().getUserAgentString();
                        } catch (InstantiationException e) {
                            Log.e(VungleApiClient.TAG, "Cannot Get UserAgent. Setting Default Device UserAgent." + e.getLocalizedMessage());
                        }
                        countDownLatch.countDown();
                    }
                });
                if (!countDownLatch.await(2L, TimeUnit.SECONDS)) {
                    Log.e(TAG, "Unable to get User Agent String in specified time");
                }
            }
        } catch (Exception e) {
            Log.e(TAG, "Cannot Get UserAgent. Setting Default Device UserAgent." + e.getLocalizedMessage());
        }
        jsonObject2.addProperty("ua", this.uaString);
        this.deviceBody = jsonObject2;
        this.appBody = jsonObject;
    }

    public void setAppId(String str) {
        setAppId(str, this.appBody);
    }

    private void setAppId(String str, JsonObject jsonObject) {
        jsonObject.addProperty("id", str);
    }

    private void initUserAgentLazy() {
        new Thread(new Runnable() {
            @Override
            public void run() {
                try {
                    VungleApiClient.this.uaString = WebSettings.getDefaultUserAgent(VungleApiClient.this.context);
                    VungleApiClient.this.deviceBody.addProperty("ua", VungleApiClient.this.uaString);
                    VungleApiClient.this.addUserAgentInCookie(VungleApiClient.this.uaString);
                } catch (Exception e) {
                    Log.e(VungleApiClient.TAG, "Cannot Get UserAgent. Setting Default Device UserAgent." + e.getLocalizedMessage());
                }
            }
        }).start();
    }

    public com.vungle.warren.network.Response config() throws VungleException, IOException {
        JsonObject jsonObject = new JsonObject();
        jsonObject.add(Constants.ParametersKeys.ORIENTATION_DEVICE, getDeviceBody());
        jsonObject.add("app", this.appBody);
        jsonObject.add("user", getUserBody());
        com.vungle.warren.network.Response<JsonObject> execute = this.api.config(getHeaderUa(), jsonObject).execute();
        if (!execute.isSuccessful()) {
            return execute;
        }
        JsonObject body = execute.body();
        Log.d(TAG, "Config Response: " + body);
        if (JsonUtil.hasNonNull(body, "sleep")) {
            String asString = JsonUtil.hasNonNull(body, "info") ? body.get("info").getAsString() : "";
            Log.e(TAG, "Error Initializing Vungle. Please try again. " + asString);
            throw new VungleException(3);
        }
        if (!JsonUtil.hasNonNull(body, "endpoints")) {
            Log.e(TAG, "Error Initializing Vungle. Please try again. ");
            throw new VungleException(3);
        }
        JsonObject asJsonObject = body.getAsJsonObject("endpoints");
        HttpUrl parse = HttpUrl.parse(asJsonObject.get(AppSettingsData.STATUS_NEW).getAsString());
        HttpUrl parse2 = HttpUrl.parse(asJsonObject.get("ads").getAsString());
        HttpUrl parse3 = HttpUrl.parse(asJsonObject.get("will_play_ad").getAsString());
        HttpUrl parse4 = HttpUrl.parse(asJsonObject.get("report_ad").getAsString());
        HttpUrl parse5 = HttpUrl.parse(asJsonObject.get("ri").getAsString());
        HttpUrl parse6 = HttpUrl.parse(asJsonObject.get("log").getAsString());
        if (parse == null || parse2 == null || parse3 == null || parse4 == null || parse5 == null || parse6 == null) {
            Log.e(TAG, "Error Initializing Vungle. Please try again. ");
            throw new VungleException(3);
        }
        this.newEndpoint = parse.toString();
        this.requestAdEndpoint = parse2.toString();
        this.willPlayAdEndpoint = parse3.toString();
        this.reportAdEndpoint = parse4.toString();
        this.riEndpoint = parse5.toString();
        this.logEndpoint = parse6.toString();
        JsonObject asJsonObject2 = body.getAsJsonObject("will_play_ad");
        this.willPlayAdTimeout = asJsonObject2.get("request_timeout").getAsInt();
        this.willPlayAdEnabled = asJsonObject2.get(Events.ENABLED).getAsBoolean();
        this.enableMoat = body.getAsJsonObject("viewability").get("moat").getAsBoolean();
        if (this.willPlayAdEnabled) {
            Log.v(TAG, "willPlayAd is enabled, generating a timeout client.");
            this.timeoutApi = new APIFactory(this.client.newBuilder().readTimeout(this.willPlayAdTimeout, TimeUnit.MILLISECONDS).build(), "https://api.vungle.com/").createAPI();
        }
        if (getMoatEnabled()) {
            MoatOptions moatOptions = new MoatOptions();
            moatOptions.disableAdIdCollection = true;
            moatOptions.disableLocationServices = true;
            moatOptions.loggingEnabled = true;
            MoatAnalytics.getInstance().start(moatOptions, (Application) this.context.getApplicationContext());
        }
        return execute;
    }

    public Call<JsonObject> reportNew() throws IllegalStateException {
        if (this.newEndpoint == null) {
            throw new IllegalStateException("API Client not configured yet! Must call /config first.");
        }
        HashMap hashMap = new HashMap(2);
        JsonElement jsonElement = this.appBody.get("id");
        JsonElement jsonElement2 = this.deviceBody.get("ifa");
        hashMap.put(AdvertisementDBAdapter.AdvertisementColumns.COLUMN_APP_ID, jsonElement != null ? jsonElement.getAsString() : "");
        hashMap.put("ifa", jsonElement2 != null ? jsonElement2.getAsString() : "");
        return this.api.reportNew(getHeaderUa(), this.newEndpoint, hashMap);
    }

    public Call<JsonObject> requestAd(String str, String str2, boolean z, JsonObject jsonObject) throws IllegalStateException {
        if (this.requestAdEndpoint == null) {
            throw new IllegalStateException("API Client not configured yet! Must call /config first.");
        }
        JsonObject jsonObject2 = new JsonObject();
        jsonObject2.add(Constants.ParametersKeys.ORIENTATION_DEVICE, getDeviceBody());
        jsonObject2.add("app", this.appBody);
        JsonObject userBody = getUserBody();
        if (jsonObject != null) {
            userBody.add("vision", jsonObject);
        }
        jsonObject2.add("user", userBody);
        JsonObject jsonObject3 = new JsonObject();
        JsonArray jsonArray = new JsonArray();
        jsonArray.add(str);
        jsonObject3.add("placements", jsonArray);
        jsonObject3.addProperty("header_bidding", Boolean.valueOf(z));
        if (!TextUtils.isEmpty(str2)) {
            jsonObject3.addProperty("ad_size", str2);
        }
        jsonObject2.add("request", jsonObject3);
        return this.gzipApi.ads(getHeaderUa(), this.requestAdEndpoint, jsonObject2);
    }

    public Call<JsonObject> willPlayAd(String str, boolean z, String str2) {
        JsonObject jsonObject = new JsonObject();
        jsonObject.add(Constants.ParametersKeys.ORIENTATION_DEVICE, getDeviceBody());
        jsonObject.add("app", this.appBody);
        jsonObject.add("user", getUserBody());
        JsonObject jsonObject2 = new JsonObject();
        JsonObject jsonObject3 = new JsonObject();
        jsonObject3.addProperty("reference_id", str);
        jsonObject3.addProperty("is_auto_cached", Boolean.valueOf(z));
        jsonObject2.add("placement", jsonObject3);
        jsonObject2.addProperty(AdvertisementDBAdapter.AdvertisementColumns.COLUMN_AD_TOKEN, str2);
        jsonObject.add("request", jsonObject2);
        return this.timeoutApi.willPlayAd(getHeaderUa(), this.willPlayAdEndpoint, jsonObject);
    }

    public boolean canCallWillPlayAd() {
        return this.willPlayAdEnabled && !TextUtils.isEmpty(this.willPlayAdEndpoint);
    }

    public Call<JsonObject> reportAd(JsonObject jsonObject) {
        if (this.reportAdEndpoint == null) {
            throw new IllegalStateException("API Client not configured yet! Must call /config first.");
        }
        JsonObject jsonObject2 = new JsonObject();
        jsonObject2.add(Constants.ParametersKeys.ORIENTATION_DEVICE, getDeviceBody());
        jsonObject2.add("app", this.appBody);
        jsonObject2.add("request", jsonObject);
        jsonObject2.add("user", getUserBody());
        return this.gzipApi.reportAd(getHeaderUa(), this.reportAdEndpoint, jsonObject2);
    }

    public Call<JsonObject> sendLog(JsonObject jsonObject) {
        if (this.logEndpoint == null) {
            throw new IllegalStateException("API Client not configured yet! Must call /config first.");
        }
        return this.gzipApi.sendLog(getHeaderUa(), this.logEndpoint, jsonObject);
    }

    public Call<JsonObject> ri(JsonObject jsonObject) {
        if (this.riEndpoint == null) {
            throw new IllegalStateException("API Client not configured yet! Must call /config first.");
        }
        JsonObject jsonObject2 = new JsonObject();
        jsonObject2.add(Constants.ParametersKeys.ORIENTATION_DEVICE, getDeviceBody());
        jsonObject2.add("app", this.appBody);
        jsonObject2.add("request", jsonObject);
        return this.api.ri(getHeaderUa(), this.riEndpoint, jsonObject2);
    }

    public boolean pingTPAT(String str) throws ClearTextTrafficException, MalformedURLException {
        boolean isCleartextTrafficPermitted;
        if (!TextUtils.isEmpty(str) && HttpUrl.parse(str) != null) {
            try {
                String host = new URL(str).getHost();
                if (Build.VERSION.SDK_INT >= 24) {
                    isCleartextTrafficPermitted = NetworkSecurityPolicy.getInstance().isCleartextTrafficPermitted(host);
                } else {
                    isCleartextTrafficPermitted = Build.VERSION.SDK_INT >= 23 ? NetworkSecurityPolicy.getInstance().isCleartextTrafficPermitted() : true;
                }
                if (!isCleartextTrafficPermitted && URLUtil.isHttpUrl(str)) {
                    throw new ClearTextTrafficException("Clear Text Traffic is blocked");
                }
                try {
                    this.api.pingTPAT(this.uaString, str).execute();
                    return true;
                } catch (IOException unused) {
                    Log.d(TAG, "Error on pinging TPAT");
                    return false;
                }
            } catch (MalformedURLException unused2) {
                throw new MalformedURLException("Invalid URL : " + str);
            }
        }
        throw new MalformedURLException("Invalid URL : " + str);
    }

    private JsonObject getDeviceBody() throws IllegalStateException {
        String str;
        int i;
        Intent registerReceiver;
        String str2;
        AudioManager audioManager;
        File cache;
        boolean z;
        String str3;
        NetworkInfo activeNetworkInfo;
        String str4;
        ?? r6;
        int i2;
        JsonObject jsonObject = new JsonObject();
        boolean z2 = false;
        try {
            if (MANUFACTURER_AMAZON.equals(Build.MANUFACTURER)) {
                try {
                    ContentResolver contentResolver = this.context.getContentResolver();
                    i = Settings.Secure.getInt(contentResolver, "limit_ad_tracking") == 1 ? 1 : 0;
                    try {
                        try {
                            str = Settings.Secure.getString(contentResolver, "advertising_id");
                        } catch (Settings.SettingNotFoundException e) {
                            e = e;
                            Log.w(TAG, "Error getting Amazon advertising info", e);
                            str = null;
                            if (str != null) {
                            }
                            this.deviceBody.addProperty("lmt", Integer.valueOf(i));
                            jsonObject.addProperty("is_google_play_services_available", Boolean.valueOf(isGooglePlayServicesAvailable(this.context)));
                            Context context = this.context;
                            if (context != null) {
                            }
                            String str5 = "UNKNOWN";
                            if (registerReceiver != null) {
                            }
                            str2 = "UNKNOWN";
                            jsonObject.addProperty("battery_state", str2);
                            if (Build.VERSION.SDK_INT >= 21) {
                            }
                            if (PermissionChecker.checkCallingOrSelfPermission(this.context, "android.permission.ACCESS_NETWORK_STATE") == 0) {
                            }
                            jsonObject.addProperty("locale", Locale.getDefault().toString());
                            jsonObject.addProperty("language", Locale.getDefault().getLanguage());
                            jsonObject.addProperty("time_zone", TimeZone.getDefault().getID());
                            audioManager = (AudioManager) this.context.getSystemService(MimeTypes.BASE_TYPE_AUDIO);
                            if (audioManager != null) {
                            }
                            cache = this.cacheManager.getCache();
                            cache.getPath();
                            if (cache.exists()) {
                            }
                            if (!MANUFACTURER_AMAZON.equals(Build.MANUFACTURER)) {
                            }
                            jsonObject.addProperty("is_tv", Boolean.valueOf(z));
                            jsonObject.addProperty("os_api_level", Integer.valueOf(Build.VERSION.SDK_INT));
                            if (Build.VERSION.SDK_INT < 26) {
                            }
                            jsonObject.addProperty("is_sideload_enabled", Boolean.valueOf(z2));
                            jsonObject.addProperty("sd_card_available", Integer.valueOf(Environment.getExternalStorageState().equals("mounted") ? 1 : 0));
                            jsonObject.addProperty("os_name", Build.FINGERPRINT);
                            jsonObject.addProperty("vduid", "");
                            this.deviceBody.getAsJsonObject(RequestInfoKeys.EXT).getAsJsonObject(AppodealNetworks.VUNGLE).add(!MANUFACTURER_AMAZON.equals(Build.MANUFACTURER) ? "amazon" : "android", jsonObject);
                            return this.deviceBody;
                        }
                    } catch (Exception unused) {
                        str = null;
                        Log.e(TAG, "Cannot load Advertising ID");
                        if (str != null) {
                        }
                        this.deviceBody.addProperty("lmt", Integer.valueOf(i));
                        jsonObject.addProperty("is_google_play_services_available", Boolean.valueOf(isGooglePlayServicesAvailable(this.context)));
                        Context context2 = this.context;
                        if (context2 != null) {
                        }
                        String str52 = "UNKNOWN";
                        if (registerReceiver != null) {
                        }
                        str2 = "UNKNOWN";
                        jsonObject.addProperty("battery_state", str2);
                        if (Build.VERSION.SDK_INT >= 21) {
                        }
                        if (PermissionChecker.checkCallingOrSelfPermission(this.context, "android.permission.ACCESS_NETWORK_STATE") == 0) {
                        }
                        jsonObject.addProperty("locale", Locale.getDefault().toString());
                        jsonObject.addProperty("language", Locale.getDefault().getLanguage());
                        jsonObject.addProperty("time_zone", TimeZone.getDefault().getID());
                        audioManager = (AudioManager) this.context.getSystemService(MimeTypes.BASE_TYPE_AUDIO);
                        if (audioManager != null) {
                        }
                        cache = this.cacheManager.getCache();
                        cache.getPath();
                        if (cache.exists()) {
                        }
                        if (!MANUFACTURER_AMAZON.equals(Build.MANUFACTURER)) {
                        }
                        jsonObject.addProperty("is_tv", Boolean.valueOf(z));
                        jsonObject.addProperty("os_api_level", Integer.valueOf(Build.VERSION.SDK_INT));
                        if (Build.VERSION.SDK_INT < 26) {
                        }
                        jsonObject.addProperty("is_sideload_enabled", Boolean.valueOf(z2));
                        jsonObject.addProperty("sd_card_available", Integer.valueOf(Environment.getExternalStorageState().equals("mounted") ? 1 : 0));
                        jsonObject.addProperty("os_name", Build.FINGERPRINT);
                        jsonObject.addProperty("vduid", "");
                        this.deviceBody.getAsJsonObject(RequestInfoKeys.EXT).getAsJsonObject(AppodealNetworks.VUNGLE).add(!MANUFACTURER_AMAZON.equals(Build.MANUFACTURER) ? "amazon" : "android", jsonObject);
                        return this.deviceBody;
                    }
                } catch (Settings.SettingNotFoundException e2) {
                    e = e2;
                    i = 1;
                }
            } else {
                try {
                    AdvertisingIdClient.Info advertisingIdInfo = AdvertisingIdClient.getAdvertisingIdInfo(this.context);
                    if (advertisingIdInfo != null) {
                        str4 = advertisingIdInfo.getId();
                        try {
                            r6 = advertisingIdInfo.isLimitAdTrackingEnabled();
                            try {
                                try {
                                    this.deviceBody.addProperty("ifa", str4);
                                    i2 = r6;
                                } catch (NoClassDefFoundError e3) {
                                    e = e3;
                                    Log.e(TAG, "Play services Not available: " + e.getLocalizedMessage());
                                    String string = Settings.Secure.getString(this.context.getContentResolver(), "advertising_id");
                                    i = r6 == true ? 1 : 0;
                                    str = string;
                                    if (str != null) {
                                    }
                                    this.deviceBody.addProperty("lmt", Integer.valueOf(i));
                                    jsonObject.addProperty("is_google_play_services_available", Boolean.valueOf(isGooglePlayServicesAvailable(this.context)));
                                    Context context22 = this.context;
                                    if (context22 != null) {
                                    }
                                    String str522 = "UNKNOWN";
                                    if (registerReceiver != null) {
                                    }
                                    str2 = "UNKNOWN";
                                    jsonObject.addProperty("battery_state", str2);
                                    if (Build.VERSION.SDK_INT >= 21) {
                                    }
                                    if (PermissionChecker.checkCallingOrSelfPermission(this.context, "android.permission.ACCESS_NETWORK_STATE") == 0) {
                                    }
                                    jsonObject.addProperty("locale", Locale.getDefault().toString());
                                    jsonObject.addProperty("language", Locale.getDefault().getLanguage());
                                    jsonObject.addProperty("time_zone", TimeZone.getDefault().getID());
                                    audioManager = (AudioManager) this.context.getSystemService(MimeTypes.BASE_TYPE_AUDIO);
                                    if (audioManager != null) {
                                    }
                                    cache = this.cacheManager.getCache();
                                    cache.getPath();
                                    if (cache.exists()) {
                                    }
                                    if (!MANUFACTURER_AMAZON.equals(Build.MANUFACTURER)) {
                                    }
                                    jsonObject.addProperty("is_tv", Boolean.valueOf(z));
                                    jsonObject.addProperty("os_api_level", Integer.valueOf(Build.VERSION.SDK_INT));
                                    if (Build.VERSION.SDK_INT < 26) {
                                    }
                                    jsonObject.addProperty("is_sideload_enabled", Boolean.valueOf(z2));
                                    jsonObject.addProperty("sd_card_available", Integer.valueOf(Environment.getExternalStorageState().equals("mounted") ? 1 : 0));
                                    jsonObject.addProperty("os_name", Build.FINGERPRINT);
                                    jsonObject.addProperty("vduid", "");
                                    this.deviceBody.getAsJsonObject(RequestInfoKeys.EXT).getAsJsonObject(AppodealNetworks.VUNGLE).add(!MANUFACTURER_AMAZON.equals(Build.MANUFACTURER) ? "amazon" : "android", jsonObject);
                                    return this.deviceBody;
                                }
                            } catch (Exception unused2) {
                                String str6 = str4;
                                i = r6;
                                str = str6;
                                Log.e(TAG, "Cannot load Advertising ID");
                                if (str != null) {
                                }
                                this.deviceBody.addProperty("lmt", Integer.valueOf(i));
                                jsonObject.addProperty("is_google_play_services_available", Boolean.valueOf(isGooglePlayServicesAvailable(this.context)));
                                Context context222 = this.context;
                                if (context222 != null) {
                                }
                                String str5222 = "UNKNOWN";
                                if (registerReceiver != null) {
                                }
                                str2 = "UNKNOWN";
                                jsonObject.addProperty("battery_state", str2);
                                if (Build.VERSION.SDK_INT >= 21) {
                                }
                                if (PermissionChecker.checkCallingOrSelfPermission(this.context, "android.permission.ACCESS_NETWORK_STATE") == 0) {
                                }
                                jsonObject.addProperty("locale", Locale.getDefault().toString());
                                jsonObject.addProperty("language", Locale.getDefault().getLanguage());
                                jsonObject.addProperty("time_zone", TimeZone.getDefault().getID());
                                audioManager = (AudioManager) this.context.getSystemService(MimeTypes.BASE_TYPE_AUDIO);
                                if (audioManager != null) {
                                }
                                cache = this.cacheManager.getCache();
                                cache.getPath();
                                if (cache.exists()) {
                                }
                                if (!MANUFACTURER_AMAZON.equals(Build.MANUFACTURER)) {
                                }
                                jsonObject.addProperty("is_tv", Boolean.valueOf(z));
                                jsonObject.addProperty("os_api_level", Integer.valueOf(Build.VERSION.SDK_INT));
                                if (Build.VERSION.SDK_INT < 26) {
                                }
                                jsonObject.addProperty("is_sideload_enabled", Boolean.valueOf(z2));
                                jsonObject.addProperty("sd_card_available", Integer.valueOf(Environment.getExternalStorageState().equals("mounted") ? 1 : 0));
                                jsonObject.addProperty("os_name", Build.FINGERPRINT);
                                jsonObject.addProperty("vduid", "");
                                this.deviceBody.getAsJsonObject(RequestInfoKeys.EXT).getAsJsonObject(AppodealNetworks.VUNGLE).add(!MANUFACTURER_AMAZON.equals(Build.MANUFACTURER) ? "amazon" : "android", jsonObject);
                                return this.deviceBody;
                            }
                        } catch (Exception unused3) {
                            str = str4;
                            i = 1;
                            Log.e(TAG, "Cannot load Advertising ID");
                            if (str != null) {
                            }
                            this.deviceBody.addProperty("lmt", Integer.valueOf(i));
                            jsonObject.addProperty("is_google_play_services_available", Boolean.valueOf(isGooglePlayServicesAvailable(this.context)));
                            Context context2222 = this.context;
                            if (context2222 != null) {
                            }
                            String str52222 = "UNKNOWN";
                            if (registerReceiver != null) {
                            }
                            str2 = "UNKNOWN";
                            jsonObject.addProperty("battery_state", str2);
                            if (Build.VERSION.SDK_INT >= 21) {
                            }
                            if (PermissionChecker.checkCallingOrSelfPermission(this.context, "android.permission.ACCESS_NETWORK_STATE") == 0) {
                            }
                            jsonObject.addProperty("locale", Locale.getDefault().toString());
                            jsonObject.addProperty("language", Locale.getDefault().getLanguage());
                            jsonObject.addProperty("time_zone", TimeZone.getDefault().getID());
                            audioManager = (AudioManager) this.context.getSystemService(MimeTypes.BASE_TYPE_AUDIO);
                            if (audioManager != null) {
                            }
                            cache = this.cacheManager.getCache();
                            cache.getPath();
                            if (cache.exists()) {
                            }
                            if (!MANUFACTURER_AMAZON.equals(Build.MANUFACTURER)) {
                            }
                            jsonObject.addProperty("is_tv", Boolean.valueOf(z));
                            jsonObject.addProperty("os_api_level", Integer.valueOf(Build.VERSION.SDK_INT));
                            if (Build.VERSION.SDK_INT < 26) {
                            }
                            jsonObject.addProperty("is_sideload_enabled", Boolean.valueOf(z2));
                            jsonObject.addProperty("sd_card_available", Integer.valueOf(Environment.getExternalStorageState().equals("mounted") ? 1 : 0));
                            jsonObject.addProperty("os_name", Build.FINGERPRINT);
                            jsonObject.addProperty("vduid", "");
                            this.deviceBody.getAsJsonObject(RequestInfoKeys.EXT).getAsJsonObject(AppodealNetworks.VUNGLE).add(!MANUFACTURER_AMAZON.equals(Build.MANUFACTURER) ? "amazon" : "android", jsonObject);
                            return this.deviceBody;
                        } catch (NoClassDefFoundError e4) {
                            e = e4;
                            r6 = 1;
                            Log.e(TAG, "Play services Not available: " + e.getLocalizedMessage());
                            String string2 = Settings.Secure.getString(this.context.getContentResolver(), "advertising_id");
                            i = r6 == true ? 1 : 0;
                            str = string2;
                            if (str != null) {
                            }
                            this.deviceBody.addProperty("lmt", Integer.valueOf(i));
                            jsonObject.addProperty("is_google_play_services_available", Boolean.valueOf(isGooglePlayServicesAvailable(this.context)));
                            Context context22222 = this.context;
                            if (context22222 != null) {
                            }
                            String str522222 = "UNKNOWN";
                            if (registerReceiver != null) {
                            }
                            str2 = "UNKNOWN";
                            jsonObject.addProperty("battery_state", str2);
                            if (Build.VERSION.SDK_INT >= 21) {
                            }
                            if (PermissionChecker.checkCallingOrSelfPermission(this.context, "android.permission.ACCESS_NETWORK_STATE") == 0) {
                            }
                            jsonObject.addProperty("locale", Locale.getDefault().toString());
                            jsonObject.addProperty("language", Locale.getDefault().getLanguage());
                            jsonObject.addProperty("time_zone", TimeZone.getDefault().getID());
                            audioManager = (AudioManager) this.context.getSystemService(MimeTypes.BASE_TYPE_AUDIO);
                            if (audioManager != null) {
                            }
                            cache = this.cacheManager.getCache();
                            cache.getPath();
                            if (cache.exists()) {
                            }
                            if (!MANUFACTURER_AMAZON.equals(Build.MANUFACTURER)) {
                            }
                            jsonObject.addProperty("is_tv", Boolean.valueOf(z));
                            jsonObject.addProperty("os_api_level", Integer.valueOf(Build.VERSION.SDK_INT));
                            if (Build.VERSION.SDK_INT < 26) {
                            }
                            jsonObject.addProperty("is_sideload_enabled", Boolean.valueOf(z2));
                            jsonObject.addProperty("sd_card_available", Integer.valueOf(Environment.getExternalStorageState().equals("mounted") ? 1 : 0));
                            jsonObject.addProperty("os_name", Build.FINGERPRINT);
                            jsonObject.addProperty("vduid", "");
                            this.deviceBody.getAsJsonObject(RequestInfoKeys.EXT).getAsJsonObject(AppodealNetworks.VUNGLE).add(!MANUFACTURER_AMAZON.equals(Build.MANUFACTURER) ? "amazon" : "android", jsonObject);
                            return this.deviceBody;
                        }
                    } else {
                        str4 = null;
                        i2 = 1;
                    }
                    String str7 = str4;
                    i = i2;
                    str = str7;
                } catch (NoClassDefFoundError e5) {
                    e = e5;
                    str4 = null;
                }
            }
        } catch (Exception unused4) {
            str = null;
        }
        if (str != null) {
            jsonObject.addProperty(MANUFACTURER_AMAZON.equals(Build.MANUFACTURER) ? "amazon_advertising_id" : "gaid", str);
            this.deviceBody.addProperty("ifa", str);
        } else {
            String string3 = Settings.Secure.getString(this.context.getContentResolver(), "android_id");
            this.deviceBody.addProperty("ifa", (this.defaultIdFallbackDisabled || TextUtils.isEmpty(string3)) ? "" : string3);
            if (!TextUtils.isEmpty(string3) && !this.defaultIdFallbackDisabled) {
                jsonObject.addProperty("android_id", string3);
            }
        }
        this.deviceBody.addProperty("lmt", Integer.valueOf(i));
        jsonObject.addProperty("is_google_play_services_available", Boolean.valueOf(isGooglePlayServicesAvailable(this.context)));
        Context context222222 = this.context;
        registerReceiver = context222222 != null ? context222222.registerReceiver(null, new IntentFilter("android.intent.action.BATTERY_CHANGED")) : null;
        String str5222222 = "UNKNOWN";
        if (registerReceiver != null) {
            int intExtra = registerReceiver.getIntExtra("level", -1);
            int intExtra2 = registerReceiver.getIntExtra("scale", -1);
            if (intExtra > 0 && intExtra2 > 0) {
                jsonObject.addProperty("battery_level", Float.valueOf(intExtra / intExtra2));
            }
            int intExtra3 = registerReceiver.getIntExtra("status", -1);
            if (intExtra3 != -1) {
                if (intExtra3 == 2 || intExtra3 == 5) {
                    int intExtra4 = registerReceiver.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";
                }
                jsonObject.addProperty("battery_state", str2);
                if (Build.VERSION.SDK_INT >= 21) {
                    PowerManager powerManager = (PowerManager) this.context.getSystemService("power");
                    jsonObject.addProperty("battery_saver_enabled", Integer.valueOf((powerManager == null || !powerManager.isPowerSaveMode()) ? 0 : 1));
                }
                if (PermissionChecker.checkCallingOrSelfPermission(this.context, "android.permission.ACCESS_NETWORK_STATE") == 0) {
                    ConnectivityManager connectivityManager = (ConnectivityManager) this.context.getSystemService("connectivity");
                    String str8 = "unknown";
                    if (connectivityManager == null || (activeNetworkInfo = connectivityManager.getActiveNetworkInfo()) == null) {
                        str3 = "NONE";
                    } else {
                        int type = activeNetworkInfo.getType();
                        if (type != 0) {
                            str3 = (type == 1 || type == 6) ? "WIFI" : type != 7 ? type != 9 ? "UNKNOWN" : "ETHERNET" : "BLUETOOTH";
                        } else {
                            str8 = getConnectionTypeDetail(activeNetworkInfo.getSubtype());
                            str3 = "MOBILE";
                        }
                    }
                    jsonObject.addProperty("connection_type", str3);
                    jsonObject.addProperty("connection_type_detail", str8);
                    if (Build.VERSION.SDK_INT >= 24) {
                        if (connectivityManager.isActiveNetworkMetered()) {
                            int restrictBackgroundStatus = connectivityManager.getRestrictBackgroundStatus();
                            if (restrictBackgroundStatus == 1) {
                                str5222222 = "DISABLED";
                            } else if (restrictBackgroundStatus == 2) {
                                str5222222 = "WHITELISTED";
                            } else if (restrictBackgroundStatus == 3) {
                                str5222222 = "ENABLED";
                            }
                            jsonObject.addProperty("data_saver_status", str5222222);
                            jsonObject.addProperty("network_metered", (Number) 1);
                        } else {
                            jsonObject.addProperty("data_saver_status", "NOT_APPLICABLE");
                            jsonObject.addProperty("network_metered", (Number) 0);
                        }
                    }
                }
                jsonObject.addProperty("locale", Locale.getDefault().toString());
                jsonObject.addProperty("language", Locale.getDefault().getLanguage());
                jsonObject.addProperty("time_zone", TimeZone.getDefault().getID());
                audioManager = (AudioManager) this.context.getSystemService(MimeTypes.BASE_TYPE_AUDIO);
                if (audioManager != null) {
                    int streamMaxVolume = audioManager.getStreamMaxVolume(3);
                    int streamVolume = audioManager.getStreamVolume(3);
                    jsonObject.addProperty("volume_level", Float.valueOf(streamVolume / streamMaxVolume));
                    jsonObject.addProperty("sound_enabled", Integer.valueOf(streamVolume > 0 ? 1 : 0));
                }
                cache = this.cacheManager.getCache();
                cache.getPath();
                if (cache.exists() && cache.isDirectory()) {
                    jsonObject.addProperty("storage_bytes_available", Long.valueOf(this.cacheManager.getBytesAvailable()));
                }
                if (!MANUFACTURER_AMAZON.equals(Build.MANUFACTURER)) {
                    z = this.context.getApplicationContext().getPackageManager().hasSystemFeature("amazon.hardware.fire_tv");
                } else {
                    z = 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;
                }
                jsonObject.addProperty("is_tv", Boolean.valueOf(z));
                jsonObject.addProperty("os_api_level", Integer.valueOf(Build.VERSION.SDK_INT));
                if (Build.VERSION.SDK_INT < 26) {
                    if (this.context.checkCallingOrSelfPermission("android.permission.REQUEST_INSTALL_PACKAGES") == 0) {
                        z2 = this.context.getApplicationContext().getPackageManager().canRequestPackageInstalls();
                    }
                } else if (Settings.Secure.getInt(this.context.getContentResolver(), "install_non_market_apps") == 1) {
                    z2 = true;
                }
                jsonObject.addProperty("is_sideload_enabled", Boolean.valueOf(z2));
                jsonObject.addProperty("sd_card_available", Integer.valueOf(Environment.getExternalStorageState().equals("mounted") ? 1 : 0));
                jsonObject.addProperty("os_name", Build.FINGERPRINT);
                jsonObject.addProperty("vduid", "");
                this.deviceBody.getAsJsonObject(RequestInfoKeys.EXT).getAsJsonObject(AppodealNetworks.VUNGLE).add(!MANUFACTURER_AMAZON.equals(Build.MANUFACTURER) ? "amazon" : "android", jsonObject);
                return this.deviceBody;
            }
        }
        str2 = "UNKNOWN";
        jsonObject.addProperty("battery_state", str2);
        if (Build.VERSION.SDK_INT >= 21) {
        }
        if (PermissionChecker.checkCallingOrSelfPermission(this.context, "android.permission.ACCESS_NETWORK_STATE") == 0) {
        }
        jsonObject.addProperty("locale", Locale.getDefault().toString());
        jsonObject.addProperty("language", Locale.getDefault().getLanguage());
        jsonObject.addProperty("time_zone", TimeZone.getDefault().getID());
        audioManager = (AudioManager) this.context.getSystemService(MimeTypes.BASE_TYPE_AUDIO);
        if (audioManager != null) {
        }
        cache = this.cacheManager.getCache();
        cache.getPath();
        if (cache.exists()) {
            jsonObject.addProperty("storage_bytes_available", Long.valueOf(this.cacheManager.getBytesAvailable()));
        }
        if (!MANUFACTURER_AMAZON.equals(Build.MANUFACTURER)) {
        }
        jsonObject.addProperty("is_tv", Boolean.valueOf(z));
        jsonObject.addProperty("os_api_level", Integer.valueOf(Build.VERSION.SDK_INT));
        if (Build.VERSION.SDK_INT < 26) {
        }
        jsonObject.addProperty("is_sideload_enabled", Boolean.valueOf(z2));
        jsonObject.addProperty("sd_card_available", Integer.valueOf(Environment.getExternalStorageState().equals("mounted") ? 1 : 0));
        jsonObject.addProperty("os_name", Build.FINGERPRINT);
        jsonObject.addProperty("vduid", "");
        this.deviceBody.getAsJsonObject(RequestInfoKeys.EXT).getAsJsonObject(AppodealNetworks.VUNGLE).add(!MANUFACTURER_AMAZON.equals(Build.MANUFACTURER) ? "amazon" : "android", jsonObject);
        return this.deviceBody;
    }

    private JsonObject getUserBody() {
        long j;
        String str;
        String str2;
        String str3;
        JsonObject jsonObject = new JsonObject();
        Cookie cookie = (Cookie) this.repository.load(Cookie.CONSENT_COOKIE, Cookie.class).get();
        if (cookie != null) {
            str = cookie.getString("consent_status");
            str2 = cookie.getString("consent_source");
            j = cookie.getLong("timestamp").longValue();
            str3 = cookie.getString("consent_message_version");
        } else {
            j = 0;
            str = "unknown";
            str2 = "no_interaction";
            str3 = "";
        }
        JsonObject jsonObject2 = new JsonObject();
        jsonObject2.addProperty("consent_status", str);
        jsonObject2.addProperty("consent_source", str2);
        jsonObject2.addProperty("consent_timestamp", Long.valueOf(j));
        if (TextUtils.isEmpty(str3)) {
            str3 = "";
        }
        jsonObject2.addProperty("consent_message_version", str3);
        jsonObject.add("gdpr", jsonObject2);
        Cookie cookie2 = (Cookie) this.repository.load(Cookie.CCPA_COOKIE, Cookie.class).get();
        String string = cookie2 != null ? cookie2.getString(Cookie.CCPA_CONSENT_STATUS) : Cookie.CONSENT_STATUS_OPTED_IN;
        JsonObject jsonObject3 = new JsonObject();
        jsonObject3.addProperty("status", string);
        jsonObject.add("ccpa", jsonObject3);
        return jsonObject;
    }

    public boolean getMoatEnabled() {
        return this.enableMoat && Build.VERSION.SDK_INT >= 16;
    }

    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;
    }

    public void addUserAgentInCookie(String str) throws DatabaseHelper.DBException {
        Cookie cookie = new Cookie(Cookie.USER_AGENT_ID_COOKIE);
        cookie.putValue(Cookie.USER_AGENT_ID_COOKIE, str);
        this.repository.save(cookie);
    }

    public long getRetryAfterHeaderValue(com.vungle.warren.network.Response response) {
        try {
            return Long.parseLong(response.headers().get("Retry-After")) * 1000;
        } catch (NumberFormatException unused) {
            return 0L;
        }
    }

    public static class ClearTextTrafficException extends IOException {
        ClearTextTrafficException(String str) {
            super(str);
        }
    }

    void overrideApi(VungleApi vungleApi) {
        this.api = vungleApi;
    }

    public static boolean isGooglePlayServicesAvailable(Context context) {
        try {
            GoogleApiAvailabilityLight googleApiAvailabilityLight = GoogleApiAvailabilityLight.getInstance();
            if (googleApiAvailabilityLight != null) {
                return googleApiAvailabilityLight.isGooglePlayServicesAvailable(context) == 0;
            }
        } catch (NoClassDefFoundError unused) {
            Log.w(TAG, "Play services Not available");
        }
        return false;
    }
}