[tor-commits] [orbot/master] make sure start on boot works properly
n8fr8 at torproject.org
n8fr8 at torproject.org
Thu Jul 17 17:58:37 UTC 2014
commit 29a06410a5771e3d9299b1d7bae72477451911d2
Author: Nathan Freitas <nathan at freitas.net>
Date: Thu Jul 17 13:42:59 2014 -0400
make sure start on boot works properly
---
src/org/torproject/android/OnBootReceiver.java | 11 +++++------
src/org/torproject/android/service/TorService.java | 12 +++---------
2 files changed, 8 insertions(+), 15 deletions(-)
diff --git a/src/org/torproject/android/OnBootReceiver.java b/src/org/torproject/android/OnBootReceiver.java
index 92104e0..8185129 100644
--- a/src/org/torproject/android/OnBootReceiver.java
+++ b/src/org/torproject/android/OnBootReceiver.java
@@ -14,7 +14,7 @@ public class OnBootReceiver extends BroadcastReceiver {
public void onReceive(Context context, Intent intent) {
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());
@@ -23,11 +23,10 @@ public class OnBootReceiver extends BroadcastReceiver {
if (startOnBoot)
{
- //Phase 1: Launch a service
- Intent service = new Intent();
- service.setAction("onboot");
- service.setClass(context, TorService.class);
- context.startService(service);
+ Intent torService = new Intent(context.getApplicationContext(), TorService.class);
+ torService.setAction(Intent.ACTION_BOOT_COMPLETED);
+ context.getApplicationContext().startService(torService);
+
}
}
diff --git a/src/org/torproject/android/service/TorService.java b/src/org/torproject/android/service/TorService.java
index 2ab4c89..88e8082 100644
--- a/src/org/torproject/android/service/TorService.java
+++ b/src/org/torproject/android/service/TorService.java
@@ -364,15 +364,9 @@ public class TorService extends Service implements TorServiceConstants, TorConst
mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
- if (intent != null && intent.getAction()!=null && intent.getAction().equals("onboot"))
- {
-
- boolean startOnBoot = TorServiceUtils.getSharedPrefs(getApplicationContext()).getBoolean("pref_start_boot",false);
-
- if (startOnBoot)
- {
- setTorProfile(PROFILE_ON);
- }
+ if (intent != null && intent.getAction()!=null && intent.getAction().equals(Intent.ACTION_BOOT_COMPLETED))
+ {
+ setTorProfile(PROFILE_ON);
}
}
}
More information about the tor-commits
mailing list