package com.ss.android.common.util;

import X.0Gz;
import X.0H0;
import X.2FV;
import X.2He;
import X.2K7;
import X.2kf;
import X.32q;
import X.32r;
import X.3GY;
import X.3Tp;
import X.3XD;
import X.4N2;
import X.AnonymousClass7lW;
import X.C08347s1;
import X.C18518Kc;
import X.C24258ca;
import X.C28338jA;
import X.C30578mm;
import X.C30738n2;
import X.C31968p1;
import X.C31988p3;
import X.C31998p4;
import X.C32658q8;
import X.C33198r0;
import X.C33208r1;
import X.C49409c3;
import X.C49419c4;
import X.C49439c6;
import X.C49449c7;
import X.C49459c8;
import X.C49469c9;
import X.C49489cB;
import X.C49509cD;
import X.C49529cF;
import X.C49539cG;
import X.C49549cH;
import X.C49559cI;
import X.C49569cJ;
import X.C49579cK;
import X.C49629cP;
import X.C49669cT;
import X.C49769cd;
import X.EV0;
import X.Tet;
import X.Tew;
import android.content.ClipboardManager;
import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.Uri;
import android.os.Build;
import android.os.Handler;
import android.os.Looper;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import android.util.Pair;
import android.webkit.CookieManager;
import com.bytedance.covode.number.Covode;
import com.bytedance.frameworks.apm.trace.MethodCollector;
import com.bytedance.ies.abmock.SettingsManager;
import com.ss.android.ugc.aweme.legoImp.NetWorkInjectImpl;
import java.io.ByteArrayOutputStream;
import java.io.Closeable;
import java.io.EOFException;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.Field;
import java.net.URLConnection;
import java.security.GeneralSecurityException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.zip.Deflater;
import java.util.zip.GZIPInputStream;
import java.util.zip.GZIPOutputStream;
import javax.net.ssl.SSLException;
import org.apache.http.client.RedirectHandler;
import org.apache.http.params.HttpParams;
import org.json.JSONArray;
import org.json.JSONObject;

public class NetworkUtils {
    public static int isForceHttps = 1;
    public static volatile boolean mAllowKeepAlive = true;
    public static volatile long mLocalTime = -1;
    public static volatile long mServerTime = -1;
    public static C49459c8 sApiInterceptor;
    public static C49549cH sApiLibSelector;
    public static C49669cT sCommandListener;
    public static final Object sCookieLock = new Object();
    public static volatile boolean sCookieMgrInited = false;
    public static volatile boolean sHasRebuildSsl = false;
    public static C49419c4 sMonitorProcessHook;
    public static ArrayList<String> sNoHttpList = new ArrayList<>();
    public static volatile C49539cG sServerTimeFromResponse;
    public static String sShareCookieHost;
    public static volatile int sUseDnsMapping = -1;
    public static String sUserAgent = null;

    public static int com_ss_android_common_util_NetworkUtils_android_telephony_TelephonyManager_getNetworkType(TelephonyManager telephonyManager) {
        3GY.LIZ(102013);
        TelephonyManager telephonyManager2 = telephonyManager;
        Pair LIZ = 3GY.LIZ((Object) null, telephonyManager2, new Object[0], 102013, "int", false, -520854456, 2);
        return ((Boolean) LIZ.first).booleanValue() ? ((Integer) LIZ.second).intValue() : telephonyManager2.getNetworkType();
    }

    public static String com_ss_android_common_util_NetworkUtils_com_ss_android_ugc_aweme_feed_lancet_NetworkUtilsLancet_filterUrl(String str) {
        return str;
    }

    public static void com_ss_android_common_util_NetworkUtils_com_ss_android_ugc_aweme_net_lancet_ServerTimeLancet_handleTimeStampFromResponse(String str) {
    }

    public static String filterUrl(String str) {
        com_ss_android_common_util_NetworkUtils_com_ss_android_ugc_aweme_feed_lancet_NetworkUtilsLancet_filterUrl(str);
        return str;
    }

    public static int getServerTime() {
        return com_ss_android_common_util_NetworkUtils_com_ss_android_ugc_aweme_net_lancet_ServerTimeLancet_getServerTime();
    }

    public static void handleTimeStampFromResponse(String str) {
        com_ss_android_common_util_NetworkUtils_com_ss_android_ugc_aweme_net_lancet_ServerTimeLancet_handleTimeStampFromResponse(str);
    }

    public static boolean getAllowKeepAlive() {
        return mAllowKeepAlive;
    }

    public static C49459c8 getApiRequestInterceptor() {
        return sApiInterceptor;
    }

    public static C49669cT getCommandListener() {
        return sCommandListener;
    }

    public static boolean getHasRebuildSsl() {
        return sHasRebuildSsl;
    }

    public static int getIsForceHttps() {
        return isForceHttps;
    }

    public static String getShareCookieHost() {
        return sShareCookieHost;
    }

    public static String executeGet(int i, String str) {
        return executeGet(0, i, str, true, true);
    }

    public static String executeGet(int i, String str, int i2, int i3) {
        return executeGet(0, i, str, true, true, (List<C49529cF>) null, (EV0) null, true);
    }

    public static String executeGet(int i, String str, boolean z) {
        return executeGet(0, i, str, z, true);
    }

    public static String executeGet(int i, String str, boolean z, boolean z2) {
        return executeGet(0, i, str, z, z2, (List<C49529cF>) null, (EV0) null, true);
    }

    public static String executeGet(int i, String str, boolean z, boolean z2, List<C49529cF> list, EV0 ev0, boolean z3) {
        return executeGet(0, i, str, z, z2, list, ev0, z3);
    }

    public static String executeGet(int i, String str, List<Tet> list) {
        return executeGet(0, i, str, true, true, list);
    }

    public static String executeGet(int i, String str, int i2, int i3, List<Tet> list) {
        return executeGet(0, i, str, true, true, (List<C49529cF>) null, (EV0) null, true, list);
    }

    public static String executeGet(int i, String str, boolean z, List<Tet> list) {
        return executeGet(0, i, str, z, true, list);
    }

    public static String executeGet(int i, String str, boolean z, boolean z2, List<Tet> list) {
        return executeGet(0, i, str, z, z2, (List<C49529cF>) null, (EV0) null, true, list);
    }

    public static String executeGet(int i, String str, boolean z, boolean z2, List<C49529cF> list, EV0 ev0, boolean z3, List<Tet> list2) {
        return executeGet(0, i, str, z, z2, list, ev0, z3, list2);
    }

    public static String executeGet(int i, int i2, String str, boolean z, boolean z2, List<C49529cF> list, EV0 ev0, boolean z3, List<Tet> list2) {
        EV0 ev02 = ev0;
        List<C49529cF> list3 = list;
        boolean z4 = z3;
        int i3 = i;
        List<Tet> list4 = list2;
        int i4 = i2;
        boolean z5 = z;
        boolean z6 = z2;
        try {
            filterUrl(str);
            return executeGetRetry(i3, i4, addGetRetryCountParam(str, "no_retry"), z5, list3, ev02, z4, list4, z6);
        } catch (Exception e) {
            if (TextUtils.isEmpty(str) || !str.startsWith("https") || (!(e instanceof SSLException) && !(e instanceof GeneralSecurityException))) {
                filterUrl(str);
                return executeGetRetry(i3, i4, addGetRetryCountParam(str, "first_retry"), z5, list3, ev02, z4, list4, z6);
            } else if (!isHitNoHttpList(str)) {
                return executeGetRetry(i3, i4, addGetRetryCountParam(str, "retry_http"), z5, list3, ev02, z4, list4, z6);
            } else {
                filterUrl(str);
                return executeGetRetry(i3, i4, addGetRetryCountParam(str, "first_retry"), z5, list3, ev02, z4, list4, z6);
            }
        }
    }

    public static String executePost(int i, String str, List<Tet> list, C49769cd[] r4) {
        return executePost(0, i, str, list, r4);
    }

    public static String executePost(String str, JSONObject jSONObject, String str2, List<C49529cF> list) {
        byte[] bytes;
        String str3 = str2;
        List<C49529cF> list2 = list;
        String str4 = str;
        if (str3 == null || !str3.startsWith("application/json")) {
            ArrayList arrayList = new ArrayList();
            jsonObjectToBasicNameValuePairs(arrayList, jSONObject, "");
            return executePost(0, 0, str4, (List<Tet>) arrayList, (C49769cd[]) null, list2);
        }
        if (jSONObject == null) {
            bytes = null;
        } else {
            bytes = jSONObject.toString().getBytes("UTF-8");
        }
        return executePost(-1, str4, bytes, C24258ca.GZIP, str3, list2);
    }

    public static String executePost(int i, String str, byte[] bArr, C24258ca r9, String str2) {
        return executePost(i, str, bArr, r9, str2, (List<C49529cF>) null);
    }

    public static String executePost(int i, String str, byte[] bArr, C24258ca r4, String str2, List<C49529cF> list) {
        if (str == null) {
            return null;
        }
        return execute("post", i, addCommonParams(str, true), bArr, r4, str2, list);
    }

    public static int com_ss_android_common_util_NetworkUtils_com_ss_android_ugc_aweme_net_lancet_ServerTimeLancet_getServerTime() {
        return C31968p1.LIZ();
    }

    public static boolean getUseDnsMapping() {
        if (sUseDnsMapping > 0) {
            return true;
        }
        return false;
    }

    public static String getUserAgent() {
        tryInitUserAgent();
        return sUserAgent;
    }

    public static int com_ss_android_common_util_NetworkUtils__getServerTime$___twin___() {
        return (int) (getServerTimeMills() / 1000);
    }

