mirror of
https://github.com/M66B/NetGuard.git
synced 2025-02-26 16:13:01 +00:00
Native pcap init/cleanup
This commit is contained in:
parent
27843d3f88
commit
af04ece071
2 changed files with 14 additions and 5 deletions
|
@ -415,10 +415,10 @@ public class ActivitySettings extends AppCompatActivity implements SharedPrefere
|
||||||
SinkholeService.reload(null, "setting changed", this);
|
SinkholeService.reload(null, "setting changed", this);
|
||||||
|
|
||||||
else if ("pcap_enabled".equals(name)) {
|
else if ("pcap_enabled".equals(name)) {
|
||||||
if (prefs.getBoolean(name, false)) {
|
|
||||||
File pcap = new File(getCacheDir(), "netguard.pcap");
|
File pcap = new File(getCacheDir(), "netguard.pcap");
|
||||||
if (pcap.exists())
|
if (pcap.exists())
|
||||||
pcap.delete();
|
pcap.delete();
|
||||||
|
if (prefs.getBoolean(name, false)) {
|
||||||
SinkholeService.setPcap(pcap.getAbsolutePath());
|
SinkholeService.setPcap(pcap.getAbsolutePath());
|
||||||
} else
|
} else
|
||||||
SinkholeService.setPcap(null);
|
SinkholeService.setPcap(null);
|
||||||
|
|
|
@ -862,9 +862,18 @@ public class SinkholeService extends VpnService implements SharedPreferences.OnS
|
||||||
public void onCreate() {
|
public void onCreate() {
|
||||||
Log.i(TAG, "Create");
|
Log.i(TAG, "Create");
|
||||||
|
|
||||||
jni_init();
|
|
||||||
|
|
||||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
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);
|
prefs.registerOnSharedPreferenceChangeListener(this);
|
||||||
|
|
||||||
Util.setTheme(this);
|
Util.setTheme(this);
|
||||||
|
|
Loading…
Reference in a new issue