add support for other onboot events, including external storage mount

also version up to ensure install for PIE fix
This commit is contained in:
Nathan Freitas 2014-11-17 14:10:12 -05:00
parent dbd4efe86b
commit f180f13d80
1 changed files with 24 additions and 25 deletions

View File

@ -7,41 +7,40 @@ import android.content.BroadcastReceiver;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences; 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 { public class OnBootReceiver extends BroadcastReceiver {
@Override @Override
public void onReceive(Context context, Intent intent) { public void onReceive(Context context, Intent intent) {
//Log.i(TorService.TAG,"got boot receiver event"); SharedPreferences prefs = TorServiceUtils.getSharedPrefs(context.getApplicationContext());
if (intent.getAction() != null boolean startOnBoot = prefs.getBoolean("pref_start_boot",true);
&& Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction()))
if (startOnBoot)
{ {
startService("init",context);
//Log.i(TorService.TAG,"boot is completed"); startService("start",context);
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);
}
} }
}
private void startService (String action, Context context)
{
Intent torService = new Intent(context, TorService.class);
torService.setAction(action);
context.startService(torService);
} }
} }