Skip to content

Commit

Permalink
change name
Browse files Browse the repository at this point in the history
  • Loading branch information
quietbamboo committed Nov 2, 2011
1 parent 72e55c6 commit a4899c6
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 2 deletions.
59 changes: 59 additions & 0 deletions client/src/com/mobiperf/service/TcpdumpService.java
@@ -0,0 +1,59 @@
package com.mobiperf.service;

import java.util.Date;
import java.util.Timer;
import java.util.TimerTask;

import com.mobiperf.InformationCenter;
import com.mobiperf.Tcpdump;

import android.app.Service;
import android.content.Intent;
import android.os.IBinder;

public class TcpdumpService extends Service {

public class Worker extends TimerTask {
public void run() {

Tcpdump.terminate_client();

//if current network is WiFi, upload trace
if(InformationCenter.getNetworkTypeName().equals("WIFI")){
//upload traces, delete old files

//scan the whole directory and upload all files, in upload delete old file
Tcpdump.upload();

}

Tcpdump.start_client();

Timer timer = new Timer(false);
//timer.schedule(new Worker(), new Date(System.currentTimeMillis() + 4 * 60 * 60 * 1000));
timer.schedule(new Worker(), new Date(System.currentTimeMillis() + 60 * 1000));
}
}
@Override
public IBinder onBind(Intent intent) {
return null;
}

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
Timer timer = new Timer(false);
timer.schedule(new Worker(), new Date(System.currentTimeMillis() + 1000));
return START_STICKY;
}

@Override
public void onDestroy() {
super.onDestroy();
Tcpdump.terminate_client();
}





}
2 changes: 1 addition & 1 deletion client/src/com/mobiperf/ui/TrafficPerApplication.java
Expand Up @@ -42,7 +42,7 @@ public void onClick(View v) {
SharedPreferences.Editor spe = settings.edit();
spe.putBoolean("canUpload", false);
spe.commit();
Intent intent = new Intent(getActivity(), com.mobiperf.service.CollectData.class);
Intent intent = new Intent(getActivity(), com.mobiperf.service.TcpdumpService.class);
stopService(intent);
finish();
}
Expand Down
2 changes: 1 addition & 1 deletion client/src/com/mobiperf/ui/Warning.java
Expand Up @@ -41,7 +41,7 @@ public void onClick(View v) {
SharedPreferences.Editor spe = settings.edit();
spe.putBoolean("canUpload", true);
spe.commit();
Intent intent = new Intent(getActivity(), com.mobiperf.service.CollectData.class);
Intent intent = new Intent(getActivity(), com.mobiperf.service.TcpdumpService.class);
startService(intent);
finish();
}
Expand Down

0 comments on commit a4899c6

Please sign in to comment.