Skip to content

Commit

Permalink
v3.2.2 (build 254)
Browse files Browse the repository at this point in the history
  • Loading branch information
finiasz committed Oct 18, 2024
1 parent 26c9333 commit 06363c6
Show file tree
Hide file tree
Showing 53 changed files with 519 additions and 173 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
# Build 254 (3.2.2)
2024-10-18

- Fix a layout issue with vide attachments
- Fix a crash with endless location sharing

# Build 253 (3.2.1)
2024-10-11

- Fix a bug when viewing read-once images and videos
- Fix a bug with message swipe being too sensitive (and preventing tap/long press)
- Allow to configure an alternate TURN server through MDM

# Build 252 (3.2)
2024-09-25

Expand Down
5 changes: 5 additions & 0 deletions obv_engine/engine/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,8 @@ dependencies {
testImplementation 'junit:junit:4.13.2'
testImplementation 'org.xerial:sqlite-jdbc:3.45.1.0' // only here to check if a new version is available
}

java {
sourceCompatibility = 17
targetCompatibility = 17
}
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ public byte[] internalSign(SignatureECSdsaPrivateKey privateKey, SignatureECSdsa
System.arraycopy(Encoded.bytesFromBigUInt(publicKey.getAy(), l), 0, hashInput, l, l);
System.arraycopy(message, 0, hashInput, 2*l, message.length);

// TODO: switch to once all clients support signature with SHA512 hash (supported since build 242, 2024-06-10)
// TODO: switch to this once all clients support signature with SHA512 hash (supported since build 242, 2024-06-10)
// byte[] hash = new HashSHA512().digest(hashInput);
byte[] hash = new HashSHA256().digest(hashInput);
BigInteger e = Encoded.bigUIntFromBytes(hash);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,9 @@ public void retryScheduledRunnables() {
}

// for polling only
public ScheduledFuture<?> scheduleAtFixedRate(Runnable runnable, int i, long delay, TimeUnit timeUnit) {
return scheduler.scheduleAtFixedRate(runnable, i, delay, timeUnit);
}
// public ScheduledFuture<?> scheduleAtFixedRate(Runnable runnable, int i, long delay, TimeUnit timeUnit) {
// return scheduler.scheduleAtFixedRate(runnable, i, delay, timeUnit);
// }

protected long computeReschedulingDelay(int failedAttemptCount) {
return (long) ((Constants.BASE_RESCHEDULING_TIME << failedAttemptCount) * (1 + random.nextFloat()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLSocketFactory;

import io.olvid.engine.Logger;
import io.olvid.engine.encoder.DecodingException;
import io.olvid.engine.encoder.Encoded;

Expand Down Expand Up @@ -170,6 +171,7 @@ public byte execute(boolean ownedIdentityIsActive) {
break;
}
default: { // unknown server response
Logger.w("Unexpected HTTP response code: " + serverResponse + " for query " + path);
returnStatus = SERVER_CONNECTION_ERROR;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLSocketFactory;

import io.olvid.engine.Logger;

public abstract class ServerMethodForS3 {
public static final byte OK = 0x00;
public static final byte NOT_FOUND = 0x01;
Expand Down Expand Up @@ -164,6 +166,7 @@ public byte execute(boolean ownedIdentityIsActive) {
break;
}
default:
Logger.w("Unexpected HTTP response code: " + serverResponse + " for attachment download");
returnStatus = GENERAL_ERROR;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* Olvid for Android
* Copyright © 2019-2024 Olvid SAS
*
* This file is part of Olvid for Android.
*
* Olvid is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* Olvid is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Olvid. If not, see <https://www.gnu.org/licenses/>.
*/

package io.olvid.engine.datatypes.containers;

public enum OwnedIdentitySynchronizationStatus {
SYNCHRONIZED,
INITIAL_SYNC_IN_PROGRESS,
MANUAL_SYNC_IN_PROGRESS,
OTHER_SYNC_IN_PROGRESS,
}
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,6 @@ public enum TurnCredentialsFailedReason {

public static final String NOTIFICATION_OWNED_IDENTITY_SYNCHRONIZING_WITH_SERVER = "network_fetch_notification_owned_identity_synchronizing_with_server";
public static final String NOTIFICATION_OWNED_IDENTITY_SYNCHRONIZING_WITH_SERVER_OWNED_IDENTITY_KEY = "owned_identity"; // Identity
public static final String NOTIFICATION_OWNED_IDENTITY_SYNCHRONIZING_WITH_SERVER_IN_PROGRESS_KEY = "in_progress"; // boolean
public static final String NOTIFICATION_OWNED_IDENTITY_SYNCHRONIZING_WITH_SERVER_STATUS_KEY = "status"; // OwnedIdentitySynchronizationStatus

}
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public abstract class ProtocolNotifications {
public static final String NOTIFICATION_CONTACT_INTRODUCTION_INVITATION_RESPONSE = "protocol_manager_notification_contact_introduction_invitation_response";
public static final String NOTIFICATION_CONTACT_INTRODUCTION_INVITATION_RESPONSE_OWNED_IDENTITY_KEY = "owned_identity"; // Identity
public static final String NOTIFICATION_CONTACT_INTRODUCTION_INVITATION_RESPONSE_MEDIATOR_IDENTITY_KEY = "mediator_identity"; // Identity
public static final String NOTIFICATION_CONTACT_INTRODUCTION_INVITATION_RESPONSE_CONTACT_IDENTITY_KEY = "contact_identity"; // Identity
public static final String NOTIFICATION_CONTACT_INTRODUCTION_INVITATION_RESPONSE_CONTACT_SERIALIZED_DETAILS_KEY = "contact_serialized_details"; // String
public static final String NOTIFICATION_CONTACT_INTRODUCTION_INVITATION_RESPONSE_ACCEPTED_KEY = "accepted"; // boolean

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,16 +203,18 @@ public void callback(String notificationName, HashMap<String, Object> userInfo)
case ProtocolNotifications.NOTIFICATION_CONTACT_INTRODUCTION_INVITATION_RESPONSE: {
Identity ownedIdentity = (Identity) userInfo.get(ProtocolNotifications.NOTIFICATION_CONTACT_INTRODUCTION_INVITATION_RESPONSE_OWNED_IDENTITY_KEY);
Identity mediatorIdentity = (Identity) userInfo.get(ProtocolNotifications.NOTIFICATION_CONTACT_INTRODUCTION_INVITATION_RESPONSE_MEDIATOR_IDENTITY_KEY);
Identity contactIdentity = (Identity) userInfo.get(ProtocolNotifications.NOTIFICATION_CONTACT_INTRODUCTION_INVITATION_RESPONSE_CONTACT_IDENTITY_KEY);
String contactSerializedDetails = (String) userInfo.get(ProtocolNotifications.NOTIFICATION_CONTACT_INTRODUCTION_INVITATION_RESPONSE_CONTACT_SERIALIZED_DETAILS_KEY);
Boolean accepted = (Boolean) userInfo.get(ProtocolNotifications.NOTIFICATION_CONTACT_INTRODUCTION_INVITATION_RESPONSE_ACCEPTED_KEY);

if (ownedIdentity == null || mediatorIdentity == null || contactSerializedDetails == null || accepted == null) {
if (ownedIdentity == null || mediatorIdentity == null || contactSerializedDetails == null || accepted == null || contactIdentity == null) {
break;
}

HashMap<String, Object> engineInfo = new HashMap<>();
engineInfo.put(EngineNotifications.CONTACT_INTRODUCTION_INVITATION_RESPONSE_BYTES_OWNED_IDENTITY_KEY, ownedIdentity.getBytes());
engineInfo.put(EngineNotifications.CONTACT_INTRODUCTION_INVITATION_RESPONSE_BYTES_MEDIATOR_IDENTITY_KEY, mediatorIdentity.getBytes());
engineInfo.put(EngineNotifications.CONTACT_INTRODUCTION_INVITATION_RESPONSE_BYTES_CONTACT_IDENTITY_KEY, contactIdentity.getBytes());
engineInfo.put(EngineNotifications.CONTACT_INTRODUCTION_INVITATION_RESPONSE_CONTACT_SERIALIZED_DETAILS_KEY, contactSerializedDetails);
engineInfo.put(EngineNotifications.CONTACT_INTRODUCTION_INVITATION_RESPONSE_ACCEPTED_KEY, accepted);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import io.olvid.engine.datatypes.Identity;
import io.olvid.engine.datatypes.NotificationListener;
import io.olvid.engine.datatypes.UID;
import io.olvid.engine.datatypes.containers.OwnedIdentitySynchronizationStatus;
import io.olvid.engine.datatypes.notifications.DownloadNotifications;
import io.olvid.engine.engine.types.EngineAPI;
import io.olvid.engine.engine.types.EngineNotifications;
Expand Down Expand Up @@ -562,14 +563,14 @@ public void callback(String notificationName, HashMap<String, Object> userInfo)
}
case DownloadNotifications.NOTIFICATION_OWNED_IDENTITY_SYNCHRONIZING_WITH_SERVER: {
Identity ownedIdentity = (Identity) userInfo.get(DownloadNotifications.NOTIFICATION_OWNED_IDENTITY_SYNCHRONIZING_WITH_SERVER_OWNED_IDENTITY_KEY);
boolean inProgress = (boolean) userInfo.get(DownloadNotifications.NOTIFICATION_OWNED_IDENTITY_SYNCHRONIZING_WITH_SERVER_IN_PROGRESS_KEY);
if (ownedIdentity == null) {
OwnedIdentitySynchronizationStatus status = (OwnedIdentitySynchronizationStatus) userInfo.get(DownloadNotifications.NOTIFICATION_OWNED_IDENTITY_SYNCHRONIZING_WITH_SERVER_STATUS_KEY);
if (ownedIdentity == null || status == null) {
break;
}

HashMap<String, Object> engineInfo = new HashMap<>();
engineInfo.put(EngineNotifications.OWNED_IDENTITY_SYNCHRONIZING_WITH_SERVER_BYTES_OWNED_IDENTITY_KEY, ownedIdentity.getBytes());
engineInfo.put(EngineNotifications.OWNED_IDENTITY_SYNCHRONIZING_WITH_SERVER_IN_PROGRESS_KEY, inProgress);
engineInfo.put(EngineNotifications.OWNED_IDENTITY_SYNCHRONIZING_WITH_SERVER_STATUS_KEY, status);

engine.postEngineNotification(EngineNotifications.OWNED_IDENTITY_SYNCHRONIZING_WITH_SERVER, engineInfo);
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,7 @@ public abstract class EngineNotifications {
public static final String CONTACT_INTRODUCTION_INVITATION_RESPONSE = "engine_notification_contact_introduction_invitation_response";
public static final String CONTACT_INTRODUCTION_INVITATION_RESPONSE_BYTES_OWNED_IDENTITY_KEY = "bytes_owned_identity"; // byte[]
public static final String CONTACT_INTRODUCTION_INVITATION_RESPONSE_BYTES_MEDIATOR_IDENTITY_KEY = "bytes_mediator_identity"; // byte[]
public static final String CONTACT_INTRODUCTION_INVITATION_RESPONSE_BYTES_CONTACT_IDENTITY_KEY = "bytes_contact_identity"; // byte[]
public static final String CONTACT_INTRODUCTION_INVITATION_RESPONSE_CONTACT_SERIALIZED_DETAILS_KEY = "contact_serialized_Details"; // String
public static final String CONTACT_INTRODUCTION_INVITATION_RESPONSE_ACCEPTED_KEY = "accepted"; // boolean

Expand All @@ -400,5 +401,5 @@ public abstract class EngineNotifications {

public static final String OWNED_IDENTITY_SYNCHRONIZING_WITH_SERVER = "engine_notification_owned_identity_synchronizing_with_server";
public static final String OWNED_IDENTITY_SYNCHRONIZING_WITH_SERVER_BYTES_OWNED_IDENTITY_KEY = "bytes_owned_identity"; // byte[]
public static final String OWNED_IDENTITY_SYNCHRONIZING_WITH_SERVER_IN_PROGRESS_KEY = "in_progress"; // boolean
public static final String OWNED_IDENTITY_SYNCHRONIZING_WITH_SERVER_STATUS_KEY = "status"; // OwnedIdentitySynchronizationStatus
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import io.olvid.engine.datatypes.UID;
import io.olvid.engine.datatypes.containers.AttachmentKeyAndMetadata;
import io.olvid.engine.datatypes.containers.DecryptedApplicationMessage;
import io.olvid.engine.datatypes.containers.OwnedIdentitySynchronizationStatus;
import io.olvid.engine.datatypes.containers.ReceivedAttachment;
import io.olvid.engine.datatypes.containers.ServerQuery;
import io.olvid.engine.datatypes.key.symmetric.AuthEncKey;
Expand Down Expand Up @@ -309,6 +310,7 @@ private FetchManagerSession wrapSession(Session session) {

@Override
public void downloadMessages(Identity ownedIdentity, UID deviceUid) {
markOwnedIdentityAsNotUpToDate(ownedIdentity, OwnedIdentitySynchronizationStatus.MANUAL_SYNC_IN_PROGRESS);
downloadMessagesAndListAttachmentsCoordinator.downloadMessagesAndListAttachments(ownedIdentity, deviceUid);

HashMap<String, Object> userInfo = new HashMap<>();
Expand Down Expand Up @@ -502,7 +504,7 @@ public void markOwnedIdentityAsUpToDate(Identity ownedIdentity) {
if (notificationPostingDelegate != null) {
HashMap<String, Object> userInfo = new HashMap<>();
userInfo.put(DownloadNotifications.NOTIFICATION_OWNED_IDENTITY_SYNCHRONIZING_WITH_SERVER_OWNED_IDENTITY_KEY, ownedIdentity);
userInfo.put(DownloadNotifications.NOTIFICATION_OWNED_IDENTITY_SYNCHRONIZING_WITH_SERVER_IN_PROGRESS_KEY, false);
userInfo.put(DownloadNotifications.NOTIFICATION_OWNED_IDENTITY_SYNCHRONIZING_WITH_SERVER_STATUS_KEY, OwnedIdentitySynchronizationStatus.SYNCHRONIZED);
notificationPostingDelegate.postNotification(DownloadNotifications.NOTIFICATION_OWNED_IDENTITY_SYNCHRONIZING_WITH_SERVER, userInfo);
}

Expand All @@ -518,15 +520,15 @@ public void markOwnedIdentityAsUpToDate(Identity ownedIdentity) {
}

@Override
public void markOwnedIdentityAsNotUpToDate(Identity ownedIdentity) {
public void markOwnedIdentityAsNotUpToDate(Identity ownedIdentity, OwnedIdentitySynchronizationStatus synchronizationStatus) {
synchronized (ownedIdentitiesUpToDateRegardingServerListing) {
// notify app that syncing is in progress, but only if it was in sync
ownedIdentitiesUpToDateRegardingServerListing.remove(ownedIdentity);

// notify app that syncing is in progress
if (notificationPostingDelegate != null) {
if (notificationPostingDelegate != null && synchronizationStatus != OwnedIdentitySynchronizationStatus.SYNCHRONIZED) {
HashMap<String, Object> userInfo = new HashMap<>();
userInfo.put(DownloadNotifications.NOTIFICATION_OWNED_IDENTITY_SYNCHRONIZING_WITH_SERVER_OWNED_IDENTITY_KEY, ownedIdentity);
userInfo.put(DownloadNotifications.NOTIFICATION_OWNED_IDENTITY_SYNCHRONIZING_WITH_SERVER_IN_PROGRESS_KEY, true);
userInfo.put(DownloadNotifications.NOTIFICATION_OWNED_IDENTITY_SYNCHRONIZING_WITH_SERVER_STATUS_KEY, synchronizationStatus);
notificationPostingDelegate.postNotification(DownloadNotifications.NOTIFICATION_OWNED_IDENTITY_SYNCHRONIZING_WITH_SERVER, userInfo);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import io.olvid.engine.datatypes.PushNotificationTypeAndParameters;
import io.olvid.engine.datatypes.UID;
import io.olvid.engine.datatypes.containers.IdentityAndUid;
import io.olvid.engine.datatypes.containers.OwnedIdentitySynchronizationStatus;
import io.olvid.engine.datatypes.notifications.DownloadNotifications;
import io.olvid.engine.metamanager.NotificationListeningDelegate;
import io.olvid.engine.metamanager.NotificationPostingDelegate;
Expand Down Expand Up @@ -147,10 +148,11 @@ public void onFinishCallback(Operation operation) {
Identity ownedIdentity = ((RegisterPushNotificationOperation) operation).getOwnedIdentity();
UID deviceUid = ((RegisterPushNotificationOperation) operation).getDeviceUid();
scheduler.clearFailedCount(ownedIdentity);
if (deviceUid != null) {
// after a registration, always start a downloadMessages
downloadMessagesAndListAttachmentsDelegate.downloadMessagesAndListAttachments(ownedIdentity, deviceUid);
}
// sync is not needed after a register
// if (deviceUid != null) {
// // after a registration, always start a downloadMessages
// downloadMessagesAndListAttachmentsDelegate.downloadMessagesAndListAttachments(ownedIdentity, deviceUid);
// }
if (notificationPostingDelegate != null) {
HashMap<String, Object> userInfo = new HashMap<>();
userInfo.put(DownloadNotifications.NOTIFICATION_PUSH_NOTIFICATION_REGISTERED_OWNED_IDENTITY_KEY, ownedIdentity);
Expand Down Expand Up @@ -230,6 +232,7 @@ public void processAndroidPushNotification(String androidMaskingUidString) {
UID androidIdentityMaskingUid = new UID(androidMaskingUidString);
IdentityAndUid identityAndUid = androidIdentityMaskingUids.get(androidIdentityMaskingUid);
if (identityAndUid != null) {
fetchManagerSessionFactory.markOwnedIdentityAsNotUpToDate(identityAndUid.ownedIdentity, OwnedIdentitySynchronizationStatus.OTHER_SYNC_IN_PROGRESS);
downloadMessagesAndListAttachmentsDelegate.downloadMessagesAndListAttachments(identityAndUid.ownedIdentity, identityAndUid.uid);
}
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
import io.olvid.engine.datatypes.Operation;
import io.olvid.engine.datatypes.ServerMethod;
import io.olvid.engine.datatypes.UID;
import io.olvid.engine.datatypes.containers.OwnedIdentitySynchronizationStatus;
import io.olvid.engine.datatypes.notifications.DownloadNotifications;
import io.olvid.engine.datatypes.notifications.IdentityNotifications;
import io.olvid.engine.encoder.DecodingException;
Expand Down Expand Up @@ -86,6 +87,7 @@ public class WebsocketCoordinator implements Operation.OnCancelCallback {
private final ObjectMapper jsonObjectMapper;

private final Map<String, List<IdentityAndUid>> ownedIdentityAndUidsByServer;
private final HashSet<Identity> ownedIdentityFirstRegisterSuccessful;
private final Map<Identity, UID> ownedIdentityCurrentDeviceUids;
private final Map<Identity, byte[]> ownedIdentityServerSessionTokens;
private final Object ownedIdentityAndUidsLock = new Object();
Expand Down Expand Up @@ -154,6 +156,7 @@ protected long computeReschedulingDelay(int failedAttemptCount) {
wellKnownCacheNotificationListener = new WellKnownCacheNotificationListener();

ownedIdentityAndUidsByServer = new HashMap<>();
ownedIdentityFirstRegisterSuccessful = new HashSet<>();
ownedIdentityCurrentDeviceUids = new HashMap<>();
ownedIdentityServerSessionTokens = new HashMap<>();
existingWebsockets = new HashMap<>();
Expand Down Expand Up @@ -706,6 +709,9 @@ public void onMessage(WebSocket webSocket, String message) {
}
if (!receivedMessage.containsKey("err")) {
Logger.d("Successfully registered identity on websocket");
synchronized (ownedIdentityFirstRegisterSuccessful) {
ownedIdentityFirstRegisterSuccessful.add(identity);
}
break;
}

Expand Down Expand Up @@ -766,7 +772,13 @@ public void onMessage(WebSocket webSocket, String message) {
}
}
// uf we receive this notification, we might have many pending messages on the server --> mark own identity as not up to date
fetchManagerSessionFactory.markOwnedIdentityAsNotUpToDate(identity);
synchronized (ownedIdentityFirstRegisterSuccessful) {
if (ownedIdentityFirstRegisterSuccessful.contains(identity)) {
fetchManagerSessionFactory.markOwnedIdentityAsNotUpToDate(identity, OwnedIdentitySynchronizationStatus.OTHER_SYNC_IN_PROGRESS);
} else {
fetchManagerSessionFactory.markOwnedIdentityAsNotUpToDate(identity, OwnedIdentitySynchronizationStatus.INITIAL_SYNC_IN_PROGRESS);
}
}
downloadMessagesAndListAttachmentsDelegate.downloadMessagesAndListAttachments(identity, deviceUid);
} catch (IOException | DecodingException e) {
Logger.d("Error decoding identity");
Expand Down
Loading

0 comments on commit 06363c6

Please sign in to comment.