Skip to content

Commit 3dafe04

Browse files
kasnderclaudeCopilot
authored
Remove hidden NetGuard lockdown feature (#542)
* Remove NetGuard lockdown feature (hidden/unused in TC) NetGuard's app lockdown feature was hidden in TrackerControl (menu_lockdown had android:visible="false") and the "lockdown" pref defaulted to false with no UI to enable it. Remove all related code: - ServiceSinkhole: isLockedDown(), prepareUidIPFilters lockdown check, NOTIFY_LOCKDOWN constant, showLockdownNotification/removeLockdownNotification, notification icon lock/rocket conditional, lockdown SharedPreferences cleanup - Rule: lockdown field and SharedPreferences loading - AdapterRule: lockdown persistence and related-app propagation - ActivityMain: hidden menu item handler, legend lockdown icon - ActivitySettings: lockdown_wifi/lockdown_other pref listener, lockdown export/import in XML backup - XML: menu_lockdown item, legend lockdown entry Note: Android system VPN lockdown detection (always_on_vpn_lockdown in Settings.Secure) used in ActivityOnboarding and ActivityMain is preserved — that's a different feature that warns users about the system "Block connections without VPN" setting. https://claude.ai/code/session_01PuXevPG3gUKEXWHrgRMptV * Fix missing closing brace in ActivitySettings.java after lockdown removal Agent-Logs-Url: https://github.com/TrackerControl/tracker-control-android/sessions/869a1602-7f49-4251-86af-cd1fdf728cf3 Co-authored-by: kasnder <5175206+kasnder@users.noreply.github.com> --------- Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
1 parent 81864a0 commit 3dafe04

7 files changed

Lines changed: 6 additions & 142 deletions

File tree

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

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -936,8 +936,6 @@ else if ("trackers_all".equals(sort))
936936
else
937937
menu.findItem(R.id.menu_sort_trackers_week).setChecked(true);
938938

939-
menu.findItem(R.id.menu_lockdown).setChecked(prefs.getBoolean("lockdown", false));
940-
941939
return super.onPrepareOptionsMenu(menu);
942940
}
943941

