bi.smali

.class final Lcom/baidu/techain/af/bi;
.super Ljava/lang/Object;


# direct methods
.method public static a(Landroid/content/Context;)Ljava/lang/String;
    .registers 3

    const/4 v0, 0x0

    :try_start_1
    invoke-static {p0}, Lcom/baidu/techain/af/bi;->d(Landroid/content/Context;)Landroid/net/DhcpInfo;

    move-result-object v1

    if-nez v1, :cond_8

    :goto_7
    return-object v0

    :cond_8
    iget v1, v1, Landroid/net/DhcpInfo;->gateway:I

    invoke-static {v1}, Lcom/baidu/techain/af/bi;->a(I)Ljava/net/InetAddress;

    move-result-object v1

    invoke-virtual {v1}, Ljava/net/InetAddress;->getHostAddress()Ljava/lang/String;
    :try_end_11
    .catch Ljava/lang/Exception; {:try_start_1 .. :try_end_11} :catch_13

    move-result-object v0

    goto :goto_7

    :catch_13
    move-exception v1

    goto :goto_7
.end method

.method public static a(Landroid/content/Context;I)Ljava/lang/String;
    .registers 8

    .prologue
    const/4 v5, 0x1

    const/4 v1, 0x0

    .line 0
    :try_start_2
    const-string v0, "wifi"

    invoke-virtual {p0, v0}, Landroid/content/Context;->getSystemService(Ljava/lang/String;)Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Landroid/net/wifi/WifiManager;

    if-eqz v0, :cond_12

    invoke-virtual {v0}, Landroid/net/wifi/WifiManager;->isWifiEnabled()Z
    :try_end_f
    .catch Ljava/lang/Exception; {:try_start_2 .. :try_end_f} :catch_5f

    move-result v2

    if-nez v2, :cond_13

    .line 1000
    :cond_12
    :goto_12
    return-object v1

    .line 0
    :cond_13
    :try_start_13
    invoke-virtual {p0}, Landroid/content/Context;->getPackageManager()Landroid/content/pm/PackageManager;

    move-result-object v2

    const-string v3, "android.permission.ACCESS_WIFI_STATE"

    invoke-virtual {p0}, Landroid/content/Context;->getPackageName()Ljava/lang/String;

    move-result-object v4

    invoke-virtual {v2, v3, v4}, Landroid/content/pm/PackageManager;->checkPermission(Ljava/lang/String;Ljava/lang/String;)I

    move-result v2

    if-nez v2, :cond_31

    invoke-virtual {v0}, Landroid/net/wifi/WifiManager;->getConnectionInfo()Landroid/net/wifi/WifiInfo;
    :try_end_26
    .catch Ljava/lang/Exception; {:try_start_13 .. :try_end_26} :catch_30

    move-result-object v0

    :goto_27
    if-eqz v0, :cond_12

    if-nez p1, :cond_33

    :try_start_2b
    invoke-virtual {v0}, Landroid/net/wifi/WifiInfo;->getMacAddress()Ljava/lang/String;

    move-result-object v1

    goto :goto_12

    :catch_30
    move-exception v0

    :cond_31
    move-object v0, v1

    goto :goto_27

    :cond_33
    if-ne p1, v5, :cond_3a

    invoke-virtual {v0}, Landroid/net/wifi/WifiInfo;->getBSSID()Ljava/lang/String;

    move-result-object v1

    goto :goto_12

    :cond_3a
    const/4 v2, 0x2

    if-ne p1, v2, :cond_12

    invoke-virtual {v0}, Landroid/net/wifi/WifiInfo;->getSSID()Ljava/lang/String;

    move-result-object v0

    .line 1000
    const-string v2, "\""

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

    move-result v2

    if-eqz v2, :cond_5d

    const-string v2, "\""

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

    move-result v2

    if-eqz v2, :cond_5d

    const/4 v2, 0x1

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

    move-result v3

    add-int/lit8 v3, v3, -0x1

    invoke-virtual {v0, v2, v3}, Ljava/lang/String;->substring(II)Ljava/lang/String;
    :try_end_5b
    .catch Ljava/lang/Exception; {:try_start_2b .. :try_end_5b} :catch_5f

    move-result-object v1

    goto :goto_12

    :cond_5d
    move-object v1, v0

    .line 0
    goto :goto_12

    :catch_5f
    move-exception v0

    goto :goto_12
