Fixed Surfing to download all linked content like images and iframes, also added FTP download
This commit is contained in:
parent
21e55f12c4
commit
73a3de5eb8
2 changed files with 79 additions and 0 deletions
BIN
app/app-release.apk
Executable file
BIN
app/app-release.apk
Executable file
Binary file not shown.
79
app/src/main/java/com/ericsson/uecontrol/core/behaviour/UeBehaviourFtp.java
Executable file
79
app/src/main/java/com/ericsson/uecontrol/core/behaviour/UeBehaviourFtp.java
Executable file
|
|
@ -0,0 +1,79 @@
|
|||
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 java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
|
||||
/**
|
||||
* This behaviour simulates visiting a website
|
||||
*
|
||||
* Created by ezivkoc on 2014-07-15.
|
||||
*/
|
||||
public class UeBehaviourFtp extends UeBehaviour {
|
||||
|
||||
@Configurable("Host")
|
||||
private String host;
|
||||
@Configurable("File Path")
|
||||
private String filePath;
|
||||
@Configurable("Username")
|
||||
private String username;
|
||||
@Configurable("Password")
|
||||
private String password;
|
||||
|
||||
|
||||
@Override
|
||||
protected void execute() throws IOException {
|
||||
URL url = new URL(getFtpUrl());
|
||||
Log.v(getClass().getSimpleName(), "Downloading from FTP: " + url);
|
||||
|
||||
byte[] data = new byte[100];
|
||||
URLConnection connection = url.openConnection();
|
||||
connection.setUseCaches(false);
|
||||
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.setHandledIncomingData(read);
|
||||
}
|
||||
}
|
||||
|
||||
private String getFtpUrl() {
|
||||
String url = "ftp://";
|
||||
if(username != null && !username.isEmpty()) {
|
||||
url += username;
|
||||
if(password !=null && !password.isEmpty())
|
||||
url += ":"+password;
|
||||
url += "@";
|
||||
}
|
||||
url += host;
|
||||
if(filePath != null && filePath.isEmpty()){
|
||||
if(!filePath.startsWith("/"))
|
||||
filePath = "/"+filePath;
|
||||
url += filePath;
|
||||
}
|
||||
return url;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "FTP Download";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Will download "+ getFtpUrl();
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue