package ᨨ;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.Socket;
import java.util.logging.Logger;
import ඓ.K.K.K.C1293;

/* renamed from: ᨨ.㗗  reason: contains not printable characters */
/* compiled from: Okio */
public final class C1486 {

    /* renamed from: K  reason: contains not printable characters */
    public static final Logger f5520 = Logger.getLogger(C1486.class.getName());

    /* renamed from: ᨨ.㗗$K  reason: contains not printable characters */
    /* compiled from: Okio */
    public class C1487 implements AbstractC1494 {

        /* renamed from: ʬ  reason: contains not printable characters */
        public final /* synthetic */ InputStream f5521;

        /* renamed from: ῲ  reason: contains not printable characters */
        public final /* synthetic */ C1477 f5522;

        public C1487(C1477 r1, InputStream inputStream) {
            this.f5522 = r1;
            this.f5521 = inputStream;
        }

        @Override // ᨨ.AbstractC1494, java.io.Closeable, java.lang.AutoCloseable
        public void close() throws IOException {
            this.f5521.close();
        }

        @Override // ᨨ.AbstractC1494
        public long read(C1492 r4, long j) throws IOException {
            int i = (j > 0 ? 1 : (j == 0 ? 0 : -1));
            if (i < 0) {
                throw new IllegalArgumentException(C1293.m3409("byteCount < 0: ", j));
            } else if (i == 0) {
                return 0;
            } else {
                try {
                    this.f5522.m3701();
                    C1475 r0 = r4.m3786(1);
                    int read = this.f5521.read(r0.f5498, r0.f5494, (int) Math.min(j, (long) (8192 - r0.f5494)));
                    if (read == -1) {
                        return -1;
                    }
                    r0.f5494 += read;
                    long j2 = (long) read;
                    r4.f5529 += j2;
                    return j2;
                } catch (AssertionError e) {
                    if (C1486.m3742(e)) {
                        throw new IOException(e);
                    }
                    throw e;
                }
            }
        }

        @Override // ᨨ.AbstractC1494
        public C1477 timeout() {
            return this.f5522;
        }

        public String toString() {
            StringBuilder r0 = C1293.m3416("source(");
            r0.append(this.f5521);
            r0.append(")");
            return r0.toString();
        }
    }

    /* renamed from: ῲ  reason: contains not printable characters */
    public static AbstractC1494 m3735(Socket socket) throws IOException {
        if (socket == null) {
            throw new IllegalArgumentException("socket == null");
        } else if (socket.getInputStream() != null) {
            C1474 r0 = new C1474(socket);
            return new C1482(r0, m3740(socket.getInputStream(), r0));
        } else {
            throw new IOException("socket's input stream == null");
        }
    }

    /* renamed from: K  reason: contains not printable characters */
    public static AbstractC1496 m3741(AbstractC1494 r1) {
        return new C1488(r1);
    }

    /* renamed from: K  reason: contains not printable characters */
    public static AbstractC1483 m3737(AbstractC1473 r1) {
        return new C1479(r1);
    }

    /* renamed from: K  reason: contains not printable characters */
    public static AbstractC1473 m3736(Socket socket) throws IOException {
        if (socket == null) {
            throw new IllegalArgumentException("socket == null");
        } else if (socket.getOutputStream() != null) {
            C1474 r0 = new C1474(socket);
            OutputStream outputStream = socket.getOutputStream();
            if (outputStream != null) {
                return new C1484(r0, new C1472(r0, outputStream));
            }
            throw new IllegalArgumentException("out == null");
        } else {
            throw new IOException("socket's output stream == null");
        }
    }

    /* renamed from: K  reason: contains not printable characters */
    public static AbstractC1494 m3739(InputStream inputStream) {
        return m3740(inputStream, new C1477());
    }

    /* renamed from: K  reason: contains not printable characters */
    public static AbstractC1494 m3740(InputStream inputStream, C1477 r2) {
        if (inputStream == null) {
            throw new IllegalArgumentException("in == null");
        } else if (r2 != null) {
            return new C1487(r2, inputStream);
        } else {
            throw new IllegalArgumentException("timeout == null");
        }
    }

    /* renamed from: K  reason: contains not printable characters */
    public static AbstractC1494 m3738(File file) throws FileNotFoundException {
        if (file != null) {
            return m3739(new FileInputStream(file));
        }
        throw new IllegalArgumentException("file == null");
    }

    /* renamed from: K  reason: contains not printable characters */
    public static boolean m3742(AssertionError assertionError) {
        return (assertionError.getCause() == null || assertionError.getMessage() == null || !assertionError.getMessage().contains("getsockname failed")) ? false : true;
    }
}
