package a.b.a.k.f;

import android.net.wifi.p2p.WifiP2pConfig;
import java.lang.reflect.Field;
import java.lang.reflect.Method;

public class b {

    /* renamed from: a  reason: collision with root package name */
    private static final String f49a = "ConfigBuilderProxy";
    private static Class b;
    private static Field c;
    private static Method d;
    private static Method e = b.getDeclaredMethod("setPassphrase", String.class);
    private static Method f;
    private static Method g;
    private static Method h = b.getDeclaredMethod("build", new Class[0]);

    static {
        try {
            Class<?> cls = Class.forName("android.net.wifi.p2p.WifiP2pConfig$Builder");
            b = cls;
            d = cls.getDeclaredMethod("setNetworkName", String.class);
            Class cls2 = b;
            Class<?> cls3 = Integer.TYPE;
            f = cls2.getDeclaredMethod("setGroupOperatingFrequency", cls3);
            g = b.getDeclaredMethod("setGroupOperatingBand", cls3);
            try {
                Field declaredField = b.getDeclaredField("mNetworkName");
                c = declaredField;
                declaredField.setAccessible(true);
            } catch (Exception e2) {
                a.a.a.b.e(f49a, "Reflect private field failed, reasonable. " + e2.getMessage());
            }
        } catch (Exception e3) {
            a.a.a.b.b(f49a, "Reflect initialize failed.", e3);
        }
    }

    public static WifiP2pConfig a(a aVar) {
        try {
            Object newInstance = b.newInstance();
            try {
                c.set(newInstance, aVar.c());
            } catch (Exception e2) {
                a.a.a.b.e(f49a, "Set network name by field failed. " + e2.getMessage());
                d.invoke(newInstance, aVar.c());
            }
            e.invoke(newInstance, aVar.e());
            if (aVar.b() == 0) {
                g.invoke(newInstance, Integer.valueOf(aVar.a()));
            } else {
                f.invoke(newInstance, Integer.valueOf(aVar.b()));
            }
            return (WifiP2pConfig) h.invoke(newInstance, new Object[0]);
        } catch (Exception e3) {
            a.a.a.b.b(f49a, "Get WifiP2pConfig failed. " + e3.getMessage());
            return null;
        }
    }
}
