九州世界 v1.0版本的 MD5 值为:7e82e48b69a4c36d0bdfb2a8d382d05d

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


package com.bytedance.bdtracker;

import android.net.Uri;
import android.os.Build;
import android.text.TextUtils;
import androidx.recyclerview.widget.ItemTouchHelper;
import com.bytedance.applog.InitConfig;
import com.bytedance.applog.convert.BuildConfig;
import com.bytedance.applog.log.EventBus;
import com.bytedance.applog.log.LogUtils;
import com.bytedance.applog.network.INetworkClient;
import com.bytedance.applog.network.RangersHttpException;
import com.bytedance.bdtracker.l0;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.Closeable;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.zip.GZIPInputStream;
import org.json.JSONArray;
import org.json.JSONObject;
public class p3 {
    public static JSONObject d;
    public String a = "https://databyterangers.com.cn";
    public final d b;
    public final p4 c;

    public class a implements EventBus.DataFetcher {
        public final JSONObject a;

        public a(JSONObject jSONObject) {
            this.a = jSONObject;
        }

        @Override
        public Object fetch() {
            JSONObject jSONObject = new JSONObject();
            l0.b.b(this.a, jSONObject);
            try {
                jSONObject.put("appId", p3.this.b.m);
            } catch (Throwable unused) {
            }
            return jSONObject;
        }
    }

    public class b implements EventBus.DataFetcher {
        public final String a;
        public final int b;
        public final byte[] c;
        public final String d;
        public final long e;
        public final HttpURLConnection f;

        public b(String str, int i, byte[] bArr, String str2, long j, HttpURLConnection httpURLConnection) {
            this.a = str;
            this.b = i;
            this.c = bArr;
            this.d = str2;
            this.e = j;
            this.f = httpURLConnection;
        }

        @Override
        public Object fetch() {
            JSONObject jSONObject = new JSONObject();
            try {
                jSONObject.put("appId", p3.this.b.m);
                jSONObject.put("nid", this.a);
                jSONObject.put("statusCode", this.b);
                jSONObject.put("responseByte", this.c);
                jSONObject.put("responseString", this.d);
                jSONObject.put("time", this.e);
                jSONObject.put("header", p3.this.a(this.f));
            } catch (Throwable unused) {
            }
            return jSONObject;
        }
    }

    public p3(d dVar) {
        this.b = dVar;
        this.c = new p4(dVar);
    }

    public static String a(String str, String[] strArr) {
        if (TextUtils.isEmpty(str)) {
            return str;
        }
        Uri parse = Uri.parse(str);
        HashMap hashMap = new HashMap(strArr.length);
        for (String str2 : strArr) {
            String queryParameter = parse.getQueryParameter(str2);
            if (!TextUtils.isEmpty(queryParameter)) {
                hashMap.put(str2, queryParameter);
            }
        }
        Uri.Builder buildUpon = parse.buildUpon();
        buildUpon.clearQuery();
        for (String str3 : hashMap.keySet()) {
            buildUpon.appendQueryParameter(str3, (String) hashMap.get(str3));
        }
        return buildUpon.build().toString();
    }

    public static JSONObject a(String str, String str2) {
        JSONObject jSONObject = new JSONObject();
        jSONObject.put("aid", str);
        jSONObject.put("os", "Android");
        jSONObject.put("os_version", String.valueOf(Build.VERSION.SDK_INT));
        jSONObject.put("sdk_version", BuildConfig.VERSION_NAME);
        jSONObject.put("app_version", str2);
        return jSONObject;
    }

    public static void a(StringBuilder sb, String str, String str2) {
        if (sb == null || TextUtils.isEmpty(str) || TextUtils.isEmpty(str2)) {
            return;
        }
        sb.append(sb.toString().indexOf(63) < 0 ? "?" : com.alipay.sdk.m.s.a.n);
        sb.append(str);
        sb.append("=");
        sb.append(Uri.encode(str2));
    }

    public static JSONObject b(JSONObject jSONObject) {
        JSONObject jSONObject2 = new JSONObject();
        jSONObject2.put("magic_tag", "ss_app_log");
        jSONObject2.put("header", jSONObject);
        jSONObject2.put("_gen_time", System.currentTimeMillis());
        return jSONObject2;
    }

    public final HashMap<String, String> a() {
        Map<String, String> httpHeaders;
        HashMap hashMap = new HashMap(2);
        InitConfig initConfig = this.b.getInitConfig();
        if (initConfig != null && (httpHeaders = initConfig.getHttpHeaders()) != null && !httpHeaders.isEmpty()) {
            hashMap.putAll(httpHeaders);
        }
        return p4.a(hashMap, this.b);
    }

    public final JSONObject a(String str) {
        if (str != null) {
            try {
                JSONObject jSONObject = new JSONObject(str);
                a(jSONObject);
                return jSONObject;
            } catch (Throwable th) {
                this.b.D.error(11, "JSON handle failed", th, new Object[0]);
                return null;
            }
        }
        return null;
    }

