fix crash when no ledger connected (#463)
This commit is contained in:
parent
dc86f0469e
commit
29583fa40d
|
@ -193,7 +193,8 @@ 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) {
|
||||||
startDetails(walletFile, password, GenerateReviewFragment.VIEW_TYPE_DETAILS);
|
if (checkDevice(walletName, password))
|
||||||
|
startDetails(walletFile, password, GenerateReviewFragment.VIEW_TYPE_DETAILS);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else { // this cannot really happen as we prefilter choices
|
} else { // this cannot really happen as we prefilter choices
|
||||||
|
@ -225,7 +226,8 @@ 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) {
|
||||||
startReceive(walletFile, password);
|
if (checkDevice(walletName, password))
|
||||||
|
startReceive(walletFile, password);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else { // this cannot really happen as we prefilter choices
|
} else { // this cannot really happen as we prefilter choices
|
||||||
|
@ -1160,6 +1162,28 @@ public class LoginActivity extends BaseActivity
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean checkDevice(String walletName, String password) {
|
||||||
|
String keyPath = new File(Helper.getWalletRoot(LoginActivity.this),
|
||||||
|
walletName + ".keys").getAbsolutePath();
|
||||||
|
// check if we need connected hardware
|
||||||
|
Wallet.Device device =
|
||||||
|
WalletManager.getInstance().queryWalletDevice(keyPath, password);
|
||||||
|
switch (device) {
|
||||||
|
case Device_Ledger:
|
||||||
|
if (!hasLedger()) {
|
||||||
|
toast(R.string.open_wallet_ledger_missing);
|
||||||
|
} else {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
// device could be undefined meaning the password is wrong
|
||||||
|
// this gets dealt with later
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void promptAndStart(WalletNode walletNode) {
|
void promptAndStart(WalletNode walletNode) {
|
||||||
File walletFile = Helper.getWalletFile(this, walletNode.getName());
|
File walletFile = Helper.getWalletFile(this, walletNode.getName());
|
||||||
if (WalletManager.getInstance().walletExists(walletFile)) {
|
if (WalletManager.getInstance().walletExists(walletFile)) {
|
||||||
|
@ -1168,24 +1192,9 @@ public class LoginActivity extends BaseActivity
|
||||||
new Helper.PasswordAction() {
|
new Helper.PasswordAction() {
|
||||||
@Override
|
@Override
|
||||||
public void action(String walletName, String password, boolean fingerprintUsed) {
|
public void action(String walletName, String password, boolean fingerprintUsed) {
|
||||||
String keyPath = new File(Helper.getWalletRoot(LoginActivity.this),
|
if (checkDevice(walletName, password))
|
||||||
walletName + ".keys").getAbsolutePath();
|
startWallet(walletName, password, fingerprintUsed);
|
||||||
// check if we need connected hardware
|
|
||||||
Wallet.Device device =
|
|
||||||
WalletManager.getInstance().queryWalletDevice(keyPath, password);
|
|
||||||
switch (device) {
|
|
||||||
case Device_Ledger:
|
|
||||||
if (!hasLedger()) {
|
|
||||||
toast(R.string.open_wallet_ledger_missing);
|
|
||||||
} else {
|
|
||||||
startWallet(walletName, password, fingerprintUsed);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
// device could be undefined meaning the password is wrong
|
|
||||||
// this gets dealt with later
|
|
||||||
startWallet(walletName, password, fingerprintUsed);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else { // this cannot really happen as we prefilter choices
|
} else { // this cannot really happen as we prefilter choices
|
||||||
|
|
Loading…
Reference in New Issue