|
@@ -61,8 +61,6 @@ import android.widget.Toast;
|
|
|
*/
|
|
|
public class ViewLog extends Activity {
|
|
|
|
|
|
- public static final int JSON = 0x01;
|
|
|
-
|
|
|
private final SimpleDateFormat sdf = new SimpleDateFormat("MMM dd,yyyy HH:mm", Locale.US);
|
|
|
|
|
|
private Logger logger;
|
|
@@ -196,53 +194,36 @@ public class ViewLog extends Activity {
|
|
|
builder.setOnlyAlertOnce(false);
|
|
|
mNotifyManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
|
|
|
mNotifyManager.notify(2, builder.build());
|
|
|
+ final Context context = this;
|
|
|
// Create a new Thread for upload
|
|
|
new Thread(new Runnable() {
|
|
|
public void run() {
|
|
|
- // Create a https client. Uses MySSLSocketFactory to accept all certificates
|
|
|
- HttpClient httpclient = HelperUtils.createHttpClient();
|
|
|
// get RecordList
|
|
|
ArrayList<Record> recordList = logger.getRecordOfEachAttack(lastUploadedAttackId);
|
|
|
final int progressMax = recordList.size();
|
|
|
Log.i("SQLLogger", "Logs to upload: " + progressMax);
|
|
|
- HttpPost httppost;
|
|
|
+
|
|
|
int progressBarStatus = 0;
|
|
|
int retry_counter = 0;
|
|
|
while(progressBarStatus < progressMax){
|
|
|
Record record = recordList.get(progressBarStatus);
|
|
|
if(record.getExternalIP() != null){
|
|
|
- Log.i("SQLLogger", "Uploading log: " + progressBarStatus);
|
|
|
- try {
|
|
|
- // Create HttpPost
|
|
|
- httppost = new HttpPost(pref.getString("pref_upload", "https://ssi.cased.de"));
|
|
|
- // Create JSON String of Record
|
|
|
- StringEntity se = new StringEntity(record.toString(JSON));
|
|
|
- httppost.setEntity(se);
|
|
|
- // Execute HttpPost
|
|
|
- HttpResponse response = httpclient.execute(httppost);
|
|
|
- Log.i("SQLLogger", "Statuscode of log " + progressBarStatus + ": " + " " + response.getStatusLine().getReasonPhrase());
|
|
|
- Log.i("SQLLogger", "Statuscode of log " + progressBarStatus + ": " + " " + response.getStatusLine().getStatusCode());
|
|
|
retry_counter = 0;
|
|
|
- // Update Notification progress bar
|
|
|
- progressBarStatus++;
|
|
|
- builder.setProgress(progressMax, progressBarStatus, false);
|
|
|
- // Update the progress bar
|
|
|
- mNotifyManager.notify(2, builder.build());
|
|
|
- } catch (Exception e) {
|
|
|
-
|
|
|
+ if(HelperUtils.uploadSingleRecord(context, record)){
|
|
|
+ // Update Notification progress bar
|
|
|
+ progressBarStatus++;
|
|
|
+ builder.setProgress(progressMax, progressBarStatus, false);
|
|
|
+ // Update the progress bar
|
|
|
+ mNotifyManager.notify(2, builder.build());
|
|
|
+ }else{
|
|
|
retry_counter++;
|
|
|
if(retry_counter == 3){
|
|
|
retry_counter = 0;
|
|
|
progressBarStatus++;
|
|
|
- Log.i("SQLLogger", "Upload of log " + progressBarStatus + " failed. Continue with next log");
|
|
|
- } else {
|
|
|
- Log.i("SQLLogger", "Upload of log " + progressBarStatus + " failed...retry");
|
|
|
- }
|
|
|
-
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
if(progressBarStatus == progressMax){
|
|
|
// When the loop is finished, updates the notification
|
|
@@ -256,6 +237,8 @@ public class ViewLog extends Activity {
|
|
|
editor.putInt("LAST_UPLOADED_ATTACK_ID",currentAttackId - 1);
|
|
|
editor.commit();
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* Starts a ViewLogTable Activity.
|