BTGO游戏盒 v3.4.80版本的 MD5 值为:000032bab1addaabfdc671ee6a7087ab

以下内容为反编译后的 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 androidx.core.app.NotificationCompat;
import com.qiyukf.nimlib.net.a.d.b;
import com.qiyukf.nimlib.q.i;
import com.umeng.analytics.pro.am;
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.Iterator;
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 f14431a = com.qiyukf.nimlib.q.a.a.a().a(com.qiyukf.nimlib.q.a.b.TYPE_LOG);

    private static final String f14432b = com.qiyukf.nimlib.push.e.a();

    private static volatile int f14433c = 0;

    private static volatile a f14434d = null;

    private final Semaphore f14435e = new Semaphore(1);

    public static class C0143a {

        private final short f14436a;

        private final String f14437b;

        private final long f14438c;

        private final String f14439d;

        private final String f14440e;

        private int f14441f;

        public C0143a(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.f14441f;
        }

        public final String b() {
            JSONObject jSONObject = new JSONObject();
            try {
                jSONObject.put("errorCode", (int) this.f14436a);
                jSONObject.put("accid", this.f14437b);
                jSONObject.put("timestamp", this.f14438c);
                jSONObject.put(am.f20521e, this.f14439d);
                jSONObject.put("file", this.f14440e);
                jSONObject.put("count", this.f14441f);
            } catch (JSONException e10) {
                e10.printStackTrace();
            }
            return jSONObject.toString();
        }

        public final String c() {
            JSONObject jSONObject = new JSONObject();
            try {
                jSONObject.put("errorCode", (int) this.f14436a);
                jSONObject.put("accid", this.f14437b);
                jSONObject.put(am.f20521e, this.f14439d);
                jSONObject.put("file", this.f14440e);
                return jSONObject.toString();
            } catch (JSONException e10) {
                e10.printStackTrace();
                return null;
            }
        }

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

        public static C0143a a(JSONObject jSONObject) {
            return new C0143a((short) jSONObject.optInt("errorCode"), jSONObject.optString("accid"), jSONObject.optLong("timestamp"), jSONObject.optString(am.f20521e), jSONObject.optString("file"), jSONObject.optInt("count"));
        }

        private C0143a(short s10, String str, long j10, String str2, String str3, int i10) {
            this.f14436a = s10;
            this.f14437b = str == null ? "" : str;
            this.f14438c = j10;
            this.f14439d = str2 == null ? "" : str2;
            this.f14440e = str3 == null ? "" : str3;
            this.f14441f = i10;
        }
    }

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

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

    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;
                    }
                    if (usbDevice2.getInterface(i10).getInterfaceClass() == 14) {
                        usbDevice = usbDevice2;
                        break;
                    }
                    i10++;
                }
            }
        }
        if (usbDevice == null) {
            return "";
        }
        return usbDevice.getVendorId() + ":" + usbDevice.getProductId();
    }

    private static File c() throws IOException {
        String str = f14431a;
        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.f14435e.tryAcquire()) {
            return;
        }
        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 sb = new StringBuilder();
        sb.append("------WebKitFormBoundaryyEePCbPKpBvrs9OE\r\n");
        sb.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(am.f20537u, "IM").put("device_id", f14432b)).put(NotificationCompat.CATEGORY_EVENT, new JSONObject().put("logReport", new JSONObject().put("fileMD5", i.b(a10)).put("errorList", h())));
            } catch (JSONException e10) {
                e10.printStackTrace();
            }
            sb.append(jSONObject.toString());
            sb.append("\r\n");
            sb.append("------WebKitFormBoundaryyEePCbPKpBvrs9OE\r\n");
            sb.append("Content-Disposition: form-data; name=\"logReport\"; filename=\"");
            StringBuilder sb2 = new StringBuilder("logs_");
            jSONObject = "yyyyMMddhhmm";
            sb2.append(new SimpleDateFormat("yyyyMMddhhmm", Locale.CHINA).format(new Date()));
            sb2.append(".zip");
            sb.append(sb2.toString());
            sb.append("\"\r\n");
            sb.append("Content-Type: application/octet-stream\r\n\r\n");
            byte[] bArr = null;
            str = null;
            try {
                byteArrayOutputStream.write(sb.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();
            if (bArr == null) {
                return new byte[0];
            }
            return bArr;
        } catch (Throwable th) {
            sb.append(jSONObject.toString());
            sb.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 sb = new StringBuilder();
            for (String readLine = bufferedReader.readLine(); readLine != null; readLine = bufferedReader.readLine()) {
                sb.append(readLine);
            }
            String sb2 = sb.toString();
            if (sb2.isEmpty()) {
                return new JSONArray();
            }
            return new JSONArray(sb2);
        } 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) {
            f14433c = 2;
        } else {
            f14433c = 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 = f14433c;
        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 (f14433c == 0 && com.qiyukf.nimlib.c.g().reportImLog) {
            f14433c = 1;
            JSONObject jSONObject = new JSONObject();
            try {
                JSONObject put = jSONObject.put("common", new JSONObject().put(am.f20537u, "IM").put("device_id", f14432b));
                JSONObject jSONObject2 = new JSONObject();
                JSONObject put2 = new JSONObject().put(com.alipay.sdk.cons.b.f1885h, com.qiyukf.nimlib.c.f()).put("sdk_ver", "1.0.0").put("platform", "Android");
                StringBuilder sb = new StringBuilder();
                String str = Build.BRAND;
                sb.append(str);
                sb.append("#");
                sb.append(Build.BOARD);
                sb.append("#");
                String str2 = Build.MODEL;
                sb.append(str2);
                String sb2 = sb.toString();
                String b10 = b();
                if (b10 != null && !b10.isEmpty()) {
                    sb2 = sb2 + "#" + b10;
                }
                put.put(NotificationCompat.CATEGORY_EVENT, jSONObject2.put("deviceinfo", put2.put("compat_id", sb2).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, C0143a> concurrentHashMap) {
        try {
            File c10 = c();
            JSONArray jSONArray = new JSONArray();
            Iterator<String> it = concurrentHashMap.keySet().iterator();
            while (it.hasNext()) {
                C0143a c0143a = concurrentHashMap.get(it.next());
                if (c0143a != null) {
                    jSONArray.put(new JSONObject(c0143a.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) {
                    C0143a a10 = C0143a.a((JSONObject) opt);
                    concurrentHashMap.put(a10.c(), a10);
                }
            }
            C0143a c0143a = new C0143a(s10, b10, b11);
            String c10 = c0143a.c();
            C0143a c0143a2 = (C0143a) concurrentHashMap.get(c0143a.c());
            if (c0143a2 == null) {
                concurrentHashMap.put(c10, c0143a);
            } else {
                c0143a.a(c0143a2.a() + c0143a.a());
                concurrentHashMap.replace(c10, c0143a);
            }
            a((ConcurrentHashMap<String, C0143a>) concurrentHashMap);
        }
    }

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