    public static C49469c9 getApiProcessHook() {
        return NetWorkInjectImpl.LIZLLL().LIZIZ();
    }

    public static Context getAppContext() {
        return NetWorkInjectImpl.LIZLLL().LIZ();
    }

    public static long getServerTimeMills() {
        long currentTimeMillis = System.currentTimeMillis();
        if (mServerTime > 0) {
            return (mServerTime + System.currentTimeMillis()) - mLocalTime;
        }
        return currentTimeMillis;
    }

    static {
        Covode.recordClassIndex(48263);
    }

    /* JADX WARNING: Can't wrap try/catch for region: R(5:5|6|7|8|9) */
    /* JADX WARNING: Missing exception handler attribute for start block: B:8:0x0012 */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    public static android.webkit.CookieManager tryNecessaryInit() {
        /*
            r4 = 16918(0x4216, float:2.3707E-41)
            com.bytedance.frameworks.apm.trace.MethodCollector.i(r4)
            java.lang.Object r3 = sCookieLock
            monitor-enter(r3)
            boolean r0 = sCookieMgrInited     // Catch:{ all -> 0x0031 }
            r2 = 1
            if (r0 != 0) goto L_0x0014
            r0 = 1500(0x5dc, double:7.41E-321)
            java.lang.Thread.sleep(r0)     // Catch:{ Exception -> 0x0012 }
        L_0x0012:
            sCookieMgrInited = r2     // Catch:{ all -> 0x0031 }
        L_0x0014:
            monitor-exit(r3)     // Catch:{ all -> 0x0031 }
            com.ss.android.common.util.INetWorkInject r0 = com.ss.android.ugc.aweme.legoImp.NetWorkInjectImpl.LIZLLL()
            X.9c9 r0 = r0.LIZIZ()
            r0.LIZ()
            android.webkit.CookieManager r1 = android.webkit.CookieManager.getInstance()
            boolean r0 = r1.acceptCookie()
            if (r0 != 0) goto L_0x002d
            r1.setAcceptCookie(r2)
        L_0x002d:
            com.bytedance.frameworks.apm.trace.MethodCollector.o(r4)
            return r1
        L_0x0031:
            r0 = move-exception
            monitor-exit(r3)
            com.bytedance.frameworks.apm.trace.MethodCollector.o(r4)
            throw r0
        */
        throw new UnsupportedOperationException("Method not decompiled: com.ss.android.common.util.NetworkUtils.tryNecessaryInit():android.webkit.CookieManager");
    }

    /* renamed from: com.ss.android.common.util.NetworkUtils$1  reason: invalid class name */
    public static /* synthetic */ class AnonymousClass1 {
        public static final /* synthetic */ int[] LIZ;

        /* JADX WARNING: Can't wrap try/catch for region: R(10:0|1|2|3|4|5|6|7|8|(3:9|10|12)) */
        /* JADX WARNING: Can't wrap try/catch for region: R(12:0|1|2|3|4|5|6|7|8|9|10|12) */
        /* JADX WARNING: Failed to process nested try/catch */
        /* JADX WARNING: Missing exception handler attribute for start block: B:3:0x0018 */
        /* JADX WARNING: Missing exception handler attribute for start block: B:5:0x0023 */
        /* JADX WARNING: Missing exception handler attribute for start block: B:7:0x002e */
        /* JADX WARNING: Missing exception handler attribute for start block: B:9:0x0039 */
        static {
            /*
                r0 = 48264(0xbc88, float:6.7632E-41)
                com.bytedance.covode.number.Covode.recordClassIndex(r0)
                X.9c7[] r0 = X.C49449c7.values()
                int r0 = r0.length
                int[] r2 = new int[r0]
                LIZ = r2
                X.9c7 r0 = X.C49449c7.WIFI     // Catch:{ NoSuchFieldError -> 0x0018 }
                int r1 = r0.ordinal()     // Catch:{ NoSuchFieldError -> 0x0018 }
                r0 = 1
                r2[r1] = r0     // Catch:{ NoSuchFieldError -> 0x0018 }
            L_0x0018:
                int[] r2 = LIZ     // Catch:{ NoSuchFieldError -> 0x0023 }
                X.9c7 r0 = X.C49449c7.MOBILE_2G     // Catch:{ NoSuchFieldError -> 0x0023 }
                int r1 = r0.ordinal()     // Catch:{ NoSuchFieldError -> 0x0023 }
                r0 = 2
                r2[r1] = r0     // Catch:{ NoSuchFieldError -> 0x0023 }
            L_0x0023:
                int[] r2 = LIZ     // Catch:{ NoSuchFieldError -> 0x002e }
                X.9c7 r0 = X.C49449c7.MOBILE_3G     // Catch:{ NoSuchFieldError -> 0x002e }
                int r1 = r0.ordinal()     // Catch:{ NoSuchFieldError -> 0x002e }
                r0 = 3
                r2[r1] = r0     // Catch:{ NoSuchFieldError -> 0x002e }
            L_0x002e:
                int[] r2 = LIZ     // Catch:{ NoSuchFieldError -> 0x0039 }
                X.9c7 r0 = X.C49449c7.MOBILE_4G     // Catch:{ NoSuchFieldError -> 0x0039 }
                int r1 = r0.ordinal()     // Catch:{ NoSuchFieldError -> 0x0039 }
                r0 = 4
                r2[r1] = r0     // Catch:{ NoSuchFieldError -> 0x0039 }
            L_0x0039:
                int[] r2 = LIZ     // Catch:{ NoSuchFieldError -> 0x0044 }
                X.9c7 r0 = X.C49449c7.MOBILE     // Catch:{ NoSuchFieldError -> 0x0044 }
                int r1 = r0.ordinal()     // Catch:{ NoSuchFieldError -> 0x0044 }
                r0 = 5
                r2[r1] = r0     // Catch:{ NoSuchFieldError -> 0x0044 }
            L_0x0044:
                return
            */
            throw new UnsupportedOperationException("Method not decompiled: com.ss.android.common.util.NetworkUtils.AnonymousClass1.<clinit>():void");
        }
    }

    /* JADX WARNING: Can't wrap try/catch for region: R(7:9|10|(5:12|13|(3:15|(2:19|31)(1:32)|20)|30|(1:22))|23|24|25|26) */
    /* JADX WARNING: Missing exception handler attribute for start block: B:23:0x0040 */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    public static synchronized void tryInitUserAgent() {
        /*
            java.lang.Class<com.ss.android.common.util.NetworkUtils> r8 = com.ss.android.common.util.NetworkUtils.class
            monitor-enter(r8)
            r7 = 15108(0x3b04, float:2.1171E-41)
            com.bytedance.frameworks.apm.trace.MethodCollector.i(r7)     // Catch:{ all -> 0x0047 }
            java.lang.String r0 = sUserAgent     // Catch:{ all -> 0x0047 }
            if (r0 == 0) goto L_0x0011
            com.bytedance.frameworks.apm.trace.MethodCollector.o(r7)     // Catch:{ all -> 0x0047 }
            monitor-exit(r8)
            return
        L_0x0011:
            com.ss.android.common.util.INetWorkInject r0 = com.ss.android.ugc.aweme.legoImp.NetWorkInjectImpl.LIZLLL()     // Catch:{ all -> 0x0047 }
            java.lang.String r6 = r0.LIZJ()     // Catch:{ all -> 0x0047 }
            if (r6 == 0) goto L_0x0040
            char[] r5 = r6.toCharArray()     // Catch:{ Exception -> 0x0040 }
            int r4 = r5.length     // Catch:{ Exception -> 0x0040 }
            r3 = 0
            r2 = 0
        L_0x0022:
            if (r3 >= r4) goto L_0x0038
            char r1 = r5[r3]     // Catch:{ Exception -> 0x0040 }
            r0 = 32
            if (r1 < r0) goto L_0x0030
            char r1 = r5[r3]     // Catch:{ Exception -> 0x0040 }
            r0 = 126(0x7e, float:1.77E-43)
            if (r1 <= r0) goto L_0x0035
        L_0x0030:
            r0 = 63
            r5[r3] = r0     // Catch:{ Exception -> 0x0040 }
            r2 = 1
        L_0x0035:
            int r3 = r3 + 1
            goto L_0x0022
        L_0x0038:
            if (r2 == 0) goto L_0x0040
            java.lang.String r0 = new java.lang.String     // Catch:{ Exception -> 0x0040 }
            r0.<init>(r5)     // Catch:{ Exception -> 0x0040 }
            r6 = r0
        L_0x0040:
            sUserAgent = r6     // Catch:{ all -> 0x0047 }
            com.bytedance.frameworks.apm.trace.MethodCollector.o(r7)     // Catch:{ all -> 0x0047 }
            monitor-exit(r8)
            return
        L_0x0047:
            r0 = move-exception
            monitor-exit(r8)
            throw r0
        */
        throw new UnsupportedOperationException("Method not decompiled: com.ss.android.common.util.NetworkUtils.tryInitUserAgent():void");
    }

    public static void setAllowKeepAlive(boolean z) {
        mAllowKeepAlive = z;
    }

    public static void setApiLibrarySelector(C49549cH r0) {
        sApiLibSelector = r0;
    }

    public static void setApiRequestInterceptor(C49459c8 r0) {
        sApiInterceptor = r0;
    }

    public static void setCommandListener(C49669cT r0) {
        sCommandListener = r0;
    }

    public static void setHasRebuildSsl(boolean z) {
        sHasRebuildSsl = z;
    }

    public static void setIsForceHttps(int i) {
        isForceHttps = i;
    }

    public static void setMonitorProcessHook(C49419c4 r0) {
        sMonitorProcessHook = r0;
    }

    public static void setNoHttpList(ArrayList<String> arrayList) {
        sNoHttpList = arrayList;
    }

