1 Commits

Author SHA1 Message Date
LIAUD Corentin
4ebbd99607 chore: bump criterion + pyo3 2025-05-24 13:47:46 +02:00
7 changed files with 19 additions and 24 deletions

View File

@@ -9,7 +9,7 @@ homepage = "https://github.com/cocool97/adb_client"
keywords = ["adb", "android", "tcp", "usb"]
license = "MIT"
repository = "https://github.com/cocool97/adb_client"
version = "2.1.14"
version = "2.1.13"
# To build locally when working on a new release
[patch.crates-io]

View File

@@ -14,7 +14,7 @@ base64 = { version = "0.22.1" }
bincode = { version = "1.3.3" }
byteorder = { version = "1.5.0" }
chrono = { version = "0.4.40", default-features = false, features = ["std"] }
homedir = { version = "= 0.3.4" }
homedir = { version = "0.3.4" }
image = { version = "0.25.5", default-features = false }
log = { version = "0.4.26" }
mdns-sd = { version = "0.13.9", default-features = false, features = [

View File

@@ -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
pub fn search_adb_devices() -> Result<Option<(u16, u16)>> {
fn search_adb_devices() -> Result<Option<(u16, u16)>> {
let mut found_devices = vec![];
for device in rusb::devices()?.iter() {
let Ok(des) = device.device_descriptor() else {
@@ -57,8 +57,7 @@ pub fn search_adb_devices() -> Result<Option<(u16, u16)>> {
}
}
/// Check whether a device with given descriptor is an ADB device
pub fn is_adb_device<T: UsbContext>(device: &Device<T>, des: &DeviceDescriptor) -> bool {
fn is_adb_device<T: UsbContext>(device: &Device<T>, des: &DeviceDescriptor) -> bool {
const ADB_SUBCLASS: u8 = 0x42;
const ADB_PROTOCOL: u8 = 0x1;
@@ -181,11 +180,6 @@ impl ADBUSBDevice {
self.get_transport_mut().write_message(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)?;
// At this point, we should have receive an AUTH message with arg0 == 1

View File

@@ -35,10 +35,10 @@ impl<T: ADBMessageTransport> Write for MessageWriter<T> {
Ok(response) => {
response
.assert_command(MessageCommand::Okay)
.map_err(Error::other)?;
.map_err(|e| Error::new(ErrorKind::Other, e))?;
Ok(buf.len())
}
Err(e) => Err(Error::other(e)),
Err(e) => Err(Error::new(ErrorKind::Other, e)),
}
}

View File

@@ -11,9 +11,7 @@ mod shell_message_writer;
use adb_message_device::ADBMessageDevice;
pub use adb_tcp_device::ADBTcpDevice;
pub use adb_transport_message::{ADBTransportMessage, ADBTransportMessageHeader};
pub use adb_usb_device::{
ADBUSBDevice, get_default_adb_key_path, is_adb_device, search_adb_devices,
};
pub use adb_usb_device::{ADBUSBDevice, get_default_adb_key_path};
pub use message_writer::MessageWriter;
pub use models::{ADBRsaKey, MessageCommand, MessageSubcommand};
pub use shell_message_writer::ShellMessageWriter;

View File

@@ -17,7 +17,7 @@ mod transports;
mod utils;
pub use adb_device_ext::ADBDeviceExt;
pub use device::{ADBTcpDevice, ADBUSBDevice, is_adb_device, search_adb_devices};
pub use device::{ADBTcpDevice, ADBUSBDevice};
pub use emulator_device::ADBEmulatorDevice;
pub use error::{Result, RustADBError};
pub use mdns::*;

View File

@@ -42,15 +42,18 @@ impl<R: Read> Read for ADBRecvCommandReader<R> {
let mut error_msg = vec![0; length];
self.inner.read_exact(&mut error_msg)?;
Err(std::io::Error::other(format!(
"ADB request failed: {}",
String::from_utf8_lossy(&error_msg)
)))
Err(std::io::Error::new(
std::io::ErrorKind::Other,
format!(
"ADB request failed: {}",
String::from_utf8_lossy(&error_msg)
),
))
}
_ => Err(std::io::Error::other(format!(
"Unknown response from device {:#?}",
header
))),
_ => Err(std::io::Error::new(
std::io::ErrorKind::Other,
format!("Unknown response from device {:#?}", header),
)),
}
} else {
// Computing minimum to ensure to stop reading before next header...