导航菜单

页面标题

页面副标题

Top浏览器 v4.6.16 - d.java 源代码

正在查看: Top浏览器 v4.6.16 应用的 d.java JAVA 源代码文件

本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。


package c.x.c;

import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
import android.os.Handler;
import android.os.HandlerThread;
import android.os.Looper;
import android.os.Message;
import android.os.SystemClock;
import android.text.TextUtils;
import android.util.DisplayMetrics;
import android.view.WindowManager;
import android.webkit.WebView;
import c.x.c.g.k;
import com.tencent.mm.opensdk.modelmsg.WXMediaMessage;
import com.uc.crashsdk.export.LogType;
import com.umeng.analytics.pro.ak;
import com.umeng.commonsdk.statistics.SdkVersion;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.io.UnsupportedEncodingException;
import java.lang.ref.WeakReference;
import java.net.SocketTimeoutException;
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.security.SecureRandom;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Random;
import java.util.TimeZone;
import java.util.concurrent.Executor;
import org.adblockplus.libadblockplus.android.webview.AdblockWebView;
import org.adblockplus.libadblockplus.android.webview.BaseSiteKeyExtractor;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

public class d {
    public HashMap<String, b> a = new HashMap<>();

    public static class a {
        public WeakReference<WebView> a;
        public long b;

        public String f619c;

        public a(WebView webView, long j2, String str) {
            this.a = new WeakReference<>(webView);
            this.b = j2;
            this.f619c = str;
        }

        public void a() {
            WebView webView = this.a.get();
            if (webView == null) {
                return;
            }
            webView.loadUrl("javascript:window.JsBridge&&JsBridge.callback(" + this.b + ",{'r':1,'result':'no such method'})");
        }

        public void b(Object obj) {
            String obj2;
            WebView webView = this.a.get();
            if (webView == null) {
                return;
            }
            if (obj instanceof String) {
                obj2 = "'" + ((Object) ((String) obj).replace("\\", "\\\\").replace("'", "\\'")) + "'";
            } else {
                obj2 = ((obj instanceof Number) || (obj instanceof Long) || (obj instanceof Integer) || (obj instanceof Double) || (obj instanceof Float)) ? obj.toString() : obj instanceof Boolean ? obj.toString() : "'undefined'";
            }
            webView.loadUrl("javascript:window.JsBridge&&JsBridge.callback(" + this.b + ",{'r':0,'result':" + obj2 + "});");
        }

        public void c(String str) {
            WebView webView = this.a.get();
            if (webView != null) {
                webView.loadUrl("javascript:" + str);
            }
        }
    }

    public static class b {
        public void a(java.lang.String r11, java.util.List<java.lang.String> r12, c.x.c.d.a r13) {
            throw new UnsupportedOperationException("Method not decompiled: c.x.c.d.b.a(java.lang.String, java.util.List, c.x.c.d$a):void");
        }

        public boolean b() {
            return false;
        }
    }

    public class c {
        public static final Uri a = Uri.parse("content://telephony/carriers/preferapn");

        public static String a(Context context) {
            int d2 = d(context);
            if (d2 == 2) {
                return "wifi";
            }
            if (d2 == 1) {
                return "cmwap";
            }
            if (d2 == 4) {
                return "cmnet";
            }
            if (d2 == 16) {
                return "uniwap";
            }
            if (d2 == 8) {
                return "uninet";
            }
            if (d2 == 64) {
                return "wap";
            }
            if (d2 == 32) {
                return "net";
            }
            if (d2 == 512) {
                return "ctwap";
            }
            if (d2 == 256) {
                return "ctnet";
            }
            if (d2 == 2048) {
                return "3gnet";
            }
            if (d2 == 1024) {
                return "3gwap";
            }
            String b = b(context);
            return (b == null || b.length() == 0) ? "none" : b;
        }

        public static String b(Context context) {
            return "";
        }

        public static String c(Context context) {
            try {
                Cursor query = context.getContentResolver().query(a, null, null, null, null);
                if (query == null) {
                    return null;
                }
                query.moveToFirst();
                if (query.isAfterLast()) {
                    query.close();
                    return null;
                }
                String string = query.getString(query.getColumnIndex("proxy"));
                query.close();
                return string;
            } catch (SecurityException e2) {
                c.x.c.f.a.h("openSDK_LOG.APNUtil", "getApnProxy has exception: " + e2.getMessage());
                return "";
            }
        }

        public static int d(Context context) {
            ConnectivityManager connectivityManager;
            NetworkInfo activeNetworkInfo;
            try {
                connectivityManager = (ConnectivityManager) context.getSystemService("connectivity");
            } catch (Exception e2) {
                c.x.c.f.a.h("openSDK_LOG.APNUtil", "getMProxyType has exception: " + e2.getMessage());
            }
            if (connectivityManager == null || (activeNetworkInfo = connectivityManager.getActiveNetworkInfo()) == null) {
                return 128;
            }
            if (activeNetworkInfo.getTypeName().toUpperCase().equals("WIFI")) {
                return 2;
            }
            String lowerCase = activeNetworkInfo.getExtraInfo().toLowerCase();
            if (lowerCase.startsWith("cmwap")) {
                return 1;
            }
            if (!lowerCase.startsWith("cmnet") && !lowerCase.startsWith("epc.tmobile.com")) {
                if (lowerCase.startsWith("uniwap")) {
                    return 16;
                }
                if (lowerCase.startsWith("uninet")) {
                    return 8;
                }
                if (lowerCase.startsWith("wap")) {
                    return 64;
                }
                if (lowerCase.startsWith("net")) {
                    return 32;
                }
                if (lowerCase.startsWith("ctwap")) {
                    return WXMediaMessage.TITLE_LENGTH_LIMIT;
                }
                if (lowerCase.startsWith("ctnet")) {
                    return LogType.UNEXP;
                }
                if (lowerCase.startsWith("3gwap")) {
                    return WXMediaMessage.DESCRIPTION_LENGTH_LIMIT;
                }
                if (lowerCase.startsWith("3gnet")) {
                    return 2048;
                }
                if (lowerCase.startsWith("#777")) {
                    String c2 = c(context);
                    if (c2 != null) {
                        if (c2.length() > 0) {
                            return WXMediaMessage.TITLE_LENGTH_LIMIT;
                        }
                    }
                    return LogType.UNEXP;
                }
                return 128;
            }
            return 4;
        }

