feat: add Shell v2 protocol when the host supports Shell v2.

This commit is contained in:
wxitcode
2025-05-10 18:45:20 +08:00
committed by Corentin LIAUD
parent 22ceceb26a
commit c3e4ea9eb8
2 changed files with 13 additions and 2 deletions

View File

@@ -27,6 +27,7 @@ pub(crate) enum AdbServerCommand {
WaitForDevice(WaitForDeviceState, WaitForDeviceTransport),
// Local commands
ShellCommand(String),
Shellv2Command(String),
Shell,
FrameBuffer,
Sync,
@@ -55,6 +56,10 @@ impl Display for AdbServerCommand {
Ok(term) => write!(f, "shell,TERM={term},raw:{command}"),
Err(_) => write!(f, "shell,raw:{command}"),
},
AdbServerCommand::Shellv2Command(command) => match std::env::var("TERM") {
Ok(term) => write!(f, "shell,v2,TERM={term},raw:{command}"),
Err(_) => write!(f, "shell,raw:{command}"),
},
AdbServerCommand::Shell => match std::env::var("TERM") {
Ok(term) => write!(f, "shell,TERM={term},raw:"),
Err(_) => write!(f, "shell,raw:"),

View File

@@ -22,8 +22,14 @@ impl ADBDeviceExt for ADBServerDevice {
self.set_serial_transport()?;
self.transport
.send_adb_request(AdbServerCommand::ShellCommand(command.join(" ")))?;
let cmd = command.join(" ");
let server_command = if supported_features.contains(&HostFeatures::ShellV2) {
AdbServerCommand::Shellv2Command(cmd)
} else {
AdbServerCommand::ShellCommand(cmd)
};
self.transport.send_adb_request(server_command)?;
let mut buffer = vec![0; BUFFER_SIZE].into_boxed_slice();
loop {