导航菜单

页面标题

页面副标题

Cantique de Louanges v12 - m.java 源代码

正在查看: Cantique de Louanges v12 应用的 m.java JAVA 源代码文件

本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。


package com.vungle.ads.internal.network;

import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.Build;
import android.telephony.TelephonyManager;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.Display;
import android.view.WindowManager;
import com.google.android.gms.common.GoogleApiAvailabilityLight;
import com.google.gson.mediation.vungle.BuildConfig;
import com.mbridge.msdk.foundation.entity.CampaignUnit;
import com.startapp.simple.bloomfilter.codec.IOUtils;
import com.vungle.ads.VungleAds;
import com.vungle.ads.internal.model.g;
import com.vungle.ads.internal.model.i;
import com.vungle.ads.internal.protos.Sdk$MetricBatch;
import com.vungle.ads.internal.protos.Sdk$SDKError;
import com.vungle.ads.internal.protos.Sdk$SDKErrorBatch;
import com.vungle.ads.internal.protos.Sdk$SDKMetric;
import com.vungle.ads.o;
import com.vungle.ads.x1;
import fe.a0;
import fe.b0;
import fe.c0;
import fe.d0;
import fe.e0;
import fe.w;
import fe.x;
import fe.z;
import ha.l0;
import ia.p;
import java.io.IOException;
import java.net.Proxy;
import java.net.ProxySelector;
import java.net.SocketAddress;
import java.net.URI;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.ConcurrentHashMap;
import kotlin.jvm.internal.m0;
import kotlin.jvm.internal.s;
import kotlin.jvm.internal.u;
import ue.o;

public final class m {
    private static final String BASE_URL;
    public static final b Companion;
    private static final String MANUFACTURER_AMAZON = "Amazon";
    private static final String TAG = "VungleApiClient";
    private static VungleAds.WrapperFramework WRAPPER_FRAMEWORK_SELECTED;
    private static String headerUa;
    private static final kotlinx.serialization.json.a json;
    private static final Set<w> logInterceptors;
    private static final Set<w> networkInterceptors;
    private VungleApi api;
    private com.vungle.ads.internal.model.d appBody;
    private String appSetId;
    private final Context applicationContext;
    private com.vungle.ads.internal.model.i baseDeviceInfo;
    private final aa.b filePreferences;
    private VungleApi gzipApi;
    private Boolean isGooglePlayServicesAvailable;
    private final com.vungle.ads.internal.platform.d platform;
    private w responseInterceptor;
    private Map<String, Long> retryAfterDataMap;
    private String uaString;

    static final class a extends u implements ta.l {
        public static final a INSTANCE = new a();

        a() {
            super(1);
        }

        @Override
        public Object invoke(Object obj) {
            invoke((kotlinx.serialization.json.d) obj);
            return l0.a;
        }

        public final void invoke(kotlinx.serialization.json.d Json) {
            s.f(Json, "$this$Json");
            Json.f(true);
            Json.d(true);
            Json.e(false);
        }
    }

    public static final class b {
        private b() {
        }

        public b(kotlin.jvm.internal.k kVar) {
            this();
        }

        public final String defaultHeader() {
            StringBuilder sb = new StringBuilder();
            sb.append(s.a("Amazon", Build.MANUFACTURER) ? "VungleAmazon/" : "VungleDroid/");
            sb.append(BuildConfig.ADAPTER_VERSION);
            return sb.toString();
        }

        public final String getBASE_URL$vungle_ads_release() {
            return m.BASE_URL;
        }

        public final String getHeaderUa() {
            return m.headerUa;
        }

        public final VungleAds.WrapperFramework getWRAPPER_FRAMEWORK_SELECTED$vungle_ads_release() {
            return m.WRAPPER_FRAMEWORK_SELECTED;
        }

        public final void reset$vungle_ads_release() {
            setWRAPPER_FRAMEWORK_SELECTED$vungle_ads_release(null);
            setHeaderUa(defaultHeader());
        }

        public final void setHeaderUa(String str) {
            s.f(str, "<set-?>");
            m.headerUa = str;
        }

        public final void setWRAPPER_FRAMEWORK_SELECTED$vungle_ads_release(VungleAds.WrapperFramework wrapperFramework) {
            m.WRAPPER_FRAMEWORK_SELECTED = wrapperFramework;
        }
    }

