package g.i.a.c.t;

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 final class g extends e {
    public g(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:26:0x00df  */
    /* JADX WARN: Removed duplicated region for block: B:34:0x0119 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 r7) {
        /*
            Method dump skipped, instruction units count: 301
            To view this dump add '--comments-level debug' option
        */
        throw new UnsupportedOperationException("Method not decompiled: g.i.a.c.t.g.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 iH0 = h0(this.O, r().M);
            if (iH0 != 0) {
                i.D0(String.format("Something error in OTA process, errorCode: 0x%04X, mProcessState=0x%04X", Integer.valueOf(iH0), Integer.valueOf(this.E)));
                k0(iH0, true);
                return false;
            }
        }
        if (z2) {
            try {
                q0();
                z(Bzip2Constants.HUFFMAN_MAX_ALPHABET_SIZE, true);
            } catch (g.i.a.c.a e2) {
                e2.printStackTrace();
                k0(e2.f5446m, false);
            }
        } else {
            w0();
            k0(274, false);
        }
        return true;
    }

    @Override // g.i.a.c.m.a.a
    public void o() {
        int iV;
        int i2;
        try {
            setName("ProcessorXG0014S");
            i.w0("ProcessorXG0014S running.");
            iV = v();
        } catch (Exception e2) {
            e2.printStackTrace();
            i.W3(e2.toString());
            k0(0, false);
        }
        if (iV != 0) {
            k0(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 iH0 = h0(str, r().M);
        if (iH0 != 0) {
            if (iH0 == 4128) {
                throw new g.i.a.c.g.c("aborted, connectRemoteDevice failed", iH0);
            }
            F(a0());
            if (this.f5600r) {
                throw new g.i.a.c.g.c("user aborted", InvokeCmd.CMD_EXTENDDISPLAY_CTRL_GET_DISPLAY_EDID_INFO);
            }
            int iH02 = h0(str, r().M);
            if (iH02 != 0) {
                if (iH02 == 4128) {
                    throw new g.i.a.c.g.c("aborted, connectRemoteDevice failed", iH02);
                }
                throw new g.i.a.c.g.c("connectRemoteDevice failed", iH02);
            }
        }
        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(20, 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;
        }
        k0(4097, false);
        return false;
    }

    /* JADX WARN: Can't wrap try/catch for region: R(8:16|(1:18)(9:19|(2:21|(8:23|24|(3:26|(2:31|(1:33)(1:35))(1:29)|30)(0)|40|59|41|66|65)(6:37|40|59|41|66|65))(1:38)|36|39|40|59|41|66|65)|34|40|59|41|66|65) */
    /* JADX WARN: Code restructure failed: missing block: B:43:0x00e1, code lost:
    
        r0 = move-exception;
     */
    /* JADX WARN: Code restructure failed: missing block: B:44:0x00e2, code lost:
    
        r0.printStackTrace();
     */
    /* JADX WARN: Removed duplicated region for block: B:31:0x009a A[Catch: a -> 0x00e7, TryCatch #0 {a -> 0x00e7, blocks: (B:6:0x000d, B:9:0x0014, B:12:0x001b, B:14:0x0030, B:16:0x0047, B:18:0x0056, B:34:0x00bd, B:19:0x006b, B:21:0x0074, B:23:0x0078, B:26:0x007e, B:29:0x0086, B:30:0x0096, B:31:0x009a, B:33:0x00ac, B:35:0x00c1, B:36:0x00c5, B:39:0x00d7, B:37:0x00c8, B:38:0x00d2), top: B:57:0x000d }] */
    /*
        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: 268
            To view this dump add '--comments-level debug' option
        */
        throw new UnsupportedOperationException("Method not decompiled: g.i.a.c.t.g.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.t.g.z0():boolean");
    }
}
