add support for other onboot events, including external storage mount
also version up to ensure install for PIE fix
This commit is contained in:
parent
dbd4efe86b
commit
f180f13d80
|
@ -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");
|
|
||||||
|
|
||||||
if (intent.getAction() != null
|
|
||||||
&& Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction()))
|
|
||||||
{
|
|
||||||
|
|
||||||
//Log.i(TorService.TAG,"boot is completed");
|
|
||||||
|
|
||||||
SharedPreferences prefs = TorServiceUtils.getSharedPrefs(context.getApplicationContext());
|
SharedPreferences prefs = TorServiceUtils.getSharedPrefs(context.getApplicationContext());
|
||||||
|
|
||||||
boolean startOnBoot = prefs.getBoolean("pref_start_boot",true);
|
boolean startOnBoot = prefs.getBoolean("pref_start_boot",true);
|
||||||
|
|
||||||
// Log.i(TorService.TAG,"start on boot: " + startOnBoot);
|
|
||||||
|
|
||||||
|
|
||||||
if (startOnBoot)
|
if (startOnBoot)
|
||||||
{
|
{
|
||||||
Intent torService = new Intent(context.getApplicationContext(), TorService.class);
|
startService("init",context);
|
||||||
torService.setAction(Intent.ACTION_BOOT_COMPLETED);
|
startService("start",context);
|
||||||
context.getApplicationContext().startService(torService);
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void startService (String action, Context context)
|
||||||
|
{
|
||||||
|
|
||||||
|
Intent torService = new Intent(context, TorService.class);
|
||||||
|
torService.setAction(action);
|
||||||
|
context.startService(torService);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue