summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--res/menu/logmenu.xml2
-rwxr-xr-xres/values/strings.xml4
-rw-r--r--res/xml/general_settings.xml12
-rw-r--r--src/de/blinkt/openvpn/api/ConfirmDialog.java1
-rw-r--r--src/de/blinkt/openvpn/api/ExternalAppDatabase.java6
-rw-r--r--src/de/blinkt/openvpn/api/ExternalOpenVPNService.java4
-rw-r--r--src/de/blinkt/openvpn/fragments/GeneralSettings.java110
7 files changed, 114 insertions, 25 deletions
diff --git a/res/menu/logmenu.xml b/res/menu/logmenu.xml
index 9e79702c..12b54c67 100644
--- a/res/menu/logmenu.xml
+++ b/res/menu/logmenu.xml
@@ -11,7 +11,7 @@
android:id="@+id/cancel"
android:icon="@android:drawable/ic_menu_close_clear_cancel"
android:showAsAction="ifRoom|withText"
- android:title="@string/cancel_connection"
+ android:title="@string/disconnect"
android:titleCondensed="@string/cancel"/>
<item
android:id="@+id/info"
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 3e969f18..abdf1779 100755
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -57,6 +57,7 @@
<string name="custom_config_summary">Specify custom options. Use with care!</string>
<string name="route_rejected">Route rejected by Android</string>
<string name="cancel_connection">Disconnect</string>
+ <string name="disconnect">Disconnect</string>
<string name="clear_log">clear log</string>
<string name="title_cancel">Cancel Confirmation</string>
<string name="cancel_connection_query">Disconnect the connected VPN/cancel the connection attempt?</string>
@@ -281,5 +282,8 @@
<string name="prompt">%1$s attempts to control %2$s</string>
<string name="remote_warning">By proceeding, you are giving the application permission to completely control OpenVPN for Android and to intercept all network traffic. <b> Do NOT accept unless you trust the application. </b> Otherwise, you run the risk of having your data compromised by malicious software."</string>
<string name="remote_trust">I trust this application.</string>
+ <string name="no_external_app_allowed">No app allowed to use external API</string>
+ <string name="allowed_apps">Allowed apps: %s</string>
+ <string name="clearappsdialog">Clear list of allowed external apps?\nCurrent list of allowed apps:\n\n%s</string>
</resources> \ No newline at end of file
diff --git a/res/xml/general_settings.xml b/res/xml/general_settings.xml
index 5b4726d3..6dbf58bf 100644
--- a/res/xml/general_settings.xml
+++ b/res/xml/general_settings.xml
@@ -11,11 +11,13 @@
android:key="showlogwindow"
android:summary="@string/show_log_summary"
android:title="@string/show_log_window" />
- <!-- <CheckBoxPreference
+ <!--
+ <CheckBoxPreference
android:defaultValue="false"
android:key="statusafterconnect"
android:summary="@string/keppstatus_summary"
- android:title="@string/keepstatus" /> -->
+ android:title="@string/keepstatus" />
+ -->
<CheckBoxPreference
android:defaultValue="true"
android:key="usesystemproxy"
@@ -27,6 +29,11 @@
android:summary="@string/onbootrestartsummary"
android:title="@string/onbootrestart" />
+ <Preference
+ android:key="clearapi"
+ android:title="Clear allowed external apps"
+ android:persistent="false" />
+
<PreferenceCategory android:title="Device specifics Hacks" >
<CheckBoxPreference
android:defaultValue="false"
@@ -40,5 +47,4 @@
android:title="@string/setting_loadtun" />
</PreferenceCategory>
-
</PreferenceScreen> \ No newline at end of file
diff --git a/src/de/blinkt/openvpn/api/ConfirmDialog.java b/src/de/blinkt/openvpn/api/ConfirmDialog.java
index f72f4921..dfd01884 100644
--- a/src/de/blinkt/openvpn/api/ConfirmDialog.java
+++ b/src/de/blinkt/openvpn/api/ConfirmDialog.java
@@ -73,6 +73,7 @@ CompoundButton.OnCheckedChangeListener, DialogInterface.OnClickListener {
builder.setNegativeButton(android.R.string.cancel,this);
mAlert = builder.create();
+ mAlert.setCanceledOnTouchOutside(false);
mAlert.setOnShowListener (new OnShowListener() {
diff --git a/src/de/blinkt/openvpn/api/ExternalAppDatabase.java b/src/de/blinkt/openvpn/api/ExternalAppDatabase.java
index ca348152..e640a13a 100644
--- a/src/de/blinkt/openvpn/api/ExternalAppDatabase.java
+++ b/src/de/blinkt/openvpn/api/ExternalAppDatabase.java
@@ -25,12 +25,12 @@ public class ExternalAppDatabase {
}
- Set<String> getExtAppList() {
+ public Set<String> getExtAppList() {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(mContext);
Set<String> allowedapps = prefs.getStringSet(PREFERENCES_KEY, new HashSet<String>());
return allowedapps;
}
-
+
void addApp(String packagename)
{
Set<String> allowedapps = getExtAppList();
@@ -45,7 +45,7 @@ public class ExternalAppDatabase {
prefedit.apply();
}
- void clearAllApiApps() {
+ public void clearAllApiApps() {
saveExtAppList(new HashSet<String>());
}
diff --git a/src/de/blinkt/openvpn/api/ExternalOpenVPNService.java b/src/de/blinkt/openvpn/api/ExternalOpenVPNService.java
index fff6c34f..9e6ac9f3 100644
--- a/src/de/blinkt/openvpn/api/ExternalOpenVPNService.java
+++ b/src/de/blinkt/openvpn/api/ExternalOpenVPNService.java
@@ -244,7 +244,9 @@ public class ExternalOpenVPNService extends Service implements StateListener {
@Override
public void updateState (String state, String logmessage, int resid, ConnectionStatus level) {
mMostRecentState = new UpdateMessage(state, logmessage, level);
- mHandler.obtainMessage(SEND_TOALL, mMostRecentState);
+ Message msg = mHandler.obtainMessage(SEND_TOALL, mMostRecentState);
+ msg.sendToTarget();
+
}
private static final Handler mHandler = new Handler() {
diff --git a/src/de/blinkt/openvpn/fragments/GeneralSettings.java b/src/de/blinkt/openvpn/fragments/GeneralSettings.java
index 4ac0a8ac..bf391d29 100644
--- a/src/de/blinkt/openvpn/fragments/GeneralSettings.java
+++ b/src/de/blinkt/openvpn/fragments/GeneralSettings.java
@@ -1,31 +1,107 @@
package de.blinkt.openvpn.fragments;
import java.io.File;
+import android.app.AlertDialog;
+import android.app.AlertDialog.Builder;
+import android.app.Dialog;
+import android.content.DialogInterface;
+import android.content.DialogInterface.OnClickListener;
+import android.content.pm.ApplicationInfo;
+import android.content.pm.PackageManager;
+import android.content.pm.PackageManager.NameNotFoundException;
import android.os.Bundle;
import android.preference.Preference;
+import android.preference.Preference.OnPreferenceClickListener;
import android.preference.PreferenceFragment;
import de.blinkt.openvpn.R;
+import de.blinkt.openvpn.api.ExternalAppDatabase;
-public class GeneralSettings extends PreferenceFragment {
+public class GeneralSettings extends PreferenceFragment implements OnPreferenceClickListener, OnClickListener {
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
+ private ExternalAppDatabase mExtapp;
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+
+ // Load the preferences from an XML resource
+ addPreferencesFromResource(R.xml.general_settings);
+
+ Preference loadtun = findPreference("loadTunModule");
+ if(!isTunModuleAvailable())
+ loadtun.setEnabled(false);
- // Load the preferences from an XML resource
- addPreferencesFromResource(R.xml.general_settings);
- Preference loadtun = findPreference("loadTunModule");
- if(!isTunModuleAvailable())
- loadtun.setEnabled(false);
+ mExtapp = new ExternalAppDatabase(getActivity());
+ Preference clearapi = findPreference("clearapi");
+ clearapi.setOnPreferenceClickListener(this);
+
+ setClearApiSummary();
+ }
+
+ private void setClearApiSummary() {
+ Preference clearapi = findPreference("clearapi");
+
+ if(mExtapp.getExtAppList().isEmpty()) {
+ clearapi.setEnabled(false);
+ clearapi.setSummary(R.string.no_external_app_allowed);
+ } else {
+ clearapi.setEnabled(true);
+ clearapi.setSummary(getString(R.string.allowed_apps,getExtAppList(", ")));
}
+ }
+
+ private String getExtAppList(String delim) {
+ ApplicationInfo app;
+ PackageManager pm = getActivity().getPackageManager();
+
+ String applist=null;
+ for (String packagename : mExtapp.getExtAppList()) {
+ try {
+ app = pm.getApplicationInfo(packagename, 0);
+ if (applist==null)
+ applist = "";
+ else
+ applist += delim;
+ applist+=app.loadLabel(pm);
- private boolean isTunModuleAvailable() {
- // Check if the tun module exists on the file system
- if(new File("/system/lib/modules/tun.ko").length() > 10)
- return true;
- return false;
+ } catch (NameNotFoundException e) {
+ // App not found. Remove it from the list
+ mExtapp.removeApp(packagename);
+ }
}
-
- } \ No newline at end of file
+ return applist;
+ }
+
+ private boolean isTunModuleAvailable() {
+ // Check if the tun module exists on the file system
+ if(new File("/system/lib/modules/tun.ko").length() > 10)
+ return true;
+ return false;
+ }
+
+ @Override
+ public boolean onPreferenceClick(Preference preference) {
+ if(preference.getKey().equals("clearapi")){
+ Builder builder = new AlertDialog.Builder(getActivity());
+ builder.setPositiveButton(R.string.clear, this);
+ builder.setNegativeButton(android.R.string.cancel, null);
+ builder.setMessage(getString(R.string.clearappsdialog,getExtAppList("\n")));
+ builder.show();
+ }
+
+ return true;
+ }
+
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ if( which == Dialog.BUTTON_POSITIVE){
+ mExtapp.clearAllApiApps();
+ setClearApiSummary();
+ }
+ }
+
+
+
+} \ No newline at end of file