fix crash when no ledger connected (#463)

This commit is contained in:
m2049r 2018-11-05 18:47:11 +01:00 committed by GitHub
parent dc86f0469e
commit 29583fa40d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 29 additions and 20 deletions

View File

@ -193,6 +193,7 @@ public class LoginActivity extends BaseActivity
Helper.promptPassword(LoginActivity.this, walletName, true, new Helper.PasswordAction() { Helper.promptPassword(LoginActivity.this, walletName, true, new Helper.PasswordAction() {
@Override @Override
public void action(String walletName, String password, boolean fingerprintUsed) { public void action(String walletName, String password, boolean fingerprintUsed) {
if (checkDevice(walletName, password))
startDetails(walletFile, password, GenerateReviewFragment.VIEW_TYPE_DETAILS); startDetails(walletFile, password, GenerateReviewFragment.VIEW_TYPE_DETAILS);
} }
}); });
@ -225,6 +226,7 @@ public class LoginActivity extends BaseActivity
Helper.promptPassword(LoginActivity.this, walletName, false, new Helper.PasswordAction() { Helper.promptPassword(LoginActivity.this, walletName, false, new Helper.PasswordAction() {
@Override @Override
public void action(String walletName, String password, boolean fingerprintUsed) { public void action(String walletName, String password, boolean fingerprintUsed) {
if (checkDevice(walletName, password))
startReceive(walletFile, password); startReceive(walletFile, password);
} }
}); });
@ -1160,14 +1162,7 @@ public class LoginActivity extends BaseActivity
} }
} }
void promptAndStart(WalletNode walletNode) { boolean checkDevice(String walletName, String password) {
File walletFile = Helper.getWalletFile(this, walletNode.getName());
if (WalletManager.getInstance().walletExists(walletFile)) {
WalletManager.getInstance().setDaemon(walletNode);
Helper.promptPassword(LoginActivity.this, walletNode.getName(), false,
new Helper.PasswordAction() {
@Override
public void action(String walletName, String password, boolean fingerprintUsed) {
String keyPath = new File(Helper.getWalletRoot(LoginActivity.this), String keyPath = new File(Helper.getWalletRoot(LoginActivity.this),
walletName + ".keys").getAbsolutePath(); walletName + ".keys").getAbsolutePath();
// check if we need connected hardware // check if we need connected hardware
@ -1178,14 +1173,28 @@ public class LoginActivity extends BaseActivity
if (!hasLedger()) { if (!hasLedger()) {
toast(R.string.open_wallet_ledger_missing); toast(R.string.open_wallet_ledger_missing);
} else { } else {
startWallet(walletName, password, fingerprintUsed); return true;
} }
break; break;
default: default:
// device could be undefined meaning the password is wrong // device could be undefined meaning the password is wrong
// this gets dealt with later // this gets dealt with later
startWallet(walletName, password, fingerprintUsed); return true;
} }
return false;
}
void promptAndStart(WalletNode walletNode) {
File walletFile = Helper.getWalletFile(this, walletNode.getName());
if (WalletManager.getInstance().walletExists(walletFile)) {
WalletManager.getInstance().setDaemon(walletNode);
Helper.promptPassword(LoginActivity.this, walletNode.getName(), false,
new Helper.PasswordAction() {
@Override
public void action(String walletName, String password, boolean fingerprintUsed) {
if (checkDevice(walletName, password))
startWallet(walletName, password, fingerprintUsed);
} }
}); });
} else { // this cannot really happen as we prefilter choices } else { // this cannot really happen as we prefilter choices