package defpackage;

import com.hierynomus.mssmb2.SMBApiException;
import com.hierynomus.protocol.transport.TransportException;
import java.io.InputStream;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;

/* JADX INFO: renamed from: ˀᵧᴵ, reason: contains not printable characters */
/* JADX INFO: loaded from: classes3.dex */
public final class C0602 extends InputStream {

    /* JADX INFO: renamed from: ᵸˆˁ, reason: contains not printable characters */
    public static final InterfaceC5025 f2917 = AbstractC2626.m6386(C0602.class);

    /* JADX INFO: renamed from: ˈᵲᵢ, reason: contains not printable characters */
    public C4479 f2918;

    /* JADX INFO: renamed from: ˌᴵ, reason: contains not printable characters */
    public final long f2919;

    /* JADX INFO: renamed from: ˌᵨʠᵫ, reason: contains not printable characters */
    public final int f2920;

    /* JADX INFO: renamed from: ᵜᵪʾ, reason: contains not printable characters */
    public C0609 f2922;

    /* JADX INFO: renamed from: ᵯᵷʽ, reason: contains not printable characters */
    public byte[] f2924;

    /* JADX INFO: renamed from: ᵶˇᵱ, reason: contains not printable characters */
    public boolean f2925;

    /* JADX INFO: renamed from: ᵔᵖᵹᵫ, reason: contains not printable characters */
    public long f2921 = 0;

    /* JADX INFO: renamed from: ᵨᵼⁱ, reason: contains not printable characters */
    public int f2923 = 0;

    public C0602(C0609 c0609, int i, long j) {
        this.f2922 = c0609;
        this.f2920 = i;
        this.f2919 = j;
    }

    @Override // java.io.InputStream
    public final int available() {
        return 0;
    }

    @Override // java.io.InputStream, java.io.Closeable, java.lang.AutoCloseable
    public final void close() {
        this.f2925 = true;
        this.f2922 = null;
        this.f2924 = null;
    }

    @Override // java.io.InputStream
    public final int read() throws TransportException {
        byte[] bArr = this.f2924;
        if (bArr == null || this.f2923 >= bArr.length) {
            m2228();
        }
        if (this.f2925) {
            return -1;
        }
        byte[] bArr2 = this.f2924;
        int i = this.f2923;
        this.f2923 = i + 1;
        return bArr2[i] & 255;
    }

    @Override // java.io.InputStream
    public final int read(byte[] bArr) {
        return read(bArr, 0, bArr.length);
    }

    @Override // java.io.InputStream
    public final int read(byte[] bArr, int i, int i2) throws TransportException {
        byte[] bArr2 = this.f2924;
        if (bArr2 == null || this.f2923 >= bArr2.length) {
            m2228();
        }
        if (this.f2925) {
            return -1;
        }
        byte[] bArr3 = this.f2924;
        int length = bArr3.length;
        int i3 = this.f2923;
        if (length - i3 <= i2) {
            i2 = bArr3.length - i3;
        }
        System.arraycopy(bArr3, i3, bArr, i, i2);
        this.f2923 += i2;
        return i2;
    }

    @Override // java.io.InputStream
    public final long skip(long j) {
        byte[] bArr = this.f2924;
        if (bArr == null) {
            this.f2921 += j;
            return j;
        }
        long j2 = ((long) this.f2923) + j;
        if (j2 < bArr.length) {
            this.f2923 = (int) j2;
            return j;
        }
        this.f2921 = (j2 - ((long) bArr.length)) + this.f2921;
        this.f2924 = null;
        this.f2918 = null;
        return j;
    }

    /* JADX INFO: renamed from: ːˏᵟᵯ, reason: contains not printable characters */
    public final C4479 m2227() {
        C0609 c0609 = this.f2922;
        long j = this.f2921;
        C4675 c4675 = c0609.f6250;
        C3714 c3714 = c0609.f6249;
        return c4675.m3748(new C3888(c4675.f5281, c3714, c4675.f5279, c4675.f5277, j, Math.min(this.f2920, c4675.f5282)));
    }

    /* JADX WARN: Removed duplicated region for block: B:31:0x007f  */
    /* JADX WARN: Removed duplicated region for block: B:32:0x0082  */
    /* JADX INFO: renamed from: ᵲᵶᵳˈ, reason: contains not printable characters */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final void m2228() throws TransportException {
        if (this.f2925) {
            return;
        }
        if (this.f2918 == null) {
            this.f2918 = m2227();
        }
        try {
            C0652 c0652 = (C0652) this.f2918.f17089.get(this.f2919, TimeUnit.MILLISECONDS);
            C2964 c2964 = (C2964) ((InterfaceC2684) ((ᵜᵪʾ) c0652).ˌᴵ);
            long j = c2964.f11408;
            if (j == 0) {
                this.f2924 = c0652.f3088;
                this.f2923 = 0;
                this.f2921 += (long) c0652.f3089;
            }
            if (j == 3221225489L || c0652.f3089 == 0) {
                f2917.mo9486(Long.valueOf(this.f2921), "EOF, {} bytes read");
                this.f2925 = true;
            } else if (j == 0) {
                this.f2918 = m2227();
            } else {
                throw new SMBApiException(c2964, "Read failed for " + this);
            }
        } catch (InterruptedException e) {
            Thread.currentThread().interrupt();
            throw new TransportException(e);
        } catch (ExecutionException e2) {
            e = e2;
            if (!(e instanceof TransportException)) {
                throw ((TransportException) e);
            }
            throw new TransportException(e);
        } catch (TimeoutException e3) {
            e = e3;
            if (!(e instanceof TransportException)) {
            }
        }
    }
}
