Skip to content

Commit 2ae890e

Browse files
committed
Update to libsignal-service 2.6.11
// FREEBIE
1 parent 5fadc88 commit 2ae890e

File tree

5 files changed

+39
-20
lines changed

5 files changed

+39
-20
lines changed

build.gradle

+3-3
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ dependencies {
6363

6464
compile 'org.whispersystems:jobmanager:1.0.2'
6565
compile 'org.whispersystems:libpastelog:1.0.7'
66-
compile 'org.whispersystems:signal-service-android:2.6.10'
66+
compile 'org.whispersystems:signal-service-android:2.6.11'
6767
compile 'org.whispersystems:webrtc-android:M59-S1'
6868

6969
compile "me.leolin:ShortcutBadger:1.1.16"
@@ -147,7 +147,7 @@ dependencyVerification {
147147
'com.google.android.exoplayer:exoplayer:955085aa611a8f7cf6c61b88ae03d1a392f4ad94c9bfbc153f3dedb9ffb14718',
148148
'org.whispersystems:jobmanager:506f679fc2fcf7bb6d10f00f41d6f6ea0abf75c70dc95b913398661ad538a181',
149149
'org.whispersystems:libpastelog:bb331d9a98240fc139101128ba836c1edec3c40e000597cdbb29ebf4cbf34d88',
150-
'org.whispersystems:signal-service-android:784b748c15cb3d2824b8fa2b0f9d8fd8b990b39e7a50259bac27bdcad845ce20',
150+
'org.whispersystems:signal-service-android:89f8630cc1737c3d52178dc46926f0755d75fed3ac9b94d067c0a42e4e3169c9',
151151
'org.whispersystems:webrtc-android:de647643afbbea45a26a4f24db75aa10bc8de45426e8eb0d9d563cc10af4f582',
152152
'me.leolin:ShortcutBadger:e3cb3e7625892129b0c92dd5e4bc649faffdd526d5af26d9c45ee31ff8851774',
153153
'se.emilsjolander:stickylistheaders:a08ca948aa6b220f09d82f16bbbac395f6b78897e9eeac6a9f0b0ba755928eeb',
@@ -185,7 +185,7 @@ dependencyVerification {
185185
'com.google.android.gms:play-services-basement:95dd882c5ffba15b9a99de3fefb05d3a01946623af67454ca00055d222f85a8d',
186186
'com.google.android.gms:play-services-iid:54e919f9957b8b7820da7ee9b83471d00d0cac1cf08ddea8b5b41aea80bb1a70',
187187
'org.whispersystems:signal-protocol-android:5b8acded7f2a40178eb90ab8e8cbfec89d170d91b3ff5e78487d1098df6185a1',
188-
'org.whispersystems:signal-service-java:308d9e61b753760d0f3828eb3181db58469e75c763bdce5a8335df6c4af47695',
188+
'org.whispersystems:signal-service-java:ef89da56b915490bb907d848eae79efdf1218e985763e7dd2e8047c7ccb03c0c',
189189
'com.github.bumptech.glide:gifdecoder:217da4520c568a93aea9c7ce3b3cac2c61fabed5113b07ae38698054f6d2d8b6',
190190
'com.github.bumptech.glide:disklrucache:795c13245498c0cd806c3af71ee57b3f179cbd1609440a3021c211c364ef74d3',
191191
'com.github.bumptech.glide:annotations:057927a236f3229e72cfbac8bed0e9fb398473daf7d933390f59ea4cb79c137b',

src/org/thoughtcrime/securesms/jobs/AttachmentDownloadJob.java

+8-2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import org.thoughtcrime.securesms.notifications.MessageNotifier;
2222
import org.thoughtcrime.securesms.util.AttachmentUtil;
2323
import org.thoughtcrime.securesms.util.Hex;
24+
import org.thoughtcrime.securesms.util.Util;
2425
import org.whispersystems.jobqueue.JobParameters;
2526
import org.whispersystems.jobqueue.requirements.NetworkRequirement;
2627
import org.whispersystems.libsignal.InvalidMessageException;
@@ -165,8 +166,13 @@ SignalServiceAttachmentPointer createAttachmentPointer(MasterSecret masterSecret
165166
Log.w(TAG, "Downloading attachment with no digest...");
166167
}
167168

168-
return new SignalServiceAttachmentPointer(id, null, key, relay, Optional.fromNullable(attachment.getDigest()), Optional.fromNullable(attachment.getFileName()), attachment.isVoiceNote());
169-
} catch (InvalidMessageException | IOException e) {
169+
return new SignalServiceAttachmentPointer(id, null, key, relay,
170+
Optional.of(Util.toIntExact(attachment.getSize())),
171+
Optional.absent(),
172+
Optional.fromNullable(attachment.getDigest()),
173+
Optional.fromNullable(attachment.getFileName()),
174+
attachment.isVoiceNote());
175+
} catch (InvalidMessageException | IOException | ArithmeticException e) {
170176
Log.w(TAG, e);
171177
throw new InvalidPartException(e);
172178
}

src/org/thoughtcrime/securesms/jobs/AvatarDownloadJob.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,9 @@ public void onRun(MasterSecret masterSecret) throws IOException {
8181
attachment = File.createTempFile("avatar", "tmp", context.getCacheDir());
8282
attachment.deleteOnExit();
8383

84-
SignalServiceAttachmentPointer pointer = new SignalServiceAttachmentPointer(avatarId, contentType, key, relay, digest, fileName, false);
84+
SignalServiceAttachmentPointer pointer = new SignalServiceAttachmentPointer(avatarId, contentType, key, relay, Optional.of(0), Optional.absent(), digest, fileName, false);
8585
InputStream inputStream = receiver.retrieveAttachment(pointer, attachment, MAX_AVATAR_SIZE);
86-
Bitmap avatar = BitmapUtil.createScaledBitmap(context, new AttachmentModel(attachment, key), 500, 500);
86+
Bitmap avatar = BitmapUtil.createScaledBitmap(context, new AttachmentModel(attachment, key, 0, digest), 500, 500);
8787

8888
database.updateAvatar(encodeId, avatar);
8989
inputStream.close();

src/org/thoughtcrime/securesms/mms/AttachmentStreamLocalUriFetcher.java

+12-6
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,25 @@ class AttachmentStreamLocalUriFetcher implements DataFetcher<InputStream> {
1919

2020
private static final String TAG = AttachmentStreamLocalUriFetcher.class.getSimpleName();
2121

22-
private File attachment;
23-
private byte[] key;
22+
private final File attachment;
23+
private final byte[] key;
24+
private final Optional<byte[]> digest;
25+
private final long plaintextLength;
26+
2427
private InputStream is;
2528

26-
AttachmentStreamLocalUriFetcher(File attachment, byte[] key) {
27-
this.attachment = attachment;
28-
this.key = key;
29+
AttachmentStreamLocalUriFetcher(File attachment, long plaintextLength, byte[] key, Optional<byte[]> digest) {
30+
this.attachment = attachment;
31+
this.plaintextLength = plaintextLength;
32+
this.digest = digest;
33+
this.key = key;
2934
}
3035

3136
@Override
3237
public void loadData(Priority priority, DataCallback<? super InputStream> callback) {
3338
try {
34-
is = new AttachmentCipherInputStream(attachment, key, Optional.absent());
39+
if (!digest.isPresent()) throw new InvalidMessageException("No attachment digest!");
40+
is = AttachmentCipherInputStream.createFor(attachment, plaintextLength, key, digest.get());
3541
callback.onDataReady(is);
3642
} catch (IOException | InvalidMessageException e) {
3743
callback.onLoadFailed(e);

src/org/thoughtcrime/securesms/mms/AttachmentStreamUriLoader.java

+14-7
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import com.bumptech.glide.load.model.MultiModelLoaderFactory;
1111

1212
import org.thoughtcrime.securesms.mms.AttachmentStreamUriLoader.AttachmentModel;
13+
import org.whispersystems.libsignal.util.guava.Optional;
1314

1415
import java.io.File;
1516
import java.io.InputStream;
@@ -20,7 +21,7 @@ public class AttachmentStreamUriLoader implements ModelLoader<AttachmentModel, I
2021
@Nullable
2122
@Override
2223
public LoadData<InputStream> buildLoadData(AttachmentModel attachmentModel, int width, int height, Options options) {
23-
return new LoadData<>(attachmentModel, new AttachmentStreamLocalUriFetcher(attachmentModel.attachment, attachmentModel.key));
24+
return new LoadData<>(attachmentModel, new AttachmentStreamLocalUriFetcher(attachmentModel.attachment, attachmentModel.plaintextLength, attachmentModel.key, attachmentModel.digest));
2425
}
2526

2627
@Override
@@ -42,12 +43,18 @@ public void teardown() {
4243
}
4344

4445
public static class AttachmentModel implements Key {
45-
public @NonNull File attachment;
46-
public @NonNull byte[] key;
47-
48-
public AttachmentModel(@NonNull File attachment, @NonNull byte[] key) {
49-
this.attachment = attachment;
50-
this.key = key;
46+
public @NonNull File attachment;
47+
public @NonNull byte[] key;
48+
public @NonNull Optional<byte[]> digest;
49+
public long plaintextLength;
50+
51+
public AttachmentModel(@NonNull File attachment, @NonNull byte[] key,
52+
long plaintextLength, @NonNull Optional<byte[]> digest)
53+
{
54+
this.attachment = attachment;
55+
this.key = key;
56+
this.digest = digest;
57+
this.plaintextLength = plaintextLength;
5158
}
5259

5360
@Override

0 commit comments

Comments
 (0)