c.smali

.class public abstract Lcom/reactnativecommunity/netinfo/c;
.super Ljava/lang/Object;
.source "SourceFile"


# instance fields
.field public final a:Landroid/net/ConnectivityManager;

.field public final b:Landroid/net/wifi/WifiManager;

.field public final c:Landroid/telephony/TelephonyManager;

.field public final d:Lcom/facebook/react/bridge/ReactApplicationContext;

.field public e:Lcom/reactnativecommunity/netinfo/types/b;

.field public f:Lcom/reactnativecommunity/netinfo/types/a;

.field public g:Z

.field public h:Ljava/lang/Boolean;


# direct methods
.method public constructor <init>(Lcom/facebook/react/bridge/ReactApplicationContext;)V
    .registers 4

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

    .line 2
    sget-object v0, Lcom/reactnativecommunity/netinfo/types/b;->UNKNOWN:Lcom/reactnativecommunity/netinfo/types/b;

    iput-object v0, p0, Lcom/reactnativecommunity/netinfo/c;->e:Lcom/reactnativecommunity/netinfo/types/b;

    const/4 v0, 0x0

    .line 3
    iput-object v0, p0, Lcom/reactnativecommunity/netinfo/c;->f:Lcom/reactnativecommunity/netinfo/types/a;

    const/4 v0, 0x0

    .line 4
    iput-boolean v0, p0, Lcom/reactnativecommunity/netinfo/c;->g:Z

    .line 5
    iput-object p1, p0, Lcom/reactnativecommunity/netinfo/c;->d:Lcom/facebook/react/bridge/ReactApplicationContext;

    const-string v0, "connectivity"

    .line 6
    invoke-virtual {p1, v0}, Lcom/facebook/react/bridge/ReactContext;->getSystemService(Ljava/lang/String;)Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Landroid/net/ConnectivityManager;

    iput-object v0, p0, Lcom/reactnativecommunity/netinfo/c;->a:Landroid/net/ConnectivityManager;

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

    move-result-object v0

    const-string v1, "wifi"

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

    move-result-object v0

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

    iput-object v0, p0, Lcom/reactnativecommunity/netinfo/c;->b:Landroid/net/wifi/WifiManager;

    const-string v0, "phone"

    .line 8
    invoke-virtual {p1, v0}, Lcom/facebook/react/bridge/ReactContext;->getSystemService(Ljava/lang/String;)Ljava/lang/Object;

    move-result-object p1

    check-cast p1, Landroid/telephony/TelephonyManager;

    iput-object p1, p0, Lcom/reactnativecommunity/netinfo/c;->c:Landroid/telephony/TelephonyManager;

    return-void
.end method