    public static void setServerTimeFromResponse(C49539cG r0) {
        sServerTimeFromResponse = r0;
    }

    public static void setShareCookieHost(String str) {
        sShareCookieHost = str;
    }

    public static void setUseDnsMapping(int i) {
        sUseDnsMapping = i;
    }

    public static boolean isNetworkAvailable(Context context) {
        return INVOKESTATIC_com_ss_android_common_util_NetworkUtils_com_ss_android_ugc_aweme_net_lancet_NetworkLancet_isNetworkAvailable(context);
    }

    public static boolean isWifi(Context context) {
        return C32658q8.LIZ(context);
    }

    public static void safeClose(Closeable closeable) {
        safeClose(closeable, (String) null);
    }

    public static boolean INVOKESTATIC_com_ss_android_common_util_NetworkUtils_com_ss_android_ugc_aweme_net_lancet_NetworkLancet_isNetworkAvailable(Context context) {
        try {
            return 2K7.LIZ.LIZJ();
        } catch (Exception unused) {
            return false;
        }
    }

    public static Context INVOKEVIRTUAL_com_ss_android_common_util_NetworkUtils_com_ss_android_ugc_aweme_lancet_launch_ApplicationContextLancet_getApplicationContext(Context context) {
        Context applicationContext = context.getApplicationContext();
        if (AnonymousClass7lW.LIZJ && applicationContext == null) {
            return AnonymousClass7lW.LIZ;
        }
        return applicationContext;
    }

    public static NetworkInfo INVOKEVIRTUAL_com_ss_android_common_util_NetworkUtils_com_ss_android_ugc_aweme_net_lancet_ConnecttivityManagerLancet_getActiveNetworkInfo(ConnectivityManager connectivityManager) {
        try {
            return INVOKEVIRTUAL_com_ss_android_common_util_NetworkUtils_com_ss_android_ugc_aweme_lancet_process_AwemeMetaDataLancet_getActiveNetworkInfo(connectivityManager);
        } catch (Exception e) {
            2kf.LIZ(e);
            return 3XD.LIZ();
        }
    }

    public static String com_ss_android_common_util_NetworkUtils__filterUrl$___twin___(String str) {
        C49459c8 r0;
        if (!TextUtils.isEmpty(str) && (r0 = sApiInterceptor) != null) {
            return r0.LIZ();
        }
        return str;
    }

    public static String getNetworkAccessType(Context context) {
        return getNetworkAccessType(getNetworkType(context));
    }

    public static String getNetworkOperatorCode(Context context) {
        try {
            return ((TelephonyManager) INVOKEVIRTUAL_com_ss_android_common_util_NetworkUtils_com_ss_android_ugc_aweme_lancet_GetSystemServiceLancet_getSystemService(context, "phone")).getNetworkOperator();
        } catch (Exception unused) {
            return "unkown";
        }
    }

    public static List<String> getShareCookieHostList(String str) {
        C49459c8 r0 = sApiInterceptor;
        if (r0 != null) {
            return r0.LIZLLL();
        }
        return null;
    }

    public static void setTimeout(URLConnection uRLConnection) {
        if (uRLConnection != null) {
            uRLConnection.setConnectTimeout(15000);
            uRLConnection.setReadTimeout(15000);
        }
    }

    public static NetworkInfo INVOKEVIRTUAL_com_ss_android_common_util_NetworkUtils_com_ss_android_ugc_aweme_lancet_process_AwemeMetaDataLancet_getActiveNetworkInfo(ConnectivityManager connectivityManager) {
        if (C30738n2.LJIIJJI != null && C30738n2.LJIIIZ && !C30738n2.LIZ()) {
            return C30738n2.LJIIJJI;
        }
        NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
        C30738n2.LJIIJJI = activeNetworkInfo;
        return activeNetworkInfo;
    }

    public static String getEtag(EV0 ev0) {
        C49529cF LIZIZ;
        if (ev0 == null || (LIZIZ = ev0.LIZIZ("ETag")) == null) {
            return null;
        }
        return LIZIZ.LIZIZ();
    }

    public static String getLastModified(EV0 ev0) {
        C49529cF LIZIZ;
        if (ev0 == null || (LIZIZ = ev0.LIZIZ("Last-Modified")) == null) {
            return null;
        }
        return LIZIZ.LIZIZ();
    }

    public static boolean isMobile(Context context) {
        C49449c7 networkType = getNetworkType(context);
        if (C49449c7.MOBILE_2G == networkType || C49449c7.MOBILE_3G == networkType || C49449c7.MOBILE_4G == networkType || C49449c7.MOBILE == networkType) {
            return true;
        }
        return false;
    }

    public static void setUserAgent(HttpParams httpParams) {
        tryInitUserAgent();
        String str = sUserAgent;
        if (TextUtils.isEmpty(str)) {
            return;
        }
        if (httpParams != null) {
            httpParams.setParameter("http.useragent", str);
            return;
        }
        throw new IllegalArgumentException("HTTP parameters may not be null");
    }

    public static boolean testIsSSBinary(String str) {
        int indexOf;
        if (str != null && (indexOf = str.indexOf("application/octet-stream")) >= 0 && str.indexOf("ssmix=", indexOf + 24) > 0) {
            return true;
        }
        return false;
    }

    public static int INVOKEVIRTUAL_com_ss_android_common_util_NetworkUtils_com_ss_android_ugc_aweme_lancet_telephony_TelephonyManagerLancet_getNetworkType(TelephonyManager telephonyManager) {
        if (Build.VERSION.SDK_INT < 29) {
            return com_ss_android_common_util_NetworkUtils_android_telephony_TelephonyManager_getNetworkType(telephonyManager);
        }
        if (!C30578mm.LIZ.getAndSet(true)) {
            C30578mm.LIZ().LIZ();
        }
        int i = C30578mm.LIZ().LIZIZ.get();
        if (C30578mm.LIZJ || i != -1) {
            return i;
        }
        return 0;
    }

    public static long extractMaxAge(EV0 ev0) {
        C49529cF LIZIZ;
        if (ev0 == null || (LIZIZ = ev0.LIZIZ("Cache-Control")) == null) {
            return -1;
        }
        try {
            C49509cD[] LIZJ = LIZIZ.LIZJ();
            if (LIZJ != null) {
                for (C49509cD r2 : LIZJ) {
                    if ("max-age".equals(r2.LIZ())) {
                        String LIZIZ2 = r2.LIZIZ();
                        if (LIZIZ2 != null) {
                            return Long.parseLong(LIZIZ2);
                        }
                        return -1;
                    }
                }
            }
        } catch (Exception unused) {
        }
        return -1;
    }

    public static String getNetworkAccessType(C49449c7 r3) {
        try {
            int i = AnonymousClass1.LIZ[r3.ordinal()];
            if (i == 1) {
                return "wifi";
            }
            if (i == 2) {
                return "2g";
            }
            if (i == 3) {
                return "3g";
            }
            if (i == 4) {
                return "4g";
            }
            if (i != 5) {
                return "";
            }
            return "mobile";
        } catch (Exception unused) {
            return "";
        }
    }

    public static boolean isHitNoHttpList(String str) {
        ArrayList<String> arrayList;
        if (isForceHttps == 1) {
            return true;
        }
        if (!TextUtils.isEmpty(str) && (arrayList = sNoHttpList) != null && !arrayList.isEmpty()) {
            Iterator<String> it = sNoHttpList.iterator();
            while (it.hasNext()) {
                if (str.contains(it.next())) {
                    return true;
                }
            }
        }
        return false;
    }

    public static Pair<String, String> parseContentType(String str) {
        String str2 = null;
        if (str == null) {
            return null;
        }
        C49509cD[] LIZJ = new Tew("Content-Type", str).LIZJ();
        if (LIZJ.length == 0) {
            return null;
        }
        int i = 0;
        C49509cD r0 = LIZJ[0];
        String LIZ = r0.LIZ();
        32r[] LIZJ2 = r0.LIZJ();
        if (LIZJ2 != null) {
            int length = LIZJ2.length;
            while (true) {
                if (i >= length) {
                    break;
                }
                32r r2 = LIZJ2[i];
                if ("charset".equalsIgnoreCase(r2.LIZ())) {
                    str2 = r2.LIZIZ();
                    break;
                }
                i++;
            }
        }
        return new Pair<>(LIZ, str2);
    }

    public static boolean INVOKEVIRTUAL_com_ss_android_common_util_NetworkUtils_com_ss_android_ugc_aweme_storage_FileLancet_delete(File file) {
        C33208r1 r3;
        MethodCollector.i(17357);
        try {
            if (C18518Kc.LIZIZ()) {
                r3 = (C33208r1) SettingsManager.LIZ().LIZ("storage_intercepter_key", C33208r1.class, 4N2.LIZ);
            } else {
                r3 = 4N2.LIZ;
            }
            if (C33198r0.LIZ(file.getAbsolutePath(), r3)) {
                C33198r0.LIZ(file, new RuntimeException(), "exception_delete_log", C33198r0.LIZ(r3));
            }
            if (C33198r0.LIZJ(file.getAbsolutePath(), r3)) {
                C33198r0.LIZ(file, new RuntimeException(), "exception_handle", C33198r0.LIZ(r3));
                MethodCollector.o(17357);
                return false;
            }
        } catch (Throwable unused) {
        }
        boolean delete = file.delete();
        MethodCollector.o(17357);
        return delete;
    }

