Enable support for app selection to work with VPN mode on Lollipop+
For now we will re-use/overload the app selection transproxy UI in Settings
This commit is contained in:
parent
bf8113cd19
commit
1b6126e3d0
|
@ -50,7 +50,6 @@ android:defaultValue="false"
|
||||||
android:key="pref_transparent"
|
android:key="pref_transparent"
|
||||||
android:title="@string/pref_trans_proxy_title"
|
android:title="@string/pref_trans_proxy_title"
|
||||||
android:summary="@string/pref_trans_proxy_summary"
|
android:summary="@string/pref_trans_proxy_summary"
|
||||||
android:dependency="has_root"
|
|
||||||
android:enabled="true"/>
|
android:enabled="true"/>
|
||||||
|
|
||||||
<CheckBoxPreference
|
<CheckBoxPreference
|
||||||
|
@ -58,7 +57,6 @@ android:defaultValue="false"
|
||||||
android:key="pref_transparent_all"
|
android:key="pref_transparent_all"
|
||||||
android:summary="@string/pref_transparent_all_summary"
|
android:summary="@string/pref_transparent_all_summary"
|
||||||
android:enabled="true"
|
android:enabled="true"
|
||||||
android:dependency="has_root"
|
|
||||||
android:title="@string/pref_transparent_all_title"/>
|
android:title="@string/pref_transparent_all_title"/>
|
||||||
|
|
||||||
<Preference
|
<Preference
|
||||||
|
@ -66,7 +64,6 @@ android:defaultValue=""
|
||||||
android:key="pref_transparent_app_list"
|
android:key="pref_transparent_app_list"
|
||||||
android:title="@string/pref_select_apps"
|
android:title="@string/pref_select_apps"
|
||||||
android:summary="@string/pref_select_apps_summary"
|
android:summary="@string/pref_select_apps_summary"
|
||||||
android:dependency="has_root"
|
|
||||||
android:enabled="true"/>
|
android:enabled="true"/>
|
||||||
|
|
||||||
<CheckBoxPreference
|
<CheckBoxPreference
|
||||||
|
|
|
@ -965,7 +965,7 @@ public class OrbotMainActivity extends Activity
|
||||||
|
|
||||||
|
|
||||||
})
|
})
|
||||||
.setNegativeButton(android.R.string.cancel, new Dialog.OnClickListener ()
|
.setNegativeButton(R.string.btn_cancel, new Dialog.OnClickListener ()
|
||||||
{
|
{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -6,6 +6,7 @@ package org.torproject.android.settings;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.preference.CheckBoxPreference;
|
import android.preference.CheckBoxPreference;
|
||||||
import android.preference.EditTextPreference;
|
import android.preference.EditTextPreference;
|
||||||
|
@ -21,6 +22,7 @@ import info.guardianproject.util.Languages;
|
||||||
import org.sufficientlysecure.rootcommands.RootCommands;
|
import org.sufficientlysecure.rootcommands.RootCommands;
|
||||||
import org.sufficientlysecure.rootcommands.Shell;
|
import org.sufficientlysecure.rootcommands.Shell;
|
||||||
import org.torproject.android.OrbotApp;
|
import org.torproject.android.OrbotApp;
|
||||||
|
import org.torproject.android.Prefs;
|
||||||
import org.torproject.android.R;
|
import org.torproject.android.R;
|
||||||
import org.torproject.android.service.TorServiceUtils;
|
import org.torproject.android.service.TorServiceUtils;
|
||||||
|
|
||||||
|
@ -97,21 +99,33 @@ public class SettingsPreferences
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
prefTransProxyApps = findPreference("pref_transparent_app_list");
|
prefTransProxyApps = findPreference("pref_transparent_app_list");
|
||||||
prefTransProxyApps.setOnPreferenceClickListener(this);
|
prefTransProxyApps.setOnPreferenceClickListener(this);
|
||||||
prefTransProxyApps.setEnabled(prefCBTransProxy.isChecked()
|
|
||||||
&& (!prefcBTransProxyAll.isChecked()));
|
|
||||||
|
|
||||||
prefCBTransProxy.setOnPreferenceClickListener(this);
|
prefCBTransProxy.setOnPreferenceClickListener(this);
|
||||||
prefcBTransProxyAll.setOnPreferenceClickListener(this);
|
prefcBTransProxyAll.setOnPreferenceClickListener(this);
|
||||||
prefcBTransProxyAll.setEnabled(prefCBTransProxy.isChecked());
|
|
||||||
|
|
||||||
prefHiddenServices = (CheckBoxPreference) findPreference("pref_hs_enable");
|
prefHiddenServices = (CheckBoxPreference) findPreference("pref_hs_enable");
|
||||||
prefHiddenServices.setOnPreferenceClickListener(this);
|
prefHiddenServices.setOnPreferenceClickListener(this);
|
||||||
prefHiddenServicesPorts = (EditTextPreference) findPreference("pref_hs_ports");
|
|
||||||
prefHiddenServicesPorts.setEnabled(prefHiddenServices.isChecked());
|
|
||||||
prefHiddenServicesHostname = (EditTextPreference) findPreference("pref_hs_hostname");
|
prefHiddenServicesHostname = (EditTextPreference) findPreference("pref_hs_hostname");
|
||||||
|
|
||||||
|
|
||||||
|
prefCBTransProxy.setEnabled(prefRequestRoot.isChecked());
|
||||||
|
|
||||||
|
prefcBTransProxyAll.setEnabled(prefCBTransProxy.isChecked());
|
||||||
|
|
||||||
|
if (prefCBTransProxy.isChecked())
|
||||||
|
prefTransProxyApps.setEnabled((!prefcBTransProxyAll.isChecked()));
|
||||||
|
|
||||||
|
prefHiddenServicesPorts = (EditTextPreference) findPreference("pref_hs_ports");
|
||||||
prefHiddenServicesHostname.setEnabled(prefHiddenServices.isChecked());
|
prefHiddenServicesHostname.setEnabled(prefHiddenServices.isChecked());
|
||||||
|
prefHiddenServicesPorts.setEnabled(prefHiddenServices.isChecked());
|
||||||
|
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
|
||||||
|
{
|
||||||
|
prefTransProxyApps.setEnabled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean onPreferenceClick(Preference preference) {
|
public boolean onPreferenceClick(Preference preference) {
|
||||||
|
@ -134,7 +148,8 @@ public class SettingsPreferences
|
||||||
shell.close();
|
shell.close();
|
||||||
|
|
||||||
prefRequestRoot.setChecked(true);
|
prefRequestRoot.setChecked(true);
|
||||||
|
prefCBTransProxy.setEnabled(true);
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
|
|
@ -17,10 +17,13 @@
|
||||||
package org.torproject.android.vpn;
|
package org.torproject.android.vpn;
|
||||||
|
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
import org.torproject.android.service.TorServiceConstants;
|
import org.torproject.android.service.TorServiceConstants;
|
||||||
import org.torproject.android.service.TorServiceUtils;
|
import org.torproject.android.service.TorServiceUtils;
|
||||||
|
import org.torproject.android.settings.AppManager;
|
||||||
|
import org.torproject.android.settings.TorifiedApp;
|
||||||
|
|
||||||
import android.annotation.TargetApi;
|
import android.annotation.TargetApi;
|
||||||
import android.app.PendingIntent;
|
import android.app.PendingIntent;
|
||||||
|
@ -178,9 +181,6 @@ public class OrbotVpnService extends VpnService implements Handler.Callback {
|
||||||
|
|
||||||
private void stopVPN ()
|
private void stopVPN ()
|
||||||
{
|
{
|
||||||
|
|
||||||
Tun2Socks.Stop();
|
|
||||||
|
|
||||||
//stopSocksBypass ();
|
//stopSocksBypass ();
|
||||||
|
|
||||||
if (mInterface != null){
|
if (mInterface != null){
|
||||||
|
@ -202,8 +202,14 @@ public class OrbotVpnService extends VpnService implements Handler.Callback {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Tun2Socks.Stop();
|
||||||
|
|
||||||
mThreadVPN = null;
|
mThreadVPN = null;
|
||||||
|
|
||||||
|
|
||||||
|
// Tun2Socks.Stop();
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -293,7 +299,24 @@ public class OrbotVpnService extends VpnService implements Handler.Callback {
|
||||||
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||||
private void doLollipopAppRouting (Builder builder) throws NameNotFoundException
|
private void doLollipopAppRouting (Builder builder) throws NameNotFoundException
|
||||||
{
|
{
|
||||||
builder.addDisallowedApplication("org.torproject.android");
|
|
||||||
|
ArrayList<TorifiedApp> 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
|
@Override
|
||||||
|
|
Loading…
Reference in New Issue