package com.tencent.mm.plugin.freewifi;

import android.content.Intent;
import com.tencent.matrix.trace.core.AppMethodBeat;
import com.tencent.mm.plugin.freewifi.f.b;
import com.tencent.mm.plugin.freewifi.model.j;
import com.tencent.mm.plugin.report.service.h;
import com.tencent.mm.sdk.platformtools.ab;
import java.util.Map;
import org.json.JSONException;
import org.json.JSONObject;

public final class k {
    public static Map<String, String> mua = new 1();
    private String bssid;
    private int cIb;
    private String cuH;
    private String cuI;
    private String ehr;
    private String kBq;
    private int mub;
    private String muc;
    private String mud;
    private int mue;
    private long muf;
    private String mug;
    private String muh;
    private long mui;
    private int result;
    private String ssid;

    /* synthetic */ k(byte b) {
        this();
    }

    static {
        AppMethodBeat.i(20616);
        AppMethodBeat.o(20616);
    }

    public static String Mu(String str) {
        AppMethodBeat.i(20612);
        String Mw = m.Mw((String) mua.get(str));
        AppMethodBeat.o(20612);
        return Mw;
    }

    private k() {
    }

    public static a byo() {
        AppMethodBeat.i(20613);
        a aVar = new a((byte) 0);
        AppMethodBeat.o(20613);
        return aVar;
    }

    public final k byp() {
        AppMethodBeat.i(20614);
        h.pYm.e(12804, new Object[]{m.Mw(this.ssid), m.Mw(this.bssid), m.Mw(this.cuI), m.Mw(this.cuH), Integer.valueOf(this.mub), m.Mw(this.muc), m.Mw(this.mud), m.Mw(this.kBq), Integer.valueOf(this.mue), Long.valueOf(this.muf), m.Mw(this.mug), Integer.valueOf(this.result), Integer.valueOf(this.cIb), m.Mw(this.muh), Long.valueOf(this.mui), m.Mw(this.ehr)});
        AppMethodBeat.o(20614);
        return this;
    }

    public final k b(Intent intent, boolean z) {
        AppMethodBeat.i(20615);
        try {
            final int X = m.X(intent);
            if (X != 31) {
                AppMethodBeat.o(20615);
                return this;
            }
            JSONObject jSONObject = new JSONObject();
            try {
                jSONObject.put("ssid", this.ssid);
                jSONObject.put("bssid", this.bssid);
                jSONObject.put("clientMac", this.cuI);
                jSONObject.put("apKey", this.cuH);
                jSONObject.put("qrtype", this.mub);
                jSONObject.put("mpShopId", this.muc);
                jSONObject.put("mpAppId", this.mud);
                jSONObject.put("sessionKey", this.kBq);
                jSONObject.put("protocolType", this.mue);
                jSONObject.put("stageCode", this.muf);
                jSONObject.put("stageName", this.mug);
                jSONObject.put("result", this.result);
                jSONObject.put("channel", this.cIb);
                jSONObject.put("mpUserName", this.muh);
                jSONObject.put("timeCost", this.mui);
                jSONObject.put("resultMsg", this.ehr);
                jSONObject.put("logCurrentTimeMillis", System.currentTimeMillis());
            } catch (JSONException e) {
                ab.e("MicroMsg.FreeWifi.FreeWifiQualityReporter", "JSONException e. " + m.h(e));
            }
            String jSONObject2 = jSONObject.toString();
            String stringExtra = intent.getStringExtra("ConstantsFreeWifi.FREE_WIFI_REPORT_WIFI_SERVER_JSON");
            if (m.isEmpty(stringExtra)) {
                intent.putExtra("ConstantsFreeWifi.FREE_WIFI_REPORT_WIFI_SERVER_JSON", jSONObject2);
            } else {
                intent.putExtra("ConstantsFreeWifi.FREE_WIFI_REPORT_WIFI_SERVER_JSON", stringExtra + "," + jSONObject2);
            }
            final long currentTimeMillis = System.currentTimeMillis();
            final String stringExtra2 = intent.getStringExtra("ConstantsFreeWifi.FREE_WIFI_REPORT_WIFI_SERVER_ID");
            final String stringExtra3 = intent.getStringExtra("ConstantsFreeWifi.FREE_WIFI_REPORT_WIFI_SERVER_JSON");
            if (z) {
                j.bza().byI().post(new Runnable() {
                    public final void run() {
                        AppMethodBeat.i(20606);
                        j.byY().a(stringExtra2, X, stringExtra3, currentTimeMillis);
                        if (m.byu()) {
                            b.kT(1);
                        }
                        AppMethodBeat.o(20606);
                    }
                });
            }
            AppMethodBeat.o(20615);
            return this;
        } catch (Exception e2) {
            ab.e("MicroMsg.FreeWifi.FreeWifiQualityReporter", "reportWifiServer() write to local file exception. " + m.h(e2));
        }
    }
}