        public static String e(Context context) {
            NetworkInfo activeNetworkInfo;
            ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService("connectivity");
            return (connectivityManager == null || (activeNetworkInfo = connectivityManager.getActiveNetworkInfo()) == null) ? "MOBILE" : activeNetworkInfo.getTypeName();
        }
    }

    public class C0038d {
        public static C0038d a;
        public String b = "";

        public String f620c = "";

        public String f621d = "";

        public String f622e = "";

        public String f623f = "";

        public String f624g = "";

        public String f625h = "";

        public List<Serializable> f626i = Collections.synchronizedList(new ArrayList());

        public List<Serializable> f627j = Collections.synchronizedList(new ArrayList());

        public Executor f628k = c.x.c.g.j.c();

        public boolean f629l;

        public class a implements Runnable {
            public final e a;

            public a(e eVar) {
                this.a = eVar;
            }

            @Override
            public void run() {
                C0038d.this.f626i.add(this.a);
                if (k.n(c.x.c.g.f.a())) {
                    try {
                        C0038d.this.n();
                        return;
                    } catch (Exception e2) {
                        c.x.c.f.a.i("AttaReporter", "Exception", e2);
                        return;
                    }
                }
                c.x.c.f.a.k("AttaReporter", "attaReport net disconnect, " + this.a);
            }
        }

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

        public final void c(e eVar) {
            this.f628k.execute(new a(eVar));
        }

        public void d(String str) {
            c.x.c.f.a.k("AttaReporter", "updateOpenId");
            if (str == null) {
                str = "";
            }
            this.f621d = str;
        }

        public void e(String str, Context context) {
            c.x.c.f.a.k("AttaReporter", "init");
            this.b = str;
            this.f620c = c.x.c.g.i.f(context);
            this.f622e = k.r(context, c.x.c.g.f.d());
            this.f623f = c.x.c.g.f.d();
            this.f624g = c.x.c.g.i.k(context) ? SdkVersion.MINI_VERSION : "0";
            this.f625h = k.o(context, "com.tencent.mobileqq");
            k();
        }

        public void f(String str, Object obj) {
            h(str, "", obj, null);
        }

        public void g(String str, String str2) {
            i(str, str2, null);
        }

        public void h(String str, String str2, Object obj, Map<String, Object> map) {
            e j2 = j(str, str2, obj, map);
            if (!TextUtils.isEmpty(this.b) && !TextUtils.isEmpty(this.f620c) && c.x.c.g.f.a() != null) {
                c(j2);
                return;
            }
            c.x.c.f.a.k("AttaReporter", "attaReport cancel appid=" + this.b + ", mAppName=" + this.f620c + ", context=" + c.x.c.g.f.a() + ", " + j2);
            this.f627j.add(j2);
        }

        public void i(String str, String str2, Map<String, Object> map) {
            h(str, str2, "", map);
        }

        public final e j(String str, String str2, Object obj, Map<String, Object> map) {
            long currentTimeMillis = System.currentTimeMillis();
            HashMap hashMap = new HashMap();
            hashMap.put("attaid", "09400051119");
            hashMap.put("token", "9389887874");
            hashMap.put("time_appid_openid", currentTimeMillis + "_" + this.b + "_" + this.f621d);
            hashMap.put("time", String.valueOf(currentTimeMillis));
            hashMap.put("openid", this.f621d);
            hashMap.put("appid", this.b);
            hashMap.put("app_name", this.f620c);
            hashMap.put("app_ver", this.f622e);
            hashMap.put("pkg_name", this.f623f);
            hashMap.put(ak.x, "AND");
            hashMap.put("os_ver", Build.VERSION.RELEASE);
            hashMap.put("sdk_ver", "3.5.8.lite");
            hashMap.put("model_name", c.x.c.g.e.a().c(c.x.c.g.f.a()));
            hashMap.put("interface_name", str);
            hashMap.put("interface_data", str2);
            hashMap.put("interface_result", obj == null ? "" : obj.toString());
            hashMap.put("qq_install", this.f624g);
            hashMap.put("qq_ver", this.f625h);
            if (map != null && !map.isEmpty()) {
                Object obj2 = map.get("reserve1");
                hashMap.put("reserve1", obj2 == null ? "" : obj2.toString());
                Object obj3 = map.get("reserve2");
                hashMap.put("reserve2", obj3 == null ? "" : obj3.toString());
                Object obj4 = map.get("reserve3");
                hashMap.put("reserve3", obj4 == null ? "" : obj4.toString());
                Object obj5 = map.get("reserve4");
                hashMap.put("reserve4", obj5 != null ? obj5.toString() : "");
            }
            return new e((HashMap<String, String>) hashMap);
        }

