[or-cvs] r23291: {} adding new classes for handling on boot (in projects/android/trunk/Orbot/src/org/torproject/android: . boot)

Nathan Freitas nathan at freitas.net
Thu Sep 23 21:03:40 UTC 2010


Author: n8fr8
Date: 2010-09-23 21:03:40 +0000 (Thu, 23 Sep 2010)
New Revision: 23291

Added:
   projects/android/trunk/Orbot/src/org/torproject/android/boot/
   projects/android/trunk/Orbot/src/org/torproject/android/boot/OnbootBroadcastReceiver.java
Log:
adding new classes for handling on boot

Added: projects/android/trunk/Orbot/src/org/torproject/android/boot/OnbootBroadcastReceiver.java
===================================================================
--- projects/android/trunk/Orbot/src/org/torproject/android/boot/OnbootBroadcastReceiver.java	                        (rev 0)
+++ projects/android/trunk/Orbot/src/org/torproject/android/boot/OnbootBroadcastReceiver.java	2010-09-23 21:03:40 UTC (rev 23291)
@@ -0,0 +1,37 @@
+package org.torproject.android.boot;
+
+import org.torproject.android.service.ITorService;
+import org.torproject.android.service.TorService;
+import org.torproject.android.service.TorServiceConstants;
+
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.content.SharedPreferences;
+import android.preference.PreferenceManager;
+import android.util.Log;
+
+public class OnbootBroadcastReceiver extends BroadcastReceiver implements TorServiceConstants {
+	@Override
+	public void onReceive(Context context, Intent intent) {
+		
+		Log.d(TAG, "received on boot notification");
+		
+		SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
+		
+		boolean startOnBoot = prefs.getBoolean("pref_start_boot",true);
+		
+		Log.d(TAG, "startOnBoot:" + startOnBoot);
+		
+		if (startOnBoot)
+		{
+			Intent serviceIntent = new Intent(context,TorService.class);
+			serviceIntent.setAction("onboot");
+			context.startService(serviceIntent);
+		}
+		
+		//bindService(new Intent(ITorService.class.getName()),
+          //      mConnection, Context.BIND_AUTO_CREATE);
+	}
+
+}
\ No newline at end of file



More information about the tor-commits mailing list