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; estimatedDataLength = progress;
log.debug("Total download size: "+ estimatedDataLength +" bytes");
in.close(); in.close();
} }

View file

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

View file

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

View file

@ -39,10 +39,12 @@ public class UeBehaviourFtpUpload extends UeBehaviourFtp {
@Override @Override
protected void executeFtp(FTPClient ftp) throws IOException { protected void executeFtp(FTPClient ftp) throws IOException {
// Upload data log.debug("Uploading to FTP file: " + getFtpUrl(filePath));
OutputStream outStream = ftp.storeFileStream(filePath); OutputStream outStream = ftp.storeFileStream(filePath);
if (outStream != null) { if (outStream != null) {
OutputStream out = new BufferedOutputStream(outStream); OutputStream out = new BufferedOutputStream(outStream);
// Upload data
int total = 0; int total = 0;
byte[] data = new byte[BUFFER_SIZE]; byte[] data = new byte[BUFFER_SIZE];
while (total < size && !stopExecution()) { while (total < size && !stopExecution()) {
@ -52,6 +54,7 @@ public class UeBehaviourFtpUpload extends UeBehaviourFtp {
total += writeLength; total += writeLength;
super.setProgress((float) total / size); super.setProgress((float) total / size);
} }
out.close(); out.close();
if(!ftp.completePendingCommand()) { if(!ftp.completePendingCommand()) {
throw new IOException("FTP reply: "+ftp.getReplyString()); 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); TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
// Wait to receive Call // Wait to receive Call
log.debug("Waiting for call...");
while(tm.getCallState() != TelephonyManager.CALL_STATE_RINGING ){ while(tm.getCallState() != TelephonyManager.CALL_STATE_RINGING ){
if(super.stopExecution()) if(super.stopExecution())
return; return;
@ -37,6 +38,7 @@ public class UeBehaviourReceiveCall extends UeBehaviour{
CallUtil.answerCall(); CallUtil.answerCall();
// Wait for call to end // Wait for call to end
log.debug("Waiting for call to end...");
while(tm.getCallState() != TelephonyManager.CALL_STATE_IDLE){ while(tm.getCallState() != TelephonyManager.CALL_STATE_IDLE){
if(super.stopExecution()) if(super.stopExecution())
return; return;

View file

@ -1,7 +1,9 @@
package com.ericsson.uecontrol.core.behaviour; package com.ericsson.uecontrol.core.behaviour;
import android.util.Log;
import com.ericsson.uecontrol.core.UeBehaviour; import com.ericsson.uecontrol.core.UeBehaviour;
import com.ericsson.uecontrol.gui.util.Configurator.Configurable; import com.ericsson.uecontrol.gui.util.Configurator.Configurable;
import org.apache.log4j.Logger;
/** /**
* This behaviour simulates an idle period for the device. * 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. * Created by ezivkoc on 2014-07-15.
*/ */
public class UeBehaviourSleep extends UeBehaviour{ public class UeBehaviourSleep extends UeBehaviour{
private static final Logger log = Logger.getLogger(UeBehaviourSleep.class);
public static final int SLEEP_PERIOD = 100; public static final int SLEEP_PERIOD = 100;
@Configurable("Sleep(millisec)") @Configurable("Sleep(millisec)")
@ -23,6 +26,7 @@ public class UeBehaviourSleep extends UeBehaviour{
@Override @Override
protected void execute() throws InterruptedException { protected void execute() throws InterruptedException {
log.debug(toString());
int elapsedTime = 0; int elapsedTime = 0;
while(elapsedTime < time){ while(elapsedTime < time){
super.setProgress((float)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++) { for(int i=0; i<urlList.size(); i++) {
if(!UrlUtil.isNetworkAvailable()){ if(!UrlUtil.isNetworkAvailable()){
try { Thread.sleep(100); } catch (InterruptedException e) { } log.warn("Network unavailable");
try { Thread.sleep(400); } catch (InterruptedException e) { }
continue; continue;
} }
InputStream in = null; InputStream in = null;

View file

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