    public static void com_ss_android_common_util_NetworkUtils__handleTimeStampFromResponse$___twin___(String str) {
        if (!TextUtils.isEmpty(str)) {
            if (sServerTimeFromResponse != null) {
                long LIZ = sServerTimeFromResponse.LIZ(str);
                if (LIZ > 0) {
                    mServerTime = LIZ;
                    mLocalTime = System.currentTimeMillis();
                    return;
                }
                return;
            }
            try {
                long optLong = ((JSONObject) new JSONObject(str).get("extra")).optLong("now", -1);
                if (optLong >= 0) {
                    mServerTime = optLong;
                    mLocalTime = System.currentTimeMillis();
                }
            } catch (Exception unused) {
            }
        }
    }

    public static C49449c7 getNetworkType(Context context) {
        try {
            NetworkInfo INVOKEVIRTUAL_com_ss_android_common_util_NetworkUtils_com_ss_android_ugc_aweme_net_lancet_ConnecttivityManagerLancet_getActiveNetworkInfo = INVOKEVIRTUAL_com_ss_android_common_util_NetworkUtils_com_ss_android_ugc_aweme_net_lancet_ConnecttivityManagerLancet_getActiveNetworkInfo((ConnectivityManager) INVOKEVIRTUAL_com_ss_android_common_util_NetworkUtils_com_ss_android_ugc_aweme_lancet_GetSystemServiceLancet_getSystemService(context, "connectivity"));
            if (INVOKEVIRTUAL_com_ss_android_common_util_NetworkUtils_com_ss_android_ugc_aweme_net_lancet_ConnecttivityManagerLancet_getActiveNetworkInfo == null || !INVOKEVIRTUAL_com_ss_android_common_util_NetworkUtils_com_ss_android_ugc_aweme_net_lancet_ConnecttivityManagerLancet_getActiveNetworkInfo.isAvailable()) {
                return C49449c7.NONE;
            }
            int type = INVOKEVIRTUAL_com_ss_android_common_util_NetworkUtils_com_ss_android_ugc_aweme_net_lancet_ConnecttivityManagerLancet_getActiveNetworkInfo.getType();
            if (1 == type) {
                return C49449c7.WIFI;
            }
            if (type != 0) {
                return C49449c7.MOBILE;
            }
            switch (INVOKEVIRTUAL_com_ss_android_common_util_NetworkUtils_com_ss_android_ugc_aweme_lancet_telephony_TelephonyManagerLancet_getNetworkType((TelephonyManager) INVOKEVIRTUAL_com_ss_android_common_util_NetworkUtils_com_ss_android_ugc_aweme_lancet_GetSystemServiceLancet_getSystemService(context, "phone"))) {
                case 1:
                case 2:
                case 4:
                case 7:
                case 11:
                    return C49449c7.MOBILE_2G;
                case 3:
                case 5:
                case 6:
                case 8:
                case 9:
                case 10:
                case 12:
                case 14:
                case 15:
                    return C49449c7.MOBILE_3G;
                case 13:
                    return C49449c7.MOBILE_4G;
                default:
                    return C49449c7.MOBILE;
            }
        } catch (Throwable unused) {
            return C49449c7.MOBILE;
        }
    }

    public static String addCommonParams(String str, boolean z) {
        return NetWorkInjectImpl.LIZLLL().LIZIZ().LIZ(str, z);
    }

    public static List<String> getShareCookie(CookieManager cookieManager, String str) {
        C49459c8 r0 = sApiInterceptor;
        if (r0 != null) {
            return r0.LIZJ();
        }
        return null;
    }

    public static void putCommonParams(List<Tet> list, boolean z) {
        NetWorkInjectImpl.LIZLLL().LIZIZ().LIZ(list, z);
    }

    public static void safeClose(Closeable closeable, String str) {
        if (closeable != null) {
            try {
                closeable.close();
            } catch (Exception unused) {
            }
        }
    }

    public static String addGetRetryCountParam(String str, String str2) {
        if (TextUtils.isEmpty(str)) {
            return str;
        }
        3Tp r1 = new 3Tp(str);
        r1.LIZ("retry_type", str2);
        return r1.toString();
    }

    public static List<Tet> addPostRetryCountParam(List<Tet> list, String str) {
        if (list == null) {
            list = new ArrayList<>();
        }
        list.add(new Tet("retry_type", str));
        return list;
    }

    public static byte[] downloadFile(int i, String str) {
        C49439c6 r0 = C31988p3.LIZ;
        if (r0 != null) {
            return r0.LIZ(i, str);
        }
        return null;
    }

    public static String joinCommonParams(String str, List<Tet> list) {
        if (TextUtils.isEmpty(str) || list == null || list.isEmpty()) {
            return str;
        }
        StringBuilder sb = new StringBuilder(str);
        if (str.indexOf(63) < 0) {
            sb.append("?");
        } else {
            sb.append("&");
        }
        sb.append(32q.LIZ(list, "UTF-8"));
        return sb.toString();
    }

    public static Object INVOKEVIRTUAL_com_ss_android_common_util_NetworkUtils_com_ss_android_ugc_aweme_lancet_GetSystemServiceLancet_getSystemService(Context context, String str) {
        Object obj;
        MethodCollector.i(15315);
        if (Build.VERSION.SDK_INT > 27 || !"clipboard".equals(str)) {
            if (!2FV.LIZIZ && "connectivity".equals(str)) {
                try {
                    new C08347s1().LIZ();
                    2FV.LIZIZ = true;
                    obj = context.getSystemService(str);
                } catch (Throwable unused) {
                }
            }
            obj = context.getSystemService(str);
        } else if (2FV.LIZ) {
            synchronized (ClipboardManager.class) {
                try {
                    obj = context.getSystemService(str);
                    if (Thread.currentThread() != Looper.getMainLooper().getThread()) {
                        Field declaredField = ClipboardManager.class.getDeclaredField("mHandler");
                        declaredField.setAccessible(true);
                        declaredField.set(obj, new 2He((Handler) declaredField.get(obj)));
                    }
                } catch (Exception e) {
                    C28338jA.LIZ(e, "ClipboardManager Handler Reflect Fail");
                } catch (Throwable th) {
                    MethodCollector.o(15315);
                    throw th;
                }
                2FV.LIZ = false;
            }
        } else {
            obj = context.getSystemService(str);
        }
        MethodCollector.o(15315);
        return obj;
    }

    public static String tryDnsMapping(String str, String[] strArr) {
        C49449c7 networkType;
        C49459c8 r0;
        if (sUseDnsMapping <= 0 || strArr == null || strArr.length <= 0 || ((str != null && str.startsWith("https://")) || NetWorkInjectImpl.LIZLLL().LIZ() == null || (networkType = getNetworkType(INVOKEVIRTUAL_com_ss_android_common_util_NetworkUtils_com_ss_android_ugc_aweme_lancet_launch_ApplicationContextLancet_getApplicationContext(NetWorkInjectImpl.LIZLLL().LIZ()))) == null)) {
            return str;
        }
        int i = AnonymousClass1.LIZ[networkType.ordinal()];
        int i2 = 4;
        if (i == 1) {
            i2 = 1;
        } else if (i != 2) {
            if (i == 3 || i == 4) {
                i2 = 2;
            } else if (i != 5) {
                i2 = 0;
            }
        }
        if (!((sUseDnsMapping & i2) == 0 || (r0 = sApiInterceptor) == null)) {
            String LIZIZ = r0.LIZIZ();
            if (!TextUtils.isEmpty(LIZIZ)) {
                return LIZIZ;
            }
            strArr[0] = null;
            return str;
        }
        return str;
    }

    public static String executeGet(int i, int i2, String str) {
        return executeGet(i, i2, str, true, true);
    }

    public static void handleApiOk(String str, long j, C49409c3 r3) {
        NetWorkInjectImpl.LIZLLL();
        TextUtils.isEmpty(str);
    }

    public static void addCacheValidationHeaders(List<C49529cF> list, String str, String str2) {
        if (list != null) {
            if (!TextUtils.isEmpty(str)) {
                list.add(new Tew("If-None-Match", str));
            }
            if (!TextUtils.isEmpty(str2)) {
                list.add(new Tew("If-Modified-Since", str2));
            }
        }
    }

    public static String decodeSSBinary(byte[] bArr, int i, String str) {
        if (bArr == null || i <= 0) {
            return null;
        }
        byte[] bArr2 = {-99, -114, Byte.MAX_VALUE, 90};
        int i2 = 0;
        do {
            bArr[i2] = (byte) (bArr[i2] ^ bArr2[i2 % 4]);
            i2++;
        } while (i2 < i);
        return new String(bArr, 0, i, str);
    }

    public static byte[] getBytes(InputStream inputStream, long j, String str) {
        MethodCollector.i(12719);
        if (j <= 2147483647L) {
            int i = (int) j;
            byte[] bArr = new byte[i];
            int i2 = 0;
            while (i2 < i) {
                int read = inputStream.read(bArr, i2, i - i2);
                if (read < 0) {
                    break;
                }
                i2 += read;
            }
            if (i2 >= i) {
                inputStream.close();
                MethodCollector.o(12719);
                return bArr;
            }
            IOException iOException = new IOException("Could not completely read file ".concat(String.valueOf(str)));
            MethodCollector.o(12719);
            throw iOException;
        }
        IOException iOException2 = new IOException("File is too large: ".concat(String.valueOf(str)));
        MethodCollector.o(12719);
        throw iOException2;
    }

