Skip to content

Commit f3d8eb4

Browse files
authored
Merge pull request #98 from jackBonadies/fix_vpn_network_register_race_condition
Fix vpn network register race condition
2 parents ec480bd + ee15172 commit f3d8eb4

3 files changed

Lines changed: 14 additions & 2 deletions

File tree

‎Seeker/Properties/AndroidManifest.xml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="133" android:versionName="3.7.1" package="com.companyname.andriodapp1" android:installLocation="auto" android:requestLegacyExternalStorage="true">
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="134" android:versionName="3.7.2" package="com.companyname.andriodapp1" android:installLocation="auto" android:requestLegacyExternalStorage="true">
33
<application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:supportsRtl="false" android:enableOnBackInvokedCallback="true" android:theme="@style/AppTheme" android:localeConfig="@xml/locales_config">
44
<provider android:name="androidx.core.content.FileProvider" android:authorities="${applicationId}.provider" android:exported="false" android:grantUriPermissions="true">
55
<meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/provider_paths" />

‎Seeker/SeekerApplication.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,6 @@ public override void OnCreate()
241241
}
242242

243243
NetworkStateService.SetNetworkState(this);
244-
NetworkStateService.RegisterDefaultNetworkCallback(this);
245244

246245
//need search response and enqueue download action...
247246
//SeekerState.SoulseekClient = new SoulseekClient(new SoulseekClientOptions(messageTimeout: 30000, enableListener: false, autoAcknowledgePrivateMessages: false, acceptPrivateRoomInvitations:PreferencesState.AllowPrivateRoomInvitations)); //Enable Listener is False. Default is True.
@@ -273,6 +272,7 @@ public override void OnCreate()
273272
addressResolver: ResolveAddressAsync,
274273
userInfoResolver: UserInfoResponder.HandleRequest));
275274
#endif
275+
NetworkStateService.RegisterDefaultNetworkCallback(this);
276276
SetDiagnosticState(PreferencesState.LogDiagnostics);
277277
SeekerState.SoulseekClient.UserStatisticsChanged += SoulseekClient_UserDataReceived;
278278
SeekerState.SoulseekClient.UserStatusChanged += UserStatusDeduplicator.Instance.OnUserStatusChanged;

‎Seeker/Services/SharingService.cs‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ public static class SharingService
3434

3535
public static void TurnOnSharing()
3636
{
37+
if (SeekerState.SoulseekClient == null)
38+
{
39+
// A network callback can fire before SeekerState.SoulseekClient is constructed
40+
// in SeekerApplication.OnCreate. Sharing is (re)configured once the client exists.
41+
return;
42+
}
3743
SeekerState.SoulseekClient.ReconfigureOptionsAsync(new SoulseekClientOptionsPatch(
3844
searchResponseResolver: SearchResponseResolver,
3945
browseResponseResolver: BrowseResponseResolver,
@@ -44,6 +50,12 @@ public static void TurnOnSharing()
4450

4551
public static void TurnOffSharing()
4652
{
53+
if (SeekerState.SoulseekClient == null)
54+
{
55+
// A network callback can fire before SeekerState.SoulseekClient is constructed
56+
// in SeekerApplication.OnCreate. Sharing is (re)configured once the client exists.
57+
return;
58+
}
4759
SeekerState.SoulseekClient.ReconfigureOptionsAsync(new SoulseekClientOptionsPatch(
4860
searchResponseResolver: NoOpSearchResolver,
4961
browseResponseResolver: NoOpBrowseResolver,

0 commit comments

Comments
 (0)