Compare commits
8 Commits
wasm-suppo
...
v2.1.15
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0732a0bbad | ||
|
|
b5673001ca | ||
|
|
81829c1523 | ||
|
|
b9d2b8374f | ||
|
|
5716784f5d | ||
|
|
b6ddc720d8 | ||
|
|
5438e53361 | ||
|
|
39a7f0a8cf |
@@ -9,7 +9,7 @@ homepage = "https://github.com/cocool97/adb_client"
|
|||||||
keywords = ["adb", "android", "tcp", "usb"]
|
keywords = ["adb", "android", "tcp", "usb"]
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
repository = "https://github.com/cocool97/adb_client"
|
repository = "https://github.com/cocool97/adb_client"
|
||||||
version = "2.1.13"
|
version = "2.1.15"
|
||||||
|
|
||||||
# To build locally when working on a new release
|
# To build locally when working on a new release
|
||||||
[patch.crates-io]
|
[patch.crates-io]
|
||||||
|
|||||||
@@ -10,39 +10,32 @@ repository.workspace = true
|
|||||||
version.workspace = true
|
version.workspace = true
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
getrandom = { version = "*", features = ["js"] }
|
base64 = { version = "0.22.1" }
|
||||||
ring = { version = "*", features = ["wasm32_unknown_unknown_js"] }
|
|
||||||
|
|
||||||
bincode = { version = "1.3.3" }
|
bincode = { version = "1.3.3" }
|
||||||
base64 = { version = "0.22.1", optional = true }
|
byteorder = { version = "1.5.0" }
|
||||||
byteorder = { version = "1.5.0", optional = true }
|
|
||||||
chrono = { version = "0.4.40", default-features = false, features = ["std"] }
|
chrono = { version = "0.4.40", default-features = false, features = ["std"] }
|
||||||
homedir = { version = "0.3.4", optional = true }
|
homedir = { version = "= 0.3.4" }
|
||||||
image = { version = "0.25.5", default-features = false }
|
image = { version = "0.25.5", default-features = false }
|
||||||
log = { version = "0.4.26" }
|
log = { version = "0.4.26" }
|
||||||
mdns-sd = { version = "0.13.9", default-features = false, features = [
|
mdns-sd = { version = "0.13.9", default-features = false, features = [
|
||||||
"logging",
|
"logging",
|
||||||
], optional = true }
|
] }
|
||||||
num-bigint = { version = "0.8.4", package = "num-bigint-dig", optional = true }
|
num-bigint = { version = "0.8.4", package = "num-bigint-dig" }
|
||||||
num-traits = { version = "0.2.19", optional = true }
|
num-traits = { version = "0.2.19" }
|
||||||
quick-protobuf = { version = "0.8.1", optional = true }
|
quick-protobuf = { version = "0.8.1" }
|
||||||
rand = { version = "0.8.5", optional = true }
|
rand = { version = "0.9.0" }
|
||||||
rcgen = { version = "0.13.1", default-features = false, features = [
|
rcgen = { version = "0.13.1", default-features = false, features = [
|
||||||
"aws_lc_rs",
|
"aws_lc_rs",
|
||||||
"pem",
|
"pem",
|
||||||
], optional = true }
|
] }
|
||||||
regex = { version = "1.11.1", features = [
|
regex = { version = "1.11.1", features = ["perf", "std", "unicode"] }
|
||||||
"perf",
|
rsa = { version = "0.9.7" }
|
||||||
"std",
|
rusb = { version = "0.9.4", features = ["vendored"] }
|
||||||
"unicode",
|
rustls = { version = "0.23.27" }
|
||||||
], optional = true }
|
rustls-pki-types = { version = "1.11.0" }
|
||||||
rsa = { version = "0.9.7", optional = true }
|
|
||||||
rusb = { version = "0.9.4", features = ["vendored"], optional = true }
|
|
||||||
rustls = { version = "0.23.27", optional = true }
|
|
||||||
rustls-pki-types = { version = "1.11.0", optional = true }
|
|
||||||
serde = { version = "1.0.216", features = ["derive"] }
|
serde = { version = "1.0.216", features = ["derive"] }
|
||||||
serde_repr = { version = "0.1.19", optional = true }
|
serde_repr = { version = "0.1.19" }
|
||||||
sha1 = { version = "0.10.6", features = ["oid"], optional = true }
|
sha1 = { version = "0.10.6", features = ["oid"] }
|
||||||
thiserror = { version = "2.0.7" }
|
thiserror = { version = "2.0.7" }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ pub fn read_adb_private_key<P: AsRef<Path>>(private_key_path: P) -> Result<Optio
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Search for adb devices with known interface class and subclass values
|
/// Search for adb devices with known interface class and subclass values
|
||||||
fn search_adb_devices() -> Result<Option<(u16, u16)>> {
|
pub fn search_adb_devices() -> Result<Option<(u16, u16)>> {
|
||||||
let mut found_devices = vec![];
|
let mut found_devices = vec![];
|
||||||
for device in rusb::devices()?.iter() {
|
for device in rusb::devices()?.iter() {
|
||||||
let Ok(des) = device.device_descriptor() else {
|
let Ok(des) = device.device_descriptor() else {
|
||||||
@@ -57,7 +57,8 @@ fn search_adb_devices() -> Result<Option<(u16, u16)>> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_adb_device<T: UsbContext>(device: &Device<T>, des: &DeviceDescriptor) -> bool {
|
/// Check whether a device with given descriptor is an ADB device
|
||||||
|
pub fn is_adb_device<T: UsbContext>(device: &Device<T>, des: &DeviceDescriptor) -> bool {
|
||||||
const ADB_SUBCLASS: u8 = 0x42;
|
const ADB_SUBCLASS: u8 = 0x42;
|
||||||
const ADB_PROTOCOL: u8 = 0x1;
|
const ADB_PROTOCOL: u8 = 0x1;
|
||||||
|
|
||||||
@@ -180,6 +181,11 @@ impl ADBUSBDevice {
|
|||||||
self.get_transport_mut().write_message(message)?;
|
self.get_transport_mut().write_message(message)?;
|
||||||
|
|
||||||
let message = self.get_transport_mut().read_message()?;
|
let message = self.get_transport_mut().read_message()?;
|
||||||
|
// If the device returned CNXN instead of AUTH it does not require authentication,
|
||||||
|
// so we can skip the auth steps.
|
||||||
|
if message.header().command() == MessageCommand::Cnxn {
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
message.assert_command(MessageCommand::Auth)?;
|
message.assert_command(MessageCommand::Auth)?;
|
||||||
|
|
||||||
// At this point, we should have receive an AUTH message with arg0 == 1
|
// At this point, we should have receive an AUTH message with arg0 == 1
|
||||||
|
|||||||
@@ -35,10 +35,10 @@ impl<T: ADBMessageTransport> Write for MessageWriter<T> {
|
|||||||
Ok(response) => {
|
Ok(response) => {
|
||||||
response
|
response
|
||||||
.assert_command(MessageCommand::Okay)
|
.assert_command(MessageCommand::Okay)
|
||||||
.map_err(|e| Error::new(ErrorKind::Other, e))?;
|
.map_err(Error::other)?;
|
||||||
Ok(buf.len())
|
Ok(buf.len())
|
||||||
}
|
}
|
||||||
Err(e) => Err(Error::new(ErrorKind::Other, e)),
|
Err(e) => Err(Error::other(e)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,9 @@ mod shell_message_writer;
|
|||||||
use adb_message_device::ADBMessageDevice;
|
use adb_message_device::ADBMessageDevice;
|
||||||
pub use adb_tcp_device::ADBTcpDevice;
|
pub use adb_tcp_device::ADBTcpDevice;
|
||||||
pub use adb_transport_message::{ADBTransportMessage, ADBTransportMessageHeader};
|
pub use adb_transport_message::{ADBTransportMessage, ADBTransportMessageHeader};
|
||||||
pub use adb_usb_device::{ADBUSBDevice, get_default_adb_key_path};
|
pub use adb_usb_device::{
|
||||||
|
ADBUSBDevice, get_default_adb_key_path, is_adb_device, search_adb_devices,
|
||||||
|
};
|
||||||
pub use message_writer::MessageWriter;
|
pub use message_writer::MessageWriter;
|
||||||
pub use models::{ADBRsaKey, MessageCommand, MessageSubcommand};
|
pub use models::{ADBRsaKey, MessageCommand, MessageSubcommand};
|
||||||
pub use shell_message_writer::ShellMessageWriter;
|
pub use shell_message_writer::ShellMessageWriter;
|
||||||
|
|||||||
@@ -7,37 +7,21 @@
|
|||||||
mod adb_device_ext;
|
mod adb_device_ext;
|
||||||
mod constants;
|
mod constants;
|
||||||
mod device;
|
mod device;
|
||||||
mod error;
|
|
||||||
mod models;
|
|
||||||
mod transports;
|
|
||||||
|
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
|
||||||
mod emulator_device;
|
mod emulator_device;
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
mod error;
|
||||||
mod mdns;
|
mod mdns;
|
||||||
|
mod models;
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
|
||||||
mod server;
|
mod server;
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
|
||||||
mod server_device;
|
mod server_device;
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
mod transports;
|
||||||
mod utils;
|
mod utils;
|
||||||
|
|
||||||
pub use adb_device_ext::ADBDeviceExt;
|
pub use adb_device_ext::ADBDeviceExt;
|
||||||
pub use device::ADBUSBDevice;
|
pub use device::{ADBTcpDevice, ADBUSBDevice, is_adb_device, search_adb_devices};
|
||||||
pub use error::{Result, RustADBError};
|
|
||||||
pub use models::{AdbStatResponse, RebootType};
|
|
||||||
pub use transports::{ADBMessageTransport, ADBTransport};
|
|
||||||
|
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
|
||||||
pub use device::ADBTcpDevice;
|
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
|
||||||
pub use emulator_device::ADBEmulatorDevice;
|
pub use emulator_device::ADBEmulatorDevice;
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
pub use error::{Result, RustADBError};
|
||||||
pub use mdns::*;
|
pub use mdns::*;
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
pub use models::{AdbStatResponse, RebootType};
|
||||||
pub use server::*;
|
pub use server::*;
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
|
||||||
pub use server_device::ADBServerDevice;
|
pub use server_device::ADBServerDevice;
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
|
||||||
pub use transports::*;
|
pub use transports::*;
|
||||||
|
|||||||
@@ -42,18 +42,15 @@ impl<R: Read> Read for ADBRecvCommandReader<R> {
|
|||||||
let mut error_msg = vec![0; length];
|
let mut error_msg = vec![0; length];
|
||||||
self.inner.read_exact(&mut error_msg)?;
|
self.inner.read_exact(&mut error_msg)?;
|
||||||
|
|
||||||
Err(std::io::Error::new(
|
Err(std::io::Error::other(format!(
|
||||||
std::io::ErrorKind::Other,
|
"ADB request failed: {}",
|
||||||
format!(
|
String::from_utf8_lossy(&error_msg)
|
||||||
"ADB request failed: {}",
|
)))
|
||||||
String::from_utf8_lossy(&error_msg)
|
|
||||||
),
|
|
||||||
))
|
|
||||||
}
|
}
|
||||||
_ => Err(std::io::Error::new(
|
_ => Err(std::io::Error::other(format!(
|
||||||
std::io::ErrorKind::Other,
|
"Unknown response from device {:#?}",
|
||||||
format!("Unknown response from device {:#?}", header),
|
header
|
||||||
)),
|
))),
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Computing minimum to ensure to stop reading before next header...
|
// Computing minimum to ensure to stop reading before next header...
|
||||||
|
|||||||
Reference in New Issue
Block a user