5 Commits

Author SHA1 Message Date
LIAUD Corentin
8b4602c62f chore: version 2.1.11 2025-04-13 16:40:48 +02:00
cocool97
e917a45670 feat: edition 2024 (#106) 2025-04-13 16:38:38 +02:00
cocool97
b0303ad544 feat(ci): add windows + macos build (#105)
* feat(ci): add windows + macos build
2025-04-13 16:24:49 +02:00
LIAUD Corentin
f3f95d92c2 chore: v2.1.10 2025-03-12 17:27:02 +01:00
Cendy
886adfa392 feat: adb custom path (#101)
---------

Co-authored-by: LIAUD Corentin <corentinliaud26@gmail.com>
2025-03-12 17:26:13 +01:00
61 changed files with 195 additions and 115 deletions

2
.cargo/config.toml Normal file
View File

@@ -0,0 +1,2 @@
[target.aarch64-apple-darwin]
rustflags = ["-C", "link-arg=-undefined", "-C", "link-arg=dynamic_lookup"]

View File

@@ -10,9 +10,13 @@ env:
CARGO_TERM_COLOR: always
jobs:
build-release:
name: "build-release"
runs-on: ubuntu-latest
build:
name: "Build on ${{ matrix.os }}"
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- uses: actions/checkout@v4
- name: Build project

View File

@@ -4,46 +4,101 @@ on:
release:
types: [created]
env:
CARGO_TERM_COLOR: always
jobs:
create-release:
release-linux:
name: Linux - Build and Publish
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: "Set up Rust"
- name: Set up Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- name: "Install dependencies"
- name: Install dependencies
run: |
sudo apt update
sudo apt install -y rpm
cargo install cargo-deb
cargo install cargo-generate-rpm
- name: "Publish crates"
- name: Publish crates
run: |
cargo publish -p adb_client --token ${CRATES_IO_TOKEN}
cargo publish -p adb_cli --token ${CRATES_IO_TOKEN}
env:
CRATES_IO_TOKEN: ${{ secrets.CRATES_IO_TOKEN }}
- name: "build-release"
- name: Build release
run: cargo build --all-features --release
- name: "Build DEB package"
- name: Rename binary
run: mv target/release/adb_cli target/release/adb_cli-linux
- name: Build DEB package
run: cargo deb -p adb_cli
- name: "Build RPM package"
- name: Build RPM package
run: cargo generate-rpm -p adb_cli
- name: "Publish GitHub artefacts"
- name: Upload Linux artifacts
uses: softprops/action-gh-release@v2
with:
files: |
target/debian/*.deb
target/generate-rpm/*.rpm
target/release/adb_cli
target/release/adb_cli-linux
release-macos:
name: macOS - Build Binary
runs-on: macos-13
steps:
- uses: actions/checkout@v4
- name: Set up Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- name: Build release
run: cargo build --all-features --release
- name: Rename binary
run: mv target/release/adb_cli target/release/adb_cli-macos
- name: Upload macOS binary
uses: softprops/action-gh-release@v2
with:
files: target/release/adb_cli-macos
release-windows:
name: Windows - Build Binary
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- name: Set up Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- name: Build release
run: cargo build --all-features --release
- name: Rename binary
run: Rename-Item -Path target/release/adb_cli.exe -NewName adb_cli-windows.exe
- name: Upload Windows binary
uses: softprops/action-gh-release@v2
with:
files: target/release/adb_cli-windows.exe

View File

@@ -4,12 +4,12 @@ resolver = "2"
[workspace.package]
authors = ["Corentin LIAUD"]
edition = "2021"
edition = "2024"
homepage = "https://github.com/cocool97/adb_client"
keywords = ["adb", "android", "tcp", "usb"]
license = "MIT"
repository = "https://github.com/cocool97/adb_client"
version = "2.1.9"
version = "2.1.11"
# To build locally when working on a new release
[patch.crates-io]

View File

@@ -2,7 +2,7 @@
use std::os::unix::prelude::{AsRawFd, RawFd};
use termios::{tcsetattr, Termios, TCSANOW, VMIN, VTIME};
use termios::{TCSANOW, Termios, VMIN, VTIME, tcsetattr};
use crate::Result;

View File

@@ -1,7 +1,7 @@
use std::{fs::File, io::Write};
use adb_client::ADBServerDevice;
use anyhow::{anyhow, Result};
use anyhow::{Result, anyhow};
use crate::models::LocalDeviceCommand;

View File

@@ -10,7 +10,10 @@ mod utils;
use adb_client::{
ADBDeviceExt, ADBServer, ADBServerDevice, ADBTcpDevice, ADBUSBDevice, MDNSDiscoveryService,
};
#[cfg(any(target_os = "linux", target_os = "macos"))]
use adb_termios::ADBTermios;
use anyhow::Result;
use clap::Parser;
use handlers::{handle_emulator_commands, handle_host_commands, handle_local_commands};
@@ -36,7 +39,7 @@ fn main() -> Result<()> {
// Must start server to communicate with device, but only if this is a local one.
let server_address_ip = server_command.address.ip();
if server_address_ip.is_loopback() || server_address_ip.is_unspecified() {
ADBServer::start(&HashMap::default());
ADBServer::start(&HashMap::default(), &None);
}
let device = match server_command.serial {
@@ -47,7 +50,7 @@ fn main() -> Result<()> {
match server_command.command {
LocalCommand::DeviceCommands(device_commands) => (device.boxed(), device_commands),
LocalCommand::LocalDeviceCommand(local_device_command) => {
return handle_local_commands(device, local_device_command)
return handle_local_commands(device, local_device_command);
}
}
}
@@ -62,7 +65,9 @@ fn main() -> Result<()> {
None => ADBUSBDevice::autodetect()?,
},
_ => {
anyhow::bail!("please either supply values for both the --vendor-id and --product-id flags or none.");
anyhow::bail!(
"please either supply values for both the --vendor-id and --product-id flags or none."
);
}
};
(device.boxed(), usb_command.commands)
@@ -104,7 +109,7 @@ fn main() -> Result<()> {
#[cfg(not(any(target_os = "linux", target_os = "macos")))]
{
device.shell(std::io::stdin(), std::io::stdout())?;
device.shell(&mut std::io::stdin(), Box::new(std::io::stdout()))?;
}
} else {
let commands: Vec<&str> = commands.iter().map(|v| v.as_str()).collect();

View File

@@ -6,7 +6,7 @@ pub fn setup_logger(debug: bool) {
false => "info",
};
std::env::set_var("RUST_LOG", level);
unsafe { std::env::set_var("RUST_LOG", level) };
}
env_logger::init();

View File

@@ -2,9 +2,9 @@ use byteorder::{LittleEndian, ReadBytesExt};
use rand::Rng;
use std::io::{Cursor, Read, Seek};
use crate::{constants::BUFFER_SIZE, ADBMessageTransport, AdbStatResponse, Result, RustADBError};
use crate::{ADBMessageTransport, AdbStatResponse, Result, RustADBError, constants::BUFFER_SIZE};
use super::{models::MessageSubcommand, ADBTransportMessage, MessageCommand};
use super::{ADBTransportMessage, MessageCommand, models::MessageSubcommand};
/// Generic structure representing an ADB device reachable over an [`ADBMessageTransport`].
/// Structure is totally agnostic over which transport is truly used.
@@ -146,7 +146,7 @@ impl<T: ADBMessageTransport> ADBMessageDevice<T> {
return Err(RustADBError::ADBRequestFailed(format!(
"Wrong command received {}",
c
)))
)));
}
}
}

View File

@@ -1,4 +1,4 @@
use crate::{models::AdbStatResponse, ADBDeviceExt, ADBMessageTransport, RebootType, Result};
use crate::{ADBDeviceExt, ADBMessageTransport, RebootType, Result, models::AdbStatResponse};
use std::{
io::{Read, Write},
path::Path,

View File

@@ -2,9 +2,9 @@ use std::io::Write;
use std::path::Path;
use std::{io::Read, net::SocketAddr};
use super::ADBTransportMessage;
use super::adb_message_device::ADBMessageDevice;
use super::models::MessageCommand;
use super::ADBTransportMessage;
use crate::{ADBDeviceExt, ADBMessageTransport, ADBTransport, Result, TcpTransport};
/// Represent a device reached and available over USB.

View File

@@ -1,7 +1,7 @@
use rusb::constants::LIBUSB_CLASS_VENDOR_SPEC;
use rusb::Device;
use rusb::DeviceDescriptor;
use rusb::UsbContext;
use rusb::constants::LIBUSB_CLASS_VENDOR_SPEC;
use std::fs::read_to_string;
use std::io::Read;
use std::io::Write;
@@ -12,10 +12,10 @@ use std::time::Duration;
use super::adb_message_device::ADBMessageDevice;
use super::models::MessageCommand;
use super::{ADBRsaKey, ADBTransportMessage};
use crate::device::adb_transport_message::{AUTH_RSAPUBLICKEY, AUTH_SIGNATURE, AUTH_TOKEN};
use crate::ADBDeviceExt;
use crate::ADBMessageTransport;
use crate::ADBTransport;
use crate::device::adb_transport_message::{AUTH_RSAPUBLICKEY, AUTH_SIGNATURE, AUTH_TOKEN};
use crate::{Result, RustADBError, USBTransport};
pub fn read_adb_private_key<P: AsRef<Path>>(private_key_path: P) -> Result<Option<ADBRsaKey>> {
@@ -188,7 +188,7 @@ impl ADBUSBDevice {
v => {
return Err(RustADBError::ADBRequestFailed(format!(
"Received AUTH message with type != 1 ({v})"
)))
)));
}
};

View File

@@ -4,9 +4,9 @@ use byteorder::{LittleEndian, ReadBytesExt};
use image::{ImageBuffer, Rgba};
use crate::{
device::{adb_message_device::ADBMessageDevice, MessageCommand},
models::{FrameBufferInfoV1, FrameBufferInfoV2},
ADBMessageTransport, Result, RustADBError,
device::{MessageCommand, adb_message_device::ADBMessageDevice},
models::{FrameBufferInfoV1, FrameBufferInfoV2},
};
impl<T: ADBMessageTransport> ADBMessageDevice<T> {

View File

@@ -3,9 +3,9 @@ use std::{fs::File, path::Path};
use rand::Rng;
use crate::{
device::{adb_message_device::ADBMessageDevice, MessageWriter},
utils::check_extension_is_apk,
ADBMessageTransport, Result,
device::{MessageWriter, adb_message_device::ADBMessageDevice},
utils::check_extension_is_apk,
};
impl<T: ADBMessageTransport> ADBMessageDevice<T> {

View File

@@ -1,11 +1,11 @@
use std::io::Write;
use crate::{
device::{
adb_message_device::ADBMessageDevice, models::MessageSubcommand, ADBTransportMessage,
MessageCommand,
},
ADBMessageTransport, Result, RustADBError,
device::{
ADBTransportMessage, MessageCommand, adb_message_device::ADBMessageDevice,
models::MessageSubcommand,
},
};
impl<T: ADBMessageTransport> ADBMessageDevice<T> {

View File

@@ -1,11 +1,11 @@
use std::io::Read;
use crate::{
device::{
adb_message_device::ADBMessageDevice, ADBTransportMessage, MessageCommand,
MessageSubcommand,
},
ADBMessageTransport, Result, RustADBError,
device::{
ADBTransportMessage, MessageCommand, MessageSubcommand,
adb_message_device::ADBMessageDevice,
},
};
impl<T: ADBMessageTransport> ADBMessageDevice<T> {

View File

@@ -1,6 +1,6 @@
use crate::{
device::{adb_message_device::ADBMessageDevice, MessageCommand},
ADBMessageTransport, RebootType, Result,
device::{MessageCommand, adb_message_device::ADBMessageDevice},
};
impl<T: ADBMessageTransport> ADBMessageDevice<T> {

View File

@@ -1,10 +1,10 @@
use std::io::{ErrorKind, Read, Write};
use crate::device::ShellMessageWriter;
use crate::Result;
use crate::device::ShellMessageWriter;
use crate::{
device::{ADBMessageDevice, ADBTransportMessage, MessageCommand},
ADBMessageTransport, RustADBError,
device::{ADBMessageDevice, ADBTransportMessage, MessageCommand},
};
impl<T: ADBMessageTransport> ADBMessageDevice<T> {

View File

@@ -1,5 +1,5 @@
use crate::{
device::adb_message_device::ADBMessageDevice, ADBMessageTransport, AdbStatResponse, Result,
ADBMessageTransport, AdbStatResponse, Result, device::adb_message_device::ADBMessageDevice,
};
impl<T: ADBMessageTransport> ADBMessageDevice<T> {

View File

@@ -1,4 +1,4 @@
use crate::{device::adb_message_device::ADBMessageDevice, ADBMessageTransport, Result};
use crate::{ADBMessageTransport, Result, device::adb_message_device::ADBMessageDevice};
impl<T: ADBMessageTransport> ADBMessageDevice<T> {
pub(crate) fn uninstall(&mut self, package_name: &str) -> Result<()> {

View File

@@ -11,7 +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::{get_default_adb_key_path, ADBUSBDevice};
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

@@ -1,8 +1,8 @@
use crate::{Result, RustADBError};
use base64::{engine::general_purpose::STANDARD, Engine};
use base64::{Engine, engine::general_purpose::STANDARD};
use num_bigint::{BigUint, ModInverse};
use num_traits::cast::ToPrimitive;
use num_traits::FromPrimitive;
use num_traits::cast::ToPrimitive;
use rsa::pkcs8::DecodePrivateKey;
use rsa::traits::PublicKeyParts;
use rsa::{Pkcs1v15Sign, RsaPrivateKey};

View File

@@ -2,7 +2,7 @@ use std::io::Write;
use crate::ADBMessageTransport;
use super::{models::MessageCommand, ADBTransportMessage};
use super::{ADBTransportMessage, models::MessageCommand};
/// [`Write`] trait implementation to hide underlying ADB protocol write logic for shell commands.
pub struct ShellMessageWriter<T: ADBMessageTransport> {

View File

@@ -1,4 +1,4 @@
use crate::{emulator_device::ADBEmulatorCommand, ADBEmulatorDevice, Result};
use crate::{ADBEmulatorDevice, Result, emulator_device::ADBEmulatorCommand};
impl ADBEmulatorDevice {
/// Send a SMS to this emulator with given content with given phone number

View File

@@ -1,4 +1,4 @@
use crate::{emulator_device::ADBEmulatorCommand, ADBEmulatorDevice, Result};
use crate::{ADBEmulatorDevice, Result, emulator_device::ADBEmulatorCommand};
impl ADBEmulatorDevice {
/// Send a SMS to this emulator with given content with given phone number

View File

@@ -33,19 +33,21 @@ impl MDNSDiscoveryService {
pub fn start(&mut self, sender: Sender<MDNSDevice>) -> Result<()> {
let receiver = self.daemon.browse(ADB_SERVICE_NAME)?;
let handle: JoinHandle<Result<()>> = std::thread::spawn(move || loop {
while let Ok(event) = receiver.recv() {
match event {
ServiceEvent::SearchStarted(_)
| ServiceEvent::ServiceRemoved(_, _)
| ServiceEvent::ServiceFound(_, _)
| ServiceEvent::SearchStopped(_) => {
// Ignoring these events. We are only interesting in found devices
continue;
}
ServiceEvent::ServiceResolved(service_info) => {
if let Err(e) = sender.send(MDNSDevice::from(service_info)) {
return Err(e.into());
let handle: JoinHandle<Result<()>> = std::thread::spawn(move || {
loop {
while let Ok(event) = receiver.recv() {
match event {
ServiceEvent::SearchStarted(_)
| ServiceEvent::ServiceRemoved(_, _)
| ServiceEvent::ServiceFound(_, _)
| ServiceEvent::SearchStopped(_) => {
// Ignoring these events. We are only interesting in found devices
continue;
}
ServiceEvent::ServiceResolved(service_info) => {
if let Err(e) = sender.send(MDNSDevice::from(service_info)) {
return Err(e.into());
}
}
}
}

View File

@@ -15,6 +15,9 @@ pub struct ADBServer {
pub(crate) socket_addr: Option<SocketAddrV4>,
/// adb-server start envs
pub(crate) envs: HashMap<String, String>,
/// Path to adb binary
/// If not set, will use adb from PATH
pub(crate) adb_path: Option<String>,
}
impl ADBServer {
@@ -24,13 +27,24 @@ impl ADBServer {
transport: None,
socket_addr: Some(address),
envs: HashMap::new(),
adb_path: None,
}
}
/// Instantiates a new [ADBServer] with a custom adb path
pub fn new_from_path(address: SocketAddrV4, adb_path: Option<String>) -> Self {
Self {
transport: None,
socket_addr: Some(address),
envs: HashMap::new(),
adb_path,
}
}
/// Start an instance of `adb-server`
pub fn start(envs: &HashMap<String, String>) {
pub fn start(envs: &HashMap<String, String>, adb_path: &Option<String>) {
// ADB Server is local, we start it if not already running
let mut command = Command::new("adb");
let mut command = Command::new(adb_path.as_deref().unwrap_or("adb"));
command.arg("start-server");
for (env_k, env_v) in envs.iter() {
command.env(env_k, env_v);
@@ -79,7 +93,7 @@ impl ADBServer {
};
if is_local_ip {
Self::start(&self.envs);
Self::start(&self.envs, &self.adb_path);
}
transport.connect()?;
@@ -91,7 +105,7 @@ impl ADBServer {
impl Drop for ADBServer {
fn drop(&mut self) {
if let Some(ref mut transport) = &mut self.transport {
if let Some(transport) = &mut self.transport {
let _ = transport.disconnect();
}
}

View File

@@ -1,4 +1,4 @@
use crate::{models::AdbServerCommand, ADBServer, Result, RustADBError};
use crate::{ADBServer, Result, RustADBError, models::AdbServerCommand};
use std::net::SocketAddrV4;
impl ADBServer {

View File

@@ -1,8 +1,8 @@
use std::io::Read;
use crate::{
models::AdbServerCommand, ADBEmulatorDevice, ADBServer, ADBServerDevice, DeviceLong,
DeviceShort, Result, RustADBError,
ADBEmulatorDevice, ADBServer, ADBServerDevice, DeviceLong, DeviceShort, Result, RustADBError,
models::AdbServerCommand,
};
impl ADBServer {

View File

@@ -1,4 +1,4 @@
use crate::{models::AdbServerCommand, ADBServer, Result, RustADBError};
use crate::{ADBServer, Result, RustADBError, models::AdbServerCommand};
use std::net::SocketAddrV4;
impl ADBServer {

View File

@@ -1,4 +1,4 @@
use crate::{models::AdbServerCommand, ADBServer, Result};
use crate::{ADBServer, Result, models::AdbServerCommand};
impl ADBServer {
/// Asks the ADB server to quit immediately.

View File

@@ -1,7 +1,7 @@
use std::io::BufRead;
use crate::{
models::AdbServerCommand, server::models::MDNSBackend, ADBServer, MDNSServices, Result,
ADBServer, MDNSServices, Result, models::AdbServerCommand, server::models::MDNSBackend,
};
const OPENSCREEN_MDNS_BACKEND: &str = "ADB_MDNS_OPENSCREEN";

View File

@@ -1,4 +1,4 @@
use crate::{models::AdbServerCommand, ADBServer, Result};
use crate::{ADBServer, Result, models::AdbServerCommand};
impl ADBServer {
/// Reconnect the device

View File

@@ -1,4 +1,4 @@
use crate::{models::AdbServerCommand, server::models::ServerStatus, ADBServer, Result};
use crate::{ADBServer, Result, models::AdbServerCommand, server::models::ServerStatus};
impl ADBServer {
/// Check ADB server status

View File

@@ -1,4 +1,4 @@
use crate::{models::AdbServerCommand, ADBServer, AdbVersion, Result};
use crate::{ADBServer, AdbVersion, Result, models::AdbServerCommand};
impl ADBServer {
/// Gets server's internal version number.

View File

@@ -1,5 +1,5 @@
use crate::{
models::AdbServerCommand, ADBServer, Result, WaitForDeviceState, WaitForDeviceTransport,
ADBServer, Result, WaitForDeviceState, WaitForDeviceTransport, models::AdbServerCommand,
};
impl ADBServer {

View File

@@ -1,4 +1,4 @@
use crate::{models::AdbServerCommand, ADBTransport, Result, TCPServerTransport};
use crate::{ADBTransport, Result, TCPServerTransport, models::AdbServerCommand};
use std::net::SocketAddrV4;
/// Represents a device connected to the ADB server.

View File

@@ -4,9 +4,9 @@ use std::{
};
use crate::{
ADBDeviceExt, Result, RustADBError,
constants::BUFFER_SIZE,
models::{AdbServerCommand, AdbStatResponse, HostFeatures},
ADBDeviceExt, Result, RustADBError,
};
use super::ADBServerDevice;

View File

@@ -1,4 +1,4 @@
use crate::{models::AdbServerCommand, ADBServerDevice, Result};
use crate::{ADBServerDevice, Result, models::AdbServerCommand};
impl ADBServerDevice {
/// Forward socket connection

View File

@@ -4,8 +4,8 @@ use byteorder::{LittleEndian, ReadBytesExt};
use image::{ImageBuffer, Rgba};
use crate::{
models::{AdbServerCommand, FrameBufferInfoV1, FrameBufferInfoV2},
ADBServerDevice, Result, RustADBError,
models::{AdbServerCommand, FrameBufferInfoV1, FrameBufferInfoV2},
};
impl ADBServerDevice {

View File

@@ -1,6 +1,6 @@
use crate::{
models::{AdbServerCommand, HostFeatures},
ADBServerDevice, Result,
models::{AdbServerCommand, HostFeatures},
};
impl ADBServerDevice {

View File

@@ -1,7 +1,7 @@
use std::{fs::File, io::Read, path::Path};
use crate::{
models::AdbServerCommand, server_device::ADBServerDevice, utils::check_extension_is_apk, Result,
Result, models::AdbServerCommand, server_device::ADBServerDevice, utils::check_extension_is_apk,
};
impl ADBServerDevice {

View File

@@ -1,6 +1,6 @@
use crate::{
models::{AdbServerCommand, SyncCommand},
ADBServerDevice, Result,
models::{AdbServerCommand, SyncCommand},
};
use byteorder::{ByteOrder, LittleEndian};
use std::{

View File

@@ -1,6 +1,6 @@
use crate::{
models::{AdbServerCommand, RebootType},
ADBServerDevice, Result,
models::{AdbServerCommand, RebootType},
};
impl ADBServerDevice {

View File

@@ -1,4 +1,4 @@
use crate::{models::AdbServerCommand, ADBServerDevice, Result};
use crate::{ADBServerDevice, Result, models::AdbServerCommand};
impl ADBServerDevice {
/// Reconnect device

View File

@@ -1,7 +1,6 @@
use crate::{
constants,
ADBServerDevice, Result, constants,
models::{AdbServerCommand, SyncCommand},
ADBServerDevice, Result,
};
use byteorder::{LittleEndian, ReadBytesExt};
use std::io::{BufReader, BufWriter, Read, Write};

View File

@@ -1,4 +1,4 @@
use crate::{models::AdbServerCommand, ADBServerDevice, Result};
use crate::{ADBServerDevice, Result, models::AdbServerCommand};
impl ADBServerDevice {
/// Reverse socket connection

View File

@@ -1,7 +1,6 @@
use crate::{
constants,
ADBServerDevice, Result, RustADBError, constants,
models::{AdbRequestStatus, AdbServerCommand, SyncCommand},
ADBServerDevice, Result, RustADBError,
};
use std::{
convert::TryInto,

View File

@@ -3,8 +3,8 @@ use std::io::{Read, Write};
use byteorder::{ByteOrder, LittleEndian};
use crate::{
models::{AdbServerCommand, AdbStatResponse, SyncCommand},
ADBServerDevice, Result, RustADBError,
models::{AdbServerCommand, AdbStatResponse, SyncCommand},
};
impl ADBServerDevice {

View File

@@ -1,4 +1,4 @@
use crate::{models::AdbServerCommand, ADBServerDevice, Result};
use crate::{ADBServerDevice, Result, models::AdbServerCommand};
impl ADBServerDevice {
/// Set adb daemon to tcp/ip mode

View File

@@ -1,4 +1,4 @@
use crate::{models::AdbServerCommand, ADBServerDevice, Result};
use crate::{ADBServerDevice, Result, models::AdbServerCommand};
impl ADBServerDevice {
/// Asks ADB server to switch the connection to either the device or emulator connect to/running on the host. Will fail if there is more than one such device/emulator available.

View File

@@ -1,6 +1,6 @@
use std::io::Read;
use crate::{models::AdbServerCommand, server_device::ADBServerDevice, Result};
use crate::{Result, models::AdbServerCommand, server_device::ADBServerDevice};
impl ADBServerDevice {
/// Uninstall a package from device

View File

@@ -1,4 +1,4 @@
use crate::{models::AdbServerCommand, ADBServerDevice, Result};
use crate::{ADBServerDevice, Result, models::AdbServerCommand};
impl ADBServerDevice {
/// Set adb daemon to usb mode

View File

@@ -7,7 +7,7 @@ use std::{
use homedir::my_home;
use super::ADBTransport;
use crate::{emulator_device::ADBEmulatorCommand, Result, RustADBError};
use crate::{Result, RustADBError, emulator_device::ADBEmulatorCommand};
/// Emulator transport running on top on TCP.
#[derive(Debug)]

View File

@@ -5,7 +5,7 @@ use std::str::FromStr;
use byteorder::{ByteOrder, LittleEndian};
use crate::models::{AdbRequestStatus, SyncCommand};
use crate::{models::AdbServerCommand, ADBTransport};
use crate::{ADBTransport, models::AdbServerCommand};
use crate::{Result, RustADBError};
const DEFAULT_SERVER_IP: Ipv4Addr = Ipv4Addr::new(127, 0, 0, 1);

View File

@@ -1,16 +1,16 @@
use rcgen::{CertificateParams, KeyPair, PKCS_RSA_SHA256};
use rustls::{
client::danger::{HandshakeSignatureValid, ServerCertVerified, ServerCertVerifier},
pki_types::{pem::PemObject, CertificateDer, PrivatePkcs8KeyDer},
ClientConfig, ClientConnection, KeyLogFile, SignatureScheme, StreamOwned,
client::danger::{HandshakeSignatureValid, ServerCertVerified, ServerCertVerifier},
pki_types::{CertificateDer, PrivatePkcs8KeyDer, pem::PemObject},
};
use super::{ADBMessageTransport, ADBTransport};
use crate::{
device::{
get_default_adb_key_path, ADBTransportMessage, ADBTransportMessageHeader, MessageCommand,
},
Result, RustADBError,
device::{
ADBTransportMessage, ADBTransportMessageHeader, MessageCommand, get_default_adb_key_path,
},
};
use std::{
fs::read_to_string,
@@ -125,7 +125,7 @@ impl TcpTransport {
None => {
return Err(RustADBError::UpgradeError(
"cannot upgrade a non-existing connection...".into(),
))
));
}
};
@@ -162,7 +162,7 @@ impl TcpTransport {
CurrentConnection::Tls(_) => {
return Err(RustADBError::UpgradeError(
"cannot upgrade a TLS connection...".into(),
))
));
}
}
}

View File

@@ -1,7 +1,7 @@
use std::time::Duration;
use super::ADBTransport;
use crate::{device::ADBTransportMessage, Result};
use crate::{Result, device::ADBTransportMessage};
const DEFAULT_READ_TIMEOUT: Duration = Duration::from_secs(u64::MAX);
const DEFAULT_WRITE_TIMEOUT: Duration = Duration::from_secs(2);

View File

@@ -1,14 +1,14 @@
use std::{sync::Arc, time::Duration};
use rusb::{
constants::LIBUSB_CLASS_VENDOR_SPEC, Device, DeviceHandle, Direction, GlobalContext,
TransferType,
Device, DeviceHandle, Direction, GlobalContext, TransferType,
constants::LIBUSB_CLASS_VENDOR_SPEC,
};
use super::{ADBMessageTransport, ADBTransport};
use crate::{
device::{ADBTransportMessage, ADBTransportMessageHeader, MessageCommand},
Result, RustADBError,
device::{ADBTransportMessage, ADBTransportMessageHeader, MessageCommand},
};
#[derive(Clone, Debug)]

View File

@@ -1,7 +1,7 @@
use adb_client::ADBServer;
use anyhow::Result;
use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion};
use rand::{rng, Rng};
use criterion::{BenchmarkId, Criterion, criterion_group, criterion_main};
use rand::{Rng, rng};
use std::fs::File;
use std::io::Write;
use std::process::Command;

View File

@@ -21,7 +21,7 @@ name = "stub_gen"
[dependencies]
adb_client = { path = "../adb_client" }
anyhow = { version = "1.0.95" }
pyo3 = { version = "0.23.4", features = [
pyo3 = { version = "0.24.1", features = [
"abi3-py37",
"anyhow",
"extension-module",

View File

@@ -2,7 +2,7 @@ use std::net::SocketAddrV4;
use adb_client::ADBServer;
use anyhow::Result;
use pyo3::{pyclass, pymethods, PyResult};
use pyo3::{PyResult, pyclass, pymethods};
use pyo3_stub_gen_derive::{gen_stub_pyclass, gen_stub_pymethods};
use crate::{PyADBServerDevice, PyDeviceShort};