diff --git a/matrix-sdk-android/src/kotlinCrypto/java/org/matrix/android/sdk/internal/crypto/DefaultCryptoService.kt b/matrix-sdk-android/src/kotlinCrypto/java/org/matrix/android/sdk/internal/crypto/DefaultCryptoService.kt index bc0263cc43..d87416884f 100755 --- a/matrix-sdk-android/src/kotlinCrypto/java/org/matrix/android/sdk/internal/crypto/DefaultCryptoService.kt +++ b/matrix-sdk-android/src/kotlinCrypto/java/org/matrix/android/sdk/internal/crypto/DefaultCryptoService.kt @@ -1187,6 +1187,8 @@ internal class DefaultCryptoService @Inject constructor( override fun isShareKeysOnInviteEnabled() = cryptoStore.isShareKeysOnInviteEnabled() + override fun supportsShareKeysOnInvite() = true + override fun enableShareKeyOnInvite(enable: Boolean) = cryptoStore.enableShareKeyOnInvite(enable) /** diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/crypto/CryptoService.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/crypto/CryptoService.kt index 3b308fff95..0ee3ea499f 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/crypto/CryptoService.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/crypto/CryptoService.kt @@ -89,6 +89,10 @@ interface CryptoService { fun isKeyGossipingEnabled(): Boolean + /* + * Tells if the current crypto implementation supports MSC3061 + */ + fun supportsShareKeysOnInvite(): Boolean /** * As per MSC3061. * If true will make it possible to share part of e2ee room history diff --git a/matrix-sdk-android/src/rustCrypto/java/org/matrix/android/sdk/internal/crypto/RustCryptoService.kt b/matrix-sdk-android/src/rustCrypto/java/org/matrix/android/sdk/internal/crypto/RustCryptoService.kt index d168663a1b..d434f89d78 100755 --- a/matrix-sdk-android/src/rustCrypto/java/org/matrix/android/sdk/internal/crypto/RustCryptoService.kt +++ b/matrix-sdk-android/src/rustCrypto/java/org/matrix/android/sdk/internal/crypto/RustCryptoService.kt @@ -724,15 +724,15 @@ internal class RustCryptoService @Inject constructor( return cryptoStore.isKeyGossipingEnabled() } + override fun supportsShareKeysOnInvite() = false + override fun enableShareKeyOnInvite(enable: Boolean) { if (enable) { TODO("Enable share key on invite not implemented") } } - override fun isShareKeysOnInviteEnabled(): Boolean { - return false - } + override fun isShareKeysOnInviteEnabled() = false override fun setRoomUnBlockUnverifiedDevices(roomId: String) { cryptoStore.blockUnverifiedDevicesInRoom(roomId, false) diff --git a/vector/src/main/java/im/vector/app/features/settings/labs/VectorSettingsLabsFragment.kt b/vector/src/main/java/im/vector/app/features/settings/labs/VectorSettingsLabsFragment.kt index 189d55d990..73a2eb1b73 100644 --- a/vector/src/main/java/im/vector/app/features/settings/labs/VectorSettingsLabsFragment.kt +++ b/vector/src/main/java/im/vector/app/features/settings/labs/VectorSettingsLabsFragment.kt @@ -72,13 +72,18 @@ class VectorSettingsLabsFragment : } findPreference(VectorPreferences.SETTINGS_LABS_MSC3061_SHARE_KEYS_HISTORY)?.let { pref -> - // ensure correct default - pref.isChecked = session.cryptoService().isShareKeysOnInviteEnabled() + if (session.cryptoService().supportsShareKeysOnInvite()) { + // ensure correct default + pref.isChecked = session.cryptoService().isShareKeysOnInviteEnabled() - pref.onPreferenceClickListener = Preference.OnPreferenceClickListener { - session.cryptoService().enableShareKeyOnInvite(pref.isChecked) - MainActivity.restartApp(requireActivity(), MainActivityArgs(clearCache = true)) - true + pref.onPreferenceClickListener = Preference.OnPreferenceClickListener { + session.cryptoService().enableShareKeyOnInvite(pref.isChecked) + MainActivity.restartApp(requireActivity(), MainActivityArgs(clearCache = true)) + true + } + } else { + pref.isEnabled = false + pref.isChecked = false } }