package g.i.a.c.w;

import android.content.Context;
import com.cvte.vman.instance.InvokeCmd;
import g.h.a.i;
import io.netty.handler.codec.compression.Bzip2Constants;
import java.util.ArrayList;

/* JADX INFO: loaded from: classes.dex */
public class e extends c {
    public e(Context context, g.i.a.c.q.f fVar, g.i.a.c.m.a.b bVar) {
        super(context, fVar, bVar);
    }

    public void A0(g.i.a.b.e.h.e eVar) throws g.i.a.c.g.c {
        if (this.f5600r) {
            throw new g.i.a.c.g.c("user aborted", InvokeCmd.CMD_EXTENDDISPLAY_CTRL_GET_DISPLAY_EDID_INFO);
        }
        z(527, true);
        this.M = 0;
        this.k0 = false;
        H(eVar);
        try {
            synchronized (this.j0) {
                if (this.M == 0 && !this.k0) {
                    this.j0.wait(31000L);
                }
            }
        } catch (InterruptedException e2) {
            StringBuilder sbF = g.a.a.a.a.F("findRemoteDevice interrupted, e = ");
            sbF.append(e2.toString());
            i.D0(sbF.toString());
            this.M = 259;
        }
        if (this.M == 0 && !this.k0) {
            i.W3("didn't find the secondary bud device");
            this.M = 265;
        }
        if (this.M != 0) {
            throw new g.i.a.c.g.c("Error while scan remote device", this.M);
        }
    }

    /* JADX WARN: Removed duplicated region for block: B:40:0x00f7  */
    /* JADX WARN: Removed duplicated region for block: B:50:0x0157  */
    /* JADX WARN: Removed duplicated region for block: B:58:0x0191 A[ORIG_RETURN, RETURN] */
    @Override // g.i.a.c.p.b
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public void N(g.i.a.b.e.h.b r8) {
        /*
            Method dump skipped, instruction units count: 421
            To view this dump add '--comments-level debug' option
        */
        throw new UnsupportedOperationException("Method not decompiled: g.i.a.c.w.e.N(g.i.a.b.e.h.b):void");
    }

    @Override // g.i.a.c.m.a.a
    public boolean f(boolean z2) {
        if (!super.f(z2)) {
            return false;
        }
        if (this.f5605w != 515) {
            boolean z3 = this.f5594f;
            StringBuilder sbF = g.a.a.a.a.F("start to re-connect the RCU which going to active image, current state is: ");
            sbF.append(this.f5605w);
            i.x0(z3, sbF.toString());
            int iG0 = g0(this.O, r().M);
            if (iG0 != 0) {
                i.D0(String.format("Something error in OTA process, errorCode: 0x%04X, mProcessState=0x%04X", Integer.valueOf(iG0), Integer.valueOf(this.E)));
                j0(iG0, true);
                return false;
            }
        }
        if (z2) {
            try {
                q0();
                z(Bzip2Constants.HUFFMAN_MAX_ALPHABET_SIZE, true);
            } catch (g.i.a.c.a e2) {
                e2.printStackTrace();
                j0(e2.f5446m, false);
            }
        } else {
            w0();
            j0(274, false);
        }
        return true;
    }

    @Override // g.i.a.c.m.a.a
    public void o() {
        int iV;
        int i2;
        try {
            setName("ProcessorXG0010S");
            i.w0("ProcessorXG0010S running.");
            iV = v();
        } catch (Exception e2) {
            e2.printStackTrace();
            i.D0(e2.toString());
            j0(0, false);
        }
        if (iV != 0) {
            j0(iV, false);
            return;
        }
        z(InvokeCmd.CMD_XBUG_GET_VMAN_SERVICE_LOG_LEVEL, true);
        this.O = this.P;
        this.f5602t = true;
        if (y0()) {
            if (t().f5686v) {
                q0();
                z(522, true);
                i.w0("wait master to handover ...");
                ArrayList arrayList = new ArrayList();
                int i3 = r().Q;
                byte[] bArr = t().A;
                if (bArr != null && i3 < 0) {
                    throw new IllegalArgumentException("invalid manufacture id");
                }
                arrayList.add(new g.i.a.b.e.h.g.a(null, null, null, null, null, null, null, null, null, i3, bArr, null, 0, null));
                g.i.a.b.e.h.e eVarA0 = a0();
                eVarA0.A = arrayList;
                A0(eVarA0);
                i.w0("start to upload secondary bud ...");
                this.f5602t = true;
                this.f5601s = false;
                this.J = 0;
                if (y0()) {
                    if (this.T) {
                        q0();
                        i2 = Bzip2Constants.HUFFMAN_MAX_ALPHABET_SIZE;
                    } else {
                        i2 = 523;
                    }
                }
            } else if (this.T) {
                q0();
                i2 = Bzip2Constants.HUFFMAN_MAX_ALPHABET_SIZE;
            } else {
                i2 = 523;
            }
            z(i2, true);
        }
        k(this.G);
        i.x0(this.f5594f, "ProcessorXG0010S stopped");
        A();
        if (this.E == 525) {
            z(259, true);
        }
    }

