龙将斩千 v5.5.5.39856版本的 MD5 值为:5c05b1d6f8d872ca3fe0343d6ff07caf

以下内容为反编译后的 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 ch.qos.logback.core.joran.action.Action;
import com.loopj.android.http.RequestParams;
import com.qiyukf.nimlib.net.a.d.b;
import com.qiyukf.nimlib.q.i;
import com.qiyukf.unicorn.mediaselect.internal.loader.AlbumLoader;
import com.yaya.sdk.constants.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.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 a = com.qiyukf.nimlib.q.a.a.a().a(com.qiyukf.nimlib.q.a.b.TYPE_LOG);
    private static final String b = com.qiyukf.nimlib.push.e.a();
    private static volatile int c = 0;
    private static volatile a d = null;
    private final Semaphore e = new Semaphore(1);

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

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

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

    private static String b() {
        UsbManager usbManager;
        Context d2 = com.qiyukf.nimlib.c.d();
        if (d2 == null || (usbManager = (UsbManager) d2.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 i = 0;
                while (true) {
                    if (i >= interfaceCount) {
                        break;
                    }
                    if (usbDevice2.getInterface(i).getInterfaceClass() == 14) {
                        usbDevice = usbDevice2;
                        break;
                    }
                    i++;
                }
            }
        }
        if (usbDevice == null) {
            return "";
        }
        return usbDevice.getVendorId() + ":" + usbDevice.getProductId();
    }

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

    public final void a(short s) {
        if (s != 200) {
            return;
        }
        switch (c) {
            case 0:
                final b.a aVar = new b.a() {
                    @Override
                    public final void onResponse(String str, int i, Throwable th) {
                        a.this.b(str, i, th);
                    }
                };
                if (c != 0 || !com.qiyukf.nimlib.c.g().reportImLog) {
                    return;
                }
                c = 1;
                JSONObject jSONObject = new JSONObject();
                try {
                    JSONObject put = jSONObject.put("common", new JSONObject().put("sdk_type", "IM").put("device_id", b));
                    JSONObject jSONObject2 = new JSONObject();
                    JSONObject put2 = new JSONObject().put("app_key", com.qiyukf.nimlib.c.f()).put("sdk_ver", Constants.VERSION_NAME).put("platform", "Android");
                    String str = Build.BRAND + "#" + Build.BOARD + "#" + Build.MODEL;
                    String b2 = b();
                    if (b2 != null && !b2.isEmpty()) {
                        str = str + "#" + b2;
                    }
                    put.put(NotificationCompat.CATEGORY_EVENT, jSONObject2.put("deviceinfo", put2.put("compat_id", str).put("os_ver", Build.VERSION.RELEASE).put("manufacturer", Build.BRAND).put("model", Build.MODEL)));
                } catch (JSONException e) {
                    e.printStackTrace();
                }
                HashMap hashMap = new HashMap();
                hashMap.put("Content-Type", RequestParams.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 str2, int i, Throwable th) {
                        a.a(b.a.this, str2, i, th);
                    }
                });
                return;
            case 1:
                return;
            case 2:
                d();
                return;
            default:
                return;
        }
    }

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

    private void d() {
        if (g() || !this.e.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 i, Throwable th) {
                a.this.a(str, i, th);
            }
        });
    }

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

    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() {
        byte[] bArr;
        FileInputStream fileInputStream;
        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 a2 = com.qiyukf.nimlib.j.a.a(true);
        File file = new File(a2);
        JSONObject jSONObject = new JSONObject();
        try {
            try {
                jSONObject.put("common", new JSONObject().put("sdk_type", "IM").put("device_id", b)).put(NotificationCompat.CATEGORY_EVENT, new JSONObject().put("logReport", new JSONObject().put("fileMD5", i.b(a2)).put("errorList", h())));
            } catch (Throwable th) {
                sb.append(jSONObject.toString());
                sb.append("\r\n");
                throw th;
            }
        } catch (JSONException e) {
            e.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_");
        sb2.append(new SimpleDateFormat("yyyyMMddhhmm", Locale.CHINA).format(new Date()));
        jSONObject = ".zip";
        sb2.append(".zip");
        sb.append(sb2.toString());
        sb.append("\"\r\n");
        sb.append("Content-Type: application/octet-stream\r\n\r\n");
        try {
            byteArrayOutputStream.write(sb.toString().getBytes());
            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();
        } catch (IOException e2) {
            e = e2;
            bArr = null;
        }
        try {
            byteArrayOutputStream.flush();
            byteArrayOutputStream.close();
            fileInputStream.close();
        } catch (IOException e3) {
            e = e3;
            e.printStackTrace();
            file.delete();
            if (bArr != null) {
            }
        }
        file.delete();
        return bArr != null ? new byte[0] : bArr;
    }

    public static void a(short s, byte b2, byte b3) {
        if (!(com.qiyukf.nimlib.c.g().reportImLog && (s == 408 || s == 415 || s == 500))) {
            return;
        }
        JSONArray h = h();
        ConcurrentHashMap concurrentHashMap = new ConcurrentHashMap();
        for (int i = 0; i < h.length(); i++) {
            Object opt = h.opt(i);
            if (opt instanceof JSONObject) {
                C0027a a2 = C0027a.a((JSONObject) opt);
                concurrentHashMap.put(a2.c(), a2);
            }
        }
        C0027a c0027a = new C0027a(s, b2, b3);
        String c2 = c0027a.c();
        C0027a c0027a2 = (C0027a) concurrentHashMap.get(c0027a.c());
        if (c0027a2 == null) {
            concurrentHashMap.put(c2, c0027a);
        } else {
            c0027a.a(c0027a2.a() + c0027a.a());
            concurrentHashMap.replace(c2, c0027a);
        }
        a((ConcurrentHashMap<String, C0027a>) concurrentHashMap);
    }

    private static boolean a(ConcurrentHashMap<String, C0027a> concurrentHashMap) {
        try {
            File c2 = c();
            JSONArray jSONArray = new JSONArray();
            Iterator<String> it = concurrentHashMap.keySet().iterator();
            while (it.hasNext()) {
                C0027a c0027a = concurrentHashMap.get(it.next());
                if (c0027a != null) {
                    jSONArray.put(new JSONObject(c0027a.b()));
                }
            }
            c2.setWritable(true);
            OutputStreamWriter outputStreamWriter = new OutputStreamWriter(new FileOutputStream(c2));
            outputStreamWriter.write(jSONArray.toString());
            outputStreamWriter.flush();
            outputStreamWriter.close();
            return true;
        } catch (IOException e) {
            e.printStackTrace();
            return false;
        } catch (JSONException e2) {
            e2.printStackTrace();
            return false;
        }
    }

    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();
            return sb2.isEmpty() ? new JSONArray() : new JSONArray(sb2);
        } catch (FileNotFoundException e) {
            e.printStackTrace();
            Log.e("@CJL/文件不存在", e.getMessage());
            return new JSONArray();
        } catch (IOException e2) {
            e2.printStackTrace();
            Log.e("@CJL/读写异常", e2.getMessage());
            return new JSONArray();
        } catch (JSONException e3) {
            e3.printStackTrace();
            Log.e("@CJL/字符串转JSONArray异常", e3.getMessage());
            return new JSONArray();
        }
    }

    public static class C0027a {
        private final short a;
        private final String b;
        private final long c;
        private final String d;
        private final String e;
        private int f;

        C0027a(short s, byte b, byte b2) {
            this(s, com.qiyukf.nimlib.c.k(), System.currentTimeMillis(), String.valueOf((int) b), String.valueOf((int) b2), 1);
        }

        private C0027a(short s, String str, long j, String str2, String str3, int i) {
            this.a = s;
            this.b = str == null ? "" : str;
            this.c = j;
            this.d = str2 == null ? "" : str2;
            this.e = str3 == null ? "" : str3;
            this.f = i;
        }

        final int a() {
            return this.f;
        }

        final void a(int i) {
            this.f = i;
        }

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

        public final String b() {
            JSONObject jSONObject = new JSONObject();
            try {
                jSONObject.put("errorCode", (int) this.a);
                jSONObject.put("accid", this.b);
                jSONObject.put("timestamp", this.c);
                jSONObject.put("module", this.d);
                jSONObject.put(Action.FILE_ATTRIBUTE, this.e);
                jSONObject.put(AlbumLoader.COLUMN_COUNT, this.f);
            } catch (JSONException e) {
                e.printStackTrace();
            }
            return jSONObject.toString();
        }

        final String c() {
            JSONObject jSONObject = new JSONObject();
            try {
                jSONObject.put("errorCode", (int) this.a);
                jSONObject.put("accid", this.b);
                jSONObject.put("module", this.d);
                jSONObject.put(Action.FILE_ATTRIBUTE, this.e);
                return jSONObject.toString();
            } catch (JSONException e) {
                e.printStackTrace();
                return null;
            }
        }
    }
}