package com.tencent.mm.plugin.freewifi.model;

import android.content.IntentFilter;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.RemoteException;
import com.tencent.matrix.trace.core.AppMethodBeat;
import com.tencent.mm.cd.h.d;
import com.tencent.mm.g.a.ae;
import com.tencent.mm.g.a.af;
import com.tencent.mm.g.a.pm;
import com.tencent.mm.kernel.g;
import com.tencent.mm.model.at;
import com.tencent.mm.model.aw;
import com.tencent.mm.model.bw;
import com.tencent.mm.model.bz;
import com.tencent.mm.network.n;
import com.tencent.mm.plugin.freewifi.g.f;
import com.tencent.mm.plugin.freewifi.k;
import com.tencent.mm.plugin.freewifi.m;
import com.tencent.mm.plugin.freewifi.ui.a;
import com.tencent.mm.sdk.b.b;
import com.tencent.mm.sdk.b.c;
import com.tencent.mm.sdk.platformtools.ab;
import com.tencent.mm.sdk.platformtools.ah;
import com.tencent.ytcommon.BuildConfig;
import java.util.HashMap;

public final class j implements at {
    private static HashMap<Integer, d> eaA;
    private c gRa = new c<ae>() {
        {
            AppMethodBeat.i(20740);
            this.xxI = ae.class.getName().hashCode();
            AppMethodBeat.o(20740);
        }

        public final /* synthetic */ boolean a(b bVar) {
            AppMethodBeat.i(20741);
            af afVar = new af();
            afVar.csZ.ctb = new a(ah.getContext());
            com.tencent.mm.sdk.b.a.xxA.m(afVar);
            AppMethodBeat.o(20741);
            return false;
        }
    };
    private bz.a luy = new 4(this);
    private volatile d mwd;
    private volatile com.tencent.mm.plugin.freewifi.g.d mwe;
    private volatile com.tencent.mm.plugin.freewifi.g.b mwf;
    private volatile f mwg;
    private volatile c mwh;
    private volatile c mwi;
    private volatile a mwj;
    private volatile e mwk;
    private n mwl = new 7(this);
    private c mwm = new 8(this);
    private c mwn = new c<pm>() {
        {
            AppMethodBeat.i(20748);
            this.xxI = pm.class.getName().hashCode();
            AppMethodBeat.o(20748);
        }

        public final /* synthetic */ boolean a(b bVar) {
            AppMethodBeat.i(20749);
            pm pmVar = (pm) bVar;
            int networkType = d.getNetworkType();
            if (!(networkType == 0 || networkType == -1)) {
                ab.i("MicroMsg.FreeWifi.SubCoreFreeWifi", "networkType is " + networkType + ", start to scan and report near field wifi, to get a pushed message for connecting wifi.");
                h.b.byT().a(new 1(this, pmVar.cLH.userName));
            }
            AppMethodBeat.o(20749);
            return false;
        }
    };
    private c mwo = new 10(this);
    private c mwp = new 11(this);
    private c mwq = new 12(this);
    private c mwr = new 2(this);

    public j() {
        AppMethodBeat.i(20757);
        AppMethodBeat.o(20757);
    }

    static {
        AppMethodBeat.i(20769);
        HashMap hashMap = new HashMap();
        eaA = hashMap;
        hashMap.put(Integer.valueOf("FREEWIFIINFO_TABLE".hashCode()), new 1());
        eaA.put(Integer.valueOf("FREEWIFICONFIG_TABLE".hashCode()), new 5());
        eaA.put(Integer.valueOf("FREEWIFILOG_TABLE".hashCode()), new 6());
        AppMethodBeat.o(20769);
    }

    public static j byU() {
        AppMethodBeat.i(20758);
        aw.ZE();
        j jVar = (j) bw.oJ("plugin.freewifi");
        if (jVar == null) {
            ab.w("MicroMsg.FreeWifi.SubCoreFreeWifi", "not found in MMCore, new one");
            jVar = new j();
            aw.ZE().a("plugin.freewifi", jVar);
        }
        AppMethodBeat.o(20758);
        return jVar;
    }

