1
0
Fork 0
mirror of https://github.com/M66B/NetGuard.git synced 2025-01-31 11:52:24 +00:00

Make sure the JNI context is cleared

Reason: onCreate can be called multiple times without onDestroy being called
This commit is contained in:
M66B 2019-07-22 11:22:06 +02:00
parent dafea6ea39
commit ede610a3da

View file

@ -137,7 +137,7 @@ public class ServiceSinkhole extends VpnService implements SharedPreferences.OnS
private int last_blocked = -1;
private int last_hosts = -1;
private long jni_context = 0;
private static long jni_context = 0;
private Thread tunnelThread = null;
private ServiceSinkhole.Builder last_builder = null;
private ParcelFileDescriptor vpn = null;
@ -2350,6 +2350,12 @@ public class ServiceSinkhole extends VpnService implements SharedPreferences.OnS
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
if (jni_context != 0) {
jni_stop(jni_context);
jni_done(jni_context);
jni_context = 0;
}
// Native init
jni_context = jni_init(Build.VERSION.SDK_INT);
boolean pcap = prefs.getBoolean("pcap", false);