more SAF implementation

* full support for Directory API (Android Lollipop or later)
* best effort to handle any kind errors (missing file, revoked permissions, etc) and recover the download
* implemented directory choosing
* fix download database version upgrading
* misc. cleanup
* do not release permission on the old save path (if the user change the download directory) under SAF api
This commit is contained in:
kapodamy 2019-04-09 18:38:34 -03:00
parent f6b32823ba
commit d00dc798f4
28 changed files with 946 additions and 589 deletions

View file

@ -16,6 +16,8 @@ public class DataReader {
public final static int INTEGER_SIZE = 4;
public final static int FLOAT_SIZE = 4;
private final static int BUFFER_SIZE = 128 * 1024;// 128 KiB
private long position = 0;
private final SharpStream stream;
@ -229,7 +231,7 @@ public class DataReader {
}
}
private final byte[] readBuffer = new byte[8 * 1024];
private final byte[] readBuffer = new byte[BUFFER_SIZE];
private int readOffset;
private int readCount;

View file

@ -12,7 +12,6 @@ import java.io.IOException;
import java.nio.ByteBuffer;
/**
*
* @author kapodamy
*/
public class Mp4FromDashWriter {
@ -262,12 +261,12 @@ public class Mp4FromDashWriter {
final int ftyp_size = make_ftyp();
// reserve moov space in the output stream
if (outStream.canSetLength()) {
/*if (outStream.canSetLength()) {
long length = writeOffset + auxSize;
outStream.setLength(length);
outSeek(length);
} else {
// hard way
} else {*/
if (auxSize > 0) {
int length = auxSize;
byte[] buffer = new byte[8 * 1024];// 8 KiB
while (length > 0) {
@ -276,6 +275,7 @@ public class Mp4FromDashWriter {
length -= count;
}
}
if (auxBuffer == null) {
outSeek(ftyp_size);
}