    public static void jsonObjectToBasicNameValuePairs(List<Tet> list, JSONObject jSONObject, String str) {
        String str2;
        String obj;
        if (jSONObject != null) {
            Iterator<String> keys = jSONObject.keys();
            while (keys.hasNext()) {
                String next = keys.next();
                if (TextUtils.isEmpty(str)) {
                    str2 = next;
                } else {
                    str2 = str + "[" + next + "]";
                }
                Object obj2 = jSONObject.get(next);
                if (obj2 instanceof JSONObject) {
                    jsonObjectToBasicNameValuePairs(list, (JSONObject) obj2, str2);
                } else if (obj2 instanceof JSONArray) {
                    JSONArray jSONArray = (JSONArray) obj2;
                    for (int i = 0; i < jSONArray.length(); i++) {
                        jsonObjectToBasicNameValuePairs(list, jSONArray.getJSONObject(i), str2);
                    }
                } else {
                    if (obj2 == null) {
                        obj = "";
                    } else {
                        obj = obj2.toString();
                    }
                    list.add(new Tet(str2, obj));
                }
            }
        }
    }

    public static byte[] stream2ByteArray(int i, InputStream inputStream, long j) {
        int i2;
        MethodCollector.i(16388);
        if (inputStream == null) {
            MethodCollector.o(16388);
            return null;
        } else if (j > 2147483647L) {
            inputStream.close();
            MethodCollector.o(16388);
            return null;
        } else {
            if (j < 0) {
                j = 4096;
            } else if (j > ((long) i)) {
                inputStream.close();
                MethodCollector.o(16388);
                return null;
            }
            try {
                C49489cB r3 = new C49489cB((int) j);
                byte[] bArr = new byte[4096];
                int i3 = 0;
                do {
                    int read = inputStream.read(bArr);
                    if (read == -1) {
                        byte[] bArr2 = new byte[r3.LIZIZ];
                        if (r3.LIZIZ > 0) {
                            System.arraycopy(r3.LIZ, 0, bArr2, 0, r3.LIZIZ);
                        }
                        inputStream.close();
                        MethodCollector.o(16388);
                        return bArr2;
                    } else if (read < 0 || (i2 = read + 0) < 0 || i2 > 4096) {
                        IndexOutOfBoundsException indexOutOfBoundsException = new IndexOutOfBoundsException();
                        MethodCollector.o(16388);
                        throw indexOutOfBoundsException;
                    } else {
                        if (read != 0) {
                            int i4 = r3.LIZIZ + read;
                            if (i4 > r3.LIZ.length) {
                                byte[] bArr3 = new byte[Math.max(r3.LIZ.length << 1, i4)];
                                System.arraycopy(r3.LIZ, 0, bArr3, 0, r3.LIZIZ);
                                r3.LIZ = bArr3;
                            }
                            System.arraycopy(bArr, 0, r3.LIZ, r3.LIZIZ, read);
                            r3.LIZIZ = i4;
                        }
                        i3 += read;
                    }
                } while (i3 <= i);
                return null;
            } finally {
                inputStream.close();
                MethodCollector.o(16388);
            }
        }
    }

    public static String executePost(int i, String str, C49629cP r4) {
        return executePost(0, i, str, r4, (C49769cd[]) null);
    }

    public static String executePost(int i, String str, List<Tet> list) {
        return executePost(0, i, str, list, (C49769cd[]) null);
    }

    public static String executePost(int i, int i2, String str, C49629cP r4) {
        return executePost(i, i2, str, r4, (C49769cd[]) null);
    }

    public static String executePost(int i, int i2, String str, List<Tet> list) {
        return executePost(i, i2, str, list, (C49769cd[]) null);
    }

    public static void handleApiError(String str, Throwable th, long j, C49409c3 r4) {
        if (!TextUtils.isEmpty(str) && th != null) {
            NetWorkInjectImpl.LIZLLL();
        }
    }

    public static String executeGet(int i, int i2, String str, List<Tet> list) {
        return executeGet(i, i2, str, true, true, list);
    }

    public static String executePut(String str, JSONObject jSONObject, String str2, List<C49529cF> list) {
        byte[] bytes;
        String str3 = str2;
        List<C49529cF> list2 = list;
        String str4 = str;
        if (str3 == null || !str3.startsWith("application/json")) {
            ArrayList arrayList = new ArrayList();
            jsonObjectToBasicNameValuePairs(arrayList, jSONObject, "");
            return executePut(0, 0, str4, (List<Tet>) arrayList, (C49769cd[]) null, list2);
        }
        if (jSONObject == null) {
            bytes = null;
        } else {
            bytes = jSONObject.toString().getBytes("UTF-8");
        }
        return executePut(-1, str4, bytes, C24258ca.GZIP, str3, list2);
    }

    public static String executeGet(int i, int i2, String str, boolean z) {
        return executeGet(i, i2, str, z, true);
    }

    public static String postFile(int i, String str, String str2, String str3) {
        C49629cP r5 = new C49629cP();
        if (str3.startsWith("content://")) {
            Uri parse = Uri.parse(str3);
            InputStream LIZ = 0Gz.LIZ(NetWorkInjectImpl.LIZLLL().LIZ(), parse);
            long LIZ2 = 0H0.LIZ(NetWorkInjectImpl.LIZLLL().LIZ(), parse);
            String path = parse.getPath();
            r5.LIZ(str2, getBytes(LIZ, LIZ2, path), path);
        } else {
            r5.LIZ(str2, new File(str3));
        }
        return executePost(0, i, str, r5);
    }

    public static String executePost(int i, String str, C49629cP r3, C49769cd[] r4) {
        return executePost(0, i, str, r3, r4);
    }

    public static String executeGet(int i, int i2, String str, int i3, int i4) {
        return executeGet(i, i2, str, true, true, (List<C49529cF>) null, (EV0) null, true);
    }

    public static String executePostFile(int i, int i2, String str, C49629cP r8, List<Tet> list) {
        return executePostFile(i, i2, str, r8, (C49769cd[]) null, list);
    }

    public static String executePostRetry(int i, int i2, String str, List<Tet> list, C49769cd[] r10) {
        return executePostRetry(i, i2, str, list, r10, (List<C49529cF>) null);
    }

    public static String executeDelete(int i, int i2, String str, List<C49529cF> list, List<Tet> list2) {
        if (str == null) {
            return null;
        }
        String addCommonParams = addCommonParams(str, true);
        C31998p4 r0 = C31988p3.LIZIZ;
        if (r0 != null) {
            addCommonParams = r0.LIZ();
        }
        C49439c6 r02 = C31988p3.LIZ;
        if (r02 != null) {
            return r02.LIZ(i, i2, addCommonParams, list);
        }
        return null;
    }

    public static String executePost(int i, int i2, String str, List<Tet> list, C49769cd[] r10) {
        return executePost(i, i2, str, list, r10, (List<C49529cF>) null);
    }

    public static void monitorApiSample(long j, long j2, String str, String str2, C49409c3 r10) {
        C49419c4 r3 = sMonitorProcessHook;
        if (!TextUtils.isEmpty(str) && j > 0 && r3 != null) {
            r3.LIZ(j, j2, str, str2, r10);
        }
    }

    public static String executePost(int i, int i2, String str, C49629cP r9, C49769cd[] r10) {
        String str2 = str;
        filterUrl(str2);
        int i3 = i2;
        int i4 = i;
        C49769cd[] r7 = r10;
        C49629cP r6 = r9;
        try {
            return executePostRetry(i4, i3, str2, r6, r7, addPostRetryCountParam((List<Tet>) null, "no_retry"), true);
        } catch (Exception e) {
            if (!TextUtils.isEmpty(str2) && str2.startsWith("https") && ((e instanceof SSLException) || (e instanceof GeneralSecurityException))) {
                return executePostRetry(i4, i3, str2, r6, r7, addPostRetryCountParam((List<Tet>) null, "retry_http"), false);
            }
            filterUrl(str2);
            return executePostRetry(i4, i3, str2, r6, r7, addPostRetryCountParam((List<Tet>) null, "first_retry"), false);
        }
    }

    public static String executeGet(int i, int i2, String str, boolean z, List<Tet> list) {
        return executeGet(i, i2, str, z, true, list);
    }

    public static String postFile(int i, String str, String str2, String str3, List<Tet> list) {
        C49629cP r4 = new C49629cP();
        if (str3.startsWith("content://")) {
            Uri parse = Uri.parse(str3);
            InputStream LIZ = 0Gz.LIZ(NetWorkInjectImpl.LIZLLL().LIZ(), parse);
            long LIZ2 = 0H0.LIZ(NetWorkInjectImpl.LIZLLL().LIZ(), parse);
            String path = parse.getPath();
            r4.LIZ(str2, getBytes(LIZ, LIZ2, path), path);
        } else {
            r4.LIZ(str2, new File(str3));
        }
        return executePostFile(0, i, str, r4, list);
    }

    public static String response2String(boolean z, boolean z2, int i, InputStream inputStream, String str) {
        int i2;
        MethodCollector.i(17295);
        if (i <= 0) {
            i = 5242880;
        }
        if (i < 1048576) {
            i = 1048576;
        }
        if (inputStream == null) {
            MethodCollector.o(17295);
            return null;
        }
        if (str == null) {
            str = "UTF-8";
        }
        if (z) {
            try {
                inputStream = new GZIPInputStream(inputStream);
            } catch (EOFException e) {
                if (!z || i2 <= 0) {
                    MethodCollector.o(17295);
                    throw e;
                }
            } catch (IOException e2) {
                String message = e2.getMessage();
                if (z && i2 > 0) {
                    if (!"CRC mismatch".equals(message)) {
                        if ("Size mismatch".equals(message)) {
                        }
                    }
                }
                MethodCollector.o(17295);
                throw e2;
            } catch (Throwable th) {
                safeClose(inputStream);
                MethodCollector.o(17295);
                throw th;
            }
        }
        byte[] bArr = new byte[8192];
        i2 = 0;
        do {
            if (i2 + 4096 > bArr.length) {
                byte[] bArr2 = new byte[(bArr.length * 2)];
                System.arraycopy(bArr, 0, bArr2, 0, i2);
                bArr = bArr2;
            }
            int read = inputStream.read(bArr, i2, 4096);
            if (read > 0) {
                i2 += read;
            } else if (i2 <= 0) {
                safeClose(inputStream);
                MethodCollector.o(17295);
                return null;
            } else if (z2) {
                String decodeSSBinary = decodeSSBinary(bArr, i2, str);
                safeClose(inputStream);
                MethodCollector.o(17295);
                return decodeSSBinary;
            } else {
                String str2 = new String(bArr, 0, i2, str);
                safeClose(inputStream);
                MethodCollector.o(17295);
                return str2;
            }
        } while (i2 <= i);
        safeClose(inputStream);
        MethodCollector.o(17295);
        return null;
    }

