漫漫擼2 v1.3.9版本的 MD5 值为:e07b15db49ff38b958ff7c8268ff1c9b

以下内容为反编译后的 h.java 源代码,内容仅作参考


package g.e.a;

import android.text.TextUtils;
import android.webkit.MimeTypeMap;
import androidx.recyclerview.widget.RecyclerView;
import com.openmediation.sdk.utils.event.AdvanceEventId;
import com.openmediation.sdk.utils.request.network.Headers;
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InterruptedIOException;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Objects;
public class h implements o {
    public static final a.d.b f5192a = a.d.c.c("HttpUrlSource");
    public final g.e.a.s.c f5193b;
    public p f5194c;
    public HttpURLConnection f5195d;
    public InputStream f5196e;

    public h(String str, g.e.a.s.c cVar) {
        Objects.requireNonNull(cVar);
        this.f5193b = cVar;
        p pVar = cVar.get(str);
        if (pVar == null) {
            a.d.b bVar = n.f5216a;
            MimeTypeMap singleton = MimeTypeMap.getSingleton();
            String fileExtensionFromUrl = MimeTypeMap.getFileExtensionFromUrl(str);
            pVar = new p(str, -2147483648L, TextUtils.isEmpty(fileExtensionFromUrl) ? null : singleton.getMimeTypeFromExtension(fileExtensionFromUrl));
        }
        this.f5194c = pVar;
    }

    @Override
    public int a(byte[] bArr) throws m {
        InputStream inputStream = this.f5196e;
        if (inputStream != null) {
            try {
                return inputStream.read(bArr, 0, bArr.length);
            } catch (InterruptedIOException e2) {
                throw new j(g.b.a.a.a.z(g.b.a.a.a.D("Reading source "), this.f5194c.f5217a, " is interrupted"), e2);
            } catch (IOException e3) {
                StringBuilder D = g.b.a.a.a.D("Error reading data from ");
                D.append(this.f5194c.f5217a);
                throw new m(D.toString(), e3);
            }
        }
        throw new m(g.b.a.a.a.z(g.b.a.a.a.D("Error reading data from "), this.f5194c.f5217a, ": connection is absent!"));
    }

    @Override
    public void b(long j2) throws m {
        try {
            HttpURLConnection d2 = d(j2, -1);
            this.f5195d = d2;
            String contentType = d2.getContentType();
            this.f5196e = new BufferedInputStream(this.f5195d.getInputStream(), RecyclerView.a0.FLAG_BOUNCED_FROM_HIDDEN_LIST);
            HttpURLConnection httpURLConnection = this.f5195d;
            int responseCode = httpURLConnection.getResponseCode();
            String headerField = httpURLConnection.getHeaderField("Content-Length");
            long parseLong = headerField == null ? -1L : Long.parseLong(headerField);
            if (responseCode != 200) {
                parseLong = responseCode == 206 ? parseLong + j2 : this.f5194c.f5218b;
            }
            String str = this.f5194c.f5217a;
            p pVar = new p(str, parseLong, contentType);
            this.f5194c = pVar;
            this.f5193b.a(str, pVar);
        } catch (IOException e2) {
            StringBuilder D = g.b.a.a.a.D("Error opening connection for ");
            D.append(this.f5194c.f5217a);
            D.append(" with offset ");
            D.append(j2);
            throw new m(D.toString(), e2);
        }
    }