        public final void k() {
            while (!this.f627j.isEmpty()) {
                e eVar = (e) this.f627j.remove(0);
                eVar.a.put("appid", this.b);
                eVar.a.put("app_name", this.f620c);
                eVar.a.put("app_ver", this.f622e);
                eVar.a.put("pkg_name", this.f623f);
                eVar.a.put("qq_install", this.f624g);
                eVar.a.put("qq_ver", this.f625h);
                eVar.a.put("openid", this.f621d);
                eVar.a.put("time_appid_openid", eVar.a.get("time") + "_" + this.b + "_" + this.f621d);
                StringBuilder sb = new StringBuilder();
                sb.append("fixDirtyData--------------------------");
                sb.append(eVar);
                c.x.c.f.a.k("AttaReporter", sb.toString());
                this.f626i.add(eVar);
            }
        }

        public final boolean m(e eVar) {
            int i2 = 0;
            do {
                i2++;
                try {
                    c.x.c.f.a.k("AttaReporter", "doAttaReportItem post " + eVar);
                    return c.x.c.b.a.a().h("https://h.trace.qq.com/kv", eVar.a).d() == 200;
                } catch (Exception e2) {
                    c.x.c.f.a.l("AttaReporter", "Exception", e2);
                }
            } while (i2 < 2);
            return false;
        }

        public final void n() {
            c.x.c.f.a.k("AttaReporter", "attaReportAtSubThread");
            if (!this.f629l) {
                List<Serializable> b = i.a().b("report_atta");
                this.f629l = b.isEmpty();
                this.f626i.addAll(b);
                Iterator<Serializable> it2 = b.iterator();
                while (it2.hasNext()) {
                    c.x.c.f.a.k("AttaReporter", "attaReportAtSubThread from db = " + it2.next());
                }
            }
            ArrayList arrayList = new ArrayList();
            while (!this.f626i.isEmpty()) {
                e eVar = (e) this.f626i.remove(0);
                if (!m(eVar)) {
                    arrayList.add(eVar);
                }
            }
            if (arrayList.isEmpty()) {
                if (this.f629l) {
                    return;
                }
                c.x.c.f.a.k("AttaReporter", "attaReportAtSubThread clear db");
                i.a().i("report_atta");
                this.f629l = true;
                return;
            }
            c.x.c.f.a.k("AttaReporter", "attaReportAtSubThread fail size=" + arrayList.size());
            Iterator it3 = arrayList.iterator();
            while (it3.hasNext()) {
                c.x.c.f.a.k("AttaReporter", "attaReportAtSubThread fail cache to db, " + ((e) ((Serializable) it3.next())));
            }
            i.a().d("report_atta", arrayList);
            this.f629l = false;
        }
    }

    public class f {
        public static String a;
        public static String b;

        public static String a() {
            return "";
        }

        public static String b(Context context) {
            if (!TextUtils.isEmpty(a)) {
                return a;
            }
            if (context == null) {
                return "";
            }
            a = "";
            WindowManager windowManager = (WindowManager) context.getSystemService("window");
            if (windowManager != null) {
                a = windowManager.getDefaultDisplay().getWidth() + "x" + windowManager.getDefaultDisplay().getHeight();
            }
            return a;
        }

        public static String c() {
            return Locale.getDefault().getLanguage();
        }

        public static String d(Context context) {
            return "";
        }

        public static String e(Context context) {
            return "";
        }

        public static String f(Context context) {
            return "";
        }

        public static String g(Context context) {
            try {
                if (b == null) {
                    WindowManager windowManager = (WindowManager) context.getSystemService("window");
                    DisplayMetrics displayMetrics = new DisplayMetrics();
                    windowManager.getDefaultDisplay().getMetrics(displayMetrics);
                    StringBuilder sb = new StringBuilder();
                    sb.append("imei=");
                    sb.append(d(context));
                    sb.append('&');
                    sb.append("model=");
                    sb.append(c.x.c.g.e.a().c(c.x.c.g.f.a()));
                    sb.append('&');
                    sb.append("os=");
                    sb.append(Build.VERSION.RELEASE);
                    sb.append('&');
                    sb.append("apilevel=");
                    sb.append(Build.VERSION.SDK_INT);
                    sb.append('&');
                    String b2 = c.b(context);
                    if (b2 == null) {
                        b2 = "";
                    }
                    sb.append("network=");
                    sb.append(b2);
                    sb.append('&');
                    sb.append("sdcard=");
                    sb.append(Environment.getExternalStorageState().equals("mounted") ? 1 : 0);
                    sb.append('&');
                    sb.append("display=");
                    sb.append(displayMetrics.widthPixels);
                    sb.append('*');
                    sb.append(displayMetrics.heightPixels);
                    sb.append('&');
                    sb.append("manu=");
                    sb.append(Build.MANUFACTURER);
                    sb.append("&");
                    sb.append("wifi=");
                    sb.append(c.e(context));
                    b = sb.toString();
                }
                return b;
            } catch (Exception unused) {
                return null;
            }
        }
    }

    public class g {
        public static g a;

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

