.class Lcom/miaozhen/mzmonitor/p;
.super Ljava/lang/Object;


# static fields
.field private static final c:Ljavax/net/ssl/HostnameVerifier;


# instance fields
.field private a:Lcom/miaozhen/mzmonitor/b;

.field private b:Landroid/content/Context;


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

    new-instance v0, Lcom/miaozhen/mzmonitor/q;

    invoke-direct {v0}, Lcom/miaozhen/mzmonitor/q;-><init>()V

    sput-object v0, Lcom/miaozhen/mzmonitor/p;->c:Ljavax/net/ssl/HostnameVerifier;

    return-void
.end method

.method public constructor <init>(Landroid/content/Context;Lcom/miaozhen/mzmonitor/b;)V
    .locals 0

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

    invoke-virtual {p1}, Landroid/content/Context;->getApplicationContext()Landroid/content/Context;

    move-result-object p1

    iput-object p1, p0, Lcom/miaozhen/mzmonitor/p;->b:Landroid/content/Context;

    iput-object p2, p0, Lcom/miaozhen/mzmonitor/p;->a:Lcom/miaozhen/mzmonitor/b;

    return-void
.end method

.method private a(Ljava/lang/String;)V
    .locals 2

    if-eqz p1, :cond_1

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

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

    const/4 p1, 0x1

    invoke-static {p1}, Ljava/net/HttpURLConnection;->setFollowRedirects(Z)V

    const-string p1, "https"

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

    move-result-object v1

    invoke-virtual {p1, v1}, Ljava/lang/String;->equalsIgnoreCase(Ljava/lang/String;)Z

    move-result p1

    if-eqz p1, :cond_0

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

    move-result-object p1

    check-cast p1, Ljavax/net/ssl/HttpsURLConnection;

    move-object v0, p1

    check-cast v0, Ljavax/net/ssl/HttpsURLConnection;

    invoke-static {v0}, Lcom/miaozhen/mzmonitor/p;->a(Ljavax/net/ssl/HttpsURLConnection;)V

    goto :goto_0

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

    move-result-object p1

    check-cast p1, Ljava/net/HttpURLConnection;

    :goto_0
    if-eqz p1, :cond_1

    const/4 v0, 0x0

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

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

    const/16 v0, 0x1388

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

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

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

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

    invoke-virtual {p1}, Ljava/net/HttpURLConnection;->disconnect()V
    :try_end_0
    .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0

    goto :goto_1

    :catch_0
    move-exception p1

    invoke-virtual {p1}, Ljava/lang/Exception;->printStackTrace()V

    :cond_1
    :goto_1
    return-void
.end method

