QQ浏览器 v12.2.3.7053版本的 MD5 值为:8285ab3059e5c8b521a264dfbc5c3685

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


package com.tencent.mtt.browser.push.service;

import MTT.JoinIPInfo;
import MTT.RouteIPListRsp;
import android.content.Context;
import android.content.SharedPreferences;
import android.text.TextUtils;
import com.huawei.hms.support.hianalytics.HiAnalyticsConstant;
import com.tencent.common.http.Apn;
import com.tencent.common.http.NetUtils;
import com.tencent.common.utils.UrlUtils;
import com.tencent.common.wup.IWUPRequestCallBack;
import com.tencent.common.wup.WUPRequestBase;
import com.tencent.common.wup.WUPResponseBase;
import com.tencent.mtt.ContextHolder;
import com.tencent.mtt.base.network.ConnectionConfiguration;
import com.tencent.mtt.multiproc.QBSharedPreferences;
import com.tencent.mtt.operation.event.EventLog;
import com.tencent.mtt.twsdk.qbinfo.TWSettingManager;
import com.xiaomi.mipush.sdk.Constants;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class PushServerConfigs implements IWUPRequestCallBack {

    private PushEngine f44118a;

    private ArrayList<String> f44119b = new ArrayList<>();

    private String f44120c;

    private int f44121d;
    private int e;
    private int f;

    public PushServerConfigs(PushEngine pushEngine) {
        this.f44118a = pushEngine;
    }

    public static void a(Context context, boolean z) {
        if (!z) {
            TWSettingManager.a().b("push_test_server_ip", "");
        }
        QBSharedPreferences.getDirectSharedPreferences(context, "push_settings", 0).edit().putLong("key_push_test_time", System.currentTimeMillis()).putBoolean("pref_test", z).commit();
    }

    private void a(String str, List<String> list) {
        boolean z;
        if (a(ContextHolder.getAppContext())) {
            return;
        }
        synchronized (this.f44119b) {
            if (!list.isEmpty()) {
                this.f44118a.e().edit().putString("pref_addr_" + str, TextUtils.join(HiAnalyticsConstant.REPORT_VAL_SEPARATOR, list)).commit();
                String i = i();
                this.f44120c = str;
                this.f44119b.clear();
                this.f44119b.addAll(list);
                if (!this.f44119b.contains("jpush.html5.qq.com:14000")) {
                    this.f44119b.add("jpush.html5.qq.com:14000");
                }
                this.f44118a.f();
                if (this.f44121d >= this.f44119b.size()) {
                    this.f44121d = 0;
                }
                if (i != null && this.f44118a.u()) {
                    z = !list.contains(i) ? !"tpush.html5.qq.com:8080".equals(i) : false;
                    if (z) {
                        this.f44121d = 0;
                        this.f44118a.g();
                    }
                }
                z = true;
                if (z) {
                }
            }
            TWSettingManager.a().b("PUSH_CHECK_FOR_IPV6_IPLIST", true);
            EventLog.a("Push(ip list)", "更新ip列表", "ip列表更新", this.f44119b.toString(), "normanchen", 1, 1);
            EventLog.a("Push(ip list)", "当前使用的ip列表", "在用ip列表", this.f44119b.toString(), "normanchen", 1, 1);
        }
    }

    public static boolean a(Context context) {
        SharedPreferences directSharedPreferences = QBSharedPreferences.getDirectSharedPreferences(context, "push_settings", 0);
        if (System.currentTimeMillis() - directSharedPreferences.getLong("key_push_test_time", 0L) < 86400000) {
            return directSharedPreferences.getBoolean("pref_test", false);
        }
        TWSettingManager.a().b("push_test_server_ip", "");
        return false;
    }

    private void h() {
        ArrayList<String> arrayList;
        String str;
        String str2;
        synchronized (this.f44119b) {
            this.f44119b.clear();
            if (a(ContextHolder.getAppContext())) {
                String a2 = TWSettingManager.a().a("push_test_server_ip", "");
                if (TextUtils.isEmpty(a2)) {
                    arrayList = this.f44119b;
                    str = "58.247.205.28:8080";
                    arrayList.add(str);
                    str2 = "";
                    if (this.f44119b.size() > 1) {
                        Iterator<String> it = this.f44119b.iterator();
                        while (true) {
                            if (!it.hasNext()) {
                                break;
                            }
                            String next = it.next();
                            if (!UrlUtils.isIpUrl(next)) {
                                str2 = next;
                                break;
                            }
                        }
                    }
                    if (!TextUtils.isEmpty(str2)) {
                        this.f44119b.remove(str2);
                        this.f44119b.add(0, str2);
                    }
                    this.f44121d = 0;
                    EventLog.a("Push(ip list)", "当前使用的ip列表", "在用ip列表", this.f44119b.toString(), "normanchen", 1, 1);
                } else {
                    this.f44119b.add(a2);
                    str2 = "";
                    if (this.f44119b.size() > 1) {
                    }
                    if (!TextUtils.isEmpty(str2)) {
                    }
                    this.f44121d = 0;
                    EventLog.a("Push(ip list)", "当前使用的ip列表", "在用ip列表", this.f44119b.toString(), "normanchen", 1, 1);
                }
            } else {
                this.f44120c = j();
                String string = this.f44118a.e().getString("pref_addr_" + this.f44120c, null);
                if (TextUtils.isEmpty(string)) {
                    try {
                        k();
                    } catch (Exception unused) {
                    }
                } else {
                    for (String str3 : TextUtils.split(string, "\\|")) {
                        this.f44119b.add(str3);
                    }
                    if (!TWSettingManager.a().a("PUSH_CHECK_FOR_IPV6_IPLIST", false)) {
                        k();
                    }
                }
                if (this.f44119b.isEmpty()) {
                    this.f44119b.add("tpush.html5.qq.com:8080");
                }
                if (!this.f44119b.contains("jpush.html5.qq.com:14000")) {
                    arrayList = this.f44119b;
                    str = "jpush.html5.qq.com:14000";
                    arrayList.add(str);
                }
                str2 = "";
                if (this.f44119b.size() > 1) {
                }
                if (!TextUtils.isEmpty(str2)) {
                }
                this.f44121d = 0;
                EventLog.a("Push(ip list)", "当前使用的ip列表", "在用ip列表", this.f44119b.toString(), "normanchen", 1, 1);
            }
        }
    }

    private String i() {
        synchronized (this.f44119b) {
            String j = j();
            if (j == null) {
                return null;
            }
            if (this.f44119b.isEmpty() || !j.equals(this.f44120c)) {
                h();
            }
            if (this.f44119b.isEmpty()) {
                return null;
            }
            if (this.f44121d < 0 || this.f44121d >= this.f44119b.size()) {
                this.f44121d = 0;
            }
            return this.f44119b.get(this.f44121d);
        }
    }

    private static String j() {
        return Apn.getApnNameWithBSSID(Apn.getApnTypeS());
    }

    private void k() {
        throw new UnsupportedOperationException("Method not decompiled: com.tencent.mtt.browser.push.service.PushServerConfigs.k():void");
    }

    public ConnectionConfiguration a() {
        ConnectionConfiguration connectionConfiguration;
        String i = i();
        if (TextUtils.isEmpty(i)) {
            return null;
        }
        try {
            if (UrlUtils.isIpUrl(i)) {
                connectionConfiguration = new ConnectionConfiguration(i);
            } else {
                int lastIndexOf = i.lastIndexOf(Constants.COLON_SEPARATOR);
                connectionConfiguration = lastIndexOf > 0 ? new ConnectionConfiguration(i.substring(0, lastIndexOf), Integer.parseInt(i.substring(lastIndexOf + 1, i.length()))) : new ConnectionConfiguration(i);
            }
            connectionConfiguration.c(0);
            connectionConfiguration.b(5000);
            this.f++;
            return connectionConfiguration;
        } catch (Throwable unused) {
            return null;
        }
    }

    public void a(List<String> list) {
        a(j(), list);
    }

    public String b() {
        synchronized (this.f44119b) {
            Iterator<String> it = this.f44119b.iterator();
            while (it.hasNext()) {
                String next = it.next();
                if (next.endsWith(":80") || next.endsWith(":8080")) {
                    if (UrlUtils.isIpUrl(next)) {
                        return NetUtils.SCHEME_HTTP + next;
                    }
                    int lastIndexOf = next.lastIndexOf(Constants.COLON_SEPARATOR);
                    if (lastIndexOf <= 0) {
                        return NetUtils.SCHEME_HTTP + next;
                    }
                    return "http://[" + next.substring(0, lastIndexOf) + "]:" + next.substring(lastIndexOf + 1, next.length());
                }
            }
            return null;
        }
    }

    public String c() {
        ArrayList<String> arrayList = this.f44119b;
        return (arrayList == null || arrayList.size() == 0) ? "" : TextUtils.join(Constants.ACCEPT_TIME_SEPARATOR_SP, this.f44119b.toArray());
    }

    public boolean d() {
        ArrayList<String> arrayList = this.f44119b;
        return (arrayList == null || arrayList.size() == 0 || this.f44121d != this.f44119b.size() - 1) ? false : true;
    }

    public boolean e() {
        if (this.f < 2) {
            return true;
        }
        synchronized (this.f44119b) {
            int i = this.e + 1;
            this.e = i;
            if (i >= this.f44119b.size()) {
                return false;
            }
            this.f = 0;
            this.f44121d++;
            if (this.f44121d >= this.f44119b.size()) {
                this.f44121d = 0;
            }
            return true;
        }
    }

    public boolean f() {
        return this.f == 2;
    }

    public void g() {
        this.f = 0;
        synchronized (this.f44119b) {
            this.e = 0;
        }
    }

    @Override
    public void onWUPTaskFail(WUPRequestBase wUPRequestBase) {
    }

    @Override
    public void onWUPTaskSuccess(WUPRequestBase wUPRequestBase, WUPResponseBase wUPResponseBase) {
        RouteIPListRsp routeIPListRsp;
        if (wUPResponseBase.isSuccess() && (wUPResponseBase.get(HiAnalyticsConstant.Direction.RESPONSE) instanceof RouteIPListRsp) && (routeIPListRsp = (RouteIPListRsp) wUPResponseBase.get(HiAnalyticsConstant.Direction.RESPONSE)) != null) {
            Iterator<JoinIPInfo> it = routeIPListRsp.vIPInfos.iterator();
            while (it.hasNext()) {
                JoinIPInfo next = it.next();
                if (next.eIPType == 10) {
                    a(routeIPListRsp.sApn, next.vIPList);
                }
            }
        }
    }
}