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

import com.tencent.matrix.trace.core.AppMethodBeat;
import com.tencent.mm.g.a.fe;
import com.tencent.mm.plugin.freewifi.b.a.a;
import com.tencent.mm.plugin.freewifi.m;
import com.tencent.mm.sdk.platformtools.ab;
import com.tencent.mm.sdk.platformtools.al;

public final class b {
    /* synthetic */ b(byte b) {
        this();
    }

    private b() {
    }

    public final synchronized void a(fe feVar) {
        AppMethodBeat.i(20671);
        ab.i("MicroMsg.FreeWifi.FreeWifiManufacturerConnectWifiHelper", "Method connectWifi gets called");
        String Mv = m.Mv(feVar.cyA.ssid);
        String str = feVar.cyA.bssid;
        if (m.isEmpty(Mv)) {
            a(feVar, 1141, "Ssid is empty.");
            AppMethodBeat.o(20671);
        } else if (m.isEmpty(str)) {
            a(feVar, 1142, "Bssid is empty.");
            AppMethodBeat.o(20671);
        } else {
            ab.i("MicroMsg.FreeWifi.FreeWifiManufacturerConnectWifiHelper", "args: ssid=" + feVar.cyA.ssid + "; bssid=" + feVar.cyA.bssid + "; version=" + feVar.cyA.version);
            ab.i("MicroMsg.FreeWifi.FreeWifiManufacturerConnectWifiHelper", "Try to get connect info from cache");
            com.tencent.mm.plugin.freewifi.b.a.b eq = a.byy().eq(Mv, str);
            ab.i("MicroMsg.FreeWifi.FreeWifiManufacturerConnectWifiHelper", "read cache done.");
            if (eq != null) {
                String str2 = eq.cuH;
                int i = eq.mue;
                if (i == 4) {
                    ab.i("MicroMsg.FreeWifi.FreeWifiManufacturerConnectWifiHelper", "Ready to start up password ap connect page.");
                    al.d(new 1(this, str2));
                    a(feVar, 1, null);
                    AppMethodBeat.o(20671);
                } else if (i == 31) {
                    ab.i("MicroMsg.FreeWifi.FreeWifiManufacturerConnectWifiHelper", "Ready to connect 31 page.");
                    al.d(new 2(this, Mv, str));
                    a(feVar, 1, null);
                    AppMethodBeat.o(20671);
                } else {
                    a(feVar, 1143, "Wechant installed Currently doesn't support connect protocol ".concat(String.valueOf(i)));
                    AppMethodBeat.o(20671);
                }
            } else if (a.byy().size() == 0) {
                a(feVar, 1145, "Ap connect info cache in wechat is empty. It may be wechat got killed before.");
                AppMethodBeat.o(20671);
            } else {
                a(feVar, 1144, "Ap connect info cache in wechat is not empty but the ap tried to connect to is not contained in the cache.");
                AppMethodBeat.o(20671);
            }
        }
    }

    private static void a(fe feVar, int i, String str) {
        AppMethodBeat.i(20672);
        feVar.cyB.cyE = i;
        feVar.cyB.cyF = str;
        feVar.cyB.cyD = 1;
        ab.i("MicroMsg.FreeWifi.FreeWifiManufacturerConnectWifiHelper", "FreeWifiManufacturerConnectWifiHelper setResult. errorcode=%d, errmsg=%s", new Object[]{Integer.valueOf(i), str});
        if (feVar.callback != null) {
            feVar.callback.run();
        }
        AppMethodBeat.o(20672);
    }
}
