h.smali

.class public Lu0/h;
.super Ljava/lang/Object;
.source "TcpConnection.java"


# instance fields
.field public a:Ljava/net/Socket;

.field public b:Ljava/io/InputStream;

.field public c:Ljava/io/OutputStream;

.field public d:Ljava/lang/String;

.field public e:I

.field public f:I

.field public g:Z

.field public h:I


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

    return-void
.end method

.method public constructor <init>(Ljava/lang/String;I)V
    .registers 4

    const/4 v0, 0x0

    invoke-direct {p0, p1, p2, v0}, Lu0/h;-><init>(Ljava/lang/String;IZ)V

    return-void
.end method

.method public constructor <init>(Ljava/lang/String;IZ)V
    .registers 4

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

    iput-object p1, p0, Lu0/h;->d:Ljava/lang/String;

    iput p2, p0, Lu0/h;->e:I

    const/4 p1, 0x0

    iput p1, p0, Lu0/h;->h:I

    iput-boolean p3, p0, Lu0/h;->g:Z

    return-void
.end method


# virtual methods
.method public a()V
    .registers 8
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Lq0/d;
        }
    .end annotation

    const/4 v0, 0x2

    iput v0, p0, Lu0/h;->h:I

    :try_start_3
    iget-object v0, p0, Lu0/h;->d:Ljava/lang/String;

    invoke-static {v0}, Ljava/net/InetAddress;->getByName(Ljava/lang/String;)Ljava/net/InetAddress;

    move-result-object v0

    invoke-virtual {v0}, Ljava/net/InetAddress;->getAddress()[B

    iget-boolean v1, p0, Lu0/h;->g:Z
    :try_end_e
    .catch Ljava/io/IOException; {:try_start_3 .. :try_end_e} :catch_8a

    const/4 v2, 0x0

    const/4 v3, 0x1

    if-eqz v1, :cond_4b

    :try_start_12
    const-string v1, "TLS"

    invoke-static {v1}, Ljavax/net/ssl/SSLContext;->getInstance(Ljava/lang/String;)Ljavax/net/ssl/SSLContext;

    move-result-object v1

    const/4 v4, 0x0

    new-array v5, v3, [Ljavax/net/ssl/TrustManager;

    new-instance v6, Lu0/h$a;

    invoke-direct {v6, p0}, Lu0/h$a;-><init>(Lu0/h;)V

    aput-object v6, v5, v2

    new-instance v6, Ljava/security/SecureRandom;

    invoke-direct {v6}, Ljava/security/SecureRandom;-><init>()V

    invoke-virtual {v1, v4, v5, v6}, Ljavax/net/ssl/SSLContext;->init([Ljavax/net/ssl/KeyManager;[Ljavax/net/ssl/TrustManager;Ljava/security/SecureRandom;)V
    :try_end_2a
    .catch Ljava/security/KeyManagementException; {:try_start_12 .. :try_end_2a} :catch_41
    .catch Ljava/security/NoSuchAlgorithmException; {:try_start_12 .. :try_end_2a} :catch_37
    .catch Ljava/io/IOException; {:try_start_12 .. :try_end_2a} :catch_8a

    :try_start_2a
    invoke-virtual {v1}, Ljavax/net/ssl/SSLContext;->getSocketFactory()Ljavax/net/ssl/SSLSocketFactory;

    move-result-object v1

    iget v4, p0, Lu0/h;->e:I

    invoke-virtual {v1, v0, v4}, Ljavax/net/SocketFactory;->createSocket(Ljava/net/InetAddress;I)Ljava/net/Socket;

    move-result-object v0

    iput-object v0, p0, Lu0/h;->a:Ljava/net/Socket;

    goto :goto_5b

    :catch_37
    move-exception v0

    invoke-static {v0}, Lt0/a;->a(Ljava/lang/Exception;)V

    new-instance v1, Lq0/d;

    invoke-direct {v1, v0}, Lq0/d;-><init>(Ljava/lang/Exception;)V

    throw v1

    :catch_41
    move-exception v0

    invoke-static {v0}, Lt0/a;->a(Ljava/lang/Exception;)V

    new-instance v1, Lq0/d;

    invoke-direct {v1, v0}, Lq0/d;-><init>(Ljava/lang/Exception;)V

    throw v1

    :cond_4b
    new-instance v1, Ljava/net/Socket;

    invoke-virtual {v0}, Ljava/net/InetAddress;->getHostAddress()Ljava/lang/String;

    move-result-object v0

    iget v4, p0, Lu0/h;->e:I

    invoke-direct {v1, v0, v4}, Ljava/net/Socket;-><init>(Ljava/lang/String;I)V

    iput-object v1, p0, Lu0/h;->a:Ljava/net/Socket;

    invoke-virtual {v1, v3}, Ljava/net/Socket;->setKeepAlive(Z)V

    :goto_5b
    iget-object v0, p0, Lu0/h;->a:Ljava/net/Socket;

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

    move-result-object v0

    iput-object v0, p0, Lu0/h;->b:Ljava/io/InputStream;

    iget-object v0, p0, Lu0/h;->a:Ljava/net/Socket;

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

    move-result-object v0

    iput-object v0, p0, Lu0/h;->c:Ljava/io/OutputStream;

    iget-object v0, p0, Lu0/h;->a:Ljava/net/Socket;

    invoke-virtual {v0}, Ljava/net/Socket;->isConnected()Z

    move-result v0

    if-eqz v0, :cond_74

    goto :goto_75

    :cond_74
    const/4 v3, 0x0

    :goto_75
    iput v3, p0, Lu0/h;->h:I

    iget-object v0, p0, Lu0/h;->a:Ljava/net/Socket;

    invoke-virtual {v0}, Ljava/net/Socket;->isConnected()Z

    move-result v0

    if-eqz v0, :cond_82

    const-string v0, "connection ok"

    goto :goto_84

    :cond_82
    const-string v0, "connection fails"

    :goto_84
    new-array v1, v2, [Ljava/lang/Object;

    invoke-static {v0, v1}, Lt0/a;->b(Ljava/lang/String;[Ljava/lang/Object;)V
    :try_end_89
    .catch Ljava/io/IOException; {:try_start_2a .. :try_end_89} :catch_8a

    return-void

    :catch_8a
    move-exception v0

    invoke-static {v0}, Lt0/a;->a(Ljava/lang/Exception;)V

    new-instance v1, Lq0/d;

    invoke-direct {v1, v0}, Lq0/d;-><init>(Ljava/lang/Exception;)V

    throw v1
.end method

.method public a([B)V
    .registers 4
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Lq0/b;
        }
    .end annotation

    array-length v0, p1

    const/4 v1, 0x0

    invoke-virtual {p0, p1, v1, v0}, Lu0/h;->a([BII)V

    return-void
.end method

.method public a([BII)V
    .registers 5
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Lq0/b;
        }
    .end annotation

    :try_start_0
    iget-object v0, p0, Lu0/h;->c:Ljava/io/OutputStream;

    invoke-virtual {v0, p1, p2, p3}, Ljava/io/OutputStream;->write([BII)V

    iget-object p1, p0, Lu0/h;->c:Ljava/io/OutputStream;

    invoke-virtual {p1}, Ljava/io/OutputStream;->flush()V
    :try_end_a
    .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_a} :catch_b

    return-void

    :catch_b
    move-exception p1

    invoke-static {p1}, Lt0/a;->a(Ljava/lang/Exception;)V

    invoke-virtual {p0}, Lu0/h;->b()V

    new-instance p2, Lq0/b;

    invoke-direct {p2, p1}, Lq0/b;-><init>(Ljava/lang/Exception;)V

    throw p2
.end method

.method public a(Ljava/lang/String;I)Z
    .registers 4

    iget-object v0, p0, Lu0/h;->d:Ljava/lang/String;

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

    move-result p1

    if-eqz p1, :cond_e

    iget p1, p0, Lu0/h;->e:I

    if-ne p1, p2, :cond_e

    const/4 p1, 0x1

    goto :goto_f

    :cond_e
    const/4 p1, 0x0

    :goto_f
    return p1
.end method

.method public b()V
    .registers 3

    iget-object v0, p0, Lu0/h;->a:Ljava/net/Socket;

    if-eqz v0, :cond_18

    const/4 v1, 0x0

    :try_start_5
    invoke-virtual {v0}, Ljava/net/Socket;->close()V

    const/4 v0, 0x0

    iput-object v0, p0, Lu0/h;->a:Ljava/net/Socket;
    :try_end_b
    .catch Ljava/io/IOException; {:try_start_5 .. :try_end_b} :catch_e
    .catchall {:try_start_5 .. :try_end_b} :catchall_c

    goto :goto_12

    :catchall_c
    move-exception v0

    goto :goto_15

    :catch_e
    move-exception v0

    :try_start_f
    invoke-static {v0}, Lt0/a;->a(Ljava/lang/Exception;)V
    :try_end_12
    .catchall {:try_start_f .. :try_end_12} :catchall_c

    :goto_12
    iput v1, p0, Lu0/h;->h:I

    goto :goto_18

    :goto_15
    iput v1, p0, Lu0/h;->h:I

    throw v0

    :cond_18
    :goto_18
    return-void
.end method

.method public c()I
    .registers 2

    iget v0, p0, Lu0/h;->f:I

    return v0
.end method

.method public d()Ljava/io/InputStream;
    .registers 2

    iget-object v0, p0, Lu0/h;->b:Ljava/io/InputStream;

    return-object v0
.end method

.method public e()Z
    .registers 3

    iget v0, p0, Lu0/h;->h:I

    const/4 v1, 0x1

    if-ne v0, v1, :cond_6

    goto :goto_7

    :cond_6
    const/4 v1, 0x0

    :goto_7
    return v1
.end method