Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Commit

Permalink
Enable libusb for android
Browse files Browse the repository at this point in the history
* Tested by it compiling succesfully with `cargo build --target=armv7--linux-androideabi`
* The binary is ~66 MB

```bash
$ size
size target/armv7-linux-androideabi/release/parity
text    	data     	bss     	dec     	hex 		filename
50676230        416200   	31456 		51123886        30c16ae 	target/armv7-linux-androideabi/release/parity
```
  • Loading branch information
niklasad1 committed Jun 3, 2018
1 parent 88460f8 commit 3b78b39
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
10 changes: 5 additions & 5 deletions ethcore/src/account_provider/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
mod stores;

#[cfg(not(any(target_os = "linux", target_os = "macos", target_os = "windows")))]
#[cfg(not(any(target_os = "linux", target_os = "macos", target_os = "windows", target_os = "android")))]
mod no_hw;

use ethstore::{
Expand All @@ -38,12 +38,12 @@ pub use ethstore::ethkey::Signature;
pub use ethstore::{Derivation, IndexDerivation, KeyFile};
pub use super::transaction::{Action, Transaction};

#[cfg(any(target_os = "linux", target_os = "macos", target_os = "windows"))]
#[cfg(any(target_os = "linux", target_os = "macos", target_os = "windows", target_os = "android"))]
mod hw {
pub use hardware_wallet::{Error as HardwareError, HardwareWalletManager, KeyPath, TransactionInfo};
}

#[cfg(not(any(target_os = "linux", target_os = "macos", target_os = "windows")))]
#[cfg(not(any(target_os = "linux", target_os = "macos", target_os = "windows", target_os = "android")))]
mod hw {
pub use account_provider::no_hw::{HardwareError, HardwareWalletManager};
}
Expand Down Expand Up @@ -178,7 +178,7 @@ impl AccountProvider {
pub fn new(sstore: Box<SecretStore>, settings: AccountProviderSettings) -> Self {
let mut hardware_store = None;

#[cfg(any(target_os = "linux", target_os = "macos", target_os = "windows"))]
#[cfg(any(target_os = "linux", target_os = "macos", target_os = "windows", target_os = "android"))]
{
if settings.enable_hardware_wallets {
match hw::HardwareWalletManager::new() {
Expand Down Expand Up @@ -826,7 +826,7 @@ impl AccountProvider {
}

/// Sign transaction with hardware wallet.
#[cfg(any(target_os = "linux", target_os = "macos", target_os = "windows"))]
#[cfg(any(target_os = "linux", target_os = "macos", target_os = "windows", target_os = "android"))]
pub fn sign_with_hardware(&self, address: Address, transaction: &Transaction, chain_id: Option<u64>, rlp_encoded_transaction: &[u8]) -> Result<Signature, SignError> {
let t_info = hw::TransactionInfo {
nonce: transaction.nonce,
Expand Down
2 changes: 1 addition & 1 deletion ethcore/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ extern crate wasm;
extern crate memory_cache;
extern crate journaldb;

#[cfg(any(target_os = "linux", target_os = "macos", target_os = "windows"))]
#[cfg(any(target_os = "linux", target_os = "macos", target_os = "windows", target_os = "android"))]
extern crate hardware_wallet;

#[cfg(test)]
Expand Down
2 changes: 1 addition & 1 deletion rpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ extern crate rlp;
extern crate stats;
extern crate keccak_hash as hash;

#[cfg(any(target_os = "linux", target_os = "macos", target_os = "windows"))]
#[cfg(any(target_os = "linux", target_os = "macos", target_os = "windows", target_os = "android"))]
extern crate hardware_wallet;

extern crate patricia_trie as trie;
Expand Down
6 changes: 3 additions & 3 deletions rpc/src/v1/helpers/dispatch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ use v1::types::{
DecryptRequest as RpcDecryptRequest,
};

#[cfg(any(target_os = "linux", target_os = "macos", target_os = "windows"))]
#[cfg(any(target_os = "linux", target_os = "macos", target_os = "windows", target_os = "android"))]
use rlp;

pub use self::nonce::Reservations;
Expand Down Expand Up @@ -433,7 +433,7 @@ fn sign_transaction(
data: filled.data,
};

#[cfg(any(target_os = "linux", target_os = "macos", target_os = "windows"))]
#[cfg(any(target_os = "linux", target_os = "macos", target_os = "windows", target_os = "android"))]
{
if accounts.is_hardware_address(&filled.from) {
return hardware_signature(accounts, filled.from, t, chain_id).map(WithToken::No)
Expand Down Expand Up @@ -717,7 +717,7 @@ fn signature(accounts: &AccountProvider, address: Address, hash: H256, password:
}

// obtain a hardware signature from the given account.
#[cfg(any(target_os = "linux", target_os = "macos", target_os = "windows"))]
#[cfg(any(target_os = "linux", target_os = "macos", target_os = "windows", target_os = "android"))]
fn hardware_signature(accounts: &AccountProvider, address: Address, t: Transaction, chain_id: Option<u64>)
-> Result<SignedTransaction>
{
Expand Down

0 comments on commit 3b78b39

Please sign in to comment.