mirror of https://github.com/M66B/NetGuard.git
Remove settings on uninstalling application
This commit is contained in:
parent
e58ff7459f
commit
215e6b3c81
|
@ -37,6 +37,10 @@
|
|||
<action android:name="android.intent.action.BOOT_COMPLETED" />
|
||||
<action android:name="android.intent.action.MY_PACKAGE_REPLACED" />
|
||||
</intent-filter>
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.PACKAGE_REMOVED" />
|
||||
<data android:scheme="package" />
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
</application>
|
||||
</manifest>
|
||||
|
|
|
@ -3,6 +3,7 @@ package eu.faircode.netguard;
|
|||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.net.VpnService;
|
||||
import android.util.Log;
|
||||
|
||||
|
@ -14,8 +15,21 @@ public class Receiver extends BroadcastReceiver {
|
|||
Log.i(TAG, "Received " + intent);
|
||||
Util.logExtras(TAG, intent);
|
||||
|
||||
if (Intent.ACTION_PACKAGE_REMOVED.equals(intent.getAction())) {
|
||||
// Remove settings
|
||||
if (intent.getBooleanExtra(Intent.EXTRA_DATA_REMOVED, false)) {
|
||||
String packageName = intent.getData().getSchemeSpecificPart();
|
||||
Log.i(TAG, "Deleting settings package=" + packageName);
|
||||
context.getSharedPreferences("wifi", Context.MODE_PRIVATE).edit().remove(packageName).apply();
|
||||
context.getSharedPreferences("other", Context.MODE_PRIVATE).edit().remove(packageName).apply();
|
||||
context.getSharedPreferences("unused", Context.MODE_PRIVATE).edit().remove(packageName).apply();
|
||||
context.getSharedPreferences("roaming", Context.MODE_PRIVATE).edit().remove(packageName).apply();
|
||||
}
|
||||
|
||||
} else {
|
||||
// Start service
|
||||
if (VpnService.prepare(context) == null)
|
||||
SinkholeService.start(context);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue