安全中心 v4.9.2版本的 MD5 值为:d64c0ec7920c532fa6e6d9bb001cf9bf

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


package tcs;

import android.content.Context;
import android.text.TextUtils;
import com.tencent.kingkong.database.SQLiteDatabase;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.List;
import tmsdk.common.module.sdknetpool.tcpnetwork.j;

public class pv implements tmsdk.common.module.sdknetpool.tcpnetwork.g {
    public static final boolean cqm = true;
    public static final String ect = "mazuburst.3g.qq.com";
    private final Object aLH = new Object();
    private String cqo = "key_notset";
    private a cqp;
    private a cqq;
    private boolean dAw;
    private Context mContext;
    private agm uT;
    private static String cOu = "mazu.3g.qq.com";
    private static pv cqn = null;
    private static a cqr = null;
    private static a cqs = null;

    public static void a(pv pvVar) {
        cqn = pvVar;
    }

    public static pv oh() {
        return cqn;
    }

    public static class a {
        public long cqt;
        public boolean cqv;
        public List<String> cqu = new ArrayList();
        private int cqw = 0;

        public a(long j, List<String> list, boolean z) {
            this.cqv = false;
            this.cqt = j;
            if (list != null) {
                this.cqu.addAll(list);
            }
            this.cqv = z;
        }

        public String toString() {
            StringBuilder sb = new StringBuilder();
            sb.append("|mValidTimeMills=").append(this.cqt).append("|mIsDefault=").append(this.cqv).append("|mIPPortList=").append(this.cqu);
            return sb.toString();
        }

        public boolean isValid() {
            return (this.cqv || System.currentTimeMillis() <= this.cqt) && this.cqu.size() > 0;
        }

        public void O(List<String> list) {
            int size = this.cqu.size();
            if (size >= 2) {
                this.cqu.addAll(size - 1, pv.b(list, true));
            } else {
                this.cqu.addAll(pv.b(list, true));
            }
        }

        public a om() {
            LinkedHashSet linkedHashSet = new LinkedHashSet();
            Iterator<String> it = this.cqu.iterator();
            while (it.hasNext()) {
                String eK = eK(it.next());
                if (eK != null) {
                    linkedHashSet.add(eK);
                }
            }
            return new a(this.cqt, new ArrayList(linkedHashSet), this.cqv);
        }

        private static String eK(String str) {
            String str2;
            if (TextUtils.isEmpty(str)) {
                return null;
            }
            int lastIndexOf = str.lastIndexOf(":");
            if (lastIndexOf >= 0) {
                str2 = str.substring(0, lastIndexOf) + ":80";
            } else {
                str2 = str + ":80";
            }
            if (str2.length() < "http://".length() || !str2.substring(0, "http://".length()).equalsIgnoreCase("http://")) {
                return "http://" + str2;
            }
            return str2;
        }

        public j.b on() {
            if (this.cqw >= this.cqu.size()) {
                this.cqw = 0;
            }
            return pv.eH(this.cqu.get(this.cqw));
        }

        public void oo() {
            this.cqw++;
            if (this.cqw >= this.cqu.size()) {
                this.cqw = 0;
            }
        }

        public void rp() {
            this.cqw = 0;
        }
    }

    public pv(Context context, boolean z, agm agmVar, String str) {
        this.dAw = false;
        this.mContext = context;
        this.dAw = z;
        this.uT = agmVar;
        if (this.dAw) {
            if (!TextUtils.isEmpty(str)) {
                cOu = str;
            } else {
                cOu = "mazutest.3g.qq.com";
            }
        }
        oi();
        a(this);
    }

    public void XJ() {
        oi();
    }

    @Override
    public void a(long j, int i, gu guVar) {
        if (guVar != null && (guVar instanceof cp)) {
            cp cpVar = (cp) guVar;
            a aVar = new a(System.currentTimeMillis() + (1000 * cpVar.eO), b(cpVar.be, false), false);
            if (aVar.isValid()) {
                int cu = agh.cu(this.mContext);
                int i2 = cpVar.lY;
                if (i2 == cu) {
                    String ok = ok();
                    this.uT.b(ok, aVar.cqt, aVar.cqu);
                    a(ok, aVar, true);
                } else {
                    this.uT.b(hJ(i2), aVar.cqt, aVar.cqu);
                }
            }
        }
    }

