package g.i.a.c.b0;

import android.content.Context;
import android.hardware.usb.UsbManager;
import android.text.TextUtils;
import com.cvte.vman.instance.InvokeCmd;
import g.h.a.i;
import g.i.a.c.l.c;
import g.i.a.c.q.f;
import g.i.a.c.q.g;
import java.util.List;

/* JADX INFO: loaded from: classes.dex */
public abstract class a extends g.i.a.c.m.a.a {
    public UsbManager h0;

    public a(Context context, f fVar, g.i.a.c.m.a.b bVar) {
        super(context, fVar, bVar);
        u();
    }

    public void E() {
        synchronized (this.e0) {
            if (this.f5593d0) {
                i.w0("Remote busy now, just wait!");
                try {
                    this.e0.wait(60000L);
                } catch (InterruptedException e2) {
                    e2.printStackTrace();
                }
                i.V3(this.f5594f, "Remote idle now, just go!");
            }
        }
    }

    public void F() {
        int i2 = s().f5713o;
        int i3 = s().f5716r;
        if (i3 < 0 || i3 >= i2) {
            i.w0("invalid FileIndex: " + i3 + ", reset to 0");
            i3 = 0;
        }
        s().f5714p = i3;
        g.i.a.c.l.e.a aVar = this.F.get(i3);
        this.G = aVar;
        if (aVar != null) {
            g gVarS = s();
            g.i.a.c.l.e.a aVar2 = this.G;
            gVarS.n(aVar2.f5575z, aVar2.f5570u, aVar2.f5572w, aVar2.h(), r().f5707x);
        } else {
            i.W3("mCurBinInputStream == null");
        }
        int i4 = i3 + 1;
        if (i4 < i2) {
            this.H = this.F.get(i4);
            this.I = i4;
        } else {
            this.H = null;
            this.I = -1;
        }
    }

    public void G() {
        k(this.G);
        c.b bVar = new c.b();
        bVar.f5536e = r().f5698o;
        bVar.f5533b = r().f5700q;
        bVar.f5534c = this.Q;
        bVar.f5535d = r().c();
        bVar.a = this.f5595m;
        bVar.f5541j = this.R;
        bVar.f5542k = t();
        bVar.f5545n = r().n();
        bVar.f5546o = r().o();
        boolean zP = r().p();
        int i2 = r().f5705v;
        bVar.f5543l = zP;
        bVar.f5544m = i2;
        List<g.i.a.c.l.e.a> listO = g.i.a.c.l.b.o(bVar.a());
        this.F = listO;
        if (listO == null || listO.size() <= 0) {
            i.W3("pendingImageInputStreams == null || pendingImageInputStreams.size() <= 0");
            throw new g.i.a.c.g.c("load image file error", 4097);
        }
        if (s().f5716r == 0) {
            int[] iArr = new int[this.F.size()];
        }
        s().f5713o = this.F.size();
        i.U3(s().toString());
        F();
    }

    @Override // g.i.a.c.m.a.a
    public void u() {
        super.u();
        this.W = new g.i.a.c.q.i(this.f5596n, 2);
        if (this.h0 == null) {
            UsbManager usbManager = (UsbManager) this.f5595m.getSystemService("usb");
            this.h0 = usbManager;
            if (usbManager == null) {
                i.W3("Unable to initialize mUsbManager.");
            }
        }
    }

    @Override // g.i.a.c.m.a.a
    public int v() {
        int iV = super.v();
        if (iV != 0) {
            return iV;
        }
        if (!TextUtils.isEmpty(this.P)) {
            return 0;
        }
        if (!this.f5594f) {
            i.W3("invalid address: ");
            return InvokeCmd.CMD_EXTENDDISPLAY_CTRL_GET_HDMI_IN_OUT;
        }
        StringBuilder sbF = g.a.a.a.a.F("invalid address: ");
        sbF.append(this.P);
        i.W3(sbF.toString());
        return InvokeCmd.CMD_EXTENDDISPLAY_CTRL_GET_HDMI_IN_OUT;
    }
}
