package com.ifpdos.autotest.n0;

import android.content.Context;
import android.os.SystemProperties;
import com.ifpdos.autotest.RemoteApplication;
import com.ifpdos.autotest.model.EthernetConfig;
import d.n;
import d.n0.c.s;
import java.util.concurrent.TimeUnit;

/* JADX INFO: compiled from: SeewoEthernetHandler.kt */
/* JADX INFO: loaded from: classes.dex */
@n
public final class k implements i {
    /* JADX INFO: Access modifiers changed from: private */
    public static final b.c.b.b.b e(b.c.b.c.e.a.c cVar, EthernetConfig ethernetConfig, Context context, Boolean bool) {
        String ip;
        String mask;
        String gateway;
        String seewoConnectMode;
        s.e(context, "$context");
        s.e(bool, "it");
        cVar.e(false);
        b.c.b.b.b bVarB = cVar.b();
        h hVar = h.f2250a;
        if (!hVar.a().getInit()) {
            EthernetConfig ethernetConfig2 = new EthernetConfig(null, null, null, null, null, false, 63, null);
            String strD = bVarB.d();
            String str = "";
            if (strD == null) {
                strD = "";
            } else {
                s.d(strD, "ethernetDevInfo.ipAddress ?: \"\"");
            }
            ethernetConfig2.setIp(strD);
            String strC = bVarB.c();
            if (strC == null) {
                strC = "";
            } else {
                s.d(strC, "ethernetDevInfo.netMask ?: \"\"");
            }
            ethernetConfig2.setMask(strC);
            String strJ = bVarB.j();
            if (strJ != null) {
                s.d(strJ, "ethernetDevInfo.routeAddr ?: \"\"");
                str = strJ;
            }
            ethernetConfig2.setGateway(str);
            String strI = bVarB.i();
            if (strI == null) {
                strI = "dhcp";
            } else {
                s.d(strI, "ethernetDevInfo.connectM…t.ETHERNET_CONN_MODE_DHCP");
            }
            ethernetConfig2.setSeewoConnectMode(strI);
            hVar.b(ethernetConfig2);
        }
        if (ethernetConfig == null || (ip = ethernetConfig.getIp()) == null) {
            ip = "192.168.1.11";
        }
        bVarB.k(ip);
        if (ethernetConfig == null || (mask = ethernetConfig.getMask()) == null) {
            mask = "255.255.0.0";
        }
        bVarB.g(mask);
        if (ethernetConfig == null || (gateway = ethernetConfig.getGateway()) == null) {
            gateway = "192.168.1.1";
        }
        bVarB.e(gateway);
        if (ethernetConfig == null || (seewoConnectMode = ethernetConfig.getSeewoConnectMode()) == null) {
            seewoConnectMode = "manual";
        }
        bVarB.f(seewoConnectMode);
        cVar.f(bVarB);
        try {
            SystemProperties.set("dhcp.eth0.gateway", bVarB.j());
            SystemProperties.set("dhcp.eth0.dns1", bVarB.b());
            SystemProperties.set("dhcp.eth0.dns2", bVarB.l());
            com.seewo.vcommons.data.c.h(context, bVarB.j());
        } catch (Throwable unused) {
        }
        return bVarB;
    }

    /* JADX INFO: Access modifiers changed from: private */
    public static final void f(b.c.b.c.e.a.c cVar, EthernetConfig ethernetConfig, Context context, b.c.b.b.b bVar) {
        s.e(context, "$context");
        s.e(bVar, "ethernetDevInfo");
        cVar.e(true);
        if (ethernetConfig == null) {
            com.ifpdos.autotest.o0.d.d(context, "Set static: " + bVar.d() + ", " + cVar.b().i() + ", " + com.seewo.vcommons.data.c.b(context));
        }
    }

    @Override // com.ifpdos.autotest.n0.i
    public void a(final Context context, final EthernetConfig ethernetConfig) {
        s.e(context, "context");
        final b.c.b.c.e.a.c cVarC = RemoteApplication.c();
        c.a.h.f(Boolean.TRUE).g(new c.a.p.f() { // from class: com.ifpdos.autotest.n0.f
            @Override // c.a.p.f
            public final Object apply(Object obj) {
                return k.e(cVarC, ethernetConfig, context, (Boolean) obj);
            }
        }).d(1L, TimeUnit.SECONDS).i(new c.a.p.e() { // from class: com.ifpdos.autotest.n0.e
            @Override // c.a.p.e
            public final void accept(Object obj) {
                k.f(cVarC, ethernetConfig, context, (b.c.b.b.b) obj);
            }
        });
    }

    @Override // com.ifpdos.autotest.n0.i
    public void b(Context context) {
        s.e(context, "context");
        h hVar = h.f2250a;
        if (hVar.a().getInit()) {
            a(context, hVar.a());
        }
    }
}
