2014-10-13 23:06:45 +00:00
|
|
|
package eu.siacs.conversations.http;
|
|
|
|
|
2015-08-10 17:48:36 +00:00
|
|
|
import android.os.PowerManager;
|
2015-07-10 11:28:50 +00:00
|
|
|
import android.util.Log;
|
2014-11-03 18:59:11 +00:00
|
|
|
|
2014-10-13 23:06:45 +00:00
|
|
|
import java.io.BufferedInputStream;
|
|
|
|
import java.io.IOException;
|
2015-08-10 10:15:14 +00:00
|
|
|
import java.io.InputStream;
|
2014-10-13 23:06:45 +00:00
|
|
|
import java.io.OutputStream;
|
|
|
|
import java.net.HttpURLConnection;
|
|
|
|
import java.net.MalformedURLException;
|
|
|
|
import java.net.URL;
|
2015-12-11 19:33:41 +00:00
|
|
|
import java.util.concurrent.CancellationException;
|
2014-10-13 23:06:45 +00:00
|
|
|
|
|
|
|
import javax.net.ssl.HttpsURLConnection;
|
2014-10-19 21:42:53 +00:00
|
|
|
import javax.net.ssl.SSLHandshakeException;
|
2014-10-13 23:06:45 +00:00
|
|
|
|
2014-11-14 00:29:56 +00:00
|
|
|
import eu.siacs.conversations.Config;
|
2015-07-10 11:28:50 +00:00
|
|
|
import eu.siacs.conversations.R;
|
2014-10-14 10:02:48 +00:00
|
|
|
import eu.siacs.conversations.entities.DownloadableFile;
|
2014-10-13 23:06:45 +00:00
|
|
|
import eu.siacs.conversations.entities.Message;
|
2015-07-20 12:26:29 +00:00
|
|
|
import eu.siacs.conversations.entities.Transferable;
|
2015-10-17 13:23:46 +00:00
|
|
|
import eu.siacs.conversations.entities.TransferablePlaceholder;
|
2015-07-31 23:19:16 +00:00
|
|
|
import eu.siacs.conversations.persistance.FileBackend;
|
|
|
|
import eu.siacs.conversations.services.AbstractConnectionManager;
|
2014-10-13 23:06:45 +00:00
|
|
|
import eu.siacs.conversations.services.XmppConnectionService;
|
2014-10-22 11:06:46 +00:00
|
|
|
import eu.siacs.conversations.utils.CryptoHelper;
|
2014-10-13 23:06:45 +00:00
|
|
|
|
2015-07-10 13:14:13 +00:00
|
|
|
public class HttpDownloadConnection implements Transferable {
|
2014-10-13 23:06:45 +00:00
|
|
|
|
|
|
|
private HttpConnectionManager mHttpConnectionManager;
|
|
|
|
private XmppConnectionService mXmppConnectionService;
|
|
|
|
|
|
|
|
private URL mUrl;
|
|
|
|
private Message message;
|
|
|
|
private DownloadableFile file;
|
2015-07-10 13:11:03 +00:00
|
|
|
private int mStatus = Transferable.STATUS_UNKNOWN;
|
2014-10-24 11:29:18 +00:00
|
|
|
private boolean acceptedAutomatically = false;
|
2014-11-13 20:04:05 +00:00
|
|
|
private int mProgress = 0;
|
2015-11-28 19:11:38 +00:00
|
|
|
private boolean mUseTor = false;
|
2015-12-11 19:33:41 +00:00
|
|
|
private boolean canceled = false;
|
2014-10-13 23:06:45 +00:00
|
|
|
|
2015-07-10 13:14:13 +00:00
|
|
|
public HttpDownloadConnection(HttpConnectionManager manager) {
|
2014-10-13 23:06:45 +00:00
|
|
|
this.mHttpConnectionManager = manager;
|
|
|
|
this.mXmppConnectionService = manager.getXmppConnectionService();
|
2015-11-28 19:11:38 +00:00
|
|
|
this.mUseTor = mXmppConnectionService.useTorToConnect();
|
2014-10-13 23:06:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2014-10-17 11:09:02 +00:00
|
|
|
public boolean start() {
|
|
|
|
if (mXmppConnectionService.hasInternetConnection()) {
|
2014-10-19 21:42:53 +00:00
|
|
|
if (this.mStatus == STATUS_OFFER_CHECK_FILESIZE) {
|
|
|
|
checkFileSize(true);
|
|
|
|
} else {
|
2014-10-21 22:00:01 +00:00
|
|
|
new Thread(new FileDownloader(true)).start();
|
2014-10-19 21:42:53 +00:00
|
|
|
}
|
2014-10-17 11:09:02 +00:00
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
2014-10-13 23:06:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public void init(Message message) {
|
2015-07-10 13:11:03 +00:00
|
|
|
init(message, false);
|
2015-07-10 11:28:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public void init(Message message, boolean interactive) {
|
2014-10-13 23:06:45 +00:00
|
|
|
this.message = message;
|
2015-07-10 13:11:03 +00:00
|
|
|
this.message.setTransferable(this);
|
2014-10-13 23:06:45 +00:00
|
|
|
try {
|
2015-10-17 13:23:46 +00:00
|
|
|
if (message.hasFileOnRemoteHost()) {
|
|
|
|
mUrl = message.getFileParams().url;
|
|
|
|
} else {
|
|
|
|
mUrl = new URL(message.getBody());
|
|
|
|
}
|
2015-01-11 14:19:36 +00:00
|
|
|
String[] parts = mUrl.getPath().toLowerCase().split("\\.");
|
|
|
|
String lastPart = parts.length >= 1 ? parts[parts.length - 1] : null;
|
|
|
|
String secondToLast = parts.length >= 2 ? parts[parts.length -2] : null;
|
|
|
|
if ("pgp".equals(lastPart) || "gpg".equals(lastPart)) {
|
2014-10-22 17:05:15 +00:00
|
|
|
this.message.setEncryption(Message.ENCRYPTION_PGP);
|
2015-07-19 12:17:25 +00:00
|
|
|
} else if (message.getEncryption() != Message.ENCRYPTION_OTR
|
|
|
|
&& message.getEncryption() != Message.ENCRYPTION_AXOLOTL) {
|
2014-10-27 10:00:03 +00:00
|
|
|
this.message.setEncryption(Message.ENCRYPTION_NONE);
|
2014-10-22 17:05:15 +00:00
|
|
|
}
|
2015-01-11 14:19:36 +00:00
|
|
|
String extension;
|
2016-03-04 10:24:53 +00:00
|
|
|
if (VALID_CRYPTO_EXTENSIONS.contains(lastPart)) {
|
2015-01-11 14:19:36 +00:00
|
|
|
extension = secondToLast;
|
|
|
|
} else {
|
|
|
|
extension = lastPart;
|
|
|
|
}
|
2016-03-23 18:23:22 +00:00
|
|
|
message.setRelativeFilePath(message.getUuid() + "." + extension);
|
2015-01-11 14:19:36 +00:00
|
|
|
this.file = mXmppConnectionService.getFileBackend().getFile(message, false);
|
2014-10-22 11:06:46 +00:00
|
|
|
String reference = mUrl.getRef();
|
|
|
|
if (reference != null && reference.length() == 96) {
|
2015-07-31 23:19:16 +00:00
|
|
|
this.file.setKeyAndIv(CryptoHelper.hexToBytes(reference));
|
2014-10-22 11:06:46 +00:00
|
|
|
}
|
2014-11-03 18:59:11 +00:00
|
|
|
|
2015-07-19 12:17:25 +00:00
|
|
|
if ((this.message.getEncryption() == Message.ENCRYPTION_OTR
|
|
|
|
|| this.message.getEncryption() == Message.ENCRYPTION_AXOLOTL)
|
2014-10-22 11:06:46 +00:00
|
|
|
&& this.file.getKey() == null) {
|
|
|
|
this.message.setEncryption(Message.ENCRYPTION_NONE);
|
2015-01-14 17:20:02 +00:00
|
|
|
}
|
2015-07-17 21:58:33 +00:00
|
|
|
checkFileSize(interactive);
|
2014-10-13 23:06:45 +00:00
|
|
|
} catch (MalformedURLException e) {
|
|
|
|
this.cancel();
|
|
|
|
}
|
|
|
|
}
|
2014-10-15 17:32:12 +00:00
|
|
|
|
2014-10-19 21:42:53 +00:00
|
|
|
private void checkFileSize(boolean interactive) {
|
|
|
|
new Thread(new FileSizeChecker(interactive)).start();
|
2014-10-13 23:06:45 +00:00
|
|
|
}
|
|
|
|
|
2015-12-11 19:33:41 +00:00
|
|
|
@Override
|
2014-10-13 23:06:45 +00:00
|
|
|
public void cancel() {
|
2015-12-11 19:33:41 +00:00
|
|
|
this.canceled = true;
|
2014-10-14 17:27:49 +00:00
|
|
|
mHttpConnectionManager.finishConnection(this);
|
2015-10-17 13:23:46 +00:00
|
|
|
if (message.isFileOrImage()) {
|
|
|
|
message.setTransferable(new TransferablePlaceholder(Transferable.STATUS_DELETED));
|
|
|
|
} else {
|
|
|
|
message.setTransferable(null);
|
|
|
|
}
|
2014-10-16 13:29:39 +00:00
|
|
|
mXmppConnectionService.updateConversationUi();
|
2014-10-14 17:27:49 +00:00
|
|
|
}
|
2014-10-15 17:32:12 +00:00
|
|
|
|
2014-10-14 17:27:49 +00:00
|
|
|
private void finish() {
|
2016-03-23 18:23:22 +00:00
|
|
|
mXmppConnectionService.getFileBackend().updateMediaScanner(file);
|
2015-07-10 13:11:03 +00:00
|
|
|
message.setTransferable(null);
|
2014-10-14 17:27:49 +00:00
|
|
|
mHttpConnectionManager.finishConnection(this);
|
2016-06-15 10:44:29 +00:00
|
|
|
boolean notify = acceptedAutomatically && !message.isRead();
|
2015-11-25 19:47:02 +00:00
|
|
|
if (message.getEncryption() == Message.ENCRYPTION_PGP) {
|
2016-06-15 10:44:29 +00:00
|
|
|
notify = message.getConversation().getAccount().getPgpDecryptionService().decrypt(message, notify);
|
2015-11-25 19:47:02 +00:00
|
|
|
}
|
2014-10-22 17:05:15 +00:00
|
|
|
mXmppConnectionService.updateConversationUi();
|
2016-06-15 10:44:29 +00:00
|
|
|
if (notify) {
|
2014-10-24 11:29:18 +00:00
|
|
|
mXmppConnectionService.getNotificationService().push(message);
|
|
|
|
}
|
2014-10-13 23:06:45 +00:00
|
|
|
}
|
|
|
|
|
2014-10-15 17:32:12 +00:00
|
|
|
private void changeStatus(int status) {
|
|
|
|
this.mStatus = status;
|
|
|
|
mXmppConnectionService.updateConversationUi();
|
|
|
|
}
|
2014-10-20 19:08:33 +00:00
|
|
|
|
2016-06-02 19:37:52 +00:00
|
|
|
private class WriteException extends IOException {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2015-08-10 10:15:14 +00:00
|
|
|
private void showToastForException(Exception e) {
|
|
|
|
if (e instanceof java.net.UnknownHostException) {
|
|
|
|
mXmppConnectionService.showErrorToastInUi(R.string.download_failed_server_not_found);
|
|
|
|
} else if (e instanceof java.net.ConnectException) {
|
|
|
|
mXmppConnectionService.showErrorToastInUi(R.string.download_failed_could_not_connect);
|
2016-06-02 19:37:52 +00:00
|
|
|
} else if (e instanceof WriteException) {
|
|
|
|
mXmppConnectionService.showErrorToastInUi(R.string.download_failed_could_not_write_file);
|
2015-12-11 19:33:41 +00:00
|
|
|
} else if (!(e instanceof CancellationException)) {
|
2015-08-10 10:15:14 +00:00
|
|
|
mXmppConnectionService.showErrorToastInUi(R.string.download_failed_file_not_found);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-10-13 23:06:45 +00:00
|
|
|
private class FileSizeChecker implements Runnable {
|
2014-10-20 19:08:33 +00:00
|
|
|
|
2014-10-19 21:42:53 +00:00
|
|
|
private boolean interactive = false;
|
|
|
|
|
|
|
|
public FileSizeChecker(boolean interactive) {
|
|
|
|
this.interactive = interactive;
|
|
|
|
}
|
2014-10-13 23:06:45 +00:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void run() {
|
2014-10-14 17:27:49 +00:00
|
|
|
long size;
|
2014-10-13 23:06:45 +00:00
|
|
|
try {
|
2014-10-14 17:27:49 +00:00
|
|
|
size = retrieveFileSize();
|
2016-07-21 17:17:26 +00:00
|
|
|
} catch (Exception e) {
|
2014-10-19 21:42:53 +00:00
|
|
|
changeStatus(STATUS_OFFER_CHECK_FILESIZE);
|
2015-07-10 11:28:50 +00:00
|
|
|
Log.d(Config.LOGTAG, "io exception in http file size checker: " + e.getMessage());
|
|
|
|
if (interactive) {
|
2015-08-10 10:15:14 +00:00
|
|
|
showToastForException(e);
|
2016-07-21 17:17:26 +00:00
|
|
|
} else {
|
|
|
|
HttpDownloadConnection.this.acceptedAutomatically = false;
|
|
|
|
HttpDownloadConnection.this.mXmppConnectionService.getNotificationService().push(message);
|
2015-07-10 11:28:50 +00:00
|
|
|
}
|
2014-10-13 23:06:45 +00:00
|
|
|
cancel();
|
2014-10-14 17:27:49 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
file.setExpectedSize(size);
|
2015-12-06 17:23:59 +00:00
|
|
|
if (mHttpConnectionManager.hasStoragePermission() && size <= mHttpConnectionManager.getAutoAcceptFileSize()) {
|
2015-07-10 13:14:13 +00:00
|
|
|
HttpDownloadConnection.this.acceptedAutomatically = true;
|
2014-10-21 22:00:01 +00:00
|
|
|
new Thread(new FileDownloader(interactive)).start();
|
2014-10-14 17:27:49 +00:00
|
|
|
} else {
|
2014-10-15 17:32:12 +00:00
|
|
|
changeStatus(STATUS_OFFER);
|
2015-07-10 13:14:13 +00:00
|
|
|
HttpDownloadConnection.this.acceptedAutomatically = false;
|
|
|
|
HttpDownloadConnection.this.mXmppConnectionService.getNotificationService().push(message);
|
2014-10-13 23:06:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-07-10 11:28:50 +00:00
|
|
|
private long retrieveFileSize() throws IOException {
|
|
|
|
try {
|
2015-08-10 10:15:14 +00:00
|
|
|
Log.d(Config.LOGTAG, "retrieve file size. interactive:" + String.valueOf(interactive));
|
|
|
|
changeStatus(STATUS_CHECKING);
|
2015-11-28 19:11:38 +00:00
|
|
|
HttpURLConnection connection;
|
|
|
|
if (mUseTor) {
|
|
|
|
connection = (HttpURLConnection) mUrl.openConnection(mHttpConnectionManager.getProxy());
|
|
|
|
} else {
|
|
|
|
connection = (HttpURLConnection) mUrl.openConnection();
|
|
|
|
}
|
2015-08-10 10:15:14 +00:00
|
|
|
connection.setRequestMethod("HEAD");
|
2015-11-28 19:11:38 +00:00
|
|
|
Log.d(Config.LOGTAG,"url: "+connection.getURL().toString());
|
|
|
|
Log.d(Config.LOGTAG,"connection: "+connection.toString());
|
2015-09-23 16:05:51 +00:00
|
|
|
connection.setRequestProperty("User-Agent", mXmppConnectionService.getIqGenerator().getIdentityName());
|
2015-08-10 10:15:14 +00:00
|
|
|
if (connection instanceof HttpsURLConnection) {
|
|
|
|
mHttpConnectionManager.setupTrustManager((HttpsURLConnection) connection, interactive);
|
|
|
|
}
|
|
|
|
connection.connect();
|
|
|
|
String contentLength = connection.getHeaderField("Content-Length");
|
|
|
|
connection.disconnect();
|
|
|
|
if (contentLength == null) {
|
2016-06-16 18:36:51 +00:00
|
|
|
throw new IOException("no content-length found in HEAD response");
|
2015-08-10 10:15:14 +00:00
|
|
|
}
|
2015-07-10 11:28:50 +00:00
|
|
|
return Long.parseLong(contentLength, 10);
|
2015-08-10 10:15:14 +00:00
|
|
|
} catch (IOException e) {
|
|
|
|
throw e;
|
2015-07-10 11:28:50 +00:00
|
|
|
} catch (NumberFormatException e) {
|
|
|
|
throw new IOException();
|
|
|
|
}
|
2014-10-13 23:06:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2014-10-15 17:32:12 +00:00
|
|
|
|
2014-10-13 23:06:45 +00:00
|
|
|
private class FileDownloader implements Runnable {
|
|
|
|
|
2014-10-21 22:00:01 +00:00
|
|
|
private boolean interactive = false;
|
|
|
|
|
2015-07-31 23:19:16 +00:00
|
|
|
private OutputStream os;
|
|
|
|
|
2014-10-21 22:00:01 +00:00
|
|
|
public FileDownloader(boolean interactive) {
|
|
|
|
this.interactive = interactive;
|
|
|
|
}
|
|
|
|
|
2014-10-13 23:06:45 +00:00
|
|
|
@Override
|
|
|
|
public void run() {
|
|
|
|
try {
|
2014-10-21 22:00:01 +00:00
|
|
|
changeStatus(STATUS_DOWNLOADING);
|
2014-10-13 23:06:45 +00:00
|
|
|
download();
|
2014-10-14 16:16:03 +00:00
|
|
|
updateImageBounds();
|
2014-10-14 17:27:49 +00:00
|
|
|
finish();
|
2014-10-21 22:00:01 +00:00
|
|
|
} catch (SSLHandshakeException e) {
|
|
|
|
changeStatus(STATUS_OFFER);
|
2015-12-11 19:33:41 +00:00
|
|
|
} catch (Exception e) {
|
2015-08-10 10:15:14 +00:00
|
|
|
if (interactive) {
|
|
|
|
showToastForException(e);
|
2016-07-21 17:17:26 +00:00
|
|
|
} else {
|
|
|
|
HttpDownloadConnection.this.acceptedAutomatically = false;
|
|
|
|
HttpDownloadConnection.this.mXmppConnectionService.getNotificationService().push(message);
|
2015-08-10 10:15:14 +00:00
|
|
|
}
|
2014-10-13 23:06:45 +00:00
|
|
|
cancel();
|
|
|
|
}
|
|
|
|
}
|
2014-10-15 17:32:12 +00:00
|
|
|
|
2015-12-11 19:33:41 +00:00
|
|
|
private void download() throws Exception {
|
2015-08-10 10:15:14 +00:00
|
|
|
InputStream is = null;
|
2015-08-10 17:48:36 +00:00
|
|
|
PowerManager.WakeLock wakeLock = mHttpConnectionManager.createWakeLock("http_download_"+message.getUuid());
|
2015-08-10 10:15:14 +00:00
|
|
|
try {
|
2015-08-10 17:48:36 +00:00
|
|
|
wakeLock.acquire();
|
2015-11-28 19:11:38 +00:00
|
|
|
HttpURLConnection connection;
|
|
|
|
if (mUseTor) {
|
|
|
|
connection = (HttpURLConnection) mUrl.openConnection(mHttpConnectionManager.getProxy());
|
|
|
|
} else {
|
|
|
|
connection = (HttpURLConnection) mUrl.openConnection();
|
|
|
|
}
|
2015-08-10 10:15:14 +00:00
|
|
|
if (connection instanceof HttpsURLConnection) {
|
|
|
|
mHttpConnectionManager.setupTrustManager((HttpsURLConnection) connection, interactive);
|
|
|
|
}
|
2015-09-23 16:05:51 +00:00
|
|
|
connection.setRequestProperty("User-Agent",mXmppConnectionService.getIqGenerator().getIdentityName());
|
2015-12-11 19:33:41 +00:00
|
|
|
final boolean tryResume = file.exists() && file.getKey() == null;
|
|
|
|
if (tryResume) {
|
|
|
|
Log.d(Config.LOGTAG,"http download trying resume");
|
|
|
|
long size = file.getSize();
|
|
|
|
connection.setRequestProperty("Range", "bytes="+size+"-");
|
|
|
|
}
|
2015-08-10 10:15:14 +00:00
|
|
|
connection.connect();
|
|
|
|
is = new BufferedInputStream(connection.getInputStream());
|
2015-12-11 19:33:41 +00:00
|
|
|
boolean serverResumed = "bytes".equals(connection.getHeaderField("Accept-Ranges"));
|
2015-08-10 10:15:14 +00:00
|
|
|
long transmitted = 0;
|
|
|
|
long expected = file.getExpectedSize();
|
2015-12-11 19:33:41 +00:00
|
|
|
if (tryResume && serverResumed) {
|
|
|
|
Log.d(Config.LOGTAG,"server resumed");
|
|
|
|
transmitted = file.getSize();
|
|
|
|
updateProgress((int) ((((double) transmitted) / expected) * 100));
|
|
|
|
os = AbstractConnectionManager.createAppendedOutputStream(file);
|
|
|
|
} else {
|
|
|
|
file.getParentFile().mkdirs();
|
|
|
|
file.createNewFile();
|
|
|
|
os = AbstractConnectionManager.createOutputStream(file, true);
|
|
|
|
}
|
2016-06-02 19:37:52 +00:00
|
|
|
int count;
|
2015-08-10 10:15:14 +00:00
|
|
|
byte[] buffer = new byte[1024];
|
|
|
|
while ((count = is.read(buffer)) != -1) {
|
|
|
|
transmitted += count;
|
2016-06-02 19:37:52 +00:00
|
|
|
try {
|
|
|
|
os.write(buffer, 0, count);
|
|
|
|
} catch (IOException e) {
|
|
|
|
throw new WriteException();
|
|
|
|
}
|
2015-08-10 10:15:14 +00:00
|
|
|
updateProgress((int) ((((double) transmitted) / expected) * 100));
|
2015-12-11 19:33:41 +00:00
|
|
|
if (canceled) {
|
|
|
|
throw new CancellationException();
|
|
|
|
}
|
2015-08-10 10:15:14 +00:00
|
|
|
}
|
2016-06-03 12:27:05 +00:00
|
|
|
try {
|
|
|
|
os.flush();
|
|
|
|
} catch (IOException e) {
|
|
|
|
throw new WriteException();
|
|
|
|
}
|
2015-12-11 19:33:41 +00:00
|
|
|
} catch (CancellationException | IOException e) {
|
2015-08-10 10:15:14 +00:00
|
|
|
throw e;
|
|
|
|
} finally {
|
|
|
|
FileBackend.close(os);
|
|
|
|
FileBackend.close(is);
|
2015-08-10 17:48:36 +00:00
|
|
|
wakeLock.release();
|
2014-10-13 23:06:45 +00:00
|
|
|
}
|
2014-10-14 16:16:03 +00:00
|
|
|
}
|
2014-10-15 17:32:12 +00:00
|
|
|
|
2014-10-14 16:16:03 +00:00
|
|
|
private void updateImageBounds() {
|
2015-06-30 15:15:02 +00:00
|
|
|
message.setType(Message.TYPE_FILE);
|
|
|
|
mXmppConnectionService.getFileBackend().updateFileParams(message, mUrl);
|
2014-10-15 17:32:12 +00:00
|
|
|
mXmppConnectionService.updateMessage(message);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2014-11-14 00:29:56 +00:00
|
|
|
public void updateProgress(int i) {
|
|
|
|
this.mProgress = i;
|
2015-07-20 13:48:58 +00:00
|
|
|
mXmppConnectionService.updateConversationUi();
|
2014-11-14 00:29:56 +00:00
|
|
|
}
|
|
|
|
|
2014-10-15 17:32:12 +00:00
|
|
|
@Override
|
|
|
|
public int getStatus() {
|
|
|
|
return this.mStatus;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public long getFileSize() {
|
|
|
|
if (this.file != null) {
|
|
|
|
return this.file.getExpectedSize();
|
|
|
|
} else {
|
|
|
|
return 0;
|
2014-10-13 23:06:45 +00:00
|
|
|
}
|
|
|
|
}
|
2014-11-13 20:04:05 +00:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public int getProgress() {
|
|
|
|
return this.mProgress;
|
|
|
|
}
|
2015-01-14 17:20:02 +00:00
|
|
|
}
|