Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle Keystore crash on App resume #7745

Merged
merged 2 commits into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import io.horizontalsystems.bankwallet.core.stats.stat
import io.horizontalsystems.marketkit.models.Blockchain
import java.net.MalformedURLException
import java.net.URI
import java.net.URISyntaxException

class AddRpcViewModel(
private val blockchain: Blockchain,
Expand Down Expand Up @@ -50,7 +51,7 @@ class AddRpcViewModel(
if (!hasRequiredProtocol) {
throw MalformedURLException()
}
} catch (e: MalformedURLException) {
} catch (e: Throwable) {
urlCaution = Caution(Translator.getString(R.string.AddEvmSyncSource_Error_InvalidUrl), Caution.Type.Error)
syncState()
return
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package io.horizontalsystems.bankwallet.modules.main

import android.os.Bundle
import android.widget.Toast
import androidx.activity.viewModels
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
import androidx.navigation.fragment.NavHostFragment
import com.walletconnect.web3.wallet.client.Wallet
import io.horizontalsystems.bankwallet.R
import io.horizontalsystems.bankwallet.core.App
import io.horizontalsystems.bankwallet.core.BaseActivity
import io.horizontalsystems.bankwallet.core.slideFromBottom
import io.horizontalsystems.bankwallet.modules.intro.IntroActivity
Expand Down Expand Up @@ -92,5 +94,8 @@ class MainActivity : BaseActivity() {
finish()
} catch (e: MainScreenValidationError.Unlock) {
LockScreenActivity.start(this)
} catch (e: MainScreenValidationError.KeystoreRuntimeException) {
Toast.makeText(App.instance, "Issue with Keystore", Toast.LENGTH_SHORT).show()
finish()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ class MainActivityViewModel(
throw MainScreenValidationError.UserAuthentication()
} catch (e: KeyStoreValidationError.KeyIsInvalid) {
throw MainScreenValidationError.KeyInvalidated()
} catch (e: RuntimeException) {
throw MainScreenValidationError.KeystoreRuntimeException()
}

if (accountManager.isAccountsEmpty && !localStorage.mainShowedOnce) {
Expand Down Expand Up @@ -117,4 +119,5 @@ sealed class MainScreenValidationError : Exception() {
class NoSystemLock : MainScreenValidationError()
class KeyInvalidated : MainScreenValidationError()
class UserAuthentication : MainScreenValidationError()
class KeystoreRuntimeException : MainScreenValidationError()
}
Loading