1
0
Fork 0
mirror of https://github.com/M66B/NetGuard.git synced 2025-01-03 13:54:09 +00:00

Synchronize JNI done

This commit is contained in:
M66B 2019-07-23 20:46:43 +02:00
parent bbd12a7386
commit 4c8d1d89d1

View file

@ -137,6 +137,7 @@ public class ServiceSinkhole extends VpnService implements SharedPreferences.OnS
private int last_blocked = -1; private int last_blocked = -1;
private int last_hosts = -1; private int last_hosts = -1;
private static Object jni_lock = new Object();
private static long jni_context = 0; private static long jni_context = 0;
private Thread tunnelThread = null; private Thread tunnelThread = null;
private ServiceSinkhole.Builder last_builder = null; private ServiceSinkhole.Builder last_builder = null;
@ -2352,9 +2353,11 @@ public class ServiceSinkhole extends VpnService implements SharedPreferences.OnS
if (jni_context != 0) { if (jni_context != 0) {
jni_stop(jni_context); jni_stop(jni_context);
synchronized (jni_lock) {
jni_done(jni_context); jni_done(jni_context);
jni_context = 0; jni_context = 0;
} }
}
// Native init // Native init
jni_context = jni_init(Build.VERSION.SDK_INT); jni_context = jni_init(Build.VERSION.SDK_INT);
@ -2718,7 +2721,10 @@ public class ServiceSinkhole extends VpnService implements SharedPreferences.OnS
Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex)); Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex));
} }
synchronized (jni_lock) {
jni_done(jni_context); jni_done(jni_context);
jni_context = 0;
}
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
prefs.unregisterOnSharedPreferenceChangeListener(this); prefs.unregisterOnSharedPreferenceChangeListener(this);