热汗舞蹈 v1.24.1.0版本的 MD5 值为:f1dc6ef07903515a73f51f41f372123e

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


package com.qiyukf.nimlib.c.f;

import android.content.Context;
import android.hardware.usb.UsbDevice;
import android.hardware.usb.UsbManager;
import android.os.Build;
import android.util.Log;
import com.huawei.hms.framework.common.hianalytics.HianalyticsBaseData;
import com.huawei.hms.support.hianalytics.HiAnalyticsConstant;
import com.qiyukf.nimlib.net.a.d.b;
import com.qiyukf.nimlib.q.i;
import com.qiyukf.unicorn.mediaselect.internal.loader.AlbumLoader;
import com.tencent.thumbplayer.core.downloadproxy.api.TPDownloadProxyEnum;
import com.xiaomi.mipush.sdk.Constants;
import java.io.BufferedReader;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.Semaphore;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
public class a {
    private static final String f19601a = com.qiyukf.nimlib.q.a.a.a().a(com.qiyukf.nimlib.q.a.b.TYPE_LOG);
    private static final String f19602b = com.qiyukf.nimlib.push.e.a();
    private static volatile int f19603c = 0;
    private static volatile a f19604d = null;
    private final Semaphore f19605e = new Semaphore(1);

    public static class C0152a {
        private final short f19606a;
        private final String f19607b;
        private final long f19608c;
        private final String f19609d;
        private final String f19610e;
        private int f19611f;

        public C0152a(short s10, byte b10, byte b11) {
            this(s10, com.qiyukf.nimlib.c.k(), System.currentTimeMillis(), String.valueOf((int) b10), String.valueOf((int) b11), 1);
        }

        public final int a() {
            return this.f19611f;
        }

        public final String b() {
            JSONObject jSONObject = new JSONObject();
            try {
                jSONObject.put("errorCode", (int) this.f19606a);
                jSONObject.put("accid", this.f19607b);
                jSONObject.put("timestamp", this.f19608c);
                jSONObject.put("module", this.f19609d);
                jSONObject.put("file", this.f19610e);
                jSONObject.put(AlbumLoader.COLUMN_COUNT, this.f19611f);
            } catch (JSONException e10) {
                e10.printStackTrace();
            }
            return jSONObject.toString();
        }

        public final String c() {
            JSONObject jSONObject = new JSONObject();
            try {
                jSONObject.put("errorCode", (int) this.f19606a);
                jSONObject.put("accid", this.f19607b);
                jSONObject.put("module", this.f19609d);
                jSONObject.put("file", this.f19610e);
                return jSONObject.toString();
            } catch (JSONException e10) {
                e10.printStackTrace();
                return null;
            }
        }

        public final void a(int i10) {
            this.f19611f = i10;
        }

        public static C0152a a(JSONObject jSONObject) {
            return new C0152a((short) jSONObject.optInt("errorCode"), jSONObject.optString("accid"), jSONObject.optLong("timestamp"), jSONObject.optString("module"), jSONObject.optString("file"), jSONObject.optInt(AlbumLoader.COLUMN_COUNT));
        }

        private C0152a(short s10, String str, long j10, String str2, String str3, int i10) {
            this.f19606a = s10;
            this.f19607b = str == null ? "" : str;
            this.f19608c = j10;
            this.f19609d = str2 == null ? "" : str2;
            this.f19610e = str3 == null ? "" : str3;
            this.f19611f = i10;
        }
    }

    private a() {
        File file = new File(f19601a, "JsonBody.log");
        if (file.exists()) {
            file.delete();
        }
        try {
            c();
        } catch (IOException e10) {
            e10.printStackTrace();
        }
    }

    public static a a() {
        if (f19604d == null) {
            synchronized (a.class) {
                if (f19604d == null) {
                    a aVar = new a();
                    f19604d = aVar;
                    return aVar;
                }
            }
        }
        return f19604d;
    }

    private static String b() {
        UsbManager usbManager;
        Context d10 = com.qiyukf.nimlib.c.d();
        if (d10 == null || (usbManager = (UsbManager) d10.getSystemService("usb")) == null) {
            return "";
        }
        UsbDevice usbDevice = null;
        for (UsbDevice usbDevice2 : usbManager.getDeviceList().values()) {
            int deviceClass = usbDevice2.getDeviceClass();
            if (deviceClass == 239 || deviceClass == 14) {
                int interfaceCount = usbDevice2.getInterfaceCount();
                int i10 = 0;
                while (true) {
                    if (i10 >= interfaceCount) {
                        break;
                    } else if (usbDevice2.getInterface(i10).getInterfaceClass() == 14) {
                        usbDevice = usbDevice2;
                        break;
                    } else {
                        i10++;
                    }
                }
            }
        }
        if (usbDevice == null) {
            return "";
        }
        return usbDevice.getVendorId() + Constants.COLON_SEPARATOR + usbDevice.getProductId();
    }