        public static Map<String, String> b(String str, String str2, String str3, String str4, String str5, String str6, String str7, String str8, String str9) {
            HashMap hashMap = new HashMap();
            hashMap.put("platform", SdkVersion.MINI_VERSION);
            hashMap.put("result", str);
            hashMap.put("code", str2);
            hashMap.put("tmcost", str3);
            hashMap.put("rate", str4);
            hashMap.put("cmd", str5);
            hashMap.put("uin", str6);
            hashMap.put("appid", str7);
            hashMap.put("share_type", str8);
            hashMap.put("detail", str9);
            hashMap.put("os_ver", Build.VERSION.RELEASE);
            hashMap.put("network", c.a(c.x.c.g.f.a()));
            hashMap.put("apn", c.b(c.x.c.g.f.a()));
            hashMap.put("model_name", c.x.c.g.e.a().c(c.x.c.g.f.a()));
            hashMap.put("sdk_ver", "3.5.8.lite");
            hashMap.put("packagename", c.x.c.g.f.d());
            hashMap.put("app_ver", k.r(c.x.c.g.f.a(), c.x.c.g.f.d()));
            return hashMap;
        }

        public void c(int i2, String str, String str2, String str3, String str4, Long l2, int i3, int i4, String str5) {
            long elapsedRealtime = SystemClock.elapsedRealtime() - l2.longValue();
            if (l2.longValue() == 0 || elapsedRealtime < 0) {
                elapsedRealtime = 0;
            }
            StringBuffer stringBuffer = new StringBuffer("https://huatuocode.huatuo.qq.com");
            stringBuffer.append("?domain=mobile.opensdk.com&cgi=opensdk&type=");
            stringBuffer.append(i2);
            stringBuffer.append("&code=");
            stringBuffer.append(i3);
            stringBuffer.append("&time=");
            stringBuffer.append(elapsedRealtime);
            stringBuffer.append("&rate=");
            stringBuffer.append(i4);
            stringBuffer.append("&uin=");
            stringBuffer.append(str2);
            try {
                String encode = URLEncoder.encode(c.x.c.g.a.f(b(String.valueOf(i2), String.valueOf(i3), String.valueOf(elapsedRealtime), String.valueOf(i4), str, str2, str3, str4, str5)), AdblockWebView.WebResponseResult.RESPONSE_CHARSET_NAME);
                stringBuffer.append("&data");
                stringBuffer.append("=");
                stringBuffer.append(encode);
                j.b().f(stringBuffer.toString(), null);
            } catch (UnsupportedEncodingException e2) {
                c.x.c.f.a.i("openSDK_LOG.OpenSdkStatic", "reportHaboCgi exception.", e2);
            }
        }

        public void d(String str, String str2, String str3, String str4, String str5, String str6) {
            j.b().c(k.c(str, str3, str4, str5, str2, str6), str2, true);
        }

        public void e(String str, String str2, String str3, String str4, String str5, String str6, String str7, String str8) {
            j.b().c(k.d(str, str4, str5, str3, str2, str6, "", str7, str8, "", "", ""), str2, false);
        }

        public void f(String str, String str2, String str3, String str4, String str5, String str6, String str7, String str8, String str9, String str10) {
            j.b().c(k.d(str, str4, str5, str3, str2, str6, str7, "", "", str8, str9, str10), str2, false);
        }
    }

    public class h {
        public static int a() {
            int b = c.x.c.g.g.c(c.x.c.g.f.a(), null).b("Common_HttpRetryCount");
            if (b == 0) {
                return 2;
            }
            return b;
        }

        public static int b(String str) {
            int b;
            if (c.x.c.g.f.a() == null || (b = c.x.c.g.g.c(c.x.c.g.f.a(), str).b("Common_BusinessReportFrequency")) == 0) {
                return 100;
            }
            return b;
        }
    }

    public class i extends SQLiteOpenHelper {
        public static final String[] a = {"key"};
        public static i b;

        public i(Context context) {
            super(context, "sdk_report.db", (SQLiteDatabase.CursorFactory) null, 2);
        }

        public static synchronized i a() {
            i iVar;
            synchronized (i.class) {
                if (b == null) {
                    b = new i(c.x.c.g.f.a());
                }
                iVar = b;
            }
            return iVar;
        }

        public synchronized java.util.List<java.io.Serializable> b(java.lang.String r12) {
            throw new UnsupportedOperationException("Method not decompiled: c.x.c.d.i.b(java.lang.String):java.util.List");
        }

        public synchronized void d(String str, List<Serializable> list) {
            ObjectOutputStream objectOutputStream;
            int size = list.size();
            if (size == 0) {
                return;
            }
            if (size > 20) {
                size = 20;
            }
            if (TextUtils.isEmpty(str)) {
                return;
            }
            i(str);
            SQLiteDatabase writableDatabase = getWritableDatabase();
            if (writableDatabase == null) {
                return;
            }
            writableDatabase.beginTransaction();
            try {
                try {
                    ContentValues contentValues = new ContentValues();
                    for (int i2 = 0; i2 < size; i2++) {
                        Serializable serializable = list.get(i2);
                        if (serializable != null) {
                            contentValues.put(com.umeng.analytics.pro.d.y, str);
                            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(WXMediaMessage.TITLE_LENGTH_LIMIT);
                            ObjectOutputStream objectOutputStream2 = null;
                            try {
                                objectOutputStream = new ObjectOutputStream(byteArrayOutputStream);
                                try {
                                    objectOutputStream.writeObject(serializable);
                                    try {
                                        objectOutputStream.close();
                                    } catch (IOException unused) {
                                    }
                                } catch (IOException unused2) {
                                    if (objectOutputStream != null) {
                                        objectOutputStream.close();
                                    }
                                    byteArrayOutputStream.close();
                                    contentValues.put("blob", byteArrayOutputStream.toByteArray());
                                    writableDatabase.insert("via_cgi_report", null, contentValues);
                                    contentValues.clear();
                                } catch (Throwable th) {
                                    th = th;
                                    objectOutputStream2 = objectOutputStream;
                                    if (objectOutputStream2 != null) {
                                        try {
                                            objectOutputStream2.close();
                                        } catch (IOException unused3) {
                                        }
                                    }
                                    try {
                                        byteArrayOutputStream.close();
                                        throw th;
                                    } catch (IOException unused4) {
                                        throw th;
                                    }
                                }
                            } catch (IOException unused5) {
                                objectOutputStream = null;
                            } catch (Throwable th2) {
                                th = th2;
                            }
                            try {
                                byteArrayOutputStream.close();
                            } catch (IOException unused6) {
                            }
                            contentValues.put("blob", byteArrayOutputStream.toByteArray());
                            writableDatabase.insert("via_cgi_report", null, contentValues);
                        }
                        contentValues.clear();
                    }
                    writableDatabase.setTransactionSuccessful();
                    writableDatabase.endTransaction();
                } catch (Throwable th3) {
                    writableDatabase.endTransaction();
                    writableDatabase.close();
                    throw th3;
                }
            } catch (Exception unused7) {
                c.x.c.f.a.h("openSDK_LOG.ReportDatabaseHelper", "saveReportItemToDB has exception.");
                writableDatabase.endTransaction();
            }
            writableDatabase.close();
        }

