NetworkUtils.smali

.class public final Lcom/baidu/pass/biometrics/base/utils/NetworkUtils;
.super Ljava/lang/Object;
.source "NetworkUtils.java"


# static fields
.field public static final NETWORK_2G:I = 0x2

.field public static final NETWORK_3G:I = 0x3

.field public static final NETWORK_4G:I = 0x4

.field public static final NETWORK_TYPE_1XRTT:I = 0x7

.field public static final NETWORK_TYPE_CDMA:I = 0x4

.field public static final NETWORK_TYPE_EDGE:I = 0x2

.field public static final NETWORK_TYPE_EHRPD:I = 0xe

.field public static final NETWORK_TYPE_EVDO_0:I = 0x5

.field public static final NETWORK_TYPE_EVDO_A:I = 0x6

.field public static final NETWORK_TYPE_EVDO_B:I = 0xc

.field public static final NETWORK_TYPE_GPRS:I = 0x1

.field public static final NETWORK_TYPE_GSM:I = 0x10

.field public static final NETWORK_TYPE_HSDPA:I = 0x8

.field public static final NETWORK_TYPE_HSPA:I = 0xa

.field public static final NETWORK_TYPE_HSPAP:I = 0xf

.field public static final NETWORK_TYPE_HSUPA:I = 0x9

.field public static final NETWORK_TYPE_IDEN:I = 0xb

.field public static final NETWORK_TYPE_IWLAN:I = 0x12

.field public static final NETWORK_TYPE_LTE:I = 0xd

.field public static final NETWORK_TYPE_TD_SCDMA:I = 0x11

.field public static final NETWORK_TYPE_UMTS:I = 0x3

.field public static final NETWORK_TYPE_UNKNOWN:I = 0x0

.field public static final NETWORK_UNKNOW:I = 0x0

.field public static final NETWORK_WIFI:I = 0x1

.field private static final TAG:Ljava/lang/String; = "NetworkUtils"


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

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

    .line 131
    return-void
.end method

.method public static getConnectedWifi(Landroid/content/Context;)Lorg/json/JSONObject;
    .registers 6

    .prologue
    const/4 v1, 0x0

    .line 278
    if-nez p0, :cond_5

    move-object v0, v1

    .line 297
    :goto_4
    return-object v0

    .line 282
    :cond_5
    :try_start_5
    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;

    .line 283
    if-eqz v0, :cond_15

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

    move-result v2

    if-nez v2, :cond_17

    :cond_15
    move-object v0, v1

    .line 284
    goto :goto_4

    .line 286
    :cond_17
    invoke-virtual {v0}, Landroid/net/wifi/WifiManager;->getConnectionInfo()Landroid/net/wifi/WifiInfo;

    move-result-object v2

    .line 287
    if-eqz v2, :cond_41

    .line 288
    new-instance v0, Lorg/json/JSONObject;

    invoke-direct {v0}, Lorg/json/JSONObject;-><init>()V

    .line 289
    const-string v3, "mac"

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

    move-result-object v4

    invoke-virtual {v0, v3, v4}, Lorg/json/JSONObject;->put(Ljava/lang/String;Ljava/lang/Object;)Lorg/json/JSONObject;

    .line 290
    const-string v3, "rssi"

    invoke-virtual {v2}, Landroid/net/wifi/WifiInfo;->getRssi()I

    move-result v4

    invoke-virtual {v0, v3, v4}, Lorg/json/JSONObject;->put(Ljava/lang/String;I)Lorg/json/JSONObject;

    .line 291
    const-string v3, "ssid"

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

    move-result-object v2

    invoke-virtual {v0, v3, v2}, Lorg/json/JSONObject;->put(Ljava/lang/String;Ljava/lang/Object;)Lorg/json/JSONObject;
    :try_end_3d
    .catch Ljava/lang/Exception; {:try_start_5 .. :try_end_3d} :catch_3e

    goto :goto_4

    .line 294
    :catch_3e
    move-exception v0

    move-object v0, v1

    .line 295
    goto :goto_4

    :cond_41
    move-object v0, v1

    .line 297
    goto :goto_4
.end method

