夏天YY v1.0版本的 MD5 值为:04df6daece98ad4aaa5f0e7a450865f8

以下内容为反编译后的 am.java 源代码,内容仅作参考


package c.t.m.g;

import android.content.Context;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.os.Handler;
import android.text.TextUtils;
import java.util.HashMap;
import java.util.Iterator;
import java.util.TimerTask;
import org.json.JSONException;
import org.json.JSONObject;
public class am extends bx {
    private static volatile am d;
    private static Context e;
    private volatile boolean f9c = true;
    private volatile bo f = bo.a;
    private Handler g;
    private volatile String h;

    @Override
    public String b() {
        return "TxCC";
    }

    private am() {
        if (e == null || e.getApplicationContext() == null) {
            throw new IllegalStateException("Please invoke initial(context,...) first when app started!");
        }
    }

    public static void a(HashMap<String, String> hashMap) {
        an.a(hashMap);
    }

    public static void a(Context context, String str, String str2) {
        if (context == null || context.getApplicationContext() == null) {
            throw new NullPointerException("context cannot be null!");
        }
        e = context.getApplicationContext();
        ci.a(e);
        ao.a(str);
        an.a(str, str2);
        new Thread("th_loc_tmp") {
            @Override
            public void run() {
                try {
                    am.c();
                    ao.a();
                    an.a();
                    dh.a(ao.a().b(), "last_pull_time", (Object) 0L);
                } catch (Throwable unused) {
                }
            }
        }.start();
    }

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

    public static synchronized am c() {
        am amVar;
        synchronized (am.class) {
            if (d == null) {
                synchronized (am.class) {
                    if (d == null) {
                        d = new am();
                    }
                }
            }
            amVar = d;
        }
        return amVar;
    }

    @Override
    public int d() {
        this.g = new Handler(cs.a("th_loc_task_t_consume").getLooper());
        a(5000L);
        return 0;
    }

    @Override
    public void a() {
        try {
            an.a().c();
            cy.a("TxCC", "shutdown:pull immediately");
            cu.b(this.g);
            a(0L);
            cs.a("th_loc_task_t_consume", 100L);
            this.g = null;
        } catch (Throwable th) {
            cy.a("TxCC", "shutdown error.", th);
        }
    }

    public void h() {
        try {
            int b = an.a().b("cc_version");
            long i = b == -1 ? 10800000L : i();
            cy.a("TxCC", "schedule : locVer[" + b + "],delayTime[" + i + "]");
            a(i);
        } catch (Throwable th) {
            cy.a("TxCC", "startSchedule error.", th);
        }
    }

    public long i() {
        long c2 = an.a().c("cc_req_interval");
        if (c2 > 86400000) {
            c2 = 86400000;
        }
        if (c2 < 1800000) {
            return 1800000L;
        }
        return c2;
    }

    private void a(long j) {
        Handler handler = this.g;
        a aVar = new a();
        if (j < 0) {
            j = 0;
        }
        cu.a(handler, aVar, j);
    }

    public class a extends TimerTask {
        private final JSONObject b = new JSONObject();
        private an f10c;
        private ao d;

        public a() {
            this.f10c = null;
            this.d = null;
            this.f10c = an.a();
            this.d = ao.a();
        }

        @Override
        public void run() {
            try {
                if (Math.abs(System.currentTimeMillis() - this.f10c.c("last_pull_time")) >= am.this.i()) {
                    a();
                } else {
                    cy.a("CC_Task", "skip pull");
                }
                if (am.this.f()) {
                    am.this.h();
                }
            } catch (Throwable th) {
                cy.a("CC_Task", "timer task error.", th);
            }
        }

        private void a() {
            boolean f = am.this.f();
            if (f) {
                try {
                    this.d.c();
                } catch (Throwable th) {
                    try {
                        cy.a("CC_Task", "pullSettings error.", th);
                        this.f10c.b();
                        if (!f) {
                            return;
                        }
                    } catch (Throwable th2) {
                        this.f10c.b();
                        if (f) {
                            this.d.d();
                        }
                        throw th2;
                    }
                }
            }
            JSONObject b = b();
            if (b != this.b) {
                int parseInt = Integer.parseInt(b.optString("status", "-5"));
                cy.a("CC_Task", "status:" + parseInt);
                if (parseInt == 0 && b.has("version")) {
                    a(b);
                }
                dh.a(this.d.b(), "last_pull_time", Long.valueOf(System.currentTimeMillis()));
                Thread.sleep(1000L);
                cy.a("CC_Task", "---> finish update xml");
            }
            this.f10c.b();
            if (!f) {
                return;
            }
            this.d.d();
        }