    public static String executeGet(int i, int i2, String str, boolean z, boolean z2) {
        return executeGet(i, i2, str, z, z2, (List<C49529cF>) null, (EV0) null, true);
    }

    public static String executePostRetry(int i, int i2, String str, List<Tet> list, C49769cd[] r5, List<C49529cF> list2) {
        return executetRetry("post", i, i2, str, list, r5, list2);
    }

    public static String executePut(int i, int i2, String str, List<Tet> list, C49769cd[] r5, List<C49529cF> list2) {
        return execute("put", i, i2, str, list, r5, list2);
    }

    public static String executePutRetry(int i, int i2, String str, List<Tet> list, C49769cd[] r5, List<C49529cF> list2) {
        return executetRetry("put", i, i2, str, list, r5, list2);
    }

    public static String executePut(int i, String str, byte[] bArr, C24258ca r4, String str2, List<C49529cF> list) {
        if (str == null) {
            return null;
        }
        return execute("put", i, addCommonParams(str, true), bArr, r4, str2, list);
    }

    public static String executeGet(int i, int i2, String str, int i3, int i4, List<Tet> list) {
        return executeGet(i, i2, str, true, true, (List<C49529cF>) null, (EV0) null, true, list);
    }

    public static void monitorApiError(long j, long j2, String str, String str2, C49409c3 r7, Throwable th) {
        C49419c4 r0;
        if (!TextUtils.isEmpty(str) && th != null && (r0 = sMonitorProcessHook) != null) {
            r0.LIZ(j, j2, str, str2, r7, th);
        }
    }

    public static String executePost(int i, int i2, String str, List<Tet> list, C49769cd[] r5, List<C49529cF> list2) {
        return execute("post", i, i2, str, list, r5, list2);
    }

    public static String executePostFile(int i, int i2, String str, C49629cP r8, C49769cd[] r9, List<Tet> list) {
        String str2 = str;
        filterUrl(str2);
        int i3 = i2;
        int i4 = i;
        C49769cd[] r6 = r9;
        C49629cP r5 = r8;
        try {
            return executePostFileRetry(i4, i3, str2, r5, r6, addPostRetryCountParam(list, "no_retry"), true);
        } catch (Exception e) {
            if (!TextUtils.isEmpty(str2) && str2.startsWith("https") && ((e instanceof SSLException) || (e instanceof GeneralSecurityException))) {
                return executePostFileRetry(i4, i3, str2, r5, r6, addPostRetryCountParam(list, "retry_http"), false);
            }
            filterUrl(str2);
            return executePostFileRetry(i4, i3, str2, r5, r6, addPostRetryCountParam(list, "first_retry"), false);
        }
    }

    public static String executePost(int i, int i2, String str, byte[] bArr, C24258ca r13, String str2) {
        String str3;
        MethodCollector.i(17192);
        filterUrl(str);
        if (str == null) {
            MethodCollector.o(17192);
            return null;
        }
        if (bArr == null) {
            bArr = new byte[0];
        }
        int length = bArr.length;
        if (C24258ca.GZIP == r13) {
            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(8192);
            GZIPOutputStream gZIPOutputStream = new GZIPOutputStream(byteArrayOutputStream);
            try {
                gZIPOutputStream.write(bArr);
                gZIPOutputStream.close();
                bArr = byteArrayOutputStream.toByteArray();
                str3 = "gzip";
            } catch (Throwable unused) {
                gZIPOutputStream.close();
                MethodCollector.o(17192);
                return null;
            }
        } else if (C24258ca.DEFLATER != r13 || length <= 128) {
            str3 = null;
        } else {
            ByteArrayOutputStream byteArrayOutputStream2 = new ByteArrayOutputStream(8192);
            Deflater deflater = new Deflater();
            deflater.setInput(bArr);
            deflater.finish();
            byte[] bArr2 = new byte[8192];
            while (!deflater.finished()) {
                byteArrayOutputStream2.write(bArr2, 0, deflater.deflate(bArr2));
            }
            deflater.end();
            bArr = byteArrayOutputStream2.toByteArray();
            str3 = "deflate";
        }
        C49439c6 r8 = C31988p3.LIZ;
        if (r8 != null) {
            String LIZ = r8.LIZ(i, i2, str, bArr, str3, str2);
            MethodCollector.o(17192);
            return LIZ;
        }
        MethodCollector.o(17192);
        return null;
    }

    public static String postFile(int i, String str, String str2, String str3, Map<String, String> map, C49769cd[] r10) {
        C49629cP r3 = new C49629cP();
        if (str3.startsWith("content://")) {
            Uri parse = Uri.parse(str3);
            InputStream LIZ = 0Gz.LIZ(NetWorkInjectImpl.LIZLLL().LIZ(), parse);
            long LIZ2 = 0H0.LIZ(NetWorkInjectImpl.LIZLLL().LIZ(), parse);
            String path = parse.getPath();
            r3.LIZ(str2, getBytes(LIZ, LIZ2, path), path);
        } else {
            r3.LIZ(str2, new File(str3));
        }
        if (map != null) {
            for (Map.Entry next : map.entrySet()) {
                r3.LIZ((String) next.getKey(), (String) next.getValue());
            }
        }
        return executePost(0, i, str, r3, r10);
    }

    public static String executeGet(int i, int i2, String str, boolean z, boolean z2, List<Tet> list) {
        return executeGet(i, i2, str, z, z2, (List<C49529cF>) null, (EV0) null, true, list);
    }

    public static String executePostRetry(int i, int i2, String str, C49629cP r8, C49769cd[] r9, List<Tet> list, boolean z) {
        filterUrl(str);
        if (str == null) {
            return null;
        }
        List<Tet> list2 = list;
        putCommonParams(list2, true);
        String joinCommonParams = joinCommonParams(str, list2);
        C49439c6 r0 = C31988p3.LIZ;
        if (r0 == null) {
            return null;
        }
        return r0.LIZ(i, i2, joinCommonParams, list2, r8, r9);
    }

    public static String executePostFileRetry(int i, int i2, String str, C49629cP r8, C49769cd[] r9, List<Tet> list, boolean z) {
        filterUrl(str);
        if (str == null) {
            return null;
        }
        ArrayList arrayList = new ArrayList();
        putCommonParams(arrayList, true);
        String joinCommonParams = joinCommonParams(str, arrayList);
        List<Tet> list2 = list;
        list2.addAll(arrayList);
        C49439c6 r0 = C31988p3.LIZ;
        if (r0 == null) {
            return null;
        }
        return r0.LIZ(i, i2, joinCommonParams, list2, r8, r9);
    }

    public static String postData(int i, String str, String str2, byte[] bArr, String str3, Map<String, String> map, C49769cd[] r10) {
        C49629cP r3 = new C49629cP();
        r3.LIZ(str2, bArr, str3);
        if (map != null) {
            for (Map.Entry next : map.entrySet()) {
                r3.LIZ((String) next.getKey(), (String) next.getValue());
            }
        }
        return executePost(0, i, str, r3, r10);
    }

    public static String uploadFile(int i, String str, String str2, String str3, C49569cJ r12, long j, C49769cd[] r15) {
        filterUrl(str);
        if (str != null && !TextUtils.isEmpty(str3)) {
            File file = new File(str3);
            C49629cP r4 = new C49629cP();
            r4.LIZ(str2, file);
            ArrayList arrayList = new ArrayList();
            putCommonParams(arrayList, true);
            String joinCommonParams = joinCommonParams(str, arrayList);
            C49439c6 r1 = C31988p3.LIZ;
            if (r1 != null) {
                return r1.LIZ(i, joinCommonParams, r4, (C49569cJ<Long>) r12, j, r15);
            }
        }
        return null;
    }

    public static String execute(String str, int i, int i2, String str2, List<Tet> list, C49769cd[] r11, List<C49529cF> list2) {
        String str3 = str2;
        filterUrl(str3);
        int i3 = i;
        String str4 = str;
        int i4 = i2;
        List<C49529cF> list3 = list2;
        C49769cd[] r7 = r11;
        try {
            return executetRetry(str4, i3, i4, str3, addPostRetryCountParam(list, "no_retry"), r7, list3);
        } catch (Exception unused) {
            if (TextUtils.isEmpty(str3) || !str3.startsWith("https")) {
                filterUrl(str3);
                return executetRetry(str4, i3, i4, str3, addPostRetryCountParam(list, "first_retry"), r7, list3);
            } else if (!isHitNoHttpList(str3)) {
                return executetRetry(str4, i3, i4, str3, addPostRetryCountParam(list, "retry_http"), r7, list3);
            } else {
                filterUrl(str3);
                return executetRetry(str4, i3, i4, str3, addPostRetryCountParam(list, "first_retry"), r7, list3);
            }
        }
    }

