Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
72e55c6
commit a4899c6
Showing
3 changed files
with
61 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
} | ||
|
||
|
||
|
||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters