apkfuckery/com.discord/smali/com/discord/stores/StoreConnectivity.smali

731 lines
17 KiB
Smali

.class public Lcom/discord/stores/StoreConnectivity;
.super Landroid/content/BroadcastReceiver;
.source "StoreConnectivity.java"
# static fields
.field public static final CONNECTING_DELAY_AGGRESSIVE:J = 0xbb8L
.field public static final CONNECTING_DELAY_PASSIVE:J = 0x7530L
.field public static final RECENTLY_FOREGROUNDED_WINDOW:J = 0x7530L
.field public static final STATE_CONNECTING:I = 0x3
.field public static final STATE_OFFLINE:I = 0x2
.field public static final STATE_ONLINE:I = 0x1
# instance fields
.field public final $lock:Ljava/lang/Object;
.field public connectingTransitionTimerSubscription:Lrx/Subscription;
.field public final connectionOpenSubject:Lrx/subjects/Subject;
.annotation system Ldalvik/annotation/Signature;
value = {
"Lrx/subjects/Subject<",
"Ljava/lang/Boolean;",
"Ljava/lang/Boolean;",
">;"
}
.end annotation
.end field
.field public deviceNetworkOffline:Z
.field public optimisticallyConnected:Z
.field public recentlyForegrounded:Z
.field public recentlyForegroundedClearSubscription:Lrx/Subscription;
.field public state:I
.field public final statePublisher:Lrx/subjects/Subject;
.annotation system Ldalvik/annotation/Signature;
value = {
"Lrx/subjects/Subject<",
"Ljava/lang/Integer;",
"Ljava/lang/Integer;",
">;"
}
.end annotation
.end field
# direct methods
.method public constructor <init>()V
.locals 3
invoke-direct {p0}, Landroid/content/BroadcastReceiver;-><init>()V
const/4 v0, 0x0
new-array v1, v0, [Ljava/lang/Object;
iput-object v1, p0, Lcom/discord/stores/StoreConnectivity;->$lock:Ljava/lang/Object;
const/4 v1, 0x1
iput-boolean v1, p0, Lcom/discord/stores/StoreConnectivity;->recentlyForegrounded:Z
new-instance v2, Lrx/subjects/SerializedSubject;
invoke-static {v1}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;
move-result-object v1
invoke-static {v1}, Lrx/subjects/BehaviorSubject;->a(Ljava/lang/Object;)Lrx/subjects/BehaviorSubject;
move-result-object v1
invoke-direct {v2, v1}, Lrx/subjects/SerializedSubject;-><init>(Lrx/subjects/Subject;)V
iput-object v2, p0, Lcom/discord/stores/StoreConnectivity;->statePublisher:Lrx/subjects/Subject;
new-instance v1, Lrx/subjects/SerializedSubject;
invoke-static {v0}, Ljava/lang/Boolean;->valueOf(Z)Ljava/lang/Boolean;
move-result-object v0
invoke-static {v0}, Lrx/subjects/BehaviorSubject;->a(Ljava/lang/Object;)Lrx/subjects/BehaviorSubject;
move-result-object v0
invoke-direct {v1, v0}, Lrx/subjects/SerializedSubject;-><init>(Lrx/subjects/Subject;)V
iput-object v1, p0, Lcom/discord/stores/StoreConnectivity;->connectionOpenSubject:Lrx/subjects/Subject;
return-void
.end method
.method private handleDeviceConnectivityChange(Z)V
.locals 1
iget-object v0, p0, Lcom/discord/stores/StoreConnectivity;->$lock:Ljava/lang/Object;
monitor-enter v0
if-nez p1, :cond_0
const/4 p1, 0x1
goto :goto_0
:cond_0
const/4 p1, 0x0
:goto_0
:try_start_0
iput-boolean p1, p0, Lcom/discord/stores/StoreConnectivity;->deviceNetworkOffline:Z
invoke-direct {p0}, Lcom/discord/stores/StoreConnectivity;->updateConnectivityState()V
monitor-exit v0
return-void
:catchall_0
move-exception p1
monitor-exit v0
:try_end_0
.catchall {:try_start_0 .. :try_end_0} :catchall_0
throw p1
.end method
.method public static isDeviceConnectedOrConnecting(Landroid/content/Context;)Z
.locals 6
.param p0 # Landroid/content/Context;
.annotation build Landroidx/annotation/NonNull;
.end annotation
.end param
const-string v0, "connectivity"
invoke-virtual {p0, v0}, Landroid/content/Context;->getSystemService(Ljava/lang/String;)Ljava/lang/Object;
move-result-object p0
check-cast p0, Landroid/net/ConnectivityManager;
const/4 v0, 0x0
if-nez p0, :cond_0
return v0
:cond_0
invoke-virtual {p0}, Landroid/net/ConnectivityManager;->getActiveNetworkInfo()Landroid/net/NetworkInfo;
move-result-object v1
const/4 v2, 0x1
if-eqz v1, :cond_1
invoke-virtual {v1}, Landroid/net/NetworkInfo;->isConnectedOrConnecting()Z
move-result v1
if-eqz v1, :cond_1
return v2
:cond_1
invoke-virtual {p0}, Landroid/net/ConnectivityManager;->getAllNetworks()[Landroid/net/Network;
move-result-object v1
if-eqz v1, :cond_3
array-length v3, v1
const/4 v4, 0x0
:goto_0
if-ge v4, v3, :cond_3
aget-object v5, v1, v4
invoke-virtual {p0, v5}, Landroid/net/ConnectivityManager;->getNetworkInfo(Landroid/net/Network;)Landroid/net/NetworkInfo;
move-result-object v5
if-eqz v5, :cond_2
invoke-virtual {v5}, Landroid/net/NetworkInfo;->isConnectedOrConnecting()Z
move-result v5
if-eqz v5, :cond_2
return v2
:cond_2
add-int/lit8 v4, v4, 0x1
goto :goto_0
:cond_3
return v0
.end method
.method private setRecentlyForegrounded(Z)V
.locals 1
iget-object v0, p0, Lcom/discord/stores/StoreConnectivity;->$lock:Ljava/lang/Object;
monitor-enter v0
:try_start_0
iput-boolean p1, p0, Lcom/discord/stores/StoreConnectivity;->recentlyForegrounded:Z
monitor-exit v0
return-void
:catchall_0
move-exception p1
monitor-exit v0
:try_end_0
.catchall {:try_start_0 .. :try_end_0} :catchall_0
throw p1
.end method
.method private setState(I)V
.locals 2
iget-object v0, p0, Lcom/discord/stores/StoreConnectivity;->$lock:Ljava/lang/Object;
monitor-enter v0
:try_start_0
iget v1, p0, Lcom/discord/stores/StoreConnectivity;->state:I
if-ne v1, p1, :cond_0
monitor-exit v0
return-void
:cond_0
iput p1, p0, Lcom/discord/stores/StoreConnectivity;->state:I
iget-object v1, p0, Lcom/discord/stores/StoreConnectivity;->statePublisher:Lrx/subjects/Subject;
invoke-static {p1}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;
move-result-object p1
invoke-interface {v1, p1}, Le0/g;->onNext(Ljava/lang/Object;)V
monitor-exit v0
return-void
:catchall_0
move-exception p1
monitor-exit v0
:try_end_0
.catchall {:try_start_0 .. :try_end_0} :catchall_0
throw p1
.end method
.method private transitioningFromRecentlyForegroundedTimer(Z)V
.locals 6
iget-object v0, p0, Lcom/discord/stores/StoreConnectivity;->recentlyForegroundedClearSubscription:Lrx/Subscription;
if-eqz v0, :cond_0
invoke-interface {v0}, Lrx/Subscription;->unsubscribe()V
const/4 v0, 0x0
iput-object v0, p0, Lcom/discord/stores/StoreConnectivity;->recentlyForegroundedClearSubscription:Lrx/Subscription;
:cond_0
if-eqz p1, :cond_1
return-void
:cond_1
const-wide/16 v0, 0x7530
sget-object p1, Ljava/util/concurrent/TimeUnit;->MILLISECONDS:Ljava/util/concurrent/TimeUnit;
invoke-static {v0, v1, p1}, Lrx/Observable;->i(JLjava/util/concurrent/TimeUnit;)Lrx/Observable;
move-result-object p1
invoke-static {}, Le/a/b/l;->a()Lrx/Observable$c;
move-result-object v0
invoke-virtual {p1, v0}, Lrx/Observable;->a(Lrx/Observable$c;)Lrx/Observable;
move-result-object p1
new-instance v0, Le/a/h/b;
invoke-direct {v0, p0}, Le/a/h/b;-><init>(Lcom/discord/stores/StoreConnectivity;)V
const-class v1, Lcom/discord/stores/StoreConnectivity;
new-instance v3, Le/a/h/c;
invoke-direct {v3, p0}, Le/a/h/c;-><init>(Lcom/discord/stores/StoreConnectivity;)V
const/4 v4, 0x0
const/16 v5, 0x10
const/4 v2, 0x0
invoke-static/range {v0 .. v5}, Le/a/b/l;->a(Lrx/functions/Action1;Ljava/lang/Class;Lrx/functions/Action1;Lrx/functions/Action1;Landroid/content/Context;I)Lrx/Observable$c;
move-result-object v0
invoke-virtual {p1, v0}, Lrx/Observable;->a(Lrx/Observable$c;)Lrx/Observable;
return-void
.end method
.method private updateConnectivityState()V
.locals 7
iget-object v0, p0, Lcom/discord/stores/StoreConnectivity;->connectingTransitionTimerSubscription:Lrx/Subscription;
if-eqz v0, :cond_0
invoke-interface {v0}, Lrx/Subscription;->unsubscribe()V
const/4 v0, 0x0
iput-object v0, p0, Lcom/discord/stores/StoreConnectivity;->connectingTransitionTimerSubscription:Lrx/Subscription;
:cond_0
iget-boolean v0, p0, Lcom/discord/stores/StoreConnectivity;->deviceNetworkOffline:Z
const/4 v1, 0x2
if-eqz v0, :cond_1
invoke-direct {p0, v1}, Lcom/discord/stores/StoreConnectivity;->setState(I)V
goto :goto_1
:cond_1
iget-boolean v0, p0, Lcom/discord/stores/StoreConnectivity;->optimisticallyConnected:Z
if-eqz v0, :cond_2
const/4 v0, 0x1
invoke-direct {p0, v0}, Lcom/discord/stores/StoreConnectivity;->setState(I)V
goto :goto_1
:cond_2
iget v0, p0, Lcom/discord/stores/StoreConnectivity;->state:I
if-ne v0, v1, :cond_3
const/4 v0, 0x3
invoke-direct {p0, v0}, Lcom/discord/stores/StoreConnectivity;->setState(I)V
goto :goto_1
:cond_3
iget-boolean v0, p0, Lcom/discord/stores/StoreConnectivity;->recentlyForegrounded:Z
if-eqz v0, :cond_4
const-wide/16 v0, 0xbb8
goto :goto_0
:cond_4
const-wide/16 v0, 0x7530
:goto_0
sget-object v2, Ljava/util/concurrent/TimeUnit;->MILLISECONDS:Ljava/util/concurrent/TimeUnit;
invoke-static {v0, v1, v2}, Lrx/Observable;->i(JLjava/util/concurrent/TimeUnit;)Lrx/Observable;
move-result-object v0
invoke-static {}, Le/a/b/l;->a()Lrx/Observable$c;
move-result-object v1
invoke-virtual {v0, v1}, Lrx/Observable;->a(Lrx/Observable$c;)Lrx/Observable;
move-result-object v0
new-instance v1, Le/a/h/e;
invoke-direct {v1, p0}, Le/a/h/e;-><init>(Lcom/discord/stores/StoreConnectivity;)V
const-class v2, Lcom/discord/stores/StoreConnectivity;
new-instance v4, Le/a/h/d;
invoke-direct {v4, p0}, Le/a/h/d;-><init>(Lcom/discord/stores/StoreConnectivity;)V
const/4 v5, 0x0
const/16 v6, 0x10
const/4 v3, 0x0
invoke-static/range {v1 .. v6}, Le/a/b/l;->a(Lrx/functions/Action1;Ljava/lang/Class;Lrx/functions/Action1;Lrx/functions/Action1;Landroid/content/Context;I)Lrx/Observable$c;
move-result-object v1
invoke-virtual {v0, v1}, Lrx/Observable;->a(Lrx/Observable$c;)Lrx/Observable;
:goto_1
return-void
.end method
# virtual methods
.method public synthetic a(Ljava/lang/Long;)V
.locals 0
const/4 p1, 0x0
invoke-direct {p0, p1}, Lcom/discord/stores/StoreConnectivity;->setRecentlyForegrounded(Z)V
return-void
.end method
.method public synthetic a(Lrx/Subscription;)V
.locals 0
iput-object p1, p0, Lcom/discord/stores/StoreConnectivity;->recentlyForegroundedClearSubscription:Lrx/Subscription;
return-void
.end method
.method public synthetic b(Ljava/lang/Long;)V
.locals 0
const/4 p1, 0x3
invoke-direct {p0, p1}, Lcom/discord/stores/StoreConnectivity;->setState(I)V
return-void
.end method
.method public synthetic b(Lrx/Subscription;)V
.locals 0
iput-object p1, p0, Lcom/discord/stores/StoreConnectivity;->connectingTransitionTimerSubscription:Lrx/Subscription;
return-void
.end method
.method public getConnectionOpen()Lrx/Observable;
.locals 4
.annotation system Ldalvik/annotation/Signature;
value = {
"()",
"Lrx/Observable<",
"Ljava/lang/Boolean;",
">;"
}
.end annotation
iget-object v0, p0, Lcom/discord/stores/StoreConnectivity;->connectionOpenSubject:Lrx/subjects/Subject;
invoke-static {}, Le/a/b/l;->a()Lrx/Observable$c;
move-result-object v1
invoke-virtual {v0, v1}, Lrx/Observable;->a(Lrx/Observable$c;)Lrx/Observable;
move-result-object v0
sget-object v1, Ljava/util/concurrent/TimeUnit;->MILLISECONDS:Ljava/util/concurrent/TimeUnit;
const-wide/16 v2, 0x64
invoke-virtual {v0, v2, v3, v1}, Lrx/Observable;->c(JLjava/util/concurrent/TimeUnit;)Lrx/Observable;
move-result-object v0
return-object v0
.end method
.method public getState()Lrx/Observable;
.locals 2
.annotation system Ldalvik/annotation/Signature;
value = {
"()",
"Lrx/Observable<",
"Ljava/lang/Integer;",
">;"
}
.end annotation
iget-object v0, p0, Lcom/discord/stores/StoreConnectivity;->statePublisher:Lrx/subjects/Subject;
invoke-static {}, Le/a/b/l;->a()Lrx/Observable$c;
move-result-object v1
invoke-virtual {v0, v1}, Lrx/Observable;->a(Lrx/Observable$c;)Lrx/Observable;
move-result-object v0
return-object v0
.end method
.method public handleBackgrounded(Z)V
.locals 1
iget-object v0, p0, Lcom/discord/stores/StoreConnectivity;->$lock:Ljava/lang/Object;
monitor-enter v0
:try_start_0
invoke-direct {p0, p1}, Lcom/discord/stores/StoreConnectivity;->transitioningFromRecentlyForegroundedTimer(Z)V
if-nez p1, :cond_0
const/4 p1, 0x1
goto :goto_0
:cond_0
const/4 p1, 0x0
:goto_0
iput-boolean p1, p0, Lcom/discord/stores/StoreConnectivity;->recentlyForegrounded:Z
invoke-direct {p0}, Lcom/discord/stores/StoreConnectivity;->updateConnectivityState()V
monitor-exit v0
return-void
:catchall_0
move-exception p1
monitor-exit v0
:try_end_0
.catchall {:try_start_0 .. :try_end_0} :catchall_0
throw p1
.end method
.method public handleConnected(Z)V
.locals 2
iget-object v0, p0, Lcom/discord/stores/StoreConnectivity;->$lock:Ljava/lang/Object;
monitor-enter v0
:try_start_0
iput-boolean p1, p0, Lcom/discord/stores/StoreConnectivity;->optimisticallyConnected:Z
invoke-direct {p0}, Lcom/discord/stores/StoreConnectivity;->updateConnectivityState()V
if-nez p1, :cond_0
iget-object p1, p0, Lcom/discord/stores/StoreConnectivity;->connectionOpenSubject:Lrx/subjects/Subject;
const/4 v1, 0x0
invoke-static {v1}, Ljava/lang/Boolean;->valueOf(Z)Ljava/lang/Boolean;
move-result-object v1
invoke-interface {p1, v1}, Le0/g;->onNext(Ljava/lang/Object;)V
:cond_0
monitor-exit v0
return-void
:catchall_0
move-exception p1
monitor-exit v0
:try_end_0
.catchall {:try_start_0 .. :try_end_0} :catchall_0
throw p1
.end method
.method public handleConnectionOpen()V
.locals 3
iget-object v0, p0, Lcom/discord/stores/StoreConnectivity;->$lock:Ljava/lang/Object;
monitor-enter v0
:try_start_0
iget-object v1, p0, Lcom/discord/stores/StoreConnectivity;->connectionOpenSubject:Lrx/subjects/Subject;
const/4 v2, 0x1
invoke-static {v2}, Ljava/lang/Boolean;->valueOf(Z)Ljava/lang/Boolean;
move-result-object v2
invoke-interface {v1, v2}, Le0/g;->onNext(Ljava/lang/Object;)V
monitor-exit v0
return-void
:catchall_0
move-exception v1
monitor-exit v0
:try_end_0
.catchall {:try_start_0 .. :try_end_0} :catchall_0
throw v1
.end method
.method public handleConnectionReady(Z)V
.locals 2
iget-object v0, p0, Lcom/discord/stores/StoreConnectivity;->$lock:Ljava/lang/Object;
monitor-enter v0
:try_start_0
iget-boolean v1, p0, Lcom/discord/stores/StoreConnectivity;->deviceNetworkOffline:Z
if-eqz v1, :cond_0
if-eqz p1, :cond_0
const/4 p1, 0x0
iput-boolean p1, p0, Lcom/discord/stores/StoreConnectivity;->deviceNetworkOffline:Z
:cond_0
invoke-direct {p0}, Lcom/discord/stores/StoreConnectivity;->updateConnectivityState()V
monitor-exit v0
return-void
:catchall_0
move-exception p1
monitor-exit v0
:try_end_0
.catchall {:try_start_0 .. :try_end_0} :catchall_0
throw p1
.end method
.method public init(Landroid/content/Context;)V
.locals 3
.param p1 # Landroid/content/Context;
.annotation build Landroidx/annotation/NonNull;
.end annotation
.end param
iget-object v0, p0, Lcom/discord/stores/StoreConnectivity;->$lock:Ljava/lang/Object;
monitor-enter v0
:try_start_0
new-instance v1, Landroid/content/IntentFilter;
const-string v2, "android.net.conn.CONNECTIVITY_CHANGE"
invoke-direct {v1, v2}, Landroid/content/IntentFilter;-><init>(Ljava/lang/String;)V
invoke-virtual {p1, p0, v1}, Landroid/content/Context;->registerReceiver(Landroid/content/BroadcastReceiver;Landroid/content/IntentFilter;)Landroid/content/Intent;
invoke-static {p1}, Lcom/discord/stores/StoreConnectivity;->isDeviceConnectedOrConnecting(Landroid/content/Context;)Z
move-result p1
invoke-direct {p0, p1}, Lcom/discord/stores/StoreConnectivity;->handleDeviceConnectivityChange(Z)V
monitor-exit v0
return-void
:catchall_0
move-exception p1
monitor-exit v0
:try_end_0
.catchall {:try_start_0 .. :try_end_0} :catchall_0
throw p1
.end method
.method public onReceive(Landroid/content/Context;Landroid/content/Intent;)V
.locals 0
invoke-static {p1}, Lcom/discord/stores/StoreConnectivity;->isDeviceConnectedOrConnecting(Landroid/content/Context;)Z
move-result p1
invoke-direct {p0, p1}, Lcom/discord/stores/StoreConnectivity;->handleDeviceConnectivityChange(Z)V
return-void
.end method