mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-05-02 14:43:09 +01:00
Fix handling non-existent SVR enclaves.
This commit is contained in:
@@ -103,6 +103,9 @@ interface SecureValueRecovery {
|
||||
/** The PIN was incorrect. Includes the number of attempts the user has remaining. */
|
||||
data class PinMismatch(val triesRemaining: Int) : RestoreResponse()
|
||||
|
||||
/** The enclave no longer exists */
|
||||
data object EnclaveNotFound : RestoreResponse()
|
||||
|
||||
/** There as a network error. Not a bad response, but rather interference or some other inability to make a network request. */
|
||||
data class NetworkError(val exception: IOException) : RestoreResponse()
|
||||
|
||||
|
||||
@@ -83,7 +83,11 @@ class SecureValueRecoveryV2(
|
||||
DeleteResponse.Success
|
||||
} catch (e: NonSuccessfulResponseCodeException) {
|
||||
Log.w(TAG, "[Delete] Failed with a non-successful response code exception!", e)
|
||||
DeleteResponse.ApplicationError(e)
|
||||
if (e.code == 404) {
|
||||
DeleteResponse.EnclaveNotFound
|
||||
} else {
|
||||
DeleteResponse.ApplicationError(e)
|
||||
}
|
||||
} catch (e: IOException) {
|
||||
Log.w(TAG, "[Delete] Failed with a network exception!", e)
|
||||
DeleteResponse.NetworkError(e)
|
||||
@@ -149,7 +153,11 @@ class SecureValueRecoveryV2(
|
||||
}
|
||||
} catch (e: NonSuccessfulResponseCodeException) {
|
||||
Log.w(TAG, "[Restore] Failed with a non-successful response code exception!", e)
|
||||
RestoreResponse.ApplicationError(e)
|
||||
if (e.code == 404) {
|
||||
RestoreResponse.EnclaveNotFound
|
||||
} else {
|
||||
RestoreResponse.ApplicationError(e)
|
||||
}
|
||||
} catch (e: IOException) {
|
||||
Log.w(TAG, "[Restore] Failed with a network exception!", e)
|
||||
RestoreResponse.NetworkError(e)
|
||||
@@ -212,7 +220,11 @@ class SecureValueRecoveryV2(
|
||||
}
|
||||
} catch (e: NonSuccessfulResponseCodeException) {
|
||||
Log.w(TAG, "[Set] Failed with a non-successful response code exception!", e)
|
||||
BackupResponse.ApplicationError(e)
|
||||
if (e.code == 404) {
|
||||
BackupResponse.EnclaveNotFound
|
||||
} else {
|
||||
BackupResponse.ApplicationError(e)
|
||||
}
|
||||
} catch (e: IOException) {
|
||||
Log.w(TAG, "[Set] Failed with a network exception!", e)
|
||||
BackupResponse.NetworkError(e)
|
||||
|
||||
@@ -149,7 +149,13 @@ internal class Svr2Socket(
|
||||
}
|
||||
|
||||
override fun onFailure(webSocket: WebSocket, t: Throwable, response: OkHttpResponse?) {
|
||||
if (emitError(IOException(t))) {
|
||||
val exception = if (t.message?.contains("404") == true) {
|
||||
NonSuccessfulResponseCodeException(404)
|
||||
} else {
|
||||
IOException(t)
|
||||
}
|
||||
|
||||
if (emitError(exception)) {
|
||||
Log.w(TAG, "[onFailure] response? " + (response != null), t)
|
||||
stage.set(Stage.FAILED)
|
||||
webSocket.close(1000, "OK")
|
||||
|
||||
Reference in New Issue
Block a user