    public static final class c implements w {
        private static final String CONTENT_ENCODING = "Content-Encoding";
        public static final a Companion = new a(null);
        private static final String GZIP = "gzip";

        public static final class a {
            private a() {
            }

            public a(kotlin.jvm.internal.k kVar) {
                this();
            }
        }

        public static final class b extends c0 {
            final ue.c $output;
            final c0 $requestBody;

            b(c0 c0Var, ue.c cVar) {
                this.$requestBody = c0Var;
                this.$output = cVar;
            }

            public long contentLength() {
                return this.$output.H();
            }

            public x contentType() {
                return this.$requestBody.contentType();
            }

            public void writeTo(ue.d sink) throws IOException {
                s.f(sink, "sink");
                sink.M(this.$output.S());
            }
        }

        private final c0 gzip(c0 c0Var) throws IOException {
            ue.c cVar = new ue.c();
            ue.d c = o.c(new ue.k(cVar));
            c0Var.writeTo(c);
            c.close();
            return new b(c0Var, cVar);
        }

        public d0 intercept(w.a chain) throws IOException {
            s.f(chain, "chain");
            b0 request = chain.request();
            c0 a2 = request.a();
            return (a2 == null || request.d(CONTENT_ENCODING) != null) ? chain.a(request) : chain.a(request.i().g(CONTENT_ENCODING, GZIP).i(request.h(), gzip(a2)).b());
        }
    }

    public static final class d extends ProxySelector {
        d() {
        }

        @Override
        public void connectFailed(URI uri, SocketAddress socketAddress, IOException iOException) {
            try {
                ProxySelector.getDefault().connectFailed(uri, socketAddress, iOException);
            } catch (Exception unused) {
            }
        }

        @Override
        public List<Proxy> select(URI uri) {
            try {
                List<Proxy> select = ProxySelector.getDefault().select(uri);
                s.e(select, "{\n                      …ri)\n                    }");
                return select;
            } catch (Exception unused) {
                return p.e(Proxy.NO_PROXY);
            }
        }
    }

    public static final class e implements androidx.core.util.a {
        final x1 $uaMetric;
        final m this$0;

        e(x1 x1Var, m mVar) {
            this.$uaMetric = x1Var;
            this.this$0 = mVar;
        }

        public void accept(String str) {
            if (str == null) {
                Log.e(m.TAG, "Cannot Get UserAgent. Setting Default Device UserAgent");
                com.vungle.ads.o.INSTANCE.logError$vungle_ads_release(7, "Fail to get user agent.", (r13 & 4) != 0 ? null : null, (r13 & 8) != 0 ? null : null, (r13 & 16) != 0 ? null : null);
            } else {
                this.$uaMetric.markEnd();
                com.vungle.ads.o.INSTANCE.logMetric$vungle_ads_release(this.$uaMetric.getMetricType(), (r15 & 2) != 0 ? 0L : this.$uaMetric.calculateIntervalDuration(), (r15 & 4) != 0 ? null : null, (r15 & 8) != 0 ? null : null, (r15 & 16) != 0 ? null : null, (r15 & 32) == 0 ? null : null);
                this.this$0.uaString = str;
            }
        }
    }

    public static final class f implements com.vungle.ads.internal.network.b {
        final o.b $requestListener;

        f(o.b bVar) {
            this.$requestListener = bVar;
        }

        @Override
        public void onFailure(com.vungle.ads.internal.network.a aVar, Throwable th) {
            this.$requestListener.onFailure();
        }

        @Override
        public void onResponse(com.vungle.ads.internal.network.a aVar, com.vungle.ads.internal.network.d dVar) {
            this.$requestListener.onSuccess();
        }
    }

    public static final class g implements com.vungle.ads.internal.network.b {
        final o.b $requestListener;

        g(o.b bVar) {
            this.$requestListener = bVar;
        }

        @Override
        public void onFailure(com.vungle.ads.internal.network.a aVar, Throwable th) {
            this.$requestListener.onFailure();
        }

        @Override
        public void onResponse(com.vungle.ads.internal.network.a aVar, com.vungle.ads.internal.network.d dVar) {
            this.$requestListener.onSuccess();
        }
    }

