From ea90e689585a364efa191f183c740d048e0a2018 Mon Sep 17 00:00:00 2001 From: Arne Schwabe Date: Wed, 19 Nov 2014 00:21:18 +0100 Subject: Only list apps with INTERNET permission in app list. --HG-- extra : rebase_source : 016a9c0cf440b66ccbd311dca4e3dc937ed40730 --- .../blinkt/openvpn/fragments/Settings_Allowed_Apps.java | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'main/src') diff --git a/main/src/main/java/de/blinkt/openvpn/fragments/Settings_Allowed_Apps.java b/main/src/main/java/de/blinkt/openvpn/fragments/Settings_Allowed_Apps.java index ed6e9c7c..bfba0ed6 100644 --- a/main/src/main/java/de/blinkt/openvpn/fragments/Settings_Allowed_Apps.java +++ b/main/src/main/java/de/blinkt/openvpn/fragments/Settings_Allowed_Apps.java @@ -5,6 +5,7 @@ package de.blinkt.openvpn.fragments; +import android.Manifest; import android.app.Fragment; import android.content.Context; import android.content.pm.ApplicationInfo; @@ -24,7 +25,9 @@ import android.widget.Switch; import android.widget.TextView; import java.util.Collections; +import java.util.LinkedList; import java.util.List; +import java.util.Vector; import de.blinkt.openvpn.R; import de.blinkt.openvpn.VpnProfile; @@ -81,10 +84,20 @@ public class Settings_Allowed_Apps extends Fragment { PackageAdapter(Context c, VpnProfile vp) { mPm = c.getPackageManager(); mProfile = vp; - mPackages = mPm.getInstalledApplications(PackageManager.GET_META_DATA); + List installedPackages = mPm.getInstalledApplications(PackageManager.GET_META_DATA); mInflater = LayoutInflater.from(c); - Collections.sort(mPackages, new ApplicationInfo.DisplayNameComparator(mPm)); + // Remove apps not using Internet + + Vector apps= new Vector(); + for (ApplicationInfo app:installedPackages) { + if (mPm.checkPermission(Manifest.permission.INTERNET, app.packageName) == PackageManager.PERMISSION_GRANTED) + apps.add(app); + } + + + Collections.sort(apps, new ApplicationInfo.DisplayNameComparator(mPm)); + mPackages=apps; } @Override -- cgit v1.2.3