    private void oi() {
        String ok = ok();
        synchronized (this.aLH) {
            if (this.cqo == null || !this.cqo.equals(ok) || this.cqp == null || !this.cqp.isValid()) {
                a h = h(ok, true);
                if (h != null && h.isValid()) {
                    a(ok, h, true);
                } else {
                    oj();
                }
            }
        }
    }

    private void oj() {
        synchronized (this.aLH) {
            if (this.cqo == null || !this.cqo.equals("key_default") || this.cqp == null || !this.cqp.isValid()) {
                a("key_default", U(true), false);
            }
        }
    }

    private void a(String str, a aVar, boolean z) {
        if (str != null && aVar != null && aVar.isValid()) {
            a aVar2 = new a(aVar.cqt, aVar.cqu, aVar.cqv);
            if (z) {
                aVar2.O(W(true));
            }
            synchronized (this.aLH) {
                this.cqp = aVar2;
                this.cqq = this.cqp.om();
                this.cqo = str;
            }
        }
    }

    private a U(boolean z) {
        if (z && cqr != null) {
            return cqr;
        }
        if (!z && cqs != null) {
            return cqs;
        }
        List<String> W = W(z);
        List<String> al = al(z);
        ArrayList arrayList = new ArrayList();
        arrayList.addAll(W);
        arrayList.addAll(al);
        a aVar = new a(0L, arrayList, true);
        if (z) {
            cqr = aVar;
            return aVar;
        }
        cqs = aVar;
        return aVar;
    }

    private List<String> W(boolean z) {
        ArrayList arrayList = new ArrayList();
        ArrayList arrayList2 = new ArrayList();
        if (z) {
            arrayList2.add(443);
        } else {
            arrayList2.add(80);
        }
        String str = cOu;
        Iterator it = arrayList2.iterator();
        while (it.hasNext()) {
            arrayList.add(String.format("%s:%d", str, Integer.valueOf(((Integer) it.next()).intValue())));
        }
        return arrayList;
    }

    private List<String> al(boolean z) {
        Object obj;
        ArrayList arrayList = new ArrayList();
        if (this.dAw) {
            return arrayList;
        }
        switch (ro()) {
            case 0:
                obj = "183.232.125.162";
                break;
            case 1:
                obj = "163.177.71.153";
                break;
            default:
                obj = "120.198.203.156";
                break;
        }
        ArrayList arrayList2 = new ArrayList();
        if (z) {
            arrayList2.add(443);
        } else {
            arrayList2.add(80);
        }
        Iterator it = arrayList2.iterator();
        while (it.hasNext()) {
            arrayList.add(String.format("%s:%d", obj, Integer.valueOf(((Integer) it.next()).intValue())));
        }
        return arrayList;
    }

    private a h(String str, boolean z) {
        a eh = this.uT.eh(str);
        if (eh != null) {
            if (!eh.isValid()) {
                if (z) {
                    this.uT.b(str, 0L, null);
                }
            } else {
                return eh;
            }
        }
        return null;
    }

    private String ok() {
        String str;
        String str2 = SQLiteDatabase.KeyEmpty + (this.dAw ? "t_" : "r_");
        int cu = agh.cu(this.mContext);
        if (cu == 1) {
            str = "wifi_" + uh.getSSID();
        } else {
            str = "apn_" + cu;
        }
        return str2 + str;
    }

    private String hJ(int i) {
        String str;
        String str2 = SQLiteDatabase.KeyEmpty + (this.dAw ? "t_" : "r_");
        if (i == 1) {
            if (uh.KS()) {
                str = "wifi_" + uh.getSSID();
            } else {
                str = "wifi_nonessid";
            }
        } else {
            str = "apn_" + i;
        }
        return str2 + str;
    }