    static {
        b bVar = new b(null);
        Companion = bVar;
        BASE_URL = "https://config.ads.vungle.com/";
        headerUa = bVar.defaultHeader();
        networkInterceptors = new HashSet();
        logInterceptors = new HashSet();
        json = kotlinx.serialization.json.o.b((kotlinx.serialization.json.a) null, a.INSTANCE, 1, (Object) null);
    }

    public m(Context applicationContext, com.vungle.ads.internal.platform.d platform, aa.b filePreferences) {
        s.f(applicationContext, "applicationContext");
        s.f(platform, "platform");
        s.f(filePreferences, "filePreferences");
        this.applicationContext = applicationContext;
        this.platform = platform;
        this.filePreferences = filePreferences;
        this.uaString = System.getProperty("http.agent");
        this.appSetId = "";
        this.retryAfterDataMap = new ConcurrentHashMap();
        this.responseInterceptor = new w() {
            public final d0 intercept(w.a aVar) {
                d0 m106responseInterceptor$lambda0;
                m106responseInterceptor$lambda0 = m.m106responseInterceptor$lambda0(m.this, aVar);
                return m106responseInterceptor$lambda0;
            }
        };
        z.a K = new z.a().a(this.responseInterceptor).K(new d());
        z b2 = K.b();
        z b3 = K.a(new c()).b();
        this.api = new n(b2);
        this.gzipApi = new n(b3);
    }

    private final String bodyToString(c0 c0Var) {
        try {
            ue.c cVar = new ue.c();
            if (c0Var == null) {
                return "";
            }
            c0Var.writeTo(cVar);
            return cVar.readUtf8();
        } catch (Exception unused) {
            return "";
        }
    }

    private final d0 defaultErrorResponse(b0 b0Var) {
        return new d0.a().s(b0Var).g(500).q(a0.d).n("Server is busy").b(e0.Companion.e("{\"Error\":\"Server is busy\"}", x.e.b("application/json; charset=utf-8"))).c();
    }

    public static void getAppBody$vungle_ads_release$annotations() {
    }

    private final com.vungle.ads.internal.model.i getBasicDeviceBody(Context context) {
        DisplayMetrics displayMetrics = new DisplayMetrics();
        Object systemService = context.getSystemService("window");
        s.d(systemService, "null cannot be cast to non-null type android.view.WindowManager");
        Display defaultDisplay = ((WindowManager) systemService).getDefaultDisplay();
        if (defaultDisplay != null) {
            defaultDisplay.getMetrics(displayMetrics);
        }
        String MANUFACTURER = Build.MANUFACTURER;
        s.e(MANUFACTURER, "MANUFACTURER");
        String MODEL = Build.MODEL;
        s.e(MODEL, "MODEL");
        String RELEASE = Build.VERSION.RELEASE;
        s.e(RELEASE, "RELEASE");
        Object systemService2 = context.getSystemService("phone");
        s.d(systemService2, "null cannot be cast to non-null type android.telephony.TelephonyManager");
        com.vungle.ads.internal.model.i iVar = new com.vungle.ads.internal.model.i(MANUFACTURER, MODEL, RELEASE, ((TelephonyManager) systemService2).getNetworkOperatorName(), s.a("Amazon", MANUFACTURER) ? "amazon" : "android", displayMetrics.widthPixels, displayMetrics.heightPixels, this.uaString, (String) null, (Integer) null, (i.e) null, 1792, (kotlin.jvm.internal.k) null);
        try {
            String userAgent = this.platform.getUserAgent();
            this.uaString = userAgent;
            iVar.setUa(userAgent);
            initUserAgentLazy();
        } catch (Exception e2) {
            Log.e(TAG, "Cannot Get UserAgent. Setting Default Device UserAgent." + e2.getLocalizedMessage());
        }
        return iVar;
    }

    private final String getConnectionType() {
        if (androidx.core.content.e.a(this.applicationContext, "android.permission.ACCESS_NETWORK_STATE") != 0) {
            return null;
        }
        Object systemService = this.applicationContext.getSystemService("connectivity");
        s.d(systemService, "null cannot be cast to non-null type android.net.ConnectivityManager");
        NetworkInfo activeNetworkInfo = ((ConnectivityManager) systemService).getActiveNetworkInfo();
        if (activeNetworkInfo == null) {
            return "NONE";
        }
        int type = activeNetworkInfo.getType();
        return type != 0 ? (type == 1 || type == 6) ? "WIFI" : type != 7 ? type != 9 ? "UNKNOWN" : "ETHERNET" : "BLUETOOTH" : "MOBILE";
    }

    private final String getConnectionTypeDetail(int i) {
        if (i == 0) {
            return "unknown";
        }
        if (i == 1) {
            return "gprs";
        }
        if (i == 2) {
            return "edge";
        }
        if (i == 20) {
            return "unknown";
        }
        switch (i) {
            case 4:
                break;
            case 5:
                break;
            case 6:
                break;
            case 7:
                break;
            case 8:
                break;
            case 9:
                break;
            default:
                switch (i) {
                }
        }
        return "unknown";
    }

    private final com.vungle.ads.internal.model.i getDeviceBody() throws IllegalStateException {
        return getDeviceBody$vungle_ads_release(false);
    }

    private final com.vungle.ads.internal.model.g.f getExtBody() {
        throw new UnsupportedOperationException("Method not decompiled: com.vungle.ads.internal.network.m.getExtBody():com.vungle.ads.internal.model.g$f");
    }

    public static void getGzipApi$vungle_ads_release$annotations() {
    }

    private final String getPlacementID(c0 c0Var) {
        List<String> placements;
        try {
            kotlinx.serialization.json.a aVar = json;
            String bodyToString = bodyToString(c0Var);
            yd.b b2 = yd.l.b(aVar.a(), m0.k(com.vungle.ads.internal.model.g.class));
            s.d(b2, "null cannot be cast to non-null type kotlinx.serialization.KSerializer<T of kotlinx.serialization.internal.Platform_commonKt.cast>");
            g.C0088g request = ((com.vungle.ads.internal.model.g) aVar.c(b2, bodyToString)).getRequest();
            if (request == null || (placements = request.getPlacements()) == null) {
                return "";
            }
            String str = placements.get(0);
            return str == null ? "" : str;
        } catch (Exception unused) {
            return "";
        }
    }

    public static void getResponseInterceptor$vungle_ads_release$annotations() {
    }

    public static void getRetryAfterDataMap$vungle_ads_release$annotations() {
    }

    private final g.h getUserBody() {
        g.h hVar = new g.h((g.e) null, (g.b) null, (g.c) null, 7, (kotlin.jvm.internal.k) null);
        ba.c cVar = ba.c.INSTANCE;
        hVar.setGdpr(new g.e(cVar.getConsentStatus(), cVar.getConsentSource(), cVar.getConsentTimestamp(), cVar.getConsentMessageVersion()));
        hVar.setCcpa(new g.b(cVar.getCcpaStatus()));
        if (cVar.getCoppaStatus() != ba.a.COPPA_NOTSET) {
            hVar.setCoppa(new g.c(cVar.getCoppaStatus().getValue()));
        }
        return hVar;
    }

    private final void initUserAgentLazy() {
        x1 x1Var = new x1(Sdk$SDKMetric.b.USER_AGENT_LOAD_DURATION_MS);
        x1Var.markStart();
        this.platform.getUserAgentLazy(new e(x1Var, this));
    }

    public static final d0 m106responseInterceptor$lambda0(m this$0, w.a chain) {
        s.f(this$0, "this$0");
        s.f(chain, "chain");
        b0 request = chain.request();
        try {
            try {
                d0 a2 = chain.a(request);
                String b2 = a2.n().b("Retry-After");
                boolean z = true;
                if (b2 == null || b2.length() == 0) {
                    return a2;
                }
                try {
                    long parseLong = Long.parseLong(b2);
                    if (parseLong <= 0) {
                        return a2;
                    }
                    String d2 = request.k().d();
                    long currentTimeMillis = (parseLong * 1000) + System.currentTimeMillis();
                    if (!ld.m.s(d2, CampaignUnit.JSON_KEY_ADS, false, 2, (Object) null)) {
                        return a2;
                    }
                    String placementID = this$0.getPlacementID(request.a());
                    if (placementID.length() <= 0) {
                        z = false;
                    }
                    if (!z) {
                        return a2;
                    }
                    this$0.retryAfterDataMap.put(placementID, Long.valueOf(currentTimeMillis));
                    return a2;
                } catch (Exception unused) {
                    Log.d(TAG, "Retry-After value is not an valid value");
                    return a2;
                }
            } catch (Exception e2) {
                com.vungle.ads.internal.util.k.Companion.e(TAG, "Exception: " + e2.getMessage() + " for " + request.k());
                return this$0.defaultErrorResponse(request);
            }
        } catch (OutOfMemoryError unused2) {
            com.vungle.ads.internal.util.k.Companion.e(TAG, "OOM for " + request.k());
            return this$0.defaultErrorResponse(request);
        }
    }