    public static String executetRetry(String str, int i, int i2, String str2, List<Tet> list, C49769cd[] r11, List<C49529cF> list2) {
        if (str2 == null || TextUtils.isEmpty(str)) {
            return null;
        }
        if ("get".equals(str)) {
            throw new RuntimeException("executetRetry does not support [get]");
        } else if (!"delete".equals(str)) {
            ArrayList arrayList = new ArrayList();
            putCommonParams(arrayList, true);
            String joinCommonParams = joinCommonParams(str2, arrayList);
            List<Tet> list3 = list;
            list3.addAll(arrayList);
            C31998p4 r0 = C31988p3.LIZIZ;
            if (r0 != null) {
                joinCommonParams = r0.LIZ();
            }
            C49439c6 r1 = C31988p3.LIZ;
            if (r1 == null) {
                return null;
            }
            int i3 = i2;
            int i4 = i;
            List<C49529cF> list4 = list2;
            C49769cd[] r7 = r11;
            if ("put".equals(str)) {
                return r1.LIZIZ(i4, i3, joinCommonParams, list3, true, r7, list4);
            }
            return r1.LIZ(i4, i3, joinCommonParams, list3, true, r7, list4);
        } else {
            throw new RuntimeException("executetRetry does not support [delete]");
        }
    }

    public static String execute(String str, int i, String str2, byte[] bArr, C24258ca r13, String str3, List<C49529cF> list) {
        String str4;
        MethodCollector.i(12717);
        if ("get".equals(str)) {
            RuntimeException runtimeException = new RuntimeException("this method does not support [get]");
            MethodCollector.o(12717);
            throw runtimeException;
        } else if (!"delete".equals(str)) {
            filterUrl(str2);
            if (str2 == null || TextUtils.isEmpty(str)) {
                MethodCollector.o(12717);
                return null;
            }
            if (bArr == null) {
                bArr = new byte[0];
            }
            int length = bArr.length;
            if (C24258ca.GZIP == r13) {
                ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(8192);
                GZIPOutputStream gZIPOutputStream = new GZIPOutputStream(byteArrayOutputStream);
                try {
                    gZIPOutputStream.write(bArr);
                    gZIPOutputStream.close();
                    bArr = byteArrayOutputStream.toByteArray();
                    str4 = "gzip";
                } catch (Throwable unused) {
                    gZIPOutputStream.close();
                    MethodCollector.o(12717);
                    return null;
                }
            } else if (C24258ca.DEFLATER != r13 || length <= 128) {
                str4 = null;
            } else {
                ByteArrayOutputStream byteArrayOutputStream2 = new ByteArrayOutputStream(8192);
                Deflater deflater = new Deflater();
                deflater.setInput(bArr);
                deflater.finish();
                byte[] bArr2 = new byte[8192];
                while (!deflater.finished()) {
                    byteArrayOutputStream2.write(bArr2, 0, deflater.deflate(bArr2));
                }
                deflater.end();
                bArr = byteArrayOutputStream2.toByteArray();
                str4 = "deflate";
            }
            C49439c6 r8 = C31988p3.LIZ;
            if (r8 == null) {
                MethodCollector.o(12717);
                return null;
            } else if ("put".equals(str)) {
                String LIZIZ = r8.LIZIZ(0, i, str2, bArr, str4, str3, list);
                MethodCollector.o(12717);
                return LIZIZ;
            } else {
                String LIZ = r8.LIZ(0, i, str2, bArr, str4, str3, list);
                MethodCollector.o(12717);
                return LIZ;
            }
        } else {
            RuntimeException runtimeException2 = new RuntimeException("This method does not support [delete]");
            MethodCollector.o(12717);
            throw runtimeException2;
        }
    }

    public static String executeGet(int i, int i2, String str, boolean z, boolean z2, List<C49529cF> list, EV0 ev0, boolean z3) {
        return executeGet(i, i2, str, z, z2, list, ev0, z3, (List<Tet>) null);
    }

    public static String executeGetRetry(int i, int i2, String str, boolean z, List<C49529cF> list, EV0 ev0, boolean z2, List<Tet> list2, boolean z3) {
        boolean z4 = z;
        String str2 = str;
        if (str2 == null) {
            return null;
        }
        if (z3) {
            str2 = addCommonParams(str2, true);
        }
        if (!mAllowKeepAlive) {
            z4 = false;
        }
        C31998p4 r0 = C31988p3.LIZIZ;
        if (r0 != null) {
            str2 = r0.LIZ();
        }
        C49439c6 r02 = C31988p3.LIZ;
        if (r02 == null) {
            return null;
        }
        return r02.LIZ(i, i2, str2, list, z4, true, ev0, z2);
    }