    private static File c() throws IOException {
        String str = f19601a;
        File file = new File(str, "IMLogMsg.log");
        if (!file.exists()) {
            com.qiyukf.nimlib.j.b.a.a.b(str, "IMLogMsg.log");
            file.createNewFile();
            file.setReadable(true);
            file.setWritable(true);
        }
        return file;
    }

    private void d() {
        if (!g() && this.f19605e.tryAcquire()) {
            com.qiyukf.nimlib.net.a.d.b.a().a(com.qiyukf.nimlib.c.d());
            com.qiyukf.nimlib.net.a.d.b.a().a("http://statistic.live.126.net/statics/report/common/form", e(), f(), new b.a() {
                @Override
                public final void onResponse(String str, int i10, Throwable th) {
                    a.this.a(str, i10, th);
                }
            });
        }
    }

    private static Map<String, String> e() {
        HashMap hashMap = new HashMap();
        hashMap.put("Content-Type", "multipart/form-data; boundary=----WebKitFormBoundaryyEePCbPKpBvrs9OE");
        return hashMap;
    }

    private static byte[] f() {
        String str = "\r\n";
        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
        StringBuilder sb2 = new StringBuilder();
        sb2.append("------WebKitFormBoundaryyEePCbPKpBvrs9OE\r\n");
        sb2.append("Content-Disposition: form-data; name=\"reporterHeader\"\r\n\r\n");
        String a10 = com.qiyukf.nimlib.j.a.a(true);
        File file = new File(a10);
        JSONObject jSONObject = new JSONObject();
        try {
            try {
                jSONObject.put("common", new JSONObject().put(HianalyticsBaseData.SDK_TYPE, "IM").put(TPDownloadProxyEnum.USER_DEVICE_ID, f19602b)).put("event", new JSONObject().put("logReport", new JSONObject().put("fileMD5", i.b(a10)).put("errorList", h())));
            } catch (JSONException e10) {
                e10.printStackTrace();
            }
            sb2.append(jSONObject.toString());
            sb2.append("\r\n");
            sb2.append("------WebKitFormBoundaryyEePCbPKpBvrs9OE\r\n");
            sb2.append("Content-Disposition: form-data; name=\"logReport\"; filename=\"");
            StringBuilder sb3 = new StringBuilder("logs_");
            jSONObject = "yyyyMMddhhmm";
            sb3.append(new SimpleDateFormat("yyyyMMddhhmm", Locale.CHINA).format(new Date()));
            sb3.append(".zip");
            sb2.append(sb3.toString());
            sb2.append("\"\r\n");
            sb2.append("Content-Type: application/octet-stream\r\n\r\n");
            byte[] bArr = null;
            str = null;
            try {
                byteArrayOutputStream.write(sb2.toString().getBytes());
                FileInputStream fileInputStream = new FileInputStream(file);
                byte[] bArr2 = new byte[4096];
                while (fileInputStream.read(bArr2) != -1) {
                    byteArrayOutputStream.write(bArr2);
                }
                byteArrayOutputStream.write("\r\n------WebKitFormBoundaryyEePCbPKpBvrs9OE--".getBytes());
                bArr = byteArrayOutputStream.toByteArray();
                byteArrayOutputStream.flush();
                byteArrayOutputStream.close();
                fileInputStream.close();
            } catch (IOException e11) {
                e11.printStackTrace();
            }
            file.delete();
            return bArr == null ? new byte[0] : bArr;
        } catch (Throwable th) {
            sb2.append(jSONObject.toString());
            sb2.append(str);
            throw th;
        }
    }

    private static boolean g() {
        return h().length() == 0;
    }

    private static JSONArray h() {
        try {
            BufferedReader bufferedReader = new BufferedReader(new FileReader(c()));
            StringBuilder sb2 = new StringBuilder();
            for (String readLine = bufferedReader.readLine(); readLine != null; readLine = bufferedReader.readLine()) {
                sb2.append(readLine);
            }
            String sb3 = sb2.toString();
            return sb3.isEmpty() ? new JSONArray() : new JSONArray(sb3);
        } catch (FileNotFoundException e10) {
            e10.printStackTrace();
            Log.e("@CJL/文件不存在", e10.getMessage());
            return new JSONArray();
        } catch (IOException e11) {
            e11.printStackTrace();
            Log.e("@CJL/读写异常", e11.getMessage());
            return new JSONArray();
        } catch (JSONException e12) {
            e12.printStackTrace();
            Log.e("@CJL/字符串转JSONArray异常", e12.getMessage());
            return new JSONArray();
        }
    }

