mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-22 07:57:30 +00:00
WIP
This commit is contained in:
parent
becce74cc8
commit
c8cc22e8fe
@ -5,6 +5,8 @@ import java.security.MessageDigest
|
||||
buildscript {
|
||||
ext.gradle_version = "3.4.1"
|
||||
ext.kotlin_version = "1.3.31"
|
||||
ext.kovenant_version = "3.3.0"
|
||||
|
||||
repositories {
|
||||
google()
|
||||
mavenCentral()
|
||||
@ -180,6 +182,7 @@ dependencies {
|
||||
testImplementation 'org.robolectric:robolectric:4.2'
|
||||
testImplementation 'org.robolectric:shadows-multidex:4.2'
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
|
||||
implementation "nl.komponents.kovenant:kovenant:$kovenant_version"
|
||||
}
|
||||
|
||||
android {
|
||||
|
@ -29,6 +29,7 @@ import android.support.multidex.MultiDexApplication;
|
||||
import com.google.android.gms.security.ProviderInstaller;
|
||||
|
||||
import org.conscrypt.Conscrypt;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.signal.aesgcmprovider.AesGcmProvider;
|
||||
import org.thoughtcrime.securesms.components.TypingStatusRepository;
|
||||
import org.thoughtcrime.securesms.components.TypingStatusSender;
|
||||
@ -69,6 +70,8 @@ import org.webrtc.PeerConnectionFactory.InitializationOptions;
|
||||
import org.webrtc.voiceengine.WebRtcAudioManager;
|
||||
import org.webrtc.voiceengine.WebRtcAudioUtils;
|
||||
import org.whispersystems.libsignal.logging.SignalProtocolLoggerProvider;
|
||||
import org.whispersystems.signalservice.loki.api.LokiP2PAPI;
|
||||
import org.whispersystems.signalservice.loki.api.LokiP2PAPIDelegate;
|
||||
|
||||
import java.security.Security;
|
||||
import java.util.HashSet;
|
||||
@ -76,6 +79,7 @@ import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import dagger.ObjectGraph;
|
||||
import kotlin.jvm.functions.Function2;
|
||||
|
||||
/**
|
||||
* Will be called once when the TextSecure process is created.
|
||||
@ -85,7 +89,7 @@ import dagger.ObjectGraph;
|
||||
*
|
||||
* @author Moxie Marlinspike
|
||||
*/
|
||||
public class ApplicationContext extends MultiDexApplication implements DependencyInjector, DefaultLifecycleObserver {
|
||||
public class ApplicationContext extends MultiDexApplication implements DependencyInjector, DefaultLifecycleObserver, LokiP2PAPIDelegate {
|
||||
|
||||
private static final String TAG = ApplicationContext.class.getSimpleName();
|
||||
|
||||
@ -126,6 +130,17 @@ public class ApplicationContext extends MultiDexApplication implements Dependenc
|
||||
initializeBlobProvider();
|
||||
NotificationChannels.create(this);
|
||||
ProcessLifecycleOwner.get().getLifecycle().addObserver(this);
|
||||
|
||||
String hexEncodedPublicKey = TextSecurePreferences.getLocalNumber(this);
|
||||
if (hexEncodedPublicKey != null) {
|
||||
LokiP2PAPI.Companion.configure(hexEncodedPublicKey, new Function2<Boolean, String, Void>() {
|
||||
|
||||
@Override
|
||||
public Void invoke(Boolean aBoolean, String s) {
|
||||
return null;
|
||||
}
|
||||
}, this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -356,4 +371,9 @@ public class ApplicationContext extends MultiDexApplication implements Dependenc
|
||||
|
||||
private static class ProviderInitializationException extends RuntimeException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void ping(@NotNull String s) {
|
||||
// TODO: Implement
|
||||
}
|
||||
}
|
||||
|
@ -19,7 +19,6 @@ package org.thoughtcrime.securesms;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.MenuItem;
|
||||
import android.widget.Toast;
|
||||
|
||||
import org.thoughtcrime.securesms.conversation.ConversationActivity;
|
||||
import org.thoughtcrime.securesms.database.Address;
|
||||
@ -50,10 +49,10 @@ public class NewConversationActivity extends ContactSelectionActivity {
|
||||
public void onContactSelected(String number) {
|
||||
boolean isValid = PublicKeyValidation.isValid(number);
|
||||
|
||||
if (!isValid) {
|
||||
Toast.makeText(this, R.string.activity_new_conversation_invalid_public_key_message, Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
}
|
||||
// if (!isValid) {
|
||||
// Toast.makeText(this, R.string.activity_new_conversation_invalid_public_key_message, Toast.LENGTH_SHORT).show();
|
||||
// return;
|
||||
// }
|
||||
|
||||
Recipient recipient = Recipient.from(this, Address.fromSerialized(number), true);
|
||||
|
||||
|
@ -31,6 +31,7 @@ import org.thoughtcrime.securesms.crypto.MasterSecret;
|
||||
import org.thoughtcrime.securesms.database.helpers.ClassicOpenHelper;
|
||||
import org.thoughtcrime.securesms.database.helpers.SQLCipherMigrationHelper;
|
||||
import org.thoughtcrime.securesms.database.helpers.SQLCipherOpenHelper;
|
||||
import org.thoughtcrime.securesms.loki.LokiAPIDatabase;
|
||||
import org.thoughtcrime.securesms.loki.LokiContactPreKeyDatabase;
|
||||
import org.thoughtcrime.securesms.loki.LokiPreKeyBundleDatabase;
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||
@ -62,6 +63,7 @@ public class DatabaseFactory {
|
||||
private final JobDatabase jobDatabase;
|
||||
|
||||
// Loki
|
||||
private final LokiAPIDatabase lokiAPIDatabase;
|
||||
private final LokiContactPreKeyDatabase lokiContactPreKeyDatabase;
|
||||
private final LokiPreKeyBundleDatabase lokiPreKeyBundleDatabase;
|
||||
|
||||
@ -151,6 +153,10 @@ public class DatabaseFactory {
|
||||
}
|
||||
|
||||
// region Loki
|
||||
public static LokiAPIDatabase getLokiAPIDatabase(Context context) {
|
||||
return getInstance(context).lokiAPIDatabase;
|
||||
}
|
||||
|
||||
public static LokiContactPreKeyDatabase getLokiContactPreKeyDatabase(Context context) {
|
||||
return getInstance(context).lokiContactPreKeyDatabase;
|
||||
}
|
||||
@ -191,6 +197,7 @@ public class DatabaseFactory {
|
||||
this.searchDatabase = new SearchDatabase(context, databaseHelper);
|
||||
this.jobDatabase = new JobDatabase(context, databaseHelper);
|
||||
|
||||
this.lokiAPIDatabase = new LokiAPIDatabase(TextSecurePreferences.getLocalNumber(context), context, databaseHelper);
|
||||
this.lokiContactPreKeyDatabase = new LokiContactPreKeyDatabase(context, databaseHelper);
|
||||
this.lokiPreKeyBundleDatabase = new LokiPreKeyBundleDatabase(context, databaseHelper);
|
||||
}
|
||||
|
@ -870,7 +870,7 @@ public class SmsDatabase extends MessagingDatabase {
|
||||
long expireStarted = cursor.getLong(cursor.getColumnIndexOrThrow(SmsDatabase.EXPIRE_STARTED));
|
||||
String body = cursor.getString(cursor.getColumnIndexOrThrow(SmsDatabase.BODY));
|
||||
boolean unidentified = cursor.getInt(cursor.getColumnIndexOrThrow(SmsDatabase.UNIDENTIFIED)) == 1;
|
||||
boolean isFriendRequest = cursor.getInt(cursor.getColumnIndexOrThrow(SmsDatabase.IS_FRIEND_REQUEST)) == 1;
|
||||
boolean isFriendRequest = true;//= cursor.getInt(cursor.getColumnIndexOrThrow(SmsDatabase.IS_FRIEND_REQUEST)) == 1;
|
||||
|
||||
if (!TextSecurePreferences.isReadReceiptsEnabled(context)) {
|
||||
readReceiptCount = 0;
|
||||
|
@ -2,14 +2,13 @@ package org.thoughtcrime.securesms.jobs;
|
||||
|
||||
import android.support.annotation.NonNull;
|
||||
|
||||
import org.thoughtcrime.securesms.database.MessagingDatabase.SyncMessageId;
|
||||
import org.thoughtcrime.securesms.database.RecipientDatabase.UnidentifiedAccessMode;
|
||||
|
||||
import org.thoughtcrime.securesms.ApplicationContext;
|
||||
import org.thoughtcrime.securesms.crypto.UnidentifiedAccessUtil;
|
||||
import org.thoughtcrime.securesms.database.Address;
|
||||
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
||||
import org.thoughtcrime.securesms.database.MessagingDatabase.SyncMessageId;
|
||||
import org.thoughtcrime.securesms.database.NoSuchMessageException;
|
||||
import org.thoughtcrime.securesms.database.RecipientDatabase.UnidentifiedAccessMode;
|
||||
import org.thoughtcrime.securesms.database.SmsDatabase;
|
||||
import org.thoughtcrime.securesms.database.model.SmsMessageRecord;
|
||||
import org.thoughtcrime.securesms.dependencies.InjectableType;
|
||||
@ -30,11 +29,16 @@ import org.whispersystems.signalservice.api.messages.SignalServiceDataMessage;
|
||||
import org.whispersystems.signalservice.api.messages.multidevice.SignalServiceSyncMessage;
|
||||
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
||||
import org.whispersystems.signalservice.api.push.exceptions.UnregisteredUserException;
|
||||
import org.whispersystems.signalservice.internal.push.SignalServiceProtos;
|
||||
import org.whispersystems.signalservice.loki.api.LokiAPI;
|
||||
import org.whispersystems.signalservice.loki.messaging.SignalMessageInfo;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import kotlin.Unit;
|
||||
|
||||
public class PushTextSendJob extends PushSendJob implements InjectableType {
|
||||
|
||||
public static final String KEY = "PushTextSendJob";
|
||||
@ -90,6 +94,11 @@ public class PushTextSendJob extends PushSendJob implements InjectableType {
|
||||
byte[] profileKey = recipient.getProfileKey();
|
||||
UnidentifiedAccessMode accessMode = recipient.getUnidentifiedAccessMode();
|
||||
|
||||
String hexEncodedPublicKey = TextSecurePreferences.getLocalNumber(context);
|
||||
SignalMessageInfo message = new SignalMessageInfo(SignalServiceProtos.Envelope.Type.FRIEND_REQUEST, System.currentTimeMillis(), hexEncodedPublicKey, 0, "stub", recipient.getAddress().serialize(), 4 * 24 * 60 * 60 * 1000, false);
|
||||
LokiAPI api = new LokiAPI(hexEncodedPublicKey, DatabaseFactory.getLokiAPIDatabase(context));
|
||||
api.sendSignalMessage(message, () -> Unit.INSTANCE);
|
||||
|
||||
boolean unidentified = deliver(record);
|
||||
|
||||
database.markAsSent(messageId, true);
|
||||
|
@ -183,15 +183,19 @@ public class MessageSender {
|
||||
}
|
||||
|
||||
private static boolean isPushTextSend(Context context, Recipient recipient, boolean keyExchange) {
|
||||
if (!TextSecurePreferences.isPushRegistered(context)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (keyExchange) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return isPushDestination(context, recipient);
|
||||
return true;
|
||||
// Loki - Original code
|
||||
// ========
|
||||
// if (!TextSecurePreferences.isPushRegistered(context)) {
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// if (keyExchange) {
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// return isPushDestination(context, recipient);
|
||||
// ========
|
||||
}
|
||||
|
||||
private static boolean isPushMediaSend(Context context, Recipient recipient) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user