187 lines
5.6 KiB
Smali
187 lines
5.6 KiB
Smali
.class public final Lcom/discord/utilities/networking/NetworkMonitor;
|
|
.super Ljava/lang/Object;
|
|
.source "NetworkMonitor.kt"
|
|
|
|
|
|
# instance fields
|
|
.field public final isConnectedSubject:Lrx/subjects/BehaviorSubject;
|
|
.annotation system Ldalvik/annotation/Signature;
|
|
value = {
|
|
"Lrx/subjects/BehaviorSubject<",
|
|
"Ljava/lang/Boolean;",
|
|
">;"
|
|
}
|
|
.end annotation
|
|
.end field
|
|
|
|
|
|
# direct methods
|
|
.method public constructor <init>(Landroid/content/Context;)V
|
|
.locals 1
|
|
|
|
if-eqz p1, :cond_0
|
|
|
|
invoke-direct {p0}, Ljava/lang/Object;-><init>()V
|
|
|
|
sget-object v0, Ljava/lang/Boolean;->FALSE:Ljava/lang/Boolean;
|
|
|
|
invoke-static {v0}, Lrx/subjects/BehaviorSubject;->h0(Ljava/lang/Object;)Lrx/subjects/BehaviorSubject;
|
|
|
|
move-result-object v0
|
|
|
|
iput-object v0, p0, Lcom/discord/utilities/networking/NetworkMonitor;->isConnectedSubject:Lrx/subjects/BehaviorSubject;
|
|
|
|
invoke-direct {p0, p1}, Lcom/discord/utilities/networking/NetworkMonitor;->registerConnectivityNetworkMonitor(Landroid/content/Context;)V
|
|
|
|
invoke-direct {p0, p1}, Lcom/discord/utilities/networking/NetworkMonitor;->isDeviceConnected(Landroid/content/Context;)V
|
|
|
|
return-void
|
|
|
|
:cond_0
|
|
const-string p1, "context"
|
|
|
|
invoke-static {p1}, Lj0/n/c/h;->c(Ljava/lang/String;)V
|
|
|
|
const/4 p1, 0x0
|
|
|
|
throw p1
|
|
.end method
|
|
|
|
.method public static final synthetic access$isDeviceConnected(Lcom/discord/utilities/networking/NetworkMonitor;Landroid/content/Context;)V
|
|
.locals 0
|
|
|
|
invoke-direct {p0, p1}, Lcom/discord/utilities/networking/NetworkMonitor;->isDeviceConnected(Landroid/content/Context;)V
|
|
|
|
return-void
|
|
.end method
|
|
|
|
.method private final isDeviceConnected(Landroid/content/Context;)V
|
|
.locals 2
|
|
|
|
iget-object v0, p0, Lcom/discord/utilities/networking/NetworkMonitor;->isConnectedSubject:Lrx/subjects/BehaviorSubject;
|
|
|
|
sget-object v1, Lcom/discord/utilities/io/NetworkUtils;->INSTANCE:Lcom/discord/utilities/io/NetworkUtils;
|
|
|
|
invoke-virtual {v1, p1}, Lcom/discord/utilities/io/NetworkUtils;->isDeviceConnected(Landroid/content/Context;)Z
|
|
|
|
move-result p1
|
|
|
|
invoke-static {p1}, Ljava/lang/Boolean;->valueOf(Z)Ljava/lang/Boolean;
|
|
|
|
move-result-object p1
|
|
|
|
invoke-virtual {v0, p1}, Lrx/subjects/BehaviorSubject;->onNext(Ljava/lang/Object;)V
|
|
|
|
return-void
|
|
.end method
|
|
|
|
.method private final registerConnectivityNetworkMonitor(Landroid/content/Context;)V
|
|
.locals 3
|
|
|
|
const-string v0, "connectivity"
|
|
|
|
invoke-virtual {p1, v0}, Landroid/content/Context;->getSystemService(Ljava/lang/String;)Ljava/lang/Object;
|
|
|
|
move-result-object v0
|
|
|
|
instance-of v1, v0, Landroid/net/ConnectivityManager;
|
|
|
|
if-nez v1, :cond_0
|
|
|
|
const/4 v0, 0x0
|
|
|
|
:cond_0
|
|
check-cast v0, Landroid/net/ConnectivityManager;
|
|
|
|
if-eqz v0, :cond_1
|
|
|
|
new-instance v1, Landroid/net/NetworkRequest$Builder;
|
|
|
|
invoke-direct {v1}, Landroid/net/NetworkRequest$Builder;-><init>()V
|
|
|
|
invoke-virtual {v1}, Landroid/net/NetworkRequest$Builder;->build()Landroid/net/NetworkRequest;
|
|
|
|
move-result-object v1
|
|
|
|
new-instance v2, Lcom/discord/utilities/networking/NetworkMonitor$registerConnectivityNetworkMonitor$1;
|
|
|
|
invoke-direct {v2, p0, p1}, Lcom/discord/utilities/networking/NetworkMonitor$registerConnectivityNetworkMonitor$1;-><init>(Lcom/discord/utilities/networking/NetworkMonitor;Landroid/content/Context;)V
|
|
|
|
invoke-virtual {v0, v1, v2}, Landroid/net/ConnectivityManager;->registerNetworkCallback(Landroid/net/NetworkRequest;Landroid/net/ConnectivityManager$NetworkCallback;)V
|
|
|
|
:cond_1
|
|
return-void
|
|
.end method
|
|
|
|
|
|
# virtual methods
|
|
.method public final getIsConnected()Lrx/Observable;
|
|
.locals 2
|
|
.annotation system Ldalvik/annotation/Signature;
|
|
value = {
|
|
"()",
|
|
"Lrx/Observable<",
|
|
"Ljava/lang/Boolean;",
|
|
">;"
|
|
}
|
|
.end annotation
|
|
|
|
iget-object v0, p0, Lcom/discord/utilities/networking/NetworkMonitor;->isConnectedSubject:Lrx/subjects/BehaviorSubject;
|
|
|
|
invoke-virtual {v0}, Lrx/Observable;->q()Lrx/Observable;
|
|
|
|
move-result-object v0
|
|
|
|
const-string v1, "isConnectedSubject.distinctUntilChanged()"
|
|
|
|
invoke-static {v0, v1}, Lj0/n/c/h;->checkExpressionValueIsNotNull(Ljava/lang/Object;Ljava/lang/String;)V
|
|
|
|
return-object v0
|
|
.end method
|
|
|
|
.method public final isStablyConnected()Lrx/Observable;
|
|
.locals 3
|
|
.annotation system Ldalvik/annotation/Signature;
|
|
value = {
|
|
"()",
|
|
"Lrx/Observable<",
|
|
"Ljava/lang/Boolean;",
|
|
">;"
|
|
}
|
|
.end annotation
|
|
|
|
invoke-virtual {p0}, Lcom/discord/utilities/networking/NetworkMonitor;->getIsConnected()Lrx/Observable;
|
|
|
|
move-result-object v0
|
|
|
|
const/4 v1, 0x1
|
|
|
|
invoke-virtual {v0, v1}, Lrx/Observable;->V(I)Lrx/Observable;
|
|
|
|
move-result-object v0
|
|
|
|
invoke-virtual {p0}, Lcom/discord/utilities/networking/NetworkMonitor;->getIsConnected()Lrx/Observable;
|
|
|
|
move-result-object v1
|
|
|
|
sget-object v2, Lcom/discord/utilities/networking/NetworkMonitor$isStablyConnected$1;->INSTANCE:Lcom/discord/utilities/networking/NetworkMonitor$isStablyConnected$1;
|
|
|
|
invoke-virtual {v1, v2}, Lrx/Observable;->U(Lr0/k/b;)Lrx/Observable;
|
|
|
|
move-result-object v1
|
|
|
|
invoke-static {v0, v1}, Lrx/Observable;->m(Lrx/Observable;Lrx/Observable;)Lrx/Observable;
|
|
|
|
move-result-object v0
|
|
|
|
invoke-virtual {v0}, Lrx/Observable;->q()Lrx/Observable;
|
|
|
|
move-result-object v0
|
|
|
|
const-string v1, "Observable.concat(\n \u2026 .distinctUntilChanged()"
|
|
|
|
invoke-static {v0, v1}, Lj0/n/c/h;->checkExpressionValueIsNotNull(Ljava/lang/Object;Ljava/lang/String;)V
|
|
|
|
return-object v0
|
|
.end method
|