4399游戏盒 v7.2.1.31版本的 MD5 值为:951717f45e3fda95c8a358caf4ca93e1

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


package com.m4399.gamecenter.manager.a;

import android.text.TextUtils;
import com.framework.EnvironmentMode;
import com.framework.config.Config;
import com.framework.config.SysConfigKey;
import com.framework.swapper.interfaces.IServerHostManager;
import com.m4399.framework.BaseApplication;
import com.m4399.gamecenter.app.config.AppConfigKey;
import com.m4399.gamecenter.plugin.main.manager.i.d;
import com.m4399.stat.StatisticsConfig;
import java.util.HashMap;
import java.util.Iterator;

public class c implements IServerHostManager {
    private static c aaT;
    private HashMap<Integer, a> aaU = new HashMap<>();

    private c() {
        a B = new a(1).C(EnvironmentMode.T2, "https://dlstest.img4399.com/redirect/cdn.4399sj.com/t2").C(EnvironmentMode.TESTER, "https://dlstest.img4399.com/redirect/cdn.4399sj.com/test").C(EnvironmentMode.OT, "https://dlstest.img4399.com/redirect/cdn.4399sj.com/ot").C(EnvironmentMode.ONLINE, "https://cdn.yxhapi.com").B(EnvironmentMode.ONLINE, "https://cdn.yxhapi2.com");
        this.aaU.put(1, B);
        a B2 = new a(2).C(EnvironmentMode.T2, "https://dlstest.img4399.com").C(EnvironmentMode.TESTER, "https://dlstest.img4399.com").C(EnvironmentMode.OT, "https://dlstest.img4399.com").C(EnvironmentMode.ONLINE, "https://mapi.yxhapi.com").B(EnvironmentMode.ONLINE, "https://mapi.yxhapi2.com");
        this.aaU.put(2, B2);
        this.aaU.put(1001, new a(1001, B).C(EnvironmentMode.ONLINE, "https://dl.yxhapi.com").B(EnvironmentMode.ONLINE, "https://dl.yxhapi2.com"));
        this.aaU.put(5, new a(5, B2).C(EnvironmentMode.ONLINE, "https://sapi.yxhapi.com").B(EnvironmentMode.ONLINE, "https://sapi.yxhapi2.com"));
        final a C = new a(3).C(EnvironmentMode.T2, "https://dlstest.img4399.com/redirect/a.4399.cn/t2/").C(EnvironmentMode.TESTER, "https://dlstest.img4399.com/redirect/a.4399.cn/test/").C(EnvironmentMode.OT, "https://dlstest.img4399.com/redirect/a.4399.cn/ot/").C(EnvironmentMode.ONLINE, "https://a.4399.cn/");
        com.m4399.gamecenter.manager.b.a aVar = new com.m4399.gamecenter.manager.b.a() {
            @Override
            public void onReceive(String str, Object obj) {
                String str2 = (String) Config.getValue(AppConfigKey.USL_HOST_WEB_STATIC);
                if (TextUtils.isEmpty(str2)) {
                    return;
                }
                C.C(EnvironmentMode.ONLINE, str2);
            }
        };
        aVar.onReceive("", null);
        com.m4399.gamecenter.manager.b.b.get().register(this, "tag_on_config_static_loaded", aVar);
        this.aaU.put(3, C);
        this.aaU.put(6, new a(6).C(EnvironmentMode.T2, "https://dlstest.img4399.com/redirect/yxh/udb/test").C(EnvironmentMode.TESTER, "https://dlstest.img4399.com/redirect/yxhudb/test").C(EnvironmentMode.OT, "https://dlstest.img4399.com/redirect/yxhudb/ot").C(EnvironmentMode.ONLINE, "https://udb.yxhapi.com").B(EnvironmentMode.ONLINE, "https://udb.yxhapi2.com"));
        if (BaseApplication.getApplication().getStartupConfig().getReleaseMode() == 2) {
            jx();
            jw();
            jv();
            com.m4399.gamecenter.manager.b.b.get().register(this, "tag_on_setting_change", new com.m4399.gamecenter.manager.b.a() {
                @Override
                public void onReceive(String str, Object obj) {
                    c.this.jx();
                    c.this.jw();
                    c.this.jv();
                }
            });
        }
    }

    public void jv() {
        Boolean bool = (Boolean) Config.getValue(AppConfigKey.SETTING_IS_ALTERNATE);
        Iterator<a> it = this.aaU.values().iterator();
        while (it.hasNext()) {
            it.next().setStandbyHost(bool.booleanValue());
        }
    }

    public void jw() {
        boolean booleanValue = ((Boolean) Config.getValue(SysConfigKey.SETTING_HTTPS_TOGGLE)).booleanValue();
        String str = (String) Config.getValue(SysConfigKey.HTTP_ENVIRONMENT);
        StatisticsConfig.setOpenHttps(!booleanValue);
        for (a aVar : this.aaU.values()) {
            if (aVar.getType() == 2 || aVar.getType() == 1) {
                aVar.setUpEnv(str);
                if (booleanValue) {
                    if (aVar.aaS) {
                        aVar.B(str, aVar.getHost().replace("https://", d.MIME_TYPE_HTTP));
                    } else {
                        aVar.C(str, aVar.getHost().replace("https://", d.MIME_TYPE_HTTP));
                    }
                } else if (aVar.aaS) {
                    aVar.B(str, aVar.getHost().replace(d.MIME_TYPE_HTTP, "https://"));
                } else {
                    aVar.C(str, aVar.getHost().replace(d.MIME_TYPE_HTTP, "https://"));
                }
            }
        }
    }

    public void jx() {
        Iterator<a> it = this.aaU.values().iterator();
        while (it.hasNext()) {
            it.next().setUpEnv((String) Config.getValue(SysConfigKey.HTTP_ENVIRONMENT));
        }
    }

    public static c getInstance() {
        synchronized (c.class) {
            if (aaT == null) {
                aaT = new c();
            }
        }
        return aaT;
    }

    @Override
    public void resetApiServerHost() {
        Iterator<a> it = this.aaU.values().iterator();
        while (it.hasNext()) {
            it.next().reset();
        }
    }

    @Override
    public String getHost(int i) {
        a aVar = this.aaU.get(Integer.valueOf(i));
        if (aVar == null) {
            throw new RuntimeException("can't found host with type:" + i);
        }
        return aVar.getHost();
    }

    @Override
    public String tryChangeHost(String str) {
        for (a aVar : this.aaU.values()) {
            if (aVar.isMatch(str)) {
                String host = aVar.getHost();
                if (aVar.changeHost()) {
                    return str.replace(host, aVar.getHost());
                }
            }
        }
        return "";
    }

    @Override
    public boolean isHostChange(String str) {
        for (a aVar : this.aaU.values()) {
            if (aVar.isMatch(str) && !str.startsWith(aVar.getHost())) {
                return true;
            }
        }
        return false;
    }

    @Override
    public boolean isStandbyHost(String str) {
        for (a aVar : this.aaU.values()) {
            if (aVar.isMatch(str)) {
                return aVar.isStandbyHost();
            }
        }
        return false;
    }
}