|
@@ -8,12 +8,8 @@ import de.tudarmstadt.informatik.hostage.persistence.HostageDBOpenHelper;
|
|
|
public class Logger extends IntentService {
|
|
|
|
|
|
private static final String ACTION_LOG = "de.tudarmstadt.informatik.hostage.action.LOG";
|
|
|
- private static final String ACTION_DELETE_BY_BSSID = "de.tudarmstadt.informatik.hostage.action.DELETE_BY_BSSID";
|
|
|
- private static final String ACTION_DELETE_BY_DATE = "de.tudarmstadt.informatik.hostage.action.DELETE_BY_DATE";
|
|
|
- private static final String ACTION_DELETE_ALL = "de.tudarmstadt.informatik.hostage.action.DELETE_ALL";
|
|
|
|
|
|
private static final String EXTRA_RECORD = "de.tudarmstadt.informatik.hostage.extra.RECORD";
|
|
|
- private static final String EXTRA_MISC = "de.tudarmstadt.informatik.hostage.extra.MISC";
|
|
|
|
|
|
public static void log(Context context, Record record) {
|
|
|
Intent intent = new Intent(context, Logger.class);
|
|
@@ -22,26 +18,6 @@ public class Logger extends IntentService {
|
|
|
context.startService(intent);
|
|
|
}
|
|
|
|
|
|
- public static void deleteByBssid(Context context, String bssid) {
|
|
|
- Intent intent = new Intent(context, Logger.class);
|
|
|
- intent.setAction(ACTION_DELETE_BY_BSSID);
|
|
|
- intent.putExtra(EXTRA_MISC, bssid);
|
|
|
- context.startService(intent);
|
|
|
- }
|
|
|
-
|
|
|
- public static void deleteByDate(Context context, long timestamp) {
|
|
|
- Intent intent = new Intent(context, Logger.class);
|
|
|
- intent.setAction(ACTION_DELETE_BY_DATE);
|
|
|
- intent.putExtra(EXTRA_MISC, timestamp);
|
|
|
- context.startService(intent);
|
|
|
- }
|
|
|
-
|
|
|
- public static void deleteAll(Context context) {
|
|
|
- Intent intent = new Intent(context, Logger.class);
|
|
|
- intent.setAction(ACTION_DELETE_ALL);
|
|
|
- context.startService(intent);
|
|
|
- }
|
|
|
-
|
|
|
private HostageDBOpenHelper mDbHelper;
|
|
|
|
|
|
public Logger() {
|
|
@@ -58,18 +34,6 @@ public class Logger extends IntentService {
|
|
|
mDbHelper.addRecord(record);
|
|
|
}
|
|
|
|
|
|
- private void handleActionDeleteByBssid(String bssid) {
|
|
|
- mDbHelper.deleteByBSSID(bssid);
|
|
|
- }
|
|
|
-
|
|
|
- private void handleActionDeleteByDate(long timestamp) {
|
|
|
- mDbHelper.deleteByDate(timestamp);
|
|
|
- }
|
|
|
-
|
|
|
- private void handleActionDeleteAll() {
|
|
|
- mDbHelper.clearData();
|
|
|
- }
|
|
|
-
|
|
|
@Override
|
|
|
protected void onHandleIntent(Intent intent) {
|
|
|
if (intent != null) {
|
|
@@ -77,14 +41,6 @@ public class Logger extends IntentService {
|
|
|
if (ACTION_LOG.equals(action)) {
|
|
|
final Record record = intent.getParcelableExtra(EXTRA_RECORD);
|
|
|
handleActionLog(record);
|
|
|
- } else if (ACTION_DELETE_BY_BSSID.equals(action)) {
|
|
|
- final String bssid = intent.getStringExtra(EXTRA_MISC);
|
|
|
- handleActionDeleteByBssid(bssid);
|
|
|
- } else if (ACTION_DELETE_BY_DATE.equals(action)) {
|
|
|
- final long timestamp = intent.getLongExtra(EXTRA_MISC, -1L);
|
|
|
- handleActionDeleteByDate(timestamp);
|
|
|
- } else if (ACTION_DELETE_ALL.equals(action)) {
|
|
|
- handleActionDeleteAll();
|
|
|
}
|
|
|
}
|
|
|
}
|