Change from cache to data dir for PCAP files

This commit is contained in:
M66B 2017-02-18 13:37:02 +01:00
parent 58d49780e6
commit 059a6ab7d3
3 changed files with 5 additions and 5 deletions

View File

@ -363,7 +363,7 @@ public class ActivityLog extends AppCompatActivity implements SharedPreferences.
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
// https://gist.github.com/granoeste/5574148
File pcap_file = new File(getCacheDir(), "netguard.pcap");
File pcap_file = new File(getDir("data", MODE_PRIVATE), "netguard.pcap");
boolean export = (getPackageManager().resolveActivity(getIntentPCAPDocument(), 0) != null);
@ -386,7 +386,7 @@ public class ActivityLog extends AppCompatActivity implements SharedPreferences.
@Override
public boolean onOptionsItemSelected(MenuItem item) {
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
final File pcap_file = new File(getCacheDir(), "netguard.pcap");
final File pcap_file = new File(getDir("data", MODE_PRIVATE), "netguard.pcap");
switch (item.getItemId()) {
case android.R.id.home:
@ -563,7 +563,7 @@ public class ActivityLog extends AppCompatActivity implements SharedPreferences.
Log.i(TAG, "Export PCAP URI=" + target);
out = getContentResolver().openOutputStream(target);
File pcap = new File(getCacheDir(), "netguard.pcap");
File pcap = new File(getDir("data", MODE_PRIVATE), "netguard.pcap");
in = new FileInputStream(pcap);
int len;

View File

@ -718,7 +718,7 @@ public class ActivitySettings extends AppCompatActivity implements SharedPrefere
ServiceSinkhole.setPcap(false, this);
File pcap_file = new File(getCacheDir(), "netguard.pcap");
File pcap_file = new File(getDir("data", MODE_PRIVATE), "netguard.pcap");
if (pcap_file.exists() && !pcap_file.delete())
Log.w(TAG, "Delete PCAP failed");

View File

@ -191,7 +191,7 @@ public class ServiceSinkhole extends VpnService implements SharedPreferences.OnS
private native void jni_done();
public static void setPcap(boolean enabled, Context context) {
File pcap = (enabled ? new File(context.getCacheDir(), "netguard.pcap") : null);
File pcap = (enabled ? new File(context.getDir("data", MODE_PRIVATE), "netguard.pcap") : null);
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
String r = prefs.getString("pcap_record_size", null);
if (TextUtils.isEmpty(r))