Added option to enable TCP keep alive

This commit is contained in:
M66B
2020-11-08 20:51:44 +01:00
parent da35152457
commit af01f4173d
6 changed files with 57 additions and 7 deletions

View File

@@ -61,6 +61,7 @@ public class FragmentOptionsConnection extends FragmentBase implements SharedPre
private SwitchCompat swRlah;
private EditText etTimeout;
private SwitchCompat swPreferIp4;
private SwitchCompat swTcpKeepAlive;
private SwitchCompat swSslHarden;
private Button btnManage;
private TextView tvNetworkMetered;
@@ -68,7 +69,7 @@ public class FragmentOptionsConnection extends FragmentBase implements SharedPre
private TextView tvNetworkInfo;
private final static String[] RESET_OPTIONS = new String[]{
"metered", "download", "roaming", "rlah", "timeout", "prefer_ip4", "ssl_harden"
"metered", "download", "roaming", "rlah", "timeout", "prefer_ip4", "tcp_keep_alive", "ssl_harden"
};
@Override
@@ -87,6 +88,7 @@ public class FragmentOptionsConnection extends FragmentBase implements SharedPre
swRlah = view.findViewById(R.id.swRlah);
etTimeout = view.findViewById(R.id.etTimeout);
swPreferIp4 = view.findViewById(R.id.swPreferIp4);
swTcpKeepAlive = view.findViewById(R.id.swTcpKeepAlive);
swSslHarden = view.findViewById(R.id.swSslHarden);
btnManage = view.findViewById(R.id.btnManage);
@@ -166,6 +168,18 @@ public class FragmentOptionsConnection extends FragmentBase implements SharedPre
}
});
swTcpKeepAlive.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
try {
System.setProperty("fairemail.tcp_keep_alive", Boolean.toString(checked));
} catch (Throwable ex) {
Log.e(ex);
}
prefs.edit().putBoolean("tcp_keep_alive", checked).apply();
}
});
swSslHarden.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
@@ -281,6 +295,7 @@ public class FragmentOptionsConnection extends FragmentBase implements SharedPre
etTimeout.setHint(Integer.toString(EmailService.DEFAULT_CONNECT_TIMEOUT));
swPreferIp4.setChecked(prefs.getBoolean("prefer_ip4", true));
swTcpKeepAlive.setChecked(prefs.getBoolean("tcp_keep_alive", true));
swSslHarden.setChecked(prefs.getBoolean("ssl_harden", false));
}