    public static List<String> b(List<String> list, boolean z) {
        ArrayList arrayList = new ArrayList();
        if (list != null && list.size() > 0) {
            for (String str : list) {
                if (j(str, z)) {
                    arrayList.add(str);
                }
            }
        }
        return arrayList;
    }

    public static j.b eH(String str) {
        int lastIndexOf;
        if (TextUtils.isEmpty(str) || (lastIndexOf = str.lastIndexOf(":")) <= 0 || lastIndexOf == str.length() - 1) {
            return null;
        }
        String substring = str.substring(0, lastIndexOf);
        String substring2 = str.substring(lastIndexOf + 1);
        if (TextUtils.isDigitsOnly(substring2)) {
            return new j.b(substring, Integer.parseInt(substring2));
        }
        return null;
    }

    private static boolean j(String str, boolean z) {
        int lastIndexOf;
        if (TextUtils.isEmpty(str) || (lastIndexOf = str.lastIndexOf(":")) <= 0 || lastIndexOf == str.length() - 1) {
            return false;
        }
        return (z || eI(str.substring(0, lastIndexOf))) && TextUtils.isDigitsOnly(str.substring(lastIndexOf + 1));
    }

    private static boolean eI(String str) {
        if (TextUtils.isEmpty(str)) {
            return false;
        }
        try {
            if (!str.matches("\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}")) {
                return false;
            }
            String[] split = str.split("\\.");
            if (split.length < 4 || Integer.parseInt(split[0]) > 255 || Integer.parseInt(split[1]) > 255 || Integer.parseInt(split[2]) > 255) {
                return false;
            }
            return Integer.parseInt(split[3]) <= 255;
        } catch (Exception e) {
            return false;
        }
    }

    private void X(boolean z) {
        a aVar;
        synchronized (this.aLH) {
            if (z) {
                aVar = this.cqp;
            } else {
                aVar = this.cqq;
            }
        }
        if (aVar == null) {
            oi();
        } else if (!aVar.isValid()) {
            oj();
        }
    }

    @Override
    public j.b Y(boolean z) {
        a aVar;
        X(true);
        synchronized (this.aLH) {
            if (z) {
                aVar = this.cqp;
            } else {
                aVar = this.cqq;
            }
            if (aVar != null) {
                return aVar.on();
            }
            return null;
        }
    }

    @Override
    public void Z(boolean z) {
        a aVar;
        X(true);
        synchronized (this.aLH) {
            if (z) {
                aVar = this.cqp;
            } else {
                aVar = this.cqq;
            }
            if (aVar != null) {
                aVar.oo();
            }
        }
    }

    @Override
    public void am(boolean z) {
        a aVar;
        X(true);
        synchronized (this.aLH) {
            if (z) {
                aVar = this.cqp;
            } else {
                aVar = this.cqq;
            }
            if (aVar != null) {
                aVar.rp();
            }
        }
    }

    @Override
    public void fE(boolean z) {
    }

    @Override
    public ArrayList<String> aa(boolean z) {
        a aVar;
        X(true);
        synchronized (this.aLH) {
            if (z) {
                aVar = this.cqp;
            } else {
                aVar = this.cqq;
            }
            if (aVar != null) {
                return (ArrayList) aVar.cqu;
            }
            return null;
        }
    }

    @Override
    public int ab(boolean z) {
        ArrayList<String> aa = aa(z);
        if (aa != null) {
            return aa.size();
        }
        return 0;
    }

    @Override
    public String ol() {
        String str = null;
        j.b Y = Y(false);
        if (Y != null && (str = Y.cn()) != null && (str.length() < "http://".length() || !str.substring(0, "http://".length()).equalsIgnoreCase("http://"))) {
            str = "http://" + str;
        }
        if (str == null) {
            return "http://" + cOu;
        }
        return str;
    }

    @Override
    public boolean LI() {
        return this.dAw;
    }

    private int ro() {
        int aP;
        if (4 == tmsdk.common.internal.utils.y.ctO || -1 == (aP = ub.aP(this.mContext))) {
            return 2;
        }
        return aP;
    }
}