    public final boolean x0() throws g.i.a.c.g.b, g.i.a.c.g.c {
        String str = this.O;
        if (this.f5600r) {
            throw new g.i.a.c.g.c("user aborted", InvokeCmd.CMD_EXTENDDISPLAY_CTRL_GET_DISPLAY_EDID_INFO);
        }
        z(InvokeCmd.CMD_XBUG_VMAN_FUNTION_CHECK_TIMEOUT_BASE_SET, true);
        int iG0 = g0(str, r().M);
        if (iG0 != 0) {
            if (iG0 == 4128) {
                throw new g.i.a.c.g.c("aborted, connectRemoteDevice failed", iG0);
            }
            F(a0());
            if (this.f5600r) {
                throw new g.i.a.c.g.c("user aborted", InvokeCmd.CMD_EXTENDDISPLAY_CTRL_GET_DISPLAY_EDID_INFO);
            }
            int iG02 = g0(str, r().M);
            if (iG02 != 0) {
                if (iG02 == 4128) {
                    throw new g.i.a.c.g.c("aborted, connectRemoteDevice failed", iG02);
                }
                throw new g.i.a.c.g.c("connectRemoteDevice failed", iG02);
            }
        }
        f0();
        if (this.f5601s) {
            J();
        } else {
            this.f5601s = false;
            z(InvokeCmd.CMD_XBUG_VMAN_FUNTION_CHECK_TIMEOUT_BASE_GET, true);
            try {
                Thread.sleep(1500L);
            } catch (InterruptedException e2) {
                e2.printStackTrace();
            }
            this.W = new g.i.a.c.q.i(16, 2);
            s0();
            if (t().f5686v && t().f5688x != 0) {
                throw new g.i.a.c.g.c("rws state not ready", 282);
            }
            t0();
            r0();
            u0();
            if (this.f5594f) {
                i.w0(t().toString());
            }
            K();
            this.f5601s = true;
            i.w0("Ota Environment prepared.");
        }
        if (this.G != null) {
            return true;
        }
        j0(4097, false);
        return false;
    }

    /* JADX WARN: Can't wrap try/catch for region: R(8:16|(1:18)(9:19|(2:21|(2:23|(1:25)(1:27))(6:29|32|51|33|58|57))(1:30)|28|31|32|51|33|58|57)|26|32|51|33|58|57) */
    /* JADX WARN: Code restructure failed: missing block: B:35:0x00c3, code lost:
    
        r0 = move-exception;
     */
    /* JADX WARN: Code restructure failed: missing block: B:36:0x00c4, code lost:
    
        r0.printStackTrace();
     */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public final boolean y0() {
        /*
            Method dump skipped, instruction units count: 238
            To view this dump add '--comments-level debug' option
        */
        throw new UnsupportedOperationException("Method not decompiled: g.i.a.c.w.e.y0():boolean");
    }

    /* JADX WARN: Removed duplicated region for block: B:35:0x0102  */
    /* JADX WARN: Removed duplicated region for block: B:38:0x0121  */
    /* JADX WARN: Removed duplicated region for block: B:41:0x0130  */
    /* JADX WARN: Removed duplicated region for block: B:42:0x0136  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public final boolean z0() throws g.i.a.c.g.c {
        /*
            Method dump skipped, instruction units count: 377
            To view this dump add '--comments-level debug' option
        */
        throw new UnsupportedOperationException("Method not decompiled: g.i.a.c.w.e.z0():boolean");
    }
}