    public final JSONObject a(HttpURLConnection httpURLConnection) {
        if (httpURLConnection == null) {
            return null;
        }
        Map<String, List<String>> headerFields = httpURLConnection.getHeaderFields();
        if (headerFields.isEmpty()) {
            return null;
        }
        JSONObject jSONObject = new JSONObject();
        for (String str : headerFields.keySet()) {
            if (l0.b.d(str)) {
                try {
                    jSONObject.put(str, httpURLConnection.getHeaderField(str));
                } catch (Throwable unused) {
                }
            }
        }
        return jSONObject;
    }

    public final void a(String str, int i, byte[] bArr, String str2, long j, HttpURLConnection httpURLConnection) {
        LogUtils.sendJsonFetcher("do_request_end", new b(str, i, bArr, str2, j, httpURLConnection));
    }

    public final void a(JSONObject jSONObject) {
        try {
            long optLong = jSONObject.optLong("server_time");
            if (optLong > 0) {
                JSONObject jSONObject2 = new JSONObject();
                jSONObject2.put("server_time", optLong);
                jSONObject2.put("local_time", System.currentTimeMillis() / 1000);
                d = jSONObject2;
                LogUtils.sendJsonFetcher("server_time_sync", new a(jSONObject2));
            }
        } catch (Exception unused) {
        }
    }

    public JSONObject b(String str, JSONObject jSONObject) {
        String str2;
        this.b.D.debug(11, "Start to report oaid to uri:{} with request:{}...", str, jSONObject);
        try {
            str2 = new String(this.b.getNetClient().execute((byte) 1, this.c.a(str), jSONObject, a(), (byte) 0, true, 60000));
        } catch (Exception e) {
            e = e;
            str2 = null;
        }
        try {
            this.b.D.debug(11, "reportOaid success: {}", str2);
        } catch (Exception e2) {
            e = e2;
            this.b.D.error(11, "reportOaid error", e, new Object[0]);
            return a(str2);
        }
        return a(str2);
    }

    public JSONObject a(String str, JSONObject jSONObject) {
        String str2;
        this.b.D.debug(11, "Start to register to uri:{} with request:{}...", str, jSONObject);
        try {
            str2 = new String(this.b.getNetClient().execute((byte) 1, this.c.a(str), jSONObject, a(), (byte) 0, true, 60000));
            try {
                this.b.D.debug(11, "request register success: {}", str2);
            } catch (Throwable th) {
                th = th;
                this.b.D.error(11, "request register error", th, new Object[0]);
                return a(str2);
            }
        } catch (Throwable th2) {
            th = th2;
            str2 = null;
        }
        return a(str2);
    }

    public final String a(JSONObject jSONObject, String str, Map<String, String> map, int i) {
        GZIPInputStream gZIPInputStream;
        ByteArrayInputStream byteArrayInputStream;
        byte[] byteArray;
        String optString = jSONObject.optString("key");
        String optString2 = jSONObject.optString("iv");
        boolean z = true;
        byte b2 = (TextUtils.isEmpty(optString) || TextUtils.isEmpty(optString2)) ? (byte) 0 : (byte) 1;
        byte[] execute = this.b.getNetClient().execute((byte) 1, str, jSONObject, map, b2, true, i);
        if (b2 != 0) {
            String str2 = null;
            str2 = null;
            ByteArrayInputStream byteArrayInputStream2 = null;
            if (execute != null) {
                byte[] a2 = p4.a(execute, optString, optString2);
                if (a2 != null) {
                    if (a2.length <= 0) {
                        byteArray = null;
                    } else {
                        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
                        try {
                            byteArrayInputStream = new ByteArrayInputStream(a2);
                            try {
                                gZIPInputStream = new GZIPInputStream(byteArrayInputStream);
                            } catch (IOException unused) {
                                gZIPInputStream = null;
                            } catch (Throwable th) {
                                th = th;
                                gZIPInputStream = null;
                            }
                            try {
                                byte[] bArr = new byte[1024];
                                while (true) {
                                    int read = gZIPInputStream.read(bArr);
                                    if (read < 0) {
                                        break;
                                    }
                                    byteArrayOutputStream.write(bArr, 0, read);
                                }
                            } catch (IOException unused2) {
                            } catch (Throwable th2) {
                                th = th2;
                                byteArrayInputStream2 = byteArrayInputStream;
                                l0.b.a((Closeable) gZIPInputStream);
                                l0.b.a((Closeable) byteArrayInputStream2);
                                throw th;
                            }
                        } catch (IOException unused3) {
                            gZIPInputStream = null;
                            byteArrayInputStream = null;
                        } catch (Throwable th3) {
                            th = th3;
                            gZIPInputStream = null;
                        }
                        l0.b.a((Closeable) gZIPInputStream);
                        l0.b.a((Closeable) byteArrayInputStream);
                        byteArray = byteArrayOutputStream.toByteArray();
                    }
                    if (byteArray != null) {
                        str2 = new String(byteArray);
                    }
                } else {
                    str2 = new String(execute);
                }
                z = false;
            }
            return z ? new String(this.b.getNetClient().execute((byte) 1, str, jSONObject, map, (byte) 0, true, 60000)) : str2;
        }
        return new String(execute);
    }

