feat: ADBServerDevice without serial (#97)

* feat: ADBServerDevice without serial

* chore: bump deps

* actions: improve build
This commit is contained in:
cocool97
2025-03-09 19:33:20 +01:00
committed by GitHub
parent ad064a9f41
commit 1b7efc1cc6
26 changed files with 115 additions and 97 deletions

View File

@@ -14,7 +14,7 @@ adb_client = { version = "^2.0.0" }
anyhow = { version = "1.0.94" }
clap = { version = "4.5.23", features = ["derive"] }
env_logger = { version = "0.11.5" }
log = { version = "0.4.22" }
log = { version = "0.4.26" }
[target.'cfg(unix)'.dependencies]
termios = { version = "0.3.3" }

View File

@@ -7,12 +7,15 @@ mod handlers;
mod models;
mod utils;
use adb_client::{ADBDeviceExt, ADBServer, ADBTcpDevice, ADBUSBDevice, MDNSDiscoveryService};
use adb_client::{
ADBDeviceExt, ADBServer, ADBServerDevice, ADBTcpDevice, ADBUSBDevice, MDNSDiscoveryService,
};
use adb_termios::ADBTermios;
use anyhow::Result;
use clap::Parser;
use handlers::{handle_emulator_commands, handle_host_commands, handle_local_commands};
use models::{DeviceCommands, LocalCommand, MainCommand, Opts};
use std::collections::HashMap;
use std::fs::File;
use std::io::Write;
use std::path::Path;
@@ -30,11 +33,15 @@ fn main() -> Result<()> {
MainCommand::Host(server_command) => return Ok(handle_host_commands(server_command)?),
MainCommand::Emu(emulator_command) => return handle_emulator_commands(emulator_command),
MainCommand::Local(server_command) => {
let mut adb_server = ADBServer::new(server_command.address);
// 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());
}
let device = match server_command.serial {
Some(serial) => adb_server.get_device_by_name(&serial)?,
None => adb_server.get_device()?,
Some(serial) => ADBServerDevice::new(serial, Some(server_command.address)),
None => ADBServerDevice::autodetect(Some(server_command.address)),
};
match server_command.command {