.method public static getNetworkClass(Landroid/content/Context;)Ljava/lang/String;
    .registers 4
    .annotation build Landroid/annotation/TargetApi;
        value = 0x3
    .end annotation

    .prologue
    .line 188
    :try_start_0
    const-string v0, "connectivity"

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

    move-result-object v0

    check-cast v0, Landroid/net/ConnectivityManager;

    .line 189
    invoke-virtual {v0}, Landroid/net/ConnectivityManager;->getActiveNetworkInfo()Landroid/net/NetworkInfo;

    move-result-object v0

    .line 190
    if-eqz v0, :cond_14

    invoke-virtual {v0}, Landroid/net/NetworkInfo;->isConnected()Z

    move-result v1

    if-nez v1, :cond_17

    .line 191
    :cond_14
    const-string v0, "UNCNCT"

    .line 224
    :goto_16
    return-object v0

    .line 193
    :cond_17
    invoke-virtual {v0}, Landroid/net/NetworkInfo;->getType()I

    move-result v1

    const/4 v2, 0x1

    if-ne v1, v2, :cond_21

    .line 194
    const-string v0, "WIFI"

    goto :goto_16

    .line 196
    :cond_21
    invoke-virtual {v0}, Landroid/net/NetworkInfo;->getType()I

    move-result v1

    if-nez v1, :cond_3b

    .line 197
    invoke-virtual {v0}, Landroid/net/NetworkInfo;->getSubtype()I

    move-result v0

    .line 198
    packed-switch v0, :pswitch_data_3e

    .line 218
    const-string v0, "UNKNOWN"

    goto :goto_16

    .line 204
    :pswitch_31
    const-string v0, "2G"

    goto :goto_16

    .line 214
    :pswitch_34
    const-string v0, "3G"

    goto :goto_16

    .line 216
    :pswitch_37
    const-string v0, "4G"
    :try_end_39
    .catch Ljava/lang/Throwable; {:try_start_0 .. :try_end_39} :catch_3a

    goto :goto_16

    .line 221
    :catch_3a
    move-exception v0

    .line 224
    :cond_3b
    const-string v0, "UNKNOWN"

    goto :goto_16

    .line 198
    :pswitch_data_3e
    .packed-switch 0x1
        :pswitch_31
        :pswitch_31
        :pswitch_34
        :pswitch_31
        :pswitch_34
        :pswitch_34
        :pswitch_31
        :pswitch_34
        :pswitch_34
        :pswitch_34
        :pswitch_31
        :pswitch_34
        :pswitch_37
        :pswitch_34
        :pswitch_34
    .end packed-switch
.end method

.method public static getNetworkType(Landroid/content/Context;)I
    .registers 3

    .prologue
    const/4 v1, 0x0

    .line 235
    invoke-static {p0}, Lcom/baidu/pass/biometrics/base/utils/NetworkUtils;->isWifiNetworkAvailable(Landroid/content/Context;)Z

    move-result v0

    if-eqz v0, :cond_9

    .line 236
    const/4 v0, 0x1

    .line 269
    :goto_8
    return v0

    .line 238
    :cond_9
    const-string v0, "phone"

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

    move-result-object v0

    check-cast v0, Landroid/telephony/TelephonyManager;

    .line 239
    if-eqz v0, :cond_22

    .line 240
    invoke-virtual {v0}, Landroid/telephony/TelephonyManager;->getNetworkType()I

    move-result v0

    packed-switch v0, :pswitch_data_24

    move v0, v1

    .line 265
    goto :goto_8

    .line 251
    :pswitch_1c
    const/4 v0, 0x3

    goto :goto_8

    .line 259
    :pswitch_1e
    const/4 v0, 0x2

    goto :goto_8

    .line 263
    :pswitch_20
    const/4 v0, 0x4

    goto :goto_8

    :cond_22
    move v0, v1

    .line 269
    goto :goto_8

    .line 240
    :pswitch_data_24
    .packed-switch 0x1
        :pswitch_1e
        :pswitch_1e
        :pswitch_1c
        :pswitch_1e
        :pswitch_1c
        :pswitch_1c
        :pswitch_1e
        :pswitch_1c
        :pswitch_1c
        :pswitch_1c
        :pswitch_1e
        :pswitch_1c
        :pswitch_20
        :pswitch_1c
        :pswitch_1c
        :pswitch_1e
        :pswitch_1c
        :pswitch_20
    .end packed-switch
.end method

.method public static isNetworkAvailable(Landroid/content/Context;)Z
    .registers 3

    .prologue
    const/4 v1, 0x0

    .line 140
    if-nez p0, :cond_5

    move v0, v1

    .line 153
    :goto_4
    return v0

    .line 143
    :cond_5
    const-string v0, "connectivity"

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

    move-result-object v0

    check-cast v0, Landroid/net/ConnectivityManager;

    .line 144
    if-nez v0, :cond_11

    move v0, v1

    .line 145
    goto :goto_4

    .line 148
    :cond_11
    invoke-virtual {v0}, Landroid/net/ConnectivityManager;->getActiveNetworkInfo()Landroid/net/NetworkInfo;

    move-result-object v0

    .line 149
    if-eqz v0, :cond_1d

    invoke-virtual {v0}, Landroid/net/NetworkInfo;->isAvailable()Z

    move-result v0

    if-nez v0, :cond_1f

    :cond_1d
    move v0, v1

    .line 150
    goto :goto_4

    .line 153
    :cond_1f
    const/4 v0, 0x1

    goto :goto_4
.end method

.method public static isWifiNetworkAvailable(Landroid/content/Context;)Z
    .registers 5

    .prologue
    const/4 v1, 0x1

    const/4 v2, 0x0

    .line 164
    const-string v0, "connectivity"

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

    move-result-object v0

    check-cast v0, Landroid/net/ConnectivityManager;

    .line 165
    if-nez v0, :cond_d

    .line 174
    :cond_c
    :goto_c
    return v2

    .line 169
    :cond_d
    invoke-virtual {v0}, Landroid/net/ConnectivityManager;->getActiveNetworkInfo()Landroid/net/NetworkInfo;

    move-result-object v0

    .line 170
    if-eqz v0, :cond_c

    invoke-virtual {v0}, Landroid/net/NetworkInfo;->isConnected()Z

    move-result v3

    if-eqz v3, :cond_c

    .line 174
    invoke-virtual {v0}, Landroid/net/NetworkInfo;->getType()I

    move-result v0

    if-ne v0, v1, :cond_22

    move v0, v1

    :goto_20
    move v2, v0

    goto :goto_c

    :cond_22
    move v0, v2

    goto :goto_20
.end method