.class public Lcom/bumptech/glide/load/data/j;
.super Ljava/lang/Object;
.source ""

# interfaces
.implements Lcom/bumptech/glide/load/data/d;


# annotations
.annotation system Ldalvik/annotation/MemberClasses;
    value = {
        Lcom/bumptech/glide/load/data/j$a;,
        Lcom/bumptech/glide/load/data/j$b;
    }
.end annotation

.annotation system Ldalvik/annotation/Signature;
    value = {
        "Ljava/lang/Object;",
        "Lcom/bumptech/glide/load/data/d<",
        "Ljava/io/InputStream;",
        ">;"
    }
.end annotation


# static fields
.field public static final w:Lcom/bumptech/glide/load/data/j$b;


# instance fields
.field public final r:Lq3/f;

.field public final s:I

.field public t:Ljava/net/HttpURLConnection;

.field public u:Ljava/io/InputStream;

.field public volatile v:Z


# direct methods
.method public static constructor <clinit>()V
    .registers 1

    new-instance v0, Lcom/bumptech/glide/load/data/j$a;

    invoke-direct {v0}, Lcom/bumptech/glide/load/data/j$a;-><init>()V

    sput-object v0, Lcom/bumptech/glide/load/data/j;->w:Lcom/bumptech/glide/load/data/j$b;

    return-void
.end method

.method public constructor <init>(Lq3/f;I)V
    .registers 3

    .line 1
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    iput-object p1, p0, Lcom/bumptech/glide/load/data/j;->r:Lq3/f;

    iput p2, p0, Lcom/bumptech/glide/load/data/j;->s:I

    return-void
.end method

.method public static c(Ljava/net/HttpURLConnection;)I
    .registers 3

    :try_start_0
    invoke-virtual {p0}, Ljava/net/HttpURLConnection;->getResponseCode()I

    move-result p0
    :try_end_4
    .catch Ljava/io/IOException; {:try_start_0 .. :try_end_4} :catch_5

    return p0

    :catch_5
    move-exception p0

    const/4 v0, 0x3

    const-string v1, "HttpUrlFetcher"

    invoke-static {v1, v0}, Landroid/util/Log;->isLoggable(Ljava/lang/String;I)Z

    move-result v0

    if-eqz v0, :cond_14

    const-string v0, "Failed to get a response code"

    invoke-static {v1, v0, p0}, Landroid/util/Log;->d(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)I

    :cond_14
    const/4 p0, -0x1

    return p0
.end method


# virtual methods
.method public a()Ljava/lang/Class;
    .registers 2
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "()",
            "Ljava/lang/Class<",
            "Ljava/io/InputStream;",
            ">;"
        }
    .end annotation

    const-class v0, Ljava/io/InputStream;

    return-object v0
.end method

.method public b()V
    .registers 2

    iget-object v0, p0, Lcom/bumptech/glide/load/data/j;->u:Ljava/io/InputStream;

    if-eqz v0, :cond_7

    :try_start_4
    invoke-virtual {v0}, Ljava/io/InputStream;->close()V
    :try_end_7
    .catch Ljava/io/IOException; {:try_start_4 .. :try_end_7} :catch_7

    :catch_7
    :cond_7
    iget-object v0, p0, Lcom/bumptech/glide/load/data/j;->t:Ljava/net/HttpURLConnection;

    if-eqz v0, :cond_e

    invoke-virtual {v0}, Ljava/net/HttpURLConnection;->disconnect()V

    :cond_e
    const/4 v0, 0x0

    iput-object v0, p0, Lcom/bumptech/glide/load/data/j;->t:Ljava/net/HttpURLConnection;

    return-void
.end method

.method public cancel()V
    .registers 2

    const/4 v0, 0x1

    iput-boolean v0, p0, Lcom/bumptech/glide/load/data/j;->v:Z

    return-void
.end method