        public synchronized void i(String str) {
            if (TextUtils.isEmpty(str)) {
                return;
            }
            SQLiteDatabase writableDatabase = getWritableDatabase();
            try {
                if (writableDatabase == null) {
                    return;
                }
                try {
                    writableDatabase.delete("via_cgi_report", "type = ?", new String[]{str});
                } catch (Exception e2) {
                    c.x.c.f.a.i("openSDK_LOG.ReportDatabaseHelper", "clearReportItem has exception.", e2);
                }
            } finally {
            }
        }

        @Override
        public void onCreate(SQLiteDatabase sQLiteDatabase) {
            sQLiteDatabase.execSQL("CREATE TABLE IF NOT EXISTS via_cgi_report( _id INTEGER PRIMARY KEY,key TEXT,type TEXT,blob BLOB);");
        }

        @Override
        public void onUpgrade(SQLiteDatabase sQLiteDatabase, int i2, int i3) {
            sQLiteDatabase.execSQL("DROP TABLE IF EXISTS via_cgi_report");
            onCreate(sQLiteDatabase);
        }
    }

    public class j {
        public static j a;

        public HandlerThread f632e;

        public Handler f633f;
        public Random b = new SecureRandom();

        public List<Serializable> f631d = Collections.synchronizedList(new ArrayList());

        public List<Serializable> f630c = Collections.synchronizedList(new ArrayList());

        public Executor f634g = c.x.c.g.j.c();

        public Executor f635h = c.x.c.g.j.c();

        public class a extends Handler {
            public a(Looper looper) {
                super(looper);
            }

            @Override
            public void handleMessage(Message message) {
                int i2 = message.what;
                if (i2 == 1000) {
                    j.this.i();
                } else if (i2 == 1001) {
                    j.this.l();
                }
                super.handleMessage(message);
            }
        }

        public class b implements Runnable {
            public final Bundle a;
            public final boolean b;

            public b(Bundle bundle, boolean z) {
                this.a = bundle;
                this.b = z;
            }

            @Override
            public void run() {
                try {
                    String x = k.x(f.d(c.x.c.g.f.a()));
                    String x2 = k.x(f.e(c.x.c.g.f.a()));
                    String x3 = k.x(f.a());
                    String x4 = k.x(f.f(c.x.c.g.f.a()));
                    Bundle bundle = new Bundle();
                    bundle.putString("uin", "1000");
                    bundle.putString("imei", x);
                    bundle.putString("imsi", x2);
                    bundle.putString("android_id", x4);
                    bundle.putString("mac", x3);
                    bundle.putString("platform", SdkVersion.MINI_VERSION);
                    bundle.putString("os_ver", Build.VERSION.RELEASE);
                    bundle.putString("position", "");
                    bundle.putString("network", c.a(c.x.c.g.f.a()));
                    bundle.putString(ak.N, f.c());
                    bundle.putString(ak.z, f.b(c.x.c.g.f.a()));
                    bundle.putString("apn", c.b(c.x.c.g.f.a()));
                    bundle.putString("model_name", c.x.c.g.e.a().c(c.x.c.g.f.a()));
                    bundle.putString(ak.M, TimeZone.getDefault().getID());
                    bundle.putString("sdk_ver", "3.5.8.lite");
                    bundle.putString("qz_ver", k.r(c.x.c.g.f.a(), "com.qzone"));
                    bundle.putString("qq_ver", k.o(c.x.c.g.f.a(), "com.tencent.mobileqq"));
                    bundle.putString("qua", k.t(c.x.c.g.f.a(), c.x.c.g.f.d()));
                    bundle.putString("packagename", c.x.c.g.f.d());
                    bundle.putString("app_ver", k.r(c.x.c.g.f.a(), c.x.c.g.f.d()));
                    Bundle bundle2 = this.a;
                    if (bundle2 != null) {
                        bundle.putAll(bundle2);
                    }
                    j.this.f631d.add(new e(bundle));
                    int size = j.this.f631d.size();
                    int b = c.x.c.g.g.c(c.x.c.g.f.a(), null).b("Agent_ReportTimeInterval");
                    if (b == 0) {
                        b = 10000;
                    }
                    if (!j.this.g("report_via", size) && !this.b) {
                        if (j.this.f633f.hasMessages(1001)) {
                            return;
                        }
                        Message obtain = Message.obtain();
                        obtain.what = 1001;
                        j.this.f633f.sendMessageDelayed(obtain, b);
                        return;
                    }
                    j.this.l();
                    j.this.f633f.removeMessages(1001);
                } catch (Exception e2) {
                    c.x.c.f.a.i("openSDK_LOG.ReportManager", "--> reporVia, exception in sub thread.", e2);
                }
            }
        }

