take btbv setting into account when deciding default trust

This commit is contained in:
Daniel Gultsch 2023-03-01 09:19:48 +01:00
parent 1a924d3efd
commit 303f14200f
No known key found for this signature in database
GPG key ID: F43D18AD2A0982C2
6 changed files with 30 additions and 9 deletions

View file

@ -55,7 +55,8 @@ public class MessageTransformationTest {
final long id = database.accountDao().insert(account);
this.transformer =
new Transformer(database.accountDao().getEnabledAccount(id).get(), database);
new Transformer(
database.accountDao().getEnabledAccount(id).get(), context, database);
}
@Test

View file

@ -36,7 +36,7 @@ public class AppSettings {
.apply();
}
public boolean isBtbv() {
public boolean isBTBVEnabled() {
final SharedPreferences sharedPreferences =
PreferenceManager.getDefaultSharedPreferences(context);
return sharedPreferences.getBoolean(

View file

@ -1,5 +1,6 @@
package im.conversations.android.axolotl;
import android.content.Context;
import android.os.Build;
import com.google.common.base.Optional;
import com.google.common.collect.ArrayListMultimap;
@ -62,9 +63,12 @@ public class AxolotlService extends AbstractAccountService {
private final Multimap<BareJid, Integer> devicesNotInPep = ArrayListMultimap.create();
public AxolotlService(
final Account account, final ConversationsDatabase conversationsDatabase) {
final Account account,
final Context context,
final ConversationsDatabase conversationsDatabase) {
super(account, conversationsDatabase);
this.signalProtocolStore = new AxolotlDatabaseStore(account, conversationsDatabase);
this.signalProtocolStore =
new AxolotlDatabaseStore(account, context, conversationsDatabase);
}
public void setPostDecryptionHook(final PostDecryptionHook postDecryptionHook) {

View file

@ -1,6 +1,8 @@
package im.conversations.android.database;
import android.content.Context;
import im.conversations.android.AbstractAccountService;
import im.conversations.android.AppSettings;
import im.conversations.android.axolotl.AxolotlAddress;
import im.conversations.android.database.dao.AxolotlDao;
import im.conversations.android.database.model.Account;
@ -17,9 +19,14 @@ import org.whispersystems.libsignal.state.SignedPreKeyRecord;
public class AxolotlDatabaseStore extends AbstractAccountService implements SignalProtocolStore {
private AppSettings appSettings;
public AxolotlDatabaseStore(
final Account account, final ConversationsDatabase conversationsDatabase) {
final Account account,
final Context context,
final ConversationsDatabase conversationsDatabase) {
super(account, conversationsDatabase);
this.appSettings = new AppSettings(context);
}
private AxolotlDao axolotlDao() {
@ -40,7 +47,7 @@ public class AxolotlDatabaseStore extends AbstractAccountService implements Sign
public boolean saveIdentity(
final SignalProtocolAddress signalProtocolAddress, final IdentityKey identityKey) {
final var address = AxolotlAddress.cast(signalProtocolAddress);
final boolean isBTBVEnabled = true;
final boolean isBTBVEnabled = appSettings.isBTBVEnabled();
return database.runInTransaction(
() -> {
final Trust trust;

View file

@ -1,5 +1,6 @@
package im.conversations.android.transformer;
import android.content.Context;
import com.google.common.base.Preconditions;
import im.conversations.android.axolotl.AxolotlDecryptionException;
import im.conversations.android.axolotl.AxolotlService;
@ -32,8 +33,14 @@ public class Transformer {
private final AxolotlService axolotlService;
public Transformer(final Account account, final ConversationsDatabase conversationsDatabase) {
this(account, conversationsDatabase, new AxolotlService(account, conversationsDatabase));
public Transformer(
final Account account,
final Context context,
final ConversationsDatabase conversationsDatabase) {
this(
account,
conversationsDatabase,
new AxolotlService(account, context, conversationsDatabase));
}
public Transformer(

View file

@ -67,7 +67,9 @@ public class AxolotlManager extends AbstractManager implements AxolotlService.Po
super(context, connection);
this.axolotlService =
new AxolotlService(
connection.getAccount(), ConversationsDatabase.getInstance(context));
connection.getAccount(),
context,
ConversationsDatabase.getInstance(context));
this.axolotlService.setPostDecryptionHook(this);
}