    public final void c() throws m {
        HttpURLConnection httpURLConnection;
        a.d.b bVar = f5192a;
        StringBuilder D = g.b.a.a.a.D("Read content info from ");
        D.append(this.f5194c.f5217a);
        bVar.a(D.toString());
        ?? r1 = 0;
        InputStream inputStream = null;
        try {
            try {
                httpURLConnection = d(0L, AdvanceEventId.CODE_LOAD_WHILE_INIT_PENDING);
                try {
                    String headerField = httpURLConnection.getHeaderField("Content-Length");
                    long parseLong = headerField == null ? -1L : Long.parseLong(headerField);
                    String contentType = httpURLConnection.getContentType();
                    inputStream = httpURLConnection.getInputStream();
                    String str = this.f5194c.f5217a;
                    p pVar = new p(str, parseLong, contentType);
                    this.f5194c = pVar;
                    this.f5193b.a(str, pVar);
                    bVar.a("Source info fetched: " + this.f5194c);
                    n.a(inputStream);
                } catch (IOException e2) {
                    e = e2;
                    f5192a.e("Error fetching info from " + this.f5194c.f5217a, e);
                    n.a(inputStream);
                    if (httpURLConnection == null) {
                        return;
                    }
                    httpURLConnection.disconnect();
                }
            } catch (Throwable th) {
                th = th;
                n.a(null);
                if (r1 != 0) {
                    r1.disconnect();
                }
                throw th;
            }
        } catch (IOException e3) {
            e = e3;
            httpURLConnection = null;
        } catch (Throwable th2) {
            th = th2;
            r1 = 0;
            n.a(null);
            if (r1 != 0) {
            }
            throw th;
        }
        httpURLConnection.disconnect();
    }

    @Override
    public void close() throws m {
        HttpURLConnection httpURLConnection = this.f5195d;
        if (httpURLConnection != null) {
            try {
                httpURLConnection.disconnect();
            } catch (ArrayIndexOutOfBoundsException e2) {
                f5192a.e("Error closing connection correctly. Should happen only on Android L. If anybody know how to fix it, please visit https://github.com/danikula/AndroidVideoCache/issues/88. Until good solution is not know, just ignore this issue :(", e2);
            } catch (IllegalArgumentException e3) {
                e = e3;
                throw new RuntimeException("Wait... but why? WTF!? Really shouldn't happen any more after fixing https://github.com/danikula/AndroidVideoCache/issues/43. If you read it on your device log, please, notify me danikula@gmail.com or create issue here https://github.com/danikula/AndroidVideoCache/issues.", e);
            } catch (NullPointerException e4) {
                e = e4;
                throw new RuntimeException("Wait... but why? WTF!? Really shouldn't happen any more after fixing https://github.com/danikula/AndroidVideoCache/issues/43. If you read it on your device log, please, notify me danikula@gmail.com or create issue here https://github.com/danikula/AndroidVideoCache/issues.", e);
            }
        }
    }

    public final HttpURLConnection d(long j2, int i2) throws IOException, m {
        HttpURLConnection httpURLConnection;
        boolean z;
        String str = this.f5194c.f5217a;
        int i3 = 0;
        do {
            a.d.b bVar = f5192a;
            StringBuilder D = g.b.a.a.a.D("Open connection ");
            int i4 = (j2 > 0L ? 1 : (j2 == 0L ? 0 : -1));
            D.append(i4 > 0 ? g.b.a.a.a.n(" with offset ", j2) : "");
            D.append(" to ");
            D.append(str);
            bVar.a(D.toString());
            httpURLConnection = (HttpURLConnection) new URL(str).openConnection();
            if (i4 > 0) {
                httpURLConnection.setRequestProperty(Headers.KEY_RANGE, g.b.a.a.a.o("bytes=", j2, "-"));
            }
            if (i2 > 0) {
                httpURLConnection.setConnectTimeout(i2);
                httpURLConnection.setReadTimeout(i2);
            }
            int responseCode = httpURLConnection.getResponseCode();
            z = responseCode == 301 || responseCode == 302 || responseCode == 303;
            if (z) {
                str = httpURLConnection.getHeaderField("Location");
                i3++;
                httpURLConnection.disconnect();
            }
            if (i3 > 5) {
                throw new m(g.b.a.a.a.j("Too many redirects: ", i3));
            }
        } while (z);
        return httpURLConnection;
    }

    @Override
    public synchronized long length() throws m {
        if (this.f5194c.f5218b == -2147483648L) {
            c();
        }
        return this.f5194c.f5218b;
    }

    public String toString() {
        StringBuilder D = g.b.a.a.a.D("HttpUrlSource{sourceInfo='");
        D.append(this.f5194c);
        D.append("}");
        return D.toString();
    }

    public h(h hVar) {
        this.f5194c = hVar.f5194c;
        this.f5193b = hVar.f5193b;
    }
}