.method public final d(Ljava/net/URL;ILjava/net/URL;Ljava/util/Map;)Ljava/io/InputStream;
    .registers 12
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "(",
            "Ljava/net/URL;",
            "I",
            "Ljava/net/URL;",
            "Ljava/util/Map<",
            "Ljava/lang/String;",
            "Ljava/lang/String;",
            ">;)",
            "Ljava/io/InputStream;"
        }
    .end annotation

    const/4 v0, -0x1

    const/4 v1, 0x0

    const/4 v2, 0x5

    if-ge p2, v2, :cond_13c

    if-eqz p3, :cond_1e

    :try_start_7
    invoke-virtual {p1}, Ljava/net/URL;->toURI()Ljava/net/URI;

    move-result-object v2

    invoke-virtual {p3}, Ljava/net/URL;->toURI()Ljava/net/URI;

    move-result-object p3

    invoke-virtual {v2, p3}, Ljava/net/URI;->equals(Ljava/lang/Object;)Z

    move-result p3

    if-nez p3, :cond_16

    goto :goto_1e

    :cond_16
    new-instance p3, Lk3/b;

    const-string v2, "In re-direct loop"

    .line 1
    invoke-direct {p3, v2, v0, v1}, Lk3/b;-><init>(Ljava/lang/String;ILjava/lang/Throwable;)V

    .line 2
    throw p3
    :try_end_1e
    .catch Ljava/net/URISyntaxException; {:try_start_7 .. :try_end_1e} :catch_1e

    :catch_1e
    :cond_1e
    :goto_1e
    const/4 p3, 0x0

    .line 3
    :try_start_1f
    invoke-virtual {p1}, Ljava/net/URL;->openConnection()Ljava/net/URLConnection;

    move-result-object v2

    check-cast v2, Ljava/net/HttpURLConnection;
    :try_end_25
    .catch Ljava/io/IOException; {:try_start_1f .. :try_end_25} :catch_133

    .line 4
    invoke-interface {p4}, Ljava/util/Map;->entrySet()Ljava/util/Set;

    move-result-object v3

    invoke-interface {v3}, Ljava/util/Set;->iterator()Ljava/util/Iterator;

    move-result-object v3

    :goto_2d
    invoke-interface {v3}, Ljava/util/Iterator;->hasNext()Z

    move-result v4

    if-eqz v4, :cond_49

    invoke-interface {v3}, Ljava/util/Iterator;->next()Ljava/lang/Object;

    move-result-object v4

    check-cast v4, Ljava/util/Map$Entry;

    invoke-interface {v4}, Ljava/util/Map$Entry;->getKey()Ljava/lang/Object;

    move-result-object v5

    check-cast v5, Ljava/lang/String;

    invoke-interface {v4}, Ljava/util/Map$Entry;->getValue()Ljava/lang/Object;

    move-result-object v4

    check-cast v4, Ljava/lang/String;

    invoke-virtual {v2, v5, v4}, Ljava/net/HttpURLConnection;->addRequestProperty(Ljava/lang/String;Ljava/lang/String;)V

    goto :goto_2d

    :cond_49
    iget v3, p0, Lcom/bumptech/glide/load/data/j;->s:I

    invoke-virtual {v2, v3}, Ljava/net/HttpURLConnection;->setConnectTimeout(I)V

    iget v3, p0, Lcom/bumptech/glide/load/data/j;->s:I

    invoke-virtual {v2, v3}, Ljava/net/HttpURLConnection;->setReadTimeout(I)V

    invoke-virtual {v2, p3}, Ljava/net/HttpURLConnection;->setUseCaches(Z)V

    const/4 v3, 0x1

    invoke-virtual {v2, v3}, Ljava/net/HttpURLConnection;->setDoInput(Z)V

    invoke-virtual {v2, p3}, Ljava/net/HttpURLConnection;->setInstanceFollowRedirects(Z)V

    .line 5
    iput-object v2, p0, Lcom/bumptech/glide/load/data/j;->t:Ljava/net/HttpURLConnection;

    :try_start_5f
    invoke-virtual {v2}, Ljava/net/HttpURLConnection;->connect()V

    iget-object v2, p0, Lcom/bumptech/glide/load/data/j;->t:Ljava/net/HttpURLConnection;

    invoke-virtual {v2}, Ljava/net/HttpURLConnection;->getInputStream()Ljava/io/InputStream;

    move-result-object v2

    iput-object v2, p0, Lcom/bumptech/glide/load/data/j;->u:Ljava/io/InputStream;
    :try_end_6a
    .catch Ljava/io/IOException; {:try_start_5f .. :try_end_6a} :catch_124

    iget-boolean v2, p0, Lcom/bumptech/glide/load/data/j;->v:Z

    if-eqz v2, :cond_6f

    return-object v1

    :cond_6f
    iget-object v2, p0, Lcom/bumptech/glide/load/data/j;->t:Ljava/net/HttpURLConnection;

    invoke-static {v2}, Lcom/bumptech/glide/load/data/j;->c(Ljava/net/HttpURLConnection;)I

    move-result v2

    .line 6
    div-int/lit8 v4, v2, 0x64

    const/4 v5, 0x2

    if-ne v4, v5, :cond_7c

    move v5, v3

    goto :goto_7d

    :cond_7c
    move v5, p3

    :goto_7d
    const/4 v6, 0x3

    if-eqz v5, :cond_cf

    .line 7
    iget-object p1, p0, Lcom/bumptech/glide/load/data/j;->t:Ljava/net/HttpURLConnection;

    const-string p2, "HttpUrlFetcher"

    .line 8
    :try_start_84
    invoke-virtual {p1}, Ljava/net/HttpURLConnection;->getContentEncoding()Ljava/lang/String;

    move-result-object p3

    invoke-static {p3}, Landroid/text/TextUtils;->isEmpty(Ljava/lang/CharSequence;)Z

    move-result p3

    if-eqz p3, :cond_9d

    invoke-virtual {p1}, Ljava/net/HttpURLConnection;->getContentLength()I

    move-result p2

    invoke-virtual {p1}, Ljava/net/HttpURLConnection;->getInputStream()Ljava/io/InputStream;

    move-result-object p3

    int-to-long v0, p2

    .line 9
    new-instance p2, Lg4/c;

    invoke-direct {p2, p3, v0, v1}, Lg4/c;-><init>(Ljava/io/InputStream;J)V

    goto :goto_bf

    .line 10
    :cond_9d
    invoke-static {p2, v6}, Landroid/util/Log;->isLoggable(Ljava/lang/String;I)Z

    move-result p3

    if-eqz p3, :cond_bb

    new-instance p3, Ljava/lang/StringBuilder;

    invoke-direct {p3}, Ljava/lang/StringBuilder;-><init>()V

    const-string p4, "Got non empty content encoding: "

    invoke-virtual {p3, p4}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    invoke-virtual {p1}, Ljava/net/HttpURLConnection;->getContentEncoding()Ljava/lang/String;

    move-result-object p4

    invoke-virtual {p3, p4}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    invoke-virtual {p3}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object p3

    invoke-static {p2, p3}, Landroid/util/Log;->d(Ljava/lang/String;Ljava/lang/String;)I

    :cond_bb
    invoke-virtual {p1}, Ljava/net/HttpURLConnection;->getInputStream()Ljava/io/InputStream;

    move-result-object p2

    :goto_bf
    iput-object p2, p0, Lcom/bumptech/glide/load/data/j;->u:Ljava/io/InputStream;
    :try_end_c1
    .catch Ljava/io/IOException; {:try_start_84 .. :try_end_c1} :catch_c2

    return-object p2

    :catch_c2
    move-exception p2

    new-instance p3, Lk3/b;

    invoke-static {p1}, Lcom/bumptech/glide/load/data/j;->c(Ljava/net/HttpURLConnection;)I

    move-result p1

    const-string p4, "Failed to obtain InputStream"

    invoke-direct {p3, p4, p1, p2}, Lk3/b;-><init>(Ljava/lang/String;ILjava/lang/Throwable;)V

    throw p3

    :cond_cf
    if-ne v4, v6, :cond_d2

    move p3, v3

    :cond_d2
    if-eqz p3, :cond_105

    .line 11
    iget-object p3, p0, Lcom/bumptech/glide/load/data/j;->t:Ljava/net/HttpURLConnection;

    const-string v0, "Location"

    invoke-virtual {p3, v0}, Ljava/net/HttpURLConnection;->getHeaderField(Ljava/lang/String;)Ljava/lang/String;

    move-result-object p3

    invoke-static {p3}, Landroid/text/TextUtils;->isEmpty(Ljava/lang/CharSequence;)Z

    move-result v0

    if-nez v0, :cond_fd

    :try_start_e2
    new-instance v0, Ljava/net/URL;

    invoke-direct {v0, p1, p3}, Ljava/net/URL;-><init>(Ljava/net/URL;Ljava/lang/String;)V
    :try_end_e7
    .catch Ljava/net/MalformedURLException; {:try_start_e2 .. :try_end_e7} :catch_f0

    invoke-virtual {p0}, Lcom/bumptech/glide/load/data/j;->b()V

    add-int/2addr p2, v3

    invoke-virtual {p0, v0, p2, p1, p4}, Lcom/bumptech/glide/load/data/j;->d(Ljava/net/URL;ILjava/net/URL;Ljava/util/Map;)Ljava/io/InputStream;

    move-result-object p1

    return-object p1

    :catch_f0
    move-exception p1

    new-instance p2, Lk3/b;

    const-string p4, "Bad redirect url: "

    invoke-static {p4, p3}, Le/a;->a(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;

    move-result-object p3

    invoke-direct {p2, p3, v2, p1}, Lk3/b;-><init>(Ljava/lang/String;ILjava/lang/Throwable;)V

    throw p2

    :cond_fd
    new-instance p1, Lk3/b;

    const-string p2, "Received empty or null redirect url"

    .line 12
    invoke-direct {p1, p2, v2, v1}, Lk3/b;-><init>(Ljava/lang/String;ILjava/lang/Throwable;)V

    .line 13
    throw p1

    :cond_105
    if-ne v2, v0, :cond_10f

    new-instance p1, Lk3/b;

    const-string p2, "Http request failed"

    .line 14
    invoke-direct {p1, p2, v2, v1}, Lk3/b;-><init>(Ljava/lang/String;ILjava/lang/Throwable;)V

    .line 15
    throw p1

    :cond_10f
    :try_start_10f
    new-instance p1, Lk3/b;

    iget-object p2, p0, Lcom/bumptech/glide/load/data/j;->t:Ljava/net/HttpURLConnection;

    invoke-virtual {p2}, Ljava/net/HttpURLConnection;->getResponseMessage()Ljava/lang/String;

    move-result-object p2

    .line 16
    invoke-direct {p1, p2, v2, v1}, Lk3/b;-><init>(Ljava/lang/String;ILjava/lang/Throwable;)V

    .line 17
    throw p1
    :try_end_11b
    .catch Ljava/io/IOException; {:try_start_10f .. :try_end_11b} :catch_11b

    :catch_11b
    move-exception p1

    new-instance p2, Lk3/b;

    const-string p3, "Failed to get a response message"

    invoke-direct {p2, p3, v2, p1}, Lk3/b;-><init>(Ljava/lang/String;ILjava/lang/Throwable;)V

    throw p2

    :catch_124
    move-exception p1

    new-instance p2, Lk3/b;

    iget-object p3, p0, Lcom/bumptech/glide/load/data/j;->t:Ljava/net/HttpURLConnection;

    invoke-static {p3}, Lcom/bumptech/glide/load/data/j;->c(Ljava/net/HttpURLConnection;)I

    move-result p3

    const-string p4, "Failed to connect or obtain data"

    invoke-direct {p2, p4, p3, p1}, Lk3/b;-><init>(Ljava/lang/String;ILjava/lang/Throwable;)V

    throw p2

    :catch_133
    move-exception p1

    .line 18
    new-instance p2, Lk3/b;

    const-string p4, "URL.openConnection threw"

    invoke-direct {p2, p4, p3, p1}, Lk3/b;-><init>(Ljava/lang/String;ILjava/lang/Throwable;)V

    throw p2

    .line 19
    :cond_13c
    new-instance p1, Lk3/b;

    const-string p2, "Too many (> 5) redirects!"

    .line 20
    invoke-direct {p1, p2, v0, v1}, Lk3/b;-><init>(Ljava/lang/String;ILjava/lang/Throwable;)V

    .line 21
    throw p1
.end method

.method public e()Lcom/bumptech/glide/load/a;
    .registers 2

    sget-object v0, Lcom/bumptech/glide/load/a;->s:Lcom/bumptech/glide/load/a;

    return-object v0
.end method

.method public f(Lcom/bumptech/glide/f;Lcom/bumptech/glide/load/data/d$a;)V
    .registers 11
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "(",
            "Lcom/bumptech/glide/f;",
            "Lcom/bumptech/glide/load/data/d$a<",
            "-",
            "Ljava/io/InputStream;",
            ">;)V"
        }
    .end annotation

    const-string p1, "Finished http url fetcher fetch in "

    const-string v0, "HttpUrlFetcher"

    sget v1, Lg4/f;->b:I

    .line 1
    invoke-static {}, Landroid/os/SystemClock;->elapsedRealtimeNanos()J

    move-result-wide v1

    const/4 v3, 0x2

    .line 2
    :try_start_b
    iget-object v4, p0, Lcom/bumptech/glide/load/data/j;->r:Lq3/f;

    invoke-virtual {v4}, Lq3/f;->d()Ljava/net/URL;

    move-result-object v4

    const/4 v5, 0x0

    const/4 v6, 0x0

    iget-object v7, p0, Lcom/bumptech/glide/load/data/j;->r:Lq3/f;

    .line 3
    iget-object v7, v7, Lq3/f;->b:Lq3/g;

    invoke-interface {v7}, Lq3/g;->a()Ljava/util/Map;

    move-result-object v7

    .line 4
    invoke-virtual {p0, v4, v5, v6, v7}, Lcom/bumptech/glide/load/data/j;->d(Ljava/net/URL;ILjava/net/URL;Ljava/util/Map;)Ljava/io/InputStream;

    move-result-object v4

    invoke-interface {p2, v4}, Lcom/bumptech/glide/load/data/d$a;->d(Ljava/lang/Object;)V
    :try_end_22
    .catch Ljava/io/IOException; {:try_start_b .. :try_end_22} :catch_30
    .catchall {:try_start_b .. :try_end_22} :catchall_2e

    invoke-static {v0, v3}, Landroid/util/Log;->isLoggable(Ljava/lang/String;I)Z

    move-result p2

    if-eqz p2, :cond_5c

    new-instance p2, Ljava/lang/StringBuilder;

    invoke-direct {p2}, Ljava/lang/StringBuilder;-><init>()V

    goto :goto_4b

    :catchall_2e
    move-exception p2

    goto :goto_5d

    :catch_30
    move-exception v4

    const/4 v5, 0x3

    :try_start_32
    invoke-static {v0, v5}, Landroid/util/Log;->isLoggable(Ljava/lang/String;I)Z

    move-result v5

    if-eqz v5, :cond_3d

    const-string v5, "Failed to load data for url"

    invoke-static {v0, v5, v4}, Landroid/util/Log;->d(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)I

    :cond_3d
    invoke-interface {p2, v4}, Lcom/bumptech/glide/load/data/d$a;->c(Ljava/lang/Exception;)V
    :try_end_40
    .catchall {:try_start_32 .. :try_end_40} :catchall_2e

    invoke-static {v0, v3}, Landroid/util/Log;->isLoggable(Ljava/lang/String;I)Z

    move-result p2

    if-eqz p2, :cond_5c

    new-instance p2, Ljava/lang/StringBuilder;

    invoke-direct {p2}, Ljava/lang/StringBuilder;-><init>()V

    :goto_4b
    invoke-virtual {p2, p1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    invoke-static {v1, v2}, Lg4/f;->a(J)D

    move-result-wide v1

    invoke-virtual {p2, v1, v2}, Ljava/lang/StringBuilder;->append(D)Ljava/lang/StringBuilder;

    invoke-virtual {p2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object p1

    invoke-static {v0, p1}, Landroid/util/Log;->v(Ljava/lang/String;Ljava/lang/String;)I

    :cond_5c
    return-void

    :goto_5d
    invoke-static {v0, v3}, Landroid/util/Log;->isLoggable(Ljava/lang/String;I)Z

    move-result v3

    if-eqz v3, :cond_75

    invoke-static {p1}, Landroidx/activity/c;->a(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object p1

    invoke-static {v1, v2}, Lg4/f;->a(J)D

    move-result-wide v1

    invoke-virtual {p1, v1, v2}, Ljava/lang/StringBuilder;->append(D)Ljava/lang/StringBuilder;

    invoke-virtual {p1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object p1

    invoke-static {v0, p1}, Landroid/util/Log;->v(Ljava/lang/String;Ljava/lang/String;)I

    :cond_75
    throw p2
.end method
