From d2613d362046f42ac0c9e231b0c666ae396f127c Mon Sep 17 00:00:00 2001 From: madwasp79 Date: Mon, 11 Feb 2019 12:50:40 +0200 Subject: [PATCH] work in progress --- OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java | 9 ++++++--- OsmAnd/src/net/osmand/aidl/tiles/CopyFileParams.java | 11 ++--------- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java b/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java index fcbcae7729..25dc78d03a 100644 --- a/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java +++ b/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java @@ -1976,7 +1976,10 @@ public class OsmandAidlApi { } private boolean copyFileImpl(CopyFileParams fileParams, File file, String destination){ - LOG.debug(fileParams.toString()); + + if (fileParams.getFilePartData().length > 256*1024) { + return false; + } FileOutputStream fos; String key = fileParams.getFilename() + fileParams.getCopyStartTime(); @@ -1989,11 +1992,11 @@ public class OsmandAidlApi { file.renameTo(app.getAppPath(destination + fileParams.getFilename())); return true; - } else if (file.length() == fileParams.getSentSize()) { + } else { fos.write(fileParams.getFilePartData()); return true; } - return false; + } else { file.getParentFile().mkdirs(); fos = new FileOutputStream(file, true); diff --git a/OsmAnd/src/net/osmand/aidl/tiles/CopyFileParams.java b/OsmAnd/src/net/osmand/aidl/tiles/CopyFileParams.java index bdf49b5901..bbe5b2c7e0 100644 --- a/OsmAnd/src/net/osmand/aidl/tiles/CopyFileParams.java +++ b/OsmAnd/src/net/osmand/aidl/tiles/CopyFileParams.java @@ -5,14 +5,12 @@ import android.os.Parcelable; public class CopyFileParams implements Parcelable { private String filename; - private long sentSize; private byte[] filePartData; private long copyStartTime; private boolean isTransmitComplete; - public CopyFileParams(String filename, long sentSize, byte[] filePartData, long copyStartTime, boolean isTransmitComplete) { + public CopyFileParams(String filename, byte[] filePartData, long copyStartTime, boolean isTransmitComplete) { this.filename = filename; - this.sentSize = sentSize; this.filePartData = filePartData; this.copyStartTime = copyStartTime; this.isTransmitComplete = isTransmitComplete; @@ -22,9 +20,6 @@ public class CopyFileParams implements Parcelable { return filename; } - public long getSentSize() { - return sentSize; - } public byte[] getFilePartData() { return filePartData; @@ -39,7 +34,6 @@ public class CopyFileParams implements Parcelable { protected CopyFileParams(Parcel in) { filename = in.readString(); - sentSize = in.readLong(); filePartData = in.createByteArray(); copyStartTime = in.readLong(); isTransmitComplete = in.readByte() != 0; @@ -66,7 +60,6 @@ public class CopyFileParams implements Parcelable { @Override public void writeToParcel(Parcel dest, int flags) { dest.writeString(filename); - dest.writeLong(sentSize); dest.writeByteArray(filePartData); dest.writeLong(copyStartTime); dest.writeByte((byte) (isTransmitComplete ? 1 : 0)); @@ -74,7 +67,7 @@ public class CopyFileParams implements Parcelable { @Override public String toString() { - return "Filename: " + filename + ", sentSize = " + sentSize + ", filePartData size = " + + return "Filename: " + filename + ", filePartData size = " + filePartData.length + ", startTime: " + copyStartTime + ", isTransmitComplete: "+ isTransmitComplete; } }