diff --git a/app/src/main/java/io/netbird/client/ui/advanced/AdvancedFragment.java b/app/src/main/java/io/netbird/client/ui/advanced/AdvancedFragment.java
index ed060c5..042f758 100644
--- a/app/src/main/java/io/netbird/client/ui/advanced/AdvancedFragment.java
+++ b/app/src/main/java/io/netbird/client/ui/advanced/AdvancedFragment.java
@@ -65,6 +65,27 @@ private void configureForceRelayConnectionSwitch(@NonNull ComponentSwitchBinding
});
}
+ private void configureEnableLazyConnectionSwitch(@NonNull ComponentSwitchBinding binding, @NonNull Preferences preferences) {
+ binding.switchTitle.setText(R.string.advanced_enable_lazy_conn);
+ binding.switchDescription.setText(R.string.advanced_enable_lazy_conn_desc);
+
+ binding.switchControl.setChecked(preferences.isLazyConnectionEnabled());
+ binding.switchControl.setOnCheckedChangeListener((buttonView, isChecked) -> {
+ if (isChecked) {
+ preferences.enableLazyConnection();
+ } else {
+ preferences.disableLazyConnection();
+ }
+
+ showReconnectionNeededWarningDialog();
+ });
+
+ // Make parent layout clickable to toggle switch (for TV remote)
+ binding.getRoot().setOnClickListener(v -> {
+ binding.switchControl.toggle();
+ });
+ }
+
public View onCreateView(@NonNull LayoutInflater inflater,
ViewGroup container, Bundle savedInstanceState) {
@@ -182,6 +203,7 @@ public View onCreateView(@NonNull LayoutInflater inflater,
});
configureForceRelayConnectionSwitch(binding.layoutForceRelayConnection, preferences);
+ configureEnableLazyConnectionSwitch(binding.layoutEnableLazyConnection, preferences);
// Initialize engine config switches (your settings)
initializeEngineConfigSwitches();
diff --git a/app/src/main/res/layout/fragment_advanced.xml b/app/src/main/res/layout/fragment_advanced.xml
index 9c74605..83bf10f 100644
--- a/app/src/main/res/layout/fragment_advanced.xml
+++ b/app/src/main/res/layout/fragment_advanced.xml
@@ -530,6 +530,17 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/layout_disable_firewall" />
+
+
+ app:layout_constraintTop_toBottomOf="@id/layout_enable_lazy_connection">
Switched to profile \'%s\'
Logged out from profile \'%s\'
Profile \'%s\' removed successfully
+ Enable lazy connection
+ Enables lazy connection for this peer
diff --git a/netbird b/netbird
index 6721101..1024d45 160000
--- a/netbird
+++ b/netbird
@@ -1 +1 @@
-Subproject commit 67211010f7240d53734abd922777c32fccb02754
+Subproject commit 1024d45698c06fc9c674dfb7132c26c3b4e4fb6e
diff --git a/tool/src/main/java/io/netbird/client/tool/EnvVarPackager.java b/tool/src/main/java/io/netbird/client/tool/EnvVarPackager.java
index f6413e9..dce0496 100644
--- a/tool/src/main/java/io/netbird/client/tool/EnvVarPackager.java
+++ b/tool/src/main/java/io/netbird/client/tool/EnvVarPackager.java
@@ -8,6 +8,8 @@ public static EnvList getEnvironmentVariables(Preferences preferences) {
var envList = new EnvList();
envList.put(Android.getEnvKeyNBForceRelay(), String.valueOf(preferences.isConnectionForceRelayed()));
+ envList.put(Android.getEnvKeyNBLazyConn(), String.valueOf(preferences.isLazyConnectionEnabled()));
+ envList.put(Android.getEnvKeyNBInactivityThreshold(), String.valueOf(preferences.getInactivityThreshold()));
return envList;
}
diff --git a/tool/src/main/java/io/netbird/client/tool/Preferences.java b/tool/src/main/java/io/netbird/client/tool/Preferences.java
index ddf57ca..fa70bb3 100644
--- a/tool/src/main/java/io/netbird/client/tool/Preferences.java
+++ b/tool/src/main/java/io/netbird/client/tool/Preferences.java
@@ -8,6 +8,8 @@ public class Preferences {
private final String keyTraceLog = "tracelog";
private final String keyForceRelayConnection = "isConnectionForceRelayed";
+ private final String keyLazyConnectionEnabled = "isLazyConnectionEnabled";
+ private final String keyInactivityThreshold = "inactivityThreshold";
private final SharedPreferences sharedPref;
@@ -38,6 +40,25 @@ public void disableForcedRelayConnection() {
sharedPref.edit().putBoolean(keyForceRelayConnection, false).apply();
}
+ public boolean isLazyConnectionEnabled() {
+ return sharedPref.getBoolean(keyLazyConnectionEnabled, true);
+ }
+
+ public void enableLazyConnection() {
+ sharedPref.edit().putBoolean(keyLazyConnectionEnabled, true).apply();
+ }
+
+ public void disableLazyConnection() {
+ sharedPref.edit().putBoolean(keyLazyConnectionEnabled, false).apply();
+ }
+
+ // This value represents for how long, in minutes, it will take for a lazy connection to be considered inactive so
+ // it won't attempt reconnection anymore. Currently, the user cannot change this so it's hardcoded to five minutes
+ // (its default value in the SDK is 15 minutes, and accepts a minimum of 1 minute).
+ public int getInactivityThreshold() {
+ return sharedPref.getInt(keyInactivityThreshold, 5);
+ }
+
public static String defaultServer() {
return "https://api.netbird.io";
}