mirror of https://github.com/m2049r/xmrwallet.git
getDeviceType
This commit is contained in:
parent
cbddcdc92d
commit
78d6fef3e4
|
@ -778,11 +778,11 @@ Java_com_m2049r_xmrwallet_model_Wallet_isSynchronized(JNIEnv *env, jobject insta
|
|||
return static_cast<jboolean>(wallet->synchronized());
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_com_m2049r_xmrwallet_model_Wallet_isKeyOnDevice(JNIEnv *env, jobject instance) {
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_com_m2049r_xmrwallet_model_Wallet_getDeviceTypeJ(JNIEnv *env, jobject instance) {
|
||||
Bitmonero::Wallet *wallet = getHandle<Bitmonero::Wallet>(env, instance);
|
||||
bool key_on_device = wallet->isKeyOnDevice();
|
||||
return static_cast<jboolean>(key_on_device);
|
||||
Bitmonero::Wallet::Device device_type = wallet->getDeviceType();
|
||||
return static_cast<jint>(device_type);
|
||||
}
|
||||
|
||||
//void cn_slow_hash(const void *data, size_t length, char *hash); // from crypto/hash-ops.h
|
||||
|
|
|
@ -232,10 +232,15 @@ public class GenerateReviewFragment extends Fragment {
|
|||
|
||||
address = wallet.getAddress();
|
||||
seed = wallet.getSeed();
|
||||
if (wallet.isKeyOnDevice()) {
|
||||
viewKey = Ledger.Key();
|
||||
} else {
|
||||
viewKey = wallet.getSecretViewKey();
|
||||
switch (wallet.getDeviceType()) {
|
||||
case Device_Ledger:
|
||||
viewKey = Ledger.Key();
|
||||
break;
|
||||
case Device_Software:
|
||||
viewKey = wallet.getSecretViewKey();
|
||||
break;
|
||||
default:
|
||||
throw new IllegalStateException("Hardware backing not supported. At all!");
|
||||
}
|
||||
spendKey = isWatchOnly ? getActivity().getString(R.string.label_watchonly) : wallet.getSecretSpendKey();
|
||||
isWatchOnly = wallet.isWatchOnly();
|
||||
|
|
|
@ -514,7 +514,7 @@ public class ReceiveFragment extends Fragment {
|
|||
@Override
|
||||
protected void onPreExecute() {
|
||||
super.onPreExecute();
|
||||
if (wallet.isKeyOnDevice() && (progressCallback != null)) {
|
||||
if ((wallet.getDeviceType() == Wallet.Device.Device_Ledger) && (progressCallback != null)) {
|
||||
progressCallback.showLedgerProgressDialog(LedgerProgressDialog.TYPE_SUBADDRESS);
|
||||
dialogOpened = true;
|
||||
}
|
||||
|
|
|
@ -51,6 +51,7 @@ import com.m2049r.xmrwallet.dialog.CreditsFragment;
|
|||
import com.m2049r.xmrwallet.dialog.HelpFragment;
|
||||
import com.m2049r.xmrwallet.fragment.send.SendAddressWizardFragment;
|
||||
import com.m2049r.xmrwallet.fragment.send.SendFragment;
|
||||
import com.m2049r.xmrwallet.ledger.Ledger;
|
||||
import com.m2049r.xmrwallet.ledger.LedgerProgressDialog;
|
||||
import com.m2049r.xmrwallet.model.PendingTransaction;
|
||||
import com.m2049r.xmrwallet.model.TransactionInfo;
|
||||
|
@ -718,7 +719,7 @@ public class WalletActivity extends BaseActivity implements WalletFragment.Liste
|
|||
intent.putExtra(WalletService.REQUEST_CMD_TX_TAG, tag);
|
||||
startService(intent);
|
||||
Timber.d("CREATE TX request sent");
|
||||
if (getWallet().isKeyOnDevice())
|
||||
if (getWallet().getDeviceType() == Wallet.Device.Device_Ledger)
|
||||
showLedgerProgressDialog(LedgerProgressDialog.TYPE_SEND);
|
||||
} else {
|
||||
Timber.e("Service not bound");
|
||||
|
@ -1074,12 +1075,17 @@ public class WalletActivity extends BaseActivity implements WalletFragment.Liste
|
|||
@Override
|
||||
protected void onPreExecute() {
|
||||
super.onPreExecute();
|
||||
if (getWallet().isKeyOnDevice()) {
|
||||
showLedgerProgressDialog(LedgerProgressDialog.TYPE_ACCOUNT);
|
||||
dialogOpened = true;
|
||||
} else {
|
||||
showProgressDialog(R.string.accounts_progress_new);
|
||||
dialogOpened = true;
|
||||
switch (getWallet().getDeviceType()) {
|
||||
case Device_Ledger:
|
||||
showLedgerProgressDialog(LedgerProgressDialog.TYPE_ACCOUNT);
|
||||
dialogOpened = true;
|
||||
break;
|
||||
case Device_Software:
|
||||
showProgressDialog(R.string.accounts_progress_new);
|
||||
dialogOpened = true;
|
||||
break;
|
||||
default:
|
||||
throw new IllegalStateException("Hardware backing not supported. At all!");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -400,5 +400,11 @@ public class Wallet {
|
|||
return getSubaddress(accountIndex, getNumSubaddresses(accountIndex) - 1);
|
||||
}
|
||||
|
||||
public native boolean isKeyOnDevice();
|
||||
public Wallet.Device getDeviceType() {
|
||||
int device = getDeviceTypeJ();
|
||||
return Wallet.Device.values()[device + 1]; // mapping is monero+1=android
|
||||
}
|
||||
|
||||
private native int getDeviceTypeJ();
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue