mirror of
https://github.com/moparisthebest/SSLDroid
synced 2024-11-23 09:22:16 -05:00
8e3cd92b69
started manually Signed-off-by: Balint Kovacs <blint@blint.hu>
44 lines
1.3 KiB
Java
44 lines
1.3 KiB
Java
package hu.blint.ssldroid;
|
|
|
|
import hu.blint.ssldroid.db.SSLDroidDbAdapter;
|
|
import android.content.BroadcastReceiver;
|
|
import android.content.Context;
|
|
import android.content.Intent;
|
|
import android.database.Cursor;
|
|
import android.util.Log;
|
|
|
|
public class BootStartupReceiver extends BroadcastReceiver {
|
|
|
|
private boolean isStopped(Context context){
|
|
Boolean stopped = false;
|
|
SSLDroidDbAdapter dbHelper;
|
|
dbHelper = new SSLDroidDbAdapter(context);
|
|
dbHelper.open();
|
|
Cursor cursor = dbHelper.getStopStatus();
|
|
|
|
int tunnelcount = cursor.getCount();
|
|
Log.d("SSLDroid", "Tunnelcount: "+tunnelcount);
|
|
|
|
//don't start if the stop status field is available
|
|
if (tunnelcount != 0){
|
|
stopped = true;
|
|
}
|
|
|
|
cursor.close();
|
|
dbHelper.close();
|
|
|
|
return stopped;
|
|
}
|
|
|
|
@Override
|
|
public void onReceive(Context context, Intent intent) {
|
|
if (intent.getAction().equals(Intent.ACTION_BOOT_COMPLETED)) {
|
|
Intent i = new Intent();
|
|
i.setAction("hu.blint.ssldroid.SSLDroid");
|
|
if (!isStopped(context))
|
|
context.startService(i);
|
|
else
|
|
Log.w("SSLDroid", "Not starting service as directed by explicit stop");
|
|
}
|
|
}
|
|
} |