commit b1294f6d60eacf19c291a372ceeb509701964bb6 Author: Nathan Freitas nathan@freitas.net Date: Sat Feb 14 00:43:13 2015 -0500
improve start on boot --- .../torproject/android/service/OnBootReceiver.java | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-)
diff --git a/src/org/torproject/android/service/OnBootReceiver.java b/src/org/torproject/android/service/OnBootReceiver.java index ef40619..b04a6a1 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) {
tor-commits@lists.torproject.org