    public final void addPlaySvcAvailabilityInCookie(boolean z) {
        this.filePreferences.put("isPlaySvcAvailable", z).apply();
    }

    public final boolean checkIsRetryAfterActive(String placementID) {
        s.f(placementID, "placementID");
        Long l = this.retryAfterDataMap.get(placementID);
        if ((l != null ? l.longValue() : 0L) > System.currentTimeMillis()) {
            return true;
        }
        this.retryAfterDataMap.remove(placementID);
        return false;
    }

    public final com.vungle.ads.internal.network.a config() throws IOException {
        com.vungle.ads.internal.model.d dVar = this.appBody;
        if (dVar == null) {
            return null;
        }
        com.vungle.ads.internal.model.g gVar = new com.vungle.ads.internal.model.g(getDeviceBody$vungle_ads_release(true), dVar, getUserBody(), (g.f) null, (g.C0088g) null, 24, (kotlin.jvm.internal.k) null);
        g.f extBody = getExtBody();
        if (extBody != null) {
            gVar.setExt(extBody);
        }
        com.vungle.ads.internal.util.h hVar = com.vungle.ads.internal.util.h.INSTANCE;
        String str = BASE_URL;
        if (!hVar.isValidUrl(str)) {
            str = "https://config.ads.vungle.com/";
        }
        if (!ld.m.s(str, "/", false, 2, (Object) null)) {
            str = str + IOUtils.DIR_SEPARATOR_UNIX;
        }
        return this.api.config(headerUa, str + "config", gVar);
    }

    public final com.vungle.ads.internal.model.d getAppBody$vungle_ads_release() {
        return this.appBody;
    }

    public final synchronized com.vungle.ads.internal.model.i getDeviceBody$vungle_ads_release(boolean r15) throws java.lang.IllegalStateException {
        throw new UnsupportedOperationException("Method not decompiled: com.vungle.ads.internal.network.m.getDeviceBody$vungle_ads_release(boolean):com.vungle.ads.internal.model.i");
    }

    public final VungleApi getGzipApi$vungle_ads_release() {
        return this.gzipApi;
    }

    public final Boolean getPlayServicesAvailabilityFromAPI() {
        Boolean bool = null;
        try {
            GoogleApiAvailabilityLight googleApiAvailabilityLight = GoogleApiAvailabilityLight.getInstance();
            s.e(googleApiAvailabilityLight, "getInstance()");
            bool = Boolean.valueOf(googleApiAvailabilityLight.isGooglePlayServicesAvailable(this.applicationContext) == 0);
            addPlaySvcAvailabilityInCookie(bool.booleanValue());
            return bool;
        } catch (Exception unused) {
            Log.w(TAG, "Unexpected exception from Play services lib.");
            return bool;
        } catch (NoClassDefFoundError unused2) {
            Log.w(TAG, "Play services Not available");
            Boolean bool2 = Boolean.FALSE;
            try {
                addPlaySvcAvailabilityInCookie(false);
                return bool2;
            } catch (Exception unused3) {
                Log.w(TAG, "Failure to write GPS availability to DB");
                return bool2;
            }
        }
    }

    public final Boolean getPlayServicesAvailabilityFromCookie() {
        return this.filePreferences.getBoolean("isPlaySvcAvailable");
    }

    public final w getResponseInterceptor$vungle_ads_release() {
        return this.responseInterceptor;
    }

    public final Map<String, Long> getRetryAfterDataMap$vungle_ads_release() {
        return this.retryAfterDataMap;
    }

    public final long getRetryAfterHeaderValue(String placementID) {
        s.f(placementID, "placementID");
        Long l = this.retryAfterDataMap.get(placementID);
        if (l != null) {
            return l.longValue();
        }
        return 0L;
    }

    public final synchronized void initialize(String appId) {
        PackageInfo packageInfo;
        PackageManager.PackageInfoFlags of;
        s.f(appId, "appId");
        this.api.setAppId(appId);
        this.gzipApi.setAppId(appId);
        String str = "1.0";
        try {
            if (Build.VERSION.SDK_INT >= 33) {
                PackageManager packageManager = this.applicationContext.getPackageManager();
                String packageName = this.applicationContext.getPackageName();
                of = PackageManager.PackageInfoFlags.of(0L);
                packageInfo = packageManager.getPackageInfo(packageName, of);
                s.e(packageInfo, "{\n                    ap…      )\n                }");
            } else {
                packageInfo = this.applicationContext.getPackageManager().getPackageInfo(this.applicationContext.getPackageName(), 0);
                s.e(packageInfo, "{\n                    ap…      )\n                }");
            }
            String str2 = packageInfo.versionName;
            s.e(str2, "packageInfo.versionName");
            str = str2;
        } catch (Exception unused) {
        }
        this.baseDeviceInfo = getBasicDeviceBody(this.applicationContext);
        String packageName2 = this.applicationContext.getPackageName();
        s.e(packageName2, "applicationContext.packageName");
        this.appBody = new com.vungle.ads.internal.model.d(packageName2, str, appId);
        this.isGooglePlayServicesAvailable = getPlayServicesAvailabilityFromAPI();
    }

    public final Boolean isGooglePlayServicesAvailable() {
        if (this.isGooglePlayServicesAvailable == null) {
            this.isGooglePlayServicesAvailable = getPlayServicesAvailabilityFromCookie();
        }
        if (this.isGooglePlayServicesAvailable == null) {
            this.isGooglePlayServicesAvailable = getPlayServicesAvailabilityFromAPI();
        }
        return this.isGooglePlayServicesAvailable;
    }

    public final com.vungle.ads.internal.load.d.b pingTPAT(java.lang.String r18) {
        throw new UnsupportedOperationException("Method not decompiled: com.vungle.ads.internal.network.m.pingTPAT(java.lang.String):com.vungle.ads.internal.load.d$b");
    }

    public final void reportErrors(BlockingQueue<Sdk$SDKError.a> errors, o.b requestListener) {
        s.f(errors, "errors");
        s.f(requestListener, "requestListener");
        String errorLoggingEndpoint = com.vungle.ads.internal.c.INSTANCE.getErrorLoggingEndpoint();
        if (errorLoggingEndpoint == null || errorLoggingEndpoint.length() == 0) {
            requestListener.onFailure();
            return;
        }
        for (Sdk$SDKError.a aVar : errors) {
            String connectionType = getConnectionType();
            if (connectionType != null) {
                aVar.setConnectionType(connectionType);
            }
            String connectionTypeDetail = getConnectionTypeDetail();
            if (connectionTypeDetail != null) {
                aVar.setConnectionTypeDetail(connectionTypeDetail);
                aVar.setConnectionTypeDetailAndroid(connectionTypeDetail);
            }
        }
        ArrayList arrayList = new ArrayList();
        Iterator<Sdk$SDKError.a> it = errors.iterator();
        while (it.hasNext()) {
            arrayList.add(it.next().build());
        }
        Sdk$SDKErrorBatch sdk$SDKErrorBatch = (Sdk$SDKErrorBatch) Sdk$SDKErrorBatch.newBuilder().addAllErrors(arrayList).build();
        c0.a aVar2 = c0.Companion;
        byte[] byteArray = sdk$SDKErrorBatch.toByteArray();
        s.e(byteArray, "batch.toByteArray()");
        this.api.sendErrors(headerUa, errorLoggingEndpoint, aVar2.m(byteArray, x.e.b("application/x-protobuf"), 0, sdk$SDKErrorBatch.toByteArray().length)).enqueue(new f(requestListener));
    }

