Network.smali

.class public final Lcom/qiniu/android/dns/Network;
.super Ljava/lang/Object;
.source "Network.java"


# static fields
.field private static previousIp:Ljava/lang/String;


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

    .line 11
    const-string v0, ""

    sput-object v0, Lcom/qiniu/android/dns/Network;->previousIp:Ljava/lang/String;

    return-void
.end method

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

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

    return-void
.end method

.method public static getIp()Ljava/lang/String;
    .registers 3

    .line 15
    const/4 v0, 0x0

    .line 17
    .local v0, "socket":Ljava/net/DatagramSocket;
    :try_start_1
    new-instance v1, Ljava/net/DatagramSocket;

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

    move-object v0, v1

    .line 18
    const-string v1, "114.114.114.114"

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

    move-result-object v1

    .line 19
    .local v1, "addr":Ljava/net/InetAddress;
    const/16 v2, 0x35

    invoke-virtual {v0, v1, v2}, Ljava/net/DatagramSocket;->connect(Ljava/net/InetAddress;I)V
    :try_end_12
    .catch Ljava/io/IOException; {:try_start_1 .. :try_end_12} :catch_1f

    .line 23
    .end local v1    # "addr":Ljava/net/InetAddress;
    nop

    .line 25
    invoke-virtual {v0}, Ljava/net/DatagramSocket;->getLocalAddress()Ljava/net/InetAddress;

    move-result-object v1

    .line 26
    .local v1, "local":Ljava/net/InetAddress;
    invoke-virtual {v0}, Ljava/net/DatagramSocket;->close()V

    .line 27
    invoke-virtual {v1}, Ljava/net/InetAddress;->getHostAddress()Ljava/lang/String;

    move-result-object v2

    return-object v2

    .line 20
    .end local v1    # "local":Ljava/net/InetAddress;
    :catch_1f
    move-exception v1

    .line 21
    .local v1, "e":Ljava/io/IOException;
    invoke-virtual {v1}, Ljava/io/IOException;->printStackTrace()V

    .line 22
    const-string v2, ""

    return-object v2
.end method

.method public static declared-synchronized isNetworkChanged()Z
    .registers 3

    const-class v0, Lcom/qiniu/android/dns/Network;

    monitor-enter v0

    .line 32
    :try_start_3
    invoke-static {}, Lcom/qiniu/android/dns/Network;->getIp()Ljava/lang/String;

    move-result-object v1

    .line 33
    .local v1, "nowIp":Ljava/lang/String;
    sget-object v2, Lcom/qiniu/android/dns/Network;->previousIp:Ljava/lang/String;

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

    move-result v2
    :try_end_d
    .catchall {:try_start_3 .. :try_end_d} :catchall_17

    if-eqz v2, :cond_12

    .line 34
    const/4 v2, 0x0

    monitor-exit v0

    return v2

    .line 36
    :cond_12
    :try_start_12
    sput-object v1, Lcom/qiniu/android/dns/Network;->previousIp:Ljava/lang/String;
    :try_end_14
    .catchall {:try_start_12 .. :try_end_14} :catchall_17

    .line 37
    const/4 v2, 0x1

    monitor-exit v0

    return v2

    .line 31
    .end local v1    # "nowIp":Ljava/lang/String;
    :catchall_17
    move-exception v1

    monitor-exit v0

    throw v1
.end method