@@ -980,9 +978,6 @@ public boolean onOptionsItemSelected(MenuItem item) {
980978
item.setChecked(true);
981979
prefs.edit().putString("sort", "uid").apply();
982980
return true;
983-
} else if (itemId == R.id.menu_lockdown) {
984-
menu_lockdown(item);
985-
return true;
986981
} else if (itemId == R.id.menu_log) {
987982
if (Util.canFilter(this))
988983
startActivity(new Intent(this, ActivityLog.class));
@@ -1220,7 +1215,6 @@ private void menu_legend() {
12201215
// Create view
12211216
LayoutInflater inflater = LayoutInflater.from(this);
12221217
View view = inflater.inflate(R.layout.legend, null, false);
1223-
ImageView ivLockdownOn = view.findViewById(R.id.ivLockdownOn);
12241218
ImageView ivWifiOn = view.findViewById(R.id.ivWifiOn);
12251219
ImageView ivWifiOff = view.findViewById(R.id.ivWifiOff);
12261220
ImageView ivOtherOn = view.findViewById(R.id.ivOtherOn);
@@ -1229,7 +1223,6 @@ private void menu_legend() {
12291223
ImageView ivHostAllowed = view.findViewById(R.id.ivHostAllowed);
12301224
ImageView ivHostBlocked = view.findViewById(R.id.ivHostBlocked);
12311225
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
1232-
Drawable wrapLockdownOn = DrawableCompat.wrap(ivLockdownOn.getDrawable());
12331226
Drawable wrapWifiOn = DrawableCompat.wrap(ivWifiOn.getDrawable());
12341227
Drawable wrapWifiOff = DrawableCompat.wrap(ivWifiOff.getDrawable());
12351228
Drawable wrapOtherOn = DrawableCompat.wrap(ivOtherOn.getDrawable());
@@ -1238,7 +1231,6 @@ private void menu_legend() {
12381231
Drawable wrapHostAllowed = DrawableCompat.wrap(ivHostAllowed.getDrawable());
12391232
Drawable wrapHostBlocked = DrawableCompat.wrap(ivHostBlocked.getDrawable());
12401233

1241-
DrawableCompat.setTint(wrapLockdownOn, colorOff);
12421234
DrawableCompat.setTint(wrapWifiOn, colorOn);
12431235
DrawableCompat.setTint(wrapWifiOff, colorOff);
12441236
DrawableCompat.setTint(wrapOtherOn, colorOn);
@@ -1262,13 +1254,6 @@ public void onDismiss(DialogInterface dialogInterface) {
12621254
dialogLegend.show();
12631255
}
12641256

1265-
private void menu_lockdown(MenuItem item) {
1266-
item.setChecked(!item.isChecked());
1267-
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
1268-
prefs.edit().putBoolean("lockdown", item.isChecked()).apply();
1269-
ServiceSinkhole.reload("lockdown", this, false);
1270-
}
1271-
12721257
private void menu_about() {
12731258
// Create view
12741259
LayoutInflater inflater = LayoutInflater.from(this);

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

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -583,9 +583,7 @@ else if ("disable_on_call".equals(name)) {
583583
ServiceSinkhole.reload("changed " + name, this, false);
584584
} else
585585
ServiceSinkhole.reload("changed " + name, this, false);
586-
587-
} else if ("lockdown_wifi".equals(name) || "lockdown_other".equals(name))
588-
ServiceSinkhole.reload("changed " + name, this, false);
586+
}
589587

590588
else if ("blocking_mode".equals(name)) {
591589
String mode = prefs.getString(name, BlockingMode.getDefaultMode());
@@ -1063,10 +1061,6 @@ private void xmlExport(OutputStream _out) throws IOException {
10631061
xmlExport(getSharedPreferences("roaming", Context.MODE_PRIVATE), serializer);
10641062
serializer.endTag(null, "roaming");
10651063

1066-
serializer.startTag(null, "lockdown");
1067-
xmlExport(getSharedPreferences("lockdown", Context.MODE_PRIVATE), serializer);
1068-
serializer.endTag(null, "lockdown");
1069-
10701064
serializer.startTag(null, "apply");
10711065
xmlExport(getSharedPreferences("apply", Context.MODE_PRIVATE), serializer);
10721066
serializer.endTag(null, "apply");
@@ -1256,7 +1250,6 @@ private void xmlImport(InputStream in) throws IOException, SAXException, ParserC
12561250
xmlImport(handler.screen_wifi, getSharedPreferences("screen_wifi", Context.MODE_PRIVATE));
12571251
xmlImport(handler.screen_other, getSharedPreferences("screen_other", Context.MODE_PRIVATE));
12581252
xmlImport(handler.roaming, getSharedPreferences("roaming", Context.MODE_PRIVATE));
1259-
xmlImport(handler.lockdown, getSharedPreferences("lockdown", Context.MODE_PRIVATE));
12601253
xmlImport(handler.apply, getSharedPreferences("apply", Context.MODE_PRIVATE));
12611254
xmlImport(handler.tracker_protect, getSharedPreferences("tracker_protect", Context.MODE_PRIVATE));
12621255
xmlImport(handler.notify, getSharedPreferences("notify", Context.MODE_PRIVATE));
@@ -1311,7 +1304,6 @@ private class XmlImportHandler extends DefaultHandler {
13111304
public Map<String, Object> screen_wifi = new HashMap<>();
13121305
public Map<String, Object> screen_other = new HashMap<>();
13131306
public Map<String, Object> roaming = new HashMap<>();
1314-
public Map<String, Object> lockdown = new HashMap<>();
13151307
public Map<String, Object> apply = new HashMap<>();
13161308
public Map<String, Object> tracker_protect = new HashMap<>();
13171309
public Map<String, Object> notify = new HashMap<>();
@@ -1346,8 +1338,7 @@ else if (qName.equals("screen_other"))
13461338
else if (qName.equals("roaming"))
13471339
current = roaming;
13481340

1349-
else if (qName.equals("lockdown"))
1350-
current = lockdown;
1341+
13511342

13521343
else if (qName.equals("apply"))
13531344
current = apply;

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

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,6 @@ private void updateRule(Context context, Rule rule, boolean root, List<Rule> lis
345345
SharedPreferences screen_wifi = context.getSharedPreferences("screen_wifi", Context.MODE_PRIVATE);
346346
SharedPreferences screen_other = context.getSharedPreferences("screen_other", Context.MODE_PRIVATE);
347347
SharedPreferences roaming = context.getSharedPreferences("roaming", Context.MODE_PRIVATE);
348-
SharedPreferences lockdown = context.getSharedPreferences("lockdown", Context.MODE_PRIVATE);
349348
SharedPreferences notify = context.getSharedPreferences("notify", Context.MODE_PRIVATE);
350349

351350
if (rule.wifi_blocked == rule.wifi_default)
@@ -377,10 +376,6 @@ private void updateRule(Context context, Rule rule, boolean root, List<Rule> lis
377376
else
378377
roaming.edit().putBoolean(rule.packageName, rule.roaming).apply();
379378

380-
if (rule.lockdown)
381-
lockdown.edit().putBoolean(rule.packageName, rule.lockdown).apply();
382-
else
383-
lockdown.edit().remove(rule.packageName).apply();
384379

385380
if (rule.notify)
386381
notify.edit().remove(rule.packageName).apply();
@@ -401,7 +396,6 @@ private void updateRule(Context context, Rule rule, boolean root, List<Rule> lis
401396
related.screen_wifi = rule.screen_wifi;
402397
related.screen_other = rule.screen_other;
403398
related.roaming = rule.roaming;
404-
related.lockdown = rule.lockdown;
405399
related.notify = rule.notify;
406400
listModified.add(related);
407401
}

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ public class Rule {
8181
public boolean screen_wifi = false;
8282
public boolean screen_other = false;
8383
public boolean roaming = false;
84-
public boolean lockdown = false;
8584

8685
public boolean apply = true; // If false, completely exclude from VPN (no DNS, no routing)
8786
public boolean tracker_protect = true; // If false, don't block trackers (but still route through VPN)
@@ -240,7 +239,6 @@ public static List<Rule> getRules(final boolean all, boolean self, Context conte
240239
SharedPreferences screen_wifi = context.getSharedPreferences("screen_wifi", Context.MODE_PRIVATE);
241240
SharedPreferences screen_other = context.getSharedPreferences("screen_other", Context.MODE_PRIVATE);
242241
SharedPreferences roaming = context.getSharedPreferences("roaming", Context.MODE_PRIVATE);
243-
SharedPreferences lockdown = context.getSharedPreferences("lockdown", Context.MODE_PRIVATE);
244242
SharedPreferences apply = context.getSharedPreferences("apply", Context.MODE_PRIVATE);
245243
SharedPreferences tracker_protect = context.getSharedPreferences("tracker_protect", Context.MODE_PRIVATE);
246244
SharedPreferences notify = context.getSharedPreferences("notify", Context.MODE_PRIVATE);
@@ -413,7 +411,6 @@ public static List<Rule> getRules(final boolean all, boolean self, Context conte
413411
rule.screen_other = screen_other.getBoolean(info.packageName, rule.screen_other_default)
414412
&& screen_on;
415413
rule.roaming = roaming.getBoolean(info.packageName, rule.roaming_default);
416-
rule.lockdown = lockdown.getBoolean(info.packageName, false);
417414

418415
rule.apply = apply.getBoolean(info.packageName, true);
419416
rule.tracker_protect = BlockingMode.isTrackerProtectionEnabled(
@@ -543,7 +540,7 @@ private void updateChanged(boolean default_wifi, boolean default_other, boolean
543540
(wifi_blocked && screen_wifi != screen_wifi_default) ||
544541
(other_blocked && screen_other != screen_other_default) ||
545542
((!other_blocked || screen_other) && roaming != default_roaming) ||
546-
hosts > 0 || lockdown || !tracker_protect || !apply);
543+
hosts > 0 || !tracker_protect || !apply);
547544
}
548545

549546
public void updateChanged(Context context) {

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

Lines changed: 3 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,6 @@ public class ServiceSinkhole extends VpnService {
184184
private static final int NOTIFY_ENFORCING = 1;
185185
private static final int NOTIFY_WAITING = 2;
186186
private static final int NOTIFY_DISABLED = 3;
187-
private static final int NOTIFY_LOCKDOWN = 4;
188187
private static final int NOTIFY_AUTOSTART = 5;
189188
private static final int NOTIFY_ERROR = 6;
190189
private static final int NOTIFY_TRAFFIC = 7;
@@ -479,16 +478,6 @@ public void onCallStateChanged(int state, String incomingNumber) {
479478
Log.e(TAG, "Unknown command=" + cmd);
480479
}
481480

482-
if (cmd == Command.start || cmd == Command.reload) {
483-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
484-
boolean filter = prefs.getBoolean("filter", false);
485-
if (filter && isLockdownEnabled())
486-
showLockdownNotification();
487-
else
488-
removeLockdownNotification();
489-
}
490-
}
491-
492481
if (cmd == Command.start || cmd == Command.reload || cmd == Command.stop) {
493482
// Update main view
494483
Intent ruleset = new Intent(ActivityMain.ACTION_RULES_CHANGED);
@@ -1855,8 +1844,6 @@ public static void prepareHostsBlocked(Context c) {
18551844
}
18561845

18571846
private void prepareUidIPFilters(String dname) {
1858-
SharedPreferences lockdown = getSharedPreferences("lockdown", Context.MODE_PRIVATE);
1859-
18601847
lock.writeLock().lock();
18611848

18621849
if (dname == null) // reset mechanism, called from startNative()
@@ -1883,20 +1870,6 @@ private void prepareUidIPFilters(String dname) {
18831870
long time = (cursor.isNull(colTime) ? new Date().getTime() : cursor.getLong(colTime));
18841871
long ttl = (cursor.isNull(colTTL) ? 7 * 24 * 3600 * 1000L : cursor.getLong(colTTL));
18851872

1886-
if (isLockedDown(last_metered)) {
1887-
String[] pkg;
1888-
try {
1889-
pkg = getPackageManager().getPackagesForUid(uid);
1890-
} catch (SecurityException ignored) {
1891-
// Work profile cross-user UID
1892-
pkg = null;
1893-
}
1894-
if (pkg != null && pkg.length > 0) {
1895-
if (!lockdown.getBoolean(pkg[0], false))
1896-
continue;
1897-
}
1898-
}
1899-
19001873
IPKey key = new IPKey(version, protocol, dport, uid);
19011874
synchronized (mapUidIPFilters) {
19021875
if (!mapUidIPFilters.containsKey(key))
@@ -1991,17 +1964,6 @@ private void prepareForwarding() {
19911964
lock.writeLock().unlock();
19921965
}
19931966

1994-
private boolean isLockedDown(boolean metered) {
1995-
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(ServiceSinkhole.this);
1996-
boolean lockdown = prefs.getBoolean("lockdown", false);
1997-
boolean lockdown_wifi = prefs.getBoolean("lockdown_wifi", true);
1998-
boolean lockdown_other = prefs.getBoolean("lockdown_other", true);
1999-
if (metered ? !lockdown_other : !lockdown_wifi)
2000-
lockdown = false;
2001-
2002-
return lockdown;
2003-
}
2004-
20051967
private List<Rule> getAllowedRules(List<Rule> listRule) {
20061968
List<Rule> listAllowed = new ArrayList<>();
20071969
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
@@ -2038,8 +2000,6 @@ private List<Rule> getAllowedRules(List<Rule> listRule) {
20382000
metered = false;
20392001
last_metered = metered;
20402002

2041-
boolean lockdown = isLockedDown(last_metered);
2042-
20432003
// Update roaming state
20442004
if (roaming && eu)
20452005
roaming = !Util.isEU(this);
@@ -2055,16 +2015,14 @@ private List<Rule> getAllowedRules(List<Rule> listRule) {
20552015
" roaming=" + roaming + "/" + org_roaming +
20562016
" interactive=" + last_interactive +
20572017
" tethering=" + tethering +
2058-
" filter=" + filter +
2059-
" lockdown=" + lockdown);
2018+
" filter=" + filter);
20602019

20612020
if (last_connected)
20622021
for (Rule rule : listRule) {
20632022
boolean blocked = (metered ? rule.other_blocked : rule.wifi_blocked);
20642023
boolean screen = (metered ? rule.screen_other : rule.screen_wifi);
20652024
if ((!blocked || (screen && last_interactive)) &&
2066-
(!metered || !(rule.roaming && roaming)) &&
2067-
(!lockdown || rule.lockdown))
2025+
(!metered || !(rule.roaming && roaming)))
20682026
listAllowed.add(rule);
20692027
}
20702028

@@ -2683,8 +2641,6 @@ public void onReceive(Context context, Intent intent) {
26832641
.apply();
26842642
context.getSharedPreferences("roaming", Context.MODE_PRIVATE).edit().remove(packageName)
26852643
.apply();
2686-
context.getSharedPreferences("lockdown", Context.MODE_PRIVATE).edit().remove(packageName)
2687-
.apply();
26882644
context.getSharedPreferences("apply", Context.MODE_PRIVATE).edit().remove(packageName).apply();
26892645
BlockingMode.clearAutoExcludedApp(context, packageName);
26902646
context.getSharedPreferences("tracker_protect", Context.MODE_PRIVATE).edit().remove(packageName).apply();
@@ -3305,8 +3261,7 @@ private Notification getEnforcingNotification(int allowed, int blocked, int host
33053261
int pause = Integer.parseInt(prefs.getString("pause", "10"));
33063262

33073263
NotificationCompat.Builder builder = new NotificationCompat.Builder(this, "foreground");
3308-
builder.setSmallIcon(
3309-
isLockedDown(last_metered) ? R.drawable.ic_lock_outline_white_24dp : R.drawable.ic_rocket_white)
3264+
builder.setSmallIcon(R.drawable.ic_rocket_white)
33103265
.setContentIntent(pi)
33113266
.setColor(getResources().getColor(R.color.colorTrackerControl))
33123267
.setOngoing(true)
@@ -3417,37 +3372,7 @@ private void showDisabledNotification() {
34173372
NotificationManagerCompat.from(this).notify(NOTIFY_DISABLED, notification.build());
34183373
}
34193374

3420-
private void showLockdownNotification() {
3421-
Intent intent = new Intent(Settings.ACTION_VPN_SETTINGS);
3422-
PendingIntent pi = PendingIntentCompat.getActivity(this, NOTIFY_LOCKDOWN, intent,
3423-
PendingIntent.FLAG_UPDATE_CURRENT);
3424-
3425-
TypedValue tv = new TypedValue();
3426-
getTheme().resolveAttribute(R.attr.colorOff, tv, true);
3427-
NotificationCompat.Builder builder = new NotificationCompat.Builder(this, "notify");
3428-
builder.setSmallIcon(R.drawable.ic_error_white_24dp)
3429-
.setContentTitle(getString(R.string.app_name))
3430-
.setContentText(getString(R.string.msg_always_on_lockdown))
3431-
.setContentIntent(pi)
3432-
.setPriority(NotificationCompat.PRIORITY_HIGH)
3433-
.setColor(tv.data)
3434-
.setOngoing(false)
3435-
.setAutoCancel(true);
3436-
3437-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
3438-
builder.setCategory(NotificationCompat.CATEGORY_STATUS)
3439-
.setVisibility(NotificationCompat.VISIBILITY_SECRET);
3440-
3441-
NotificationCompat.BigTextStyle notification = new NotificationCompat.BigTextStyle(builder);
3442-
notification.bigText(getString(R.string.msg_always_on_lockdown));
34433375

3444-
if (Util.canNotify(this))
3445-
NotificationManagerCompat.from(this).notify(NOTIFY_LOCKDOWN, notification.build());
3446-
}
3447-
3448-
private void removeLockdownNotification() {
3449-
NotificationManagerCompat.from(this).cancel(NOTIFY_LOCKDOWN);
3450-
}
34513376

34523377
private void showAutoStartNotification() {
34533378
Intent main = new Intent(this, ActivityMain.class);

app/src/main/res/layout/legend.xml

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -132,29 +132,6 @@
132132
android:textAppearance="@style/TextMedium"/>
133133
</LinearLayout>
134134

135-
<LinearLayout
136-
android:layout_width="match_parent"
137-
android:layout_height="wrap_content"
138-
android:orientation="horizontal">
139-
140-
<ImageView
141-
android:id="@+id/ivLockdownOn"
142-
android:layout_width="24dp"
143-
android:layout_height="24dp"
144-
android:layout_gravity="center_vertical"
145-
android:layout_margin="4dp"
146-
android:src="@drawable/lockdown_on"/>
147-
148-
<TextView
149-
android:layout_width="wrap_content"
150-
android:layout_height="wrap_content"
151-
android:layout_gravity="center_vertical"
152-
android:layout_marginLeft="8dp"
153-
android:layout_marginStart="8dp"
154-
android:text="@string/title_lockdown_enabled"
155-
android:textAppearance="@style/TextMedium"/>
156-
</LinearLayout>
157-
158135
<LinearLayout
159136
android:layout_width="match_parent"
160137
android:layout_height="wrap_content"

app/src/main/res/menu/main.xml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,6 @@
5050
</group>
5151
</menu>
5252
</item>
53-
<item
54-
android:id="@+id/menu_lockdown"
55-
android:checkable="true"
56-
android:visible="false"
57-
android:title="@string/setting_lockdown"/>
5853
<item
5954
android:id="@+id/menu_log"
6055
android:title="@string/menu_log"/>

0 commit comments

Comments
 (0)