    public static d byV() {
        AppMethodBeat.i(20759);
        g.RN().QU();
        if (byU().mwd == null) {
            byU().mwd = new d();
        }
        d dVar = byU().mwd;
        AppMethodBeat.o(20759);
        return dVar;
    }

    public static com.tencent.mm.plugin.freewifi.g.d byW() {
        AppMethodBeat.i(20760);
        g.RN().QU();
        if (byU().mwe == null) {
            j byU = byU();
            aw.ZK();
            byU.mwe = new com.tencent.mm.plugin.freewifi.g.d(com.tencent.mm.model.c.Ru());
        }
        com.tencent.mm.plugin.freewifi.g.d dVar = byU().mwe;
        AppMethodBeat.o(20760);
        return dVar;
    }

    public static com.tencent.mm.plugin.freewifi.g.b byX() {
        AppMethodBeat.i(20761);
        g.RN().QU();
        if (byU().mwf == null) {
            j byU = byU();
            aw.ZK();
            byU.mwf = new com.tencent.mm.plugin.freewifi.g.b(com.tencent.mm.model.c.Ru());
        }
        com.tencent.mm.plugin.freewifi.g.b bVar = byU().mwf;
        AppMethodBeat.o(20761);
        return bVar;
    }

    public static f byY() {
        AppMethodBeat.i(20762);
        g.RN().QU();
        if (byU().mwg == null) {
            j byU = byU();
            aw.ZK();
            byU.mwg = new f(com.tencent.mm.model.c.Ru());
        }
        f fVar = byU().mwg;
        AppMethodBeat.o(20762);
        return fVar;
    }

    public static c byZ() {
        AppMethodBeat.i(20763);
        g.RN().QU();
        if (byU().mwh == null) {
            byU().mwh = new c();
        }
        c cVar = byU().mwh;
        AppMethodBeat.o(20763);
        return cVar;
    }

    public static c bza() {
        AppMethodBeat.i(20764);
        g.RN().QU();
        if (byU().mwi == null) {
            byU().mwi = new c();
        }
        c cVar = byU().mwi;
        AppMethodBeat.o(20764);
        return cVar;
    }

    public static synchronized a bzb() {
        a aVar;
        synchronized (j.class) {
            AppMethodBeat.i(20765);
            g.RN().QU();
            if (byU().mwj == null) {
                byU().mwj = new a();
            }
            aVar = byU().mwj;
            AppMethodBeat.o(20765);
        }
        return aVar;
    }

    public final void iy(int i) {
    }

