apk(点击下载) / es.java


package com.amap.api.col;

import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.os.Build;
import android.text.TextUtils;
import com.amap.api.maps2d.AMapException;
import com.meizu.cloud.pushsdk.notification.model.NotifyType;
import com.netease.nimlib.sdk.msg.model.RecentSession;
import java.lang.reflect.Field;
import java.net.URLDecoder;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.crypto.Cipher;
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;
import okhttp3.HttpUrl;
import org.json.JSONException;
import org.json.JSONObject;

/* compiled from: AuthConfigManager */
public class es {
    public static int a = -1;
    public static String b = "";

    /* compiled from: AuthConfigManager */
    public static class a {
        public String a;
        public int b = -1;
        public JSONObject c;

        /* renamed from: d  reason: collision with root package name */
        public JSONObject f1006d;
        public JSONObject e;
        public JSONObject f;
        public JSONObject g;
        public JSONObject h;
        public JSONObject i;
        public JSONObject j;
        public JSONObject k;
        public JSONObject l;
        public JSONObject m;
        public JSONObject n;
        public JSONObject o;
        public C0003a p;
        public d q;
        public c r;
        public b s;
        public b t;
        public b u;
        public b v;

        /* renamed from: com.amap.api.col.es$a$a  reason: collision with other inner class name */
        /* compiled from: AuthConfigManager */
        public static class C0003a {
            public boolean a;
            public boolean b;
        }

        /* compiled from: AuthConfigManager */
        public static class b {
            public boolean a;
            public String b;
            public String c;

            /* renamed from: d  reason: collision with root package name */
            public String f1007d;
        }

        /* compiled from: AuthConfigManager */
        public static class c {
            public String a;
            public String b;
        }

        /* compiled from: AuthConfigManager */
        public static class d {
            public String a;
            public String b;
            public String c;
        }
    }

    /* access modifiers changed from: package-private */
    /* compiled from: AuthConfigManager */
    public static class b extends gs {
        private String c;

        /* renamed from: d  reason: collision with root package name */
        private Map<String, String> f1008d;

        b(Context context, fa faVar, String str, Map<String, String> map) {
            super(context, faVar);
            this.c = str;
            this.f1008d = map;
        }

        private Map<String, String> m() {
            String q = ev.q(this.a);
            if (!TextUtils.isEmpty(q)) {
                q = ex.b(new StringBuilder(q).reverse().toString());
            }
            HashMap hashMap = new HashMap();
            hashMap.put("authkey", this.c);
            hashMap.put("plattype", "android");
            hashMap.put("product", this.b.a());
            hashMap.put("version", this.b.b());
            hashMap.put("output", "json");
            StringBuilder sb = new StringBuilder();
            int i = Build.VERSION.SDK_INT;
            sb.append(i);
            sb.append("");
            hashMap.put("androidversion", sb.toString());
            hashMap.put("deviceId", q);
            Map<String, String> map = this.f1008d;
            if (map != null && !map.isEmpty()) {
                hashMap.putAll(this.f1008d);
            }
            String str = null;
            if (i >= 21) {
                try {
                    ApplicationInfo applicationInfo = this.a.getApplicationInfo();
                    Field declaredField = Class.forName(ApplicationInfo.class.getName()).getDeclaredField("primaryCpuAbi");
                    declaredField.setAccessible(true);
                    str = (String) declaredField.get(applicationInfo);
                } catch (Throwable th) {
                    ff.a(th, "ConfigManager", "getcpu");
                }
            }
            if (TextUtils.isEmpty(str)) {
                str = Build.CPU_ABI;
            }
            hashMap.put("abitype", str);
            hashMap.put(RecentSession.KEY_EXT, this.b.e());
            return hashMap;
        }

        @Override // com.amap.api.col.gs
        public byte[] a() {
            return null;
        }

        @Override // com.amap.api.col.gs
        public byte[] b() {
            return fb.a(fb.b(m()));
        }

        /* access modifiers changed from: protected */
        @Override // com.amap.api.col.gs
        public String c() {
            return "3.0";
        }

        @Override // com.amap.api.col.gx
        public Map<String, String> e() {
            return null;
        }

        @Override // com.amap.api.col.gx
        public String g() {
            return "https://restapi.amap.com/v3/iasdkauth";
        }
    }

