From 4c31e52892d162f6c5e232ab5cff7a033c63b5b0 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Tue, 12 May 2020 11:36:43 +0200 Subject: [PATCH] Add facilities and Javadoc on SessionParams data class --- .../matrix/android/common/CryptoTestHelper.kt | 2 +- .../crypto/crosssigning/XSigningTest.kt | 2 +- .../crypto/gossiping/KeyShareTests.kt | 6 +-- .../crypto/keysbackup/KeysBackupTest.kt | 4 +- .../internal/crypto/verification/SASTest.kt | 4 +- .../android/api/auth/AuthenticationService.kt | 15 +++---- .../android/api/auth/data/SessionParams.kt | 43 ++++++++++++++++++- .../matrix/android/api/session/Session.kt | 2 +- .../auth/DefaultAuthenticationService.kt | 13 ++++-- .../internal/auth/db/SessionParamsMapper.kt | 2 +- ...tgoingSASDefaultVerificationTransaction.kt | 2 +- .../internal/session/DefaultSession.kt | 2 +- .../session/signout/SignInAgainTask.kt | 4 +- .../riotx/core/platform/VectorBaseActivity.kt | 3 +- .../riotx/core/pushers/PushersManager.kt | 2 +- ...eysBackupSettingsRecyclerViewController.kt | 2 +- .../VerificationBottomSheetViewModel.kt | 2 +- .../UnknownDeviceDetectorSharedViewModel.kt | 7 +-- .../riotx/features/rageshake/BugReporter.kt | 2 +- .../settings/VectorSettingsGeneralFragment.kt | 2 +- .../settings/VectorSettingsLabsFragment.kt | 2 +- .../VectorSettingsSecurityPrivacyFragment.kt | 2 +- ...iceVerificationInfoBottomSheetViewModel.kt | 2 +- .../settings/devices/DevicesViewModel.kt | 2 +- .../signout/soft/SoftLogoutViewModel.kt | 8 ++-- 25 files changed, 89 insertions(+), 48 deletions(-) diff --git a/matrix-sdk-android/src/androidTest/java/im/vector/matrix/android/common/CryptoTestHelper.kt b/matrix-sdk-android/src/androidTest/java/im/vector/matrix/android/common/CryptoTestHelper.kt index 9278bed918..f9aef3604a 100644 --- a/matrix-sdk-android/src/androidTest/java/im/vector/matrix/android/common/CryptoTestHelper.kt +++ b/matrix-sdk-android/src/androidTest/java/im/vector/matrix/android/common/CryptoTestHelper.kt @@ -246,7 +246,7 @@ class CryptoTestHelper(private val mTestHelper: CommonTestHelper) { assertNotNull(eventWireContent.get("session_id")) assertNotNull(eventWireContent.get("sender_key")) - assertEquals(senderSession.sessionParams.credentials.deviceId, eventWireContent.get("device_id")) + assertEquals(senderSession.sessionParams.deviceId, eventWireContent.get("device_id")) assertNotNull(event.eventId) assertEquals(roomId, event.roomId) diff --git a/matrix-sdk-android/src/androidTest/java/im/vector/matrix/android/internal/crypto/crosssigning/XSigningTest.kt b/matrix-sdk-android/src/androidTest/java/im/vector/matrix/android/internal/crypto/crosssigning/XSigningTest.kt index f8d30a2679..da3bbdc23c 100644 --- a/matrix-sdk-android/src/androidTest/java/im/vector/matrix/android/internal/crypto/crosssigning/XSigningTest.kt +++ b/matrix-sdk-android/src/androidTest/java/im/vector/matrix/android/internal/crypto/crosssigning/XSigningTest.kt @@ -122,7 +122,7 @@ class XSigningTest : InstrumentedTest { // We will want to test that in alice POV, this new device would be trusted by cross signing val bobSession2 = mTestHelper.logIntoAccount(bobUserId, SessionTestParams(true)) - val bobSecondDeviceId = bobSession2.sessionParams.credentials.deviceId!! + val bobSecondDeviceId = bobSession2.sessionParams.deviceId!! // Check that bob first session sees the new login val data = mTestHelper.doSync> { diff --git a/matrix-sdk-android/src/androidTest/java/im/vector/matrix/android/internal/crypto/gossiping/KeyShareTests.kt b/matrix-sdk-android/src/androidTest/java/im/vector/matrix/android/internal/crypto/gossiping/KeyShareTests.kt index bb6e020d89..57ab4aaf33 100644 --- a/matrix-sdk-android/src/androidTest/java/im/vector/matrix/android/internal/crypto/gossiping/KeyShareTests.kt +++ b/matrix-sdk-android/src/androidTest/java/im/vector/matrix/android/internal/crypto/gossiping/KeyShareTests.kt @@ -148,7 +148,7 @@ class KeyShareTests : InstrumentedTest { // Mark the device as trusted aliceSession.cryptoService().setDeviceVerification(DeviceTrustLevel(crossSigningVerified = false, locallyVerified = true), aliceSession.myUserId, - aliceSession2.sessionParams.credentials.deviceId ?: "") + aliceSession2.sessionParams.deviceId ?: "") // Re request aliceSession2.cryptoService().reRequestRoomKeyForEvent(receivedEvent.root) @@ -253,12 +253,12 @@ class KeyShareTests : InstrumentedTest { }) val txId: String = "m.testVerif12" - aliceVerificationService2.beginKeyVerification(VerificationMethod.SAS, aliceSession1.myUserId, aliceSession1.sessionParams.credentials.deviceId + aliceVerificationService2.beginKeyVerification(VerificationMethod.SAS, aliceSession1.myUserId, aliceSession1.sessionParams.deviceId ?: "", txId) mTestHelper.waitWithLatch { latch -> mTestHelper.retryPeriodicallyWithLatch(latch) { - aliceSession1.cryptoService().getDeviceInfo(aliceSession1.myUserId, aliceSession2.sessionParams.credentials.deviceId ?: "")?.isVerified == true + aliceSession1.cryptoService().getDeviceInfo(aliceSession1.myUserId, aliceSession2.sessionParams.deviceId ?: "")?.isVerified == true } } diff --git a/matrix-sdk-android/src/androidTest/java/im/vector/matrix/android/internal/crypto/keysbackup/KeysBackupTest.kt b/matrix-sdk-android/src/androidTest/java/im/vector/matrix/android/internal/crypto/keysbackup/KeysBackupTest.kt index 59ef24beec..2e698a929e 100644 --- a/matrix-sdk-android/src/androidTest/java/im/vector/matrix/android/internal/crypto/keysbackup/KeysBackupTest.kt +++ b/matrix-sdk-android/src/androidTest/java/im/vector/matrix/android/internal/crypto/keysbackup/KeysBackupTest.kt @@ -835,7 +835,7 @@ class KeysBackupTest : InstrumentedTest { assertTrue(signature.valid) assertNotNull(signature.device) assertEquals(cryptoTestData.firstSession.cryptoService().getMyDevice().deviceId, signature.deviceId) - assertEquals(signature.device!!.deviceId, cryptoTestData.firstSession.sessionParams.credentials.deviceId) + assertEquals(signature.device!!.deviceId, cryptoTestData.firstSession.sessionParams.deviceId) stateObserver.stopAndCheckStates(null) cryptoTestData.cleanUp(mTestHelper) @@ -997,7 +997,7 @@ class KeysBackupTest : InstrumentedTest { keysBackup.backupAllGroupSessions(null, it) } - val oldDeviceId = cryptoTestData.firstSession.sessionParams.credentials.deviceId!! + val oldDeviceId = cryptoTestData.firstSession.sessionParams.deviceId!! val oldKeyBackupVersion = keysBackup.currentBackupVersion val aliceUserId = cryptoTestData.firstSession.myUserId diff --git a/matrix-sdk-android/src/androidTest/java/im/vector/matrix/android/internal/crypto/verification/SASTest.kt b/matrix-sdk-android/src/androidTest/java/im/vector/matrix/android/internal/crypto/verification/SASTest.kt index 1ac70d7f2b..9bdd8f1131 100644 --- a/matrix-sdk-android/src/androidTest/java/im/vector/matrix/android/internal/crypto/verification/SASTest.kt +++ b/matrix-sdk-android/src/androidTest/java/im/vector/matrix/android/internal/crypto/verification/SASTest.kt @@ -579,7 +579,7 @@ class SASTest : InstrumentedTest { requestID!!, cryptoTestData.roomId, bobSession.myUserId, - bobSession.sessionParams.credentials.deviceId!!, + bobSession.sessionParams.deviceId!!, null) bobVerificationService.beginKeyVerificationInDMs( @@ -587,7 +587,7 @@ class SASTest : InstrumentedTest { requestID!!, cryptoTestData.roomId, aliceSession.myUserId, - aliceSession.sessionParams.credentials.deviceId!!, + aliceSession.sessionParams.deviceId!!, null) // we should reach SHOW SAS on both diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/auth/AuthenticationService.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/auth/AuthenticationService.kt index 5150420de2..effeae596a 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/auth/AuthenticationService.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/auth/AuthenticationService.kt @@ -20,7 +20,6 @@ import im.vector.matrix.android.api.MatrixCallback import im.vector.matrix.android.api.auth.data.Credentials import im.vector.matrix.android.api.auth.data.HomeServerConnectionConfig import im.vector.matrix.android.api.auth.data.LoginFlowResult -import im.vector.matrix.android.api.auth.data.SessionParams import im.vector.matrix.android.api.auth.login.LoginWizard import im.vector.matrix.android.api.auth.registration.RegistrationWizard import im.vector.matrix.android.api.auth.wellknown.WellknownResult @@ -37,6 +36,11 @@ interface AuthenticationService { */ fun getLoginFlow(homeServerConnectionConfig: HomeServerConnectionConfig, callback: MatrixCallback): Cancelable + /** + * Request the supported login flows for the corresponding sessionId. + */ + fun getLoginFlowOfSession(sessionId: String, callback: MatrixCallback): Cancelable + /** * Return a LoginWizard, to login to the homeserver. The login flow has to be retrieved first. */ @@ -74,15 +78,6 @@ interface AuthenticationService { */ fun getLastAuthenticatedSession(): Session? - /** - * Get an authenticated session. You should at least call authenticate one time before. - * If you logout, this session will no longer be valid. - * - * @param sessionParams the sessionParams to open with. - * @return the associated session if any, or null - */ - fun getSession(sessionParams: SessionParams): Session? - /** * Create a session after a SSO successful login */ diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/auth/data/SessionParams.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/auth/data/SessionParams.kt index 2d65cac43d..1cbba50af7 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/auth/data/SessionParams.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/auth/data/SessionParams.kt @@ -21,7 +21,48 @@ package im.vector.matrix.android.api.auth.data * You don't have to manually instantiate it. */ data class SessionParams( + /** + * Please consider using shortcuts instead + */ val credentials: Credentials, + + /** + * Please consider using shortcuts instead + */ val homeServerConnectionConfig: HomeServerConnectionConfig, + + /** + * Set to false if the current token is not valid anymore. Application should not have to use this info. + */ val isTokenValid: Boolean -) +) { + /* + * Shortcuts. Usually the application should only need to use these shortcuts + */ + + /** + * The userId of the session (Ex: "@user:domain.org") + */ + val userId = credentials.userId + + /** + * The deviceId of the session (Ex: "ABCDEFGH") + */ + val deviceId = credentials.deviceId + + /** + * The current homeserver Url. It can be different that the homeserver url entered + * during login phase, because a redirection may have occurred + */ + val homeServerUrl = homeServerConnectionConfig.homeServerUri.toString() + + /** + * The current homeserver host + */ + val homeServerHost = homeServerConnectionConfig.homeServerUri.host + + /** + * The default identity server url if any, returned by the homeserver during login phase + */ + val defaultIdentityServerUrl = homeServerConnectionConfig.identityServerUri?.toString() +} diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/Session.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/Session.kt index ee2823db47..c86ca25faf 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/Session.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/Session.kt @@ -80,7 +80,7 @@ interface Session : * Useful shortcut to get access to the userId */ val myUserId: String - get() = sessionParams.credentials.userId + get() = sessionParams.userId /** * The sessionId diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/auth/DefaultAuthenticationService.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/auth/DefaultAuthenticationService.kt index 997cf70e5a..dbbd85751b 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/auth/DefaultAuthenticationService.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/auth/DefaultAuthenticationService.kt @@ -23,7 +23,6 @@ import im.vector.matrix.android.api.auth.AuthenticationService import im.vector.matrix.android.api.auth.data.Credentials import im.vector.matrix.android.api.auth.data.HomeServerConnectionConfig import im.vector.matrix.android.api.auth.data.LoginFlowResult -import im.vector.matrix.android.api.auth.data.SessionParams import im.vector.matrix.android.api.auth.data.Versions import im.vector.matrix.android.api.auth.data.isLoginAndRegistrationSupportedBySdk import im.vector.matrix.android.api.auth.data.isSupportedBySdk @@ -33,6 +32,7 @@ import im.vector.matrix.android.api.auth.wellknown.WellknownResult import im.vector.matrix.android.api.failure.Failure import im.vector.matrix.android.api.session.Session import im.vector.matrix.android.api.util.Cancelable +import im.vector.matrix.android.api.util.NoOpCancellable import im.vector.matrix.android.internal.SessionManager import im.vector.matrix.android.internal.auth.data.LoginFlowResponse import im.vector.matrix.android.internal.auth.data.RiotConfig @@ -87,8 +87,15 @@ internal class DefaultAuthenticationService @Inject constructor( } } - override fun getSession(sessionParams: SessionParams): Session? { - return sessionManager.getOrCreateSession(sessionParams) + override fun getLoginFlowOfSession(sessionId: String, callback: MatrixCallback): Cancelable { + val homeServerConnectionConfig = sessionParamsStore.get(sessionId)?.homeServerConnectionConfig + + return if (homeServerConnectionConfig == null) { + callback.onFailure(IllegalStateException("Session not found")) + NoOpCancellable + } else { + getLoginFlow(homeServerConnectionConfig, callback) + } } override fun getLoginFlow(homeServerConnectionConfig: HomeServerConnectionConfig, callback: MatrixCallback): Cancelable { diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/auth/db/SessionParamsMapper.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/auth/db/SessionParamsMapper.kt index ebd50a6924..a4db0e84f7 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/auth/db/SessionParamsMapper.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/auth/db/SessionParamsMapper.kt @@ -51,7 +51,7 @@ internal class SessionParamsMapper @Inject constructor(moshi: Moshi) { } return SessionParamsEntity( sessionParams.credentials.sessionId(), - sessionParams.credentials.userId, + sessionParams.userId, credentialsJson, homeServerConnectionConfigJson, sessionParams.isTokenValid) diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/verification/DefaultOutgoingSASDefaultVerificationTransaction.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/verification/DefaultOutgoingSASDefaultVerificationTransaction.kt index 689829b8e3..1480029d6d 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/verification/DefaultOutgoingSASDefaultVerificationTransaction.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/verification/DefaultOutgoingSASDefaultVerificationTransaction.kt @@ -121,7 +121,7 @@ internal class DefaultOutgoingSASDefaultVerificationTransaction( // } // // val requestMessage = KeyVerificationRequest( -// fromDevice = session.sessionParams.credentials.deviceId ?: "", +// fromDevice = session.sessionParams.deviceId ?: "", // methods = listOf(KeyVerificationStart.VERIF_METHOD_SAS), // timestamp = System.currentTimeMillis().toInt(), // transactionId = transactionId diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/DefaultSession.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/DefaultSession.kt index 91b31d68a4..f6d1be003b 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/DefaultSession.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/DefaultSession.kt @@ -242,6 +242,6 @@ internal class DefaultSession @Inject constructor( // For easy debugging override fun toString(): String { - return "$myUserId - ${sessionParams.credentials.deviceId}" + return "$myUserId - ${sessionParams.deviceId}" } } diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/signout/SignInAgainTask.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/signout/SignInAgainTask.kt index 0b8902e71b..5763d397c8 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/signout/SignInAgainTask.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/signout/SignInAgainTask.kt @@ -43,13 +43,13 @@ internal class DefaultSignInAgainTask @Inject constructor( apiCall = signOutAPI.loginAgain( PasswordLoginParams.userIdentifier( // Reuse the same userId - sessionParams.credentials.userId, + sessionParams.userId, params.password, // The spec says the initial device name will be ignored // https://matrix.org/docs/spec/client_server/latest#post-matrix-client-r0-login // but https://github.com/matrix-org/synapse/issues/6525 // Reuse the same deviceId - deviceId = sessionParams.credentials.deviceId + deviceId = sessionParams.deviceId ) ) } diff --git a/vector/src/main/java/im/vector/riotx/core/platform/VectorBaseActivity.kt b/vector/src/main/java/im/vector/riotx/core/platform/VectorBaseActivity.kt index 28b98ea6b9..a0d8f81119 100644 --- a/vector/src/main/java/im/vector/riotx/core/platform/VectorBaseActivity.kt +++ b/vector/src/main/java/im/vector/riotx/core/platform/VectorBaseActivity.kt @@ -229,8 +229,7 @@ abstract class VectorBaseActivity : AppCompatActivity(), HasScreenInjector { handleInvalidToken(globalError) is GlobalError.ConsentNotGivenError -> consentNotGivenHelper.displayDialog(globalError.consentUri, - activeSessionHolder.getActiveSession().sessionParams.homeServerConnectionConfig.homeServerUri.host - ?: "") + activeSessionHolder.getActiveSession().sessionParams.homeServerHost ?: "") } } diff --git a/vector/src/main/java/im/vector/riotx/core/pushers/PushersManager.kt b/vector/src/main/java/im/vector/riotx/core/pushers/PushersManager.kt index aa1fbaca54..69367e529c 100644 --- a/vector/src/main/java/im/vector/riotx/core/pushers/PushersManager.kt +++ b/vector/src/main/java/im/vector/riotx/core/pushers/PushersManager.kt @@ -45,7 +45,7 @@ class PushersManager @Inject constructor( profileTag, localeProvider.current().language, appNameProvider.getAppName(), - currentSession.sessionParams.credentials.deviceId ?: "MOBILE", + currentSession.sessionParams.deviceId ?: "MOBILE", stringProvider.getString(R.string.pusher_http_url), append = false, withEventIdOnly = true diff --git a/vector/src/main/java/im/vector/riotx/features/crypto/keysbackup/settings/KeysBackupSettingsRecyclerViewController.kt b/vector/src/main/java/im/vector/riotx/features/crypto/keysbackup/settings/KeysBackupSettingsRecyclerViewController.kt index 1fec404f7d..20046fa115 100644 --- a/vector/src/main/java/im/vector/riotx/features/crypto/keysbackup/settings/KeysBackupSettingsRecyclerViewController.kt +++ b/vector/src/main/java/im/vector/riotx/features/crypto/keysbackup/settings/KeysBackupSettingsRecyclerViewController.kt @@ -197,7 +197,7 @@ class KeysBackupSettingsRecyclerViewController @Inject constructor(private val s endIconResourceId(R.drawable.e2e_warning) } else { if (isSignatureValid) { - if (session.sessionParams.credentials.deviceId == it.deviceId) { + if (session.sessionParams.deviceId == it.deviceId) { description(stringProvider.getString(R.string.keys_backup_settings_valid_signature_from_this_device)) endIconResourceId(R.drawable.e2e_verified) } else { diff --git a/vector/src/main/java/im/vector/riotx/features/crypto/verification/VerificationBottomSheetViewModel.kt b/vector/src/main/java/im/vector/riotx/features/crypto/verification/VerificationBottomSheetViewModel.kt index 7a003c3722..dce33255ce 100644 --- a/vector/src/main/java/im/vector/riotx/features/crypto/verification/VerificationBottomSheetViewModel.kt +++ b/vector/src/main/java/im/vector/riotx/features/crypto/verification/VerificationBottomSheetViewModel.kt @@ -367,7 +367,7 @@ class VerificationBottomSheetViewModel @AssistedInject constructor( ) if (trustResult.isVerified()) { // Sign this device and upload the signature - session.sessionParams.credentials.deviceId?.let { deviceId -> + session.sessionParams.deviceId?.let { deviceId -> session.cryptoService() .crossSigningService().trustDevice(deviceId, object : MatrixCallback { override fun onFailure(failure: Throwable) { diff --git a/vector/src/main/java/im/vector/riotx/features/home/UnknownDeviceDetectorSharedViewModel.kt b/vector/src/main/java/im/vector/riotx/features/home/UnknownDeviceDetectorSharedViewModel.kt index a05e9ee985..1a0d9baf15 100644 --- a/vector/src/main/java/im/vector/riotx/features/home/UnknownDeviceDetectorSharedViewModel.kt +++ b/vector/src/main/java/im/vector/riotx/features/home/UnknownDeviceDetectorSharedViewModel.kt @@ -67,9 +67,10 @@ class UnknownDeviceDetectorSharedViewModel( init { - val currentSessionTs = session.cryptoService().getCryptoDeviceInfo(session.myUserId).firstOrNull { - it.deviceId == session.sessionParams.credentials.deviceId - }?.firstTimeSeenLocalTs ?: System.currentTimeMillis() + val currentSessionTs = session.cryptoService().getCryptoDeviceInfo(session.myUserId) + .firstOrNull { it.deviceId == session.sessionParams.deviceId } + ?.firstTimeSeenLocalTs + ?: System.currentTimeMillis() Timber.v("## Detector - Current Session first time seen $currentSessionTs") ignoredDeviceList.addAll( diff --git a/vector/src/main/java/im/vector/riotx/features/rageshake/BugReporter.kt b/vector/src/main/java/im/vector/riotx/features/rageshake/BugReporter.kt index 8515a5ac50..a001567635 100755 --- a/vector/src/main/java/im/vector/riotx/features/rageshake/BugReporter.kt +++ b/vector/src/main/java/im/vector/riotx/features/rageshake/BugReporter.kt @@ -212,7 +212,7 @@ class BugReporter @Inject constructor( activeSessionHolder.getSafeActiveSession()?.let { session -> userId = session.myUserId - deviceId = session.sessionParams.credentials.deviceId ?: "undefined" + deviceId = session.sessionParams.deviceId ?: "undefined" olmVersion = session.cryptoService().getCryptoVersion(context, true) } diff --git a/vector/src/main/java/im/vector/riotx/features/settings/VectorSettingsGeneralFragment.kt b/vector/src/main/java/im/vector/riotx/features/settings/VectorSettingsGeneralFragment.kt index 506f2ba547..dfa88d9b87 100644 --- a/vector/src/main/java/im/vector/riotx/features/settings/VectorSettingsGeneralFragment.kt +++ b/vector/src/main/java/im/vector/riotx/features/settings/VectorSettingsGeneralFragment.kt @@ -169,7 +169,7 @@ class VectorSettingsGeneralFragment : VectorSettingsBaseFragment() { // home server findPreference(VectorPreferences.SETTINGS_HOME_SERVER_PREFERENCE_KEY)!! - .summary = session.sessionParams.homeServerConnectionConfig.homeServerUri.toString() + .summary = session.sessionParams.homeServerUrl refreshEmailsList() refreshPhoneNumbersList() diff --git a/vector/src/main/java/im/vector/riotx/features/settings/VectorSettingsLabsFragment.kt b/vector/src/main/java/im/vector/riotx/features/settings/VectorSettingsLabsFragment.kt index 66c56455b9..eeda0167a3 100644 --- a/vector/src/main/java/im/vector/riotx/features/settings/VectorSettingsLabsFragment.kt +++ b/vector/src/main/java/im/vector/riotx/features/settings/VectorSettingsLabsFragment.kt @@ -47,7 +47,7 @@ class VectorSettingsLabsFragment @Inject constructor( // useCryptoPref.isChecked = false // // useCryptoPref.onPreferenceChangeListener = Preference.OnPreferenceChangeListener { _, newValueAsVoid -> -// if (TextUtils.isEmpty(mSession.sessionParams.credentials.deviceId)) { +// if (TextUtils.isEmpty(mSession.sessionParams.deviceId)) { // activity?.let { activity -> // AlertDialog.Builder(activity) // .setMessage(R.string.room_settings_labs_end_to_end_warnings) diff --git a/vector/src/main/java/im/vector/riotx/features/settings/VectorSettingsSecurityPrivacyFragment.kt b/vector/src/main/java/im/vector/riotx/features/settings/VectorSettingsSecurityPrivacyFragment.kt index 394587ea5d..491890de7e 100644 --- a/vector/src/main/java/im/vector/riotx/features/settings/VectorSettingsSecurityPrivacyFragment.kt +++ b/vector/src/main/java/im/vector/riotx/features/settings/VectorSettingsSecurityPrivacyFragment.kt @@ -340,7 +340,7 @@ class VectorSettingsSecurityPrivacyFragment @Inject constructor( showDeviceListPref.isEnabled = devices.size > 0 showDeviceListPref.summary = resources.getQuantityString(R.plurals.settings_active_sessions_count, devices.size, devices.size) // val userId = session.myUserId -// val deviceId = session.sessionParams.credentials.deviceId +// val deviceId = session.sessionParams.deviceId // device name // if (null != aMyDeviceInfo) { diff --git a/vector/src/main/java/im/vector/riotx/features/settings/devices/DeviceVerificationInfoBottomSheetViewModel.kt b/vector/src/main/java/im/vector/riotx/features/settings/devices/DeviceVerificationInfoBottomSheetViewModel.kt index ac4c371448..88cc4ed4bc 100644 --- a/vector/src/main/java/im/vector/riotx/features/settings/devices/DeviceVerificationInfoBottomSheetViewModel.kt +++ b/vector/src/main/java/im/vector/riotx/features/settings/devices/DeviceVerificationInfoBottomSheetViewModel.kt @@ -73,7 +73,7 @@ class DeviceVerificationInfoBottomSheetViewModel @AssistedInject constructor(@As .execute { copy( cryptoDeviceInfo = it, - isMine = it.invoke()?.deviceId == session.sessionParams.credentials.deviceId + isMine = it.invoke()?.deviceId == session.sessionParams.deviceId ) } diff --git a/vector/src/main/java/im/vector/riotx/features/settings/devices/DevicesViewModel.kt b/vector/src/main/java/im/vector/riotx/features/settings/devices/DevicesViewModel.kt index d0369e7707..c3b645787f 100644 --- a/vector/src/main/java/im/vector/riotx/features/settings/devices/DevicesViewModel.kt +++ b/vector/src/main/java/im/vector/riotx/features/settings/devices/DevicesViewModel.kt @@ -97,7 +97,7 @@ class DevicesViewModel @AssistedInject constructor( copy( hasAccountCrossSigning = session.cryptoService().crossSigningService().getMyCrossSigningKeys() != null, accountCrossSigningIsTrusted = session.cryptoService().crossSigningService().isCrossSigningVerified(), - myDeviceId = session.sessionParams.credentials.deviceId ?: "" + myDeviceId = session.sessionParams.deviceId ?: "" ) } diff --git a/vector/src/main/java/im/vector/riotx/features/signout/soft/SoftLogoutViewModel.kt b/vector/src/main/java/im/vector/riotx/features/signout/soft/SoftLogoutViewModel.kt index 5ee7b6e8a3..e2fe17b461 100644 --- a/vector/src/main/java/im/vector/riotx/features/signout/soft/SoftLogoutViewModel.kt +++ b/vector/src/main/java/im/vector/riotx/features/signout/soft/SoftLogoutViewModel.kt @@ -58,9 +58,9 @@ class SoftLogoutViewModel @AssistedInject constructor( val activity: SoftLogoutActivity = (viewModelContext as ActivityViewModelContext).activity() val userId = activity.session.myUserId return SoftLogoutViewState( - homeServerUrl = activity.session.sessionParams.homeServerConnectionConfig.homeServerUri.toString(), + homeServerUrl = activity.session.sessionParams.homeServerUrl, userId = userId, - deviceId = activity.session.sessionParams.credentials.deviceId ?: "", + deviceId = activity.session.sessionParams.deviceId ?: "", userDisplayName = activity.session.getUser(userId)?.displayName ?: userId, hasUnsavedKeys = activity.session.hasUnsavedKeys() ) @@ -81,8 +81,6 @@ class SoftLogoutViewModel @AssistedInject constructor( } private fun getSupportedLoginFlow() { - val homeServerConnectionConfig = session.sessionParams.homeServerConnectionConfig - currentTask?.cancel() currentTask = null authenticationService.cancelPendingLoginOrRegistration() @@ -93,7 +91,7 @@ class SoftLogoutViewModel @AssistedInject constructor( ) } - currentTask = authenticationService.getLoginFlow(homeServerConnectionConfig, object : MatrixCallback { + currentTask = authenticationService.getLoginFlowOfSession(session.sessionId, object : MatrixCallback { override fun onFailure(failure: Throwable) { setState { copy(