From 3a6855aff9aef5aef664ce56d8a930458474b88a Mon Sep 17 00:00:00 2001 From: Arne Schwabe Date: Mon, 1 Dec 2014 00:51:09 +0100 Subject: Fine tune for next release, remove debug message, ignore apps with system id --HG-- extra : rebase_source : b9f8135b8b98cb501f7ad548e22ae40b931b8de9 --- .../de/blinkt/openvpn/core/OpenVPNService.java | 8 ++++---- .../openvpn/fragments/Settings_Allowed_Apps.java | 22 +++++++++++++++++++--- main/src/main/res/layout/vpn_profile_list.xml | 2 +- 3 files changed, 24 insertions(+), 8 deletions(-) (limited to 'main') diff --git a/main/src/main/java/de/blinkt/openvpn/core/OpenVPNService.java b/main/src/main/java/de/blinkt/openvpn/core/OpenVPNService.java index f12d24a5..29009e5c 100644 --- a/main/src/main/java/de/blinkt/openvpn/core/OpenVPNService.java +++ b/main/src/main/java/de/blinkt/openvpn/core/OpenVPNService.java @@ -267,8 +267,8 @@ public class OpenVPNService extends VpnService implements StateListener, Callbac registerReceiver(mDeviceStateReceiver, filter); VpnStatus.addByteCountListener(mDeviceStateReceiver); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) - addLollipopCMListener(); + /*if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) + addLollipopCMListener(); */ } synchronized void unregisterDeviceStateReceiver() { @@ -284,8 +284,8 @@ public class OpenVPNService extends VpnService implements StateListener, Callbac } mDeviceStateReceiver = null; - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) - removeLollipopCMListener(); + /*if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) + removeLollipopCMListener();*/ } 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 60b2a200..309f5447 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 @@ -80,11 +80,10 @@ public class Settings_Allowed_Apps extends Fragment implements AdapterView.OnIte } - static class PackageAdapter extends BaseAdapter { + class PackageAdapter extends BaseAdapter { private final List mPackages; private final LayoutInflater mInflater; private final PackageManager mPm; - private final VpnProfile mProfile; PackageAdapter(Context c, VpnProfile vp) { mPm = c.getPackageManager(); @@ -94,13 +93,30 @@ public class Settings_Allowed_Apps extends Fragment implements AdapterView.OnIte // Remove apps not using Internet + int androidSystemUid=0; + ApplicationInfo system = null; Vector apps= new Vector(); + + try { + system = mPm.getApplicationInfo("android", PackageManager.GET_META_DATA); + androidSystemUid = system.uid; + apps.add(system); + } catch (PackageManager.NameNotFoundException e) { + } + + for (ApplicationInfo app:installedPackages) { - if (mPm.checkPermission(Manifest.permission.INTERNET, app.packageName) == PackageManager.PERMISSION_GRANTED) + + if (mPm.checkPermission(Manifest.permission.INTERNET, app.packageName) == PackageManager.PERMISSION_GRANTED && + app.uid != androidSystemUid) { + apps.add(app); + } } + + Collections.sort(apps, new ApplicationInfo.DisplayNameComparator(mPm)); mPackages=apps; diff --git a/main/src/main/res/layout/vpn_profile_list.xml b/main/src/main/res/layout/vpn_profile_list.xml index 3ea89bdd..082ffd77 100644 --- a/main/src/main/res/layout/vpn_profile_list.xml +++ b/main/src/main/res/layout/vpn_profile_list.xml @@ -74,6 +74,6 @@ - + -- cgit v1.2.3