~singpolyma/cheogram-android

87f99d35708d09a52c1c99b2d114e4c1c07007ef — Daniel Gultsch 3 years ago b025265
Transferables interface needs to differentiate between 0 and null file size
M src/main/java/eu/siacs/conversations/entities/Transferable.java => src/main/java/eu/siacs/conversations/entities/Transferable.java +1 -1
@@ 22,7 22,7 @@ public interface Transferable {

	int getStatus();

	long getFileSize();
	Long getFileSize();

	int getProgress();


M src/main/java/eu/siacs/conversations/entities/TransferablePlaceholder.java => src/main/java/eu/siacs/conversations/entities/TransferablePlaceholder.java +2 -2
@@ 18,8 18,8 @@ public class TransferablePlaceholder implements Transferable {
	}

	@Override
	public long getFileSize() {
		return 0;
	public Long getFileSize() {
		return null;
	}

	@Override

M src/main/java/eu/siacs/conversations/http/HttpDownloadConnection.java => src/main/java/eu/siacs/conversations/http/HttpDownloadConnection.java +4 -2
@@ 107,6 107,7 @@ public class HttpDownloadConnection implements Transferable {
            }
            //TODO add auth tag size to knownFileSize
            final Long knownFileSize = message.getFileParams().size;
            Log.d(Config.LOGTAG,"knownFileSize: "+knownFileSize+", body="+message.getBody());
            if (knownFileSize != null && interactive) {
                this.file.setExpectedSize(knownFileSize);
                download(true);


@@ 130,6 131,7 @@ public class HttpDownloadConnection implements Transferable {
    }

    private void download(final boolean interactive) {
        Log.d(Config.LOGTAG,"download()",new Exception());
        EXECUTOR.execute(new FileDownloader(interactive));
    }



@@ 234,11 236,11 @@ public class HttpDownloadConnection implements Transferable {
    }

    @Override
    public long getFileSize() {
    public Long getFileSize() {
        if (this.file != null) {
            return this.file.getExpectedSize();
        } else {
            return 0;
            return null;
        }
    }


M src/main/java/eu/siacs/conversations/http/HttpUploadConnection.java => src/main/java/eu/siacs/conversations/http/HttpUploadConnection.java +2 -2
@@ 69,8 69,8 @@ public class HttpUploadConnection implements Transferable, AbstractConnectionMan
    }

    @Override
    public long getFileSize() {
        return file == null ? 0 : file.getExpectedSize();
    public Long getFileSize() {
        return file == null ? null : file.getExpectedSize();
    }

    @Override

M src/main/java/eu/siacs/conversations/services/AbstractConnectionManager.java => src/main/java/eu/siacs/conversations/services/AbstractConnectionManager.java +5 -6
@@ 5,6 5,8 @@ import android.os.PowerManager;
import android.os.SystemClock;
import android.util.Log;

import androidx.core.content.ContextCompat;

import org.bouncycastle.crypto.engines.AESEngine;
import org.bouncycastle.crypto.io.CipherInputStream;
import org.bouncycastle.crypto.io.CipherOutputStream;


@@ 118,7 120,8 @@ public class AbstractConnectionManager {
    }

    public long getAutoAcceptFileSize() {
        return this.mXmppConnectionService.getLongPreference("auto_accept_file_size", R.integer.auto_accept_filesize);
        final long autoAcceptFileSize = this.mXmppConnectionService.getLongPreference("auto_accept_file_size", R.integer.auto_accept_filesize);
        return autoAcceptFileSize <= 0 ? -1 : autoAcceptFileSize;
    }

    public boolean hasStoragePermission() {


@@ 134,12 137,8 @@ public class AbstractConnectionManager {
        }
    }

    public PowerManager.WakeLock createWakeLock(final Thread thread) {
        return createWakeLock("conversations:" + thread.getName());
    }

    public PowerManager.WakeLock createWakeLock(final String name) {
        final PowerManager powerManager = (PowerManager) mXmppConnectionService.getSystemService(Context.POWER_SERVICE);
        final PowerManager powerManager = ContextCompat.getSystemService(mXmppConnectionService, PowerManager.class);
        return powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, name);
    }


M src/main/java/eu/siacs/conversations/xmpp/jingle/JingleFileTransferConnection.java => src/main/java/eu/siacs/conversations/xmpp/jingle/JingleFileTransferConnection.java +2 -2
@@ 1239,11 1239,11 @@ public class JingleFileTransferConnection extends AbstractJingleConnection imple
    }

    @Override
    public long getFileSize() {
    public Long getFileSize() {
        if (this.file != null) {
            return this.file.getExpectedSize();
        } else {
            return 0;
            return null;
        }
    }