        public class c implements Runnable {
            public final long a;
            public final String b;

            public final String f637c;

            public final int f638d;

            public final long f639e;

            public final long f640f;

            public final boolean f641g;

            public c(long j2, String str, String str2, int i2, long j3, long j4, boolean z) {
                this.a = j2;
                this.b = str;
                this.f637c = str2;
                this.f638d = i2;
                this.f639e = j3;
                this.f640f = j4;
                this.f641g = z;
            }

            @Override
            public void run() {
                try {
                    long elapsedRealtime = SystemClock.elapsedRealtime() - this.a;
                    Bundle bundle = new Bundle();
                    String a = c.a(c.x.c.g.f.a());
                    bundle.putString("apn", a);
                    bundle.putString("appid", "1000067");
                    bundle.putString("commandid", this.b);
                    bundle.putString("detail", this.f637c);
                    StringBuilder sb = new StringBuilder();
                    sb.append("network=");
                    sb.append(a);
                    sb.append('&');
                    sb.append("sdcard=");
                    int i2 = 1;
                    sb.append(Environment.getExternalStorageState().equals("mounted") ? 1 : 0);
                    sb.append('&');
                    sb.append("wifi=");
                    sb.append(c.e(c.x.c.g.f.a()));
                    bundle.putString("deviceInfo", sb.toString());
                    int a2 = 100 / j.this.a(this.f638d);
                    if (a2 > 0) {
                        i2 = a2 > 100 ? 100 : a2;
                    }
                    bundle.putString("frequency", i2 + "");
                    bundle.putString("reqSize", this.f639e + "");
                    bundle.putString("resultCode", this.f638d + "");
                    bundle.putString("rspSize", this.f640f + "");
                    bundle.putString("timeCost", elapsedRealtime + "");
                    bundle.putString("uin", "1000");
                    j.this.f630c.add(new e(bundle));
                    int size = j.this.f630c.size();
                    int b = c.x.c.g.g.c(c.x.c.g.f.a(), null).b("Agent_ReportTimeInterval");
                    if (b == 0) {
                        b = 10000;
                    }
                    if (!j.this.g("report_cgi", size) && !this.f641g) {
                        if (!j.this.f633f.hasMessages(BaseSiteKeyExtractor.RESOURCE_HOLD_MAX_TIME_MS)) {
                            Message obtain = Message.obtain();
                            obtain.what = BaseSiteKeyExtractor.RESOURCE_HOLD_MAX_TIME_MS;
                            j.this.f633f.sendMessageDelayed(obtain, b);
                        }
                    }
                    j.this.i();
                    j.this.f633f.removeMessages(BaseSiteKeyExtractor.RESOURCE_HOLD_MAX_TIME_MS);
                } catch (Exception e2) {
                    c.x.c.f.a.i("openSDK_LOG.ReportManager", "--> reportCGI, exception in sub thread.", e2);
                }
            }
        }

        public class RunnableC0039d implements Runnable {
            public RunnableC0039d() {
            }

            @Override
            public void run() {
                try {
                    Map<String, String> j2 = j.this.j();
                    if (j2 != null && !j2.isEmpty()) {
                        int b = c.x.c.g.g.c(c.x.c.g.f.a(), null).b("Common_HttpRetryCount");
                        if (b == 0) {
                            b = 3;
                        }
                        c.x.c.f.a.f("openSDK_LOG.ReportManager", "-->doReportCgi, retryCount: " + b);
                        boolean z = false;
                        int i2 = 0;
                        while (true) {
                            i2++;
                            try {
                                try {
                                    int d2 = c.x.c.b.a.a().h("https://wspeed.qq.com/w.cgi", j2).d();
                                    c.x.c.f.a.k("openSDK_LOG.ReportManager", "-->doReportCgi, statusCode: " + d2);
                                    if (d2 != 200) {
                                        break;
                                    }
                                    i.a().i("report_cgi");
                                    z = true;
                                    break;
                                } catch (Exception e2) {
                                    c.x.c.f.a.i("openSDK_LOG.ReportManager", "-->doReportCgi, doupload exception", e2);
                                }
                            } catch (SocketTimeoutException e3) {
                                c.x.c.f.a.i("openSDK_LOG.ReportManager", "-->doReportCgi, doupload exception", e3);
                                if (i2 >= b) {
                                    break;
                                }
                            }
                        }
                        if (!z) {
                            i.a().d("report_cgi", j.this.f630c);
                        }
                        j.this.f630c.clear();
                    }
                } catch (Exception e4) {
                    c.x.c.f.a.i("openSDK_LOG.ReportManager", "-->doReportCgi, doupload exception out.", e4);
                }
            }
        }

        public class e implements Runnable {
            public e() {
            }

            @Override
            public void run() {
                throw new UnsupportedOperationException("Method not decompiled: c.x.c.d.j.e.run():void");
            }
        }

        public class f implements Runnable {
            public final String a;
            public final Map b;

            public f(String str, Map map) {
                this.a = str;
                this.b = map;
            }

