TIM v2.3.1版本的 MD5 值为:d6957e3ee7ce901ccc491cefdea0da8c

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


package com.tencent.wxop.stat;

import android.content.Context;
import android.content.IntentFilter;
import com.tencent.mobileqq.facetoface.Face2FaceAddFriendActivity;
import com.tencent.wxop.stat.common.StatLogger;
import java.net.InetAddress;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Random;
import java.util.regex.Pattern;
import org.apache.http.HttpHost;
import org.json.JSONObject;
public class a {
    private static a g = null;
    private com.tencent.wxop.stat.common.e e;
    private Context h;
    private StatLogger i;
    private List<String> f97538a = null;
    private volatile int f97539b = 2;
    private volatile String f97540c = "";
    private volatile HttpHost d = null;
    private int f = 0;

    private a(Context context) {
        this.e = null;
        this.h = null;
        this.i = null;
        this.h = context.getApplicationContext();
        this.e = new com.tencent.wxop.stat.common.e();
        i.a(context);
        this.i = com.tencent.wxop.stat.common.l.b();
        l();
        i();
        g();
    }

    public static a a(Context context) {
        if (g == null) {
            synchronized (a.class) {
                if (g == null) {
                    g = new a(context);
                }
            }
        }
        return g;
    }

    private boolean b(String str) {
        return Pattern.compile("(2[5][0-5]|2[0-4]\\d|1\\d{2}|\\d{1,2})\\.(25[0-5]|2[0-4]\\d|1\\d{2}|\\d{1,2})\\.(25[0-5]|2[0-4]\\d|1\\d{2}|\\d{1,2})\\.(25[0-5]|2[0-4]\\d|1\\d{2}|\\d{1,2})").matcher(str).matches();
    }

    private void i() {
        this.f97538a = new ArrayList(10);
        this.f97538a.add("117.135.169.101");
        this.f97538a.add("140.207.54.125");
        this.f97538a.add("180.153.8.53");
        this.f97538a.add("120.198.203.175");
        this.f97538a.add("14.17.43.18");
        this.f97538a.add("163.177.71.186");
        this.f97538a.add("111.30.131.31");
        this.f97538a.add("123.126.121.167");
        this.f97538a.add("123.151.152.111");
        this.f97538a.add("113.142.45.79");
        this.f97538a.add("123.138.162.90");
        this.f97538a.add("103.7.30.94");
    }

    private String j() {
        try {
            if (!b("pingma.qq.com")) {
                return InetAddress.getByName("pingma.qq.com").getHostAddress();
            }
        } catch (Exception e) {
            this.i.e((Throwable) e);
        }
        return "";
    }

    private void k() {
        String str;
        String j = j();
        if (StatConfig.isDebugEnable()) {
            this.i.i("remoteIp ip is " + j);
        }
        if (com.tencent.wxop.stat.common.l.c(j)) {
            if (this.f97538a.contains(j)) {
                str = j;
            } else {
                str = this.f97538a.get(this.f);
                if (StatConfig.isDebugEnable()) {
                    this.i.w(j + " not in ip list, change to:" + str);
                }
            }
            StatConfig.setStatReportUrl("http://" + str + ":80/mstat/report");
        }
    }

    private void l() {
        this.f97539b = 0;
        this.d = null;
        this.f97540c = null;
    }

    public HttpHost a() {
        return this.d;
    }

    public void a(String str) {
        if (StatConfig.isDebugEnable()) {
            this.i.i("updateIpList " + str);
        }
        try {
            if (com.tencent.wxop.stat.common.l.c(str)) {
                JSONObject jSONObject = new JSONObject(str);
                if (jSONObject.length() > 0) {
                    Iterator<String> keys = jSONObject.keys();
                    while (keys.hasNext()) {
                        String string = jSONObject.getString(keys.next());
                        if (com.tencent.wxop.stat.common.l.c(string)) {
                            String[] split = string.split(";");
                            for (String str2 : split) {
                                if (com.tencent.wxop.stat.common.l.c(str2)) {
                                    String[] split2 = str2.split(":");
                                    if (split2.length > 1) {
                                        String str3 = split2[0];
                                        if (b(str3) && !this.f97538a.contains(str3)) {
                                            if (StatConfig.isDebugEnable()) {
                                                this.i.i("add new ip:" + str3);
                                            }
                                            this.f97538a.add(str3);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        } catch (Exception e) {
            this.i.e((Throwable) e);
        }
        this.f = new Random().nextInt(this.f97538a.size());
    }

    public String b() {
        return this.f97540c;
    }

    public int c() {
        return this.f97539b;
    }

    public void d() {
        this.f = (this.f + 1) % this.f97538a.size();
    }

    public boolean e() {
        return this.f97539b == 1;
    }

    public boolean f() {
        return this.f97539b != 0;
    }

    public void g() {
        if (!com.tencent.wxop.stat.common.r.f(this.h)) {
            if (StatConfig.isDebugEnable()) {
                this.i.i("NETWORK TYPE: network is close.");
            }
            l();
            return;
        }
        if (StatConfig.g) {
            k();
        }
        this.f97540c = com.tencent.wxop.stat.common.l.j(this.h);
        if (StatConfig.isDebugEnable()) {
            this.i.i("NETWORK name:" + this.f97540c);
        }
        if (com.tencent.wxop.stat.common.l.c(this.f97540c)) {
            if ("WIFI".equalsIgnoreCase(this.f97540c)) {
                this.f97539b = 1;
            } else {
                this.f97539b = 2;
            }
            this.d = com.tencent.wxop.stat.common.l.a(this.h);
        }
        if (StatServiceImpl.a()) {
            StatServiceImpl.d(this.h);
        }
    }

    public void h() {
        this.h.getApplicationContext().registerReceiver(new b(this), new IntentFilter(Face2FaceAddFriendActivity.f22417d));
    }
}