package c0;

import android.util.Log;
import com.cvte.va.sdk.net.api.NetworkManager;
import com.vacenter.Taurus.Base;
import com.vacenter.Taurus.Controller;
import com.vacenter.Taurus.ControllerObserver;
import com.vacenter.Taurus.Device;
import com.vacenter.Taurus.Engine;
import java.util.Arrays;
import java.util.List;
import u.g;

/* JADX INFO: loaded from: classes2.dex */
public class b implements Engine.EngineObserver, ControllerObserver {
    public static b a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public static Engine f959b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public static Controller f960c;

    public static b d() {
        g.a("TaurusControlEngine", "getInstance");
        if (a == null) {
            a = new b();
        }
        return a;
    }

    public int a(List<Device> list) {
        Device[] devices = f959b.getDevices();
        if (devices == null || devices.length == 0) {
            if (g.a > 5) {
                return -1;
            }
            Log.w("VASDK:TaurusControlEngine", "No devices found!");
            return -1;
        }
        list.clear();
        list.addAll(Arrays.asList(devices));
        for (Device device : list) {
            g.a("TaurusControlEngine", String.format("devices name:%s address:%s", device.info.name, device.address));
        }
        for (Device device2 : list) {
            g.a("TaurusControlEngine", String.format("devicesVector name:%s address:%s", device2.info.name, device2.address));
        }
        return 0;
    }

    public boolean b() {
        if (NetworkManager.getInstance().getNetworkObserver() != null) {
            return true;
        }
        g.c("TaurusControlEngine", "NetworkObserver has not been initialized.");
        return false;
    }

    public Controller c() {
        Controller controller;
        Controller controller2 = f960c;
        if (controller2 != null) {
            return controller2;
        }
        do {
            controller = f959b.getController();
            f960c = controller;
        } while (controller == null);
        return controller;
    }

    @Override // com.vacenter.Taurus.ControllerObserver
    public String onCustomerString(String str, String str2) {
        return !b() ? "" : NetworkManager.getInstance().getNetworkObserver().onCustomerString(str, str2);
    }

    /* JADX WARN: Removed duplicated region for block: B:33:0x00f1  */
    /* JADX WARN: Removed duplicated region for block: B:36:0x0123  */
    /* JADX WARN: Removed duplicated region for block: B:47:0x0133 A[SYNTHETIC] */
    @Override // com.vacenter.Taurus.Engine.EngineObserver
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public void onDeviceAdd(com.vacenter.Taurus.Device r11) {
        /*
            Method dump skipped, instruction units count: 330
            To view this dump add '--comments-level debug' option
        */
        throw new UnsupportedOperationException("Method not decompiled: c0.b.onDeviceAdd(com.vacenter.Taurus.Device):void");
    }

    /* JADX WARN: Removed duplicated region for block: B:51:0x01cd  */
    /* JADX WARN: Removed duplicated region for block: B:54:0x01df  */
    /* JADX WARN: Removed duplicated region for block: B:74:0x0219 A[SYNTHETIC] */
    @Override // com.vacenter.Taurus.Engine.EngineObserver
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public void onDeviceRemove(com.vacenter.Taurus.Device r15) {
        /*
            Method dump skipped, instruction units count: 558
            To view this dump add '--comments-level debug' option
        */
        throw new UnsupportedOperationException("Method not decompiled: c0.b.onDeviceRemove(com.vacenter.Taurus.Device):void");
    }

    @Override // com.vacenter.Taurus.ControllerObserver
    public String onGetDeviceFile(String str, String str2, String str3) {
        StringBuilder sbF = g.a.a.a.a.F("[");
        sbF.append(Thread.currentThread().getStackTrace()[2].getMethodName());
        sbF.append("]address:");
        sbF.append(str);
        sbF.append(", key:");
        sbF.append(str2);
        sbF.append(", value:");
        sbF.append(str3);
        g.a("TaurusControlEngine", sbF.toString());
        return !b() ? "" : NetworkManager.getInstance().getNetworkObserver().onGetDeviceFile(str, str2, str3);
    }

    @Override // com.vacenter.Taurus.ControllerObserver
    public Base.RtspServerUrlInfo[] onGetRtspServerUrl(String str) {
        return new Base.RtspServerUrlInfo[0];
    }

