From 04977f655fa61678275f1a2512c8f56026db0b6b Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Mon, 2 Mar 2026 09:40:42 +0100 Subject: [PATCH] Fix API break. --- .../impl/LinkNewDeviceFlowNode.kt | 6 +++- .../matrix/api/linknewdevice/ErrorType.kt | 30 +++++++++++++++---- .../HumanQrGrantLoginExceptionExtension.kt | 6 +++- 3 files changed, 35 insertions(+), 7 deletions(-) diff --git a/features/linknewdevice/impl/src/main/kotlin/io/element/android/features/linknewdevice/impl/LinkNewDeviceFlowNode.kt b/features/linknewdevice/impl/src/main/kotlin/io/element/android/features/linknewdevice/impl/LinkNewDeviceFlowNode.kt index 52e93d4992..79a476ff04 100644 --- a/features/linknewdevice/impl/src/main/kotlin/io/element/android/features/linknewdevice/impl/LinkNewDeviceFlowNode.kt +++ b/features/linknewdevice/impl/src/main/kotlin/io/element/android/features/linknewdevice/impl/LinkNewDeviceFlowNode.kt @@ -189,9 +189,13 @@ class LinkNewDeviceFlowNode( is ErrorType.InvalidCheckCode -> ErrorScreenType.InsecureChannelDetected is ErrorType.MissingSecretsBackup -> ErrorScreenType.UnknownError is ErrorType.NotFound -> ErrorScreenType.Expired - is ErrorType.UnableToCreateDevice -> ErrorScreenType.UnknownError + is ErrorType.DeviceNotFound -> ErrorScreenType.UnknownError is ErrorType.Unknown -> ErrorScreenType.UnknownError is ErrorType.UnsupportedProtocol -> ErrorScreenType.UnknownError + is ErrorType.Cancelled -> ErrorScreenType.UnknownError + is ErrorType.ConnectionInsecure -> ErrorScreenType.InsecureChannelDetected + is ErrorType.Expired -> ErrorScreenType.Expired + is ErrorType.OtherDeviceAlreadySignedIn -> ErrorScreenType.UnknownError } // It is OK to push on backstack, since when user leaves the error screen, a new root will be set, // or the whole flow will be popped. diff --git a/libraries/matrix/api/src/main/kotlin/io/element/android/libraries/matrix/api/linknewdevice/ErrorType.kt b/libraries/matrix/api/src/main/kotlin/io/element/android/libraries/matrix/api/linknewdevice/ErrorType.kt index 0f61007d47..21c0d521c9 100644 --- a/libraries/matrix/api/src/main/kotlin/io/element/android/libraries/matrix/api/linknewdevice/ErrorType.kt +++ b/libraries/matrix/api/src/main/kotlin/io/element/android/libraries/matrix/api/linknewdevice/ErrorType.kt @@ -33,13 +33,33 @@ sealed class ErrorType(message: String) : Exception(message) { */ class NotFound(message: String) : ErrorType(message) - /** - * The device could not be created. - */ - class UnableToCreateDevice(message: String) : ErrorType(message) - /** * An unknown error has happened. */ class Unknown(message: String) : ErrorType(message) + + /** + * The requested device was not returned by the homeserver. + */ + class DeviceNotFound(message: String) : ErrorType(message) + + /** + * The other device is already signed in and so does not need to sign in. + */ + class OtherDeviceAlreadySignedIn(message: String) : ErrorType(message) + + /** + * The sign in was cancelled. + */ + class Cancelled(message: String) : ErrorType(message) + + /** + * The sign in was not completed in the required time. + */ + class Expired(message: String) : ErrorType(message) + + /** + * A secure connection could not have been established between the two devices. + */ + class ConnectionInsecure(message: String) : ErrorType(message) } diff --git a/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/linknewdevice/HumanQrGrantLoginExceptionExtension.kt b/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/linknewdevice/HumanQrGrantLoginExceptionExtension.kt index 2d47b60def..4027ee507b 100644 --- a/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/linknewdevice/HumanQrGrantLoginExceptionExtension.kt +++ b/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/linknewdevice/HumanQrGrantLoginExceptionExtension.kt @@ -15,7 +15,11 @@ internal fun HumanQrGrantLoginException.map() = when (this) { is HumanQrGrantLoginException.InvalidCheckCode -> ErrorType.InvalidCheckCode(message.orEmpty()) is HumanQrGrantLoginException.MissingSecretsBackup -> ErrorType.MissingSecretsBackup(message.orEmpty()) is HumanQrGrantLoginException.NotFound -> ErrorType.NotFound(message.orEmpty()) - is HumanQrGrantLoginException.UnableToCreateDevice -> ErrorType.UnableToCreateDevice(message.orEmpty()) + is HumanQrGrantLoginException.Cancelled -> ErrorType.Cancelled(message.orEmpty()) + is HumanQrGrantLoginException.ConnectionInsecure -> ErrorType.ConnectionInsecure(message.orEmpty()) + is HumanQrGrantLoginException.DeviceNotFound -> ErrorType.DeviceNotFound(message.orEmpty()) + is HumanQrGrantLoginException.Expired -> ErrorType.Expired(message.orEmpty()) + is HumanQrGrantLoginException.OtherDeviceAlreadySignedIn -> ErrorType.OtherDeviceAlreadySignedIn(message.orEmpty()) is HumanQrGrantLoginException.Unknown -> ErrorType.Unknown(message.orEmpty()) is HumanQrGrantLoginException.UnsupportedProtocol -> ErrorType.UnsupportedProtocol(message.orEmpty()) }