diff --git a/app/src/main/java/com/ericsson/uecontrol/core/behaviour/UeBehaviourFileDownload.java b/app/src/main/java/com/ericsson/uecontrol/core/behaviour/UeBehaviourFileDownload.java index 503238d..c3f289d 100755 --- a/app/src/main/java/com/ericsson/uecontrol/core/behaviour/UeBehaviourFileDownload.java +++ b/app/src/main/java/com/ericsson/uecontrol/core/behaviour/UeBehaviourFileDownload.java @@ -22,6 +22,7 @@ public class UeBehaviourFileDownload extends UeBehaviour { @Configurable("File address") private String url = "http://speedtest.ftp.otenet.gr/files/test1Mb.db"; + private transient long estimatedDataLength = -1; @Override protected void execute() throws IOException { @@ -34,15 +35,16 @@ public class UeBehaviourFileDownload extends UeBehaviour { connection.connect(); InputStream in = connection.getInputStream(); - long total = in.available(); long progress = 0; long read = 0; while((read = in.read(data)) != -1 && !stopExecution()){ progress += read; - super.setProgress((float)progress/total); + super.setProgress((float)progress/estimatedDataLength); super.setHandledIncomingData(read); } + + estimatedDataLength = progress; in.close(); }