米游社.apk(点击下载) / a.java


package com.geetest.sdk;

import android.app.Activity;
import android.content.Context;
import android.content.SharedPreferences;
import android.os.Build;
import android.text.TextUtils;
import com.geetest.sdk.ad;
import com.geetest.sdk.model.beans.Gt3GeetestText;
import com.geetest.sdk.utils.GT3ServiceNode;
import com.geetest.sdk.utils.l;
import com.geetest.sdk.utils.m;
import com.geetest.sdk.utils.n;
import com.xiaomi.mipush.sdk.Constants;
import java.io.File;
import java.util.Locale;
import java.util.UUID;
import org.json.JSONObject;

public class a {

    /* renamed from: a  reason: collision with root package name */
    private Context f29094a;

    /* renamed from: b  reason: collision with root package name */
    private GT3ConfigBean f29095b;

    /* renamed from: c  reason: collision with root package name */
    private b f29096c;

    /* renamed from: d  reason: collision with root package name */
    private long f29097d;

    /* renamed from: com.geetest.sdk.a$a  reason: collision with other inner class name */
    public class C0219a implements aj {
        public C0219a(a aVar) {
        }

        @Override // com.geetest.sdk.aj
        public void a(String str, int i10) {
            l.d("GeeLogger", "cgeelogger > cmd : " + str + " | code : " + i10);
        }
    }

    public class b implements am {
        public b(a aVar) {
        }

        @Override // com.geetest.sdk.am
        public void a(int i10, byte[] bArr) {
            String str = bArr != null ? new String(bArr) : "";
            l.d("GeeLogger", "日志上传结果, http状态码: " + i10 + ", 详细: " + str);
        }
    }

    public static /* synthetic */ class c {

        /* renamed from: a  reason: collision with root package name */
        public static final /* synthetic */ int[] f29098a;

        /* JADX WARNING: Can't wrap try/catch for region: R(6:0|1|2|3|4|(3:5|6|8)) */
        /* JADX WARNING: Failed to process nested try/catch */
        /* JADX WARNING: Missing exception handler attribute for start block: B:3:0x0012 */
        /* JADX WARNING: Missing exception handler attribute for start block: B:5:0x001d */
        static {
            int[] iArr = new int[GT3ServiceNode.values().length];
            f29098a = iArr;
            iArr[GT3ServiceNode.NODE_NORTH_AMERICA.ordinal()] = 1;
            f29098a[GT3ServiceNode.NODE_IPV6.ordinal()] = 2;
            try {
                f29098a[GT3ServiceNode.NODE_CHINA.ordinal()] = 3;
            } catch (NoSuchFieldError unused) {
            }
        }
    }

    public interface d {
        void a();

        void a(String str, String str2);

        void b();

        void c();

        void d();

        void e();

        void f();

        void g();

        void h();

        void i();
    }

    /* JADX WARNING: Can't wrap try/catch for region: R(9:2|(2:4|5)|8|9|10|11|12|15|16) */
    /* JADX WARNING: Code restructure failed: missing block: B:13:0x0093, code lost:
        r0 = move-exception;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:14:0x0094, code lost:
        r0.printStackTrace();
        r0 = "";
     */
    /* JADX WARNING: Failed to process nested try/catch */
    /* JADX WARNING: Missing exception handler attribute for start block: B:11:0x007f */
    public a(Context context) {
        this.f29094a = context;
        if (context != null) {
            this.f29096c = new b(context);
            a(context);
            n.f29462f = context.getApplicationContext().getCacheDir() + File.separator;
            File externalFilesDir = context.getExternalFilesDir(null);
            String absolutePath = context.getFilesDir().getAbsolutePath();
            if (externalFilesDir != null) {
                try {
                    m.f29456a = externalFilesDir.getAbsolutePath();
                    absolutePath = externalFilesDir.getAbsolutePath();
                } catch (Exception e10) {
                    e10.printStackTrace();
                }
            }
            ac.a(new ad.b().a(absolutePath).b(absolutePath).b("0123456789012345".getBytes()).a("0123456789012345".getBytes()).a());
            ac.a(true);
            ac.a(new C0219a(this));
            ac.a();
            String str = new JSONObject(j.a().a(context)).getString("fp");
            ac.a(context, "https://log.geetest.com/logger/mobile/log", context.getPackageName(), "1", str, new b(this));
        }
    }

    private void i() {
        GT3ConfigBean gT3ConfigBean = this.f29095b;
        if (gT3ConfigBean == null) {
            l.b("GeetestUtilsHolder", "GT3ConfigBean cannot be null !");
            throw new IllegalArgumentException("GT3ConfigBean cannot be null !");
        } else if (gT3ConfigBean.getListener() != null) {
            Context context = this.f29094a;
            if (context == null) {
                l.b("GeetestUtilsHolder", "Context cannot be null !");
                throw new IllegalArgumentException("Context cannot be null !");
            } else if (!(context instanceof Activity)) {
                l.b("GeetestUtilsHolder", "Context must be activity type !");
                throw new IllegalArgumentException("Context must be activity type !");
            }
        } else {
            l.b("GeetestUtilsHolder", "Listener cannot be null !");
            throw new IllegalArgumentException("Listener cannot be null !");
        }
    }

