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

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


package com.tencent.stat;

import android.content.Context;
import android.content.IntentFilter;
import android.os.Handler;
import android.os.HandlerThread;
import com.tencent.mobileqq.facetoface.Face2FaceAddFriendActivity;
import com.tencent.stat.common.StatCommonHelper;
import com.tencent.stat.common.StatLogger;
import com.tencent.stat.common.Util;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import org.apache.http.HttpHost;
public class NetworkManager {
    public static final int TYPE_NOT_WIFI = 2;
    public static final int TYPE_NO_NETWORK = 0;
    public static final int TYPE_WIFI = 1;
    private static NetworkManager g = null;
    private Handler e;
    private Context h;
    private StatLogger i;
    private List<String> f96564a = new ArrayList(10);
    private volatile int f96565b = 2;
    private volatile String f96566c = "";
    private volatile HttpHost d = null;
    private int f = 0;

    private NetworkManager(Context context) {
        this.e = null;
        this.h = null;
        this.i = null;
        this.h = context.getApplicationContext();
        HandlerThread handlerThread = new HandlerThread("StatNetworkMan");
        handlerThread.start();
        this.e = new Handler(handlerThread.getLooper());
        g.a(context);
        this.i = StatCommonHelper.getLogger();
        c();
        b();
        a();
    }

    private void b() {
        this.f96564a.add("117.135.169.101");
        this.f96564a.add("140.207.54.125");
        this.f96564a.add("180.153.8.53");
        this.f96564a.add("120.198.203.175");
        this.f96564a.add("14.17.43.18");
        this.f96564a.add("163.177.71.186");
        this.f96564a.add("111.30.131.31");
        this.f96564a.add("123.126.121.167");
        this.f96564a.add("123.151.152.111");
        this.f96564a.add("113.142.45.79");
        this.f96564a.add("123.138.162.90");
        this.f96564a.add("103.7.30.94");
    }

    private void c() {
        this.f96565b = 0;
        this.d = null;
        this.f96566c = null;
    }

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

    public void a() {
        if (!Util.isNetworkAvailable(this.h)) {
            if (StatConfig.isDebugEnable()) {
                this.i.i("NETWORK TYPE: network is close.");
            }
            c();
            return;
        }
        this.f96566c = StatCommonHelper.getLinkedWay(this.h);
        if (StatConfig.isDebugEnable()) {
            this.i.i("NETWORK name:" + this.f96566c);
        }
        if (StatCommonHelper.isStringValid(this.f96566c)) {
            if ("WIFI".equalsIgnoreCase(this.f96566c)) {
                this.f96565b = 1;
            } else {
                this.f96565b = 2;
            }
            this.d = StatCommonHelper.getHttpProxy(this.h);
        }
        if (StatServiceImpl.a()) {
            StatServiceImpl.e(this.h);
        }
    }

    public String getCurNetwrokName() {
        return this.f96566c;
    }

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

    public int getNetworkType() {
        return this.f96565b;
    }

    public boolean isNetworkAvailable() {
        return this.f96565b != 0;
    }

    public boolean isWifi() {
        return this.f96565b == 1;
    }

    public void onDispatchFailed() {
        if (this.f96564a == null || this.f96564a.size() <= 0) {
            return;
        }
        this.f = (this.f + 1) % this.f96564a.size();
    }

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

    public void updateIpList(String str) {
        if (StatConfig.isDebugEnable()) {
            this.i.i("updateIpList " + str);
        }
        this.f = new Random().nextInt(this.f96564a.size());
    }
}