Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6210a6a587 |
@@ -6,7 +6,7 @@ resolver = "2"
|
|||||||
edition = "2021"
|
edition = "2021"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
repository = "https://github.com/cocool97/adb_client"
|
repository = "https://github.com/cocool97/adb_client"
|
||||||
version = "1.0.6"
|
version = "1.0.5"
|
||||||
|
|
||||||
# To build locally when working on a new version
|
# To build locally when working on a new version
|
||||||
[patch.crates-io]
|
[patch.crates-io]
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ repository.workspace = true
|
|||||||
version.workspace = true
|
version.workspace = true
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
adb_client = { version = "1.0.6" }
|
adb_client = { version = "1.0.5" }
|
||||||
anyhow = { version = "1.0.86" }
|
anyhow = { version = "1.0.86" }
|
||||||
clap = { version = "4.5.17", features = ["derive"] }
|
clap = { version = "4.5.17", features = ["derive"] }
|
||||||
env_logger = { version = "0.11.5" }
|
env_logger = { version = "0.11.5" }
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ pub enum HostCommand {
|
|||||||
/// Track new devices showing up.
|
/// Track new devices showing up.
|
||||||
TrackDevices,
|
TrackDevices,
|
||||||
/// Pair device with a given code
|
/// Pair device with a given code
|
||||||
Pair { address: SocketAddrV4, code: String },
|
Pair { address: SocketAddrV4, code: u32 },
|
||||||
/// Connect device over WI-FI
|
/// Connect device over WI-FI
|
||||||
Connect { address: SocketAddrV4 },
|
Connect { address: SocketAddrV4 },
|
||||||
/// Disconnect device over WI-FI
|
/// Disconnect device over WI-FI
|
||||||
|
|||||||
@@ -19,17 +19,17 @@ adb_client = "*"
|
|||||||
|
|
||||||
### Launch a command on device via ADB server
|
### Launch a command on device via ADB server
|
||||||
|
|
||||||
```rust no_run
|
```rust
|
||||||
use adb_client::ADBServer;
|
use adb_client::ADBServer;
|
||||||
|
|
||||||
let mut server = ADBServer::default();
|
let mut server = ADBServer::default();
|
||||||
let mut device = server.get_device().expect("cannot get device");
|
let mut device = server.get_device().expect("cannot get device");
|
||||||
device.shell_command(["df", "-h"],std::io::stdout());
|
device.shell_command(["df", "-h"]);
|
||||||
```
|
```
|
||||||
|
|
||||||
### Get available ADB devices
|
### Get available ADB devices
|
||||||
|
|
||||||
```rust no_run
|
```rust
|
||||||
use adb_client::ADBServer;
|
use adb_client::ADBServer;
|
||||||
use std::net::{SocketAddrV4, Ipv4Addr};
|
use std::net::{SocketAddrV4, Ipv4Addr};
|
||||||
|
|
||||||
@@ -43,7 +43,7 @@ server.devices();
|
|||||||
|
|
||||||
### Push a file to the device
|
### Push a file to the device
|
||||||
|
|
||||||
```rust no_run
|
```rust
|
||||||
use adb_client::ADBServer;
|
use adb_client::ADBServer;
|
||||||
use std::net::Ipv4Addr;
|
use std::net::Ipv4Addr;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ pub(crate) enum AdbServerCommand {
|
|||||||
HostFeatures,
|
HostFeatures,
|
||||||
Connect(SocketAddrV4),
|
Connect(SocketAddrV4),
|
||||||
Disconnect(SocketAddrV4),
|
Disconnect(SocketAddrV4),
|
||||||
Pair(SocketAddrV4, String),
|
Pair(SocketAddrV4, u32),
|
||||||
TransportAny,
|
TransportAny,
|
||||||
TransportSerial(String),
|
TransportSerial(String),
|
||||||
// Local commands
|
// Local commands
|
||||||
@@ -50,20 +50,9 @@ impl Display for AdbServerCommand {
|
|||||||
AdbServerCommand::Connect(addr) => write!(f, "host:connect:{}", addr),
|
AdbServerCommand::Connect(addr) => write!(f, "host:connect:{}", addr),
|
||||||
AdbServerCommand::Disconnect(addr) => write!(f, "host:disconnect:{}", addr),
|
AdbServerCommand::Disconnect(addr) => write!(f, "host:disconnect:{}", addr),
|
||||||
AdbServerCommand::Pair(addr, code) => {
|
AdbServerCommand::Pair(addr, code) => {
|
||||||
write!(f, "host:pair:{code}:{addr}")
|
write!(f, "host:pair:{code}:{}", addr)
|
||||||
}
|
}
|
||||||
AdbServerCommand::FrameBuffer => write!(f, "framebuffer:"),
|
AdbServerCommand::FrameBuffer => write!(f, "framebuffer:"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_pair_command() {
|
|
||||||
let host = "192.168.0.197:34783";
|
|
||||||
let code = "091102";
|
|
||||||
let code_u32 = code.parse::<u32>().expect("cannot parse u32");
|
|
||||||
let pair = AdbServerCommand::Pair(host.parse().expect("cannot parse host"), code.into());
|
|
||||||
|
|
||||||
assert_eq!(pair.to_string(), format!("host:pair:{code}:{host}"));
|
|
||||||
assert_ne!(pair.to_string(), format!("host:pair:{code_u32}:{host}"))
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ use std::net::SocketAddrV4;
|
|||||||
|
|
||||||
impl ADBServer {
|
impl ADBServer {
|
||||||
/// Pair device on a specific port with a generated 'code'
|
/// Pair device on a specific port with a generated 'code'
|
||||||
pub fn pair(&mut self, address: SocketAddrV4, code: String) -> Result<()> {
|
pub fn pair(&mut self, address: SocketAddrV4, code: u32) -> Result<()> {
|
||||||
let response = self
|
let response = self
|
||||||
.connect()?
|
.connect()?
|
||||||
.proxy_connection(AdbServerCommand::Pair(address, code), true)?;
|
.proxy_connection(AdbServerCommand::Pair(address, code), true)?;
|
||||||
|
|||||||
Reference in New Issue
Block a user