    /* JADX WARNING: Code restructure failed: missing block: B:20:0x0057, code lost:
        r11 = move-exception;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:21:0x0058, code lost:
        r2 = r20;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:24:0x005e, code lost:
        if (android.text.TextUtils.isEmpty(r2) != false) goto L_0x0133;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:27:0x0066, code lost:
        r11 = new java.io.File(r2);
     */
    /* JADX WARNING: Code restructure failed: missing block: B:28:0x006f, code lost:
        if (r11.exists() == false) goto L_0x0071;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:29:0x0071, code lost:
        r11.mkdirs();
     */
    /* JADX WARNING: Code restructure failed: missing block: B:30:0x0074, code lost:
        r13 = r2;
        r8 = java.io.File.createTempFile(r8, ".tmp", new java.io.File(r2));
     */
    /* JADX WARNING: Code restructure failed: missing block: B:65:?, code lost:
        r14.close();
     */
    /* JADX WARNING: Code restructure failed: missing block: B:66:0x00f0, code lost:
        if (r11 <= 0) goto L_0x0111;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:69:?, code lost:
        r3.seek(0);
        r9 = new java.io.FileOutputStream(new java.io.File(r13, r21));
     */
    /* JADX WARNING: Code restructure failed: missing block: B:71:?, code lost:
        r1 = r3.read(r2);
     */
    /* JADX WARNING: Code restructure failed: missing block: B:72:0x0107, code lost:
        if (r1 == -1) goto L_0x010e;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:73:0x0109, code lost:
        r9.write(r2, 0, r1);
     */
    /* JADX WARNING: Code restructure failed: missing block: B:74:0x010e, code lost:
        r9.close();
     */
    /* JADX WARNING: Code restructure failed: missing block: B:76:?, code lost:
        r3.close();
     */
    /* JADX WARNING: Code restructure failed: missing block: B:78:?, code lost:
        INVOKEVIRTUAL_com_ss_android_common_util_NetworkUtils_com_ss_android_ugc_aweme_storage_FileLancet_delete(r8);
     */
    /* JADX WARNING: Code restructure failed: missing block: B:79:0x0117, code lost:
        safeClose((java.io.Closeable) null, "close instream exception ");
        safeClose((java.io.Closeable) null, "close outstream exception ");
        safeClose((java.io.Closeable) null, "close random file exception ");
        com.bytedance.frameworks.apm.trace.MethodCollector.o(17247);
     */
    /* JADX WARNING: Code restructure failed: missing block: B:80:0x0126, code lost:
        return true;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:81:0x0127, code lost:
        r1 = th;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:82:0x0128, code lost:
        r14 = null;
        r3 = null;
        r8 = r8;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:83:0x012b, code lost:
        r1 = th;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:84:0x012c, code lost:
        r14 = null;
        r8 = r8;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:90:?, code lost:
        com.bytedance.frameworks.apm.trace.MethodCollector.o(17247);
     */
    /* JADX WARNING: Code restructure failed: missing block: B:91:0x0138, code lost:
        throw r11;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:94:0x0144, code lost:
        r1 = th;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:95:0x0145, code lost:
        r8 = null;
        r3 = null;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:96:0x0148, code lost:
        r1 = th;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:97:0x0149, code lost:
        r14 = null;
        r4 = r9;
        r8 = r8;
     */
    /* JADX WARNING: Exception block dominator not found, dom blocks: [B:12:0x0034, B:18:0x004d] */
    /* JADX WARNING: Removed duplicated region for block: B:100:0x0156 A[SYNTHETIC, Splitter:B:100:0x0156] */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    public static boolean stream2File(java.io.InputStream r14, long r15, X.C49499cC r17, int r18, java.lang.String r19, java.lang.String r20, java.lang.String r21, X.C49559cI<java.lang.String> r22, java.lang.String r23, X.C49579cK r24) {
        /*
            r0 = r15
            r13 = r19
            java.lang.String r10 = ".tmp"
            java.lang.String r8 = "tempimage"
            r3 = 17247(0x435f, float:2.4168E-41)
            com.bytedance.frameworks.apm.trace.MethodCollector.i(r3)
            r2 = 0
            if (r14 != 0) goto L_0x0013
            com.bytedance.frameworks.apm.trace.MethodCollector.o(r3)
            return r2
        L_0x0013:
            r2 = 2147483647(0x7fffffff, double:1.060997895E-314)
            java.lang.String r7 = "close random file exception "
            java.lang.String r6 = "close outstream exception "
            java.lang.String r5 = "close instream exception "
            r4 = 0
            int r11 = (r0 > r2 ? 1 : (r0 == r2 ? 0 : -1))
            r9 = r18
            if (r11 > 0) goto L_0x0139
            r11 = 0
            int r2 = (r0 > r11 ? 1 : (r0 == r11 ? 0 : -1))
            if (r2 >= 0) goto L_0x002c
            r0 = 4096(0x1000, double:2.0237E-320)
            goto L_0x003f
        L_0x002c:
            if (r9 <= 0) goto L_0x003f
            long r2 = (long) r9
            int r11 = (r0 > r2 ? 1 : (r0 == r2 ? 0 : -1))
            if (r11 > 0) goto L_0x0034
            goto L_0x003f
        L_0x0034:
            X.8PW r2 = new X.8PW     // Catch:{ all -> 0x0144 }
            r2.<init>(r9, r0)     // Catch:{ all -> 0x0144 }
            r0 = 17247(0x435f, float:2.4168E-41)
            com.bytedance.frameworks.apm.trace.MethodCollector.o(r0)     // Catch:{ all -> 0x0144 }
            throw r2     // Catch:{ all -> 0x0144 }
        L_0x003f:
            java.io.File r3 = new java.io.File     // Catch:{ all -> 0x0144 }
            r3.<init>(r13)     // Catch:{ all -> 0x0144 }
            boolean r2 = r3.exists()     // Catch:{ all -> 0x0144 }
            if (r2 != 0) goto L_0x004d
            r3.mkdirs()     // Catch:{ all -> 0x0144 }
        L_0x004d:
            java.io.File r2 = new java.io.File     // Catch:{ IOException -> 0x0057 }
            r2.<init>(r13)     // Catch:{ IOException -> 0x0057 }
            java.io.File r8 = java.io.File.createTempFile(r8, r10, r2)     // Catch:{ IOException -> 0x0057 }
            goto L_0x007e
        L_0x0057:
            r11 = move-exception
            r2 = r20
            boolean r3 = android.text.TextUtils.isEmpty(r2)     // Catch:{ all -> 0x0144 }
            if (r3 != 0) goto L_0x0133
            boolean r3 = r2.equals(r13)     // Catch:{ all -> 0x0144 }
            if (r3 != 0) goto L_0x0133
            java.io.File r11 = new java.io.File     // Catch:{ all -> 0x0144 }
            r11.<init>(r2)     // Catch:{ all -> 0x0144 }
            boolean r3 = r11.exists()     // Catch:{ all -> 0x0144 }
            if (r3 != 0) goto L_0x0074
            r11.mkdirs()     // Catch:{ all -> 0x0144 }
        L_0x0074:
            java.io.File r3 = new java.io.File     // Catch:{ all -> 0x0144 }
            r3.<init>(r2)     // Catch:{ all -> 0x0144 }
            java.io.File r8 = java.io.File.createTempFile(r8, r10, r3)     // Catch:{ all -> 0x0144 }
            r13 = r2
        L_0x007e:
            if (r8 != 0) goto L_0x0090
            safeClose(r14, r5)
            safeClose(r4, r6)
            safeClose(r4, r7)
            r0 = 17247(0x435f, float:2.4168E-41)
            com.bytedance.frameworks.apm.trace.MethodCollector.o(r0)
        L_0x008e:
            r0 = 0
            return r0
        L_0x0090:
            java.io.RandomAccessFile r3 = new java.io.RandomAccessFile     // Catch:{ all -> 0x0130 }
            java.lang.String r2 = "rw"
            r3.<init>(r8, r2)     // Catch:{ all -> 0x0130 }
            r10 = 0
            r3.setLength(r10)     // Catch:{ all -> 0x012e }
            r2 = 4096(0x1000, float:5.74E-42)
            byte[] r2 = new byte[r2]     // Catch:{ all -> 0x012e }
            r11 = 0
        L_0x00a1:
            int r10 = r14.read(r2)     // Catch:{ all -> 0x012e }
            r12 = -1
            if (r10 == r12) goto L_0x00ed
            r12 = r24
            if (r12 == 0) goto L_0x00b1
            boolean r12 = r12.LIZ     // Catch:{ all -> 0x012e }
            if (r12 == 0) goto L_0x00b1
            goto L_0x00c2
        L_0x00b1:
            int r11 = r11 + r10
            if (r9 <= 0) goto L_0x00b6
            if (r11 > r9) goto L_0x00df
        L_0x00b6:
            r12 = 0
            r3.write(r2, r12, r10)     // Catch:{ all -> 0x012e }
            if (r22 == 0) goto L_0x00a1
            if (r23 == 0) goto L_0x00a1
            java.lang.System.currentTimeMillis()     // Catch:{ all -> 0x012e }
            goto L_0x00a1
        L_0x00c2:
            if (r17 == 0) goto L_0x00ca
            r17.LIZ()     // Catch:{ all -> 0x012e }
            r17.LIZIZ()     // Catch:{ all -> 0x012e }
        L_0x00ca:
            r3.close()     // Catch:{ all -> 0x012e }
            safeClose(r14, r5)
            safeClose(r4, r6)
            safeClose(r4, r7)
            INVOKEVIRTUAL_com_ss_android_common_util_NetworkUtils_com_ss_android_ugc_aweme_storage_FileLancet_delete(r8)     // Catch:{ Exception -> 0x00d9 }
        L_0x00d9:
            r0 = 17247(0x435f, float:2.4168E-41)
            com.bytedance.frameworks.apm.trace.MethodCollector.o(r0)
            goto L_0x008e
        L_0x00df:
            r3.close()     // Catch:{ all -> 0x012e }
            X.8PW r2 = new X.8PW     // Catch:{ all -> 0x0130 }
            r2.<init>(r9, r0)     // Catch:{ all -> 0x0130 }
            r0 = 17247(0x435f, float:2.4168E-41)
            com.bytedance.frameworks.apm.trace.MethodCollector.o(r0)     // Catch:{ all -> 0x0130 }
            throw r2     // Catch:{ all -> 0x0130 }
        L_0x00ed:
            r14.close()     // Catch:{ all -> 0x012e }
            if (r11 <= 0) goto L_0x0111
            r0 = 0
            r3.seek(r0)     // Catch:{ all -> 0x012b }
            java.io.FileOutputStream r9 = new java.io.FileOutputStream     // Catch:{ all -> 0x012b }
            java.io.File r0 = new java.io.File     // Catch:{ all -> 0x012b }
            r1 = r21
            r0.<init>(r13, r1)     // Catch:{ all -> 0x012b }
            r9.<init>(r0)     // Catch:{ all -> 0x012b }
        L_0x0103:
            int r1 = r3.read(r2)     // Catch:{ all -> 0x0148 }
            if (r1 == r12) goto L_0x010e
            r0 = 0
            r9.write(r2, r0, r1)     // Catch:{ all -> 0x0148 }
            goto L_0x0103
        L_0x010e:
            r9.close()     // Catch:{ all -> 0x0148 }
        L_0x0111:
            r3.close()     // Catch:{ all -> 0x012b }
            INVOKEVIRTUAL_com_ss_android_common_util_NetworkUtils_com_ss_android_ugc_aweme_storage_FileLancet_delete(r8)     // Catch:{ all -> 0x0127 }
            safeClose(r4, r5)
            safeClose(r4, r6)
            safeClose(r4, r7)
            r1 = 1
            r0 = 17247(0x435f, float:2.4168E-41)
            com.bytedance.frameworks.apm.trace.MethodCollector.o(r0)
            return r1
        L_0x0127:
            r1 = move-exception
            r14 = r4
            r3 = r14
            goto L_0x014b
        L_0x012b:
            r1 = move-exception
            r14 = r4
            goto L_0x014b
        L_0x012e:
            r1 = move-exception
            goto L_0x014b
        L_0x0130:
            r1 = move-exception
            r3 = r4
            goto L_0x014b
        L_0x0133:
            r0 = 17247(0x435f, float:2.4168E-41)
            com.bytedance.frameworks.apm.trace.MethodCollector.o(r0)     // Catch:{ all -> 0x0144 }
            throw r11     // Catch:{ all -> 0x0144 }
        L_0x0139:
            X.8PW r1 = new X.8PW     // Catch:{ all -> 0x0144 }
            r1.<init>(r9, r2)     // Catch:{ all -> 0x0144 }
            r0 = 17247(0x435f, float:2.4168E-41)
            com.bytedance.frameworks.apm.trace.MethodCollector.o(r0)     // Catch:{ all -> 0x0144 }
            throw r1     // Catch:{ all -> 0x0144 }
        L_0x0144:
            r1 = move-exception
            r8 = r4
            r3 = r8
            goto L_0x014b
        L_0x0148:
            r1 = move-exception
            r14 = r4
            r4 = r9
        L_0x014b:
            safeClose(r14, r5)
            safeClose(r4, r6)
            safeClose(r3, r7)
            if (r8 == 0) goto L_0x0159
            INVOKEVIRTUAL_com_ss_android_common_util_NetworkUtils_com_ss_android_ugc_aweme_storage_FileLancet_delete(r8)     // Catch:{ Exception -> 0x0159 }
        L_0x0159:
            r0 = 17247(0x435f, float:2.4168E-41)
            com.bytedance.frameworks.apm.trace.MethodCollector.o(r0)
            throw r1
        */
        throw new UnsupportedOperationException("Method not decompiled: com.ss.android.common.util.NetworkUtils.stream2File(java.io.InputStream, long, X.9cC, int, java.lang.String, java.lang.String, java.lang.String, X.9cI, java.lang.String, X.9cK):boolean");
    }

    public static boolean downloadFile(int i, String str, String str2, String str3, String str4, C49559cI<String> r6, String str5, C49579cK r8, List<Tet> list, String[] strArr, int[] iArr) {
        C49439c6 r0 = C31988p3.LIZ;
        if (r0 != null) {
            return r0.LIZ(i, str, str2, str3, str4, r6, str5, r8, list, strArr, iArr);
        }
        return false;
    }

    public static boolean downloadVideo(int i, String str, StringBuffer stringBuffer, StringBuffer stringBuffer2, StringBuffer stringBuffer3, C49559cI<String> r6, String str2, C49579cK r8, List<Tet> list, String[] strArr, int[] iArr, RedirectHandler redirectHandler) {
        C49439c6 r0 = C31988p3.LIZ;
        if (r0 != null) {
            return r0.LIZ(i, str, stringBuffer, stringBuffer2, stringBuffer3, r6, str2, r8, list, strArr, iArr, redirectHandler);
        }
        return false;
    }
}
