tor-android/src/org/torproject/android/OnBootReceiver.java

48 lines
1.1 KiB
Java
Raw Normal View History

package org.torproject.android;
import org.torproject.android.service.TorService;
import org.torproject.android.service.TorServiceUtils;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
2014-07-20 00:39:42 +00:00
import android.util.Log;
public class OnBootReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
2014-07-20 00:39:42 +00:00
//Log.i(TorService.TAG,"got boot receiver event");
if (intent.getAction() != null
2014-07-17 17:42:59 +00:00
&& Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction()))
{
2014-07-20 00:39:42 +00:00
//Log.i(TorService.TAG,"boot is completed");
SharedPreferences prefs = TorServiceUtils.getSharedPrefs(context.getApplicationContext());
2014-07-20 00:39:42 +00:00
boolean startOnBoot = prefs.getBoolean("pref_start_boot",true);
// Log.i(TorService.TAG,"start on boot: " + startOnBoot);
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);
}
}
}
}