            @Override
            public void run() {
                int i2 = 0;
                try {
                    int a = h.a();
                    if (a == 0) {
                        a = 3;
                    }
                    c.x.c.f.a.f("openSDK_LOG.ReportManager", "-->httpRequest, retryCount: " + a);
                    do {
                        i2++;
                        try {
                            c.x.c.f.a.k("openSDK_LOG.ReportManager", "-->httpRequest, statusCode: " + c.x.c.b.a.a().c(this.a, this.b).d());
                        } catch (SocketTimeoutException e2) {
                            c.x.c.f.a.i("openSDK_LOG.ReportManager", "-->ReportCenter httpRequest SocketTimeoutException:", e2);
                        } catch (Exception e3) {
                            c.x.c.f.a.i("openSDK_LOG.ReportManager", "-->ReportCenter httpRequest Exception:", e3);
                        }
                    } while (i2 < a);
                } catch (Exception e4) {
                    c.x.c.f.a.i("openSDK_LOG.ReportManager", "-->httpRequest, exception in serial executor:", e4);
                }
            }
        }

        public j() {
            this.f632e = null;
            if (this.f632e == null) {
                HandlerThread handlerThread = new HandlerThread("opensdk.report.handlerthread", 10);
                this.f632e = handlerThread;
                handlerThread.start();
            }
            if (!this.f632e.isAlive() || this.f632e.getLooper() == null) {
                return;
            }
            this.f633f = new a(this.f632e.getLooper());
        }

        public static synchronized j b() {
            j jVar;
            synchronized (j.class) {
                if (a == null) {
                    a = new j();
                }
                jVar = a;
            }
            return jVar;
        }

        public int a(int i2) {
            if (i2 == 0) {
                int b2 = c.x.c.g.g.c(c.x.c.g.f.a(), null).b("Common_CGIReportFrequencySuccess");
                if (b2 == 0) {
                    return 10;
                }
                return b2;
            }
            int b3 = c.x.c.g.g.c(c.x.c.g.f.a(), null).b("Common_CGIReportFrequencyFailed");
            if (b3 == 0) {
                return 100;
            }
            return b3;
        }

        public void c(Bundle bundle, String str, boolean z) {
            if (bundle == null) {
                return;
            }
            c.x.c.f.a.n("openSDK_LOG.ReportManager", "-->reportVia, bundle: " + bundle.toString());
            if (h("report_via", str) || z) {
                this.f634g.execute(new b(bundle, z));
            }
        }

        public void d(String str, long j2, long j3, long j4, int i2) {
            e(str, j2, j3, j4, i2, "", false);
        }

        public void e(String str, long j2, long j3, long j4, int i2, String str2, boolean z) {
            c.x.c.f.a.n("openSDK_LOG.ReportManager", "-->reportCgi, command: " + str + " | startTime: " + j2 + " | reqSize:" + j3 + " | rspSize: " + j4 + " | responseCode: " + i2 + " | detail: " + str2);
            if (h("report_cgi", "" + i2) || z) {
                this.f635h.execute(new c(j2, str, str2, i2, j3, j4, z));
            }
        }

        public void f(String str, Map<String, String> map) {
            if (k.n(c.x.c.g.f.a())) {
                c.x.c.g.j.d(new f(str, map));
            }
        }

        public boolean g(java.lang.String r5, int r6) {
            throw new UnsupportedOperationException("Method not decompiled: c.x.c.d.j.g(java.lang.String, int):boolean");
        }

        public boolean h(String str, String str2) {
            int a2;
            c.x.c.f.a.f("openSDK_LOG.ReportManager", "-->availableFrequency, report: " + str + " | ext: " + str2);
            boolean z = false;
            if (TextUtils.isEmpty(str)) {
                return false;
            }
            int i2 = 100;
            if (!str.equals("report_cgi")) {
                if (str.equals("report_via")) {
                    a2 = h.b(str2);
                    if (this.b.nextInt(100) < a2) {
                        i2 = a2;
                        z = true;
                    }
                }
                c.x.c.f.a.f("openSDK_LOG.ReportManager", "-->availableFrequency, result: " + z + " | frequency: " + i2);
                return z;
            }
            try {
                a2 = a(Integer.parseInt(str2));
                if (this.b.nextInt(100) < a2) {
                    z = true;
                }
            } catch (Exception unused) {
                return false;
            }
            i2 = a2;
            c.x.c.f.a.f("openSDK_LOG.ReportManager", "-->availableFrequency, result: " + z + " | frequency: " + i2);
            return z;
        }

        public void i() {
            if (k.n(c.x.c.g.f.a())) {
                this.f635h.execute(new RunnableC0039d());
            }
        }