    public int a(String[] strArr, JSONObject jSONObject, p1 p1Var) {
        int i;
        JSONObject jSONObject2;
        int i2;
        HashMap<String, String> a2 = a();
        int length = strArr.length;
        JSONObject jSONObject3 = null;
        int i3 = 0;
        int i4 = 102;
        while (true) {
            if (i3 >= length) {
                i = 0;
                break;
            }
            try {
                i2 = i3;
                i = 0;
                try {
                    String str = new String(this.b.getNetClient().execute((byte) 1, strArr[i3], jSONObject, a2, (byte) 0, true, 60000));
                    if (TextUtils.isEmpty(str)) {
                        continue;
                    } else {
                        jSONObject2 = new JSONObject(str);
                        try {
                            a(jSONObject2);
                            if (!"ss_app_log".equals(jSONObject2.optString("magic_tag"))) {
                                jSONObject3 = jSONObject2;
                                i4 = 102;
                            } else if ("success".equals(jSONObject2.optString("message"))) {
                                i4 = ItemTouchHelper.Callback.DEFAULT_DRAG_ANIMATION_DURATION;
                                break;
                            } else {
                                i4 = 101;
                                jSONObject3 = jSONObject2;
                            }
                        } catch (Exception e) {
                            e = e;
                            jSONObject3 = jSONObject2;
                            if (e instanceof RangersHttpException) {
                                int responseCode = ((RangersHttpException) e).getResponseCode();
                                if (p1Var.c.isCongestionControlEnable()) {
                                    if (responseCode >= 500 && responseCode < 600) {
                                        i4 = responseCode;
                                        jSONObject2 = jSONObject3;
                                        if (jSONObject2 != null) {
                                        }
                                        return i4;
                                    }
                                }
                                i4 = responseCode;
                            } else {
                                this.b.D.error(11, "Send to server failed", e, new Object[i]);
                            }
                            i3 = i2 + 1;
                        }
                    }
                } catch (Exception e2) {
                    e = e2;
                }
            } catch (Exception e3) {
                e = e3;
                i2 = i3;
                i = 0;
            }
            i3 = i2 + 1;
        }
        if (jSONObject2 != null) {
            p1Var.a(jSONObject2);
            JSONObject optJSONObject = jSONObject2.optJSONObject("blocklist");
            if (optJSONObject != null) {
                JSONArray optJSONArray = optJSONObject.optJSONArray(com.alipay.sdk.m.x.c.c);
                int length2 = optJSONArray != null ? optJSONArray.length() : 0;
                HashSet<String> hashSet = new HashSet<>(length2);
                for (int i5 = 0; i5 < length2; i5++) {
                    String optString = optJSONArray.optString(i5, null);
                    if (!TextUtils.isEmpty(optString)) {
                        hashSet.add(optString);
                    }
                }
                JSONArray optJSONArray2 = optJSONObject.optJSONArray("v3");
                int length3 = optJSONArray2 != null ? optJSONArray2.length() : 0;
                HashSet<String> hashSet2 = new HashSet<>(length3);
                while (i < length3) {
                    String optString2 = optJSONArray2.optString(i, null);
                    if (!TextUtils.isEmpty(optString2)) {
                        hashSet2.add(optString2);
                    }
                    i++;
                }
                p1Var.a(hashSet, hashSet2);
            } else {
                p1Var.a((HashSet<String>) null, (HashSet<String>) null);
            }
        }
        return i4;
    }

    public boolean a(JSONObject jSONObject, String str) {
        this.b.D.debug(11, "Start to send event:{} with cookie:{} to et...", jSONObject, str);
        JSONObject jSONObject2 = new JSONObject();
        try {
            jSONObject2.put("header", this.b.getHeader());
            if (jSONObject != null) {
                JSONArray jSONArray = new JSONArray();
                jSONArray.put(jSONObject);
                jSONObject2.put("event_v3", jSONArray);
            }
        } catch (Throwable th) {
            this.b.D.error(11, "JSON handle failed", th, new Object[0]);
        }
        HashMap<String, String> a2 = a();
        a2.put("Cookie", str);
        try {
            INetworkClient netClient = this.b.getNetClient();
            String str2 = new String(netClient.execute((byte) 1, this.a + "/simulator/mobile/log", jSONObject2, a2, (byte) 0, true, 60000));
            if (!new JSONObject(str2).getJSONObject(com.alipay.sdk.m.p.e.m).optBoolean("keep", false)) {
                this.b.setRangersEventVerifyEnable(false, str);
            }
            this.b.D.debug(11, "Send event to et with response:{}", str2);
            return true;
        } catch (Throwable th2) {
            this.b.D.error(11, "Post to event verify failed", th2, new Object[0]);
            return false;
        }
    }
}