    public final void reportMetrics(BlockingQueue<Sdk$SDKMetric.a> metrics, o.b requestListener) {
        s.f(metrics, "metrics");
        s.f(requestListener, "requestListener");
        String metricsEndpoint = com.vungle.ads.internal.c.INSTANCE.getMetricsEndpoint();
        if (metricsEndpoint == null || metricsEndpoint.length() == 0) {
            requestListener.onFailure();
            return;
        }
        for (Sdk$SDKMetric.a aVar : metrics) {
            String connectionType = getConnectionType();
            if (connectionType != null) {
                aVar.setConnectionType(connectionType);
            }
            String connectionTypeDetail = getConnectionTypeDetail();
            if (connectionTypeDetail != null) {
                aVar.setConnectionTypeDetail(connectionTypeDetail);
            }
        }
        ArrayList arrayList = new ArrayList();
        Iterator<Sdk$SDKMetric.a> it = metrics.iterator();
        while (it.hasNext()) {
            arrayList.add(it.next().build());
        }
        Sdk$MetricBatch sdk$MetricBatch = (Sdk$MetricBatch) Sdk$MetricBatch.newBuilder().addAllMetrics(arrayList).build();
        c0.a aVar2 = c0.Companion;
        x b2 = x.e.b("application/x-protobuf");
        byte[] byteArray = sdk$MetricBatch.toByteArray();
        s.e(byteArray, "batch.toByteArray()");
        this.api.sendMetrics(headerUa, metricsEndpoint, c0.a.n(aVar2, b2, byteArray, 0, 0, 12, (Object) null)).enqueue(new g(requestListener));
    }

    public final com.vungle.ads.internal.network.a requestAd(String placement, String str, boolean z) throws IllegalStateException {
        s.f(placement, "placement");
        String adsEndpoint = com.vungle.ads.internal.c.INSTANCE.getAdsEndpoint();
        if (adsEndpoint == null || adsEndpoint.length() == 0) {
            return null;
        }
        com.vungle.ads.internal.model.g requestBody = requestBody();
        g.C0088g c0088g = new g.C0088g(p.e(placement), Boolean.valueOf(z), (String) null, (Long) null, (String) null, (String) null, (String) null, 124, (kotlin.jvm.internal.k) null);
        if (!(str == null || str.length() == 0)) {
            c0088g.setAdSize(str);
        }
        requestBody.setRequest(c0088g);
        return this.gzipApi.ads(headerUa, adsEndpoint, requestBody);
    }

    public final com.vungle.ads.internal.model.g requestBody() throws IllegalStateException {
        com.vungle.ads.internal.model.g gVar = new com.vungle.ads.internal.model.g(getDeviceBody(), this.appBody, getUserBody(), (g.f) null, (g.C0088g) null, 24, (kotlin.jvm.internal.k) null);
        g.f extBody = getExtBody();
        if (extBody != null) {
            gVar.setExt(extBody);
        }
        return gVar;
    }

    public final com.vungle.ads.internal.network.a ri(g.C0088g request) {
        com.vungle.ads.internal.model.d dVar;
        s.f(request, "request");
        String riEndpoint = com.vungle.ads.internal.c.INSTANCE.getRiEndpoint();
        if ((riEndpoint == null || riEndpoint.length() == 0) || (dVar = this.appBody) == null) {
            return null;
        }
        com.vungle.ads.internal.model.g gVar = new com.vungle.ads.internal.model.g(getDeviceBody(), dVar, getUserBody(), (g.f) null, (g.C0088g) null, 24, (kotlin.jvm.internal.k) null);
        gVar.setRequest(request);
        g.f extBody = getExtBody();
        if (extBody != null) {
            gVar.setExt(extBody);
        }
        return this.api.ri(headerUa, riEndpoint, gVar);
    }

    public final void setAppBody$vungle_ads_release(com.vungle.ads.internal.model.d dVar) {
        this.appBody = dVar;
    }

    public final void setGzipApi$vungle_ads_release(VungleApi vungleApi) {
        s.f(vungleApi, "<set-?>");
        this.gzipApi = vungleApi;
    }

    public final void setResponseInterceptor$vungle_ads_release(w wVar) {
        s.f(wVar, "<set-?>");
        this.responseInterceptor = wVar;
    }

    public final void setRetryAfterDataMap$vungle_ads_release(Map<String, Long> map) {
        s.f(map, "<set-?>");
        this.retryAfterDataMap = map;
    }

    private final String getConnectionTypeDetail() {
        if (androidx.core.content.e.a(this.applicationContext, "android.permission.ACCESS_NETWORK_STATE") != 0) {
            return null;
        }
        Object systemService = this.applicationContext.getSystemService("connectivity");
        s.d(systemService, "null cannot be cast to non-null type android.net.ConnectivityManager");
        NetworkInfo activeNetworkInfo = ((ConnectivityManager) systemService).getActiveNetworkInfo();
        return activeNetworkInfo != null ? getConnectionTypeDetail(activeNetworkInfo.getSubtype()) : "unknown";
    }
}