        private void a(JSONObject jSONObject) throws JSONException {
            int i;
            SharedPreferences b = this.d.b();
            if (b == null) {
                return;
            }
            int b2 = this.f10c.b("cc_version");
            try {
                i = Integer.parseInt(jSONObject.optString("version", this.f10c.e("cc_version")));
            } catch (Throwable unused) {
                i = b2;
            }
            cy.a("CC_Task", "locVer:" + b2 + ",serVer:" + i);
            if (i == b2) {
                return;
            }
            cy.a("CC_Task", "locVer != serVer, clear sp.");
            b.edit().clear().apply();
            JSONObject optJSONObject = jSONObject.optJSONObject("data");
            if (optJSONObject == null) {
                optJSONObject = this.b;
            }
            SharedPreferences.Editor edit = b.edit();
            Iterator<String> keys = optJSONObject.keys();
            while (keys.hasNext()) {
                String next = keys.next();
                a(edit, next, next, optJSONObject);
            }
            edit.putString("cc_version", String.valueOf(i));
            edit.putString("app_version", an.f11c);
            try {
                long parseLong = Long.parseLong(optJSONObject.optString("cc_req_interval", this.f10c.e("cc_req_interval")));
                if (parseLong < 1800000) {
                    parseLong = 1800000;
                } else if (parseLong > 86400000) {
                    parseLong = 86400000;
                }
                edit.putString("cc_req_interval", String.valueOf(parseLong));
            } catch (Throwable unused2) {
            }
            edit.apply();
        }

        private void a(SharedPreferences.Editor editor, String str, String str2, JSONObject jSONObject) {
            try {
                String e = this.f10c.e(str);
                if (e == null) {
                    return;
                }
                editor.putString(str, jSONObject.optString(str2, e));
            } catch (Exception e2) {
                cy.a("CC_Task", "update sp error.", e2);
            }
        }

        private JSONObject b() {
            if (am.this.f == null) {
                return this.b;
            }
            String replace = am.this.f9c ? "https://cc.map.qq.com/?get_c3" : "https://cc.map.qq.com/?get_c3".replace("https:", "http:");
            cy.a("CC_Task", "cc_url:" + replace);
            try {
                JSONObject jSONObject = new JSONObject();
                jSONObject.put("cc_version", this.f10c.e("cc_version"));
                jSONObject.put("m_module", an.a);
                jSONObject.put("m_channel", an.b);
                jSONObject.put("m_version", an.f11c);
                String str = am.this.h;
                if (de.a(str) || "0123456789ABCDEF".equals(str)) {
                    str = di.f();
                }
                if (de.a(str) || "0123456789ABCDEF".equals(str)) {
                    str = di.b();
                }
                jSONObject.put("imei", str);
                String jSONObject2 = jSONObject.toString();
                cy.d("TAG", "cc request: " + jSONObject2);
                String a = cn.a("cc");
                String a2 = cn.a(jSONObject2, a);
                cy.a("CC_Task", "req string: " + jSONObject2);
                cy.a("CC_Task", "req string enc:" + a2);
                Bundle a3 = am.this.f.a(replace, a2.getBytes(), null);
                String string = a3.getString("msg_suc", "");
                if (TextUtils.isEmpty(string)) {
                    String string2 = a3.getString("msg_fail", "");
                    cy.a("CC_Task", "net work error! res = [" + string2 + "]");
                    return this.b;
                }
                cy.a("CC_Task", "res:" + string);
                String jSONObject3 = this.b.toString();
                if (jSONObject3.equals(string)) {
                    cy.a("CC_Task", "network or server error,response empty json");
                } else {
                    cy.a("CC_Task", "start dec");
                    jSONObject3 = cn.b(string, a);
                    cy.a("CC_Task", "end dec, " + jSONObject3);
                }
                return TextUtils.isEmpty(jSONObject3) ? this.b : new JSONObject(jSONObject3);
            } catch (Throwable th) {
                cy.a("CC_Task", "req cc error.", th);
                return this.b;
            }
        }
    }
}