Skip to content

Commit 1d1e9b1

Browse files
committed
Merge branch 'main' into usb-backends
2 parents 267d740 + 36097fd commit 1d1e9b1

File tree

23 files changed

+193
-76
lines changed

23 files changed

+193
-76
lines changed

.github/workflows/rust-build.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,11 @@ jobs:
1919

2020
steps:
2121
- uses: actions/checkout@v4
22+
23+
- name: Set up Python
24+
uses: actions/setup-python@v5
25+
with:
26+
python-version: "3.10"
27+
2228
- name: Build project
2329
run: cargo build --release --all-features

.github/workflows/rust-release.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,11 @@ jobs:
9292
toolchain: stable
9393
override: true
9494

95+
- name: Set up Python
96+
uses: actions/setup-python@v5
97+
with:
98+
python-version: "3.10"
99+
95100
- name: Build release
96101
run: cargo build --all-features --release
97102

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ homepage = "https://github.com/cocool97/adb_client"
99
keywords = ["adb", "android", "tcp", "usb"]
1010
license = "MIT"
1111
repository = "https://github.com/cocool97/adb_client"
12-
version = "2.1.17"
12+
version = "2.1.18"
1313
rust-version = "1.85.1"
1414

1515
# To build locally when working on a new release

adb_cli/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ version.workspace = true
1313
[dependencies]
1414
adb_client = { version = "^2.1.17", features = ["mdns", "rusb"] }
1515
anyhow = { version = "1.0.100" }
16-
clap = { version = "4.5.49", features = ["derive"] }
16+
clap = { version = "4.5.51", features = ["derive"] }
1717
env_logger = { version = "0.11.8" }
1818
log = { version = "0.4.28" }
1919

adb_cli/src/main.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,10 @@ fn main() -> Result<()> {
8282
(device.boxed(), usb_command.commands)
8383
}
8484
MainCommand::Tcp(tcp_command) => {
85-
let device = ADBTcpDevice::new(tcp_command.address)?;
85+
let device = match tcp_command.path_to_private_key {
86+
Some(pk) => ADBTcpDevice::new_with_custom_private_key(tcp_command.address, pk)?,
87+
None => ADBTcpDevice::new(tcp_command.address)?,
88+
};
8689
(device.boxed(), tcp_command.commands)
8790
}
8891
MainCommand::Mdns => {

adb_cli/src/models/tcp.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
use clap::Parser;
22
use std::net::SocketAddr;
3+
use std::path::PathBuf;
34

45
use super::DeviceCommands;
56

67
#[derive(Parser, Debug)]
78
pub struct TcpCommand {
89
pub address: SocketAddr,
10+
/// Path to a custom private key to use for authentication
11+
#[clap(short = 'k', long = "private-key")]
12+
pub path_to_private_key: Option<PathBuf>,
913
#[clap(subcommand)]
1014
pub commands: DeviceCommands,
1115
}

adb_client/Cargo.toml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ webusb = ["dep:webusb-web", "dep:rsa"]
2222

2323
[dependencies]
2424
base64 = { version = "0.22.1" }
25-
bincode = { version = "1.3.3" }
25+
bincode = { version = "2.0.1", features = ["serde"] }
2626
byteorder = { version = "1.5.0" }
2727
chrono = { version = "0.4.42", default-features = false, features = ["std"] }
2828
image = { version = "0.25.8", default-features = false }
@@ -45,7 +45,7 @@ thiserror = { version = "2.0.17" }
4545

4646
#########
4747
# MDNS dependencies
48-
mdns-sd = { version = "0.13.11", default-features = false, features = [
48+
mdns-sd = { version = "0.17.0", default-features = false, features = [
4949
"logging",
5050
], optional = true }
5151
#########
@@ -57,13 +57,13 @@ rusb = { version = "0.9.4", features = ["vendored"], optional = true }
5757
#########
5858
# webusb dependencies
5959
webusb-web = { version = "0.4.1", optional = true }
60-
getrandom = { version = "0.2.16", features = ["js"] }
61-
ring = { version = "0.17.14", features = ["wasm32_unknown_unknown_js"] }
60+
getrandom = { version = "0.2.16", features = ["js"], optional = true }
61+
ring = { version = "0.17.14", features = ["wasm32_unknown_unknown_js"], optional = true }
6262

6363

6464
[dev-dependencies]
6565
anyhow = { version = "1.0.100" }
66-
criterion = { version = "0.6.0" } # Used for benchmarks
66+
criterion = { version = "0.7.0" } # Used for benchmarks
6767

6868
[[bench]]
6969
harness = false

adb_client/src/error.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ pub enum RustADBError {
6363
/// Unimplemented framebuffer image version
6464
#[error("Unimplemented framebuffer image version: {0}")]
6565
UnimplementedFramebufferImageVersion(u32),
66+
/// An error occurred while getting user's home directory
67+
#[error("Cannot get user home directory")]
68+
HomeError,
6669
/// Cannot get home directory
6770
#[error("Cannot get home directory")]
6871
NoHomeDirectory,

adb_client/src/mdns/mdns_device.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
use std::{collections::HashSet, net::IpAddr};
22

3+
use mdns_sd::{ResolvedService, ScopedIp};
4+
35
/// Represent a device found from mdns search
46
#[derive(Debug)]
57
pub struct MDNSDevice {
@@ -9,11 +11,11 @@ pub struct MDNSDevice {
911
pub addresses: HashSet<IpAddr>,
1012
}
1113

12-
impl From<mdns_sd::ServiceInfo> for MDNSDevice {
13-
fn from(value: mdns_sd::ServiceInfo) -> Self {
14+
impl From<Box<ResolvedService>> for MDNSDevice {
15+
fn from(value: Box<ResolvedService>) -> Self {
1416
Self {
15-
fullname: value.get_fullname().to_string(),
16-
addresses: value.get_addresses().to_owned(),
17+
fullname: value.fullname,
18+
addresses: value.addresses.iter().map(ScopedIp::to_ip_addr).collect(),
1719
}
1820
}
1921
}

adb_client/src/mdns/mdns_discovery.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ impl MDNSDiscoveryService {
4848
.send(MDNSDevice::from(service_info))
4949
.map_err(|_| RustADBError::SendError);
5050
}
51+
e => {
52+
log::warn!("received unknown event type {e:?}");
53+
}
5154
}
5255
}
5356
}

0 commit comments

Comments
 (0)