Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f3f95d92c2 | ||
|
|
886adfa392 |
@@ -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.9"
|
||||
version = "2.1.10"
|
||||
|
||||
# To build locally when working on a new release
|
||||
[patch.crates-io]
|
||||
|
||||
@@ -36,7 +36,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 {
|
||||
|
||||
@@ -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()?;
|
||||
|
||||
Reference in New Issue
Block a user