Added some more debug traces

This commit is contained in:
Ziver Koc 2014-11-25 17:56:34 +01:00
parent ab404217ef
commit f9b56fc3ec
8 changed files with 32 additions and 7 deletions

View file

@ -44,6 +44,7 @@ public class UeBehaviourFileDownload extends UeBehaviour {
}
estimatedDataLength = progress;
log.debug("Total download size: "+ estimatedDataLength +" bytes");
in.close();
}

View file

@ -24,11 +24,19 @@ public abstract class UeBehaviourFtp extends UeBehaviour {
if (getHost().contains(":")) {
String tmpHost = getHost().substring(0, getHost().indexOf(':'));
int tmpPort = Integer.parseInt(getHost().substring(getHost().indexOf(':')));
log.debug("Connecting to host: "+tmpHost+" port: "+tmpPort);
ftp.connect(tmpHost, tmpPort);
} else ftp.connect(getHost());
if(getUsername() != null && !getUsername().isEmpty())
} else {
log.debug("Connecting to host: "+getHost());
ftp.connect(getHost());
}
if (getUsername() != null && !getUsername().isEmpty()) {
log.debug("Login with user: " + getUsername());
ftp.login(getUsername(), getPassword());
}
log.debug("Setting binary mode");
ftp.setFileType(FTP.BINARY_FILE_TYPE);
log.debug("Setting passive mode");
ftp.enterLocalPassiveMode();
executeFtp(ftp);

View file

@ -29,21 +29,22 @@ public class UeBehaviourFtpDownload extends UeBehaviourFtp {
@Override
protected void executeFtp(FTPClient ftp) throws IOException {
// Download data
log.debug("Downloading FTP file: " + getFtpUrl(filePath));
InputStream inStream = ftp.retrieveFileStream(filePath);
if (inStream != null) {
InputStream in = new BufferedInputStream(inStream);
// Download data
long progress = 0;
long read = 0;
byte[] data = new byte[BUFFER_SIZE];
while((read = in.read(data)) != -1 && !stopExecution()){
progress += read;
super.setProgress((float)progress/estimatedDataLength);
}
estimatedDataLength = progress;
log.debug("Total download size: "+ estimatedDataLength +" bytes");
in.close();
if(!ftp.completePendingCommand()) {
throw new IOException("FTP reply: "+ftp.getReplyString());

View file

@ -39,10 +39,12 @@ public class UeBehaviourFtpUpload extends UeBehaviourFtp {
@Override
protected void executeFtp(FTPClient ftp) throws IOException {
// Upload data
log.debug("Uploading to FTP file: " + getFtpUrl(filePath));
OutputStream outStream = ftp.storeFileStream(filePath);
if (outStream != null) {
OutputStream out = new BufferedOutputStream(outStream);
// Upload data
int total = 0;
byte[] data = new byte[BUFFER_SIZE];
while (total < size && !stopExecution()) {
@ -52,6 +54,7 @@ public class UeBehaviourFtpUpload extends UeBehaviourFtp {
total += writeLength;
super.setProgress((float) total / size);
}
out.close();
if(!ftp.completePendingCommand()) {
throw new IOException("FTP reply: "+ftp.getReplyString());

View file

@ -26,6 +26,7 @@ public class UeBehaviourReceiveCall extends UeBehaviour{
TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
// Wait to receive Call
log.debug("Waiting for call...");
while(tm.getCallState() != TelephonyManager.CALL_STATE_RINGING ){
if(super.stopExecution())
return;
@ -37,6 +38,7 @@ public class UeBehaviourReceiveCall extends UeBehaviour{
CallUtil.answerCall();
// Wait for call to end
log.debug("Waiting for call to end...");
while(tm.getCallState() != TelephonyManager.CALL_STATE_IDLE){
if(super.stopExecution())
return;

View file

@ -1,7 +1,9 @@
package com.ericsson.uecontrol.core.behaviour;
import android.util.Log;
import com.ericsson.uecontrol.core.UeBehaviour;
import com.ericsson.uecontrol.gui.util.Configurator.Configurable;
import org.apache.log4j.Logger;
/**
* This behaviour simulates an idle period for the device.
@ -9,6 +11,7 @@ import com.ericsson.uecontrol.gui.util.Configurator.Configurable;
* Created by ezivkoc on 2014-07-15.
*/
public class UeBehaviourSleep extends UeBehaviour{
private static final Logger log = Logger.getLogger(UeBehaviourSleep.class);
public static final int SLEEP_PERIOD = 100;
@Configurable("Sleep(millisec)")
@ -23,6 +26,7 @@ public class UeBehaviourSleep extends UeBehaviour{
@Override
protected void execute() throws InterruptedException {
log.debug(toString());
int elapsedTime = 0;
while(elapsedTime < time){
super.setProgress((float)elapsedTime/time);

View file

@ -73,7 +73,8 @@ public class UeBehaviourSurfing extends UeBehaviour {
for(int i=0; i<urlList.size(); i++) {
if(!UrlUtil.isNetworkAvailable()){
try { Thread.sleep(100); } catch (InterruptedException e) { }
log.warn("Network unavailable");
try { Thread.sleep(400); } catch (InterruptedException e) { }
continue;
}
InputStream in = null;

View file

@ -41,11 +41,15 @@ public class UeBehaviourVideoStreaming extends UeBehaviour implements MediaPlaye
String videoUrl = url.trim();
if (isYouTubeUrl(videoUrl)) {
videoUrl = getYoutubeRtsUrl(getYoutubeVideoId(videoUrl));
log.debug("Detected youtube video link: " + videoUrl);
log.debug("Detected youtube video url: " + videoUrl);
}
else {
log.debug("Video url: " + videoUrl);
}
mp.setDataSource(videoUrl);
mp.prepare();
mp.start();
//log.debug("Video size: "+mp.getVideoWidth()+"x"+mp.getVideoHeight());
Thread.sleep(UeBehaviourSleep.SLEEP_PERIOD);
while (mp.isPlaying() && playbackException == null) {
@ -57,6 +61,7 @@ public class UeBehaviourVideoStreaming extends UeBehaviour implements MediaPlaye
}catch(Exception e){
throw e;
}finally {
log.debug("Stopping playback");
mp.stop();
mp.reset();
mp.release();