    @Override // com.vacenter.Taurus.ControllerObserver
    public int onNoticeChannelJoin(String str, int i2) {
        g.a("TaurusControlEngine", "onNoticeChannelJoin: " + str + " type: " + i2);
        if (b()) {
            return NetworkManager.getInstance().getNetworkObserver().onNoticeChannelJoin(str, i2);
        }
        return -1;
    }

    @Override // com.vacenter.Taurus.ControllerObserver
    public int onNoticeChannelLeave(String str, int i2) {
        g.a("TaurusControlEngine", "onNoticeChannelLeave: " + str + " type: " + i2);
        if (b()) {
            return NetworkManager.getInstance().getNetworkObserver().onNoticeChannelLeave(str, i2);
        }
        return -1;
    }

    @Override // com.vacenter.Taurus.ControllerObserver
    public int onRealTimeLog(String str, String str2) {
        if (str.isEmpty()) {
            g.c("TaurusControlEngine", "address is null");
            return 0;
        }
        for (Device device : Arrays.asList(f959b.getDevices())) {
            if (device.address.startsWith(str)) {
                String str3 = device.info.name;
                return 0;
            }
        }
        return 0;
    }

    @Override // com.vacenter.Taurus.ControllerObserver
    public String onReceiveDeviceFile(String str, String str2, String str3, String str4, int i2) {
        StringBuilder sbL = g.a.a.a.a.L("onReceiveDeviceFile: address", str, " key: ", str2, " value:");
        sbL.append(str3);
        sbL.append(" file_name:");
        sbL.append(str4);
        sbL.append(" file_length:");
        sbL.append(i2);
        g.a("TaurusControlEngine", sbL.toString());
        return !b() ? "" : NetworkManager.getInstance().getNetworkObserver().onReceiveDeviceFile(str, str2, str3, str4, i2);
    }

    @Override // com.vacenter.Taurus.ControllerObserver
    public int onReceiveDeviceFileStatus(String str, int i2) {
        g.d("TaurusControlEngine", "onReceiveDeviceFileStatus: " + str + " status: " + i2);
        if (b()) {
            return NetworkManager.getInstance().getNetworkObserver().onReceiveDeviceFileStatus(str, i2);
        }
        return -1;
    }

    @Override // com.vacenter.Taurus.ControllerObserver
    public int onReceiveDeviceUpgradeProgress(String str, int i2) {
        g.d("TaurusControlEngine", "onReceiveDeviceUpgradeProgress: address:" + str + " progress: " + i2);
        if (e.g().i(str)) {
            if (b0.b.a == null) {
                b0.b.a = new b0.b();
            }
            b0.b.a.i(i2);
        }
        if (a.g().h(str)) {
            if (p.a.a == null) {
                p.a.a = new p.a();
            }
            p.a.a.c(i2);
        }
        if (!d.e().f(str)) {
            return 0;
        }
        if (i.a.a == null) {
            i.a.a = new i.a();
        }
        i.a.a.c(i2);
        return 0;
    }

    @Override // com.vacenter.Taurus.ControllerObserver
    public int onReceiveRtspClientStatus(String str, int i2) {
        return 0;
    }

    @Override // com.vacenter.Taurus.ControllerObserver
    public int onReceiveRtspServerStatus(String str, int i2) {
        return 0;
    }

    @Override // com.vacenter.Taurus.ControllerObserver
    public int onSetKey(String str, int i2) {
        g.d("TaurusControlEngine", "onSetKey: " + str + " key: " + i2);
        return 0;
    }

    @Override // com.vacenter.Taurus.ControllerObserver
    public int onSetRing(String str, boolean z2) {
        g.d("TaurusControlEngine", "onSetRing: " + str + " ring: " + z2);
        return 0;
    }

    @Override // com.vacenter.Taurus.ControllerObserver
    public int onSetRtspClientStart(String str, String str2) {
        return 0;
    }

    @Override // com.vacenter.Taurus.ControllerObserver
    public int onSetRtspClientStop(String str) {
        return 0;
    }

    @Override // com.vacenter.Taurus.ControllerObserver
    public int onSetRtspServerStart(String str) {
        return 0;
    }

    @Override // com.vacenter.Taurus.ControllerObserver
    public int onSetRtspServerStop(String str) {
        return 0;
    }
}
