小红书.apk(点击下载) / TPDLProxyUtils.java


package com.tencent.thumbplayer.core.downloadproxy.utils;

import com.alipay.sdk.util.f;
import com.tencent.thumbplayer.core.downloadproxy.api.ITPDLProxyLogListener;
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.InputStreamReader;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;

public class TPDLProxyUtils {
    private static final String FILE_NAME = "TPDLProxyUtils";

    public static String byteArrayToString(byte[] bArr) {
        if (bArr == null) {
            return "";
        }
        try {
            return new String(bArr, "UTF-8");
        } catch (Throwable th3) {
            TPDLProxyLog.e(FILE_NAME, 0, ITPDLProxyLogListener.COMMON_TAG, "byteArrayToString failed, error:" + th3.toString());
            return "";
        }
    }

    public static String losePackageCheck(int i10) {
        String str;
        Throwable th3;
        String str2 = "";
        try {
            BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(Runtime.getRuntime().exec("ping -c " + i10 + " www.qq.com").getInputStream()));
            str = str2;
            while (true) {
                try {
                    String readLine = bufferedReader.readLine();
                    if (readLine == null) {
                        break;
                    }
                    if (readLine.contains(" packet loss")) {
                        str2 = readLine.substring(10 + readLine.indexOf("received, "), readLine.indexOf("%") + 1);
                    }
                    if (readLine.contains("avg")) {
                        int indexOf = readLine.indexOf("/", 20);
                        str = readLine.substring(indexOf + 1, readLine.indexOf(".", indexOf));
                    }
                } catch (Throwable th4) {
                    th3 = th4;
                    th3.printStackTrace();
                    return str2 + f.f18324b + str;
                }
            }
        } catch (Throwable th5) {
            th3 = th5;
            str = str2;
            th3.printStackTrace();
            return str2 + f.f18324b + str;
        }
        return str2 + f.f18324b + str;
    }

    public static int objectToInt(Object obj, int i10) {
        if (obj == null) {
            return i10;
        }
        try {
            return ((Integer) obj).intValue();
        } catch (Throwable th3) {
            TPDLProxyLog.e(FILE_NAME, 0, ITPDLProxyLogListener.COMMON_TAG, "object to int failed, error:" + th3.toString());
            return i10;
        }
    }

    public static long objectToLong(Object obj, long j14) {
        if (obj == null) {
            return j14;
        }
        try {
            return ((Long) obj).longValue();
        } catch (Throwable th3) {
            TPDLProxyLog.e(FILE_NAME, 0, ITPDLProxyLogListener.COMMON_TAG, "object to long failed, error:" + th3.toString());
            return j14;
        }
    }

    /* JADX WARNING: Removed duplicated region for block: B:24:0x006c A[SYNTHETIC, Splitter:B:24:0x006c] */
    public static String serialize(Object obj) {
        Throwable th3;
        ByteArrayOutputStream byteArrayOutputStream;
        ObjectOutputStream objectOutputStream;
        ObjectOutputStream objectOutputStream2 = null;
        try {
            byteArrayOutputStream = new ByteArrayOutputStream();
            try {
                objectOutputStream = new ObjectOutputStream(byteArrayOutputStream);
            } catch (Throwable th4) {
                th3 = th4;
                try {
                    TPDLProxyLog.e(FILE_NAME, 0, ITPDLProxyLogListener.COMMON_TAG, "serialize obj, error:" + th3.toString());
                    if (objectOutputStream2 != null) {
                        try {
                            objectOutputStream2.close();
                        } catch (Throwable th5) {
                            TPDLProxyLog.e(FILE_NAME, 0, ITPDLProxyLogListener.COMMON_TAG, "obj serialize to string  objectOutputStream close, error:" + th5.toString());
                        }
                    }
                    try {
                        byteArrayOutputStream.close();
                        return "";
                    } catch (Throwable th6) {
                        TPDLProxyLog.e(FILE_NAME, 0, ITPDLProxyLogListener.COMMON_TAG, "obj serialize to string byteArrayOutputStream close, error:" + th6.toString());
                        return "";
                    }
                } catch (Throwable th7) {
                    TPDLProxyLog.e(FILE_NAME, 0, ITPDLProxyLogListener.COMMON_TAG, "obj serialize to string byteArrayOutputStream close, error:" + th7.toString());
                }
            }
            try {
                objectOutputStream.writeObject(obj);
                String byteArrayOutputStream2 = byteArrayOutputStream.toString("ISO-8859-1");
                try {
                    objectOutputStream.close();
                } catch (Throwable th8) {
                    TPDLProxyLog.e(FILE_NAME, 0, ITPDLProxyLogListener.COMMON_TAG, "obj serialize to string  objectOutputStream close, error:" + th8.toString());
                }
                try {
                    byteArrayOutputStream.close();
                } catch (Throwable th9) {
                    TPDLProxyLog.e(FILE_NAME, 0, ITPDLProxyLogListener.COMMON_TAG, "obj serialize to string byteArrayOutputStream close, error:" + th9.toString());
                }
                return byteArrayOutputStream2;
            } catch (Throwable th10) {
                th3 = th10;
                objectOutputStream2 = objectOutputStream;
                TPDLProxyLog.e(FILE_NAME, 0, ITPDLProxyLogListener.COMMON_TAG, "serialize obj, error:" + th3.toString());
                if (objectOutputStream2 != null) {
                }
                byteArrayOutputStream.close();
                return "";
            }
        } catch (Throwable th11) {
            th3 = th11;
            byteArrayOutputStream = null;
            TPDLProxyLog.e(FILE_NAME, 0, ITPDLProxyLogListener.COMMON_TAG, "serialize obj, error:" + th3.toString());
            if (objectOutputStream2 != null) {
            }
            byteArrayOutputStream.close();
            return "";
        }
        throw th;
        byteArrayOutputStream.close();
        throw th;
    }

    /* JADX WARNING: Removed duplicated region for block: B:24:0x006e A[SYNTHETIC, Splitter:B:24:0x006e] */
    /* JADX WARNING: Removed duplicated region for block: B:29:0x0088 A[SYNTHETIC, Splitter:B:29:0x0088] */
    public static Object serializeToObject(String str) {
        ObjectInputStream objectInputStream;
        Throwable th3;
        ByteArrayInputStream byteArrayInputStream;
        try {
            byteArrayInputStream = new ByteArrayInputStream(str.getBytes("ISO-8859-1"));
            try {
                objectInputStream = new ObjectInputStream(byteArrayInputStream);
                try {
                    Object readObject = objectInputStream.readObject();
                    try {
                        objectInputStream.close();
                    } catch (Throwable th4) {
                        TPDLProxyLog.e(FILE_NAME, 0, ITPDLProxyLogListener.COMMON_TAG, "serialize to obj objectInputStream close, error:" + th4.toString());
                    }
                    try {
                        byteArrayInputStream.close();
                    } catch (Throwable th5) {
                        TPDLProxyLog.e(FILE_NAME, 0, ITPDLProxyLogListener.COMMON_TAG, "serialize to obj byteArrayInputStream close, error:" + th5.toString());
                    }
                    return readObject;
                } catch (Throwable th6) {
                    th3 = th6;
                    try {
                        TPDLProxyLog.e(FILE_NAME, 0, ITPDLProxyLogListener.COMMON_TAG, "serialize to obj , error:" + th3.toString());
                        if (objectInputStream != null) {
                        }
                        if (byteArrayInputStream != null) {
                        }
                        return null;
                    } catch (Throwable th7) {
                        TPDLProxyLog.e(FILE_NAME, 0, ITPDLProxyLogListener.COMMON_TAG, "serialize to obj byteArrayInputStream close, error:" + th7.toString());
                    }
                }
            } catch (Throwable th8) {
                th3 = th8;
                objectInputStream = null;
                TPDLProxyLog.e(FILE_NAME, 0, ITPDLProxyLogListener.COMMON_TAG, "serialize to obj , error:" + th3.toString());
                if (objectInputStream != null) {
                    try {
                        objectInputStream.close();
                    } catch (Throwable th9) {
                        TPDLProxyLog.e(FILE_NAME, 0, ITPDLProxyLogListener.COMMON_TAG, "serialize to obj objectInputStream close, error:" + th9.toString());
                    }
                }
                if (byteArrayInputStream != null) {
                    try {
                        byteArrayInputStream.close();
                    } catch (Throwable th10) {
                        TPDLProxyLog.e(FILE_NAME, 0, ITPDLProxyLogListener.COMMON_TAG, "serialize to obj byteArrayInputStream close, error:" + th10.toString());
                    }
                }
                return null;
            }
        } catch (Throwable th11) {
            th3 = th11;
            objectInputStream = null;
            byteArrayInputStream = null;
            TPDLProxyLog.e(FILE_NAME, 0, ITPDLProxyLogListener.COMMON_TAG, "serialize to obj , error:" + th3.toString());
            if (objectInputStream != null) {
            }
            if (byteArrayInputStream != null) {
            }
            return null;
        }
        throw th;
        if (byteArrayInputStream != null) {
            byteArrayInputStream.close();
        }
        throw th;
    }
}