Skip to content

Commit

Permalink
TracingMonitor.org temporary disabled.
Browse files Browse the repository at this point in the history
  • Loading branch information
irinil committed Jul 3, 2020
1 parent 227856a commit ab37a38
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 46 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Expand Up @@ -146,7 +146,7 @@ android {
debug {
debuggable true
jniDebuggable true
testCoverageEnabled true
// testCoverageEnabled true
resValue "string", "google_maps_api_key", "AIzaSyDs3xp1-2KQojns5h7mWHHdQxAL-5AZ-q4"
}
if (doSigningForRelease) {
Expand Down
9 changes: 8 additions & 1 deletion src/main/java/de/tudarmstadt/informatik/hostage/Handler.java
Expand Up @@ -151,13 +151,20 @@ public void kill() {
} catch (Exception e) {

}
//uploadTracing();
listener.refreshHandlers();
}

@Deprecated
//TODO Temporary removed TracingMonitor
private void uploadTracing(){
boolean upload = pref.getBoolean("pref_auto_synchronize", false);
if(upload){
Intent intent = new Intent(service, TracingSyncService.class);
intent.setAction(TracingSyncService.ACTION_START_SYNC);
service.startService(intent);
}
listener.refreshHandlers();

}

/**
Expand Down
Expand Up @@ -71,45 +71,45 @@ public void onPerformSync(Account account, Bundle extras, String authority, Cont
// We will only do a one-direction sync. That is, only sending data to the tracing server.
// For bidirectional syncing, we will still have to decide how much data should be requested from the server,
// because the server has relatively to a mobile device almost unlimited space.

Log.i(TAG, "Beginning network synchronization");

long lastSyncTime = pref.getLong("LAST_SYNC_TIME", 0);

String serverAddress = pref.getString("pref_upload_server", "https://www.tracingmonitor.org"); //"https://192.168.1.118:9999"

Log.i(TAG, "Connecting to " + serverAddress);
LogFilter filter = new LogFilter();
filter.setAboveTimestamp(lastSyncTime);
//int recordsSize = daoHelper.getMessageRecordDAO().getRecordCount();
records = this.daoHelper.getAttackRecordDAO().getRecordsForFilter(filter, offset);

StringWriter writer = new StringWriter();

int size = records.size();
int offset = 1;
int currOffset = 1;
boolean error = false;
for (RecordAll record : records) {
SyncUtils.appendRecordToStringWriter(record, writer);

if(currOffset == 100 || offset == size){
boolean success = SyncUtils.uploadRecordsToServer(writer.toString(), serverAddress);
if(success){
syncResult.stats.numIoExceptions++;
error = true;
break;
}

writer.getBuffer().setLength(0);
currOffset = 0;
}

offset++;
currOffset++;
}

if(!error) pref.edit().putLong("LAST_SYNC_TIME", System.currentTimeMillis()).apply();
Log.i(TAG, "Network synchronization complete");
//TODO temporary remove tracemonitoring
// Log.i(TAG, "Beginning network synchronization");
//
// long lastSyncTime = pref.getLong("LAST_SYNC_TIME", 0);
//
// String serverAddress = pref.getString("pref_upload_server", "https://www.tracingmonitor.org"); //"https://192.168.1.118:9999"
//
// Log.i(TAG, "Connecting to " + serverAddress);
// LogFilter filter = new LogFilter();
// filter.setAboveTimestamp(lastSyncTime);
// //TODO recordCound for performance
// records = this.daoHelper.getAttackRecordDAO().getRecordsForFilter(filter, offset);
//
// StringWriter writer = new StringWriter();
//
// int size = records.size();
// int offset = 1;
// int currOffset = 1;
// boolean error = false;
// for (RecordAll record : records) {
// SyncUtils.appendRecordToStringWriter(record, writer);
//
// if(currOffset == 100 || offset == size){
// boolean success = SyncUtils.uploadRecordsToServer(writer.toString(), serverAddress);
// if(success){
// syncResult.stats.numIoExceptions++;
// error = true;
// break;
// }
//
// writer.getBuffer().setLength(0);
// currOffset = 0;
// }
//
// offset++;
// currOffset++;
// }
//
// if(!error) pref.edit().putLong("LAST_SYNC_TIME", System.currentTimeMillis()).apply();
// Log.i(TAG, "Network synchronization complete");
}
}
Expand Up @@ -230,7 +230,7 @@ public static void appendRecordToStringWriter(RecordAll record, Writer stream){
}
}


@Deprecated
public static boolean uploadRecordsToServer(String entity, String serverAddress){
HttpPost httppost;
try {
Expand Down
Expand Up @@ -13,6 +13,7 @@
* Starts a synchronization service and shows the progress of the synchronization.
* @author Lars Pandikow
*/
@Deprecated
public class TracingSyncActivity extends Activity implements TracingSyncResultReciever.Receiver{

TextView mInfoText;
Expand Down
Expand Up @@ -33,6 +33,7 @@
*
* @author Lars Pandikow
*/
@Deprecated
public class TracingSyncService extends IntentService {

public static final String REMOTE_DEVICE = "de.tudarmstadt.informatik.hostage.REMOTE_DEVICE";
Expand Down Expand Up @@ -98,6 +99,7 @@ protected void onHandleIntent(Intent intent) {
/**
* Uploads all new Records to a server, specified in the settings.
*/
@Deprecated
private void syncNewRecords() {
long lastSyncTime = pref.getLong("LAST_SYNC_TIME", 0);

Expand Down
Expand Up @@ -59,7 +59,6 @@
import de.tudarmstadt.informatik.hostage.persistence.DAO.DAOHelper;
import de.tudarmstadt.informatik.hostage.sync.android.SyncUtils;
import de.tudarmstadt.informatik.hostage.sync.bluetooth.BluetoothSyncActivity;
import de.tudarmstadt.informatik.hostage.sync.tracing.TracingSyncActivity;
import de.tudarmstadt.informatik.hostage.sync.wifi_direct.ui.WiFiP2pSyncActivity;
import de.tudarmstadt.informatik.hostage.ui.activity.MainActivity;
import de.tudarmstadt.informatik.hostage.ui.adapter.RecordListAdapter;
Expand Down Expand Up @@ -445,9 +444,9 @@ public void onClick(DialogInterface dialog, int position) {
/*case 1:
getActivity().startActivity(new Intent(getActivity(), NFCSyncActivity.class));
break;*/

//TODO Temporary removed TracingMonitor
case 1:
startActivityForResult(new Intent(getActivity(), TracingSyncActivity.class), 0);
//startActivityForResult(new Intent(getActivity(), TracingSyncActivity.class), 0);
break;
case 2:
startActivityForResult(new Intent(getActivity(), WiFiP2pSyncActivity.class), 0);
Expand Down

0 comments on commit ab37a38

Please sign in to comment.