WIP: clean up unused exceptions

This commit is contained in:
Ryan ZHAO 2021-02-19 15:28:26 +11:00
parent d8104c0d5c
commit 8cc78e8f4c
22 changed files with 4 additions and 5003 deletions

View File

@ -26,10 +26,6 @@ import org.thoughtcrime.securesms.mms.MmsRadioException;
import org.thoughtcrime.securesms.mms.PartParser;
import org.thoughtcrime.securesms.providers.BlobProvider;
import org.thoughtcrime.securesms.service.KeyCachingService;
import org.session.libsignal.libsignal.DuplicateMessageException;
import org.session.libsignal.libsignal.InvalidMessageException;
import org.session.libsignal.libsignal.LegacyMessageException;
import org.session.libsignal.libsignal.NoSessionException;
import org.session.libsignal.libsignal.util.guava.Optional;
import org.session.libsession.messaging.sending_receiving.attachments.Attachment;
@ -160,18 +156,6 @@ public class MmsDownloadJob extends BaseJob {
handleDownloadError(messageId, threadId,
MmsDatabase.Status.DOWNLOAD_SOFT_FAILURE,
automatic);
} catch (DuplicateMessageException e) {
Log.w(TAG, e);
database.markAsDecryptDuplicate(messageId, threadId);
} catch (LegacyMessageException e) {
Log.w(TAG, e);
database.markAsLegacyVersion(messageId, threadId);
} catch (NoSessionException e) {
Log.w(TAG, e);
database.markAsNoSession(messageId, threadId);
} catch (InvalidMessageException e) {
Log.w(TAG, e);
database.markAsDecryptFailed(messageId, threadId);
}
}
@ -194,8 +178,7 @@ public class MmsDownloadJob extends BaseJob {
private void storeRetrievedMms(String contentLocation,
long messageId, long threadId, RetrieveConf retrieved,
int subscriptionId, @Nullable Address notificationFrom)
throws MmsException, NoSessionException, DuplicateMessageException, InvalidMessageException,
LegacyMessageException
throws MmsException
{
MmsDatabase database = DatabaseFactory.getMmsDatabase(context);
Optional<Address> group = Optional.absent();

View File

@ -55,7 +55,6 @@ import org.thoughtcrime.securesms.loki.protocol.SessionMetaProtocol;
import org.thoughtcrime.securesms.loki.utilities.MentionUtilities;
import org.thoughtcrime.securesms.mms.SlideDeck;
import org.session.libsession.messaging.threads.recipients.Recipient;
import org.thoughtcrime.securesms.service.IncomingMessageObserver;
import org.thoughtcrime.securesms.service.KeyCachingService;
import org.session.libsession.utilities.ServiceUtil;
import org.thoughtcrime.securesms.util.SpanUtil;
@ -87,6 +86,7 @@ public class DefaultMessageNotifier implements MessageNotifier {
public static final String EXTRA_REMOTE_REPLY = "extra_remote_reply";
private static final int FOREGROUND_ID = 313399;
private static final int SUMMARY_NOTIFICATION_ID = 1338;
private static final int PENDING_MESSAGES_ID = 1111;
private static final String NOTIFICATION_GROUP = "messages";
@ -168,7 +168,7 @@ public class DefaultMessageNotifier implements MessageNotifier {
if (notification.getId() != SUMMARY_NOTIFICATION_ID &&
notification.getId() != KeyCachingService.SERVICE_RUNNING_ID &&
notification.getId() != IncomingMessageObserver.FOREGROUND_ID &&
notification.getId() != FOREGROUND_ID &&
notification.getId() != PENDING_MESSAGES_ID)
{
for (NotificationItem item : notificationState.getNotifications()) {

View File

@ -1,57 +0,0 @@
syntax = "proto2";
package textsecure;
option java_package = "org.session.libsignal.libsignal.protocol";
option java_outer_classname = "SignalProtos";
message SignalMessage {
optional bytes ratchetKey = 1;
optional uint32 counter = 2;
optional uint32 previousCounter = 3;
optional bytes ciphertext = 4;
}
message PreKeySignalMessage {
optional uint32 registrationId = 5;
optional uint32 preKeyId = 1;
optional uint32 signedPreKeyId = 6;
optional bytes baseKey = 2;
optional bytes identityKey = 3;
optional bytes message = 4; // SignalMessage
}
message KeyExchangeMessage {
optional uint32 id = 1;
optional bytes baseKey = 2;
optional bytes ratchetKey = 3;
optional bytes identityKey = 4;
optional bytes baseKeySignature = 5;
}
message SenderKeyMessage {
optional uint32 id = 1;
optional uint32 iteration = 2;
optional bytes ciphertext = 3;
}
message SenderKeyDistributionMessage {
optional uint32 id = 1;
optional uint32 iteration = 2;
optional bytes chainKey = 3;
optional bytes signingKey = 4;
}
message DeviceConsistencyCodeMessage {
optional uint32 generation = 1;
optional bytes signature = 2;
}
message ClosedGroupCiphertextMessage {
// @required
optional bytes ciphertext = 1;
// @required
optional bytes senderPublicKey = 2;
// @required
optional uint32 keyIndex = 3;
}

View File

@ -1,12 +0,0 @@
/**
* Copyright (C) 2014-2016 Open Whisper Systems
*
* Licensed according to the LICENSE file in this repository.
*/
package org.session.libsignal.libsignal;
public class DuplicateMessageException extends Exception {
public DuplicateMessageException(String s) {
super(s);
}
}

View File

@ -1,16 +0,0 @@
/**
* Copyright (C) 2014-2016 Open Whisper Systems
*
* Licensed according to the LICENSE file in this repository.
*/
package org.session.libsignal.libsignal;
public class InvalidKeyIdException extends Exception {
public InvalidKeyIdException(String detailMessage) {
super(detailMessage);
}
public InvalidKeyIdException(Throwable throwable) {
super(throwable);
}
}

View File

@ -1,12 +0,0 @@
/**
* Copyright (C) 2014-2016 Open Whisper Systems
*
* Licensed according to the LICENSE file in this repository.
*/
package org.session.libsignal.libsignal;
public class LegacyMessageException extends Exception {
public LegacyMessageException(String s) {
super(s);
}
}

View File

@ -1,16 +0,0 @@
/**
* Copyright (C) 2014-2016 Open Whisper Systems
*
* Licensed according to the LICENSE file in this repository.
*/
package org.session.libsignal.libsignal;
public class NoSessionException extends Exception {
public NoSessionException(String s) {
super(s);
}
public NoSessionException(Exception nested) {
super(nested);
}
}

View File

@ -1,44 +0,0 @@
/**
* Copyright (C) 2014-2016 Open Whisper Systems
*
* Licensed according to the LICENSE file in this repository.
*/
package org.session.libsignal.libsignal;
public class SignalProtocolAddress {
private final String name;
private final int deviceId;
public SignalProtocolAddress(String name, int deviceId) {
this.name = name;
this.deviceId = deviceId;
}
public String getName() {
return name;
}
public int getDeviceId() {
return deviceId;
}
@Override
public String toString() {
return name + ":" + deviceId;
}
@Override
public boolean equals(Object other) {
if (other == null) return false;
if (!(other instanceof SignalProtocolAddress)) return false;
SignalProtocolAddress that = (SignalProtocolAddress)other;
return this.name.equals(that.name) && this.deviceId == that.deviceId;
}
@Override
public int hashCode() {
return this.name.hashCode() ^ this.deviceId;
}
}

View File

@ -1,9 +0,0 @@
/**
* Copyright (C) 2014-2016 Open Whisper Systems
*
* Licensed according to the LICENSE file in this repository.
*/
package org.session.libsignal.libsignal;
public class StaleKeyExchangeException extends Throwable {
}

View File

@ -1,25 +0,0 @@
/**
* Copyright (C) 2014-2016 Open Whisper Systems
*
* Licensed according to the LICENSE file in this repository.
*/
package org.session.libsignal.libsignal;
public class UntrustedIdentityException extends Exception {
private final String name;
private final IdentityKey key;
public UntrustedIdentityException(String name, IdentityKey key) {
this.name = name;
this.key = key;
}
public IdentityKey getUntrustedIdentity() {
return key;
}
public String getName() {
return name;
}
}

View File

@ -5,9 +5,7 @@
*/
package org.session.libsignal.libsignal.state;
import org.session.libsignal.libsignal.IdentityKey;
import org.session.libsignal.libsignal.IdentityKeyPair;
import org.session.libsignal.libsignal.SignalProtocolAddress;
/**
* Provides an interface to identity information.
@ -15,11 +13,6 @@ import org.session.libsignal.libsignal.SignalProtocolAddress;
* @author Moxie Marlinspike
*/
public interface IdentityKeyStore {
public enum Direction {
SENDING, RECEIVING
}
/**
* Get the local client's identity key pair.
*

View File

@ -1,8 +0,0 @@
package org.session.libsignal.metadata;
public class InvalidMetadataVersionException extends Exception {
public InvalidMetadataVersionException(String s) {
super(s);
}
}

View File

@ -1,8 +0,0 @@
package org.session.libsignal.metadata;
public class ProtocolDuplicateMessageException extends ProtocolException {
public ProtocolDuplicateMessageException(Exception e, String sender, int senderDevice) {
super(e, sender, senderDevice);
}
}

View File

@ -1,10 +0,0 @@
package org.session.libsignal.metadata;
import org.session.libsignal.libsignal.InvalidKeyException;
public class ProtocolInvalidKeyException extends ProtocolException {
public ProtocolInvalidKeyException(InvalidKeyException e, String sender, int senderDevice) {
super(e, sender, senderDevice);
}
}

View File

@ -1,8 +0,0 @@
package org.session.libsignal.metadata;
public class ProtocolInvalidKeyIdException extends ProtocolException {
public ProtocolInvalidKeyIdException(Exception e, String sender, int senderDevice) {
super(e, sender, senderDevice);
}
}

View File

@ -1,10 +0,0 @@
package org.session.libsignal.metadata;
import org.session.libsignal.libsignal.InvalidVersionException;
public class ProtocolInvalidVersionException extends ProtocolException {
public ProtocolInvalidVersionException(InvalidVersionException e, String sender, int senderDevice) {
super(e, sender, senderDevice);
}
}

View File

@ -1,10 +0,0 @@
package org.session.libsignal.metadata;
import org.session.libsignal.libsignal.LegacyMessageException;
public class ProtocolLegacyMessageException extends ProtocolException {
public ProtocolLegacyMessageException(LegacyMessageException e, String sender, int senderDeviceId) {
super(e, sender, senderDeviceId);
}
}

View File

@ -1,10 +0,0 @@
package org.session.libsignal.metadata;
import org.session.libsignal.libsignal.NoSessionException;
public class ProtocolNoSessionException extends ProtocolException {
public ProtocolNoSessionException(NoSessionException e, String sender, int senderDevice) {
super(e, sender, senderDevice);
}
}

View File

@ -1,10 +0,0 @@
package org.session.libsignal.metadata;
import org.session.libsignal.libsignal.UntrustedIdentityException;
public class ProtocolUntrustedIdentityException extends ProtocolException {
public ProtocolUntrustedIdentityException(UntrustedIdentityException e, String sender, int senderDevice) {
super(e, sender, senderDevice);
}
}

View File

@ -1,3 +0,0 @@
package org.session.libsignal.metadata;
public class SelfSendException extends Exception { }

View File

@ -220,17 +220,8 @@ public class SignalServiceMessageSender {
byte[] content = createMessageContent(message, recipients.get(0));
long timestamp = message.getTimestamp();
boolean isClosedGroup = message.group.isPresent() && message.group.get().getGroupType() == SignalServiceGroup.GroupType.SIGNAL;
List<SendMessageResult> results = sendMessage(messageID, recipients, getTargetUnidentifiedAccess(unidentifiedAccess), timestamp, content, false, message.getTTL(), isClosedGroup, message.hasVisibleContent());
boolean needsSyncInResults = false;
for (SendMessageResult result : results) {
if (result.getSuccess() != null && result.getSuccess().isNeedsSync()) {
needsSyncInResults = true;
break;
}
}
return results;
return sendMessage(messageID, recipients, getTargetUnidentifiedAccess(unidentifiedAccess), timestamp, content, false, message.getTTL(), isClosedGroup, message.hasVisibleContent());
}
public void setMessagePipe(SignalServiceMessagePipe pipe, SignalServiceMessagePipe unidentifiedPipe) {