Skip to content

Commit 1be42f2

Browse files
committed
add migration logic of VPN settings
1 parent a1301aa commit 1be42f2

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

app/src/main/java/eu/faircode/netguard/ReceiverAutostart.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,26 @@ public static void upgrade(boolean initialized, Context context) {
9494
} else if (oldVersion <= 2017032112)
9595
editor.remove("ip6");
9696

97+
if (oldVersion < 2026010203) {
98+
Log.i(TAG, "Migrating Tracker Protection to VPN Exclusion");
99+
SharedPreferences apply = context.getSharedPreferences("apply", Context.MODE_PRIVATE);
100+
SharedPreferences vpn_exclude = context.getSharedPreferences("vpn_exclude", Context.MODE_PRIVATE);
101+
SharedPreferences.Editor vpn_exclude_editor = vpn_exclude.edit();
102+
SharedPreferences.Editor apply_editor = apply.edit();
103+
104+
Map<String, ?> allApply = apply.getAll();
105+
for (Map.Entry<String, ?> entry : allApply.entrySet()) {
106+
if (entry.getValue() instanceof Boolean && !((Boolean) entry.getValue())) {
107+
String packageName = entry.getKey();
108+
Log.i(TAG, "Excluding package=" + packageName);
109+
vpn_exclude_editor.putBoolean(packageName, true);
110+
apply_editor.putBoolean(packageName, true);
111+
}
112+
}
113+
vpn_exclude_editor.apply();
114+
apply_editor.apply();
115+
}
116+
97117
} else {
98118
Log.i(TAG, "Initializing sdk=" + Build.VERSION.SDK_INT);
99119
editor.putBoolean("filter_udp", true);

0 commit comments

Comments
 (0)