diff --git a/app/src/main/java/eu/faircode/netguard/AdapterRule.java b/app/src/main/java/eu/faircode/netguard/AdapterRule.java index 44c317e68..8a78516c1 100644 --- a/app/src/main/java/eu/faircode/netguard/AdapterRule.java +++ b/app/src/main/java/eu/faircode/netguard/AdapterRule.java @@ -412,16 +412,21 @@ protected FilterResults performFiltering(CharSequence query) { listResult.addAll(listAll); else { String queryStr = query.toString().toLowerCase().trim(); + // Apps sharing a UID are controlled together by the VPN (#229), so let + // users explicitly search for them all with a "uid:" query. + boolean uidOnly = queryStr.startsWith("uid:"); + String uidStr = uidOnly ? queryStr.substring(4).trim() : queryStr; int uid; try { - uid = Integer.parseInt(queryStr); + uid = Integer.parseInt(uidStr); } catch (NumberFormatException ignore) { uid = -1; } for (Rule rule : listAll) - if (rule.uid == uid || - rule.packageName.toLowerCase().contains(queryStr) || - (rule.name != null && rule.name.toLowerCase().contains(queryStr))) + if (uidOnly ? rule.uid == uid + : rule.uid == uid || + rule.packageName.toLowerCase().contains(queryStr) || + (rule.name != null && rule.name.toLowerCase().contains(queryStr))) listResult.add(rule); } diff --git a/app/src/main/java/net/kollnig/missioncontrol/DetailsActivity.java b/app/src/main/java/net/kollnig/missioncontrol/DetailsActivity.java index 8a598b7b9..8b00144c6 100644 --- a/app/src/main/java/net/kollnig/missioncontrol/DetailsActivity.java +++ b/app/src/main/java/net/kollnig/missioncontrol/DetailsActivity.java @@ -34,6 +34,7 @@ import android.view.MenuItem; import android.view.View; +import android.widget.TextView; import android.widget.Toast; import androidx.appcompat.app.AppCompatActivity; @@ -153,6 +154,10 @@ protected void onCreate(Bundle savedInstanceState) { toolbar.setTitle(getString(R.string.app_info)); toolbar.setSubtitle(appName); + // Show the app's UID, and any other installed packages that share it (#229), + // since blocking rules are applied per-UID and can therefore affect siblings. + showUidInfo(appUid); + // Apply window insets so content avoids status/navigation bars. // Use padding (not margin) so the AppBarLayout's colored background // extends behind the transparent status bar on API 35+. @@ -182,6 +187,37 @@ protected void onCreate(Bundle savedInstanceState) { }); } + /** + * Shows the app's UID and, if any other installed packages share it, + * their names. Blocking rules in TrackerControl are applied per-UID, so + * apps sharing a UID are controlled together (#229) — surfacing this + * avoids surprising users when a setting change affects siblings too. + * + * @param uid The UID of the app being shown + */ + private void showUidInfo(int uid) { + TextView tvUid = findViewById(R.id.tvUid); + if (uid < 0) + return; + + String[] packages = getPackageManager().getPackagesForUid(uid); + StringBuilder others = new StringBuilder(); + if (packages != null) + for (String pkg : packages) + if (!pkg.equals(appPackageName)) { + if (others.length() > 0) + others.append(", "); + others.append(pkg); + } + + String text = getString(R.string.app_uid, uid); + if (others.length() > 0) + text += "\n" + getString(R.string.app_uid_shared_with, others.toString()); + + tvUid.setText(text); + tvUid.setVisibility(View.VISIBLE); + } + @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.menu_details, menu); diff --git a/app/src/main/res/layout/activity_details.xml b/app/src/main/res/layout/activity_details.xml index 65dc15088..8b33dcb63 100644 --- a/app/src/main/res/layout/activity_details.xml +++ b/app/src/main/res/layout/activity_details.xml @@ -25,6 +25,19 @@ app:titleTextColor="@android:color/white" app:subtitleTextColor="@android:color/white" /> + + No Internet access "Cannot block Internet. App is excluded from TrackerControl." + App ID (UID): %1$d + Shares app ID with: %1$s + Back Forever Free