take btbv setting into account when deciding default trust
This commit is contained in:
parent
1a924d3efd
commit
303f14200f
|
@ -55,7 +55,8 @@ public class MessageTransformationTest {
|
||||||
final long id = database.accountDao().insert(account);
|
final long id = database.accountDao().insert(account);
|
||||||
|
|
||||||
this.transformer =
|
this.transformer =
|
||||||
new Transformer(database.accountDao().getEnabledAccount(id).get(), database);
|
new Transformer(
|
||||||
|
database.accountDao().getEnabledAccount(id).get(), context, database);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -36,7 +36,7 @@ public class AppSettings {
|
||||||
.apply();
|
.apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isBtbv() {
|
public boolean isBTBVEnabled() {
|
||||||
final SharedPreferences sharedPreferences =
|
final SharedPreferences sharedPreferences =
|
||||||
PreferenceManager.getDefaultSharedPreferences(context);
|
PreferenceManager.getDefaultSharedPreferences(context);
|
||||||
return sharedPreferences.getBoolean(
|
return sharedPreferences.getBoolean(
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package im.conversations.android.axolotl;
|
package im.conversations.android.axolotl;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import com.google.common.base.Optional;
|
import com.google.common.base.Optional;
|
||||||
import com.google.common.collect.ArrayListMultimap;
|
import com.google.common.collect.ArrayListMultimap;
|
||||||
|
@ -62,9 +63,12 @@ public class AxolotlService extends AbstractAccountService {
|
||||||
private final Multimap<BareJid, Integer> devicesNotInPep = ArrayListMultimap.create();
|
private final Multimap<BareJid, Integer> devicesNotInPep = ArrayListMultimap.create();
|
||||||
|
|
||||||
public AxolotlService(
|
public AxolotlService(
|
||||||
final Account account, final ConversationsDatabase conversationsDatabase) {
|
final Account account,
|
||||||
|
final Context context,
|
||||||
|
final ConversationsDatabase conversationsDatabase) {
|
||||||
super(account, conversationsDatabase);
|
super(account, conversationsDatabase);
|
||||||
this.signalProtocolStore = new AxolotlDatabaseStore(account, conversationsDatabase);
|
this.signalProtocolStore =
|
||||||
|
new AxolotlDatabaseStore(account, context, conversationsDatabase);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPostDecryptionHook(final PostDecryptionHook postDecryptionHook) {
|
public void setPostDecryptionHook(final PostDecryptionHook postDecryptionHook) {
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
package im.conversations.android.database;
|
package im.conversations.android.database;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
import im.conversations.android.AbstractAccountService;
|
import im.conversations.android.AbstractAccountService;
|
||||||
|
import im.conversations.android.AppSettings;
|
||||||
import im.conversations.android.axolotl.AxolotlAddress;
|
import im.conversations.android.axolotl.AxolotlAddress;
|
||||||
import im.conversations.android.database.dao.AxolotlDao;
|
import im.conversations.android.database.dao.AxolotlDao;
|
||||||
import im.conversations.android.database.model.Account;
|
import im.conversations.android.database.model.Account;
|
||||||
|
@ -17,9 +19,14 @@ import org.whispersystems.libsignal.state.SignedPreKeyRecord;
|
||||||
|
|
||||||
public class AxolotlDatabaseStore extends AbstractAccountService implements SignalProtocolStore {
|
public class AxolotlDatabaseStore extends AbstractAccountService implements SignalProtocolStore {
|
||||||
|
|
||||||
|
private AppSettings appSettings;
|
||||||
|
|
||||||
public AxolotlDatabaseStore(
|
public AxolotlDatabaseStore(
|
||||||
final Account account, final ConversationsDatabase conversationsDatabase) {
|
final Account account,
|
||||||
|
final Context context,
|
||||||
|
final ConversationsDatabase conversationsDatabase) {
|
||||||
super(account, conversationsDatabase);
|
super(account, conversationsDatabase);
|
||||||
|
this.appSettings = new AppSettings(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
private AxolotlDao axolotlDao() {
|
private AxolotlDao axolotlDao() {
|
||||||
|
@ -40,7 +47,7 @@ public class AxolotlDatabaseStore extends AbstractAccountService implements Sign
|
||||||
public boolean saveIdentity(
|
public boolean saveIdentity(
|
||||||
final SignalProtocolAddress signalProtocolAddress, final IdentityKey identityKey) {
|
final SignalProtocolAddress signalProtocolAddress, final IdentityKey identityKey) {
|
||||||
final var address = AxolotlAddress.cast(signalProtocolAddress);
|
final var address = AxolotlAddress.cast(signalProtocolAddress);
|
||||||
final boolean isBTBVEnabled = true;
|
final boolean isBTBVEnabled = appSettings.isBTBVEnabled();
|
||||||
return database.runInTransaction(
|
return database.runInTransaction(
|
||||||
() -> {
|
() -> {
|
||||||
final Trust trust;
|
final Trust trust;
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package im.conversations.android.transformer;
|
package im.conversations.android.transformer;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
import com.google.common.base.Preconditions;
|
import com.google.common.base.Preconditions;
|
||||||
import im.conversations.android.axolotl.AxolotlDecryptionException;
|
import im.conversations.android.axolotl.AxolotlDecryptionException;
|
||||||
import im.conversations.android.axolotl.AxolotlService;
|
import im.conversations.android.axolotl.AxolotlService;
|
||||||
|
@ -32,8 +33,14 @@ public class Transformer {
|
||||||
|
|
||||||
private final AxolotlService axolotlService;
|
private final AxolotlService axolotlService;
|
||||||
|
|
||||||
public Transformer(final Account account, final ConversationsDatabase conversationsDatabase) {
|
public Transformer(
|
||||||
this(account, conversationsDatabase, new AxolotlService(account, conversationsDatabase));
|
final Account account,
|
||||||
|
final Context context,
|
||||||
|
final ConversationsDatabase conversationsDatabase) {
|
||||||
|
this(
|
||||||
|
account,
|
||||||
|
conversationsDatabase,
|
||||||
|
new AxolotlService(account, context, conversationsDatabase));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Transformer(
|
public Transformer(
|
||||||
|
|
|
@ -67,7 +67,9 @@ public class AxolotlManager extends AbstractManager implements AxolotlService.Po
|
||||||
super(context, connection);
|
super(context, connection);
|
||||||
this.axolotlService =
|
this.axolotlService =
|
||||||
new AxolotlService(
|
new AxolotlService(
|
||||||
connection.getAccount(), ConversationsDatabase.getInstance(context));
|
connection.getAccount(),
|
||||||
|
context,
|
||||||
|
ConversationsDatabase.getInstance(context));
|
||||||
this.axolotlService.setPostDecryptionHook(this);
|
this.axolotlService.setPostDecryptionHook(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue