j.smali

.class public abstract Lcom/ijinshan/pluginslive/plugin/upgrade/process/j;
.super Ljava/lang/Object;
.source "ServerConnection.java"


# annotations
.annotation system Ldalvik/annotation/MemberClasses;
    value = {
        Lcom/ijinshan/pluginslive/plugin/upgrade/process/j$a;
    }
.end annotation

.annotation system Ldalvik/annotation/Signature;
    value = {
        "<T:",
        "Ljava/lang/Object;",
        ">",
        "Ljava/lang/Object;"
    }
.end annotation


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

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

    return-void
.end method

.method private a(Ljava/io/InputStream;)Ljava/lang/String;
    .registers 6
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Ljava/lang/Exception;
        }
    .end annotation

    .prologue
    .line 131
    new-instance v0, Ljava/io/ByteArrayOutputStream;

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

    .line 132
    const/16 v1, 0x80

    new-array v1, v1, [B

    .line 134
    :goto_9
    invoke-virtual {p1, v1}, Ljava/io/InputStream;->read([B)I

    move-result v2

    .line 135
    const/4 v3, -0x1

    if-ne v2, v3, :cond_1c

    .line 139
    invoke-virtual {v0}, Ljava/io/ByteArrayOutputStream;->toByteArray()[B

    move-result-object v0

    .line 140
    new-instance v1, Ljava/lang/String;

    const-string v2, "UTF-8"

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

    return-object v1

    .line 136
    :cond_1c
    const/4 v3, 0x0

    invoke-virtual {v0, v1, v3, v2}, Ljava/io/ByteArrayOutputStream;->write([BII)V

    goto :goto_9
.end method

.method private b(Ljava/lang/String;)Lcom/ijinshan/pluginslive/plugin/upgrade/process/j$a;
    .registers 9

    .prologue
    const/4 v1, 0x0

    .line 79
    new-instance v2, Lcom/ijinshan/pluginslive/plugin/upgrade/process/j$a;

    invoke-direct {v2, v1}, Lcom/ijinshan/pluginslive/plugin/upgrade/process/j$a;-><init>(Lcom/ijinshan/pluginslive/plugin/upgrade/process/k;)V

    .line 83
    :try_start_6
    new-instance v0, Ljava/net/URL;

    new-instance v3, Ljava/lang/StringBuilder;

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

    invoke-virtual {p0}, Lcom/ijinshan/pluginslive/plugin/upgrade/process/j;->a()Ljava/lang/String;

    move-result-object v4

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

    move-result-object v3

    const-string v4, "?t="

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

    move-result-object v3

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

    move-result-wide v4

    invoke-virtual {v3, v4, v5}, Ljava/lang/StringBuilder;->append(J)Ljava/lang/StringBuilder;

    move-result-object v3

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

    move-result-object v3

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

    .line 84
    invoke-virtual {v0}, Ljava/net/URL;->openConnection()Ljava/net/URLConnection;

    move-result-object v0

    check-cast v0, Ljava/net/HttpURLConnection;
    :try_end_30
    .catch Ljava/lang/Throwable; {:try_start_6 .. :try_end_30} :catch_105
    .catchall {:try_start_6 .. :try_end_30} :catchall_103

    .line 85
    const/16 v1, 0x3a98

    :try_start_32
    invoke-virtual {v0, v1}, Ljava/net/HttpURLConnection;->setConnectTimeout(I)V

    .line 86
    const/16 v1, 0x7530

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

    .line 87
    const/4 v1, 0x0

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

    .line 88
    const-string v1, "POST"

    invoke-virtual {v0, v1}, Ljava/net/HttpURLConnection;->setRequestMethod(Ljava/lang/String;)V

    .line 89
    const/4 v1, 0x0

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

    .line 90
    const/4 v1, 0x1

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

    .line 92
    new-instance v1, Ljava/io/DataOutputStream;

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

    move-result-object v3

    invoke-direct {v1, v3}, Ljava/io/DataOutputStream;-><init>(Ljava/io/OutputStream;)V

    .line 93
    invoke-virtual {v1, p1}, Ljava/io/DataOutputStream;->writeBytes(Ljava/lang/String;)V

    .line 94
    invoke-virtual {v1}, Ljava/io/DataOutputStream;->flush()V

    .line 95
    invoke-virtual {v1}, Ljava/io/DataOutputStream;->close()V

    .line 96
    invoke-virtual {v0}, Ljava/net/HttpURLConnection;->getResponseCode()I

    move-result v1

    const/16 v3, 0xc8

    if-ne v1, v3, :cond_d1

    .line 98
    invoke-virtual {v0}, Ljava/net/HttpURLConnection;->getInputStream()Ljava/io/InputStream;

    move-result-object v1

    invoke-direct {p0, v1}, Lcom/ijinshan/pluginslive/plugin/upgrade/process/j;->a(Ljava/io/InputStream;)Ljava/lang/String;

    move-result-object v1

    .line 99
    invoke-virtual {v0}, Ljava/net/HttpURLConnection;->getContentLength()I

    move-result v3

    const/4 v4, -0x1

    if-eq v3, v4, :cond_ab

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

    move-result v3

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

    move-result v4

    if-eq v3, v4, :cond_ab

    .line 100
    const/16 v3, 0x66

    invoke-static {v2, v3}, Lcom/ijinshan/pluginslive/plugin/upgrade/process/j$a;->a(Lcom/ijinshan/pluginslive/plugin/upgrade/process/j$a;S)S

    .line 101
    new-instance v3, Ljava/lang/StringBuilder;

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

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

    move-result v1

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

    move-result-object v1

    const-string v3, "/"

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

    move-result-object v1

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

    move-result v3

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

    move-result-object v1

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

    move-result-object v1

    invoke-static {v2, v1}, Lcom/ijinshan/pluginslive/plugin/upgrade/process/j$a;->a(Lcom/ijinshan/pluginslive/plugin/upgrade/process/j$a;Ljava/lang/String;)Ljava/lang/String;
    :try_end_a5
    .catch Ljava/lang/Throwable; {:try_start_32 .. :try_end_a5} :catch_b4
    .catchall {:try_start_32 .. :try_end_a5} :catchall_f1

    .line 120
    :goto_a5
    if-eqz v0, :cond_aa

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

    .line 125
    :cond_aa
    :goto_aa
    return-object v2

    .line 103
    :cond_ab
    const/16 v3, 0xc7

    :try_start_ad
    invoke-static {v2, v3}, Lcom/ijinshan/pluginslive/plugin/upgrade/process/j$a;->a(Lcom/ijinshan/pluginslive/plugin/upgrade/process/j$a;S)S

    .line 104
    invoke-static {v2, v1}, Lcom/ijinshan/pluginslive/plugin/upgrade/process/j$a;->b(Lcom/ijinshan/pluginslive/plugin/upgrade/process/j$a;Ljava/lang/String;)Ljava/lang/String;
    :try_end_b3
    .catch Ljava/lang/Throwable; {:try_start_ad .. :try_end_b3} :catch_b4
    .catchall {:try_start_ad .. :try_end_b3} :catchall_f1

    goto :goto_a5

    .line 111
    :catch_b4
    move-exception v1

    move-object v6, v1

    move-object v1, v0

    move-object v0, v6

    .line 112
    :goto_b8
    const/16 v3, 0x65

    :try_start_ba
    invoke-static {v2, v3}, Lcom/ijinshan/pluginslive/plugin/upgrade/process/j$a;->a(Lcom/ijinshan/pluginslive/plugin/upgrade/process/j$a;S)S

    .line 113
    instance-of v3, v0, Ljava/net/SocketTimeoutException;

    if-eqz v3, :cond_fb

    .line 114
    const-string v3, "SocketTimeoutException"

    invoke-static {v2, v3}, Lcom/ijinshan/pluginslive/plugin/upgrade/process/j$a;->a(Lcom/ijinshan/pluginslive/plugin/upgrade/process/j$a;Ljava/lang/String;)Ljava/lang/String;

    .line 118
    :goto_c6
    const-string v3, "ServerConnection error"

    invoke-static {v3, v0}, Lcom/ijinshan/pluginslive/b;->a(Ljava/lang/String;Ljava/lang/Throwable;)V
    :try_end_cb
    .catchall {:try_start_ba .. :try_end_cb} :catchall_103

    .line 120
    if-eqz v1, :cond_aa

    .line 121
    invoke-virtual {v1}, Ljava/net/HttpURLConnection;->disconnect()V

    goto :goto_aa

    .line 107
    :cond_d1
    const/16 v1, 0x67

    :try_start_d3
    invoke-static {v2, v1}, Lcom/ijinshan/pluginslive/plugin/upgrade/process/j$a;->a(Lcom/ijinshan/pluginslive/plugin/upgrade/process/j$a;S)S

    .line 108
    new-instance v1, Ljava/lang/StringBuilder;

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

    const-string v3, "code="

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

    move-result-object v1

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

    move-result v3

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

    move-result-object v1

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

    move-result-object v1

    invoke-static {v2, v1}, Lcom/ijinshan/pluginslive/plugin/upgrade/process/j$a;->a(Lcom/ijinshan/pluginslive/plugin/upgrade/process/j$a;Ljava/lang/String;)Ljava/lang/String;
    :try_end_f0
    .catch Ljava/lang/Throwable; {:try_start_d3 .. :try_end_f0} :catch_b4
    .catchall {:try_start_d3 .. :try_end_f0} :catchall_f1

    goto :goto_a5

    .line 120
    :catchall_f1
    move-exception v1

    move-object v6, v1

    move-object v1, v0

    move-object v0, v6

    :goto_f5
    if-eqz v1, :cond_fa

    .line 121
    invoke-virtual {v1}, Ljava/net/HttpURLConnection;->disconnect()V

    :cond_fa
    throw v0

    .line 116
    :cond_fb
    :try_start_fb
    invoke-virtual {v0}, Ljava/lang/Throwable;->getMessage()Ljava/lang/String;

    move-result-object v3

    invoke-static {v2, v3}, Lcom/ijinshan/pluginslive/plugin/upgrade/process/j$a;->a(Lcom/ijinshan/pluginslive/plugin/upgrade/process/j$a;Ljava/lang/String;)Ljava/lang/String;
    :try_end_102
    .catchall {:try_start_fb .. :try_end_102} :catchall_103

    goto :goto_c6

    .line 120
    :catchall_103
    move-exception v0

    goto :goto_f5

    .line 111
    :catch_105
    move-exception v0

    goto :goto_b8
.end method


# virtual methods
.method abstract a(Ljava/lang/String;)Lcom/ijinshan/pluginslive/plugin/upgrade/process/i;
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "(",
            "Ljava/lang/String;",
            ")",
            "Lcom/ijinshan/pluginslive/plugin/upgrade/process/i",
            "<TT;>;"
        }
    .end annotation
.end method

.method abstract a()Ljava/lang/String;
.end method

.method abstract a(Landroid/content/Context;)Ljava/lang/String;
.end method

.method public b(Landroid/content/Context;)Lcom/ijinshan/pluginslive/plugin/upgrade/process/i;
    .registers 5
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "(",
            "Landroid/content/Context;",
            ")",
            "Lcom/ijinshan/pluginslive/plugin/upgrade/process/i",
            "<TT;>;"
        }
    .end annotation

    .prologue
    const/16 v2, 0x64

    .line 43
    if-nez p1, :cond_c

    .line 44
    new-instance v0, Lcom/ijinshan/pluginslive/plugin/upgrade/process/i;

    const-string v1, "Context Null"

    invoke-direct {v0, v2, v1}, Lcom/ijinshan/pluginslive/plugin/upgrade/process/i;-><init>(SLjava/lang/String;)V

    .line 64
    :goto_b
    return-object v0

    .line 47
    :cond_c
    invoke-static {p1}, Lcom/ijinshan/pluginslive/plugin/util/g;->a(Landroid/content/Context;)Z

    move-result v0

    if-nez v0, :cond_1b

    .line 48
    new-instance v0, Lcom/ijinshan/pluginslive/plugin/upgrade/process/i;

    const/16 v1, 0x6e

    const/4 v2, 0x0

    invoke-direct {v0, v1, v2}, Lcom/ijinshan/pluginslive/plugin/upgrade/process/i;-><init>(SLjava/lang/String;)V

    goto :goto_b

    .line 52
    :cond_1b
    invoke-virtual {p0, p1}, Lcom/ijinshan/pluginslive/plugin/upgrade/process/j;->a(Landroid/content/Context;)Ljava/lang/String;

    move-result-object v0

    .line 53
    if-nez v0, :cond_29

    .line 54
    new-instance v0, Lcom/ijinshan/pluginslive/plugin/upgrade/process/i;

    const-string v1, "JSON Null"

    invoke-direct {v0, v2, v1}, Lcom/ijinshan/pluginslive/plugin/upgrade/process/i;-><init>(SLjava/lang/String;)V

    goto :goto_b

    .line 58
    :cond_29
    invoke-direct {p0, v0}, Lcom/ijinshan/pluginslive/plugin/upgrade/process/j;->b(Ljava/lang/String;)Lcom/ijinshan/pluginslive/plugin/upgrade/process/j$a;

    move-result-object v1

    .line 59
    invoke-static {v1}, Lcom/ijinshan/pluginslive/plugin/upgrade/process/j$a;->a(Lcom/ijinshan/pluginslive/plugin/upgrade/process/j$a;)S

    move-result v0

    const/16 v2, 0xc7

    if-eq v0, v2, :cond_43

    .line 60
    new-instance v0, Lcom/ijinshan/pluginslive/plugin/upgrade/process/i;

    invoke-static {v1}, Lcom/ijinshan/pluginslive/plugin/upgrade/process/j$a;->a(Lcom/ijinshan/pluginslive/plugin/upgrade/process/j$a;)S

    move-result v2

    invoke-static {v1}, Lcom/ijinshan/pluginslive/plugin/upgrade/process/j$a;->b(Lcom/ijinshan/pluginslive/plugin/upgrade/process/j$a;)Ljava/lang/String;

    move-result-object v1

    invoke-direct {v0, v2, v1}, Lcom/ijinshan/pluginslive/plugin/upgrade/process/i;-><init>(SLjava/lang/String;)V

    goto :goto_b

    .line 64
    :cond_43
    invoke-static {v1}, Lcom/ijinshan/pluginslive/plugin/upgrade/process/j$a;->c(Lcom/ijinshan/pluginslive/plugin/upgrade/process/j$a;)Ljava/lang/String;

    move-result-object v0

    invoke-virtual {p0, v0}, Lcom/ijinshan/pluginslive/plugin/upgrade/process/j;->a(Ljava/lang/String;)Lcom/ijinshan/pluginslive/plugin/upgrade/process/i;

    move-result-object v0

    goto :goto_b
.end method