京东到家.apk(点击下载) / wg.java


package com.tencent.mapsdk.internal;

import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.os.AsyncTask;
import android.os.Bundle;
import com.tencent.map.tools.net.NetManager;
import com.tencent.map.tools.net.NetResponse;
import java.io.Closeable;
import java.io.InputStream;
import java.lang.ref.WeakReference;
import org.json.JSONException;
import org.json.JSONObject;

/* compiled from: TMS */
public class wg {

    /* renamed from: c  reason: collision with root package name */
    private static final String f2228c = "https://confinfo.map.qq.com/confinfo?";
    private Context a;
    private WeakReference<b> b;

    /* compiled from: TMS */
    public interface b {
        void a();
    }

    /* compiled from: TMS */
    public class c extends AsyncTask<Context, Void, Void> {
        private c() {
        }

        /* JADX WARNING: Code restructure failed: missing block: B:22:0x0074, code lost:
            if (r7.a.a != null) goto L_0x00cf;
         */
        /* JADX WARNING: Removed duplicated region for block: B:39:0x00b4 A[DONT_GENERATE] */
        /* JADX WARNING: Removed duplicated region for block: B:41:0x00b9 A[DONT_GENERATE] */
        /* JADX WARNING: Removed duplicated region for block: B:44:0x00c4 A[DONT_GENERATE] */
        /* JADX WARNING: Removed duplicated region for block: B:46:0x00c7 A[DONT_GENERATE] */
        /* renamed from: a */
        public Void doInBackground(Context... contextArr) {
            Throwable th;
            InputStream inputStream;
            int a2 = tg.a();
            StringBuilder sb = new StringBuilder();
            sb.append(wg.f2228c);
            sb.append("apiKey=");
            char c2 = 0;
            if (contextArr != null && contextArr.length > 0) {
                sb.append(wg.this.a((wg) contextArr[c2].getApplicationContext()));
            }
            NetResponse doStream = NetManager.getInstance().builder().url(sb.toString()).timeOut(3000).doStream();
            try {
                inputStream = doStream.dataStream;
                try {
                    byte[] b = ha.b(inputStream);
                    if (b != null) {
                        if (b.length != 0) {
                            a2 = wg.this.a((wg) new String(b), (String) a2);
                            if (inputStream != null) {
                                ha.a((Closeable) inputStream);
                            }
                            ha.a((Closeable) doStream.dataStream);
                            if (a2 != tg.a()) {
                                c2 = 1;
                            }
                            if (c2 != 0) {
                            }
                            return null;
                        }
                    }
                    if (inputStream != null) {
                        ha.a((Closeable) inputStream);
                    }
                    ha.a((Closeable) doStream.dataStream);
                    if (a2 != tg.a()) {
                        c2 = 1;
                    }
                    if (!(c2 == 0 || wg.this.a == null)) {
                        tg.a(wg.this.a, a2);
                        ((b) wg.this.b.get()).a();
                    }
                    return null;
                } catch (Throwable th2) {
                    th = th2;
                    try {
                        th.printStackTrace();
                        return null;
                    } finally {
                        if (inputStream != null) {
                            ha.a((Closeable) inputStream);
                        }
                        if (doStream != null) {
                            ha.a((Closeable) doStream.dataStream);
                        }
                        if (a2 != tg.a()) {
                            c2 = 1;
                        }
                        if (!(c2 == 0 || wg.this.a == null)) {
                            tg.a(wg.this.a, a2);
                            ((b) wg.this.b.get()).a();
                        }
                    }
                }
            } catch (Throwable th3) {
                th = th3;
                inputStream = null;
                th.printStackTrace();
                return null;
            }
        }
    }

    public wg(Context context, b bVar) {
        this.a = context;
        this.b = new WeakReference<>(bVar);
    }

    public void a() {
        new c().execute(this.a);
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    private int a(String str, int i) throws JSONException {
        JSONObject optJSONObject;
        JSONObject jSONObject = new JSONObject(str);
        return (jSONObject.optInt("error", -1) != 0 || (optJSONObject = jSONObject.optJSONObject("info")) == null) ? i : optJSONObject.optInt("scenic", i);
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    private String a(Context context) {
        Bundle bundle;
        if (context == null) {
            return "";
        }
        ApplicationInfo applicationInfo = null;
        try {
            applicationInfo = context.getPackageManager().getApplicationInfo(context.getPackageName(), 128);
        } catch (PackageManager.NameNotFoundException e) {
            e.printStackTrace();
        }
        if (applicationInfo == null || (bundle = applicationInfo.metaData) == null) {
            return "";
        }
        return bundle.getString("TencentMapSDK");
    }
}