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

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


package com.m4399.gamecenter.plugin.main.manager.user;

import android.app.Activity;
import android.app.Application;
import android.content.Context;
import android.os.Build;
import android.os.Bundle;
import android.support.v4.content.ContextCompat;
import android.text.TextUtils;
import android.view.View;
import android.view.ViewGroup;
import cn.com.chinatelecom.account.api.CtSetting;
import cn.com.chinatelecom.account.sdk.ui.AuthActivity;
import cn.m4399.login.union.a;
import cn.m4399.login.union.api.AccountCandidate;
import cn.m4399.login.union.api.AccountNegotiation;
import cn.m4399.login.union.api.Client;
import cn.m4399.login.union.api.LoginNonPassword;
import cn.m4399.login.union.api.LoginUiModel;
import cn.m4399.login.union.api.OnLoginFinishedListener;
import cn.m4399.login.union.api.OnResultListener;
import cn.m4399.login.union.api.Options;
import cn.m4399.login.union.api.PreLoginStatus;
import cn.m4399.login.union.api.User;
import cn.m4399.login.union.wo.WoLoginActivity;
import com.cmic.gen.sdk.view.GenLoginAuthActivity;
import com.framework.EnvironmentMode;
import com.framework.config.Config;
import com.framework.config.SysConfigKey;
import com.framework.rxbus.RxBus;
import com.framework.utils.AppUtils;
import com.framework.utils.JSONUtils;
import com.huawei.hms.push.constant.RemoteMessageConst;
import com.m4399.framework.BaseApplication;
import com.m4399.gamecenter.plugin.main.config.UserConfigKey;
import com.m4399.gamecenter.plugin.main.controllers.user.login.LoginActivity;
import com.m4399.gamecenter.plugin.main.livedata.LiveDataBus;
import com.m4399.gamecenter.plugin.main.models.user.SimpleUserModel;
import com.m4399.gamecenter.plugin.main.user.R;
import com.m4399.gamecenter.plugin.main.utils.ay;
import com.m4399.gamecenter.plugin.main.utils.bc;
import com.m4399.gamecenter.utils.ConfigUtils;
import com.m4399.plugin.PluginApplication;
import com.m4399.support.utils.StatusBarHelper;
import com.m4399.support.utils.ToastUtils;
import com.tencent.mm.opensdk.modelmsg.SendAuth;
import com.tencent.mm.opensdk.openapi.IWXAPI;
import java.lang.ref.SoftReference;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import rx.android.schedulers.AndroidSchedulers;
import rx.functions.Action1;
import timber.log.Timber;

public class i {
    public static final String APP_ID = "100266617";
    public static final String KEY_ACCESS_TOKEN = "accessToken";
    public static final String KEY_IS_REGISTER = "isregister";
    public static final String KEY_PHONE_NUMBER = "number";
    public static final String KEY_REFRESH_TOKEN = "refreshToken";
    public static final String KEY_SIM_TYPE = "tele_type";
    public static final String KEY_UID = "uid";
    public static final int SIM_TYPE_MOBILE = 2;
    public static final int SIM_TYPE_TELECOM = 3;
    public static final int SIM_TYPE_UNICON = 1;
    public static final String WECHAT_APP_ID = "wx1131b46b69f840a5";
    public static final String WX_AUTH_REQ_STATE = "wechat_login";
    private static i diY = null;
    private static int djb = -439901;
    private static String djc = "Sdk init fail";
    private com.tencent.tauth.d diZ;
    private int dja = 0;
    private PreLoginStatus djd;
    private SoftReference<c> dje;

    public static abstract class b implements com.m4399.gamecenter.plugin.main.listeners.h {
        public abstract void onBefore();

        public abstract void onMultiUserSelect(List<SimpleUserModel> list, String str, d dVar);
    }

    public interface d {
        void select(String str);
    }

    public void debugShow(String str, int i) {
    }

    public static synchronized i getInstance() {
        i iVar;
        synchronized (i.class) {
            if (diY == null) {
                diY = new i();
            }
            iVar = diY;
        }
        return iVar;
    }

    private i() {
        RxBus.register(this);
        UserCenterManager.getInstance().asLoginStatusObservable().observeOn(AndroidSchedulers.mainThread()).subscribe(new Action1<Boolean>() {
            @Override
            public void call(Boolean bool) {
                if (bool.booleanValue()) {
                    return;
                }
                i.this.initNonPasswordSdk();
            }
        });
        LiveDataBus.INSTANCE.get("remote_static_config").observeStickyForever(new android.arch.lifecycle.m<Boolean>() {
            @Override
            public void onChanged(Boolean bool) {
                i.this.initNonPasswordSdk();
            }
        });
    }

    public com.tencent.tauth.d getTencent(Context context) {
        try {
            if (this.diZ == null) {
                this.diZ = com.tencent.tauth.d.createInstance(APP_ID, BaseApplication.getApplication(), "com.m4399.gamecenter.FileProvider");
                com.tencent.tauth.d.setIsPermissionGranted(true, Build.MODEL);
            }
        } catch (Throwable th) {
            th.printStackTrace();
        }
        return this.diZ;
    }

    public void loginByQQ(Context context, com.tencent.tauth.c cVar) {
        this.diZ = getTencent(context);
        if (this.diZ == null) {
            ToastUtils.showToast(context, "QQ登录异常");
            return;
        }
        aX(context);
        if (this.diZ.isSessionValid()) {
            return;
        }
        try {
            this.diZ.login((Activity) context, "all", cVar);
        } catch (Exception unused) {
        }
    }

    private static void aX(Context context) {
        i iVar = diY;
        if (iVar != null && iVar.diZ.isSessionValid()) {
            diY.diZ.logout(context);
        }
    }

    public static void loginByWechat(Context context, Map<String, String> map) {
        IWXAPI iwxapi = (IWXAPI) BaseApplication.getApplication().excHostFunc("getWeChatApi", "wx1131b46b69f840a5");
        if (iwxapi == null) {
            Timber.e("wechat client is null", "");
            return;
        }
        if (!iwxapi.isWXAppInstalled()) {
            ToastUtils.showToast(context, R.string.share_weixin_no_installed);
            return;
        }
        SendAuth.Req req = new SendAuth.Req();
        req.scope = "snsapi_userinfo";
        req.state = WX_AUTH_REQ_STATE + ay.mapToString(map);
        iwxapi.sendReq(req);
    }

    public synchronized void initNonPasswordSdk() {
        if (this.dja != 1 && RL()) {
            this.dja = 1;
            String str = "";
            String str2 = (String) Config.getValue(SysConfigKey.HTTP_ENVIRONMENT);
            char c2 = 65535;
            int hashCode = str2.hashCode();
            if (hashCode != -1012222381) {
                if (hashCode != 3557) {
                    if (hashCode != 3646) {
                        if (hashCode == 3556498 && str2.equals(EnvironmentMode.TESTER)) {
                            c2 = 1;
                        }
                    } else if (str2.equals(EnvironmentMode.T2)) {
                        c2 = 0;
                    }
                } else if (str2.equals(EnvironmentMode.OT)) {
                    c2 = 2;
                }
            } else if (str2.equals(EnvironmentMode.ONLINE)) {
                c2 = 3;
            }
            str = "c98c41078b11eaa49b3d5c4d392dd42d";
            Config.setValue(UserConfigKey.ONE_CLICK_LOGIN_HOST, "https://dlstest.img4399.com/redirect/cdn.4399sj.com/test");
            LoginNonPassword.init(new Options().debuggable(false).appContext(PluginApplication.getApplication()), new Client().withCustomer(PluginApplication.getApplication().getPluginVersionName()).withId(str), new OnResultListener() {
                @Override
                public void onResult(long j, String str3) {
                    if (j == 0) {
                        LoginNonPassword.canSupport(new OnResultListener() {
                            @Override
                            public void onResult(long j2, String str4) {
                                if (j2 == 0) {
                                    i.this.djd = LoginNonPassword.getPreLoginStatus();
                                    i.this.dja = 3;
                                } else {
                                    i.this.dja = 2;
                                    i.this.debugShow(str4, (int) j2);
                                    String unused = i.djc = str4 + "(" + j2 + ")";
                                }
                                i.this.a(i.this.dje != null ? (com.m4399.gamecenter.plugin.main.listeners.h) i.this.dje.get() : null, i.this.dja == 3);
                            }
                        });
                        return;
                    }
                    String unused = i.djc = str3 + "(" + j + ")";
                    i.this.dja = 2;
                    i.this.debugShow(str3, (int) j);
                    i iVar = i.this;
                    iVar.a(iVar.dje != null ? (com.m4399.gamecenter.plugin.main.listeners.h) i.this.dje.get() : null, i.this.dja == 3);
                }
            });
        }
    }