    public static void a(String str) {
        er.b(str);
    }

    public static boolean a(String str, boolean z) {
        try {
            String[] split = URLDecoder.decode(str).split("/");
            if (split[split.length - 1].charAt(4) % 2 == 1) {
                return true;
            }
            return false;
        } catch (Throwable unused) {
            return z;
        }
    }

    /* JADX WARNING: Removed duplicated region for block: B:73:0x0124 A[RETURN] */
    /* JADX WARNING: Removed duplicated region for block: B:74:0x0125  */
    public static a a(Context context, fa faVar, String str, Map<String, String> map) {
        String str2;
        String str3;
        String str4;
        String str5;
        byte[] bArr;
        gz gzVar;
        List<String> list;
        eq e;
        Throwable th;
        eq e2;
        a aVar = new a();
        String str6 = null;
        try {
            try {
                str5 = "11E";
                str4 = "11H";
                str3 = "11I";
                try {
                    gzVar = new gr().a(new b(context, faVar, str, map), true);
                    if (gzVar != null) {
                        try {
                            bArr = gzVar.a;
                        } catch (eq e3) {
                            e = e3;
                            str2 = "11C";
                            bArr = null;
                            aVar.a = e.a();
                            if (bArr == null) {
                            }
                        } catch (IllegalBlockSizeException unused) {
                            str2 = "11C";
                            bArr = null;
                        } catch (Throwable th2) {
                            th = th2;
                            str2 = "11C";
                            bArr = null;
                            ff.a(th, "ConfigManager", "loadConfig");
                            if (bArr == null) {
                            }
                        }
                    } else {
                        bArr = null;
                    }
                } catch (eq e4) {
                    e2 = e4;
                    throw e2;
                } catch (Throwable unused2) {
                    str2 = "11C";
                    try {
                        throw new eq(AMapException.ERROR_UNKNOWN);
                    } catch (eq e5) {
                        e = e5;
                        gzVar = null;
                        bArr = null;
                        aVar.a = e.a();
                        if (bArr == null) {
                        }
                    } catch (IllegalBlockSizeException unused3) {
                        gzVar = null;
                        bArr = null;
                        if (bArr == null) {
                        }
                    } catch (Throwable th3) {
                        th = th3;
                        gzVar = null;
                        bArr = null;
                        ff.a(th, "ConfigManager", "loadConfig");
                        if (bArr == null) {
                        }
                    }
                }
            } catch (eq e6) {
                e2 = e6;
                throw e2;
            } catch (Throwable unused4) {
                str5 = "11E";
                str4 = "11H";
                str3 = "11I";
                str2 = "11C";
                throw new eq(AMapException.ERROR_UNKNOWN);
            }
            try {
                byte[] bArr2 = new byte[16];
                byte[] bArr3 = new byte[(bArr.length - 16)];
                try {
                    System.arraycopy(bArr, 0, bArr2, 0, 16);
                    str2 = "11C";
                } catch (eq e7) {
                    e = e7;
                    str2 = "11C";
                    gzVar = gzVar;
                    aVar.a = e.a();
                    if (bArr == null) {
                    }
                } catch (IllegalBlockSizeException unused5) {
                    str2 = "11C";
                } catch (Throwable th4) {
                    th = th4;
                    str2 = "11C";
                    gzVar = gzVar;
                    ff.a(th, "ConfigManager", "loadConfig");
                    if (bArr == null) {
                    }
                }
                try {
                    System.arraycopy(bArr, 16, bArr3, 0, bArr.length - 16);
                    SecretKeySpec secretKeySpec = new SecretKeySpec(bArr2, "AES");
                    Cipher instance = Cipher.getInstance("AES/CBC/PKCS5Padding");
                    instance.init(2, secretKeySpec, new IvParameterSpec(fb.a()));
                    str6 = fb.a(instance.doFinal(bArr3));
                } catch (eq e8) {
                    e = e8;
                    gzVar = gzVar;
                    aVar.a = e.a();
                    if (bArr == null) {
                    }
                } catch (IllegalBlockSizeException unused6) {
                } catch (Throwable th5) {
                    th = th5;
                    gzVar = gzVar;
                    ff.a(th, "ConfigManager", "loadConfig");
                    if (bArr == null) {
                    }
                }
                gzVar = gzVar;
            } catch (eq e9) {
                e = e9;
                str2 = "11C";
                aVar.a = e.a();
            } catch (IllegalBlockSizeException unused7) {
                str2 = "11C";
            } catch (Throwable th6) {
                th = th6;
                str2 = "11C";
                ff.a(th, "ConfigManager", "loadConfig");
            }
        } catch (eq e10) {
            e = e10;
            str5 = "11E";
            str4 = "11H";
            str3 = "11I";
            str2 = "11C";
            gzVar = null;
            bArr = null;
            aVar.a = e.a();
            if (bArr == null) {
            }
        } catch (IllegalBlockSizeException unused8) {
            str5 = "11E";
            str4 = "11H";
            str3 = "11I";
            str2 = "11C";
            gzVar = null;
            bArr = null;
            if (bArr == null) {
            }
        } catch (Throwable th7) {
            th = th7;
            str5 = "11E";
            str4 = "11H";
            str3 = "11I";
            str2 = "11C";
            gzVar = null;
            bArr = null;
            ff.a(th, "ConfigManager", "loadConfig");
            if (bArr == null) {
            }
        }
        if (bArr == null) {
            return aVar;
        }
        if (TextUtils.isEmpty(str6)) {
            str6 = fb.a(bArr);
        }
        try {
            JSONObject jSONObject = new JSONObject(str6);
            if (jSONObject.has("status")) {
                int i = jSONObject.getInt("status");
                if (i == 1) {
                    a = 1;
                } else if (i == 0) {
                    String str7 = "authcsid";
                    String str8 = "authgsid";
                    if (gzVar != null) {
                        str7 = gzVar.c;
                        Map<String, List<String>> map2 = gzVar.b;
                        if (!(map2 == null || (list = map2.get("gsid")) == null || list.size() <= 0)) {
                            str8 = list.get(0);
                        }
                    }
                    fb.a(context, str7, str8, jSONObject.toString());
                    a = 0;
                    if (jSONObject.has("info")) {
                        b = jSONObject.getString("info");
                    }
                    if (a == 0) {
                        aVar.a = b;
                        return aVar;
                    }
                }
                try {
                    if (jSONObject.has("ver")) {
                        aVar.b = jSONObject.getInt("ver");
                    }
                } catch (Throwable th8) {
                    ff.a(th8, "AuthConfigManager", "loadConfigVer");
                }
                if (fb.a(jSONObject, "result")) {
                    a.C0003a aVar2 = new a.C0003a();
                    aVar2.a = false;
                    aVar2.b = false;
                    aVar.p = aVar2;
                    JSONObject jSONObject2 = jSONObject.getJSONObject("result");
                    if (fb.a(jSONObject2, "11K")) {
                        try {
                            aVar2.a = a(jSONObject2.getJSONObject("11K").getString("able"), false);
                        } catch (Throwable th9) {
                            ff.a(th9, "AuthConfigManager", "loadException");
                        }
                    }
                    if (fb.a(jSONObject2, "11B")) {
                        aVar.f1006d = jSONObject2.getJSONObject("11B");
                    }
                    if (fb.a(jSONObject2, str2)) {
                        aVar.g = jSONObject2.getJSONObject(str2);
                    }
                    if (fb.a(jSONObject2, str3)) {
                        aVar.h = jSONObject2.getJSONObject(str3);
                    }
                    if (fb.a(jSONObject2, str4)) {
                        aVar.i = jSONObject2.getJSONObject(str4);
                    }
                    if (fb.a(jSONObject2, str5)) {
                        aVar.j = jSONObject2.getJSONObject(str5);
                    }
                    if (fb.a(jSONObject2, "11F")) {
                        aVar.k = jSONObject2.getJSONObject("11F");
                    }
                    if (fb.a(jSONObject2, "13A")) {
                        aVar.m = jSONObject2.getJSONObject("13A");
                    }
                    if (fb.a(jSONObject2, "13J")) {
                        aVar.e = jSONObject2.getJSONObject("13J");
                    }
                    if (fb.a(jSONObject2, "11G")) {
                        aVar.l = jSONObject2.getJSONObject("11G");
                    }
                    if (fb.a(jSONObject2, "001")) {
                        JSONObject jSONObject3 = jSONObject2.getJSONObject("001");
                        a.d dVar = new a.d();
                        a(jSONObject3, dVar);
                        aVar.q = dVar;
                    }
                    if (fb.a(jSONObject2, "002")) {
                        JSONObject jSONObject4 = jSONObject2.getJSONObject("002");
                        a.c cVar = new a.c();
                        a(jSONObject4, cVar);
                        aVar.r = cVar;
                    }
                    if (fb.a(jSONObject2, "006")) {
                        aVar.n = jSONObject2.getJSONObject("006");
                    }
                    if (fb.a(jSONObject2, "010")) {
                        aVar.o = jSONObject2.getJSONObject("010");
                    }
                    if (fb.a(jSONObject2, "11Z")) {
                        JSONObject jSONObject5 = jSONObject2.getJSONObject("11Z");
                        a.b bVar = new a.b();
                        a(jSONObject5, bVar);
                        aVar.s = bVar;
                    }
                    if (fb.a(jSONObject2, "135")) {
                        aVar.f = jSONObject2.getJSONObject("135");
                    }
                    if (fb.a(jSONObject2, "13S")) {
                        aVar.c = jSONObject2.getJSONObject("13S");
                    }
                    if (fb.a(jSONObject2, "121")) {
                        JSONObject jSONObject6 = jSONObject2.getJSONObject("121");
                        a.b bVar2 = new a.b();
                        a(jSONObject6, bVar2);
                        aVar.t = bVar2;
                    }
                    if (fb.a(jSONObject2, "122")) {
                        JSONObject jSONObject7 = jSONObject2.getJSONObject("122");
                        a.b bVar3 = new a.b();
                        a(jSONObject7, bVar3);
                        aVar.u = bVar3;
                    }
                    if (fb.a(jSONObject2, "123")) {
                        JSONObject jSONObject8 = jSONObject2.getJSONObject("123");
                        a.b bVar4 = new a.b();
                        a(jSONObject8, bVar4);
                        aVar.v = bVar4;
                    }
                }
                return aVar;
            }
        } catch (Throwable th10) {
            ff.a(th10, "AuthConfigManager", "loadConfig");
        }
        return aVar;
    }