.end method

.method private static a(I)Ljava/net/InetAddress;
    .registers 4

    const/4 v0, 0x4

    new-array v0, v0, [B

    const/4 v1, 0x0

    and-int/lit16 v2, p0, 0xff

    int-to-byte v2, v2

    aput-byte v2, v0, v1

    const/4 v1, 0x1

    shr-int/lit8 v2, p0, 0x8

    and-int/lit16 v2, v2, 0xff

    int-to-byte v2, v2

    aput-byte v2, v0, v1

    const/4 v1, 0x2

    shr-int/lit8 v2, p0, 0x10

    and-int/lit16 v2, v2, 0xff

    int-to-byte v2, v2

    aput-byte v2, v0, v1

    const/4 v1, 0x3

    shr-int/lit8 v2, p0, 0x18

    and-int/lit16 v2, v2, 0xff

    int-to-byte v2, v2

    aput-byte v2, v0, v1

    :try_start_21
    invoke-static {v0}, Ljava/net/InetAddress;->getByAddress([B)Ljava/net/InetAddress;
    :try_end_24
    .catch Ljava/net/UnknownHostException; {:try_start_21 .. :try_end_24} :catch_26

    move-result-object v0

    return-object v0

    :catch_26
    move-exception v0

    new-instance v0, Ljava/lang/AssertionError;

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

    throw v0
.end method

.method public static b(Landroid/content/Context;)Ljava/lang/String;
    .registers 3

    const/4 v0, 0x0

    :try_start_1
    invoke-static {p0}, Lcom/baidu/techain/af/bi;->d(Landroid/content/Context;)Landroid/net/DhcpInfo;

    move-result-object v1

    if-nez v1, :cond_8

    :goto_7
    return-object v0

    :cond_8
    iget v1, v1, Landroid/net/DhcpInfo;->serverAddress:I

    invoke-static {v1}, Lcom/baidu/techain/af/bi;->a(I)Ljava/net/InetAddress;

    move-result-object v1

    invoke-virtual {v1}, Ljava/net/InetAddress;->getHostAddress()Ljava/lang/String;
    :try_end_11
    .catch Ljava/lang/Exception; {:try_start_1 .. :try_end_11} :catch_13

    move-result-object v0

    goto :goto_7

    :catch_13
    move-exception v1

    goto :goto_7
.end method

.method public static c(Landroid/content/Context;)Ljava/lang/String;
    .registers 7

    const/4 v0, 0x0

    invoke-static {p0, v0}, Lcom/baidu/techain/af/bi;->a(Landroid/content/Context;I)Ljava/lang/String;

    move-result-object v0

    if-eqz v0, :cond_15

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

    move-result v1

    if-nez v1, :cond_15

    const-string v1, "02:00:00:00:00:00"

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

    move-result v1

    if-eqz v1, :cond_35

    :cond_15
    const/4 v2, 0x0

    const/16 v1, 0x400

    :try_start_18
    new-array v3, v1, [C

    new-instance v1, Ljava/io/FileReader;

    const-string v4, "/sys/class/net/wlan0/address"

    invoke-direct {v1, v4}, Ljava/io/FileReader;-><init>(Ljava/lang/String;)V
    :try_end_21
    .catch Ljava/io/FileNotFoundException; {:try_start_18 .. :try_end_21} :catch_36
    .catch Ljava/lang/Exception; {:try_start_18 .. :try_end_21} :catch_40
    .catchall {:try_start_18 .. :try_end_21} :catchall_4a

    const/4 v2, 0x0

    const/16 v4, 0x400

    :try_start_24
    invoke-virtual {v1, v3, v2, v4}, Ljava/io/FileReader;->read([CII)I

    move-result v2

    new-instance v4, Ljava/lang/String;

    const/4 v5, 0x0

    invoke-direct {v4, v3, v5, v2}, Ljava/lang/String;-><init>([CII)V

    invoke-virtual {v4}, Ljava/lang/String;->trim()Ljava/lang/String;
    :try_end_31
    .catch Ljava/io/FileNotFoundException; {:try_start_24 .. :try_end_31} :catch_5a
    .catch Ljava/lang/Exception; {:try_start_24 .. :try_end_31} :catch_58
    .catchall {:try_start_24 .. :try_end_31} :catchall_56

    move-result-object v0

    :try_start_32
    invoke-virtual {v1}, Ljava/io/FileReader;->close()V
    :try_end_35
    .catch Ljava/lang/Exception; {:try_start_32 .. :try_end_35} :catch_52

    :cond_35
    :goto_35
    return-object v0

    :catch_36
    move-exception v1

    move-object v1, v2

    :goto_38
    if-eqz v1, :cond_35

    :try_start_3a
    invoke-virtual {v1}, Ljava/io/FileReader;->close()V
    :try_end_3d
    .catch Ljava/lang/Exception; {:try_start_3a .. :try_end_3d} :catch_3e

    goto :goto_35

    :catch_3e
    move-exception v1

    goto :goto_35

    :catch_40
    move-exception v1

    move-object v1, v2

    :goto_42
    if-eqz v1, :cond_35

    :try_start_44
    invoke-virtual {v1}, Ljava/io/FileReader;->close()V
    :try_end_47
    .catch Ljava/lang/Exception; {:try_start_44 .. :try_end_47} :catch_48

    goto :goto_35

    :catch_48
    move-exception v1

    goto :goto_35

    :catchall_4a
    move-exception v0

    move-object v1, v2

    :goto_4c
    if-eqz v1, :cond_51

    :try_start_4e
    invoke-virtual {v1}, Ljava/io/FileReader;->close()V
    :try_end_51
    .catch Ljava/lang/Exception; {:try_start_4e .. :try_end_51} :catch_54

    :cond_51
    :goto_51
    throw v0

    :catch_52
    move-exception v1

    goto :goto_35

    :catch_54
    move-exception v1

    goto :goto_51

    :catchall_56
    move-exception v0

    goto :goto_4c

    :catch_58
    move-exception v2

    goto :goto_42

    :catch_5a
    move-exception v2

    goto :goto_38
.end method

.method private static d(Landroid/content/Context;)Landroid/net/DhcpInfo;
    .registers 6

    const/4 v1, 0x0

    if-nez p0, :cond_4

    :cond_3
    :goto_3
    return-object v1

    :cond_4
    const-string v0, "wifi"

    invoke-virtual {p0, v0}, Landroid/content/Context;->getSystemService(Ljava/lang/String;)Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Landroid/net/wifi/WifiManager;

    if-eqz v0, :cond_3

    invoke-virtual {v0}, Landroid/net/wifi/WifiManager;->isWifiEnabled()Z

    move-result v2

    if-eqz v2, :cond_3

    :try_start_14
    invoke-virtual {p0}, Landroid/content/Context;->getPackageManager()Landroid/content/pm/PackageManager;

    move-result-object v2

    const-string v3, "android.permission.ACCESS_WIFI_STATE"

    invoke-virtual {p0}, Landroid/content/Context;->getPackageName()Ljava/lang/String;

    move-result-object v4

    invoke-virtual {v2, v3, v4}, Landroid/content/pm/PackageManager;->checkPermission(Ljava/lang/String;Ljava/lang/String;)I

    move-result v2

    if-nez v2, :cond_2b

    invoke-virtual {v0}, Landroid/net/wifi/WifiManager;->getDhcpInfo()Landroid/net/DhcpInfo;
    :try_end_27
    .catch Ljava/lang/Exception; {:try_start_14 .. :try_end_27} :catch_2a

    move-result-object v0

    :goto_28
    move-object v1, v0

    goto :goto_3

    :catch_2a
    move-exception v0

    :cond_2b
    move-object v0, v1

    goto :goto_28
.end method