中通快递.apk(点击下载) / i.java


package com.baidu.lbsapi.auth;

import android.app.ActivityManager;
import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.os.Process;
import android.text.TextUtils;
import cn.beekee.zhongtong.fragment.FragmentWeb;
import com.baidu.android.bbalbs.common.util.CommonParam;
import java.text.SimpleDateFormat;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.Map;
import org.json.JSONException;
import org.json.JSONObject;

public class i {
    private static Context b;
    private static o e = null;
    private static int f = 0;
    private static Hashtable<String, n> g = new Hashtable<>();
    private boolean a = true;
    private c c = null;
    private f d = null;
    private final Handler h = new j(this, Looper.getMainLooper());

    public i(Context context) {
        b = context;
        if (e != null && !e.isAlive()) {
            e = null;
        }
        d();
    }

    private int a(String str) {
        try {
            JSONObject jSONObject = new JSONObject(str);
            if (!jSONObject.has("status")) {
                jSONObject.put("status", -1);
            }
            int i = jSONObject.getInt("status");
            if (jSONObject.has("current") && i == 0) {
                long j = jSONObject.getLong("current");
                long currentTimeMillis = System.currentTimeMillis();
                if (((double) (currentTimeMillis - j)) / 3600000.0d >= 24.0d) {
                    i = 601;
                } else {
                    SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
                    if (!simpleDateFormat.format(Long.valueOf(currentTimeMillis)).equals(simpleDateFormat.format(Long.valueOf(j)))) {
                        i = 601;
                    }
                }
            }
            if (jSONObject.has("current") && i == 602) {
                if (((double) ((System.currentTimeMillis() - jSONObject.getLong("current")) / 1000)) > 180.0d) {
                    return 601;
                }
            }
            return i;
        } catch (JSONException e2) {
            e2.printStackTrace();
            return -1;
        }
    }

    private String a(Context context) {
        int myPid = Process.myPid();
        for (ActivityManager.RunningAppProcessInfo runningAppProcessInfo : ((ActivityManager) context.getSystemService("activity")).getRunningAppProcesses()) {
            if (runningAppProcessInfo.pid == myPid) {
                return runningAppProcessInfo.processName;
            }
        }
        return null;
    }

    private String a(Context context, String str) {
        n nVar;
        String str2 = "";
        try {
            ApplicationInfo applicationInfo = context.getPackageManager().getApplicationInfo(context.getPackageName(), 128);
            if (applicationInfo.metaData == null) {
                n nVar2 = g.get(str);
                if (nVar2 != null) {
                    nVar2.a(-1, ErrorMessage.a("AndroidManifest.xml的application中没有meta-data标签"));
                }
                return str2;
            }
            str2 = applicationInfo.metaData.getString("com.baidu.lbsapi.API_KEY");
            if ((str2 == null || str2.equals("")) && (nVar = g.get(str)) != null) {
                nVar.a(-1, ErrorMessage.a("无法在AndroidManifest.xml中获取com.baidu.android.lbs.API_KEY的值"));
            }
            return str2;
        } catch (PackageManager.NameNotFoundException e2) {
            n nVar3 = g.get(str);
            if (nVar3 != null) {
                nVar3.a(-1, ErrorMessage.a("无法在AndroidManifest.xml中获取com.baidu.android.lbs.API_KEY的值"));
            }
        }
    }

    static /* synthetic */ void a(i iVar, String str, String str2) {
        iVar.a(str, str2);
    }

    static /* synthetic */ void a(i iVar, boolean z, String str, Hashtable hashtable, String str2) {
        iVar.a(z, str, hashtable, str2);
    }

    static /* synthetic */ void a(i iVar, boolean z, String str, Hashtable hashtable, String[] strArr, String str2) {
        iVar.a(z, str, hashtable, strArr, str2);
    }

    private synchronized void a(String str, String str2) {
        if (str == null) {
            str = e();
        }
        Message obtainMessage = this.h.obtainMessage();
        try {
            JSONObject jSONObject = new JSONObject(str);
            if (!jSONObject.has("status")) {
                jSONObject.put("status", -1);
            }
            if (!jSONObject.has("current")) {
                jSONObject.put("current", System.currentTimeMillis());
            }
            c(jSONObject.toString());
            if (jSONObject.has("current")) {
                jSONObject.remove("current");
            }
            obtainMessage.what = jSONObject.getInt("status");
            obtainMessage.obj = jSONObject.toString();
            Bundle bundle = new Bundle();
            bundle.putString("listenerKey", str2);
            obtainMessage.setData(bundle);
            this.h.sendMessage(obtainMessage);
        } catch (JSONException e2) {
            e2.printStackTrace();
            obtainMessage.what = -1;
            obtainMessage.obj = new JSONObject();
            Bundle bundle2 = new Bundle();
            bundle2.putString("listenerKey", str2);
            obtainMessage.setData(bundle2);
            this.h.sendMessage(obtainMessage);
        }
        e.c();
        f--;
        if (a.a) {
            a.a("httpRequest called mAuthCounter-- = " + f);
        }
        if (f == 0) {
            e.a();
            if (e != null) {
                e = null;
            }
        }
    }

