From e321ae9a4345e3e950074a75facac1caceded61a Mon Sep 17 00:00:00 2001 From: 0140454 Date: Sun, 22 Apr 2018 02:20:09 +0800 Subject: [PATCH] Prevent from crashing due to missing check --- .../java/com/m2049r/xmrwallet/LoginActivity.java | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/m2049r/xmrwallet/LoginActivity.java b/app/src/main/java/com/m2049r/xmrwallet/LoginActivity.java index 59e6ea9380..03f60199bf 100644 --- a/app/src/main/java/com/m2049r/xmrwallet/LoginActivity.java +++ b/app/src/main/java/com/m2049r/xmrwallet/LoginActivity.java @@ -238,7 +238,17 @@ protected Boolean doInBackground(String... params) { if (params.length != 2) return false; File walletFile = Helper.getWalletFile(LoginActivity.this, params[0]); String newName = params[1]; - return renameWallet(walletFile, newName); + boolean success = renameWallet(walletFile, newName); + try { + if (success && FingerprintHelper.isFingerprintAuthAllowed(params[0])) { + String savedPass = KeyStoreHelper.loadWalletUserPass(LoginActivity.this, params[0]); + KeyStoreHelper.saveWalletUserPass(LoginActivity.this, newName, savedPass); + KeyStoreHelper.removeWalletUserPass(LoginActivity.this, params[0]); + } + } catch (KeyStoreException ex) { + ex.printStackTrace(); + } + return success; } @Override @@ -259,9 +269,6 @@ protected void onPostExecute(Boolean result) { // copy + delete seems safer than rename because we call rollback easily boolean renameWallet(File walletFile, String newName) { if (copyWallet(walletFile, new File(walletFile.getParentFile(), newName), false, true)) { - String savedPass = KeyStoreHelper.loadWalletUserPass(LoginActivity.this, walletFile.getName()); - KeyStoreHelper.saveWalletUserPass(LoginActivity.this, newName, savedPass); - KeyStoreHelper.removeWalletUserPass(LoginActivity.this, walletFile.getName()); deleteWallet(walletFile); return true; } else {