make sure start on boot works properly
This commit is contained in:
parent
54a39f2046
commit
29a06410a5
|
@ -14,7 +14,7 @@ public class OnBootReceiver extends BroadcastReceiver {
|
||||||
public void onReceive(Context context, Intent intent) {
|
public void onReceive(Context context, Intent intent) {
|
||||||
|
|
||||||
if (intent.getAction() != null
|
if (intent.getAction() != null
|
||||||
&& intent.getAction().equals("android.intent.action.BOOT_COMPLETED"))
|
&& Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction()))
|
||||||
{
|
{
|
||||||
|
|
||||||
SharedPreferences prefs = TorServiceUtils.getSharedPrefs(context.getApplicationContext());
|
SharedPreferences prefs = TorServiceUtils.getSharedPrefs(context.getApplicationContext());
|
||||||
|
@ -23,11 +23,10 @@ public class OnBootReceiver extends BroadcastReceiver {
|
||||||
|
|
||||||
if (startOnBoot)
|
if (startOnBoot)
|
||||||
{
|
{
|
||||||
//Phase 1: Launch a service
|
Intent torService = new Intent(context.getApplicationContext(), TorService.class);
|
||||||
Intent service = new Intent();
|
torService.setAction(Intent.ACTION_BOOT_COMPLETED);
|
||||||
service.setAction("onboot");
|
context.getApplicationContext().startService(torService);
|
||||||
service.setClass(context, TorService.class);
|
|
||||||
context.startService(service);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -364,18 +364,12 @@ public class TorService extends Service implements TorServiceConstants, TorConst
|
||||||
|
|
||||||
mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
|
mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
|
||||||
|
|
||||||
if (intent != null && intent.getAction()!=null && intent.getAction().equals("onboot"))
|
if (intent != null && intent.getAction()!=null && intent.getAction().equals(Intent.ACTION_BOOT_COMPLETED))
|
||||||
{
|
|
||||||
|
|
||||||
boolean startOnBoot = TorServiceUtils.getSharedPrefs(getApplicationContext()).getBoolean("pref_start_boot",false);
|
|
||||||
|
|
||||||
if (startOnBoot)
|
|
||||||
{
|
{
|
||||||
setTorProfile(PROFILE_ON);
|
setTorProfile(PROFILE_ON);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Log.e(TAG,"error onBind",e);
|
Log.e(TAG,"error onBind",e);
|
||||||
|
|
Loading…
Reference in New Issue