package t;

import java.util.Arrays;
import u.e;
import u.g;

/* JADX INFO: loaded from: classes2.dex */
public class c {

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public boolean f9512f = false;

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    public b f9513g = new b();
    public byte[] a = new byte[512];

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public byte[] f9509c = new byte[512];

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public byte[] f9508b = new byte[512];

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public byte[] f9510d = new byte[64];

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public byte[] f9511e = new byte[64];

    public synchronized boolean a(int i2) {
        if (i2 < 0) {
            return false;
        }
        boolean z2 = a.f9503g;
        int iB = a.f9505i == 64 ? this.f9513g.b(this.f9510d, 64, i2) : this.f9513g.b(this.a, 512, i2);
        if (512 != iB) {
            if (64 == iB) {
                byte[] bArr = this.f9510d;
                if (bArr != null && bArr.length == 64) {
                    if ((bArr[0] & 255) == 36) {
                        e.h().i(this.f9510d);
                    } else {
                        e.h().f(this.f9510d);
                    }
                }
                g.a("MicArrayCommApi", "usbReadReport: mByte64HidReadBuffer is illegality.");
                return false;
            }
            return false;
        }
        byte[] bArr2 = this.a;
        if (bArr2 != null && bArr2.length == 512) {
            int i3 = bArr2[4] & 255;
            g.a("MicArrayCommApi", "usbReadReport: requestId=" + i3);
            if (i3 == 1) {
                byte[] bArr3 = this.a;
                System.arraycopy(bArr3, 0, this.f9508b, 0, bArr3.length);
            } else if (i3 == 130 || i3 == 160) {
                e.h().g(this.a);
            }
            return true;
        }
        return false;
    }

    public boolean b() {
        Arrays.fill(this.f9509c, (byte) 0);
        byte[] bArr = this.f9509c;
        bArr[0] = 1;
        bArr[1] = 0;
        bArr[2] = 0;
        bArr[3] = 0;
        kotlin.reflect.w.internal.y0.n.c2.c.c(bArr, 4, 1);
        kotlin.reflect.w.internal.y0.n.c2.c.c(this.f9509c, 8, 0);
        return c();
    }

    public boolean c() {
        if (!this.f9512f) {
            g.c("MicArrayCommApi", "dsp device not find.");
            a.f9503g = false;
            u.c.a().q(0);
            return false;
        }
        if (a.f9505i != 64) {
            int iA = this.f9513g.a(this.f9509c, 512);
            if (iA == 512) {
                return true;
            }
            g.c("MicArrayCommApi", "Byte512 SendReports error.");
            if (iA == -1) {
                this.f9512f = false;
            }
            return false;
        }
        int iA2 = this.f9513g.a(this.f9511e, 64);
        g.a.a.a.a.e0("[usbSendReport]send byte64 ret = ", iA2, "MicArrayCommApi");
        if (iA2 == 64) {
            return true;
        }
        g.c("MicArrayCommApi", "Byte64 SendReports error.");
        if (iA2 == -1) {
            this.f9512f = false;
        }
        return false;
    }
}