    public static String a(JSONObject jSONObject, String str) throws JSONException {
        if (jSONObject != null && jSONObject.has(str) && !jSONObject.getString(str).equals(HttpUrl.PATH_SEGMENT_ENCODE_SET_URI)) {
            return jSONObject.optString(str);
        }
        return "";
    }

    private static void a(JSONObject jSONObject, a.b bVar) {
        if (bVar != null) {
            try {
                String a2 = a(jSONObject, "m");
                String a3 = a(jSONObject, "u");
                String a4 = a(jSONObject, NotifyType.VIBRATE);
                String a5 = a(jSONObject, "able");
                bVar.c = a2;
                bVar.b = a3;
                bVar.f1007d = a4;
                bVar.a = a(a5, false);
            } catch (Throwable th) {
                ff.a(th, "ConfigManager", "parsePluginEntity");
            }
        }
    }

    private static void a(JSONObject jSONObject, a.c cVar) {
        if (jSONObject != null) {
            try {
                String a2 = a(jSONObject, "md5");
                String a3 = a(jSONObject, "url");
                cVar.b = a2;
                cVar.a = a3;
            } catch (Throwable th) {
                ff.a(th, "ConfigManager", "parseSDKCoordinate");
            }
        }
    }

    private static void a(JSONObject jSONObject, a.d dVar) {
        if (jSONObject != null) {
            try {
                String a2 = a(jSONObject, "md5");
                String a3 = a(jSONObject, "url");
                String a4 = a(jSONObject, "sdkversion");
                if (!TextUtils.isEmpty(a2) && !TextUtils.isEmpty(a3)) {
                    if (!TextUtils.isEmpty(a4)) {
                        dVar.a = a3;
                        dVar.b = a2;
                        dVar.c = a4;
                    }
                }
            } catch (Throwable th) {
                ff.a(th, "ConfigManager", "parseSDKUpdate");
            }
        }
    }
}