From f180f13d80e3d2f4903d4222a29f70e898c32b35 Mon Sep 17 00:00:00 2001 From: Nathan Freitas Date: Mon, 17 Nov 2014 14:10:12 -0500 Subject: [PATCH] add support for other onboot events, including external storage mount also version up to ensure install for PIE fix --- .../torproject/android/OnBootReceiver.java | 49 +++++++++---------- 1 file changed, 24 insertions(+), 25 deletions(-) diff --git a/src/org/torproject/android/OnBootReceiver.java b/src/org/torproject/android/OnBootReceiver.java index 652e5c9a..2876a261 100644 --- a/src/org/torproject/android/OnBootReceiver.java +++ b/src/org/torproject/android/OnBootReceiver.java @@ -7,40 +7,39 @@ import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; -import android.util.Log; +import android.content.pm.ApplicationInfo; +import android.content.pm.PackageInfo; +import android.content.pm.PackageManager; +import android.content.pm.PackageManager.NameNotFoundException; +import android.os.Build.VERSION; public class OnBootReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { - - //Log.i(TorService.TAG,"got boot receiver event"); - if (intent.getAction() != null - && Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction())) + SharedPreferences prefs = TorServiceUtils.getSharedPrefs(context.getApplicationContext()); + + boolean startOnBoot = prefs.getBoolean("pref_start_boot",true); + + if (startOnBoot) { - - //Log.i(TorService.TAG,"boot is completed"); - - SharedPreferences prefs = TorServiceUtils.getSharedPrefs(context.getApplicationContext()); - - boolean startOnBoot = prefs.getBoolean("pref_start_boot",true); - - // Log.i(TorService.TAG,"start on boot: " + startOnBoot); - - - if (startOnBoot) - { - Intent torService = new Intent(context.getApplicationContext(), TorService.class); - torService.setAction(Intent.ACTION_BOOT_COMPLETED); - context.getApplicationContext().startService(torService); - - } + startService("init",context); + startService("start",context); } - - - } + } + + + private void startService (String action, Context context) + { + + Intent torService = new Intent(context, TorService.class); + torService.setAction(action); + context.startService(torService); + + + } }