.class public Lg3/e$a;
.super Ljava/lang/Object;
.source ""

# interfaces
.implements Ljava/lang/Runnable;


# annotations
.annotation system Ldalvik/annotation/EnclosingMethod;
    value = Lg3/e;->u(Z)V
.end annotation

.annotation system Ldalvik/annotation/InnerClass;
    accessFlags = 0x1
    name = null
.end annotation


# instance fields
.field public final synthetic r:Ljava/lang/String;

.field public final synthetic s:J

.field public final synthetic t:J

.field public final synthetic u:Lg3/e;


# direct methods
.method public constructor <init>(Lg3/e;Ljava/lang/String;JJ)V
    .registers 7

    iput-object p1, p0, Lg3/e$a;->u:Lg3/e;

    iput-object p2, p0, Lg3/e$a;->r:Ljava/lang/String;

    iput-wide p3, p0, Lg3/e$a;->s:J

    iput-wide p5, p0, Lg3/e$a;->t:J

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

    return-void
.end method


# virtual methods
.method public run()V
    .registers 19

    move-object/from16 v1, p0

    iget-object v8, v1, Lg3/e$a;->u:Lg3/e;

    iget-object v2, v8, Lg3/e;->b:Lv9/a0;

    iget-object v3, v1, Lg3/e$a;->r:Ljava/lang/String;

    iget-wide v4, v1, Lg3/e$a;->s:J

    iget-wide v6, v1, Lg3/e$a;->t:J

    invoke-static {v8}, Ljava/util/Objects;->requireNonNull(Ljava/lang/Object;)Ljava/lang/Object;

    const-string v9, "com.amplitude.api.AmplitudeClient"

    const-string v10, "2"

    .line 1
    new-instance v0, Ljava/lang/StringBuilder;

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

    const-string v11, ""

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

    .line 2
    invoke-static {}, Ljava/lang/System;->currentTimeMillis()J

    move-result-wide v12

    .line 3
    invoke-virtual {v0, v12, v13}, Ljava/lang/StringBuilder;->append(J)Ljava/lang/StringBuilder;

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

    move-result-object v12

    :try_start_28
    new-instance v0, Ljava/lang/StringBuilder;

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

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

    iget-object v13, v8, Lg3/e;->d:Ljava/lang/String;

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

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

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

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

    move-result-object v0

    new-instance v13, Lh3/a;

    invoke-direct {v13}, Lh3/a;-><init>()V

    const-string v14, "UTF-8"

    invoke-virtual {v0, v14}, Ljava/lang/String;->getBytes(Ljava/lang/String;)[B

    move-result-object v0

    invoke-virtual {v13, v0}, Ljava/security/MessageDigest;->digest([B)[B

    move-result-object v0

    const/16 v13, 0x10

    new-array v13, v13, [C

    .line 4
    fill-array-data v13, :array_1ce

    array-length v14, v0

    mul-int/lit8 v14, v14, 0x2

    new-array v14, v14, [C

    const/4 v15, 0x0

    :goto_5b
    array-length v1, v0

    if-ge v15, v1, :cond_75

    aget-byte v1, v0, v15

    and-int/lit16 v1, v1, 0xff

    mul-int/lit8 v16, v15, 0x2

    ushr-int/lit8 v17, v1, 0x4

    aget-char v17, v13, v17

    aput-char v17, v14, v16

    add-int/lit8 v16, v16, 0x1

    and-int/lit8 v1, v1, 0xf

    aget-char v1, v13, v1

    aput-char v1, v14, v16

    add-int/lit8 v15, v15, 0x1

    goto :goto_5b

    :cond_75
    new-instance v0, Ljava/lang/String;

    invoke-direct {v0, v14}, Ljava/lang/String;-><init>([C)V
    :try_end_7a
    .catch Ljava/io/UnsupportedEncodingException; {:try_start_28 .. :try_end_7a} :catch_7c

    move-object v11, v0

    goto :goto_8d

    :catch_7c
    move-exception v0

    .line 5
    invoke-virtual {v0}, Ljava/io/UnsupportedEncodingException;->toString()Ljava/lang/String;

    move-result-object v1

    .line 6
    invoke-static {v9, v1}, Landroid/util/Log;->e(Ljava/lang/String;Ljava/lang/String;)I

    .line 7
    invoke-static {}, Lg3/q;->a()Lg3/q;

    move-result-object v1

    const-string v13, "Failed to compute checksum for upload request"

    invoke-virtual {v1, v13, v0}, Lg3/q;->b(Ljava/lang/String;Ljava/lang/Throwable;)Lg3/q;

    :goto_8d
    new-instance v0, Lv9/s$a;

    invoke-direct {v0}, Lv9/s$a;-><init>()V

    const-string v1, "v"

    invoke-virtual {v0, v1, v10}, Lv9/s$a;->a(Ljava/lang/String;Ljava/lang/String;)Lv9/s$a;

    iget-object v1, v8, Lg3/e;->d:Ljava/lang/String;

    const-string v10, "client"

    invoke-virtual {v0, v10, v1}, Lv9/s$a;->a(Ljava/lang/String;Ljava/lang/String;)Lv9/s$a;

    const-string v1, "e"

    invoke-virtual {v0, v1, v3}, Lv9/s$a;->a(Ljava/lang/String;Ljava/lang/String;)Lv9/s$a;

    const-string v1, "upload_time"

    invoke-virtual {v0, v1, v12}, Lv9/s$a;->a(Ljava/lang/String;Ljava/lang/String;)Lv9/s$a;

    const-string v1, "checksum"

    invoke-virtual {v0, v1, v11}, Lv9/s$a;->a(Ljava/lang/String;Ljava/lang/String;)Lv9/s$a;

    invoke-virtual {v0}, Lv9/s$a;->b()Lv9/s;

    move-result-object v0

    :try_start_b1
    new-instance v1, Lv9/c0$a;

    invoke-direct {v1}, Lv9/c0$a;-><init>()V

    iget-object v3, v8, Lg3/e;->F:Ljava/lang/String;

    invoke-virtual {v1, v3}, Lv9/c0$a;->e(Ljava/lang/String;)Lv9/c0$a;

    const-string v3, "body"

    .line 8
    invoke-static {v0, v3}, Lx/e;->f(Ljava/lang/Object;Ljava/lang/String;)V

    const-string v3, "POST"

    invoke-virtual {v1, v3, v0}, Lv9/c0$a;->c(Ljava/lang/String;Lv9/f0;)Lv9/c0$a;

    .line 9
    invoke-virtual {v1}, Lv9/c0$a;->a()Lv9/c0;

    move-result-object v0
    :try_end_c9
    .catch Ljava/lang/IllegalArgumentException; {:try_start_b1 .. :try_end_c9} :catch_1b5

    const/4 v1, 0x1

    :try_start_ca
    invoke-virtual {v2, v0}, Lv9/a0;->a(Lv9/c0;)Lv9/f;

    move-result-object v0

    check-cast v0, Lz9/d;

    invoke-virtual {v0}, Lz9/d;->f()Lv9/g0;

    move-result-object v0

    .line 10
    iget-object v2, v0, Lv9/g0;->x:Lv9/h0;

    .line 11
    invoke-virtual {v2}, Lv9/h0;->o()Ljava/lang/String;

    move-result-object v2

    const-string v3, "success"

    invoke-virtual {v2, v3}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

    move-result v3
    :try_end_e0
    .catch Ljava/net/ConnectException; {:try_start_ca .. :try_end_e0} :catch_1a1
    .catch Ljava/net/UnknownHostException; {:try_start_ca .. :try_end_e0} :catch_19f
    .catch Ljava/io/IOException; {:try_start_ca .. :try_end_e0} :catch_195
    .catch Ljava/lang/AssertionError; {:try_start_ca .. :try_end_e0} :catch_18d
    .catch Ljava/lang/Exception; {:try_start_ca .. :try_end_e0} :catch_18b

    if-eqz v3, :cond_ff

    :try_start_e2
    iget-object v0, v8, Lg3/e;->G:Lg3/u;

    new-instance v10, Lg3/f;

    move-object v2, v10

    move-object v3, v8

    invoke-direct/range {v2 .. v7}, Lg3/f;-><init>(Lg3/e;JJ)V

    invoke-virtual {v0, v10}, Lg3/u;->a(Ljava/lang/Runnable;)V
    :try_end_ee
    .catch Ljava/net/ConnectException; {:try_start_e2 .. :try_end_ee} :catch_fc
    .catch Ljava/net/UnknownHostException; {:try_start_e2 .. :try_end_ee} :catch_f9
    .catch Ljava/io/IOException; {:try_start_e2 .. :try_end_ee} :catch_f6
    .catch Ljava/lang/AssertionError; {:try_start_e2 .. :try_end_ee} :catch_f3
    .catch Ljava/lang/Exception; {:try_start_e2 .. :try_end_ee} :catch_f0

    goto/16 :goto_1ac

    :catch_f0
    move-exception v0

    goto/16 :goto_18f

    :catch_f3
    move-exception v0

    goto/16 :goto_18f

    :catch_f6
    move-exception v0

    goto/16 :goto_197

    :catch_f9
    move-exception v0

    goto/16 :goto_1a3

    :catch_fc
    move-exception v0

    goto/16 :goto_1a3

    :cond_ff
    :try_start_ff
    const-string v3, "invalid_api_key"

    invoke-virtual {v2, v3}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

    move-result v3

    if-eqz v3, :cond_10e

    const-string v0, "Invalid API key, make sure your API key is correct in initialize()"

    .line 12
    invoke-static {v9, v0}, Landroid/util/Log;->e(Ljava/lang/String;Ljava/lang/String;)I

    goto/16 :goto_189

    :cond_10e
    const-string v3, "bad_checksum"

    .line 13
    invoke-virtual {v2, v3}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

    move-result v3

    if-eqz v3, :cond_119

    const-string v0, "Bad checksum, post request was mangled in transit, will attempt to reupload later"

    goto :goto_186

    :cond_119
    const-string v3, "request_db_write_failed"

    invoke-virtual {v2, v3}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

    move-result v3

    if-eqz v3, :cond_124

    const-string v0, "Couldn\'t write to request database on server, will attempt to reupload later"

    goto :goto_186

    .line 14
    :cond_124
    iget v0, v0, Lv9/g0;->u:I

    const/16 v3, 0x19d

    if-ne v0, v3, :cond_170

    .line 15
    iget-boolean v0, v8, Lg3/e;->y:Z

    if-eqz v0, :cond_146

    iget v0, v8, Lg3/e;->z:I

    if-ne v0, v1, :cond_146

    const-wide/16 v2, 0x0

    cmp-long v0, v4, v2

    if-ltz v0, :cond_13d

    iget-object v0, v8, Lg3/e;->c:Lg3/n;

    invoke-virtual {v0, v4, v5}, Lg3/n;->e0(J)V

    :cond_13d
    cmp-long v0, v6, v2

    if-ltz v0, :cond_146

    iget-object v0, v8, Lg3/e;->c:Lg3/n;

    invoke-virtual {v0, v6, v7}, Lg3/n;->h0(J)V

    :cond_146
    iput-boolean v1, v8, Lg3/e;->y:Z

    iget-object v0, v8, Lg3/e;->c:Lg3/n;

    invoke-virtual {v0}, Lg3/n;->q()J

    move-result-wide v0

    long-to-int v0, v0

    iget v1, v8, Lg3/e;->z:I

    invoke-static {v0, v1}, Ljava/lang/Math;->min(II)I

    move-result v0

    int-to-double v0, v0

    const-wide/high16 v2, 0x4000000000000000L    # 2.0

    div-double/2addr v0, v2

    invoke-static {v0, v1}, Ljava/lang/Math;->ceil(D)D

    move-result-wide v0

    double-to-int v0, v0

    iput v0, v8, Lg3/e;->z:I

    const-string v0, "Request too large, will decrease size and attempt to reupload"

    .line 16
    invoke-static {v9, v0}, Landroid/util/Log;->w(Ljava/lang/String;Ljava/lang/String;)I

    .line 17
    iget-object v0, v8, Lg3/e;->G:Lg3/u;

    new-instance v1, Lg3/g;

    invoke-direct {v1, v8}, Lg3/g;-><init>(Lg3/e;)V

    invoke-virtual {v0, v1}, Lg3/u;->a(Ljava/lang/Runnable;)V

    goto :goto_189

    :cond_170
    new-instance v0, Ljava/lang/StringBuilder;

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

    const-string v1, "Upload failed, "

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

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

    const-string v1, ", will attempt to reupload later"

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

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

    move-result-object v0

    .line 18
    :goto_186
    invoke-static {v9, v0}, Landroid/util/Log;->w(Ljava/lang/String;Ljava/lang/String;)I
    :try_end_189
    .catch Ljava/net/ConnectException; {:try_start_ff .. :try_end_189} :catch_1a1
    .catch Ljava/net/UnknownHostException; {:try_start_ff .. :try_end_189} :catch_19f
    .catch Ljava/io/IOException; {:try_start_ff .. :try_end_189} :catch_195
    .catch Ljava/lang/AssertionError; {:try_start_ff .. :try_end_189} :catch_18d
    .catch Ljava/lang/Exception; {:try_start_ff .. :try_end_189} :catch_18b

    :goto_189
    const/4 v1, 0x0

    goto :goto_1ac

    :catch_18b
    move-exception v0

    goto :goto_18e

    :catch_18d
    move-exception v0

    :goto_18e
    const/4 v1, 0x0

    :goto_18f
    const-string v2, "Exception:"

    .line 19
    invoke-static {v9, v2, v0}, Landroid/util/Log;->e(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)I

    goto :goto_1a3

    :catch_195
    move-exception v0

    const/4 v1, 0x0

    .line 20
    :goto_197
    invoke-virtual {v0}, Ljava/io/IOException;->toString()Ljava/lang/String;

    move-result-object v2

    .line 21
    invoke-static {v9, v2}, Landroid/util/Log;->e(Ljava/lang/String;Ljava/lang/String;)I

    goto :goto_1a3

    :catch_19f
    move-exception v0

    goto :goto_1a2

    :catch_1a1
    move-exception v0

    :goto_1a2
    const/4 v1, 0x0

    .line 22
    :goto_1a3
    invoke-static {}, Lg3/q;->a()Lg3/q;

    move-result-object v2

    const-string v3, "Failed to post upload request"

    invoke-virtual {v2, v3, v0}, Lg3/q;->b(Ljava/lang/String;Ljava/lang/Throwable;)Lg3/q;

    :goto_1ac
    if-nez v1, :cond_1cc

    iget-object v0, v8, Lg3/e;->E:Ljava/util/concurrent/atomic/AtomicBoolean;

    const/4 v1, 0x0

    invoke-virtual {v0, v1}, Ljava/util/concurrent/atomic/AtomicBoolean;->set(Z)V

    goto :goto_1cc

    :catch_1b5
    move-exception v0

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

    move-result-object v1

    .line 23
    invoke-static {v9, v1}, Landroid/util/Log;->e(Ljava/lang/String;Ljava/lang/String;)I

    .line 24
    iget-object v1, v8, Lg3/e;->E:Ljava/util/concurrent/atomic/AtomicBoolean;

    const/4 v2, 0x0

    invoke-virtual {v1, v2}, Ljava/util/concurrent/atomic/AtomicBoolean;->set(Z)V

    invoke-static {}, Lg3/q;->a()Lg3/q;

    move-result-object v1

    const-string v2, "Failed to build upload request"

    invoke-virtual {v1, v2, v0}, Lg3/q;->b(Ljava/lang/String;Ljava/lang/Throwable;)Lg3/q;

    :cond_1cc
    :goto_1cc
    return-void

    nop

    :array_1ce
    .array-data 2
        0x30s
        0x31s
        0x32s
        0x33s
        0x34s
        0x35s
        0x36s
        0x37s
        0x38s
        0x39s
        0x61s
        0x62s
        0x63s
        0x64s
        0x65s
        0x66s
    .end array-data
.end method