    private int j() {
        if (this.f29095b.getPattern() == 2) {
            return 2;
        }
        this.f29095b.getPattern();
        return 1;
    }

    public void a(GT3ConfigBean gT3ConfigBean) {
        Locale locale;
        String str;
        l.a(gT3ConfigBean.isReleaseLog());
        l.b("GeetestUtilsHolder", "GT3Version-->4.3.5.4");
        this.f29095b = gT3ConfigBean;
        i();
        if (Build.VERSION.SDK_INT >= 24) {
            locale = this.f29094a.getApplicationContext().getResources().getConfiguration().getLocales().get(0);
        } else {
            locale = this.f29094a.getApplicationContext().getResources().getConfiguration().locale;
        }
        StringBuilder sb2 = new StringBuilder();
        sb2.append("Lang-->");
        String str2 = "null";
        sb2.append(TextUtils.isEmpty(gT3ConfigBean.getLang()) ? str2 : gT3ConfigBean.getLang());
        sb2.append(", Default Lang-->");
        sb2.append(locale.getLanguage());
        l.b("GeetestUtilsHolder", sb2.toString());
        if (TextUtils.isEmpty(gT3ConfigBean.getLang())) {
            String str3 = "";
            if (TextUtils.equals("in", locale.getLanguage())) {
                StringBuilder sb3 = new StringBuilder();
                sb3.append("id");
                if (!TextUtils.isEmpty(locale.getCountry())) {
                    str3 = Constants.ACCEPT_TIME_SEPARATOR_SERVER + locale.getCountry();
                }
                sb3.append(str3);
                gT3ConfigBean.setLang(sb3.toString());
            } else {
                if (TextUtils.isEmpty(locale.getLanguage())) {
                    str = "zh";
                } else {
                    StringBuilder sb4 = new StringBuilder();
                    sb4.append(locale.getLanguage());
                    if (!TextUtils.isEmpty(locale.getCountry())) {
                        str3 = Constants.ACCEPT_TIME_SEPARATOR_SERVER + locale.getCountry();
                    }
                    sb4.append(str3);
                    str = sb4.toString();
                }
                gT3ConfigBean.setLang(str);
            }
        }
        Gt3GeetestText.updateLanguage(this.f29094a, gT3ConfigBean.getLang());
        StringBuilder sb5 = new StringBuilder();
        sb5.append("Parsed Lang-->");
        if (!TextUtils.isEmpty(gT3ConfigBean.getLang())) {
            str2 = gT3ConfigBean.getLang();
        }
        sb5.append(str2);
        l.b("GeetestUtilsHolder", sb5.toString());
        this.f29096c.a(gT3ConfigBean);
        this.f29096c.a(j());
    }

    public void b() {
        this.f29096c.b();
    }

    public void c() {
        this.f29096c.c();
    }

    public b d() {
        return this.f29096c;
    }

    public void e() {
        GT3ConfigBean gT3ConfigBean = this.f29095b;
        if (gT3ConfigBean == null || gT3ConfigBean.getGt3ServiceNode() == null) {
            this.f29096c.a("api.geetest.com");
        } else {
            int i10 = c.f29098a[this.f29095b.getGt3ServiceNode().ordinal()];
            if (i10 == 1) {
                this.f29096c.a("api-na.geetest.com");
            } else if (i10 != 2) {
                this.f29096c.a("api.geetest.com");
            } else {
                this.f29096c.a("apiv6.geetest.com");
            }
        }
        this.f29096c.m();
    }

    public void f() {
        this.f29096c.i();
    }

    public void g() {
        this.f29096c.k();
    }

    public void h() {
        if (System.currentTimeMillis() - this.f29097d >= 1000) {
            this.f29097d = System.currentTimeMillis();
            GT3ConfigBean gT3ConfigBean = this.f29095b;
            if (gT3ConfigBean == null || gT3ConfigBean.getGt3ServiceNode() == null) {
                this.f29096c.a("api.geetest.com");
            } else {
                int i10 = c.f29098a[this.f29095b.getGt3ServiceNode().ordinal()];
                if (i10 == 1) {
                    this.f29096c.a("api-na.geetest.com");
                } else if (i10 != 2) {
                    this.f29096c.a("api.geetest.com");
                } else {
                    this.f29096c.a("apiv6.geetest.com");
                }
            }
            this.f29096c.l();
        }
    }

    public void a() {
        this.f29096c.a();
    }

    private void a(Context context) {
        SharedPreferences sharedPreferences = context.getSharedPreferences("mydata", 0);
        if ("unknown".equals(sharedPreferences.getString("uuid", "unknown"))) {
            sharedPreferences.edit().putString("uuid", UUID.randomUUID().toString()).apply();
        }
    }
}