[tor-commits] [orbot/master] add support for other onboot events, including external storage mount

n8fr8 at torproject.org n8fr8 at torproject.org
Mon Nov 17 21:49:30 UTC 2014


commit f180f13d80e3d2f4903d4222a29f70e898c32b35
Author: Nathan Freitas <nathan at freitas.net>
Date:   Mon Nov 17 14:10:12 2014 -0500

    add support for other onboot events, including external storage mount
    also version up to ensure install for PIE fix
---
 src/org/torproject/android/OnBootReceiver.java |   45 ++++++++++++------------
 1 file changed, 22 insertions(+), 23 deletions(-)

diff --git a/src/org/torproject/android/OnBootReceiver.java b/src/org/torproject/android/OnBootReceiver.java
index 652e5c9..2876a26 100644
--- a/src/org/torproject/android/OnBootReceiver.java
+++ b/src/org/torproject/android/OnBootReceiver.java
@@ -7,40 +7,39 @@ import android.content.BroadcastReceiver;
 import android.content.Context;
 import android.content.Intent;
 import android.content.SharedPreferences;
-import android.util.Log;
+import android.content.pm.ApplicationInfo;
+import android.content.pm.PackageInfo;
+import android.content.pm.PackageManager;
+import android.content.pm.PackageManager.NameNotFoundException;
+import android.os.Build.VERSION;
 
 public class OnBootReceiver extends BroadcastReceiver {
 	
 	@Override
 	public void onReceive(Context context, Intent intent) {
-
-		//Log.i(TorService.TAG,"got boot receiver event");
 		
-		if (intent.getAction() != null 
-				&& Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction()))
-		{
+		SharedPreferences prefs = TorServiceUtils.getSharedPrefs(context.getApplicationContext());
+		
+		boolean startOnBoot = prefs.getBoolean("pref_start_boot",true);
 		
-			//Log.i(TorService.TAG,"boot is completed");
-			
-			SharedPreferences prefs = TorServiceUtils.getSharedPrefs(context.getApplicationContext());
-			
-			boolean startOnBoot = prefs.getBoolean("pref_start_boot",true);
-			
-		//	Log.i(TorService.TAG,"start on boot: " + startOnBoot);
-			
-			
-			if (startOnBoot)
-			{
-				Intent torService = new Intent(context.getApplicationContext(), TorService.class);
-				torService.setAction(Intent.ACTION_BOOT_COMPLETED);
-				context.getApplicationContext().startService(torService);
-				
-			}
+		if (startOnBoot)
+		{
+			startService("init",context);
+			startService("start",context);			
 		}
+
+	}
 	
+
+	private void startService (String action, Context context)
+	{
 		
+		Intent torService = new Intent(context, TorService.class);    
+		torService.setAction(action);
+		context.startService(torService);
+		
+        
 	}
-
 	
 	
 }





More information about the tor-commits mailing list