    public final void bz(boolean z) {
        AppMethodBeat.i(20766);
        aw.getSysCmdMsgExtension().a("freewifi", this.luy, true);
        aw.a(this.mwl);
        com.tencent.mm.sdk.b.a.xxA.c(this.mwm);
        com.tencent.mm.sdk.b.a.xxA.c(this.mwn);
        com.tencent.mm.sdk.b.a.xxA.c(this.mwo);
        com.tencent.mm.sdk.b.a.xxA.c(this.mwp);
        com.tencent.mm.sdk.b.a.xxA.c(this.mwq);
        com.tencent.mm.sdk.b.a.xxA.c(this.mwr);
        com.tencent.mm.sdk.b.a.xxA.c(this.gRa);
        try {
            this.mwl.gl(-9);
        } catch (RemoteException e) {
            ab.e("MicroMsg.FreeWifi.SubCoreFreeWifi", "netChanged.onNetworkChange(NETWORK_ACCOUNT_POST_RESET) error. e.getMessage()=" + e.getMessage());
        }
        b byH = b.b.byH();
        ab.i("MicroMsg.FreeWifi.FreeWifiConnChangedManager", "initialized");
        try {
            ConnectivityManager connectivityManager = (ConnectivityManager) ah.getContext().getSystemService("connectivity");
            NetworkInfo networkInfo = connectivityManager.getNetworkInfo(1);
            ab.i("MicroMsg.FreeWifi.FreeWifiConnChangedManager", "networkInfoWifi=%s", new Object[]{networkInfo.toString()});
            IntentFilter intentFilter;
            if (networkInfo == null || !networkInfo.isConnected()) {
                NetworkInfo networkInfo2 = connectivityManager.getNetworkInfo(0);
                ab.i("MicroMsg.FreeWifi.FreeWifiConnChangedManager", "networkInfoMobile=%s", new Object[]{networkInfo2.toString()});
                if (networkInfo2 != null && networkInfo2.isConnected()) {
                    b.a aVar = new b.a((byte) 0);
                    aVar.mvE = System.currentTimeMillis();
                    aVar.type = 0;
                    aVar.ssid = BuildConfig.FLAVOR;
                    aVar.bssid = BuildConfig.FLAVOR;
                    aVar.mvF = m.Mw(networkInfo2.getExtraInfo());
                    b.a(byH.mvB.byG(), aVar);
                    byH.mvB = aVar;
                }
                intentFilter = new IntentFilter();
                intentFilter.addAction("android.net.conn.CONNECTIVITY_CHANGE");
                byH.byc();
                ah.getContext().registerReceiver(byH.mvC, intentFilter);
                AppMethodBeat.o(20766);
            }
            String Mv = m.Mv(m.Mx("MicroMsg.FreeWifi.FreeWifiConnChangedManager"));
            String toLowerCase = m.My("MicroMsg.FreeWifi.FreeWifiConnChangedManager").toLowerCase();
            b.a aVar2 = new b.a((byte) 0);
            aVar2.mvE = System.currentTimeMillis();
            aVar2.type = 1;
            aVar2.ssid = Mv;
            aVar2.bssid = toLowerCase;
            aVar2.mvF = BuildConfig.FLAVOR;
            b.b(byH.mvB.byG(), aVar2);
            byH.mvB = aVar2;
            intentFilter = new IntentFilter();
            intentFilter.addAction("android.net.conn.CONNECTIVITY_CHANGE");
            byH.byc();
            ah.getContext().registerReceiver(byH.mvC, intentFilter);
            AppMethodBeat.o(20766);
        } catch (Exception e2) {
            k.a byo = k.byo();
            byo.cuH = "UnExpectedException";
            byo.result = -1;
            byo.ehr = m.g(e2);
            byo.byq().byp();
            ab.e("MicroMsg.FreeWifi.UnExcepctedException", m.h(e2));
        }
    }

    public final void bA(boolean z) {
    }

    public final void onAccountRelease() {
        AppMethodBeat.i(20767);
        aw.getSysCmdMsgExtension().b("freewifi", this.luy, true);
        byV();
        byZ().release();
        aw.b(this.mwl);
        com.tencent.mm.sdk.b.a.xxA.d(this.mwm);
        com.tencent.mm.sdk.b.a.xxA.d(this.mwn);
        com.tencent.mm.sdk.b.a.xxA.d(this.mwo);
        com.tencent.mm.sdk.b.a.xxA.d(this.mwp);
        com.tencent.mm.sdk.b.a.xxA.d(this.mwq);
        com.tencent.mm.sdk.b.a.xxA.d(this.mwr);
        com.tencent.mm.sdk.b.a.xxA.d(this.gRa);
        b.b.byH().byc();
        AppMethodBeat.o(20767);
    }

    public final HashMap<Integer, d> Jx() {
        return eaA;
    }

    public static e bzc() {
        AppMethodBeat.i(20768);
        g.RN().QU();
        if (byU().mwk == null) {
            byU().mwk = new e();
        }
        e eVar = byU().mwk;
        AppMethodBeat.o(20768);
        return eVar;
    }
}
