-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: implement adb pull for usb (#42)
* feat: implement adb pull for usb * feat: add subcommands for pull and shell * feat: add recv method to `ADBDeviceExt` trait, use existing impl for server * feat: merge stat commands for server and usb `impl`s * feat: improve shell; fix: minor rewording * fix: reply with quit usb subcommand at the end of a transaction * fix: adb stat works on a file, not always an apk * fix: ignore extra stat field for now --------- Co-authored-by: LIAUD Corentin <[email protected]>
- Loading branch information
Showing
12 changed files
with
311 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
use byteorder::ByteOrder; | ||
use chrono::{DateTime, Utc}; | ||
use std::{ | ||
fmt::Display, | ||
time::{Duration, UNIX_EPOCH}, | ||
}; | ||
|
||
use byteorder::LittleEndian; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
#[derive(Debug, Deserialize, Serialize)] | ||
pub struct AdbStatResponse { | ||
pub file_perm: u32, | ||
pub file_size: u32, | ||
pub mod_time: u32, | ||
} | ||
|
||
impl From<[u8; 12]> for AdbStatResponse { | ||
fn from(value: [u8; 12]) -> Self { | ||
Self { | ||
file_perm: LittleEndian::read_u32(&value[0..4]), | ||
file_size: LittleEndian::read_u32(&value[4..8]), | ||
mod_time: LittleEndian::read_u32(&value[8..]), | ||
} | ||
} | ||
} | ||
|
||
impl Display for AdbStatResponse { | ||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
let d = UNIX_EPOCH + Duration::from_secs(self.mod_time.into()); | ||
// Create DateTime from SystemTime | ||
let datetime = DateTime::<Utc>::from(d); | ||
|
||
writeln!(f, "File permissions: {}", self.file_perm)?; | ||
writeln!(f, "File size: {} bytes", self.file_size)?; | ||
write!( | ||
f, | ||
"Modification time: {}", | ||
datetime.format("%Y-%m-%d %H:%M:%S.%f %Z") | ||
)?; | ||
Ok(()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.