1
0
Fork 0
mirror of https://github.com/M66B/NetGuard.git synced 2025-02-26 08:02:47 +00:00

Native pcap init/cleanup

This commit is contained in:
M66B 2016-01-18 21:07:35 +01:00
parent 27843d3f88
commit af04ece071
2 changed files with 14 additions and 5 deletions

View file

@ -415,10 +415,10 @@ public class ActivitySettings extends AppCompatActivity implements SharedPrefere
SinkholeService.reload(null, "setting changed", this);
else if ("pcap_enabled".equals(name)) {
File pcap = new File(getCacheDir(), "netguard.pcap");
if (pcap.exists())
pcap.delete();
if (prefs.getBoolean(name, false)) {
File pcap = new File(getCacheDir(), "netguard.pcap");
if (pcap.exists())
pcap.delete();
SinkholeService.setPcap(pcap.getAbsolutePath());
} else
SinkholeService.setPcap(null);

View file

@ -862,9 +862,18 @@ public class SinkholeService extends VpnService implements SharedPreferences.OnS
public void onCreate() {
Log.i(TAG, "Create");
jni_init();
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
// Native init
jni_init();
File pcap = new File(getCacheDir(), "netguard.pcap");
if (pcap.exists())
pcap.delete();
if (prefs.getBoolean("pcap_enabled", false)) {
SinkholeService.setPcap(pcap.getAbsolutePath());
} else
SinkholeService.setPcap(null);
prefs.registerOnSharedPreferenceChangeListener(this);
Util.setTheme(this);