From 627e93cbc8b58433f219afe4c776a51b2791ddfb Mon Sep 17 00:00:00 2001 From: Arne Schwabe Date: Fri, 14 Feb 2014 18:59:32 +0100 Subject: further build fixing --HG-- rename : vpndialogxposed/src/main/java/de/blinkt/vpndialogxposed/allowedVPNsChooser.java => vpndialogxposed/src/main/java/de/blinkt/vpndialogxposed/AllowedVPNsChooser.java --- vpndialogxposed/build.gradle | 8 +- .../blinkt/vpndialogxposed/AllowedVPNsChooser.java | 150 +++++++++++++++++++++ .../blinkt/vpndialogxposed/allowedVPNsChooser.java | 150 --------------------- 3 files changed, 154 insertions(+), 154 deletions(-) create mode 100644 vpndialogxposed/src/main/java/de/blinkt/vpndialogxposed/AllowedVPNsChooser.java delete mode 100644 vpndialogxposed/src/main/java/de/blinkt/vpndialogxposed/allowedVPNsChooser.java (limited to 'vpndialogxposed') diff --git a/vpndialogxposed/build.gradle b/vpndialogxposed/build.gradle index f073cee5..ea989197 100644 --- a/vpndialogxposed/build.gradle +++ b/vpndialogxposed/build.gradle @@ -3,7 +3,7 @@ buildscript { mavenCentral() } dependencies { - classpath 'com.android.tools.build:gradle:0.5.+' + classpath 'com.android.tools.build:gradle:0.8.+' } } @@ -23,12 +23,12 @@ dependencies { android { - compileSdkVersion 18 - buildToolsVersion "18.1" + compileSdkVersion 19 + buildToolsVersion "19.0.1" defaultConfig { minSdkVersion 14 - targetSdkVersion 17 + targetSdkVersion 19 versionCode = 3 versionName = "0.3" diff --git a/vpndialogxposed/src/main/java/de/blinkt/vpndialogxposed/AllowedVPNsChooser.java b/vpndialogxposed/src/main/java/de/blinkt/vpndialogxposed/AllowedVPNsChooser.java new file mode 100644 index 00000000..199f23fb --- /dev/null +++ b/vpndialogxposed/src/main/java/de/blinkt/vpndialogxposed/AllowedVPNsChooser.java @@ -0,0 +1,150 @@ +package de.blinkt.vpndialogxposed; + +import android.Manifest; +import android.app.ListActivity; +import android.content.Context; +import android.content.Intent; +import android.content.SharedPreferences; +import android.content.pm.*; +import android.os.Bundle; +import android.widget.AbsListView; +import android.widget.ArrayAdapter; +import android.widget.ListAdapter; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.*; + + +/** + * Created by arne on 06.10.13. + */ +public class AllowedVPNsChooser extends ListActivity { + + public static final String ALLOWED_APPS = "allowedApps"; + + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + Collection vpnApps = getVpnAppList(); + ListAdapter la = new ArrayAdapter(this, android.R.layout.simple_list_item_multiple_choice, vpnApps.toArray(new VpnApp[vpnApps.size()])); + setListAdapter(la); + setContentView(R.layout.vpnapplayout); + getListView().setChoiceMode(AbsListView.CHOICE_MODE_MULTIPLE); + + + Collection allowedapps = getAllowedApps(); + for(int i=0; i < vpnApps.size(); i++) { + VpnApp va= (VpnApp) getListView().getItemAtPosition(i); + boolean allowed = allowedapps.contains(va.mPkg); + getListView().setItemChecked(i,allowed); + } + + } + + + + private Collection getAllowedApps(){ + SharedPreferences prefs = getPreferences(MODE_WORLD_READABLE); + HashSet defaultapps = new HashSet(); + defaultapps.add("de.blinkt.openvpn"); + return prefs.getStringSet(ALLOWED_APPS,defaultapps ); + } + + private void saveAllowedApps(Set allowedApps) + { + SharedPreferences prefs = getPreferences(MODE_WORLD_READABLE); + prefs.edit().putStringSet(ALLOWED_APPS,allowedApps) + .putInt("random",new Random().nextInt()).apply(); + } + + + @Override + protected void onStop() { + super.onStop(); + + HashSet allowedPkgs= new HashSet(); + for(int i=0;i < getListView().getChildCount();i++) { + if(getListView().getCheckedItemPositions().get(i)) { + allowedPkgs.add(((VpnApp)getListView().getItemAtPosition(i)).mPkg); + } + } + saveAllowedApps(allowedPkgs); + } + + private Collection getVpnAppList() { + PackageManager pm = getPackageManager(); + Intent vpnOpen = new Intent(); + vpnOpen.setAction("android.net.VpnService"); + Vector vpnApps = new Vector(); + + // Hack but should work + for(PackageInfo pkg : pm.getInstalledPackages(PackageManager.GET_SERVICES)) { + if (pkg.services != null) { + for(ServiceInfo serviceInfo:pkg.services) { + if(Manifest.permission.BIND_VPN_SERVICE.equals(serviceInfo.permission)) + vpnApps.add(new VpnApp(pkg.applicationInfo.loadLabel(pm), pkg.packageName)); + } + } + } + + + /* public abstract List queryIntentServicesAsUser(Intent intent, + int flags, int userId); + */ + + /* This does not work ... */ + /* + Class[] queryIntentServicesAsUserSignature = {Intent.class, int.class, int.class}; + try { + Method queryIntentServicesAsUser = pm.getClass().getMethod("queryIntentServicesAsUser", queryIntentServicesAsUserSignature); + + List installedApps = pm.getInstalledApplications(0); + + + + for (ApplicationInfo app : installedApps) { + + List apps; + if (app.packageName.equals(getPackageName())) { + apps = pm.queryIntentServices(vpnOpen, 0); + } else { + apps = (List) queryIntentServicesAsUser.invoke(pm, vpnOpen, 0, app.uid); + } + + + + for (ResolveInfo ri : apps) { + vpnApps.add(new VpnApp(ri.toString())); + } + } + } catch (NoSuchMethodException e) { + e.printStackTrace(); + } catch (InvocationTargetException e) { + e.printStackTrace(); + } catch (IllegalAccessException e) { + e.printStackTrace(); + } + */ + + return vpnApps; + } + + static class VpnApp { + + private final String mPkg; + private CharSequence mName; + + public VpnApp(CharSequence name, String pkg) { + mName = name; + mPkg = pkg; + } + + @Override + public String toString() { + return mName.toString(); + } + } +} diff --git a/vpndialogxposed/src/main/java/de/blinkt/vpndialogxposed/allowedVPNsChooser.java b/vpndialogxposed/src/main/java/de/blinkt/vpndialogxposed/allowedVPNsChooser.java deleted file mode 100644 index 199f23fb..00000000 --- a/vpndialogxposed/src/main/java/de/blinkt/vpndialogxposed/allowedVPNsChooser.java +++ /dev/null @@ -1,150 +0,0 @@ -package de.blinkt.vpndialogxposed; - -import android.Manifest; -import android.app.ListActivity; -import android.content.Context; -import android.content.Intent; -import android.content.SharedPreferences; -import android.content.pm.*; -import android.os.Bundle; -import android.widget.AbsListView; -import android.widget.ArrayAdapter; -import android.widget.ListAdapter; - -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.util.*; - - -/** - * Created by arne on 06.10.13. - */ -public class AllowedVPNsChooser extends ListActivity { - - public static final String ALLOWED_APPS = "allowedApps"; - - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - - Collection vpnApps = getVpnAppList(); - ListAdapter la = new ArrayAdapter(this, android.R.layout.simple_list_item_multiple_choice, vpnApps.toArray(new VpnApp[vpnApps.size()])); - setListAdapter(la); - setContentView(R.layout.vpnapplayout); - getListView().setChoiceMode(AbsListView.CHOICE_MODE_MULTIPLE); - - - Collection allowedapps = getAllowedApps(); - for(int i=0; i < vpnApps.size(); i++) { - VpnApp va= (VpnApp) getListView().getItemAtPosition(i); - boolean allowed = allowedapps.contains(va.mPkg); - getListView().setItemChecked(i,allowed); - } - - } - - - - private Collection getAllowedApps(){ - SharedPreferences prefs = getPreferences(MODE_WORLD_READABLE); - HashSet defaultapps = new HashSet(); - defaultapps.add("de.blinkt.openvpn"); - return prefs.getStringSet(ALLOWED_APPS,defaultapps ); - } - - private void saveAllowedApps(Set allowedApps) - { - SharedPreferences prefs = getPreferences(MODE_WORLD_READABLE); - prefs.edit().putStringSet(ALLOWED_APPS,allowedApps) - .putInt("random",new Random().nextInt()).apply(); - } - - - @Override - protected void onStop() { - super.onStop(); - - HashSet allowedPkgs= new HashSet(); - for(int i=0;i < getListView().getChildCount();i++) { - if(getListView().getCheckedItemPositions().get(i)) { - allowedPkgs.add(((VpnApp)getListView().getItemAtPosition(i)).mPkg); - } - } - saveAllowedApps(allowedPkgs); - } - - private Collection getVpnAppList() { - PackageManager pm = getPackageManager(); - Intent vpnOpen = new Intent(); - vpnOpen.setAction("android.net.VpnService"); - Vector vpnApps = new Vector(); - - // Hack but should work - for(PackageInfo pkg : pm.getInstalledPackages(PackageManager.GET_SERVICES)) { - if (pkg.services != null) { - for(ServiceInfo serviceInfo:pkg.services) { - if(Manifest.permission.BIND_VPN_SERVICE.equals(serviceInfo.permission)) - vpnApps.add(new VpnApp(pkg.applicationInfo.loadLabel(pm), pkg.packageName)); - } - } - } - - - /* public abstract List queryIntentServicesAsUser(Intent intent, - int flags, int userId); - */ - - /* This does not work ... */ - /* - Class[] queryIntentServicesAsUserSignature = {Intent.class, int.class, int.class}; - try { - Method queryIntentServicesAsUser = pm.getClass().getMethod("queryIntentServicesAsUser", queryIntentServicesAsUserSignature); - - List installedApps = pm.getInstalledApplications(0); - - - - for (ApplicationInfo app : installedApps) { - - List apps; - if (app.packageName.equals(getPackageName())) { - apps = pm.queryIntentServices(vpnOpen, 0); - } else { - apps = (List) queryIntentServicesAsUser.invoke(pm, vpnOpen, 0, app.uid); - } - - - - for (ResolveInfo ri : apps) { - vpnApps.add(new VpnApp(ri.toString())); - } - } - } catch (NoSuchMethodException e) { - e.printStackTrace(); - } catch (InvocationTargetException e) { - e.printStackTrace(); - } catch (IllegalAccessException e) { - e.printStackTrace(); - } - */ - - return vpnApps; - } - - static class VpnApp { - - private final String mPkg; - private CharSequence mName; - - public VpnApp(CharSequence name, String pkg) { - mName = name; - mPkg = pkg; - } - - @Override - public String toString() { - return mName.toString(); - } - } -} -- cgit v1.2.3