Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions app/src/main/java/eu/faircode/netguard/AdapterRule.java
Original file line number Diff line number Diff line change
Expand Up @@ -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:<number>" 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);
}

Expand Down
36 changes: 36 additions & 0 deletions app/src/main/java/net/kollnig/missioncontrol/DetailsActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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+.
Expand Down Expand Up @@ -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);
Expand Down
13 changes: 13 additions & 0 deletions app/src/main/res/layout/activity_details.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,19 @@
app:titleTextColor="@android:color/white"
app:subtitleTextColor="@android:color/white" />

<TextView
android:id="@+id/tvUid"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:layout_marginBottom="4dp"
android:textColor="@android:color/white"
android:textSize="12sp"
android:alpha="0.75"
android:visibility="gone"
tools:text="App ID (UID): 10123" />

<com.google.android.material.tabs.TabLayout
android:id="@+id/tabs"
android:layout_width="match_parent"
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -636,6 +636,9 @@ Sincerely,\n\n]]></string>
<string name="no_internet">No Internet access</string>
<string name="bypass_vpn_error">"Cannot block Internet. App is excluded from TrackerControl."</string>

<string name="app_uid">App ID (UID): %1$d</string>
<string name="app_uid_shared_with">Shares app ID with: %1$s</string>

<string name="back">Back</string>

<string name="forever_free">Forever Free</string>
Expand Down