    public static void a(b.a aVar, String str, int i10, Throwable th) {
        if (i10 == 200) {
            f19603c = 2;
        } else {
            f19603c = 0;
        }
        aVar.onResponse(str, i10, th);
    }

    public void b(String str, int i10, Throwable th) {
        String concat = "@CJL/注册返回".concat(String.valueOf(i10));
        if (str == null) {
            str = "";
        }
        Log.i(concat, str);
        if (i10 == 200) {
            d();
        }
    }

    public final void a(short s10) {
        if (s10 != 200) {
            return;
        }
        int i10 = f19603c;
        if (i10 != 0) {
            if (i10 != 2) {
                return;
            }
            d();
            return;
        }
        final b.a aVar = new b.a() {
            @Override
            public final void onResponse(String str, int i11, Throwable th) {
                a.this.b(str, i11, th);
            }
        };
        if (f19603c == 0 && com.qiyukf.nimlib.c.g().reportImLog) {
            f19603c = 1;
            JSONObject jSONObject = new JSONObject();
            try {
                JSONObject put = jSONObject.put("common", new JSONObject().put(HianalyticsBaseData.SDK_TYPE, "IM").put(TPDownloadProxyEnum.USER_DEVICE_ID, f19602b));
                JSONObject jSONObject2 = new JSONObject();
                JSONObject put2 = new JSONObject().put("app_key", com.qiyukf.nimlib.c.f()).put(HiAnalyticsConstant.BI_KEY_SDK_VER, "1.0.0").put("platform", "Android");
                StringBuilder sb2 = new StringBuilder();
                String str = Build.BRAND;
                sb2.append(str);
                sb2.append("#");
                sb2.append(Build.BOARD);
                sb2.append("#");
                String str2 = Build.MODEL;
                sb2.append(str2);
                String sb3 = sb2.toString();
                String b10 = b();
                if (b10 != null && !b10.isEmpty()) {
                    sb3 = sb3 + "#" + b10;
                }
                put.put("event", jSONObject2.put("deviceinfo", put2.put("compat_id", sb3).put("os_ver", Build.VERSION.RELEASE).put("manufacturer", str).put("model", str2)));
            } catch (JSONException e10) {
                e10.printStackTrace();
            }
            HashMap hashMap = new HashMap();
            hashMap.put("Content-Type", "application/json");
            com.qiyukf.nimlib.net.a.d.b.a().a(com.qiyukf.nimlib.c.d());
            com.qiyukf.nimlib.net.a.d.b.a().a("http://statistic.live.126.net/statics/report/common/form", hashMap, jSONObject.toString(), true, new b.a() {
                @Override
                public final void onResponse(String str3, int i11, Throwable th) {
                    a.a(b.a.this, str3, i11, th);
                }
            });
        }
    }

    private static boolean a(ConcurrentHashMap<String, C0152a> concurrentHashMap) {
        try {
            File c10 = c();
            JSONArray jSONArray = new JSONArray();
            for (String str : concurrentHashMap.keySet()) {
                C0152a c0152a = concurrentHashMap.get(str);
                if (c0152a != null) {
                    jSONArray.put(new JSONObject(c0152a.b()));
                }
            }
            c10.setWritable(true);
            OutputStreamWriter outputStreamWriter = new OutputStreamWriter(new FileOutputStream(c10));
            outputStreamWriter.write(jSONArray.toString());
            outputStreamWriter.flush();
            outputStreamWriter.close();
            return true;
        } catch (IOException e10) {
            e10.printStackTrace();
            return false;
        } catch (JSONException e11) {
            e11.printStackTrace();
            return false;
        }
    }

    public static void a(short s10, byte b10, byte b11) {
        if (com.qiyukf.nimlib.c.g().reportImLog && (s10 == 408 || s10 == 415 || s10 == 500)) {
            JSONArray h10 = h();
            ConcurrentHashMap concurrentHashMap = new ConcurrentHashMap();
            for (int i10 = 0; i10 < h10.length(); i10++) {
                Object opt = h10.opt(i10);
                if (opt instanceof JSONObject) {
                    C0152a a10 = C0152a.a((JSONObject) opt);
                    concurrentHashMap.put(a10.c(), a10);
                }
            }
            C0152a c0152a = new C0152a(s10, b10, b11);
            String c10 = c0152a.c();
            C0152a c0152a2 = (C0152a) concurrentHashMap.get(c0152a.c());
            if (c0152a2 == null) {
                concurrentHashMap.put(c10, c0152a);
            } else {
                c0152a.a(c0152a2.a() + c0152a.a());
                concurrentHashMap.replace(c10, c0152a);
            }
            a(concurrentHashMap);
        }
    }

    public void a(String str, int i10, Throwable th) {
        if (i10 == 200) {
            com.qiyukf.nimlib.j.a.a();
        }
        this.f19605e.release();
    }
}