        public Map<String, String> j() {
            if (this.f630c.size() == 0) {
                return null;
            }
            e eVar = (e) this.f630c.get(0);
            if (eVar == null) {
                c.x.c.f.a.f("openSDK_LOG.ReportManager", "-->prepareCgiData, the 0th cgireportitem is null.");
                return null;
            }
            String str = eVar.a.get("appid");
            List<Serializable> b2 = i.a().b("report_cgi");
            if (b2 != null) {
                this.f630c.addAll(b2);
            }
            c.x.c.f.a.f("openSDK_LOG.ReportManager", "-->prepareCgiData, mCgiList size: " + this.f630c.size());
            if (this.f630c.size() == 0) {
                return null;
            }
            HashMap hashMap = new HashMap();
            try {
                hashMap.put("appid", str);
                hashMap.put("releaseversion", "OpenSdk_3.5.8.lite");
                hashMap.put("device", c.x.c.g.e.a().b(c.x.c.g.f.a()));
                hashMap.put("qua", "V1_AND_OpenSDK_3.5.8.lite_1077_RDM_B");
                hashMap.put("key", "apn,frequency,commandid,resultcode,tmcost,reqsize,rspsize,detail,touin,deviceinfo");
                for (int i2 = 0; i2 < this.f630c.size(); i2++) {
                    e eVar2 = (e) this.f630c.get(i2);
                    hashMap.put(i2 + "_1", eVar2.a.get("apn"));
                    hashMap.put(i2 + "_2", eVar2.a.get("frequency"));
                    hashMap.put(i2 + "_3", eVar2.a.get("commandid"));
                    hashMap.put(i2 + "_4", eVar2.a.get("resultCode"));
                    hashMap.put(i2 + "_5", eVar2.a.get("timeCost"));
                    hashMap.put(i2 + "_6", eVar2.a.get("reqSize"));
                    hashMap.put(i2 + "_7", eVar2.a.get("rspSize"));
                    hashMap.put(i2 + "_8", eVar2.a.get("detail"));
                    hashMap.put(i2 + "_9", eVar2.a.get("uin"));
                    hashMap.put(i2 + "_10", f.g(c.x.c.g.f.a()) + "&" + eVar2.a.get("deviceInfo"));
                }
                c.x.c.f.a.n("openSDK_LOG.ReportManager", "-->prepareCgiData, end. params: " + hashMap.toString());
                return hashMap;
            } catch (Exception e2) {
                c.x.c.f.a.i("openSDK_LOG.ReportManager", "-->prepareCgiData, exception.", e2);
                return null;
            }
        }

        public Map<String, String> k() {
            List<Serializable> b2 = i.a().b("report_via");
            if (b2 != null) {
                this.f631d.addAll(b2);
            }
            c.x.c.f.a.f("openSDK_LOG.ReportManager", "-->prepareViaData, mViaList size: " + this.f631d.size());
            if (this.f631d.size() == 0) {
                return null;
            }
            JSONArray jSONArray = new JSONArray();
            for (Serializable serializable : this.f631d) {
                JSONObject jSONObject = new JSONObject();
                e eVar = (e) serializable;
                for (String str : eVar.a.keySet()) {
                    try {
                        String str2 = eVar.a.get(str);
                        if (str2 == null) {
                            str2 = "";
                        }
                        jSONObject.put(str, str2);
                    } catch (JSONException e2) {
                        c.x.c.f.a.i("openSDK_LOG.ReportManager", "-->prepareViaData, put bundle to json array exception", e2);
                    }
                }
                jSONArray.put(jSONObject);
            }
            c.x.c.f.a.n("openSDK_LOG.ReportManager", "-->prepareViaData, JSONArray array: " + jSONArray.toString());
            JSONObject jSONObject2 = new JSONObject();
            try {
                jSONObject2.put("data", jSONArray);
                HashMap hashMap = new HashMap();
                hashMap.put("data", jSONObject2.toString());
                return hashMap;
            } catch (JSONException e3) {
                c.x.c.f.a.i("openSDK_LOG.ReportManager", "-->prepareViaData, put bundle to json array exception", e3);
                return null;
            }
        }

        public void l() {
            if (k.n(c.x.c.g.f.a())) {
                this.f634g.execute(new e());
            }
        }
    }

    public void a(b bVar, String str) {
        this.a.put(str, bVar);
    }

    public void b(String str, String str2, List<String> list, a aVar) {
        c.x.c.f.a.n("openSDK_LOG.JsBridge", "getResult---objName = " + str + " methodName = " + str2);
        int size = list.size();
        for (int i2 = 0; i2 < size; i2++) {
            try {
                list.set(i2, URLDecoder.decode(list.get(i2), AdblockWebView.WebResponseResult.RESPONSE_CHARSET_NAME));
            } catch (UnsupportedEncodingException e2) {
                e2.printStackTrace();
            }
        }
        b bVar = this.a.get(str);
        if (bVar != null) {
            c.x.c.f.a.f("openSDK_LOG.JsBridge", "call----");
            bVar.a(str2, list, aVar);
        } else {
            c.x.c.f.a.f("openSDK_LOG.JsBridge", "not call----objName NOT FIND");
            if (aVar != null) {
                aVar.a();
            }
        }
    }

    public boolean c(WebView webView, String str) {
        c.x.c.f.a.n("openSDK_LOG.JsBridge", "-->canHandleUrl---url = " + str);
        if (str == null || !Uri.parse(str).getScheme().equals("jsbridge")) {
            return false;
        }
        ArrayList arrayList = new ArrayList(Arrays.asList((str + "/#").split("/")));
        if (arrayList.size() < 6) {
            return false;
        }
        String str2 = (String) arrayList.get(2);
        String str3 = (String) arrayList.get(3);
        List<String> subList = arrayList.subList(4, arrayList.size() - 1);
        a aVar = new a(webView, 4L, str);
        webView.getUrl();
        b(str2, str3, subList, aVar);
        return true;
    }

    public class e implements Serializable {
        public final HashMap<String, String> a;

        public e(Bundle bundle) {
            this.a = new HashMap<>();
            if (bundle != null) {
                for (String str : bundle.keySet()) {
                    this.a.put(str, bundle.getString(str));
                }
            }
        }

        public String toString() {
            return "BaseData{time=" + this.a.get("time") + ", name=" + this.a.get("interface_name") + '}';
        }

        public e(HashMap<String, String> hashMap) {
            this.a = new HashMap<>(hashMap);
        }
    }
}