use of org.thoughtcrime.securesms.jobs.MultiDeviceVerifiedUpdateJob in project Signal-Android by WhisperSystems.
the class VerifyDisplayFragment method updateVerifyButton.
private void updateVerifyButton(boolean verified, boolean update) {
currentVerifiedState = verified;
if (verified) {
verifyButton.setText(R.string.verify_display_fragment__clear_verification);
} else {
verifyButton.setText(R.string.verify_display_fragment__mark_as_verified);
}
if (update) {
final RecipientId recipientId = recipient.getId();
final Context context = requireContext().getApplicationContext();
SignalExecutors.BOUNDED.execute(() -> {
try (SignalSessionLock.Lock unused = ReentrantSessionLock.INSTANCE.acquire()) {
if (verified) {
Log.i(TAG, "Saving identity: " + recipientId);
ApplicationDependencies.getProtocolStore().aci().identities().saveIdentityWithoutSideEffects(recipientId, remoteIdentity, IdentityDatabase.VerifiedStatus.VERIFIED, false, System.currentTimeMillis(), true);
} else {
ApplicationDependencies.getProtocolStore().aci().identities().setVerified(recipientId, remoteIdentity, IdentityDatabase.VerifiedStatus.DEFAULT);
}
ApplicationDependencies.getJobManager().add(new MultiDeviceVerifiedUpdateJob(recipientId, remoteIdentity, verified ? IdentityDatabase.VerifiedStatus.VERIFIED : IdentityDatabase.VerifiedStatus.DEFAULT));
StorageSyncHelper.scheduleSyncForDataChange();
IdentityUtil.markIdentityVerified(context, recipient.get(), verified, false);
}
});
}
}
use of org.thoughtcrime.securesms.jobs.MultiDeviceVerifiedUpdateJob in project Signal-Android by WhisperSystems.
the class RecipientIdJobMigrationTest method migrate_multiDeviceVerifiedUpdateJob.
@Test
public void migrate_multiDeviceVerifiedUpdateJob() throws Exception {
JobData testData = new JobData("MultiDeviceVerifiedUpdateJob", "__MULTI_DEVICE_VERIFIED_UPDATE__", new Data.Builder().putString("destination", "+16101234567").putString("identity_key", "abcd").putInt("verified_status", 1).putLong("timestamp", 123).build());
mockRecipientResolve("+16101234567", 1);
RecipientIdJobMigration subject = new RecipientIdJobMigration(mock(Application.class));
JobData converted = subject.migrate(testData);
assertEquals("MultiDeviceVerifiedUpdateJob", converted.getFactoryKey());
assertEquals("__MULTI_DEVICE_VERIFIED_UPDATE__", converted.getQueueKey());
assertEquals("abcd", converted.getData().getString("identity_key"));
assertEquals(1, converted.getData().getInt("verified_status"));
assertEquals(123, converted.getData().getLong("timestamp"));
assertEquals("1", converted.getData().getString("destination"));
new MultiDeviceVerifiedUpdateJob.Factory().create(mock(Job.Parameters.class), converted.getData());
}
use of org.thoughtcrime.securesms.jobs.MultiDeviceVerifiedUpdateJob in project Signal-Android by signalapp.
the class RecipientIdJobMigrationTest method migrate_multiDeviceVerifiedUpdateJob.
@Test
public void migrate_multiDeviceVerifiedUpdateJob() throws Exception {
JobData testData = new JobData("MultiDeviceVerifiedUpdateJob", "__MULTI_DEVICE_VERIFIED_UPDATE__", new Data.Builder().putString("destination", "+16101234567").putString("identity_key", "abcd").putInt("verified_status", 1).putLong("timestamp", 123).build());
mockRecipientResolve("+16101234567", 1);
RecipientIdJobMigration subject = new RecipientIdJobMigration(mock(Application.class));
JobData converted = subject.migrate(testData);
assertEquals("MultiDeviceVerifiedUpdateJob", converted.getFactoryKey());
assertEquals("__MULTI_DEVICE_VERIFIED_UPDATE__", converted.getQueueKey());
assertEquals("abcd", converted.getData().getString("identity_key"));
assertEquals(1, converted.getData().getInt("verified_status"));
assertEquals(123, converted.getData().getLong("timestamp"));
assertEquals("1", converted.getData().getString("destination"));
new MultiDeviceVerifiedUpdateJob.Factory().create(mock(Job.Parameters.class), converted.getData());
}
use of org.thoughtcrime.securesms.jobs.MultiDeviceVerifiedUpdateJob in project Signal-Android by signalapp.
the class VerifyDisplayFragment method updateVerifyButton.
private void updateVerifyButton(boolean verified, boolean update) {
currentVerifiedState = verified;
if (verified) {
verifyButton.setText(R.string.verify_display_fragment__clear_verification);
} else {
verifyButton.setText(R.string.verify_display_fragment__mark_as_verified);
}
if (update) {
final RecipientId recipientId = recipient.getId();
final Context context = requireContext().getApplicationContext();
SignalExecutors.BOUNDED.execute(() -> {
try (SignalSessionLock.Lock unused = ReentrantSessionLock.INSTANCE.acquire()) {
if (verified) {
Log.i(TAG, "Saving identity: " + recipientId);
ApplicationDependencies.getProtocolStore().aci().identities().saveIdentityWithoutSideEffects(recipientId, remoteIdentity, IdentityDatabase.VerifiedStatus.VERIFIED, false, System.currentTimeMillis(), true);
} else {
ApplicationDependencies.getProtocolStore().aci().identities().setVerified(recipientId, remoteIdentity, IdentityDatabase.VerifiedStatus.DEFAULT);
}
ApplicationDependencies.getJobManager().add(new MultiDeviceVerifiedUpdateJob(recipientId, remoteIdentity, verified ? IdentityDatabase.VerifiedStatus.VERIFIED : IdentityDatabase.VerifiedStatus.DEFAULT));
StorageSyncHelper.scheduleSyncForDataChange();
IdentityUtil.markIdentityVerified(context, recipient.get(), verified, false);
}
});
}
}
Aggregations