Skip to content

Commit a2a7b20

Browse files
committed
Merge remote-tracking branch 'upstream/master' into cust_remove_call_confirm
2 parents 29eff02 + 264a245 commit a2a7b20

17 files changed

Lines changed: 183 additions & 53 deletions

File tree

app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ protobuf {
6161
}
6262
}
6363

64-
def canonicalVersionCode = 791
65-
def canonicalVersionName = "5.4.5"
64+
def canonicalVersionCode = 792
65+
def canonicalVersionName = "5.4.6"
6666

6767
def postFixSize = 100
6868
def abiPostFix = ['universal' : 0,

app/src/main/java/org/thoughtcrime/securesms/WebRtcCallActivity.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,7 @@ private void handleUntrustedIdentity(@NonNull WebRtcViewModel event) {
518518
final Recipient recipient = event.getRemoteParticipants().get(0).getRecipient();
519519

520520
if (theirKey == null) {
521+
Log.w(TAG, "Untrusted identity without an identity key, terminating call.");
521522
handleTerminate(recipient, HangupMessage.Type.NORMAL);
522523
}
523524

app/src/main/java/org/thoughtcrime/securesms/components/sensors/DeviceOrientationMonitor.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,10 @@ public LiveData<Orientation> getOrientation() {
6565
}
6666

6767
private void updateOrientationAngles() {
68-
SensorManager.getRotationMatrix(rotationMatrix, null, accelerometerReading, magnetometerReading);
68+
boolean success = SensorManager.getRotationMatrix(rotationMatrix, null, accelerometerReading, magnetometerReading);
69+
if (!success) {
70+
SensorUtil.getRotationMatrixWithoutMagneticSensorData(rotationMatrix, accelerometerReading);
71+
}
6972
SensorManager.getOrientation(rotationMatrix, orientationAngles);
7073

7174
float pitch = orientationAngles[1];
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
package org.thoughtcrime.securesms.components.sensors;
2+
3+
public final class SensorUtil {
4+
5+
private SensorUtil() { }
6+
7+
public static void getRotationMatrixWithoutMagneticSensorData(float[] rotationMatrix, float[] accelerometerReading) {
8+
double gx, gy, gz;
9+
gx = accelerometerReading[0] / 9.81f;
10+
gy = accelerometerReading[1] / 9.81f;
11+
gz = accelerometerReading[2] / 9.81f;
12+
13+
float pitch = (float) -Math.atan(gy / Math.sqrt(gx * gx + gz * gz));
14+
float roll = (float) -Math.atan(gx / Math.sqrt(gy * gy + gz * gz));
15+
float azimuth = 0;
16+
17+
float[] fakeMagnetometerReading = { azimuth, pitch, roll };
18+
19+
System.arraycopy(getRotationMatrixForOrientation(fakeMagnetometerReading), 0, rotationMatrix, 0, rotationMatrix.length);
20+
}
21+
22+
private static float[] getRotationMatrixForOrientation(float[] o) {
23+
float[] xM = new float[9];
24+
float[] yM = new float[9];
25+
float[] zM = new float[9];
26+
27+
float sinX = (float) Math.sin(o[1]);
28+
float cosX = (float) Math.cos(o[1]);
29+
float sinY = (float) Math.sin(o[2]);
30+
float cosY = (float) Math.cos(o[2]);
31+
float sinZ = (float) Math.sin(o[0]);
32+
float cosZ = (float) Math.cos(o[0]);
33+
34+
xM[0] = 1.0f;
35+
xM[1] = 0.0f;
36+
xM[2] = 0.0f;
37+
38+
xM[3] = 0.0f;
39+
xM[4] = cosX;
40+
xM[5] = sinX;
41+
42+
xM[6] = 0.0f;
43+
xM[7] = -sinX;
44+
xM[8] = cosX;
45+
46+
yM[0] = cosY;
47+
yM[1] = 0.0f;
48+
yM[2] = sinY;
49+
50+
yM[3] = 0.0f;
51+
yM[4] = 1.0f;
52+
yM[5] = 0.0f;
53+
54+
yM[6] = -sinY;
55+
yM[7] = 0.0f;
56+
yM[8] = cosY;
57+
58+
zM[0] = cosZ;
59+
zM[1] = sinZ;
60+
zM[2] = 0.0f;
61+
62+
zM[3] = -sinZ;
63+
zM[4] = cosZ;
64+
zM[5] = 0.0f;
65+
66+
zM[6] = 0.0f;
67+
zM[7] = 0.0f;
68+
zM[8] = 1.0f;
69+
70+
float[] resultMatrix = matrixMultiplication(xM, yM);
71+
resultMatrix = matrixMultiplication(zM, resultMatrix);
72+
return resultMatrix;
73+
}
74+
75+
private static float[] matrixMultiplication(float[] A, float[] B) {
76+
float[] result = new float[9];
77+
78+
result[0] = A[0] * B[0] + A[1] * B[3] + A[2] * B[6];
79+
result[1] = A[0] * B[1] + A[1] * B[4] + A[2] * B[7];
80+
result[2] = A[0] * B[2] + A[1] * B[5] + A[2] * B[8];
81+
82+
result[3] = A[3] * B[0] + A[4] * B[3] + A[5] * B[6];
83+
result[4] = A[3] * B[1] + A[4] * B[4] + A[5] * B[7];
84+
result[5] = A[3] * B[2] + A[4] * B[5] + A[5] * B[8];
85+
86+
result[6] = A[6] * B[0] + A[7] * B[3] + A[8] * B[6];
87+
result[7] = A[6] * B[1] + A[7] * B[4] + A[8] * B[7];
88+
result[8] = A[6] * B[2] + A[7] * B[5] + A[8] * B[8];
89+
90+
return result;
91+
}
92+
}

app/src/main/java/org/thoughtcrime/securesms/conversation/ConversationGroupViewModel.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -190,11 +190,12 @@ private static List<RecipientId> mapToGroupV1MigrationSuggestions(@Nullable Grou
190190

191191
@WorkerThread
192192
private static boolean mapToGroupV1MigrationReminder(@Nullable GroupRecord record) {
193-
if (record == null ||
194-
!record.isV1Group() ||
195-
!record.isActive() ||
196-
!FeatureFlags.groupsV1ManualMigration() ||
197-
FeatureFlags.groupsV1ForcedMigration() ||
193+
if (record == null ||
194+
!record.isV1Group() ||
195+
!record.isActive() ||
196+
!FeatureFlags.groupsV1ManualMigration() ||
197+
FeatureFlags.groupsV1ForcedMigration() ||
198+
Recipient.self().getGroupsV1MigrationCapability() != Recipient.Capability.SUPPORTED ||
198199
!Recipient.resolved(record.getRecipientId()).isProfileSharing())
199200
{
200201
return false;

app/src/main/java/org/thoughtcrime/securesms/crypto/IdentityKeyParcelable.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
import android.os.Parcel;
2020
import android.os.Parcelable;
2121

22+
import androidx.annotation.Nullable;
23+
24+
import org.thoughtcrime.securesms.util.ParcelUtil;
2225
import org.whispersystems.libsignal.IdentityKey;
2326
import org.whispersystems.libsignal.InvalidKeyException;
2427

@@ -40,19 +43,17 @@ public IdentityKeyParcelable[] newArray(int size) {
4043

4144
private final IdentityKey identityKey;
4245

43-
public IdentityKeyParcelable(IdentityKey identityKey) {
46+
public IdentityKeyParcelable(@Nullable IdentityKey identityKey) {
4447
this.identityKey = identityKey;
4548
}
4649

4750
public IdentityKeyParcelable(Parcel in) throws InvalidKeyException {
48-
int serializedLength = in.readInt();
49-
byte[] serialized = new byte[serializedLength];
51+
byte[] serialized = ParcelUtil.readByteArray(in);
5052

51-
in.readByteArray(serialized);
52-
this.identityKey = new IdentityKey(serialized, 0);
53+
this.identityKey = serialized != null ? new IdentityKey(serialized, 0) : null;
5354
}
5455

55-
public IdentityKey get() {
56+
public @Nullable IdentityKey get() {
5657
return identityKey;
5758
}
5859

@@ -63,7 +64,6 @@ public int describeContents() {
6364

6465
@Override
6566
public void writeToParcel(Parcel dest, int flags) {
66-
dest.writeInt(identityKey.serialize().length);
67-
dest.writeByteArray(identityKey.serialize());
67+
ParcelUtil.writeByteArray(dest, identityKey != null ? identityKey.serialize() : null);
6868
}
6969
}

app/src/main/java/org/thoughtcrime/securesms/events/CallParticipant.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ private CallParticipant(@NonNull CallParticipantId callParticipantId,
8585
this.deviceOrdinal = deviceOrdinal;
8686
}
8787

88-
public @NonNull CallParticipant withIdentityKey(@NonNull IdentityKey identityKey) {
88+
public @NonNull CallParticipant withIdentityKey(@Nullable IdentityKey identityKey) {
8989
return new CallParticipant(callParticipantId, recipient, identityKey, videoSink, cameraState, videoEnabled, microphoneEnabled, lastSpoke, mediaKeysReceived, addedToCallTime, deviceOrdinal);
9090
}
9191

app/src/main/java/org/thoughtcrime/securesms/jobs/AttachmentCompressionJob.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,9 @@ private void compress(@NonNull AttachmentDatabase attachmentDatabase,
160160
throws UndeliverableMessageException
161161
{
162162
try {
163-
if (MediaUtil.isVideo(attachment)) {
163+
if (attachment.isSticker()) {
164+
Log.d(TAG, "Sticker, not compressing.");
165+
} else if (MediaUtil.isVideo(attachment)) {
164166
Log.i(TAG, "Compressing video.");
165167
attachment = transcodeVideoIfNeededToDatabase(context, attachmentDatabase, attachment, constraints, EventBus.getDefault(), this::isCanceled);
166168
if (!constraints.isSatisfied(context, attachment)) {

app/src/main/java/org/thoughtcrime/securesms/mediasend/MediaSendActivity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -703,7 +703,7 @@ private void initViewModel() {
703703
countButton.setVisibility(View.GONE);
704704
continueButton.setVisibility(View.VISIBLE);
705705

706-
if (!TextSecurePreferences.hasSeenCameraFirstTooltip(this)) {
706+
if (!TextSecurePreferences.hasSeenCameraFirstTooltip(this) && !getIntent().hasExtra(KEY_RECIPIENTS)) {
707707
TooltipPopup.forTarget(continueButton)
708708
.setText(R.string.MediaSendActivity_select_recipients)
709709
.show(TooltipPopup.POSITION_ABOVE);

app/src/main/java/org/thoughtcrime/securesms/service/webrtc/WebRtcActionProcessor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,7 @@ public WebRtcActionProcessor(@NonNull WebRtcInteractor webRtcInteractor, @NonNul
533533

534534
if (errorCallState == WebRtcViewModel.State.UNTRUSTED_IDENTITY) {
535535
CallParticipant participant = Objects.requireNonNull(currentState.getCallInfoState().getRemoteCallParticipant(activePeer.getRecipient()));
536-
CallParticipant untrusted = participant.withIdentityKey(identityKey.get());
536+
CallParticipant untrusted = participant.withIdentityKey(identityKey.orNull());
537537

538538
builder.changeCallInfoState()
539539
.callState(WebRtcViewModel.State.UNTRUSTED_IDENTITY)

0 commit comments

Comments
 (0)