# virtual methods
.method public final a()Lcom/facebook/react/bridge/WritableMap;
    .registers 9

    .line 1
    new-instance v0, Lcom/facebook/react/bridge/WritableNativeMap;

    invoke-direct {v0}, Lcom/facebook/react/bridge/WritableNativeMap;-><init>()V

    .line 2
    iget-object v1, p0, Lcom/reactnativecommunity/netinfo/c;->e:Lcom/reactnativecommunity/netinfo/types/b;

    iget-object v1, v1, Lcom/reactnativecommunity/netinfo/types/b;->label:Ljava/lang/String;

    const-string v2, "type"

    invoke-interface {v0, v2, v1}, Lcom/facebook/react/bridge/WritableMap;->putString(Ljava/lang/String;Ljava/lang/String;)V

    .line 3
    iget-object v1, p0, Lcom/reactnativecommunity/netinfo/c;->e:Lcom/reactnativecommunity/netinfo/types/b;

    sget-object v2, Lcom/reactnativecommunity/netinfo/types/b;->NONE:Lcom/reactnativecommunity/netinfo/types/b;

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

    move-result v1

    const/4 v2, 0x0

    const/4 v3, 0x1

    if-nez v1, :cond_26

    iget-object v1, p0, Lcom/reactnativecommunity/netinfo/c;->e:Lcom/reactnativecommunity/netinfo/types/b;

    sget-object v4, Lcom/reactnativecommunity/netinfo/types/b;->UNKNOWN:Lcom/reactnativecommunity/netinfo/types/b;

    .line 5
    invoke-virtual {v1, v4}, Ljava/lang/Object;->equals(Ljava/lang/Object;)Z

    move-result v1

    if-nez v1, :cond_26

    const/4 v1, 0x1

    goto :goto_27

    :cond_26
    const/4 v1, 0x0

    :goto_27
    const-string v4, "isConnected"

    .line 6
    invoke-interface {v0, v4, v1}, Lcom/facebook/react/bridge/WritableMap;->putBoolean(Ljava/lang/String;Z)V

    .line 7
    iget-boolean v4, p0, Lcom/reactnativecommunity/netinfo/c;->g:Z

    const-string v5, "isInternetReachable"

    invoke-interface {v0, v5, v4}, Lcom/facebook/react/bridge/WritableMap;->putBoolean(Ljava/lang/String;Z)V

    const/4 v4, 0x0

    if-eqz v1, :cond_124

    .line 8
    new-instance v4, Lcom/facebook/react/bridge/WritableNativeMap;

    invoke-direct {v4}, Lcom/facebook/react/bridge/WritableNativeMap;-><init>()V

    .line 9
    iget-object v1, p0, Lcom/reactnativecommunity/netinfo/c;->a:Landroid/net/ConnectivityManager;

    .line 10
    invoke-static {v1}, Landroidx/core/net/a;->a(Landroid/net/ConnectivityManager;)Z

    move-result v1

    const-string v5, "isConnectionExpensive"

    .line 11
    invoke-interface {v4, v5, v1}, Lcom/facebook/react/bridge/WritableMap;->putBoolean(Ljava/lang/String;Z)V

    .line 12
    iget-object v1, p0, Lcom/reactnativecommunity/netinfo/c;->e:Lcom/reactnativecommunity/netinfo/types/b;

    sget-object v5, Lcom/reactnativecommunity/netinfo/types/b;->CELLULAR:Lcom/reactnativecommunity/netinfo/types/b;

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

    move-result v1

    if-eqz v1, :cond_6a

    .line 13
    iget-object v1, p0, Lcom/reactnativecommunity/netinfo/c;->f:Lcom/reactnativecommunity/netinfo/types/a;

    if-eqz v1, :cond_5b

    .line 14
    iget-object v1, v1, Lcom/reactnativecommunity/netinfo/types/a;->label:Ljava/lang/String;

    const-string v2, "cellularGeneration"

    invoke-interface {v4, v2, v1}, Lcom/facebook/react/bridge/WritableMap;->putString(Ljava/lang/String;Ljava/lang/String;)V

    .line 15
    :cond_5b
    :try_start_5b
    iget-object v1, p0, Lcom/reactnativecommunity/netinfo/c;->c:Landroid/telephony/TelephonyManager;

    invoke-virtual {v1}, Landroid/telephony/TelephonyManager;->getNetworkOperatorName()Ljava/lang/String;

    move-result-object v1

    if-eqz v1, :cond_124

    const-string v2, "carrier"

    .line 16
    invoke-interface {v4, v2, v1}, Lcom/facebook/react/bridge/WritableMap;->putString(Ljava/lang/String;Ljava/lang/String;)V
    :try_end_68
    .catch Ljava/lang/Exception; {:try_start_5b .. :try_end_68} :catch_124

    goto/16 :goto_124

    .line 17
    :cond_6a
    iget-object v1, p0, Lcom/reactnativecommunity/netinfo/c;->e:Lcom/reactnativecommunity/netinfo/types/b;

    sget-object v5, Lcom/reactnativecommunity/netinfo/types/b;->WIFI:Lcom/reactnativecommunity/netinfo/types/b;

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

    move-result v1

    if-eqz v1, :cond_124

    .line 18
    iget-object v1, p0, Lcom/reactnativecommunity/netinfo/c;->b:Landroid/net/wifi/WifiManager;

    invoke-virtual {v1}, Landroid/net/wifi/WifiManager;->getConnectionInfo()Landroid/net/wifi/WifiInfo;

    move-result-object v1

    if-eqz v1, :cond_124

    .line 19
    :try_start_7c
    invoke-virtual {v1}, Landroid/net/wifi/WifiInfo;->getSSID()Ljava/lang/String;

    move-result-object v5

    if-eqz v5, :cond_97

    const-string v6, "<unknown ssid>"

    .line 20
    invoke-virtual {v5, v6}, Ljava/lang/String;->contains(Ljava/lang/CharSequence;)Z

    move-result v6

    if-nez v6, :cond_97

    const-string v6, "\""

    const-string v7, ""

    .line 21
    invoke-virtual {v5, v6, v7}, Ljava/lang/String;->replace(Ljava/lang/CharSequence;Ljava/lang/CharSequence;)Ljava/lang/String;

    move-result-object v5

    const-string v6, "ssid"

    .line 22
    invoke-interface {v4, v6, v5}, Lcom/facebook/react/bridge/WritableMap;->putString(Ljava/lang/String;Ljava/lang/String;)V
    :try_end_97
    .catch Ljava/lang/Exception; {:try_start_7c .. :try_end_97} :catch_97

    .line 23
    :catch_97
    :cond_97
    :try_start_97
    invoke-virtual {v1}, Landroid/net/wifi/WifiInfo;->getRssi()I

    move-result v5

    const/16 v6, 0x64

    invoke-static {v5, v6}, Landroid/net/wifi/WifiManager;->calculateSignalLevel(II)I

    move-result v5

    const-string v6, "strength"

    .line 24
    invoke-interface {v4, v6, v5}, Lcom/facebook/react/bridge/WritableMap;->putInt(Ljava/lang/String;I)V
    :try_end_a6
    .catch Ljava/lang/Exception; {:try_start_97 .. :try_end_a6} :catch_a6

    .line 25
    :catch_a6
    :try_start_a6
    invoke-virtual {v1}, Landroid/net/wifi/WifiInfo;->getIpAddress()I

    move-result v5

    int-to-long v5, v5

    invoke-static {v5, v6}, Ljava/math/BigInteger;->valueOf(J)Ljava/math/BigInteger;

    move-result-object v5

    invoke-virtual {v5}, Ljava/math/BigInteger;->toByteArray()[B

    move-result-object v5

    .line 26
    invoke-static {v5}, Lcom/google/android/play/core/assetpacks/c1;->f0([B)V

    .line 27
    invoke-static {v5}, Ljava/net/InetAddress;->getByAddress([B)Ljava/net/InetAddress;

    move-result-object v5

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

    move-result-object v5

    const-string v6, "ipAddress"

    .line 29
    invoke-interface {v4, v6, v5}, Lcom/facebook/react/bridge/WritableMap;->putString(Ljava/lang/String;Ljava/lang/String;)V
    :try_end_c3
    .catch Ljava/lang/Exception; {:try_start_a6 .. :try_end_c3} :catch_c3

    .line 30
    :catch_c3
    :try_start_c3
    invoke-virtual {v1}, Landroid/net/wifi/WifiInfo;->getIpAddress()I

    move-result v1

    int-to-long v5, v1

    invoke-static {v5, v6}, Ljava/math/BigInteger;->valueOf(J)Ljava/math/BigInteger;

    move-result-object v1

    invoke-virtual {v1}, Ljava/math/BigInteger;->toByteArray()[B

    move-result-object v1

    .line 31
    invoke-static {v1}, Lcom/google/android/play/core/assetpacks/c1;->f0([B)V

    .line 32
    invoke-static {v1}, Ljava/net/InetAddress;->getByAddress([B)Ljava/net/InetAddress;

    move-result-object v1

    .line 33
    invoke-static {v1}, Ljava/net/NetworkInterface;->getByInetAddress(Ljava/net/InetAddress;)Ljava/net/NetworkInterface;

    move-result-object v1

    const/4 v5, -0x1

    .line 34
    invoke-virtual {v1}, Ljava/net/NetworkInterface;->getInterfaceAddresses()Ljava/util/List;

    move-result-object v1

    invoke-interface {v1, v3}, Ljava/util/List;->get(I)Ljava/lang/Object;

    move-result-object v1

    check-cast v1, Ljava/net/InterfaceAddress;

    invoke-virtual {v1}, Ljava/net/InterfaceAddress;->getNetworkPrefixLength()S

    move-result v1

    rsub-int/lit8 v1, v1, 0x20

    shl-int v1, v5, v1

    const-string v5, "%d.%d.%d.%d"

    const/4 v6, 0x4

    new-array v6, v6, [Ljava/lang/Object;

    shr-int/lit8 v7, v1, 0x18

    and-int/lit16 v7, v7, 0xff

    .line 35
    invoke-static {v7}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;

    move-result-object v7

    aput-object v7, v6, v2

    shr-int/lit8 v2, v1, 0x10

    and-int/lit16 v2, v2, 0xff

    invoke-static {v2}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;

    move-result-object v2

    aput-object v2, v6, v3

    const/4 v2, 0x2

    shr-int/lit8 v3, v1, 0x8

    and-int/lit16 v3, v3, 0xff

    invoke-static {v3}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;

    move-result-object v3

    aput-object v3, v6, v2

    const/4 v2, 0x3

    and-int/lit16 v1, v1, 0xff

    invoke-static {v1}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;

    move-result-object v1

    aput-object v1, v6, v2

    invoke-static {v5, v6}, Ljava/lang/String;->format(Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;

    move-result-object v1

    const-string v2, "subnet"

    .line 36
    invoke-interface {v4, v2, v1}, Lcom/facebook/react/bridge/WritableMap;->putString(Ljava/lang/String;Ljava/lang/String;)V
    :try_end_124
    .catch Ljava/lang/Exception; {:try_start_c3 .. :try_end_124} :catch_124

    :catch_124
    :cond_124
    :goto_124
    const-string v1, "details"

    .line 37
    invoke-interface {v0, v1, v4}, Lcom/facebook/react/bridge/WritableMap;->putMap(Ljava/lang/String;Lcom/facebook/react/bridge/ReadableMap;)V

    return-object v0
.end method

.method public abstract b()V
.end method

.method public abstract c()V
.end method

.method public final d(Lcom/reactnativecommunity/netinfo/types/b;Lcom/reactnativecommunity/netinfo/types/a;Z)V
    .registers 9

    .line 1
    iget-object v0, p0, Lcom/reactnativecommunity/netinfo/c;->h:Ljava/lang/Boolean;

    if-nez v0, :cond_5

    goto :goto_9

    .line 2
    :cond_5
    invoke-virtual {v0}, Ljava/lang/Boolean;->booleanValue()Z

    move-result p3

    .line 3
    :goto_9
    iget-object v0, p0, Lcom/reactnativecommunity/netinfo/c;->e:Lcom/reactnativecommunity/netinfo/types/b;

    const/4 v1, 0x1

    const/4 v2, 0x0

    if-eq p1, v0, :cond_11

    const/4 v0, 0x1

    goto :goto_12

    :cond_11
    const/4 v0, 0x0

    .line 4
    :goto_12
    iget-object v3, p0, Lcom/reactnativecommunity/netinfo/c;->f:Lcom/reactnativecommunity/netinfo/types/a;

    if-eq p2, v3, :cond_18

    const/4 v3, 0x1

    goto :goto_19

    :cond_18
    const/4 v3, 0x0

    .line 5
    :goto_19
    iget-boolean v4, p0, Lcom/reactnativecommunity/netinfo/c;->g:Z

    if-eq p3, v4, :cond_1e

    goto :goto_1f

    :cond_1e
    const/4 v1, 0x0

    :goto_1f
    if-nez v0, :cond_25

    if-nez v3, :cond_25

    if-eqz v1, :cond_3e

    .line 6
    :cond_25
    iput-object p1, p0, Lcom/reactnativecommunity/netinfo/c;->e:Lcom/reactnativecommunity/netinfo/types/b;

    .line 7
    iput-object p2, p0, Lcom/reactnativecommunity/netinfo/c;->f:Lcom/reactnativecommunity/netinfo/types/a;

    .line 8
    iput-boolean p3, p0, Lcom/reactnativecommunity/netinfo/c;->g:Z

    .line 9
    iget-object p1, p0, Lcom/reactnativecommunity/netinfo/c;->d:Lcom/facebook/react/bridge/ReactApplicationContext;

    .line 10
    const-class p2, Lcom/facebook/react/modules/core/DeviceEventManagerModule$RCTDeviceEventEmitter;

    .line 11
    invoke-virtual {p1, p2}, Lcom/facebook/react/bridge/ReactContext;->getJSModule(Ljava/lang/Class;)Lcom/facebook/react/bridge/JavaScriptModule;

    move-result-object p1

    check-cast p1, Lcom/facebook/react/modules/core/DeviceEventManagerModule$RCTDeviceEventEmitter;

    .line 12
    invoke-virtual {p0}, Lcom/reactnativecommunity/netinfo/c;->a()Lcom/facebook/react/bridge/WritableMap;

    move-result-object p2

    const-string p3, "netInfo.networkStatusDidChange"

    invoke-interface {p1, p3, p2}, Lcom/facebook/react/modules/core/DeviceEventManagerModule$RCTDeviceEventEmitter;->emit(Ljava/lang/String;Ljava/lang/Object;)V

    :cond_3e
    return-void
.end method