.class public final Lz5/pt0;
.super Ljava/lang/Object;
.source ""

# interfaces
.implements Lz5/a51;


# annotations
.annotation system Ldalvik/annotation/Signature;
    value = {
        "Ljava/lang/Object;",
        "Lz5/a51<",
        "Lz5/nt0;",
        "Lz5/ot0;",
        ">;"
    }
.end annotation


# instance fields
.field public final r:Landroid/content/Context;

.field public final s:Ljava/lang/String;


# direct methods
.method public constructor <init>(Landroid/content/Context;Ljava/lang/String;Lz5/hb;)V
    .registers 4

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

    iput-object p1, p0, Lz5/pt0;->r:Landroid/content/Context;

    iput-object p2, p0, Lz5/pt0;->s:Ljava/lang/String;

    return-void
.end method


# virtual methods
.method public final zza(Ljava/lang/Object;)Ljava/lang/Object;
    .registers 21

    move-object/from16 v1, p0

    const-string v0, "Received error HTTP response code: "

    move-object/from16 v2, p1

    check-cast v2, Lz5/nt0;

    iget-object v3, v2, Lz5/nt0;->a:Ljava/lang/String;

    iget v11, v2, Lz5/nt0;->b:I

    iget-object v12, v2, Lz5/nt0;->c:Ljava/util/Map;

    iget-object v2, v2, Lz5/nt0;->d:Ljava/lang/String;

    invoke-static {}, Lcom/google/android/gms/ads/internal/zzt;->zzj()Lu5/c;

    move-result-object v4

    invoke-interface {v4}, Lu5/c;->c()J

    move-result-wide v13

    :try_start_18
    new-instance v15, Lz5/ot0;

    invoke-direct {v15}, Lz5/ot0;-><init>()V

    const-string v4, "SDK version: "

    iget-object v5, v1, Lz5/pt0;->s:Ljava/lang/String;

    invoke-static {v5}, Ljava/lang/String;->valueOf(Ljava/lang/Object;)Ljava/lang/String;

    move-result-object v5

    invoke-virtual {v5}, Ljava/lang/String;->length()I

    move-result v6

    if-eqz v6, :cond_30

    invoke-virtual {v4, v5}, Ljava/lang/String;->concat(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v4

    goto :goto_36

    :cond_30
    new-instance v5, Ljava/lang/String;

    invoke-direct {v5, v4}, Ljava/lang/String;-><init>(Ljava/lang/String;)V

    move-object v4, v5

    :goto_36
    invoke-static {v4}, Lz5/d50;->zzh(Ljava/lang/String;)V

    const-string v4, "AdRequestServiceImpl: Sending request: "

    invoke-static {v3}, Ljava/lang/String;->valueOf(Ljava/lang/Object;)Ljava/lang/String;

    move-result-object v5

    invoke-virtual {v5}, Ljava/lang/String;->length()I

    move-result v6

    if-eqz v6, :cond_4a

    invoke-virtual {v4, v5}, Ljava/lang/String;->concat(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v4

    goto :goto_50

    :cond_4a
    new-instance v5, Ljava/lang/String;

    invoke-direct {v5, v4}, Ljava/lang/String;-><init>(Ljava/lang/String;)V

    move-object v4, v5

    :goto_50
    invoke-static {v4}, Lz5/d50;->zzd(Ljava/lang/String;)V

    new-instance v4, Ljava/net/URL;

    invoke-direct {v4, v3}, Ljava/net/URL;-><init>(Ljava/lang/String;)V

    new-instance v3, Ljava/util/HashMap;

    invoke-direct {v3}, Ljava/util/HashMap;-><init>()V

    const/4 v10, 0x0

    move/from16 v16, v10

    :goto_60
    invoke-virtual {v4}, Ljava/net/URL;->openConnection()Ljava/net/URLConnection;

    move-result-object v4

    move-object v9, v4

    check-cast v9, Ljava/net/HttpURLConnection;
    :try_end_67
    .catch Ljava/io/IOException; {:try_start_18 .. :try_end_67} :catch_255

    :try_start_67
    invoke-static {}, Lcom/google/android/gms/ads/internal/zzt;->zzc()Lcom/google/android/gms/ads/internal/util/zzs;

    move-result-object v4

    iget-object v5, v1, Lz5/pt0;->r:Landroid/content/Context;

    iget-object v6, v1, Lz5/pt0;->s:Ljava/lang/String;
    :try_end_6f
    .catch Lz5/sr0; {:try_start_67 .. :try_end_6f} :catch_22c
    .catchall {:try_start_67 .. :try_end_6f} :catchall_229

    const/4 v7, 0x0

    const/16 v17, 0x0

    move-object v8, v9

    move-object/from16 v18, v9

    move/from16 v9, v17

    move v1, v10

    move v10, v11

    :try_start_79
    invoke-virtual/range {v4 .. v10}, Lcom/google/android/gms/ads/internal/util/zzs;->zzf(Landroid/content/Context;Ljava/lang/String;ZLjava/net/HttpURLConnection;ZI)V

    invoke-interface {v12}, Ljava/util/Map;->entrySet()Ljava/util/Set;

    move-result-object v4

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

    move-result-object v4

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

    move-result v5

    if-eqz v5, :cond_a4

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

    move-result-object v5

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

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

    move-result-object v6

    check-cast v6, Ljava/lang/String;

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

    move-result-object v5

    check-cast v5, Ljava/lang/String;
    :try_end_9c
    .catch Lz5/sr0; {:try_start_79 .. :try_end_9c} :catch_225
    .catchall {:try_start_79 .. :try_end_9c} :catchall_221

    move-object/from16 v7, v18

    :try_start_9e
    invoke-virtual {v7, v6, v5}, Ljava/net/HttpURLConnection;->addRequestProperty(Ljava/lang/String;Ljava/lang/String;)V

    move-object/from16 v18, v7

    goto :goto_84

    :cond_a4
    move-object/from16 v7, v18

    invoke-virtual {v2}, Ljava/lang/String;->length()I

    move-result v4

    const/4 v5, 0x0

    const/4 v6, 0x1

    if-lez v4, :cond_d5

    sget-object v4, Lz5/m91;->b:Ljava/nio/charset/Charset;

    invoke-virtual {v2, v4}, Ljava/lang/String;->getBytes(Ljava/nio/charset/Charset;)[B

    move-result-object v4

    invoke-virtual {v7, v6}, Ljava/net/HttpURLConnection;->setDoOutput(Z)V

    array-length v8, v4

    invoke-virtual {v7, v8}, Ljava/net/HttpURLConnection;->setFixedLengthStreamingMode(I)V
    :try_end_bb
    .catch Lz5/sr0; {:try_start_9e .. :try_end_bb} :catch_21f
    .catchall {:try_start_9e .. :try_end_bb} :catchall_250

    :try_start_bb
    new-instance v8, Ljava/io/BufferedOutputStream;

    invoke-virtual {v7}, Ljava/net/HttpURLConnection;->getOutputStream()Ljava/io/OutputStream;

    move-result-object v9

    invoke-direct {v8, v9}, Ljava/io/BufferedOutputStream;-><init>(Ljava/io/OutputStream;)V
    :try_end_c4
    .catchall {:try_start_bb .. :try_end_c4} :catchall_ce

    :try_start_c4
    invoke-virtual {v8, v4}, Ljava/io/BufferedOutputStream;->write([B)V
    :try_end_c7
    .catchall {:try_start_c4 .. :try_end_c7} :catchall_cb

    .line 1
    :try_start_c7
    invoke-interface {v8}, Ljava/io/Closeable;->close()V
    :try_end_ca
    .catch Ljava/io/IOException; {:try_start_c7 .. :try_end_ca} :catch_d5
    .catch Lz5/sr0; {:try_start_c7 .. :try_end_ca} :catch_21f
    .catchall {:try_start_c7 .. :try_end_ca} :catchall_250

    goto :goto_d5

    :catchall_cb
    move-exception v0

    move-object v5, v8

    goto :goto_cf

    :catchall_ce
    move-exception v0

    :goto_cf
    if-eqz v5, :cond_d4

    :try_start_d1
    invoke-interface {v5}, Ljava/io/Closeable;->close()V
    :try_end_d4
    .catch Ljava/io/IOException; {:try_start_d1 .. :try_end_d4} :catch_d4
    .catch Lz5/sr0; {:try_start_d1 .. :try_end_d4} :catch_21f
    .catchall {:try_start_d1 .. :try_end_d4} :catchall_250

    .line 2
    :catch_d4
    :cond_d4
    :try_start_d4
    throw v0

    :catch_d5
    :cond_d5
    :goto_d5
    new-instance v4, Lz5/c50;

    invoke-direct {v4, v5}, Lz5/c50;-><init>(Ljava/lang/String;)V

    sget-object v8, Lz5/m91;->b:Ljava/nio/charset/Charset;

    invoke-virtual {v2, v8}, Ljava/lang/String;->getBytes(Ljava/nio/charset/Charset;)[B

    move-result-object v8

    invoke-virtual {v4, v7, v8}, Lz5/c50;->a(Ljava/net/HttpURLConnection;[B)V

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

    move-result v8

    invoke-virtual {v7}, Ljava/net/HttpURLConnection;->getHeaderFields()Ljava/util/Map;

    move-result-object v9

    invoke-interface {v9}, Ljava/util/Map;->entrySet()Ljava/util/Set;

    move-result-object v9

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

    move-result-object v9

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

    move-result v10

    if-eqz v10, :cond_129

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

    move-result-object v10

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

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

    move-result-object v17

    move-object/from16 v5, v17

    check-cast v5, Ljava/lang/String;

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

    move-result-object v10

    check-cast v10, Ljava/util/List;

    invoke-virtual {v3, v5}, Ljava/util/HashMap;->containsKey(Ljava/lang/Object;)Z

    move-result v17

    if-eqz v17, :cond_11e

    invoke-virtual {v3, v5}, Ljava/util/HashMap;->get(Ljava/lang/Object;)Ljava/lang/Object;

    move-result-object v5

    check-cast v5, Ljava/util/List;

    invoke-interface {v5, v10}, Ljava/util/List;->addAll(Ljava/util/Collection;)Z

    const/4 v5, 0x0

    goto :goto_f3

    :cond_11e
    new-instance v6, Ljava/util/ArrayList;

    invoke-direct {v6, v10}, Ljava/util/ArrayList;-><init>(Ljava/util/Collection;)V

    invoke-virtual {v3, v5, v6}, Ljava/util/HashMap;->put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;

    const/4 v5, 0x0

    const/4 v6, 0x1

    goto :goto_f3

    :cond_129
    invoke-virtual {v4, v7, v8}, Lz5/c50;->b(Ljava/net/HttpURLConnection;I)V

    iput v8, v15, Lz5/ot0;->a:I

    iput-object v3, v15, Lz5/ot0;->b:Ljava/util/Map;

    const-string v5, ""

    iput-object v5, v15, Lz5/ot0;->c:Ljava/lang/String;
    :try_end_134
    .catch Lz5/sr0; {:try_start_d4 .. :try_end_134} :catch_21f
    .catchall {:try_start_d4 .. :try_end_134} :catchall_250

    const/16 v5, 0xc8

    const/16 v6, 0x12c

    if-lt v8, v5, :cond_1a2

    if-ge v8, v6, :cond_1a2

    :try_start_13c
    new-instance v2, Ljava/io/InputStreamReader;

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

    move-result-object v0

    invoke-direct {v2, v0}, Ljava/io/InputStreamReader;-><init>(Ljava/io/InputStream;)V
    :try_end_145
    .catchall {:try_start_13c .. :try_end_145} :catchall_19a

    :try_start_145
    invoke-static {}, Lcom/google/android/gms/ads/internal/zzt;->zzc()Lcom/google/android/gms/ads/internal/util/zzs;

    new-instance v0, Ljava/lang/StringBuilder;

    const/16 v3, 0x2000

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

    const/16 v3, 0x800

    new-array v3, v3, [C

    :goto_153
    invoke-virtual {v2, v3}, Ljava/io/InputStreamReader;->read([C)I

    move-result v5

    const/4 v6, -0x1

    if-eq v5, v6, :cond_15e

    invoke-virtual {v0, v3, v1, v5}, Ljava/lang/StringBuilder;->append([CII)Ljava/lang/StringBuilder;

    goto :goto_153

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

    move-result-object v0
    :try_end_162
    .catchall {:try_start_145 .. :try_end_162} :catchall_197

    .line 3
    :try_start_162
    invoke-virtual {v2}, Ljava/io/InputStreamReader;->close()V
    :try_end_165
    .catch Ljava/io/IOException; {:try_start_162 .. :try_end_165} :catch_165
    .catch Lz5/sr0; {:try_start_162 .. :try_end_165} :catch_21f
    .catchall {:try_start_162 .. :try_end_165} :catchall_250

    .line 4
    :catch_165
    :try_start_165
    invoke-virtual {v4, v0}, Lz5/c50;->c(Ljava/lang/String;)V

    iput-object v0, v15, Lz5/ot0;->c:Ljava/lang/String;

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

    move-result v0

    if-eqz v0, :cond_18a

    sget-object v0, Lz5/so;->n3:Lz5/no;

    .line 5
    sget-object v1, Lz5/xk;->d:Lz5/xk;

    iget-object v1, v1, Lz5/xk;->c:Lcom/google/android/gms/internal/ads/g0;

    .line 6
    invoke-virtual {v1, v0}, Lcom/google/android/gms/internal/ads/g0;->a(Lz5/no;)Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Ljava/lang/Boolean;

    invoke-virtual {v0}, Ljava/lang/Boolean;->booleanValue()Z

    move-result v0

    if-eqz v0, :cond_183

    goto :goto_18a

    :cond_183
    new-instance v0, Lz5/sr0;

    const/4 v1, 0x3

    invoke-direct {v0, v1}, Lz5/sr0;-><init>(I)V

    throw v0

    :cond_18a
    :goto_18a
    invoke-static {}, Lcom/google/android/gms/ads/internal/zzt;->zzj()Lu5/c;

    move-result-object v0

    invoke-interface {v0}, Lu5/c;->c()J

    move-result-wide v0

    sub-long/2addr v0, v13

    iput-wide v0, v15, Lz5/ot0;->d:J
    :try_end_195
    .catch Lz5/sr0; {:try_start_165 .. :try_end_195} :catch_21f
    .catchall {:try_start_165 .. :try_end_195} :catchall_250

    goto/16 :goto_24b

    :catchall_197
    move-exception v0

    move-object v5, v2

    goto :goto_19c

    :catchall_19a
    move-exception v0

    const/4 v5, 0x0

    :goto_19c
    if-eqz v5, :cond_1a1

    .line 7
    :try_start_19e
    invoke-interface {v5}, Ljava/io/Closeable;->close()V
    :try_end_1a1
    .catch Ljava/io/IOException; {:try_start_19e .. :try_end_1a1} :catch_1a1
    .catch Lz5/sr0; {:try_start_19e .. :try_end_1a1} :catch_21f
    .catchall {:try_start_19e .. :try_end_1a1} :catchall_250

    .line 8
    :catch_1a1
    :cond_1a1
    :try_start_1a1
    throw v0

    :cond_1a2
    if-lt v8, v6, :cond_1f5

    const/16 v4, 0x190

    if-ge v8, v4, :cond_1f5

    const-string v4, "Location"

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

    move-result-object v4

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

    move-result v5

    if-nez v5, :cond_1e7

    new-instance v5, Ljava/net/URL;

    invoke-direct {v5, v4}, Ljava/net/URL;-><init>(Ljava/lang/String;)V

    const/4 v4, 0x1

    add-int/lit8 v6, v16, 0x1

    sget-object v4, Lz5/so;->a3:Lz5/no;

    .line 9
    sget-object v8, Lz5/xk;->d:Lz5/xk;

    iget-object v8, v8, Lz5/xk;->c:Lcom/google/android/gms/internal/ads/g0;

    .line 10
    invoke-virtual {v8, v4}, Lcom/google/android/gms/internal/ads/g0;->a(Lz5/no;)Ljava/lang/Object;

    move-result-object v4

    check-cast v4, Ljava/lang/Integer;

    invoke-virtual {v4}, Ljava/lang/Integer;->intValue()I

    move-result v4
    :try_end_1cc
    .catch Lz5/sr0; {:try_start_1a1 .. :try_end_1cc} :catch_21f
    .catchall {:try_start_1a1 .. :try_end_1cc} :catchall_250

    if-gt v6, v4, :cond_1d9

    :try_start_1ce
    invoke-virtual {v7}, Ljava/net/HttpURLConnection;->disconnect()V
    :try_end_1d1
    .catch Ljava/io/IOException; {:try_start_1ce .. :try_end_1d1} :catch_255

    move v10, v1

    move-object v4, v5

    move/from16 v16, v6

    move-object/from16 v1, p0

    goto/16 :goto_60

    :cond_1d9
    :try_start_1d9
    const-string v0, "Too many redirects."

    invoke-static {v0}, Lz5/d50;->zzi(Ljava/lang/String;)V

    new-instance v0, Lz5/sr0;

    const-string v1, "Too many redirects"

    const/4 v2, 0x1

    invoke-direct {v0, v2, v1}, Lz5/sr0;-><init>(ILjava/lang/String;)V

    throw v0

    :cond_1e7
    const-string v0, "No location header to follow redirect."

    invoke-static {v0}, Lz5/d50;->zzi(Ljava/lang/String;)V

    new-instance v0, Lz5/sr0;

    const-string v1, "No location header to follow redirect"

    const/4 v2, 0x1

    invoke-direct {v0, v2, v1}, Lz5/sr0;-><init>(ILjava/lang/String;)V

    throw v0

    :cond_1f5
    new-instance v1, Ljava/lang/StringBuilder;

    const/16 v2, 0x2e

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

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

    invoke-virtual {v1, v8}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;

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

    move-result-object v1

    invoke-static {v1}, Lz5/d50;->zzi(Ljava/lang/String;)V

    new-instance v1, Lz5/sr0;

    new-instance v3, Ljava/lang/StringBuilder;

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

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

    invoke-virtual {v3, v8}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;

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

    move-result-object v0

    const/4 v2, 0x1

    invoke-direct {v1, v2, v0}, Lz5/sr0;-><init>(ILjava/lang/String;)V

    throw v1
    :try_end_21f
    .catch Lz5/sr0; {:try_start_1d9 .. :try_end_21f} :catch_21f
    .catchall {:try_start_1d9 .. :try_end_21f} :catchall_250

    :catch_21f
    move-exception v0

    goto :goto_22e

    :catchall_221
    move-exception v0

    move-object/from16 v7, v18

    goto :goto_251

    :catch_225
    move-exception v0

    move-object/from16 v7, v18

    goto :goto_22e

    :catchall_229
    move-exception v0

    move-object v7, v9

    goto :goto_251

    :catch_22c
    move-exception v0

    move-object v7, v9

    :goto_22e
    :try_start_22e
    sget-object v1, Lz5/so;->s5:Lz5/no;

    .line 11
    sget-object v2, Lz5/xk;->d:Lz5/xk;

    iget-object v2, v2, Lz5/xk;->c:Lcom/google/android/gms/internal/ads/g0;

    .line 12
    invoke-virtual {v2, v1}, Lcom/google/android/gms/internal/ads/g0;->a(Lz5/no;)Ljava/lang/Object;

    move-result-object v1

    check-cast v1, Ljava/lang/Boolean;

    invoke-virtual {v1}, Ljava/lang/Boolean;->booleanValue()Z

    move-result v1

    if-eqz v1, :cond_24f

    invoke-static {}, Lcom/google/android/gms/ads/internal/zzt;->zzj()Lu5/c;

    move-result-object v0

    invoke-interface {v0}, Lu5/c;->c()J

    move-result-wide v0

    sub-long/2addr v0, v13

    iput-wide v0, v15, Lz5/ot0;->d:J
    :try_end_24b
    .catchall {:try_start_22e .. :try_end_24b} :catchall_250

    :goto_24b
    :try_start_24b
    invoke-virtual {v7}, Ljava/net/HttpURLConnection;->disconnect()V
    :try_end_24e
    .catch Ljava/io/IOException; {:try_start_24b .. :try_end_24e} :catch_255

    return-object v15

    :cond_24f
    :try_start_24f
    throw v0
    :try_end_250
    .catchall {:try_start_24f .. :try_end_250} :catchall_250

    :catchall_250
    move-exception v0

    :goto_251
    :try_start_251
    invoke-virtual {v7}, Ljava/net/HttpURLConnection;->disconnect()V

    throw v0
    :try_end_255
    .catch Ljava/io/IOException; {:try_start_251 .. :try_end_255} :catch_255

    :catch_255
    move-exception v0

    invoke-virtual {v0}, Ljava/io/IOException;->getMessage()Ljava/lang/String;

    move-result-object v1

    invoke-static {v1}, Ljava/lang/String;->valueOf(Ljava/lang/Object;)Ljava/lang/String;

    move-result-object v1

    const-string v2, "Error while connecting to ad server: "

    invoke-virtual {v1}, Ljava/lang/String;->length()I

    move-result v3

    if-eqz v3, :cond_26b

    invoke-virtual {v2, v1}, Ljava/lang/String;->concat(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v1

    goto :goto_270

    :cond_26b
    new-instance v1, Ljava/lang/String;

    invoke-direct {v1, v2}, Ljava/lang/String;-><init>(Ljava/lang/String;)V

    :goto_270
    invoke-static {v1}, Lz5/d50;->zzi(Ljava/lang/String;)V

    new-instance v2, Lz5/sr0;

    invoke-direct {v2, v1, v0}, Lz5/sr0;-><init>(Ljava/lang/String;Ljava/lang/Throwable;)V

    throw v2
.end method