    private void a(boolean z, String str, Hashtable<String, String> hashtable, String str2) {
        String a2 = a(b, str2);
        if (!(a2 == null || a2.equals(""))) {
            HashMap<String, String> hashMap = new HashMap<>();
            hashMap.put(FragmentWeb.URL, "https://sapi.map.baidu.com/sdkcs/verify");
            hashMap.put("output", "json");
            hashMap.put("ak", a2);
            hashMap.put("mcode", b.a(b));
            hashMap.put("from", "lbs_yunsdk");
            if (hashtable != null && hashtable.size() > 0) {
                for (Map.Entry<String, String> entry : hashtable.entrySet()) {
                    String key = entry.getKey();
                    String value = entry.getValue();
                    if (!TextUtils.isEmpty(key) && !TextUtils.isEmpty(value)) {
                        hashMap.put(key, value);
                    }
                }
            }
            String str3 = "";
            try {
                str3 = CommonParam.a(b);
            } catch (Exception e2) {
            }
            if (!TextUtils.isEmpty(str3)) {
                hashMap.put("cuid", str3);
            } else {
                hashMap.put("cuid", "");
            }
            hashMap.put("pcn", b.getPackageName());
            hashMap.put("version", "1.0.4");
            String str4 = "";
            try {
                str4 = b.c(b);
            } catch (Exception e3) {
            }
            if (!TextUtils.isEmpty(str4)) {
                hashMap.put("macaddr", str4);
            } else {
                hashMap.put("macaddr", "");
            }
            String str5 = "";
            try {
                str5 = b.a();
            } catch (Exception e4) {
            }
            if (!TextUtils.isEmpty(str5)) {
                hashMap.put("language", str5);
            } else {
                hashMap.put("language", "");
            }
            if (z) {
                hashMap.put("force", z ? "1" : "0");
            }
            hashMap.put("from_service", str);
            this.c = new c(b);
            this.c.a(hashMap, new l(this, str2));
        }
    }

    private void a(boolean z, String str, Hashtable<String, String> hashtable, String[] strArr, String str2) {
        String a2 = a(b, str2);
        if (!(a2 == null || a2.equals(""))) {
            HashMap<String, String> hashMap = new HashMap<>();
            hashMap.put(FragmentWeb.URL, "https://sapi.map.baidu.com/sdkcs/verify");
            hashMap.put("output", "json");
            hashMap.put("ak", a2);
            hashMap.put("from", "lbs_yunsdk");
            if (hashtable != null && hashtable.size() > 0) {
                for (Map.Entry<String, String> entry : hashtable.entrySet()) {
                    String key = entry.getKey();
                    String value = entry.getValue();
                    if (!TextUtils.isEmpty(key) && !TextUtils.isEmpty(value)) {
                        hashMap.put(key, value);
                    }
                }
            }
            String str3 = "";
            try {
                str3 = CommonParam.a(b);
            } catch (Exception e2) {
            }
            if (!TextUtils.isEmpty(str3)) {
                hashMap.put("cuid", str3);
            } else {
                hashMap.put("cuid", "");
            }
            hashMap.put("pcn", b.getPackageName());
            hashMap.put("version", "1.0.4");
            String str4 = "";
            try {
                str4 = b.c(b);
            } catch (Exception e3) {
            }
            if (!TextUtils.isEmpty(str4)) {
                hashMap.put("macaddr", str4);
            } else {
                hashMap.put("macaddr", "");
            }
            String str5 = "";
            try {
                str5 = b.a();
            } catch (Exception e4) {
            }
            if (!TextUtils.isEmpty(str5)) {
                hashMap.put("language", str5);
            } else {
                hashMap.put("language", "");
            }
            if (z) {
                hashMap.put("force", z ? "1" : "0");
            }
            hashMap.put("from_service", str);
            this.d = new f(b);
            this.d.a(hashMap, strArr, new m(this, str2));
        }
    }

    static /* synthetic */ boolean a(i iVar, String str) {
        return iVar.b(str);
    }

    static /* synthetic */ Context b() {
        return b;
    }

    private boolean b(String str) {
        String str2;
        String a2 = a(b, str);
        try {
            JSONObject jSONObject = new JSONObject(e());
            if (!jSONObject.has("ak")) {
                return true;
            }
            str2 = jSONObject.getString("ak");
            return (a2 == null || str2 == null || a2.equals(str2)) ? false : true;
        } catch (JSONException e2) {
            e2.printStackTrace();
            str2 = "";
        }
    }

    static /* synthetic */ o c() {
        return e;
    }

    private void c(String str) {
        b.getSharedPreferences("authStatus_" + a(b), 0).edit().putString("status", str).commit();
    }

    private void d() {
        synchronized (i.class) {
            if (e == null) {
                e = new o("auth");
                e.start();
                while (e.a == null) {
                    try {
                        if (a.a) {
                            a.a("wait for create auth thread.");
                        }
                        Thread.sleep(3);
                    } catch (InterruptedException e2) {
                        e2.printStackTrace();
                    }
                }
            }
        }
    }

    private String e() {
        return b.getSharedPreferences("authStatus_" + a(b), 0).getString("status", "{\"status\":601}");
    }

    public int a(boolean z, String str, Hashtable<String, String> hashtable, n nVar) {
        int i;
        synchronized (i.class) {
            String str2 = System.currentTimeMillis() + "";
            if (nVar != null) {
                g.put(str2, nVar);
            }
            String a2 = a(b, str2);
            if (a2 == null || a2.equals("")) {
                i = -1;
            } else {
                f++;
                if (a.a) {
                    a.a(" mAuthCounter  ++ = " + f);
                }
                String e2 = e();
                if (a.a) {
                    a.a("getAuthMessage from cache:" + e2);
                }
                i = a(e2);
                if (i == 601) {
                    try {
                        c(new JSONObject().put("status", 602).toString());
                    } catch (JSONException e3) {
                        e3.printStackTrace();
                    }
                }
                d();
                if (a.a) {
                    a.a("mThreadLooper.mHandler = " + e.a);
                }
                e.a.post(new k(this, i, z, str2, str, hashtable));
            }
        }
        return i;
    }
}