Skip to content

Commit

Permalink
code review
Browse files Browse the repository at this point in the history
  • Loading branch information
BillCarsonFr committed May 12, 2022
1 parent 5a323db commit 8077406
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ class CryptoTestHelper(private val testHelper: CommonTestHelper) {
return cryptoTestData
}

private fun ensureEventReceived(roomId: String, eventId: String, session: Session, andCanDecrypt : Boolean) {
private fun ensureEventReceived(roomId: String, eventId: String, session: Session, andCanDecrypt: Boolean) {
testHelper.waitWithLatch { latch ->
testHelper.retryPeriodicallyWithLatch(latch) {
val timeLineEvent = session.getRoom(roomId)?.timelineService()?.getTimelineEvent(eventId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import org.junit.Assert.assertNotNull
import org.junit.Assert.assertNull
import org.junit.Assert.assertTrue
import org.junit.FixMethodOrder
import org.junit.Ignore
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.MethodSorters
Expand Down Expand Up @@ -63,7 +62,6 @@ class KeysBackupTest : InstrumentedTest {
*/
@Test
fun roomKeysTest_testBackupStore_ok() {

val testHelper = CommonTestHelper(context())
val cryptoTestHelper = CryptoTestHelper(testHelper)

Expand Down Expand Up @@ -105,7 +103,6 @@ class KeysBackupTest : InstrumentedTest {
*/
@Test
fun prepareKeysBackupVersionTest() {

val testHelper = CommonTestHelper(context())
val cryptoTestHelper = CryptoTestHelper(testHelper)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ internal class KeysBackupTestHelper(
keysBackup.createKeysBackupVersion(megolmBackupCreationInfo, it)
}

Assert.assertNotNull("Key backup version should not be null",keysVersion.version)
Assert.assertNotNull("Key backup version should not be null", keysVersion.version)

// Backup must be enable now
Assert.assertTrue(keysBackup.isEnabled)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2020 The Matrix.org Foundation C.I.C.
* Copyright 2022 The Matrix.org Foundation C.I.C.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,6 @@ internal class DefaultKeysBackupService @Inject constructor(

override fun backupAllGroupSessions(progressListener: ProgressListener?,
callback: MatrixCallback<Unit>?) {

if (!isEnabled || backupOlmPkEncryption == null || keysBackupVersion == null) {
callback?.onFailure(Throwable("Backup not enabled"))
return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,8 @@ class KeysBackupManageActivity : SimpleFragmentActivity() {
is KeysBackupViewEvents.RequestStore4SSecret -> {
secretStartForActivityResult.launch(
SharedSecureStorageActivity.newWriteIntent(
this,
null, // default key
listOf(KEYBACKUP_SECRET_SSSS_NAME to it.recoveryKey)
context = this,
writeSecrets = listOf(KEYBACKUP_SECRET_SSSS_NAME to it.recoveryKey)
)
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,14 +156,20 @@ class KeysBackupSettingsViewModel @AssistedInject constructor(@Assisted initialS

suspend fun completeBackupCreation() {
val info = pendingBackupCreationInfo ?: return
val version = awaitCallback<KeysVersion> {
session.cryptoService().keysBackupService().createKeysBackupVersion(info, it)
try {
val version = awaitCallback<KeysVersion> {
session.cryptoService().keysBackupService().createKeysBackupVersion(info, it)
}
// Save it for gossiping
Timber.d("## BootstrapCrossSigningTask: Creating 4S - Save megolm backup key for gossiping")
session.cryptoService().keysBackupService().saveBackupRecoveryKey(info.recoveryKey, version = version.version)
} catch (failure: Throwable) {
// XXX mm... failed we should remove what we put in 4S, as it was not created?

// for now just stay on the screen, user can retry, there is no api to delete account data
} finally {
pendingBackupCreationInfo = null
}
// Save it for gossiping
Timber.d("## BootstrapCrossSigningTask: Creating 4S - Save megolm backup key for gossiping")
session.cryptoService().keysBackupService().saveBackupRecoveryKey(info.recoveryKey, version = version.version)

// TODO catch, delete 4S account data
}

private fun deleteCurrentBackup() {
Expand Down

0 comments on commit 8077406

Please sign in to comment.