diff --git a/res/xml/preferences.xml b/res/xml/preferences.xml index e1e1828a..f34548e6 100644 --- a/res/xml/preferences.xml +++ b/res/xml/preferences.xml @@ -50,7 +50,6 @@ android:defaultValue="false" android:key="pref_transparent" android:title="@string/pref_trans_proxy_title" android:summary="@string/pref_trans_proxy_summary" -android:dependency="has_root" android:enabled="true"/> = Build.VERSION_CODES.LOLLIPOP) + { + prefTransProxyApps.setEnabled(true); + } + + } public boolean onPreferenceClick(Preference preference) { @@ -134,7 +148,8 @@ public class SettingsPreferences shell.close(); prefRequestRoot.setChecked(true); - + prefCBTransProxy.setEnabled(true); + } catch (Exception e) { diff --git a/src/org/torproject/android/vpn/OrbotVpnService.java b/src/org/torproject/android/vpn/OrbotVpnService.java index e2020781..2fe3daa7 100644 --- a/src/org/torproject/android/vpn/OrbotVpnService.java +++ b/src/org/torproject/android/vpn/OrbotVpnService.java @@ -17,10 +17,13 @@ package org.torproject.android.vpn; import java.net.InetAddress; +import java.util.ArrayList; import java.util.Locale; import org.torproject.android.service.TorServiceConstants; import org.torproject.android.service.TorServiceUtils; +import org.torproject.android.settings.AppManager; +import org.torproject.android.settings.TorifiedApp; import android.annotation.TargetApi; import android.app.PendingIntent; @@ -178,9 +181,6 @@ public class OrbotVpnService extends VpnService implements Handler.Callback { private void stopVPN () { - - Tun2Socks.Stop(); - //stopSocksBypass (); if (mInterface != null){ @@ -202,8 +202,14 @@ public class OrbotVpnService extends VpnService implements Handler.Callback { } } + Tun2Socks.Stop(); + mThreadVPN = null; + + // Tun2Socks.Stop(); + + } @Override @@ -293,7 +299,24 @@ public class OrbotVpnService extends VpnService implements Handler.Callback { @TargetApi(Build.VERSION_CODES.LOLLIPOP) private void doLollipopAppRouting (Builder builder) throws NameNotFoundException { - builder.addDisallowedApplication("org.torproject.android"); + + ArrayList apps = AppManager.getApps(this, TorServiceUtils.getSharedPrefs(getApplicationContext())); + + boolean appAllowed = false; + + for (TorifiedApp app : apps) + { + if (app.isTorified()) + { + builder.addAllowedApplication(app.getUsername()); + appAllowed = true; + } + + } + + if (!appAllowed) + builder.addDisallowedApplication(getPackageName()); + } @Override