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;
|
2014-04-25 16:44:21 +00:00
|
|
|
import org.torproject.android.service.TorServiceUtils;
|
2011-05-10 02:08:16 +00:00
|
|
|
|
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;
|
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
|
2014-07-17 17:42:59 +00:00
|
|
|
&& Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction()))
|
2011-05-10 02:08:16 +00:00
|
|
|
{
|
2014-04-25 16:44:21 +00:00
|
|
|
|
|
|
|
SharedPreferences prefs = TorServiceUtils.getSharedPrefs(context.getApplicationContext());
|
2012-02-27 03:47:25 +00:00
|
|
|
|
|
|
|
boolean startOnBoot = prefs.getBoolean("pref_start_boot",false);
|
|
|
|
|
|
|
|
if (startOnBoot)
|
|
|
|
{
|
2014-07-17 17:42:59 +00:00
|
|
|
Intent torService = new Intent(context.getApplicationContext(), TorService.class);
|
|
|
|
torService.setAction(Intent.ACTION_BOOT_COMPLETED);
|
|
|
|
context.getApplicationContext().startService(torService);
|
|
|
|
|
2012-02-27 03:47:25 +00:00
|
|
|
}
|
2011-05-10 02:08:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-07-28 04:43:58 +00:00
|
|
|
}
|
|
|
|
|
2011-04-15 16:39:22 +00:00
|
|
|
|
2014-04-25 16:44:21 +00:00
|
|
|
|
2010-07-28 04:43:58 +00:00
|
|
|
}
|
|
|
|
|