create a new pref: "Allow Background Starts"
This lets the user disable the new ACTION_START Intent, in case they have more sensitive needs.
This commit is contained in:
parent
77b1bdfbc5
commit
ac8329c7f2
|
@ -126,6 +126,8 @@
|
||||||
<string name="pref_entrance_node">Entrance Nodes</string>
|
<string name="pref_entrance_node">Entrance Nodes</string>
|
||||||
<string name="pref_entrance_node_summary">Fingerprints, nicks, countries and addresses for the first hop</string>
|
<string name="pref_entrance_node_summary">Fingerprints, nicks, countries and addresses for the first hop</string>
|
||||||
<string name="pref_entrance_node_dialog">Enter Entrance Nodes</string>
|
<string name="pref_entrance_node_dialog">Enter Entrance Nodes</string>
|
||||||
|
<string name="pref_allow_background_starts_title">Allow Background Starts</string>
|
||||||
|
<string name="pref_allow_background_starts_summary">Let any app tell Orbot to start Tor and related services</string>
|
||||||
|
|
||||||
<string name="button_proxy_all">Proxy All</string>
|
<string name="button_proxy_all">Proxy All</string>
|
||||||
<string name="button_proxy_none">Proxy None</string>
|
<string name="button_proxy_none">Proxy None</string>
|
||||||
|
|
|
@ -22,6 +22,11 @@ android:summary="@string/pref_use_expanded_notifications"
|
||||||
android:enabled="true"
|
android:enabled="true"
|
||||||
android:title="@string/pref_use_expanded_notifications_title"/>
|
android:title="@string/pref_use_expanded_notifications_title"/>
|
||||||
|
|
||||||
|
<CheckBoxPreference
|
||||||
|
android:defaultValue="true"
|
||||||
|
android:key="pref_allow_background_starts"
|
||||||
|
android:summary="@string/pref_allow_background_starts_summary"
|
||||||
|
android:title="@string/pref_allow_background_starts_title"/>
|
||||||
|
|
||||||
<ListPreference android:title="@string/set_locale_title"
|
<ListPreference android:title="@string/set_locale_title"
|
||||||
android:key="pref_default_locale"
|
android:key="pref_default_locale"
|
||||||
|
|
|
@ -16,6 +16,7 @@ public class Prefs {
|
||||||
private final static String PREF_HAS_ROOT = "has_root";
|
private final static String PREF_HAS_ROOT = "has_root";
|
||||||
private final static String PREF_PERSIST_NOTIFICATIONS = "pref_persistent_notifications";
|
private final static String PREF_PERSIST_NOTIFICATIONS = "pref_persistent_notifications";
|
||||||
private final static String PREF_START_ON_BOOT = "pref_start_boot";
|
private final static String PREF_START_ON_BOOT = "pref_start_boot";
|
||||||
|
private final static String PREF_ALLOW_BACKGROUND_STARTS = "pref_allow_background_starts";
|
||||||
private final static String PREF_TRANSPARENT = "pref_transparent";
|
private final static String PREF_TRANSPARENT = "pref_transparent";
|
||||||
private final static String PREF_TRANSPARENT_ALL = "pref_transparent_all";
|
private final static String PREF_TRANSPARENT_ALL = "pref_transparent_all";
|
||||||
private final static String PREF_TRANSPARENT_TETHERING = "pref_transparent_tethering";
|
private final static String PREF_TRANSPARENT_TETHERING = "pref_transparent_tethering";
|
||||||
|
@ -98,6 +99,10 @@ public class Prefs {
|
||||||
return prefs.getBoolean(PREF_PERSIST_NOTIFICATIONS, true);
|
return prefs.getBoolean(PREF_PERSIST_NOTIFICATIONS, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean allowBackgroundStarts() {
|
||||||
|
return prefs.getBoolean(PREF_ALLOW_BACKGROUND_STARTS, true);
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean useVpn() {
|
public static boolean useVpn() {
|
||||||
return prefs.getBoolean(PREF_USE_VPN, false);
|
return prefs.getBoolean(PREF_USE_VPN, false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,13 +6,17 @@ import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
|
||||||
|
import org.torproject.android.Prefs;
|
||||||
|
|
||||||
public class StartTorReceiver extends BroadcastReceiver {
|
public class StartTorReceiver extends BroadcastReceiver {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onReceive(Context context, Intent intent) {
|
public void onReceive(Context context, Intent intent) {
|
||||||
/* sanitize the Intent before forwarding it to TorService */
|
/* sanitize the Intent before forwarding it to TorService */
|
||||||
|
Prefs.setContext(context);
|
||||||
String action = intent.getAction();
|
String action = intent.getAction();
|
||||||
if (TextUtils.equals(action, TorServiceConstants.ACTION_START)) {
|
if (Prefs.allowBackgroundStarts()
|
||||||
|
&& TextUtils.equals(action, TorServiceConstants.ACTION_START)) {
|
||||||
Intent startTorIntent = new Intent(context, TorService.class);
|
Intent startTorIntent = new Intent(context, TorService.class);
|
||||||
startTorIntent.setAction(action);
|
startTorIntent.setAction(action);
|
||||||
String packageName = intent.getStringExtra(TorServiceConstants.EXTRA_PACKAGE_NAME);
|
String packageName = intent.getStringExtra(TorServiceConstants.EXTRA_PACKAGE_NAME);
|
||||||
|
|
Loading…
Reference in New Issue