[tor-commits] [orbot/master] fixed OnBoot issue with unintended service starting

n8fr8 at torproject.org n8fr8 at torproject.org
Mon Feb 27 04:24:19 UTC 2012


commit 697f5aa2f1c7e1eb07282644edc9a609b4b51304
Author: Nathan Freitas <nathan at freitas.net>
Date:   Sun Feb 26 22:47:25 2012 -0500

    fixed OnBoot issue with unintended service starting
---
 src/org/torproject/android/OnBootReceiver.java |   19 ++++++++++++++-----
 1 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/src/org/torproject/android/OnBootReceiver.java b/src/org/torproject/android/OnBootReceiver.java
index dbc66a7..59de240 100644
--- a/src/org/torproject/android/OnBootReceiver.java
+++ b/src/org/torproject/android/OnBootReceiver.java
@@ -5,6 +5,8 @@ import org.torproject.android.service.TorService;
 import android.content.BroadcastReceiver;
 import android.content.Context;
 import android.content.Intent;
+import android.content.SharedPreferences;
+import android.preference.PreferenceManager;
 
 public class OnBootReceiver extends BroadcastReceiver {
 	
@@ -14,11 +16,18 @@ public class OnBootReceiver extends BroadcastReceiver {
 		if (intent.getAction() != null 
 				&& intent.getAction().equals("android.intent.action.BOOT_COMPLETED"))
 		{
-			//Phase 1: Launch a service
-			Intent service = new Intent();
-			service.setAction("onboot");
-			service.setClass(context, TorService.class);
-			context.startService(service);
+			SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
+			
+			boolean startOnBoot = prefs.getBoolean("pref_start_boot",false);
+			
+			if (startOnBoot)
+			{
+				//Phase 1: Launch a service
+				Intent service = new Intent();
+				service.setAction("onboot");
+				service.setClass(context, TorService.class);
+				context.startService(service);
+			}
 		}
 	
 		





More information about the tor-commits mailing list