    private boolean RL() {
        if (ConfigUtils.isBrowserMode()) {
            return false;
        }
        return ((Boolean) Config.getValue(UserConfigKey.ONE_CLICK_LOGIN_SWITCH)).booleanValue();
    }

    public void checkShowOneClickLogin(com.m4399.gamecenter.plugin.main.listeners.h hVar) {
        final c cVar = new c(hVar);
        this.dje = new SoftReference<>(cVar);
        if (RL()) {
            int i = this.dja;
            if (i == 0) {
                initNonPasswordSdk();
            } else if (i != 1) {
                if (i == 2) {
                    AppUtils.runOnUiThread(new Runnable() {
                        @Override
                        public void run() {
                            cVar.onFailure(i.djb, i.djc, null);
                        }
                    });
                    initNonPasswordSdk();
                    return;
                } else if (i == 3) {
                    a((com.m4399.gamecenter.plugin.main.listeners.h) cVar, true);
                    return;
                }
            }
            AppUtils.runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    cVar.onFailure(404, "初始化超时", null);
                }
            }, 4000L);
            return;
        }
        AppUtils.runOnUiThread(new Runnable() {
            @Override
            public void run() {
                cVar.onFailure(0, "上次登录类型不满足展示条件", null);
            }
        });
    }

    public void a(final com.m4399.gamecenter.plugin.main.listeners.h hVar, boolean z) {
        if (hVar == null) {
            return;
        }
        if (z) {
            if (this.djd != null) {
                final Bundle bundle = new Bundle();
                int operatorType = this.djd.operatorType();
                if (operatorType == 0) {
                    bundle.putInt(KEY_SIM_TYPE, 2);
                } else if (operatorType == 1) {
                    bundle.putInt(KEY_SIM_TYPE, 1);
                } else if (operatorType == 2) {
                    bundle.putInt(KEY_SIM_TYPE, 3);
                }
                AppUtils.runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        hVar.onSuccess(bundle);
                    }
                });
                return;
            }
            AppUtils.runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    hVar.onFailure(0, "运营商信息获取失败", null);
                }
            });
            return;
        }
        AppUtils.runOnUiThread(new Runnable() {
            @Override
            public void run() {
                hVar.onFailure(i.djb, i.djc, null);
            }
        });
    }

    public void doNonPasswordLogin(Activity activity, b bVar) {
        final SoftReference softReference = new SoftReference(bVar);
        if (softReference.get() != null) {
            ((b) softReference.get()).onBefore();
        }
        LoginUiModel loginActivityLayout = new LoginUiModel().appLogo(R.mipmap.m4399_png_about_app_icon).appName(R.string.app_name).showCmLoginUnion(false).privacyChecked(true).loginActivityLayout(R.layout.m4399_login_union_activity_ct_account_auth);
        final a aVar = new a() {
            @Override
            public void onActivityResumed(Activity activity2) {
                String name = activity2.getClass().getName();
                if (AuthActivity.class.getName().equals(name) || WoLoginActivity.class.getName().equals(name)) {
                    activity2.findViewById(a.d.ct_account_login_btn).performClick();
                    return;
                }
                if (GenLoginAuthActivity.class.getName().equals(name)) {
                    View childAt = ((ViewGroup) activity2.findViewById(android.R.id.content)).getChildAt(0);
                    if (childAt != null) {
                        activity2.getWindow().getDecorView().setVisibility(4);
                        childAt.setVisibility(4);
                        childAt.setBackgroundColor(ContextCompat.getColor(activity2, R.color.transparent));
                    }
                    View findViewById = activity2.findViewById(17476);
                    if (findViewById != null) {
                        findViewById.performClick();
                    }
                }
            }
        };
        BaseApplication.getApplication().registerActivityLifecycleCallbacks(aVar);
        LoginNonPassword.login(activity, new OnLoginFinishedListener() {
            @Override
            public void onLoginFinished(long j, String str, User user) {
                BaseApplication.getApplication().unregisterActivityLifecycleCallbacks(aVar);
                if (j != 0) {
                    SoftReference softReference2 = softReference;
                    if (softReference2 == null || softReference2.get() == null) {
                        return;
                    }
                    i.this.a((int) j, str, (com.m4399.gamecenter.plugin.main.listeners.h) softReference.get());
                    return;
                }
                if (user == null) {
                    SoftReference softReference3 = softReference;
                    if (softReference3 == null || softReference3.get() == null) {
                        return;
                    }
                    i.this.a(0, "user is null", (com.m4399.gamecenter.plugin.main.listeners.h) softReference.get());
                    return;
                }
                SoftReference softReference4 = softReference;
                if (softReference4 == null || softReference4.get() == null) {
                    return;
                }
                Bundle bundle = new Bundle();
                bundle.putString("uid", user.uid());
                bundle.putString(i.KEY_ACCESS_TOKEN, user.accessToken());
                bundle.putString("refreshToken", user.refreshToken());
                bundle.putBoolean(i.KEY_IS_REGISTER, user.register());
                SoftReference softReference5 = softReference;
                if (softReference5 == null || softReference5.get() == null) {
                    return;
                }
                ((b) softReference.get()).onSuccess(bundle);
            }
        }, new AccountNegotiation() {
            @Override
            public void onMultiAccount(String str, final List<AccountCandidate> list) {
                BaseApplication.getApplication().unregisterActivityLifecycleCallbacks(aVar);
                if (list == null || list.isEmpty()) {
                    SoftReference softReference2 = softReference;
                    if (softReference2 == null || softReference2.get() == null) {
                        return;
                    }
                    i.this.a(0, "用户列表数据为空", (com.m4399.gamecenter.plugin.main.listeners.h) softReference.get());
                    return;
                }
                SoftReference softReference3 = softReference;
                if (softReference3 == null || softReference3.get() == null) {
                    return;
                }
                ArrayList arrayList = new ArrayList();
                for (AccountCandidate accountCandidate : list) {
                    SimpleUserModel simpleUserModel = new SimpleUserModel();
                    simpleUserModel.setIcon(accountCandidate.avatar());
                    simpleUserModel.setPreLoginDL(bc.toLong(accountCandidate.loginTime()));
                    simpleUserModel.setPtUid(accountCandidate.uid());
                    simpleUserModel.setNick(accountCandidate.nick());
                    arrayList.add(simpleUserModel);
                }
                SoftReference softReference4 = softReference;
                if (softReference4 == null || softReference4.get() == null) {
                    return;
                }
                ((b) softReference.get()).onMultiUserSelect(arrayList, str, new d() {
                    @Override
                    public void select(String str2) {
                        for (AccountCandidate accountCandidate2 : list) {
                            if (accountCandidate2.uid().equals(str2)) {
                                accountCandidate2.onSelected();
                            }
                        }
                    }
                });
            }
        }, loginActivityLayout);
    }

    public void requirePhoneNumber(com.m4399.gamecenter.plugin.main.listeners.h hVar) {
        final SoftReference softReference = new SoftReference(hVar);
        if (ConfigUtils.isBrowserMode()) {
            AppUtils.runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    SoftReference softReference2 = softReference;
                    if (softReference2 == null || softReference2.get() == null) {
                        return;
                    }
                    ((com.m4399.gamecenter.plugin.main.listeners.h) softReference.get()).onFailure(0, "浏览模式不支持", null);
                }
            });
        } else {
            LoginNonPassword.canSupport(new AnonymousClass6(softReference));
        }
    }

    public class AnonymousClass6 implements OnResultListener {
        final SoftReference djh;

        AnonymousClass6(SoftReference softReference) {
            this.djh = softReference;
        }

        @Override
        public void onResult(long j, String str) {
            if (j != 0) {
                i.this.dja = 2;
            } else {
                i.this.djd = LoginNonPassword.getPreLoginStatus();
                i.this.dja = 3;
            }
            final Bundle bundle = new Bundle();
            if (i.this.djd != null) {
                int operatorType = i.this.djd.operatorType();
                if (operatorType == 0) {
                    bundle.putInt(i.KEY_SIM_TYPE, 2);
                } else if (operatorType == 1) {
                    bundle.putInt(i.KEY_SIM_TYPE, 1);
                } else if (operatorType == 2) {
                    bundle.putInt(i.KEY_SIM_TYPE, 3);
                }
                if (i.this.djd.operatorType() == 1) {
                    AppUtils.runOnUiThread(new Runnable() {
                        @Override
                        public void run() {
                            String desensitisedPhone = i.this.djd.desensitisedPhone();
                            if (!TextUtils.isEmpty(desensitisedPhone)) {
                                i.this.a(bundle, desensitisedPhone, (SoftReference<com.m4399.gamecenter.plugin.main.listeners.h>) AnonymousClass6.this.djh);
                                return;
                            }
                            String phone = i.this.getPhone();
                            if (TextUtils.isEmpty(phone)) {
                                return;
                            }
                            i.this.a(bundle, phone, (SoftReference<com.m4399.gamecenter.plugin.main.listeners.h>) AnonymousClass6.this.djh);
                        }
                    });
                    return;
                }
            }
            cn.com.chinatelecom.account.api.a.a().a((CtSetting) null, new cn.com.chinatelecom.account.api.c() {
                @Override
                public void a(String str2) {
                    final String string = JSONUtils.getString(i.KEY_PHONE_NUMBER, JSONUtils.getJSONObject(RemoteMessageConst.DATA, JSONUtils.parseJSONObjectFromString(str2)));
                    if (TextUtils.isEmpty(string)) {
                        String phone = i.this.getPhone();
                        if (!TextUtils.isEmpty(phone)) {
                            i.this.a(bundle, phone, (SoftReference<com.m4399.gamecenter.plugin.main.listeners.h>) AnonymousClass6.this.djh);
                            return;
                        } else {
                            AppUtils.runOnUiThread(new Runnable() {
                                @Override
                                public void run() {
                                    if (AnonymousClass6.this.djh == null || AnonymousClass6.this.djh.get() == null) {
                                        return;
                                    }
                                    ((com.m4399.gamecenter.plugin.main.listeners.h) AnonymousClass6.this.djh.get()).onFailure(0, "电话号码获取失败", null);
                                }
                            });
                            return;
                        }
                    }
                    AppUtils.runOnUiThread(new Runnable() {
                        @Override
                        public void run() {
                            i.this.a(bundle, string, (SoftReference<com.m4399.gamecenter.plugin.main.listeners.h>) AnonymousClass6.this.djh);
                        }
                    });
                }
            });
        }
    }

    public String getPhone() {
        com.cmic.gen.sdk.e.k.a(BaseApplication.getApplication());
        return com.cmic.gen.sdk.e.k.b("securityphone", "");
    }

    public void a(Bundle bundle, String str, SoftReference<com.m4399.gamecenter.plugin.main.listeners.h> softReference) {
        if (softReference == null || softReference.get() == null) {
            return;
        }
        bundle.putString(KEY_PHONE_NUMBER, str);
        softReference.get().onSuccess(bundle);
    }

    public static abstract class a implements Application.ActivityLifecycleCallbacks {
        @Override
        public void onActivityPaused(Activity activity) {
        }

        @Override
        public void onActivitySaveInstanceState(Activity activity, Bundle bundle) {
        }

        @Override
        public void onActivityStarted(Activity activity) {
        }

        @Override
        public void onActivityStopped(Activity activity) {
        }

        private a() {
        }

        @Override
        public void onActivityCreated(Activity activity, Bundle bundle) {
            String name = activity.getClass().getName();
            if (AuthActivity.class.getName().equals(name) || WoLoginActivity.class.getName().equals(name)) {
                StatusBarHelper.setStatusBarDarkStylePrive(activity, true);
            }
        }

        @Override
        public void onActivityDestroyed(Activity activity) {
            if (activity.getClass().getName().equals(LoginActivity.class.getName())) {
                BaseApplication.getApplication().unregisterActivityLifecycleCallbacks(this);
            }
        }
    }

    public void a(int i, String str, com.m4399.gamecenter.plugin.main.listeners.h hVar) {
        if (hVar != null) {
            hVar.onFailure(i, str, null);
        }
    }

    public class c implements com.m4399.gamecenter.plugin.main.listeners.h {
        private boolean aaD;
        private com.m4399.gamecenter.plugin.main.listeners.h djo;

        public c(com.m4399.gamecenter.plugin.main.listeners.h hVar) {
            this.djo = hVar;
        }

        @Override
        public void onSuccess(Bundle bundle) {
            com.m4399.gamecenter.plugin.main.listeners.h hVar;
            if (this.aaD || (hVar = this.djo) == null) {
                return;
            }
            this.aaD = true;
            hVar.onSuccess(bundle);
        }

        @Override
        public void onFailure(int i, String str, Bundle bundle) {
            com.m4399.gamecenter.plugin.main.listeners.h hVar;
            if (this.aaD || (hVar = this.djo) == null) {
                return;
            }
            this.aaD = true;
            hVar.onFailure(i, str, bundle);
        }
    }
}