From 858f2038f37ee8780649660ed1c6adaa581a9d2c Mon Sep 17 00:00:00 2001 From: M66B Date: Fri, 8 Oct 2021 10:32:50 +0200 Subject: [PATCH] Refactoring --- app/src/main/java/eu/faircode/email/ConnectionHelper.java | 6 ++++++ app/src/main/java/eu/faircode/email/EmailService.java | 8 +------- app/src/main/jni/fairemail.cc | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/ConnectionHelper.java b/app/src/main/java/eu/faircode/email/ConnectionHelper.java index 56b49dfcaf..713a0537c7 100644 --- a/app/src/main/java/eu/faircode/email/ConnectionHelper.java +++ b/app/src/main/java/eu/faircode/email/ConnectionHelper.java @@ -83,6 +83,12 @@ public class ConnectionHelper { "SE" // Sweden )); + static { + System.loadLibrary("fairemail"); + } + + public static native int jni_socket_keep_alive(int fd, int seconds); + static class NetworkState { private Boolean connected = null; private Boolean suitable = null; diff --git a/app/src/main/java/eu/faircode/email/EmailService.java b/app/src/main/java/eu/faircode/email/EmailService.java index c62c46cbfd..b62ba933a9 100644 --- a/app/src/main/java/eu/faircode/email/EmailService.java +++ b/app/src/main/java/eu/faircode/email/EmailService.java @@ -149,12 +149,6 @@ public class EmailService implements AutoCloseable { // TLS_FALLBACK_SCSV https://tools.ietf.org/html/rfc7507 // TLS_EMPTY_RENEGOTIATION_INFO_SCSV https://tools.ietf.org/html/rfc5746 - static { - System.loadLibrary("fairemail"); - } - - private static native int jni_socket_keep_alive(int fd, int seconds); - private EmailService() { // Prevent instantiation } @@ -1068,7 +1062,7 @@ public class EmailService implements AutoCloseable { Log.i("Enabling TCP keep alive"); int fd = ParcelFileDescriptor.fromSocket(socket).getFd(); - int errno = jni_socket_keep_alive(fd, TCP_KEEP_ALIVE_INTERVAL); + int errno = ConnectionHelper.jni_socket_keep_alive(fd, TCP_KEEP_ALIVE_INTERVAL); if (errno == 0) Log.i("Enabled TCP keep alive"); else diff --git a/app/src/main/jni/fairemail.cc b/app/src/main/jni/fairemail.cc index 28f7d8761c..ca7c982fe6 100644 --- a/app/src/main/jni/fairemail.cc +++ b/app/src/main/jni/fairemail.cc @@ -86,7 +86,7 @@ Java_eu_faircode_email_TextHelper_jni_1detect_1language(JNIEnv *env, jclass claz extern "C" JNIEXPORT jint JNICALL -Java_eu_faircode_email_EmailService_jni_1socket_1keep_1alive( +Java_eu_faircode_email_ConnectionHelper_jni_1socket_1keep_1alive( JNIEnv *env, jclass clazz, jint fd, jint seconds) { // https://tldp.org/HOWTO/html_single/TCP-Keepalive-HOWTO/#setsockopt