.method public static a(Ljavax/net/ssl/HttpsURLConnection;)V
    .locals 4

    const/4 v0, 0x1

    new-array v0, v0, [Ljavax/net/ssl/TrustManager;

    new-instance v1, Lcom/miaozhen/mzmonitor/r;

    invoke-direct {v1}, Lcom/miaozhen/mzmonitor/r;-><init>()V

    const/4 v2, 0x0

    aput-object v1, v0, v2

    :try_start_0
    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 v2, 0x0

    new-instance v3, Ljava/security/SecureRandom;

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

    invoke-virtual {v1, v2, v0, v3}, Ljavax/net/ssl/SSLContext;->init([Ljavax/net/ssl/KeyManager;[Ljavax/net/ssl/TrustManager;Ljava/security/SecureRandom;)V

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

    move-result-object v0

    invoke-virtual {p0, v0}, Ljavax/net/ssl/HttpsURLConnection;->setSSLSocketFactory(Ljavax/net/ssl/SSLSocketFactory;)V

    sget-object v0, Lcom/miaozhen/mzmonitor/p;->c:Ljavax/net/ssl/HostnameVerifier;

    invoke-virtual {p0, v0}, Ljavax/net/ssl/HttpsURLConnection;->setHostnameVerifier(Ljavax/net/ssl/HostnameVerifier;)V
    :try_end_0
    .catch Ljava/security/NoSuchAlgorithmException; {:try_start_0 .. :try_end_0} :catch_1
    .catch Ljava/security/KeyManagementException; {:try_start_0 .. :try_end_0} :catch_0

    goto :goto_0

    :catch_0
    move-exception p0

    invoke-virtual {p0}, Ljava/security/KeyManagementException;->printStackTrace()V

    goto :goto_0

    :catch_1
    move-exception p0

    invoke-virtual {p0}, Ljava/security/NoSuchAlgorithmException;->printStackTrace()V

    :goto_0
    return-void
.end method


# virtual methods
.method public a()Ljava/net/HttpURLConnection;
    .locals 4

    iget-object v0, p0, Lcom/miaozhen/mzmonitor/p;->b:Landroid/content/Context;

    invoke-static {v0}, Lcom/miaozhen/mzmonitor/d;->a(Landroid/content/Context;)Lcom/miaozhen/mzmonitor/d;

    move-result-object v0

    iget-object v1, p0, Lcom/miaozhen/mzmonitor/p;->a:Lcom/miaozhen/mzmonitor/b;

    invoke-virtual {v0, v1}, Lcom/miaozhen/mzmonitor/d;->a(Lcom/miaozhen/mzmonitor/b;)Ljava/net/URL;

    move-result-object v0

    const-string v1, "https"

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

    move-result-object v2

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

    move-result v1

    if-eqz v1, :cond_0

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

    move-result-object v1

    check-cast v1, Ljavax/net/ssl/HttpsURLConnection;

    move-object v2, v1

    check-cast v2, Ljavax/net/ssl/HttpsURLConnection;

    invoke-static {v2}, Lcom/miaozhen/mzmonitor/p;->a(Ljavax/net/ssl/HttpsURLConnection;)V

    goto :goto_0

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

    move-result-object v1

    check-cast v1, Ljava/net/HttpURLConnection;

    :goto_0
    iget-object v2, p0, Lcom/miaozhen/mzmonitor/p;->b:Landroid/content/Context;

    invoke-static {v2}, Lcom/miaozhen/mzmonitor/l;->a(Landroid/content/Context;)Lcom/miaozhen/mzmonitor/l;

    move-result-object v2

    invoke-virtual {v2}, Lcom/miaozhen/mzmonitor/l;->k()Ljava/lang/String;

    move-result-object v2

    const-string v3, "1"

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

    move-result v2

    if-eqz v2, :cond_1

    const/16 v2, 0x1388

    goto :goto_1

    :cond_1
    const/16 v2, 0x2710

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

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

    const/4 v2, 0x0

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

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

    iget-object v2, p0, Lcom/miaozhen/mzmonitor/p;->b:Landroid/content/Context;

    invoke-static {v2}, Lcom/miaozhen/mzmonitor/d;->a(Landroid/content/Context;)Lcom/miaozhen/mzmonitor/d;

    move-result-object v2

    invoke-virtual {v2, v0}, Lcom/miaozhen/mzmonitor/d;->a(Ljava/net/URL;)Lcom/miaozhen/mzmonitor/g;

    move-result-object v2

    if-eqz v2, :cond_2

    iget-object v3, v2, Lcom/miaozhen/mzmonitor/g;->a:Ljava/lang/String;

    if-eqz v3, :cond_2

    iget-object v2, v2, Lcom/miaozhen/mzmonitor/g;->a:Ljava/lang/String;

    const-string v3, "miaozhen"

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

    move-result v2

    if-eqz v2, :cond_2

    const-string v2, "X-MZ-UIC"

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

    move-result-object v0

    invoke-static {v0}, Lcom/miaozhen/mzmonitor/v;->a(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v0

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

    :cond_2
    return-object v1
.end method

.method public b()V
    .locals 9

    iget-object v0, p0, Lcom/miaozhen/mzmonitor/p;->b:Landroid/content/Context;

    invoke-static {v0}, Lcom/miaozhen/mzmonitor/c;->a(Landroid/content/Context;)Lcom/miaozhen/mzmonitor/c;

    move-result-object v0

    const/4 v1, 0x0

    const/4 v2, 0x0

    :try_start_0
    invoke-virtual {p0}, Lcom/miaozhen/mzmonitor/p;->a()Ljava/net/HttpURLConnection;

    move-result-object v3
    :try_end_0
    .catch Ljava/io/IOException; {:try_start_0 .. :try_end_0} :catch_3
    .catch Ljava/lang/NullPointerException; {:try_start_0 .. :try_end_0} :catch_2
    .catchall {:try_start_0 .. :try_end_0} :catchall_1

    if-eqz v3, :cond_4

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

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

    move-result v4

    if-ltz v4, :cond_2

    const/16 v5, 0x190

    if-ge v4, v5, :cond_2

    sget-boolean v4, Lcom/miaozhen/mzmonitor/MZMonitor;->a:Z

    if-eqz v4, :cond_0

    const-string v4, "MZSDK:20180108"

    const-string v5, "Request has been successfully sent"

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

    :cond_0
    iget-object v4, p0, Lcom/miaozhen/mzmonitor/p;->a:Lcom/miaozhen/mzmonitor/b;

    const/4 v5, 0x1

    invoke-virtual {v0, v4, v5}, Lcom/miaozhen/mzmonitor/c;->a(Lcom/miaozhen/mzmonitor/b;Z)V

    iget-object v4, p0, Lcom/miaozhen/mzmonitor/p;->b:Landroid/content/Context;

    invoke-static {v4}, Lcom/miaozhen/mzmonitor/d;->a(Landroid/content/Context;)Lcom/miaozhen/mzmonitor/d;

    move-result-object v4

    invoke-virtual {v3}, Ljava/net/HttpURLConnection;->getURL()Ljava/net/URL;

    move-result-object v6

    invoke-virtual {v4, v6}, Lcom/miaozhen/mzmonitor/d;->a(Ljava/net/URL;)Lcom/miaozhen/mzmonitor/g;

    move-result-object v4

    if-eqz v4, :cond_1

    iget-object v6, v4, Lcom/miaozhen/mzmonitor/g;->a:Ljava/lang/String;

    if-eqz v6, :cond_1

    iget-object v6, v4, Lcom/miaozhen/mzmonitor/g;->a:Ljava/lang/String;

    const-string v7, "miaozhen"

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

    move-result v6

    if-eqz v6, :cond_1

    iget-object v6, p0, Lcom/miaozhen/mzmonitor/p;->b:Landroid/content/Context;

    iget-object v7, v4, Lcom/miaozhen/mzmonitor/g;->a:Ljava/lang/String;

    invoke-static {v6, v7, v5}, Lcom/miaozhen/mzmonitor/s;->a(Landroid/content/Context;Ljava/lang/String;I)V

    iget-object v5, p0, Lcom/miaozhen/mzmonitor/p;->b:Landroid/content/Context;

    invoke-static {v5}, Lcom/miaozhen/mzmonitor/n;->a(Landroid/content/Context;)Lcom/miaozhen/mzmonitor/n;

    move-result-object v5

    iget-object v6, p0, Lcom/miaozhen/mzmonitor/p;->a:Lcom/miaozhen/mzmonitor/b;

    invoke-virtual {v6}, Lcom/miaozhen/mzmonitor/b;->a()Ljava/lang/String;

    move-result-object v6

    invoke-virtual {v5, v6, v4}, Lcom/miaozhen/mzmonitor/n;->a(Ljava/lang/String;Lcom/miaozhen/mzmonitor/g;)V

    :cond_1
    const-string v4, "Location"

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

    move-result-object v4

    move-object v2, v4

    goto :goto_0

    :cond_2
    sget-boolean v4, Lcom/miaozhen/mzmonitor/MZMonitor;->a:Z

    if-eqz v4, :cond_3

    const-string v4, "MZSDK:20180108"

    const-string v5, "Failed to send request"

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

    :cond_3
    iget-object v4, p0, Lcom/miaozhen/mzmonitor/p;->a:Lcom/miaozhen/mzmonitor/b;

    invoke-virtual {v0, v4, v1}, Lcom/miaozhen/mzmonitor/c;->a(Lcom/miaozhen/mzmonitor/b;Z)V

    goto :goto_0

    :catchall_0
    move-exception v0

    goto/16 :goto_5

    :catch_0
    move-exception v0

    move-object v1, v2

    move-object v2, v3

    goto :goto_1

    :catch_1
    move-exception v4

    move-object v8, v3

    move-object v3, v2

    move-object v2, v8

    goto :goto_3

    :cond_4
    :goto_0
    iget-object v4, p0, Lcom/miaozhen/mzmonitor/p;->b:Landroid/content/Context;

    invoke-static {v4}, Lcom/miaozhen/mzmonitor/s;->k(Landroid/content/Context;)Z

    move-result v4

    if-eqz v4, :cond_5

    iget-object v4, p0, Lcom/miaozhen/mzmonitor/p;->b:Landroid/content/Context;

    invoke-static {v4}, Lcom/miaozhen/mzmonitor/MZLocationManager;->a(Landroid/content/Context;)Lcom/miaozhen/mzmonitor/MZLocationManager;

    move-result-object v4

    iget-object v5, p0, Lcom/miaozhen/mzmonitor/p;->b:Landroid/content/Context;

    invoke-virtual {v4, v5}, Lcom/miaozhen/mzmonitor/MZLocationManager;->b(Landroid/content/Context;)V
    :try_end_1
    .catch Ljava/io/IOException; {:try_start_1 .. :try_end_1} :catch_1
    .catch Ljava/lang/NullPointerException; {:try_start_1 .. :try_end_1} :catch_0
    .catchall {:try_start_1 .. :try_end_1} :catchall_0

    :cond_5
    invoke-direct {p0, v2}, Lcom/miaozhen/mzmonitor/p;->a(Ljava/lang/String;)V

    if-eqz v3, :cond_8

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

    goto :goto_4

    :catchall_1
    move-exception v0

    move-object v3, v2

    goto/16 :goto_5

    :catch_2
    move-exception v0

    move-object v1, v2

    :goto_1
    :try_start_2
    invoke-virtual {v0}, Ljava/lang/NullPointerException;->printStackTrace()V

    sget-boolean v0, Lcom/miaozhen/mzmonitor/MZMonitor;->a:Z

    if-eqz v0, :cond_6

    const-string v0, "MZSDK:20180108"

    new-instance v3, Ljava/lang/StringBuilder;

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

    const-string v4, "NullPointerException Error:"

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

    iget-object v4, p0, Lcom/miaozhen/mzmonitor/p;->a:Lcom/miaozhen/mzmonitor/b;

    invoke-virtual {v4}, Lcom/miaozhen/mzmonitor/b;->a()Ljava/lang/String;

    move-result-object v4

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

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

    move-result-object v3

    invoke-static {v0, v3}, Landroid/util/Log;->d(Ljava/lang/String;Ljava/lang/String;)I
    :try_end_2
    .catchall {:try_start_2 .. :try_end_2} :catchall_2

    :cond_6
    invoke-direct {p0, v1}, Lcom/miaozhen/mzmonitor/p;->a(Ljava/lang/String;)V

    if-eqz v2, :cond_8

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

    goto :goto_4

    :catchall_2
    move-exception v0

    move-object v3, v2

    move-object v2, v1

    goto :goto_5

    :catch_3
    move-exception v4

    move-object v3, v2

    :goto_3
    :try_start_3
    invoke-virtual {v4}, Ljava/io/IOException;->printStackTrace()V

    sget-boolean v5, Lcom/miaozhen/mzmonitor/MZMonitor;->a:Z

    if-eqz v5, :cond_7

    const-string v5, "MZSDK:20180108"

    new-instance v6, Ljava/lang/StringBuilder;

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

    const-string v7, "Connection Error:"

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

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

    move-result-object v4

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

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

    move-result-object v4

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

    :cond_7
    iget-object v4, p0, Lcom/miaozhen/mzmonitor/p;->a:Lcom/miaozhen/mzmonitor/b;

    invoke-virtual {v0, v4, v1}, Lcom/miaozhen/mzmonitor/c;->a(Lcom/miaozhen/mzmonitor/b;Z)V
    :try_end_3
    .catchall {:try_start_3 .. :try_end_3} :catchall_3

    invoke-direct {p0, v3}, Lcom/miaozhen/mzmonitor/p;->a(Ljava/lang/String;)V

    if-eqz v2, :cond_8

    goto :goto_2

    :cond_8
    :goto_4
    return-void

    :catchall_3
    move-exception v0

    move-object v8, v3

    move-object v3, v2

    move-object v2, v8

    :goto_5
    invoke-direct {p0, v2}, Lcom/miaozhen/mzmonitor/p;->a(Ljava/lang/String;)V

    if-eqz v3, :cond_9

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

    :cond_9
    throw v0
.end method
