diff --git a/src/org/torproject/android/service/OnBootReceiver.java b/src/org/torproject/android/service/OnBootReceiver.java index ef40619e..b04a6a19 100644 --- a/src/org/torproject/android/service/OnBootReceiver.java +++ b/src/org/torproject/android/service/OnBootReceiver.java @@ -1,10 +1,12 @@ package org.torproject.android.service; +import android.annotation.SuppressLint; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; +import android.net.VpnService; public class OnBootReceiver extends BroadcastReceiver { @@ -14,15 +16,29 @@ public class OnBootReceiver extends BroadcastReceiver { SharedPreferences prefs = TorServiceUtils.getSharedPrefs(context.getApplicationContext()); boolean startOnBoot = prefs.getBoolean("pref_start_boot",true); + boolean useVPN = prefs.getBoolean("pref_vpn",true); if (startOnBoot) { - startService("init",context); - startService("start",context); + if (useVPN) + startVpnService(context); + + startService(TorServiceConstants.CMD_INIT,context); + startService(TorServiceConstants.CMD_START,context); + } } + @SuppressLint("NewApi") + public void startVpnService (Context context) + { + Intent intent = VpnService.prepare(context); + if (intent != null) { + context.startActivity(intent); + } + + } private void startService (String action, Context context) {