Compare commits

..

3 Commits

Author SHA1 Message Date
Torsten Grote
e2faf08c9d WIP: Fix AssertionError when receiving images 2021-05-31 11:24:46 -03:00
Torsten Grote
cc04fb05c2 Merge branch '1971-tor-0.3.5.14' into 'master'
Upgrade Tor to 0.3.5.14

Closes #1971

See merge request briar/briar!1470
2021-05-31 12:02:58 +00:00
akwizgran
58eb1d9e24 Upgrade Tor to 0.3.5.14. 2021-05-28 11:45:21 +01:00
16 changed files with 32 additions and 41 deletions

View File

@@ -42,7 +42,7 @@ configurations {
dependencies {
implementation project(path: ':bramble-core', configuration: 'default')
tor 'org.briarproject:tor-android:0.3.5.13@zip'
tor 'org.briarproject:tor-android:0.3.5.14'
tor 'org.briarproject:obfs4proxy-android:0.0.12-dev-40245c4a@zip'
annotationProcessor 'com.google.dagger:dagger-compiler:2.24'

View File

@@ -119,12 +119,7 @@ public class AndroidUtils {
* Returns an array of supported content types for image attachments.
*/
public static String[] getSupportedImageContentTypes() {
return new String[] {
"image/jpeg",
"image/png",
"image/gif",
"image/webp"
};
return new String[] {"image/jpeg", "image/png", "image/gif"};
}
@Nullable

View File

@@ -76,7 +76,7 @@ dependencyVerification {
'org.bouncycastle:bcpkix-jdk15on:1.56:bcpkix-jdk15on-1.56.jar:7043dee4e9e7175e93e0b36f45b1ec1ecb893c5f755667e8b916eb8dd201c6ca',
'org.bouncycastle:bcprov-jdk15on:1.56:bcprov-jdk15on-1.56.jar:963e1ee14f808ffb99897d848ddcdb28fa91ddda867eb18d303e82728f878349',
'org.briarproject:obfs4proxy-android:0.0.12-dev-40245c4a:obfs4proxy-android-0.0.12-dev-40245c4a.zip:8ab05a8f8391be2cb5ab2b665c281a06d9e3a756bd0f95a40a36ca927866ea82',
'org.briarproject:tor-android:0.3.5.13:tor-android-0.3.5.13.zip:e0978db136731dae07774b722970cdae1e462fb5adc82845dd80a7e2d87f356c',
'org.briarproject:tor-android:0.3.5.14:tor-android-0.3.5.14.jar:92bdb9890de8f14e9e90d1e3aff49a7a4b9262f19904410ae0a3baf94ed6be33',
'org.checkerframework:checker-compat-qual:2.5.3:checker-compat-qual-2.5.3.jar:d76b9afea61c7c082908023f0cbc1427fab9abd2df915c8b8a3e7a509bccbc6d',
'org.checkerframework:checker-qual:2.5.2:checker-qual-2.5.2.jar:64b02691c8b9d4e7700f8ee2e742dce7ea2c6e81e662b7522c9ee3bf568c040a',
'org.checkerframework:checker-qual:2.8.1:checker-qual-2.8.1.jar:9103499008bcecd4e948da29b17864abb64304e15706444ae209d17ebe0575df',

View File

@@ -16,7 +16,7 @@ dependencies {
implementation fileTree(dir: 'libs', include: '*.jar')
implementation 'net.java.dev.jna:jna:4.5.2'
implementation 'net.java.dev.jna:jna-platform:4.5.2'
tor 'org.briarproject:tor:0.3.5.13-1@zip'
tor 'org.briarproject:tor:0.3.5.14'
tor 'org.briarproject:obfs4proxy:0.0.12-dev-40245c4a@zip'
annotationProcessor 'com.google.dagger:dagger-compiler:2.24'

View File

@@ -24,7 +24,7 @@ dependencyVerification {
'org.apache.ant:ant:1.9.4:ant-1.9.4.jar:649ae0730251de07b8913f49286d46bba7b92d47c5f332610aa426c4f02161d8',
'org.beanshell:bsh:1.3.0:bsh-1.3.0.jar:9b04edc75d19db54f1b4e8b5355e9364384c6cf71eb0a1b9724c159d779879f8',
'org.briarproject:obfs4proxy:0.0.12-dev-40245c4a:obfs4proxy-0.0.12-dev-40245c4a.zip:172029e7058b3a83ac93ac4991a44bf76e16ce8d46f558f5836d57da3cb3a766',
'org.briarproject:tor:0.3.5.13-1:tor-0.3.5.13-1.zip:ef35c16bf8dc1f4c75ed71d9f55e4514f383d124ec96b859aca647c990927c99',
'org.briarproject:tor:0.3.5.14:tor-0.3.5.14.jar:a969ab3f4bde4a7fc5945c53935cf3bca50de44451a34ebeca8add93e2a9af60',
'org.checkerframework:checker-compat-qual:2.5.3:checker-compat-qual-2.5.3.jar:d76b9afea61c7c082908023f0cbc1427fab9abd2df915c8b8a3e7a509bccbc6d',
'org.checkerframework:checker-qual:2.5.2:checker-qual-2.5.2.jar:64b02691c8b9d4e7700f8ee2e742dce7ea2c6e81e662b7522c9ee3bf568c040a',
'org.codehaus.mojo:animal-sniffer-annotations:1.17:animal-sniffer-annotations-1.17.jar:92654f493ecfec52082e76354f0ebf87648dc3d5cec2e3c3cdb947c016747a53',

View File

@@ -121,7 +121,6 @@ dependencies {
exclude group: 'com.android.support'
exclude module: 'disklrucache' // when there's no disk cache, we can't accidentally use it
}
implementation "com.github.zjupure:webpdecoder:2.0.$glideVersion"
annotationProcessor 'com.google.dagger:dagger-compiler:2.24'
annotationProcessor "com.github.bumptech.glide:compiler:$glideVersion"

View File

@@ -102,10 +102,12 @@ class AttachmentCreationTask {
}
InputStream is = contentResolver.openInputStream(uri);
if (is == null) throw new IOException();
is = imageCompressor.compressImage(is, contentType);
is = imageCompressor
.compressImage(is, contentType);
long timestamp = System.currentTimeMillis();
AttachmentHeader h = messagingManager.addLocalAttachment(groupId,
timestamp, ImageCompressor.MIME_TYPE, is);
AttachmentHeader h = messagingManager
.addLocalAttachment(groupId, timestamp,
ImageCompressor.MIME_TYPE, is);
tryToClose(is, LOG, WARNING);
logDuration(LOG, "Storing attachment", start);
return h;

View File

@@ -11,7 +11,7 @@ public interface ImageCompressor {
/**
* The MIME type of compressed images
*/
String MIME_TYPE = "image/webp";
String MIME_TYPE = "image/jpeg";
/**
* Load an image from {@code is}, compress it and return an InputStream

View File

@@ -12,7 +12,7 @@ import java.util.logging.Logger;
import javax.inject.Inject;
import static android.graphics.Bitmap.CompressFormat.WEBP;
import static android.graphics.Bitmap.CompressFormat.JPEG;
import static android.graphics.BitmapFactory.decodeStream;
import static java.util.logging.Level.INFO;
import static java.util.logging.Level.WARNING;
@@ -50,7 +50,7 @@ class ImageCompressorImpl implements ImageCompressor {
public InputStream compressImage(Bitmap bitmap) throws IOException {
ByteArrayOutputStream out = new ByteArrayOutputStream();
for (int quality = 100; quality >= 0; quality -= 10) {
if (!bitmap.compress(WEBP, quality, out))
if (!bitmap.compress(JPEG, quality, out))
throw new IOException();
if (out.size() <= MAX_IMAGE_SIZE) {
if (LOG.isLoggable(INFO)) {

View File

@@ -3,8 +3,6 @@ package org.briarproject.briar.android.attachment.media;
import android.graphics.BitmapFactory;
import android.webkit.MimeTypeMap;
import com.bumptech.glide.integration.webp.WebpBitmapFactory;
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
import java.io.InputStream;
@@ -27,10 +25,6 @@ class ImageHelperImpl implements ImageHelper {
BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
BitmapFactory.decodeStream(is, null, options);
if (options.outWidth < 1 || options.outHeight < 1) {
// BitmapFactory doesn't fully support WebP on API < 17
WebpBitmapFactory.decodeStream(is, null, options);
}
String mimeType = options.outMimeType;
if (mimeType == null) mimeType = "";
return new DecodeResult(options.outWidth, options.outHeight,
@@ -40,7 +34,6 @@ class ImageHelperImpl implements ImageHelper {
@Nullable
@Override
public String getExtensionFromMimeType(String mimeType) {
if ("image/webp".equals(mimeType)) return "webp";
MimeTypeMap mimeTypeMap = MimeTypeMap.getSingleton();
return mimeTypeMap.getExtensionFromMimeType(mimeType);
}

View File

@@ -21,7 +21,6 @@ import static androidx.exifinterface.media.ExifInterface.TAG_ORIENTATION;
import static java.util.logging.Level.WARNING;
import static java.util.logging.Logger.getLogger;
import static org.briarproject.bramble.util.LogUtils.logException;
import static org.briarproject.bramble.util.StringUtils.isNullOrEmpty;
@NotNullByDefault
class ImageSizeCalculatorImpl implements ImageSizeCalculator {
@@ -62,10 +61,6 @@ class ImageSizeCalculatorImpl implements ImageSizeCalculator {
logException(LOG, WARNING, e);
}
}
if (!size.hasError() && isNullOrEmpty(size.getMimeType())) {
LOG.info("Could not determine content type, using supplied type");
size = new Size(size.getWidth(), size.getHeight(), contentType);
}
return size;
}

View File

@@ -4,8 +4,6 @@ import android.graphics.Bitmap;
import android.view.View;
import android.widget.ImageView;
import com.bumptech.glide.integration.webp.decoder.WebpDrawable;
import com.bumptech.glide.integration.webp.decoder.WebpDrawableTransformation;
import com.bumptech.glide.load.Transformation;
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
@@ -82,9 +80,7 @@ class ImageViewHolder extends ViewHolder {
.load(a.getHeader())
.diskCacheStrategy(NONE)
.error(ERROR_RES)
.optionalTransform(transformation)
.optionalTransform(WebpDrawable.class,
new WebpDrawableTransformation(transformation))
.transform(transformation)
.transition(withCrossFade())
.into(imageView)
.waitForLayout();

View File

@@ -21,6 +21,7 @@ import org.briarproject.briar.android.view.ImagePreview.ImagePreviewListener;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.logging.Logger;
import androidx.annotation.Nullable;
import androidx.annotation.UiThread;
@@ -37,6 +38,8 @@ import static android.widget.Toast.LENGTH_LONG;
import static androidx.core.content.ContextCompat.getColor;
import static androidx.customview.view.AbsSavedState.EMPTY_STATE;
import static androidx.lifecycle.Lifecycle.State.DESTROYED;
import static java.util.logging.Level.INFO;
import static java.util.logging.Logger.getLogger;
import static org.briarproject.briar.android.util.UiUtils.resolveColorAttribute;
import static org.briarproject.briar.android.view.TextSendController.SendState.SENT;
import static org.briarproject.briar.api.messaging.MessagingConstants.MAX_ATTACHMENTS_PER_MESSAGE;
@@ -46,6 +49,9 @@ import static org.briarproject.briar.api.messaging.MessagingConstants.MAX_ATTACH
public class TextAttachmentController extends TextSendController
implements ImagePreviewListener {
private static final Logger LOG =
getLogger(TextAttachmentController.class.getName());
private final ImagePreview imagePreview;
private final AttachmentListener attachmentListener;
private final CompositeSendButton sendButton;
@@ -67,6 +73,7 @@ public class TextAttachmentController extends TextSendController
sendButton.setOnImageClickListener(view -> onImageButtonClicked());
}
@UiThread
@Override
protected void updateViewState() {
super.updateViewState();
@@ -160,10 +167,13 @@ public class TextAttachmentController extends TextSendController
* at most once per call to
* {@link Activity#startActivityForResult(Intent, int)}.
*/
@UiThread
@SuppressWarnings("JavadocReference")
public void onImageReceived(@Nullable Intent resultData) {
if (LOG.isLoggable(INFO)) LOG.info("onImageReceived: " + resultData);
if (resultData == null) return;
if (loadingUris || !imageUris.isEmpty()) throw new AssertionError();
if (loadingUris) throw new AssertionError("still loading URIs");
if (!imageUris.isEmpty()) throw new AssertionError("uris " + imageUris);
List<Uri> newUris = new ArrayList<>();
if (resultData.getData() != null) {
newUris.add(resultData.getData());
@@ -177,6 +187,7 @@ public class TextAttachmentController extends TextSendController
}
}
@UiThread
private void onNewUris(boolean restart, List<Uri> newUris) {
if (newUris.isEmpty()) return;
if (loadingUris) throw new AssertionError();
@@ -197,8 +208,9 @@ public class TextAttachmentController extends TextSendController
@Override
public void onChanged(@Nullable AttachmentResult attachmentResult) {
if (attachmentResult == null) {
// The fresh LiveData was deliberately set to null.
// This means that we can stop observing it.
// The fresh LiveData was deliberately set to null
// when the AttachmentCreator reset its state.
// This means that we can simply stop observing it.
result.removeObserver(this);
} else {
boolean noError = onNewAttachmentItemResults(
@@ -270,6 +282,7 @@ public class TextAttachmentController extends TextSendController
onCancel();
}
@UiThread
@Override
public void onCancel() {
textInput.clearText();

View File

@@ -6,9 +6,6 @@ import java.io.InputStream;
import javax.annotation.Nullable;
public interface TestAvatarCreator {
String MIME_TYPE = "image/webp";
@Nullable
InputStream getAvatarInputStream() throws IOException;
}

View File

@@ -316,7 +316,7 @@ public class TestDataCreatorImpl implements TestDataCreator {
Message m;
try {
m = avatarMessageEncoder.encodeUpdateMessage(groupId, 0,
TestAvatarCreator.MIME_TYPE, is).getFirst();
"image/jpeg", is).getFirst();
} catch (IOException e) {
throw new DbException(e);
}

View File

@@ -4,6 +4,7 @@ allprojects {
repositories {
jcenter()
mavenLocal()
mavenCentral()
google()
maven { url "https://jitpack.io" }
}