2010-07-28 04:43:58 +00:00
|
|
|
package org.torproject.android;
|
|
|
|
|
2011-05-10 02:08:16 +00:00
|
|
|
import org.torproject.android.service.TorService;
|
|
|
|
|
2010-07-28 04:43:58 +00:00
|
|
|
import android.content.BroadcastReceiver;
|
|
|
|
import android.content.Context;
|
|
|
|
import android.content.Intent;
|
2012-02-27 03:47:25 +00:00
|
|
|
import android.content.SharedPreferences;
|
|
|
|
import android.preference.PreferenceManager;
|
2010-07-28 04:43:58 +00:00
|
|
|
|
|
|
|
public class OnBootReceiver extends BroadcastReceiver {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onReceive(Context context, Intent intent) {
|
|
|
|
|
2011-05-10 02:08:16 +00:00
|
|
|
if (intent.getAction() != null
|
|
|
|
&& intent.getAction().equals("android.intent.action.BOOT_COMPLETED"))
|
|
|
|
{
|
2012-02-27 03:47:25 +00:00
|
|
|
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);
|
|
|
|
}
|
2011-05-10 02:08:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-07-28 04:43:58 +00:00
|
|
|
}
|
|
|
|
|
2011-04-15 16:39:22 +00:00
|
|
|
|
2010-07-28 04:43:58 +00:00
|
|
|
}
|
|
|
|
|